Repository navigation
feat(threads): choose the default follow-up message delivery - #380
Merged
Merged
Conversation
nixuuu
added a commit
that referenced
this pull request
Nov 9, 2026
Restore model, effort and permission from the last own user turn in web and mobile without changing thread defaults. Read owner-scoped choices only for single-thread snapshots and watches; keep listing metadata free of turn lookups. Add a partial index for eligible user turns and cover linked mirrors and long provider continuations. Related: #380
nixuuu
added a commit
that referenced
this pull request
Nov 9, 2026
## Change Reloading a thread reset its composer to the thread defaults, even after the user sent a turn with a different model or effort. Web and mobile now reopen with the last user turn's model, reasoning effort and permission mode. Explicit composer picks take precedence, followed by the last user turn, thread settings and existing defaults. The additive `Thread.last_user_turn_choices` field reads existing turn records independently of history pagination. It is owner-scoped, mirrored to linked computers, and excludes provider/agent turns, inherited fork history, withdrawn messages and shell commands. Hidden or missing models fall back to an available thread/default model; unsupported effort falls back to the model default. The pills show the applied selection. Choices are computed by a separate thread-id/owner query only for the single-thread snapshot and active watch updates. `threadSelect`, `ListThreads`, `GetThread`, overview, search and ordinary broadcast metadata do not compute or carry them. Linked mirrors keep them in the full snapshot and omit them from stored list/header metadata. The common thread-select/row/mapper files are identical to `dev`. An open watch refreshes choices after turn and title changes so metadata updates cannot reset the composer. Migration `0101_composer_turn_choices` adds a partial index on `(thread_id, author_user_id, ordinal DESC)` for non-withdrawn user turns without shell commands. Rebased onto fetched `dev` head `c2fad3aaf4b15dda122106eef960bcdc3fad3a30`. The highest migration on live `dev` was checked again immediately before pushing: `0100`, so this migration takes highest + 1. No local storage is used. Mobile sends the selection as a turn override instead of changing the thread defaults. Unsent picks remain drafts in memory; durability starts when a message creates a turn. New-thread defaults, placement and the steer/queue preference are unchanged. Related: #380 ## Verification - `bun install`, `bun run gen:check`, `bun run typecheck`, `bun run lint`, `bun run format:check`, and `bun run --filter @canopy/web build` passed. - Final plain `bun run check` on base `c2fad3aa` passed: **1942 pass, 161 skip, 0 fail**, 347 files; no retry flag, timeout changes or added test exclusions. `check:tmp` finished with nothing left in the test temp dir. The focused composer run passed 4 tests and the isolated linked-mirror run passed 20 tests with clean temporary-directory cleanup. - Gateway coverage includes a fresh core over the same database, last user choices outside the loaded history page, independent threads, owner-only reads, queued fallback values, withdrawn/shell exclusions, and linked-computer qualification of the turn id. Shared resolution covers explicit precedence, unavailable models, unsupported effort and models without effort. - Real-browser check on an isolated stack: changed High to Extra high, sent a message, reloaded and restarted web; Extra high and Read only remained. Switching to another thread showed its own Low/Ask first selection. Inspected light/dark at 1280×800 and 390×844 with short, typical and long thread titles. No horizontal overflow; model/effort/send bounds stayed fixed while changing effort in the open picker. No UI test suite was added. - Production fingerprints generated on the latest `dev` base (`c2fad3aa`) and again with this PR using `bunx [email protected] fingerprint:generate --platform <ios|android> --build-profile production --json --non-interactive`: unchanged on both platforms. iOS: `bf3156a1bd878e10c0b0be25d4c194a837fb1b7e`; Android: `d638e5f7b7fa87f54ccc0715c5fe150b8c0ad3ae`. The upstream channel-identity change altered the baseline hashes, so the comparison was repeated after rebasing. This PR's mobile changes are JS/TS only; no native device run. Earlier default full runs hit timeouts in shell-steer Stop/linked slow-read recovery, then in two Claude/Codex bot routine cases (1917 pass, 161 skip, 2 fail). The complete shell file passed with both the `dev` read path and this revision (17/17 each); the complete bot regression file passed separately (11/11). A full gate on intermediate base `2ffb6f04` passed with 1937 pass, 161 skip and 0 fail, using `--retry 1` without needing any retries. No assertion or source timeout was weakened. The earlier timeout causes have not been established, and those failed runs are not counted as successful gates. ## Database performance Before: PR head `38d24acba4e31054cd3683dcacf3f24990cb8f7d`. After: the snapshot/watch-only read path and partial index in this revision. Both measurements used base `4dfb2f859e25c88cb51e3af5684df3cb7b88cb8e`; the subsequent rebases onto `2ffb6f04` and `c2fad3aa` did not change the measured read statements or migrations. Both use the opt-in bench's private PostgreSQL 18.6 container (2 CPUs, 1536 MiB), 240 threads, 32 turns per ordinary thread, 2048 in the open thread, 4096-byte text, 2 warmups and 20 measured iterations. No live database was used. Commands, before and after: ```sh bun scripts/bench/db.ts --run --explain bun scripts/bench/db.ts --run --explain --agent-tail 2047 ``` The optional `--agent-tail` fixture leaves one user turn followed by 2047 provider turns in the long thread, and one user turn followed by 31 provider turns in each ordinary thread. The default fixture remains all user turns. The explain output now includes rows removed by filters. | Fixture | Operation | p50 ms before → after | p95 ms before → after | Queries before → after | | --- | --- | --- | --- | --- | | Default | sidebar/threads | 12.02 → 16.66 | 14.48 → 19.81 | 1 → 1 | | Default | thread/open-page | 27.86 → 26.14 | 34.37 → 33.92 | 10 → 11 | | Default | thread/open-full | 62.55 → 65.54 | 79.64 → 89.38 | 7 → 8 | | Agent tail | sidebar/threads | 14.38 → 16.92 | 20.64 → 20.32 | 1 → 1 | | Agent tail | thread/open-page | 24.72 → 44.22 | 26.61 → 56.30 | 10 → 11 | | Agent tail | thread/open-full | 55.92 → 110.94 | 87.39 → 161.69 | 7 → 8 | These shared-host runs do **not** establish an end-to-end latency improvement: the agent-heavy open timings worsened. The unchanged full-history turn and item statements also slowed from 18.442/5.079 ms to 33.507/9.135 ms in the diagnostic plans. The comparison is not a controlled latency A/B; the bounded-work evidence is: - Listing SQL is identical to `dev` and contains no composer query. Decoded JSON fell from 876,526 to 847,006 bytes per 240-thread list. Shared buffer hits per listing fell from about 4,905 to 4,185 in the default fixture and 5,156 to 4,185 with the agent tail. - Before, the composer subplan ran 240 times per list. On the long agent-tail thread, a bitmap scan through `turns_last_activity` visited 2048 turns and discarded 2047, then sorted the remaining result. The existing `(thread_id, ordinal)` unique index supports order but does not restrict eligible user inputs. - After, `EXPLAIN (ANALYZE, BUFFERS, FORMAT JSON)` shows `Index Scan using turns_composer_choices`, 1 row, 1 loop, 3 shared hits at the turns index node (5 for the complete query), no filtered agent rows or sort. The separate composer statement took 0.053 ms in the paged-open diagnostic pass (0.050 ms for full open). The snapshot intentionally pays one additional query; lists pay none. The index is created by the existing transactional migrator. Building it scans `turns` once and takes PostgreSQL's normal index-build write lock; no turn data is rewritten. Migration numbering will need reassignment if another migration merges ahead of this PR. ## Copy audit (§8) Before → after: a restored thread could show `Default` → it now shows the applied existing label, such as `High`, with the corresponding model and permission label. This corrects the displayed state without introducing new vocabulary or instructions. Removed the mobile “Could not update the thread. Try again.” message from the composer because picks now travel with the send; send failures retain the existing delivery error. No new buttons, confirmations, empty states or error text. Existing labels use sentence case, glossary terms and text cues independent of colour/icons. No duplicated facts or new editorial copy. Checked short, typical and long thread titles at desktop and phone widths; truncation and picker geometry remain tidy.
nixuuu
added a commit
that referenced
this pull request
Nov 10, 2026
Stage 2 of 2, stacked on stage 1 (the composer tray). The mobile send button now matches web/desktop while a turn runs. ## What changes - **Split Steer / Queue button** (web: `SteerSendButton`): with a running turn and a message in the field, the button reads "Steer" or "Queue", following Settings → Threads → Messages. Its main part sends that way; holding it sends the other way. The chevron opens "How to send" with "Steer into this turn" / "Queue for the next turn" and what each does, as in the web menu. It replaces the previous separate alternate icon plus a round icon-only button. - **No layout shift**: the split button keeps a fixed minimum width, so swapping Steer ↔ Queue never moves the field. The toolbar pills glide aside for the send slot on `fast`, or switch at once with reduced motion; web's send slot eases the same way. - **Colours**: the round send button uses `action` like web (it was `accent`, lighter in dark mode). An empty field during a turn still shows Stop (ink on canvas, as web). ## Parity table (web → mobile) | Web element | Mobile element | Status | |---|---|---| | `SteerSendButton`: primary half with label, chevron menu "How to send" with descriptions, Mod+Enter = other way | Split button, chevron → "How to send" sheet with the same items and descriptions, hold = other way | ✅ (shortcut → long press) | | Round send `bg-action`, Stop as ink circle | Same colours | ✅ | | Send slot eases to its content's width | Toolbar padding eases (`useTween`, `fast`) | ✅ | | Running default from settings (#380) | Same setting; also toggled from the queue's "…" (stage 1) | ✅ | ## Copy audit (docs/copy.md §8) | Before → after | Reason | |---|---| | Accessible names "Steer message" / "Queue message" → "Steer into the running turn" / "Queue for the next turn" | Web's names; they say where the message goes | | Hint "Hold to steer/queue this message." → "Hold to queue it for the next turn." / "Hold to steer it into the running turn." | Same rule, says what the hold does | | New: visible "Steer" / "Queue", "More ways to send", sheet "How to send" with "Steer into this turn" — "Joins the turn the agent is working on now." and "Queue for the next turn" — "Waits and runs as the next turn." | Web strings | No new terms; sentence case; one idea per sentence. ## Verification - `bun run typecheck`, `bun run lint`, `bun run format:check`: clean. Shared repo checks are as in stage 1; CI is the gate. - **OTA**: EAS fingerprints are unchanged (iOS `6ddec9ef559ee0095ac33e94ff9418a942053b17`, Android `5f6eae3ab278f1cd543e9ed763f923a319b65ec9`). - Native visuals are not verified (no compatible dev client); the web reference is web's `SteerSendButton` at 390 px dark/light. ## Manual device checks 1. Start a turn, type a message: the button becomes "↑ Steer | ⌄" (or "Queue" with queueing on) and the model/effort pills glide left without overlapping it. Tap → steers; hold → queues (a row appears in the tray's queue). 2. Chevron → "How to send" sheet; both items send the right way, and the sheet closes. 3. Clear the field during the turn: Stop appears. After the turn ends, the round send is back with the `action` colour in light and dark. 4. Large system font: "Queue" stays readable; the button grows rather than truncating. 5. Reduced motion: the pills jump instead of gliding.
This was referenced Nov 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Settings → Threads now exposes “When the agent is working, send messages as”: Steer (default) or Queue on web/desktop and mobile. The preferred mode remains the primary send action; the other stays available per message through the web menu/alternate shortcut and the mobile secondary button/long press.
This reuses the existing owner-scoped, database-backed
UserSettings.composer.running_deliverycontract and its settings API. No additional proto field, generated-code change or migration is needed. The queue menu updates the same preference. Existing clients and gateways retain their delivery semantics. Both clients already resolve the viewing user's preference and send explicitSendMessage.deliveryto local and qualified remote thread IDs. Agent-to-agent delivery is unchanged.Validation:
check:tmpcleanup gate passed.bun install,bun run gen:check,bun run typecheck,bun run lint,bun run format:check, and the web production build passed.The unsharded
bun run check:tmpreceived SIGTERM before its summary, so full coverage uses the repository's existing CI shard runner (bun scripts/test-shards.ts 1through4), run sequentially. An initial shard 3 attempt hitENOSPCwhile copying an updater test binary in the shared tmpfs; rerunning that shard with a disk-backedTMPDIRpassed. No repository workaround was added.OTA fingerprint:
bunx [email protected] fingerprint:generate --platform <ios|android> --build-profile production --json --non-interactiveran before and after.2a0ef03a2a0fda8e7fad2e3df8609803d2edbda3→ identical.c5c880ae8d0f5d7bc867fcbaf8f756b2ca56a07d→ identical.Only JS/TS changed on mobile.
Copy audit (§8):
Sentence case, punctuation, glossary and length limits checked. Actions start with verbs. No new errors, empty states, confirmations, dependencies or “soul” copy. Descriptions do not repeat labels; meaning does not rely on color or icons. Desktop/phone/narrow checks include long text and reserved reset-control space.