Skip to content

feat(native): composer menus, attachments, drafts, queued messages, stash - #37

Merged
rynfar merged 9 commits into
nativefrom
nw/w2-triggers
Nov 2, 2026
Merged

rynfar merged 9 commits into
nativefrom
nw/w2-triggers

Conversation

@rynfar

@rynfar rynfar commented Nov 2, 2026 •

Copy link
Copy Markdown
Owner

Problem

The native composer had no @, / or $ menus, could not attach anything, lost its text on every thread switch, and had no queued-message controls, stash or prompt history.

Approach

CO-TRIGGERS (crates/core/src/composer/menu.rs, crates/app/src/composer/menu.rs)

  • Trigger detection ported from detectComposerTrigger (path words, currency amounts, # boundaries), Escape dismissal from useComposerTriggerState, highlight rules from composerMenuHighlight.ts and nudgeComposerMenuHighlight.
  • @: threads ranked like the palette (matchComposerThreadItems) and projects.searchEntries results (80, 120ms debounce). Picking a file inserts [name](path) (serializeComposerFileLink); picking a thread inserts its t3-context:// link and sends a ThreadContextRecord while the link stays in the text.
  • /: /model, /plan, /default, provider commands (/compact only when it could run), and /skill:*, ranked by searchSlashCommandItems. Per-cwd skills and commands come from server.refreshProviders (workspaceSnapshotsOnDemand), one scan per TTL. /plan or /default sent alone switches the mode.
  • $: searchProviderSkills, with the source badge.
  • Keys take Up/Down/Enter/Tab/Escape through capture_action only while the menu is open, the prompt is focused and no IME composition is marked.
  • Placeholder is now the web's Ask anything. @ files, $ skills, / commands.
  • Go-to-file's Cmd+Enter mention (from feat(native): go-to-file, content search, projects, navigation, multi-select and drag #23) now lands in the prompt: the composer drains composer_mentions; the clipboard fallback is gone.

CO-ATTACH (crates/core/src/composer/attachments.rs, crates/app/src/composer/attachments.rs, crates/client/src/upload.rs)

  • Paste (images, copied Finder files), drop, and the paperclip (icon-sm ghost, shown when the server advertises fileAttachments).
  • Uploads: attachments.createUploadUrl, then POST to the signed URL on the network runtime. Strip with 64px thumbnails, file rows, Uploading/failed states, retry and remove (removal deletes an unsent upload).
  • Large pastes (32 KiB, or over the 120k-char limit) fold into pasted-text.txt; Cmd+Shift+V keeps them inline.
  • Sends carry ChatAttachments plus their image/file context records, the attachment-only prompt when there is no text, and the web's title seed (deriveThreadTitleSeed). A failed send puts text and attachments back.

CO-DRAFTS (crates/core/src/composer/drafts.rs, crates/app/src/composer/drafts.rs)

  • Each thread and new-thread draft keeps its prompt, model/permission/mode choices, mentioned threads and uploaded attachments across thread switches and restarts (composer-drafts.json under T3_NATIVE_HOME, atomic, 300ms debounce, empty drafts dropped, 200 max). A launched draft is discarded; an open question's answer or a queued edit never overwrites the draft.

CO-QUEUE (crates/core/src/composer/queue.rs, crates/app/src/composer/queue.rs)

  • deriveThreadQueueWorkflowState port (queue position order, notices skipped, guest messages read-only, steer only when the provider can). Dashed rows above the composer: Send now (queued-run.start or queued-message.promote-to-steer), Edit in the composer (saves with a text-only queued-run.edit, which keeps attachments; send reads "Update queued message"), Remove (queued-run.cancel), Show all after three. Run gains queuePosition (conformance builder + fixtures regenerated).

CO-STASH (crates/core/src/composer/stash.rs, crates/app/src/composer/stash.rs)

  • Mod+S (composer.stash) stashes prompt + mentions + uploaded attachments (20 max, oldest evicted with the web's toast); an empty composer restores the only entry or opens the list. Stash shoulder tab and attached list with keyboard navigation, restore (joins after a blank line) and delete.
  • Prompt history: Up/Down at the prompt's first/last line recall the user's own sent prompts in this thread (recallableComposerPrompt, stepComposerPromptHistory).

Not yet: # pull-request menu and machine mentions, HEIC conversion and image compression (refused with the web's copy), upload progress percentages, the image preview dialog, inline image chips, queued-row image thumbnails and the steer/edit-latest shortcuts, image previews for drafts and stash entries after a restart (they restore as name tiles), visual-line edges for history (logical lines here).

Ledger

CO-TRIGGERS, CO-ATTACH, CO-DRAFTS, CO-QUEUE, CO-STASH → partial.

Evidence

Headless against the smoke server (T3_NATIVE_HOME=.t3-smoke/native, free devReplay), via the new composer_probe example:

@comp: 80 entries (truncated: true)
  compileCache.ts              src
codex (codex): 65 skills, 3 commands, snapshot true
/: /model  /plan  /default  /goal  /feedback  /skill:contribution-triage ...
uploaded w2c-probe.png as pending-432cd345-…
launched 59502985-…
recorded: UserMessage { text: "Please read [README.md](README.md) and compare with [Approval Needed](t3-context://v1/thread/thread_2a65db46-…)",
  attachments: [{"type":"image","id":"59502985-…","name":"w2c-probe.png","mimeType":"image/png","sizeBytes":79}],
  context: {"records":[{"kind":"thread",…},{"kind":"image","attachmentId":"07a03839-…","contextId":"image_60d0…",…}]} }

The server persisted the upload and remapped the context record to the stored attachment.

Queue (composer_probe --queue <thread> on the smoke server):

dispatch: Ok(())
after queueing: can_send=true held=false queued=["run:thre=\"Queued one\"", "run:thre=\"Queued two\""]
edit: Ok("accepted")
cancel: Ok("accepted")
after edit and cancel: can_send=true held=false queued=["run:thre=\"Queued one, edited\""]

Offscreen screenshots (snapshot tool against the smoke server; this PR adds --new-thread, --attach and --prompt to it so the composer can be put into these states):

  • @ menu, threads then files, dark: /Volumes/DevSSD/t3code-native-w2-composer/.t3/w2c-snapshots/w2c-menu-at.png
  • / menu with Codex commands and /skill:* rows, dark: /Volumes/DevSSD/t3code-native-w2-composer/.t3/w2c-snapshots/w2c-menu-slash.png
  • Attachment strip (uploaded image thumbnail, file row with size and remove), dark: /Volumes/DevSSD/t3code-native-w2-composer/.t3/w2c-snapshots/w2c-attachments.png
  • New-thread draft with an image and the @ thread rows, light: /Volumes/DevSSD/t3code-native-w2-composer/.t3/w2c-snapshots/w2c-draft-light.png

Not captured: queued rows (devReplay drains the queue instantly) and the stash list (the snapshot's throwaway home has no stash).

Gates (after rebasing on native at #41): cargo test --workspace, cargo clippy --workspace --all-targets -- -D warnings, gen-theme --check, parity/sync.test.ts, conformance --check.

Worker W2c, Claude Opus 5.5 in Claude Code.

@rynfar rynfar changed the title feat(native): composer @ / $ menus and attachments feat(native): composer menus, attachments, drafts, queued messages, stash Nov 2, 2026
Images and files attach by paste, drop and the paperclip, upload through
attachments.createUploadUrl, and ride the turn with their context records.
Large pastes fold into pasted-text files. Go-to-file mentions now land in
the prompt instead of the clipboard.
Each thread and new-thread draft keeps its prompt, model, permission and
mode choices, mentioned threads and uploaded attachments across thread
switches, written atomically under T3_NATIVE_HOME after a 300ms debounce.
Messages waiting behind the active turn show above the composer as dashed
rows. Send now starts or steers, edit opens the text in the composer and
saves it with queued-run.edit, and remove cancels the run.
Mod+S parks the prompt with its mentions and uploaded attachments (twenty
deep, saved under T3_NATIVE_HOME); the Stash tab lists them to restore or
delete. Up and Down at the prompt's edges recall what was sent in the
thread.
… the composer

--new-thread, --attach and --prompt put the composer into the states worth a
screenshot: an open @, / or $ menu and the attachment strip.
@rynfar

rynfar commented Nov 2, 2026

Copy link
Copy Markdown
Owner Author

Rebased onto native (after #44 and #45). Every conflict keeps both sides' behavior:

  • Composer: feat(native): composer menus, attachments, drafts, queued messages, stash #37's trigger menus, attachment strip, drafts, queue and stash sit alongside feat(native): side chats, subagent lineage, child approvals, provider subagent bar #45's embedded side-chat composer (fixed), its subagent bar and its child-approval banners. Prompt history and /compact now read the composer's own thread through thread_state, so they also work in a side chat tab.
  • /side and /btw: new commit b8cb08f. They now open AppState::open_side_chat(Some(prompt)), following web useComposerSend: the menu shows them only where side chats are offered, a disabled reason replaces the description, and sending while unavailable shows a "Side chat not started" toast. Attachments or context show "Side chats take text only". /side takes precedence over an open question. parse_side_chat_command is tested in core.
  • Run: keeps both workspace_preparation and queue_position.
  • test-t3-native skill: keeps both the connect-screen note and the --new-thread/--attach/--prompt flags.

Gates: cargo test --workspace, clippy -D warnings, gen-theme --check, parity/sync.test.ts (42/42) and conformance --check all pass, the pre-commit lint passes and there are no conflict markers. A read-only snapshot against real data renders the composer with no panic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant