Skip to content

feat(threads): steer messages with attachments into the running turn - #393

Merged
nixuuu merged 1 commit into
devfrom
feat/steer-with-attachments
Nov 9, 2026
Merged

nixuuu merged 1 commit into
devfrom
feat/steer-with-attachments

Conversation

@nixuuu

@nixuuu nixuuu commented Nov 9, 2026 •

Copy link
Copy Markdown
Member

Messages with files can now join a running turn from the composer or the queue on web/desktop and mobile. The worker verifies and writes every file before calling the harness, and the composed input always contains the platform note with paths, quotes and mentions.

The steer and its outbox entry are committed together. A turn ending during transfer, a worker restart, or a harness refusal preserves the files and queues the message once; queue-origin steers restore the same queue entry. Older workers use an additive steer_attachments_v1 capability fallback. Linked computers carry the blobs to the thread's home and report an accurate note when an older home queues them. No migration or breaking WorkerLink protocol change is needed.

Grok ACP still has no supported mid-turn input operation: its steer is explicitly refused and the same message runs next with its files. Claude receives the paths in text; Codex also receives native local-image parts. This PR does not claim mid-turn support from Grok ACP.

Validation:

  • Gateway/worker integration covers Claude and Codex image/file delivery ordering, paths, quotes and mentions, queue steering, turn-end races, reconnect, restart, idempotent retries, owner scoping and Grok refusal. Linked-gateway coverage verifies home routing and older-home fallback.
  • Passed: bun install, bun run gen:check, bun run typecheck, bun run lint, bun run format:check, bun run check:tmp, and the web build. Focused mobile, quote, steer and attachment tests: 65 passed across 7 files. The full test run finished with 1880 passed, 161 skipped, 0 failed across 332 files; check:tmp reported nothing left in the temp dir.
  • Manual browser check on an isolated stack: light/dark at 1280 px and 390 px, queue row with a file, composer file upload, send menu, and successful composer/queue steer with attachment display. No UI test suite added.
  • Mobile changes are JS/TS only. bunx [email protected] fingerprint:generate --platform ios --build-profile production --json --non-interactive and the equivalent Android command produced unchanged hashes before/after: iOS 2a0ef03a2a0fda8e7fad2e3df8609803d2edbda3; Android c5c880ae8d0f5d7bc867fcbaf8f756b2ca56a07d. No EAS builds or APKs.

Copy audit (§8):

  • Disabled Steer with “A message with files runs as its own turn” → enabled “Steer” / “Steer now”, because files are delivered before steering.
  • “The turn ended…” remains specific to a turn-end fallback. An older home instead says “This computer cannot steer messages with files yet. Your message runs as the next turn.” An older worker adds the action “Update the worker to steer files.” Mobile shows the stored queue fallback reason.
  • The new failure message says what happened and what to do: “Could not steer the message. Check the queue, then try again.” Actions use verbs and sentence case. Sentences stay within the copy limits; existing glossary terms are reused, with no new terms or ornamental copy. No new empty states or confirmations. Status text does not depend on colour or icons. Short labels, typical message text and a long filename were checked at desktop and phone widths; the send menu wraps and file names truncate cleanly.

@nixuuu
nixuuu force-pushed the feat/steer-with-attachments branch from 84b1a53 to 30a6684 Compare November 9, 2026 10:31
@nixuuu
nixuuu merged commit 47641c6 into dev Nov 9, 2026
10 checks passed
@nixuuu
nixuuu deleted the feat/steer-with-attachments branch November 9, 2026 10:39
nixuuu added a commit that referenced this pull request Nov 9, 2026
Hovering or focusing an attachment now shows a compact preview; clicking
opens an image or text viewer. This covers inline sent-message chips,
composer drafts, queued messages and the queue editor. Markdown uses the
existing timeline renderer, with a device-persisted Rendered/Source
choice. Mobile sent messages and uploaded drafts reuse the native
text/Markdown viewer.

Text reads are lazy, session-cached and limited to 128 KiB / 2,000
lines. The additive owner-scoped GetAttachment preview flag bounds the
SQL read and follows qualified attachment IDs to their home computer.
Downloads retain the complete file. UTF-8 replacement decoding rejects
binary content; HTML stays text and web SVG stays in an img.

### Validation

- bun install; bun run gen:check; bun run typecheck; bun run lint; bun
run format:check; web build.
- Focused attachment/queue checks after rebasing: 56 pass / 0 fail
across 8 files, including composer/queue steer delivery with files,
ownership, restart recovery, bounded reads/full downloads, linked-home
routing and binary/UTF-8/content limits. No test temp files left.
- Full bun run check:tmp after rebasing: 1,886 pass / 161 skip / 0 fail
across 334 files (945.25 seconds), using a private disk-backed TMPDIR
under /var/tmp; no test temp files left.
- Real-browser checks in light/dark at desktop, narrow and phone widths:
short/long names, small/large/tall/wide images and SVG; text, JSON, a
large log, Markdown headings/code/tables/links, binary renamed .txt;
composer, queue and queue editor. Checked hover intent, pointer
transfer, keyboard focus/Escape/modal focus return, wrapping, copy
action, unchanged chip geometry and no horizontal overflow. Full log
download was 370,000 bytes; the preview was bounded. Script content
stayed inert.
- No UI test suites or screenshots added. Touch input, native-device
interaction and OS save/share sheets were not exercised; mobile
typecheck and the JS-only fingerprint checks passed. Existing mobile SVG
export behavior remains.

### Native fingerprints

Ran in apps/mobile for each platform:
`bunx [email protected] fingerprint:generate --platform <ios|android>
--build-profile production --json --non-interactive`

Before = after:
- iOS: `2a0ef03a2a0fda8e7fad2e3df8609803d2edbda3`
- Android: `c5c880ae8d0f5d7bc867fcbaf8f756b2ca56a07d`

Both commands were rerun after rebasing; both hashes remain unchanged.

### Rebase verification

Rebased onto dev through #393 and #399. Regenerated the combined
protobuf descriptor to resolve the only conflict. Reviewed composer,
queue Steer now, steered timeline attachments and mobile delivery:
steering with files and previews are both retained. Updated the
attachment documentation to describe text previews alongside steering.
All static checks, focused tests, full tests and the web build passed
after integrating #393. The final rebase added only #399's Windows
workflow/documentation changes; application and test code are identical
to the checked tree. #394–#396 were still open at the final pre-push
check.

### Copy audit — docs/copy.md §8

- Name/size tooltip or immediate download → content preview with Open /
Download actions: labels describe the attachment action.
- No Markdown mode → Rendered / Source: short mode labels, remembered on
this device.
- Unbounded file display → “Showing up to 128 KB and 2,000 lines.
Download for the full file.”: states the limit and next action.
- No binary/error preview state → “No text preview. Download the file to
open it.” and “Could not load the preview. Check the connection, then
retry.”: explain the outcome and recovery; Retry, Wrap lines, Copy text,
Zoom in/out and platform Save/Share use action labels.
- Audited all new/changed strings for sentence case, active voice,
glossary consistency, length, duplicate facts, loading/error guidance
and accessible labels/state. No new glossary term or decorative
sentence. Short/long names were checked at desktop and phone widths;
information does not rely on color or position.
nixuuu added a commit that referenced this pull request Nov 9, 2026
Mobile now answers thread secret requests and revokes saved grants. The
write-only sheet masks input, disables autofill and suggestions, clears
its native field and JS reference on send/close/background, and displays
only grant metadata and expiry.

Linked threads route the existing answer/revoke RPCs directly to their
home. Secret values stay excluded from relays and mirrors. No new RPC,
proto, native module, dependency or configuration change.

Validation:
- Paired-device secret integration: 2 passing tests, including owner
isolation, revoked devices, expiry metadata, decline, revoke, and
absence of values in responses/streams/tool results.
- Linked-thread integration passes, including routing qualified request
IDs home without putting values in mirrors.
- Full gate passes on the rebased top branch: install, gen:check,
typecheck, lint, format:check, check:tmp and web build. The full run
finished with 1,890 pass, 161 skip, zero failures and clean temp
cleanup. No UI tests or native builds.
- Production fingerprints before/after, EAS CLI 27.4.1: iOS
`2a0ef03a2a0fda8e7fad2e3df8609803d2edbda3`; Android
`c5c880ae8d0f5d7bc867fcbaf8f756b2ca56a07d`. Both unchanged.

