Repository navigation
feat(choice): badge a waiting answer; never send an empty pick; report refused renames - #1624
Merged
Merged
Conversation
`set_session_name` wrote the new name into the in-process session and then treated a failed `update_info` as a log line: the response was `ok` either way. The name lives in two places, and every other reader — a cold load after the session is evicted, `get_state`, the host's discovery pass that converges `threads.title` — reads the disk. So a rename whose write failed was visible until something re-read the session, and then the old title came back: from a desktop connected to a remote host, that reads as "I renamed the conversation and it reverted a while later". Restore the in-memory name to what the disk holds and fail the command, so the caller keeps the name it already had instead of publishing one that cannot survive a re-read. A session with no persisted row still carries its name in memory alone, which is unchanged. The test that asserted the old behaviour (`set_session_name_survives_persist_error`) is replaced by two: the failure now reaches the caller, and memory is left on the previous name.
A card is only visible inside the conversation that holds it, so "which conversation is waiting on my answer" had no answer in a list — the approval badge says something else (an approval blocks the agent; a card only waits for the next send). The fact belongs to the run, and it is decided once, where the reply is produced: the Agent reads its own closing fence (same rules as the renderer's `parseChoiceCard`) and carries `offers_choice` on the terminal entry and on `agent_end`. The desktop host records it on the run row, so `latest_run_infos` (the rail) and the sessions catalogue (the phone, and a peer's rows in the merged list) read one boolean instead of each client guessing from text it does not hold. A follow-up turn is a new row, so the mark clears by itself. Drawn only while the conversation is at rest: the latest run completed, its reply closed with a card, and the row is not the one on screen (the card is right there). `list-checks` in the accent ink, beside the approval badge's `circle-alert` in warning; on the phone it takes the unread dot's slot, since both say "this finished while you were away" and only the card says something is owed. Docs: choice-cards §5.9 (zh + en).
Unticking the last row of a multi-choice card leaves an answer that still carries the card's question but no pick. Both ends print the answer as `[question → label]` (§7), so that state serialized to `[接下来做哪一件? → ]` — a question with an empty answer, which the agent reads as an answer. The phone already dropped the answer at the pick site (`ChatScreen`'s `pickChoice`); the desktop had no such check anywhere, so its pill kept the zero answer and `serialize()` printed it. `mentionDom.serialize` now emits nothing for an answer with no picked rows, and leaves whatever the reader typed beside the pill verbatim — dropping the answer must not take the note. Tests on both ends, each proven red by reverting the guard: desktop asserts the serialized text has no arrow, no question and no brackets while the typed note survives, then that one pick and two picks still print §7's sentence and the `、`-joined form; mobile asserts a fully unticked multi card leaves no answer and that no send carries `→ ]`, with the two-pick send as the contrast.
`rename_session` mirrors the Agent's new name into `threads.title`, but discarded both the lookup error and the write result (`let _ =`, `if let Ok(Some(...))`). The Agent already holds the new name by then, so a silently dropped local write left the two stores disagreeing and the old title coming back on a later pass — the same "it reverted later" symptom the Agent side had before its own fix, one layer out. Both failures are now propagated, with the mirror write naming what happened, so a caller learns the Agent renamed the session but the local title did not follow instead of being told the rename succeeded. The regression test installs a `BEFORE UPDATE ON threads` trigger that aborts, so the store genuinely refuses the write: it asserts the error surfaces and the stored title stays `Before`. Verified red on the old code (`expect_err` received `Ok(())`) and green with the fix.
Two paths look like the one that carries a renamed conversation to the other machine and neither is: `emit_remote_activity` only wakes this machine's own GUI and carries no payload a remote reader could apply, and the client's `session_name_changed` handler treats that event as a settings change (the Agent clears `runId` on it), so it never touches a row's title. What does carry it is the publisher's ordinary change-driven catalogue tick, because `title` is part of every row and of the delta row signature. Written down with the measured number (~22 ms from `rename_thread` to the row arriving at the peer) so the next reader does not spend a day verifying why a rename is not instant, and does not mistake a 60 s poll fallback for the delivery path. A rename that fails to appear is a failed store write, which `rename_session` now reports. Documentation only — no behaviour change in this commit.
The merged list drew nothing for a host conversation parked on an approval: `RemoteConversationRow` read only `streaming`, and a run waiting on a decision is not streaming. The phone has always badged that row (it reads the run status), so the same conversation was marked on one client and invisible on the other. The badge is the local row's own — `circle-alert` in warning, named "this conversation is waiting for approval" — drawn beside the choice mark. Also fixes the choice mark on peer rows: `normalizeRemoteSessionRows` is a field-by-field parser and did not name `offersChoice`, so the mark never reached the merged list (`mergeConversations` passed it on; the parser had already dropped it). A capture of the real list is what showed it. The harness can now stage both states — `?offersChoice=`, `?remoteWaiting=`, `?remoteChoice=` on the desktop, `?listMarks=1` on the phone — with a `list-marks` scenario for each, so the marks are reproducible from a URL. Also fixes the mobile SessionList test's icon assertion, which did not typecheck (`findAllByType` with a string is not an `ElementType`); mobile `tsc --noEmit` is part of CI.
The rail is taller than nine rows, and the peer chat row that carries the choice mark sat below the fold: the first capture asserted the mark existed in the DOM but not that a reader could see it. The scene now also scrolls that row to the middle and fails when the mark is off screen, so the second PNG is evidence rather than a coincidence.
A pill (and the phone's chip) exists to answer *what did the reader pick*. Unticking a multi-choice answer's last row left an answer with a question and no pick, so the pill printed the card's question and claimed to answer it — and the surface still counted that as content, keeping Send live over a question nobody answered. One criterion, `answerOrNull` in both `choiceAnswer.ts`, applied at every place an answer is written: the editor's pill (`writeChoicePill`/`replaceChoicePill`/ `pickChoice`), `Composer.writeChoice`, `RemoteComposer`'s three entrances and its draft load, and the phone's `useComposerDraft.setChoice`. `ComposerDock` asks the same question itself (`hasAnswer`) for the three places it decides — `canSend`, `hasDraft`, whether to draw the chip — so neither surface relies on the other. §7 gets the matching last gate in `withChoiceAnswer`, which is where every send passes; its empty-draft guard asks the same rule instead of `choice !== null`. The `|| answer.title` fallbacks in `MentionEditor.buildChoicePill` and `RemoteChoiceChip` are gone with it: nothing can reach them, and leaving them would re-create the very thing this removes. Desktop and phone each get a red-if-reverted assertion (no pill/chip node, no `→ ]` sentence, Send grey again), plus the pilot-case test that the two-pick `、` format is untouched. Also fixes `SessionList.test.ts:3137`, which passed a string where `ElementType` was expected and made mobile `tsc` fail: the mocked icon is a host element, and the file's own `headingPins` already looks one up as `"Pin" as never`.
`updateQueuedChoice` rewrote a waiting message's sentence from whatever answer it was handed, so unticking a multi-choice row's last option queued `[接下来做哪一件? → ]` — a question the agent reads as an answer — and sent that to `edit_queued_run`. Refused rather than rolled back to the bare question: the row is *already* waiting to send, and changing its text under the reader is more surprising than saying it once. Nothing happens to the text, the answer or the host, and the reader gets `chat.queue.emptyChoice`; removing the message is the row's own bin. That is the shape `removeQueuedAttachment` already uses for the last file of a message with no words. The phone's sheet also stays open on that pick, so the reader can choose another instead of watching it close on a change that could not be made. This is the fourth landing of the criterion the last two commits established — zero ticks is not an answer — alongside the draft write (`answerOrNull`), the render decision (`hasAnswer`) and the send text (`withChoiceAnswer`). Tests: the spy is the assertion, not the final string — no `edit_queued_run` call may carry an empty `selectedIds` or a `[question → ]` text. A companion case keeps one and two picks working, so the guard cannot pass vacuously.
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.
A conversation whose last finished reply closed with a choice card is waiting on the reader — this branch draws that state in the lists (desktop rail, phone session list, desktop merged peer list), stops an empty tick from being treated as an answer anywhere an answer is written or sent, badges a peer conversation parked on an approval, and stops a rename from being reported as done when its persist or mirror write was refused.
Commits
offers_choice; lists read it with the run row they already load; the field travels to a paired client as an optionaloffersChoice.threads.titleis no longer discarded; a failure reaches the caller instead of leaving the two stores disagreeing.offersChoiceso the choice mark reaches the merged list; the harness can stage both marks.answerOrNullrule at every place an answer is written; a pill can no longer print the card's question and claim to answer it.set_session_namefails the command and restores the name the disk holds, instead of publishing a name that reverts on the next read.Verification
Run in the main checkout at the frozen tip (8165322), pinned toolchain rustc 1.99.1,
ulimit -n 8192:cargo fmt --all -- --check— cleancargo check -p future-agent -p future-host --all-targets— clean (1m05)cargo clippy -p future-agent -p future-host --all-targets -- -D warnings— clean (24s)cargo test -p future-agent --lib— 3100 passed, 0 failed, 7 ignored (2m40)cargo test -p future-host --lib— 2259 passed, 0 failed, 15 ignored (8m07)tsc --noEmitclean; eslint on the changed files clean;vitest runon the seven changed suites — 307 passedtsc --noEmitclean; eslint on the changed files clean; fulljest --runInBand— 171 suites / 3247 tests passed (re-run at 8165322 after the last commit landed)tsc --noEmitclean;vitest run— 5 files / 63 tests passedmake check-docs— 421 docs OK, 0 pairs pending, provider matrix 13 rowspython3 scripts/tests/test-screenshot-scenario-fragments.py— okNotes
hostgains one additive column,runs.offers_choice INTEGER NOT NULL DEFAULT 0, declared both in the table and inADDED_COLUMNS; an existingapp.dbpicks it up on open. No row is rewritten and no backfill is needed — an old run simply carries0.offersChoiceis optional on the remote wire (RemoteSession,PresenceSession). A client older than the field omits or ignores it and draws no mark, which is what it did before.User-visible changes
threads.title(host) now fails the command and keeps the previous name, instead of replying ok and letting the old title come back on a later read. Revert 09f018c, 431d286.runs.offers_choiceis added withDEFAULT 0on open. No setting, default value or wire default other than the optional field above changes.