diff --git a/cli/internal/tui/app_commands.go b/cli/internal/tui/app_commands.go index 137a59e2a..c8cfe87cc 100644 --- a/cli/internal/tui/app_commands.go +++ b/cli/internal/tui/app_commands.go @@ -345,6 +345,17 @@ func (m *AppModel) handleCommandInvocation(msg tea.Msg) (tea.Cmd, bool) { return m.changeModelCmd(msg.Args, "", "", nil, m.ModelGen, ""), true } return m.openModelPicker(), true + case "/work", "/paperclips": + if m.ActiveSession == nil { + return nil, true + } + if strings.TrimSpace(msg.Args) == "" { + return func() tea.Msg { return ChatOpenPageMsg{Command: msg.Name} }, true + } + m.PageView = NewPageViewModel(m.Conn, m.ActiveSession.ID, msg.Name) + m.PageView.SetSize(m.Width, m.Height) + m.State = AppStatePageView + return m.PageView.shortcutCmd(msg.Args), true case "/link": if m.ActiveSession == nil { return nil, true diff --git a/cli/internal/tui/page_view.go b/cli/internal/tui/page_view.go index 628727d60..104c1cf68 100644 --- a/cli/internal/tui/page_view.go +++ b/cli/internal/tui/page_view.go @@ -36,6 +36,12 @@ type pageLoadedMsg struct { Gen int } +type pageShortcutPreparedMsg struct { + Prepared *daemon.PreparedPageAction + Err error + Gen int +} + type pageActionExecutedMsg struct { Prepared *PageDocument Err error @@ -214,6 +220,29 @@ func (m PageViewModel) Update(msg tea.Msg) (PageViewModel, tea.Cmd) { } return m, nil + case pageShortcutPreparedMsg: + if !m.settle(msg.Gen, msg.Err, &m.Busy) { + return m, nil + } + prepared := msg.Prepared + m.Doc = prepared.Page + m.Error = "" + if prepared.Request.Row != nil { + m.SelectedID = prepared.Request.Row.ID + } + act := prepared.Request.Action + if act.Confirm { + m.CurrentAction = &act + m.Mode = modeConfirm + return m, nil + } + m.FormValues = prepared.Request.Form + m.Generation = nextPageGeneration() + m.Busy = true + cmd := m.executeActionCmd(act, prepared.Request.Row, m.Generation) + m.FormValues = nil + return m, cmd + case pageActionExecutedMsg: if !m.settle(msg.Gen, msg.Err, &m.Busy) { return m, nil @@ -405,3 +434,11 @@ func (m PageViewModel) fieldChoices() []string { } return labels } + +func (m PageViewModel) shortcutCmd(arguments string) tea.Cmd { + conn, session, command, generation := m.Conn, m.SessionID, m.Command, m.Generation + return func() tea.Msg { + prepared, err := daemon.PreparePageShortcut(context.Background(), conn, session, command, arguments) + return pageShortcutPreparedMsg{Prepared: prepared, Err: err, Gen: generation} + } +} diff --git a/docs/http-api-design.md b/docs/http-api-design.md index f1ee57246..b1f639a30 100644 --- a/docs/http-api-design.md +++ b/docs/http-api-design.md @@ -1310,6 +1310,12 @@ their workspace-scoped create, read, update, and delete operations through trusted internal bindings. Work pages preserve linked-workspace labels and pending-work glances. +The CLI accepts `/work add