Repository navigation
feat(desktop): interactive choice cards with a composer answer pill; git-history refs and author - #1612
Merged
Conversation
…list every ref Three things a reader of the history asked for. A row named the *committer* (`%cn`), so every PR squash-merged on GitHub read as "GitHub" — measured on this repository, where every such commit has author `Hui Chen` and committer `GitHub`. It now reads the author. The second line's fields are ordered date · hash · author: the date is what answers "is this the change I am after", and it now leads. The detail page lists every ref on the commit — branches, remote-tracking branches and tags, plus whether HEAD is there — instead of reusing the row's one-line decoration, which drops local branches once a commit carries several. It asks `for-each-ref --points-at`, so a commit on five branches lists five; HEAD is asked separately because it is a symref and `--points-at` never lists it, which is also the only way a detached checkout of an old commit gets named.
A reply can now close by asking what to do next with 2–4 options, written as a `futureos-choice` fence (design docs/design/choice-cards.zh-CN.md §3). The fence parses into `ChoiceCardNode` — an independent node type, not a `futureEmbed`, because its payload is an option list rather than one object id — and every client that consumes the shared AST gets it, so the desktop card and the phone cannot disagree about what the block says. `parseDirectiveFields` gains the repeated-key primitive it needed: `option:` is one row per line, so `parseDirectiveEntries` keeps source order and duplicates and the single-valued `futureos-file` fence reads the last-wins view on top. Malformed input never eats the reply (§3): fewer than two or more than four rows, an illegal/duplicate/over-long id, or a row with no label drops the whole block back to the code block it was, which is also what an older client shows. The phone's MarkdownText would otherwise fall through to the paragraph branch, which assumes `children` a card does not have: it renders the options as text until §11 step 6 draws the real card there (§8's degradation promise).
`ChoiceCard.tsx` is the card the design settled on (§5.1–5.2): a title with the single/multiple marker, a subtitle pointing at the composer, and one row per option carrying the line on what picking it changes. Picking is click-only — the design rejected row numbers because they would take over the digits the reader is typing (§5.6). Two states, one component. A card with an answer surface is interactive: rows are `role="radio"`/`"checkbox"` with `aria-checked`, a roving tabindex, arrows walking the rows and Space picking. Without one it is read-only and stays out of the tab order, which is what every card is until step 4 wires the draft — so `MarkdownContent` makes only the document's **last** card live (§2) and nothing ships a button that answers nothing. Selected rows use `accent-soft` fill only (no border, no white check): v2's fix for the phone's three-times-marked row (§5.7.1) reads the same on the desktop.
The answer has to be the composer's content, not a chip beside it: v1 put it in the attachments row, where neither `inputEmpty` nor `attachments` counted it, so "pick an option and send" left the button grey (design §5.2.1). It is now a fourth pill kind in `MentionEditor` — `data-mention="choice"` carrying the answer as JSON, atomic, in the same contenteditable as the text. `isEditorEmpty` already reports any `[data-mention]` as content, so requirement (d) falls out of the existing rule and `ComposerControls`' `disabled` expression is not touched; removing the pill turns the button grey again by the same rule. `serialize()` writes the plain text §7 asks for — `[接下来做哪一件? → 重画森林图]` — because the answer must survive TUI, an IM bot and a copy-paste. The pill's pencil expands the question in place (`ChoicePopover`, 360px above the pill, Esc/outside-click closes without changing anything); its cross drops the answer and reports `null` so the draft can follow. The state itself is step 4's work: the editor exposes `setChoice()`, like the file tree's `insertMention()`. The two glyphs are lucide's `Pencil`/`X` paths drawn with `createElementNS`: the pill is built with the DOM API, so no icon component can be mounted inside it.
…ne's fallback Three scenarios run against product code now, not injected prototypes: - `choice-card-implemented` opens a fixture reply whose last block is a real `futureos-choice` fence and asserts the card is inside the reply, that its three rows are radio rows, that it is read-only while no answer surface is wired, that it is exactly as wide as the reply column, and that send is still disabled (requirement a). - `choice-pill-implemented` asserts the three-state table of §5.2.1 in the real composer: empty → `disabled`, pill alone → enabled, pill removed → disabled. The pill's DOM is injected in the shape `buildChoicePill` produces, because the card click that fills it is step 4; the send button's state is the app's own reaction through `isEditorEmpty`. - `choice-card-phone-degraded` proves §8 on the phone: the same fence becomes a readable list (title plus three option lines), not a swallowed reply. The design's own prototype scenarios stay as they are — they document the styling options that were accepted and rejected.
The queue row was the one surface v2 described only on desktop. It turns out there is no single panel to describe: remote desktop imports the desktop SendQueuePanel (RemoteComposer.tsx:23, rendered at :1244), so its queue styling is the desktop's, while the phone carries a second implementation of its own (folding header, sendQueueListHeight bound). v2 also introduced a new ambiguity that v3 removes: it gave the queue chip a pencil, and the row already has a pencil meaning "edit the words". Two pencils a few pixels apart meaning different things is the exact problem this design exists to remove. The chip is now itself the button (one chevron, aria-label carrying "change the choice in this message"), the row keeps its own pencil and bin, and dropping just the choice is the options' own "no choice" entry rather than a third control on the chip. Measured on the real panels through the real enqueue flow, not drawn: chip 136x22 on both desktop and remote, 129x23 on the phone, each with exactly one icon and a right edge left of the row's pencil. The scenarios assert that relationship, so reverting to a second pencil turns them red.
…poser The `futureos-choice` card could be drawn (§11 step 2) and its answer could live as an editor pill (step 3), but nothing connected them: every card was read-only, and the only way a pill appeared was through a test. This lands step 4. `ComposerDraft` grows an optional `choice` field — no `DRAFT_VERSION` bump, the shape was left open for exactly this, so drafts already in sessionStorage keep loading. The composer owns the value (it owns both the pill and the draft), reports it to the transcript through `onChoiceChange`, and takes a pick back through a `ComposerHandle`, so there is one writer and no second copy to keep in step. `MarkdownContent`'s `choiceAnswer.onSelect` now hands the clicked row the card's own question and options: an answer carries them so the pill's pencil can re-offer them from the editor alone, and the first pick is the only moment they are known. Only the thread's last, settled reply gets a surface at all (`MessageList`), which is what keeps every earlier card read-only. Sending writes the answer as the §7 plain text and then drops it from the draft, so the next message in the conversation does not inherit a pick. The draft's text is read with `getDraftContent()`, which leaves the answer's own pill out — otherwise a reload would rebuild it twice. Tests drive the real components: a click on a card row, the real `MentionEditor` and `ComposerControls` (send grey, then armed by the pill alone), the draft's round trip on version 1, and the draft being cleared after a send. The screenshot scenarios now click the real card instead of injecting a pill.
The parser, the desktop card and the answer pill were all in place, but no prompt section mentioned `futureos-choice`, so the model never emitted one and the whole surface was unreachable product code. `choice.md` states when a card is warranted (a reply that really ends in a next-step question, 2-4 alternatives you can carry out yourself), the fence syntax with one three-field example, and that the answer comes back as `[title → label]` text to act on rather than to re-ask. 38 lines, read on every turn.
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 reply can carry a
futureos-choicefence with a title and options. The agent's system prompt now teaches the model to emit one when it offers a choice, the shared markdown package parses the fence into a choice-card node, the desktop draws the last one as an interactive card and holds the chosen answer as a pill inside the composer (so it can be sent with no typing), and the phone degrades it to a readable list until its own card lands. The git-history panel is corrected at the same time: rows name the commit's author instead of its committer, lead the meta line with the date, and the detail page lists every branch, remote-tracking branch and tag that points at the commit.Commits
Verification
Run locally on a detached worktree of the dev tip (
08cf0204d), Rust on the pinned toolchain (rustc 1.99.1),CARGO_TARGET_DIRshared with the repo:cargo fmt --all -- --check→ cleancargo check -p future-host --all-targetsand-p future-agent --all-targets→ cleancargo clippy -p future-host --all-targets -- -D warningsand-p future-agent --all-targets -- -D warnings→ cleancargo test -p future-host --lib git_history→ 15 passed, 0 failedcargo test -p future-agent --lib prompt→ 225 passed, 0 failedtsc --noEmitclean;eslintover the 17 changed sources clean;vitest runover the 8 changed test files → 84 passedpackages/markdowntest project (vitest run --config packages/markdown/vitest.config.ts) → 731 passed over 30 files, including 20choiceCardtests;tsc --noEmitcleanpackages/remote-protocol:typecheck,check:generatedandtest→ 63 passednpm run typecheckclean;eslintover the 8 changed sources clean;jeston MarkdownText + GitGraphPanel → 67 passedNotes
GitCommitDetailgains a requiredrefsfield (branches/remotes/tags/head). Both clients read it unguarded, so a client paired with a host built before this commit cannot render a commit detail. A client and host from the same build are unaffected; the field is additive on the wire.User-visible changes
futureos-choicefence when it offers a choice, so a reply that offers options arrives as a card with clickable rows instead of a list of prose. Revert6729b88ba.futureos-choicefence: before, the fence body reached the reader as ordinary text; after, it renders as a card, and the picked answer appears as a pill in the composer from which it can be sent without typing. The phone still shows the options as a readable list. Revertc55e1b4a0,9798ad622,70effc2f6,b506c2b0b.ecef27e82.refsfield above.