Copy audit — docs/copy.md §8:
- Before: secret requests had no mobile action. After: “Provide secret”,
“Save securely”, “Decline”, “Revoke”, and an explicit 24-hour
explanation. Each action names its result; saved values have no display
control.
- Errors say what failed and how to retry, without transport details or
secret content. Existing glossary and sentence case retained; no
decorative copy or colour-only state.
- Static review covered short/typical/long labels and wrapping. The
device matrix below remains manual; native visuals were not verified in
this checkout.

Manual checks after a compatible OTA is available:
1. At 360/390 dp phone and 600/768 dp Fold widths, light/dark and
reduced motion, use 1/30/160-character labels. Check wrapping, compact
sheet scrolling, keyboard avoidance and fixed button alignment.
2. In a test gateway, save a non-sensitive test value, decline another
request, and revoke a saved grant. Confirm the field remains masked,
clears after sending, and saved values never appear; grant expiry is
readable.
3. Close/reopen the sheet, background the phone, and disconnect the
thread's home while typing. Confirm the field is cleared and unavailable
actions are disabled.
4. Repeat against a linked computer and a revoked paired device; the
automated owner-scoping tests cover rejection independently.

This is layer 1 of the independent normal-thread parity stack. The
latest rebase targets dev at `8fb894e4`, including #388–#390, #393, #398
and #399. Existing bases and ready-for-review states are preserved.
nixuuu added a commit that referenced this pull request Nov 9, 2026
Normal thread work is available from mobile: one shared action sheet
opens from the header or sidebar long press, queued messages can move or
steer immediately, and thread details expose usage, paths, grants,
schedules, worktrees and background tasks.

The action sheet respects confirmation preferences and uses the existing
lifecycle RPCs. Thread and queued-message deletion provide an 8-second
Undo; deleting an open thread or its parent navigates away and Undo can
reopen it. Queue ordering preserves platform turns and leaves the
default steer/queue preference unchanged.

Details show own-turn token/cost totals, label partial totals as “loaded
turns”, show the latest reported context window, and copy
directory/worktree paths with expo-clipboard. Schedule links filter the
existing editor to this thread. The worktree link opens the current
worktree without bulk cleanup controls. Paged snapshots retain
background task items outside the loaded turn window, so the list
survives reopening.

Validation:
- Gateway history integration: 7 passing tests, including background
task retention outside the tail page, reopening and page deduplication.
- Full gate passes on the rebased top branch: install, gen:check,
typecheck, lint, format:check, check:tmp and web build. The full run
finished with 1,890 pass, 161 skip, zero failures and clean temp
cleanup. No UI tests or native builds.
- Production fingerprints before/after, EAS CLI 27.4.1: iOS
`2a0ef03a2a0fda8e7fad2e3df8609803d2edbda3`; Android
`c5c880ae8d0f5d7bc867fcbaf8f756b2ca56a07d`. Both unchanged; no
dependencies or native configuration changed.

Copy audit — docs/copy.md §8:
- Before: queue edit/delete and “Steer now”. After: “Move up”, “Move
down”, “Move to top”, “Move to bottom” and “Undo” name the added
actions. Existing “Steer now” and “Move to a computer” wording is
preserved.
- “Delete thread?” repeats its verb in “Delete thread”; its description
explains side threads, stopped work, cancelled schedules and Undo.
“Usage · loaded turns” avoids claiming complete totals.
- Empty states and errors are short, actionable and use existing terms.
Long text wraps or truncates with full paths selectable; state also has
words. Static copy review completed; the visual matrix remains manual.

Manual checks after a compatible OTA is available:
1. Check 360/390 dp phone and 600/768 dp Fold widths, light/dark,
reduced motion, 1/30/160-character titles and 240-character paths. Check
overlays, scrolling, clipping and reserved control space.
2. Open actions from both entry points. Pin/unpin, regenerate, rename,
read/unread, archive/unarchive and delete; vary all three confirmation
preferences. Delete an open child through its parent and Undo. Confirm
the active goal has no duplicate menu control. Open “Move to a computer”
for a local thread and verify the existing preview/placement flow.
3. Queue four own messages with an intervening platform message. Move
each direction and to both ends; steer text and a message with files
during a running turn. Delete/Undo and edit a queued message, then
verify the delivery default still matches Settings. Send files with both
delivery choices and check the delivery note from a home that cannot
steer attachments. Open the landed image/text attachment previews.
4. Copy both paths and open schedules/current worktree. Check thread
scoping, add/edit/pause/resume/cancel a schedule, and verify worktree
status/removal still requires the existing safety confirmation.
5. Start background work, finish its foreground turn and reopen a long
thread. Stop the task from details and use “Show full output”; the
shared full-screen viewer reads inline or blob output and offers
Copy/Quote. Close it to return to details. Compare usage before/after
loading earlier turns.

