Skip to content

feat(choice-cards): carry the card's own context; tag answers wherever they sit - #1644

Merged
huichen merged 11 commits into
mainfrom
pr/huichen
Nov 18, 2026
Merged

huichen merged 11 commits into
mainfrom
pr/huichen

Conversation

@huichen

@huichen huichen commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

What this lands

Five commits finish the choice-card loop that #1642 started. A card can now carry a context: paragraph of its own (the situation the question sits in), an answer is drawn as a tag wherever it sits in the transcript instead of only inside the card, a past card keeps the reply's own hint instead of losing it to the read-only notice, the composer inserts the answer pill at the caret rather than behind the reader's words, and the markdown parser stops reading a choice answer as a file link.

Commits

  • feat(choice-cards): give the card a context paragraph
  • fix(choice-cards): keep a past card's own hint, not just the notice
  • fix(markdown): stop reading a choice answer as a file path
  • feat(markdown): draw a choice answer as a tag wherever it sits
  • fix(composer): put a choice answer at the caret, not behind the words

Verification

Run locally on the branch tip with the pinned toolchain (rustc 1.99.1), before opening this PR:

  • cargo fmt -p future-agent -- --check → clean
  • cargo clippy -p future-agent --all-targets -- -D warnings → clean
  • cargo test -p future-agent --lib → 3115 passed, 0 failed, 7 ignored
  • desktop tsc --noEmit → clean
  • desktop eslint on the 9 touched files → clean
  • desktop vitest run on the 4 touched suites → 52 passed
  • mobile jest src/components/__tests__/ChoiceCard.test.ts → 8 passed
  • mobile eslint on the 5 touched files → clean
  • vitest run --config ../packages/markdown/vitest.config.ts → 33 files, 755 tests passed

User-visible changes

  • Choice cards can carry a context: paragraph. The prompt now asks the model for 1–3 sentences on the situation the question sits in, and the card shows them above the instruction. Before: title, mode and rows only. After: an optional situation paragraph, so the card is answerable without scrolling back up the reply. Revert dc963d305.
  • An answered choice is a tag wherever it sits. The answer echo is drawn as a pill at its position in the sentence (desktop and mobile), not only as a block under the reader's prose. Revert 7d3d15a90.
  • The composer puts the answer at the caret. Picking a row inserts the pill where the cursor is; it used to always land behind the typed text. Revert fda674b9c.
  • A choice answer is no longer parsed as a file link. [title → label] echoes were read as candidate file paths / links by the markdown parser; they now parse as a choice answer. Revert 934379d82.
  • A past (read-only) card keeps its own hint and adds the read-only notice below it, instead of replacing the model's hint with the notice. The zh copy changed in desktop/src/i18n/locales/zh/markdown.json and mobile/src/i18n/locales.ts:
choice.hint.readonly: "只作展示:这张卡不能选" -> "早先的提问,这张卡不能再选"

Revert 54bc99c15.

  • Prompt budget: the choice.md line cap is raised 42 → 51 (asserted in agent/src/prompt/mod.rs), because every card now shows a context paragraph.

Notes

  • docs/design/choice-cards.md and its zh-CN twin document the context: field, the tag placement and the read-only card's hint handling.

A prompt typed first and picked after keeps the pill's [question → answer]
mid-sentence, because writeChoicePill appends it to the end of the editor.
The bracket-mention shorthand then read the whole run as one bare relative
path whenever a row named a path (删未在用的 ~/omlx 副本), so the bubble drew
the reader's own sentence as a file link and clicking it reported
'file not found'.

Require the bracket interior to be a single path token: whitespace or the
choice answer's arrow means prose. A path that really holds spaces stays
unambiguous as a markdown link, [name](<with space.md>).
The composer appends its pill to the end of the editor, so a reader who
types first and picks a row after sends [question → answer] in the middle
of their own sentence. The echo reader only looked at the head of the
prompt, so that answer stayed a bracket sandwich among the words.

Read the answers anywhere, in order, and hand the prose back with them
taken out — the seam left behind is closed, so a run that had a line to
itself does not leave a blank one. Two guards keep the classifier honest:
a run inside a fenced block or an inline code span is an example the
reader pasted, and cutting it out would unbalance the fence or the
backticks; a run followed by ( or [ is a link or another bracket run.

Both bubbles lift the answers into the tag row above the prose rather
than drawing one inline: a React Native View cannot sit inside a Text
flow, so one shape on all three clients.
The card carried a title, one line per option and a subtitle saying how to
answer — everything except the situation. Deciding between "redraw the forest
plot" and "add a flow diagram" still meant scrolling back through the reply to
find out what had just been done, which is the cost the card exists to remove.

`context:` is that missing piece: 1–3 sentences on what the reply found, where
it stopped, and whatever a row's cost depends on, so the card can be answered
on its own. It sits under the title and above the subtitle (content above
chrome), keeps its line breaks, and stays on a read-only card — the subtitle
says the rows are inert, but the situation is still what the question was about.

The prompt is where this is won or lost, so `choice.md` states the field, its
bounds (under ~200 characters; repeat the line for a second paragraph) and the
two ways it goes wrong: a recap of the reply instead of the state, and the same
sentence printed in both the prose and the card. The line budget goes 42 → 51
because every card now writes one and both examples had to show one.
A reply that ends with a card is re-read later, and the model's `hint` — the one
line it wrote about how to choose — was replaced by "只作展示:这张卡不能选" on
every card that is no longer the thread's last. That is the card admitting it is
inert and forgetting what it said, in a transcript that exists precisely to be
read again.

The two are now separate: the default instruction ("pick one and it lands in the
input") still never appears over dead rows, the model's own `hint` stays, and the
notice follows it saying this is an earlier question that can no longer be
picked. Both are the group's `aria-describedby`, in visual order; a card with no
hint gets only the notice. The Chinese notice also stops apologising — "早先的
提问,这张卡不能再选" says what the English copy already said.
The composer appended its pill to the end of the editor, so a reader who
typed a sentence and then clicked a card row found the answer stuck behind
their own words — the one action the card exists for, in the place they
least expect. A card's rows live in the transcript, so the click moves
focus and the browser drops the selection; the box therefore remembers the
last range that landed inside it (selectionchange) and inserts there.

The answer is inserted as one fragment (pill + its editable space) so the
text under the caret splits once and the pill is left directly followed by
the space the removal path and caretAfterChoice both read. A selection
collapses to its end rather than being replaced, so clicking a row never
deletes highlighted words, and changing the answer still rewrites the pill
in place instead of moving it.

Also adds the reverse assertion for a prose bracket that names a path: no
tag (no arrow) and no file link (prose inside the brackets), at both the
parse layer and the bubble.
@huichen
huichen enabled auto-merge (squash) November 18, 2026 10:25
@huichen
huichen merged commit 2000def into main Nov 18, 2026
56 of 58 checks passed
@huichen
huichen deleted the pr/huichen branch November 18, 2026 10:55
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