From a788dac5c673d3a886b35fdd721e02ca4fd38efc Mon Sep 17 00:00:00 2001 From: Aly Raffauf Date: Sat, 3 Oct 2026 20:46:36 -0400 Subject: [PATCH] feat(tui): wire work and paperclip action shortcuts Dispatch text shortcuts from the composer and retain deletion confirmation in the page view. Document the supported shortcut syntax. --- cli/internal/tui/app_commands.go | 11 ++++++++++ cli/internal/tui/page_view.go | 37 ++++++++++++++++++++++++++++++++ docs/http-api-design.md | 12 +++++++++++ 3 files changed, 60 insertions(+) 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 `, `/work edit <id> <title>`, +`/work status <id> <status>`, and `/work remove <id>` alongside page forms. +These shortcuts invoke the page's declared HTTP actions. Removal asks for +confirmation. Targeted shortcuts fetch the item even when it is outside the +first list page and retain its ETag through confirmation. + ### Paperclips | Path | Methods | @@ -1337,6 +1343,12 @@ Models can file, list, and resolve still-open or acknowledged items with a nonempty resolution. Human terminal decisions cannot be overwritten by a model. All edits use `If-Match`. Listings use newest-first cursor order and global glances. +The CLI accepts `/paperclips acknowledge <id>`, `/paperclips reply <id> <text>`, +`/paperclips resolve <id> [note]`, `/paperclips dismiss <id>`, and +`/paperclips remove <id>` through the same declared actions as page forms. +Removal asks for confirmation; a stale ETag returns a conflict without retrying +the mutation. + ### Schedule | Path | Methods | -- knotmirror 0.0.1