The final rebase includes #377–#378 and #385. Background tasks now reuse
the landed TextViewer; there is no timeline-link fallback or separate
output viewer. Existing quote and send behavior is preserved.

Layer 2 of 3. Rebased onto dev at `8fb894e4`: preserves #393 attachment
steering, #398 previews and #388–#390 bot/settings parity, including the
local thread move action. Existing bases and ready-for-review states are
preserved.
nixuuu added a commit that referenced this pull request Nov 9, 2026
The phone update row now checks, downloads and explicitly applies
compatible OTA updates through the installed expo-updates APIs. Settings
and the update center share state, progress, errors and next-launch
deferral; the sidebar update indicator includes this phone.

Apply checks every mounted composer synchronously, including composers
under Settings, uploads, quote-only drafts, queued-message edits and
secret entry. Unsent work defers the update and explains how to proceed.
No automatic reload is introduced. “Apply next launch” keeps the current
session running.

Release notes use the same public GitHub release bodies as the desktop
changelog. The selected OTA manifest supplies the exact JS version;
missing metadata or rollback never substitutes a newer channel release.
Notes include retry and a GitHub link. No dependencies, native modules
or configuration changes.

Validation:
- Full gate passes on the rebased top branch: install, gen:check,
typecheck, lint, format:check, check:tmp and web build. The full run
finished with 1,890 pass, 161 skip, zero failures and clean temp
cleanup. No UI tests, native builds, EAS builds or APKs.
- Production fingerprints before/after, EAS CLI 27.4.1: iOS
`2a0ef03a2a0fda8e7fad2e3df8609803d2edbda3`; Android
`c5c880ae8d0f5d7bc867fcbaf8f756b2ca56a07d`. Both unchanged.
- Final stack fetched/rebased onto origin/dev at `8fb894e4`, including
#388–#390, #393, #398 and #399, before the full gate. Runtime behavior
and visuals require the manual checks below because installed simulator
clients cannot run this checkout.

Copy audit — docs/copy.md §8:
- Before: “Updates apply after you close and reopen Canopy.” After:
distinct “Check this phone for updates”, “Download update”, “Apply
update” and “Apply next launch” actions; the row distinguishes Not
checked / Available / Downloading / Ready / Next launch.
- Deferral explains the unsent draft/files and the next action. Errors
explain failure and retry; release notes identify the actual target and
handle unavailable notes explicitly. No new glossary term, decorative
copy or colour-only state.
- Static review covered short/long channel and version strings and
multiline messages. Native short/typical/long text and theme/width
checks remain manual.

Manual checks on a compatible production-runtime test client:
1. At 360/390 dp phone and 600/768 dp Fold widths, light/dark and
reduced motion, open both About and Updates. Check wrapping with long
versions, progress, fixed action columns and compact overlay scrolling.
2. Check with no update, offline, and with a compatible update.
Download, inspect the exact version's GitHub notes, defer, and confirm
the current session keeps running. Retry notes while offline and after
reconnecting.
3. With unsent text, a quote-only draft, a picked/uploading file, and a
draft in a composer underneath Settings, press Apply. It must defer
without reloading or losing work. Include a bot composer and a
queued-message edit where reachable.
4. Send or discard the unsent work, then Apply. Confirm one restart and
the expected JS version. Repeat by choosing next launch and fully
closing/reopening the app.
5. Check development builds show no OTA action; for rollback/missing
version metadata, confirm notes say unavailable and offer GitHub rather
than presenting an unrelated release.

Layer 3 of 3. Rebased onto dev at `8fb894e4`, including #388–#390, #393,
#398 and #399. Quote editing guards and quote-only OTA blockers coexist.
Existing bases and ready-for-review states are preserved; no OTA was
published manually.
nixuuu added a commit that referenced this pull request Nov 10, 2026
## Change

