Repository navigation
feat(choice-cards): carry the card's own context; tag answers wherever they sit - #1644
Merged
Merged
Conversation
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.
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.
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
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→ cleancargo clippy -p future-agent --all-targets -- -D warnings→ cleancargo test -p future-agent --lib→ 3115 passed, 0 failed, 7 ignoredtsc --noEmit→ cleaneslinton the 9 touched files → cleanvitest runon the 4 touched suites → 52 passedjest src/components/__tests__/ChoiceCard.test.ts→ 8 passedeslinton the 5 touched files → cleanvitest run --config ../packages/markdown/vitest.config.ts→ 33 files, 755 tests passedUser-visible changes
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. Revertdc963d305.7d3d15a90.fda674b9c.[title → label]echoes were read as candidate file paths / links by the markdown parser; they now parse as a choice answer. Revert934379d82.desktop/src/i18n/locales/zh/markdown.jsonandmobile/src/i18n/locales.ts:Revert
54bc99c15.choice.mdline cap is raised 42 → 51 (asserted inagent/src/prompt/mod.rs), because every card now shows a context paragraph.Notes
docs/design/choice-cards.mdand its zh-CN twin document thecontext:field, the tag placement and the read-only card's hint handling.