Skip to content

feat(choice): badge a waiting answer; never send an empty pick; report refused renames - #1624

Merged
huichen merged 15 commits into
mainfrom
pr/huichen
Nov 15, 2026
Merged

huichen merged 15 commits into
mainfrom
pr/huichen

Conversation

@huichen

@huichen huichen commented Nov 15, 2026

Copy link
Copy Markdown
Collaborator

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

  • feat(choice): mark a conversation whose last reply offered a choice — a settled run records offers_choice; lists read it with the run row they already load; the field travels to a paired client as an optional offersChoice.
  • fix(composer): send no answer tag when a choice card has nothing ticked — the desktop editor stops writing an answer pill for a card with no tick.
  • fix(host): report a rename whose local mirror write was refused — the mirror write into threads.title is no longer discarded; a failure reaches the caller instead of leaving the two stores disagreeing.
  • docs(host): say how a rename actually reaches the paired client — corrects which path carries the new name, and which two do not.
  • fix(desktop): badge a peer's conversation waiting on an approval — a peer row now shows the same waiting-for-approval badge the phone draws, and the peer row parser names offersChoice so the choice mark reaches the merged list; the harness can stage both marks.
  • docs(screenshots): scroll a list mark into view in the list-marks scene — the capture asserts the mark is visible, not merely present in the DOM.
  • fix(choice): drop the answer and its pill when nothing is ticked — one answerOrNull rule at every place an answer is written; a pill can no longer print the card's question and claim to answer it.
  • fix(mobile): refuse a queue rewrite that would carry no answer — an edit that would leave a queued message asking its own question is refused and reported, rather than sent.
  • fix(agent): report a rename that could not be persisted — set_session_name fails 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 — clean
  • cargo 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)
  • desktop: tsc --noEmit clean; eslint on the changed files clean; vitest run on the seven changed suites — 307 passed
  • mobile: tsc --noEmit clean; eslint on the changed files clean; full jest --runInBand — 171 suites / 3247 tests passed (re-run at 8165322 after the last commit landed)
  • packages/remote-protocol: tsc --noEmit clean; vitest run — 5 files / 63 tests passed
  • make check-docs — 421 docs OK, 0 pairs pending, provider matrix 13 rows
  • python3 scripts/tests/test-screenshot-scenario-fragments.py — ok

Notes

  • host gains one additive column, runs.offers_choice INTEGER NOT NULL DEFAULT 0, declared both in the table and in ADDED_COLUMNS; an existing app.db picks it up on open. No row is rewritten and no backfill is needed — an old run simply carries 0.
  • offersChoice is 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

  • Conversation lists now mark a conversation whose last finished reply closed with a choice card, i.e. one waiting on the reader's answer: desktop rail and phone session list, plus the desktop merged peer list. Before: no mark anywhere. Revert e2617a2 (and 8dc9c94 for the peer-row parser).
  • A multi-choice answer with nothing ticked is no longer an answer: the desktop pill and the phone chip are dropped, Send goes grey, and the phone refuses to rewrite a queued message into a question with no pick (it reports that the message has no answer instead). Before: the pill printed the card's question, claimed to answer it, and the surface still counted it as content. Revert ffb687a, 7ac5326, 18d2458.
  • The desktop merged list badges a peer conversation parked on an approval, as the phone already did. Before: nothing was drawn, because a run waiting on a decision is not streaming. Revert 8dc9c94.
  • A rename that cannot be persisted (agent store) or mirrored into 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.
  • Data migration: runs.offers_choice is added with DEFAULT 0 on open. No setting, default value or wire default other than the optional field above changes.

huichen and others added 15 commits November 16, 2026 02:34
`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.
@huichen
huichen enabled auto-merge (squash) November 15, 2026 19:31
@huichen
huichen merged commit 5c998ea into main Nov 15, 2026
59 of 62 checks passed
@huichen
huichen deleted the pr/huichen branch November 15, 2026 20:16
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