Sending a prompt as a turn ends can leave it accepted without ever
reaching the harness, or attach an unrelated Codex wake-up's summary to
the user's turn. Recover undelivered steers as their own queued turns
and bind Codex turn IDs using the response to the corresponding
`turn/start` RPC.

Two defects reproduce on the original code:

1. Gateway fallback only found `dropped` steers. A successful steer RPC
followed by `turnFinished` without a matching `userMessage.clientId`
remained `pending`/`accepted` indefinitely unless the worker separately
sent a rejection or `steer_dropped`. The same loss occurs when a short
subagent-report wake-up ends around the user's send. Queue pumping now
recovers these inputs idempotently, and the startup/periodic sweep also
finds them in already idle threads after a gateway restart. Late ACKs
cannot reverse recovery; confirmed steers remain delivered.
2. The Codex adapter assigned the next unknown `turn/started` to the
oldest pending platform input. A provider-started turn could consume
that slot before the actual `turn/start` response; its old-work summary
and completion then appeared under the user's turn ID. Only the RPC
response now establishes that mapping. Notifications wait per thread
until admission resolves, preserving order and independent provider
turns, including when admission fails. Runtime draining still waits for
buffered events to be journaled.

Existing UI delivery states now advance honestly: RPC acceptance still
waits for the user-message echo; confirmed echoes get “Steered into this
turn”; an unconsumed input publishes `queued`, `queuedTurnId` and the
existing fallback reason, then appears as its own turn. No UI
components, copy, contracts or database schemas changed.

Add concise JSON diagnostics for committed send decisions
(`message_decision`: new turn/steer/queue and a categorical reason),
steer acceptance/consumption/requeue/release, and turn start/end with
the persisted trigger (`user`, `agent_bus`, `background_task`, etc.).
Codex warns once per old turn about late model/lifecycle events while
allowing normal background-command output. These diagnostics contain
identifiers and states, without prompts, responses, paths, secrets or
provider error text.

The maintainer-provided logs around 2026-11-10 19:34 UTC confirm
repeated governor saturation (`active=5 queued=0 dropped=0`) but contain
no turn-level evidence identifying the incident's path. This counter
does not identify five subagents. Requests to an existing Codex
app-server use its established RPC transport; they do not reserve
process slots. A fixture test confirms new input still runs with all
harness slots occupied. New harness launches can encounter
back-pressure, and preparatory short operations can queue. The new
diagnostics are intended to resolve that uncertainty on recurrence. The
new wire sequences are scripted adversarial sequences, not a recording
of the incident.

## Verification

- Before the fix: turn-end integration reproduction had 1 pass / 3
failures (unconsumed steer with ACK before/after completion, overlapping
child-report wake-up). Both new adapter tests failed on the original
implementation: the prompt mapped to `wake-2`, and a rejected input
incorrectly acquired a provider turn.
- After the fix: one final `TMPDIR=/var/tmp bun run check:tmp`
invocation ran 83 tests across 10 files sequentially:
prompt-after-turn-end, Codex turn-boundaries and recorded mapping,
models-steer, steer-attachments, background-task-notes,
agent-bus-notify, queue-dispatch, worker-restart, durable-threads. All
passed; nothing remained in the private temp directory. Assertions
inspect the harness's actual input and echoed answer, delivered/queued
snapshot states, retry idempotence, restart recovery, structured
logging, late-event identity and background output.
- Passed `bun install --frozen-lockfile`, `bun run typecheck`, `bun run
lint`, `bun run format` and `bun run format:check`. Self-review
completed.
- Rebased cleanly onto latest `dev` (the intervening change affects
navigation), then repeated typecheck, lint, format check and the two new
regression files on the final head: 8 passed.
- Full unfiltered tests, the web build, browser/E2E and live inference
were not run under the task's resource/verification limits. No contract
changes required `gen:check`. No UI tests were added.

Copy audit (§8): no new or changed user-facing strings. Existing
acceptance, steered and queue-reason text is reused; only the gateway
state transition changed.

History inspection found these assumptions in the original
steering/adapter implementations; neither #393 nor #502 introduced them.
Those PRs are context only.

Related: #393
Related: #502
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