Skip to content

feat(chat): page a reply's pictures in the preview; fix(markdown): read closed choice tags as cards - #1685

Merged
huichen merged 3 commits into
mainfrom
pr/huichen
Nov 24, 2026
Merged

huichen merged 3 commits into
mainfrom
pr/huichen

Conversation

@huichen

@huichen huichen commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator

Two chat improvements that landed on dev-huichen together: the markdown reader now understands a choice card written as a closed <futureos-choice> tag pair instead of the fenced form, and the desktop and mobile image previews page through all the pictures of the reply they were opened from.

Commits

  • fix(markdown): read a closed <futureos-choice> tag pair as its card — the pair is normalized into the fence it stands for and parsed by the single choice-card parser, so a model that writes tags instead of a fence still produces a card the conversation can answer rather than raw source.
  • feat(chat): page through a reply's pictures in the image preview — desktop lightbox (arrow buttons, ArrowLeft/ArrowRight, trackpad swipe) and mobile full-screen viewer (side buttons, one-finger horizontal drag at fit zoom), both wrapping around, with a 1 / 2 counter and hidden buttons for a single picture.

Verification

Local, pinned toolchain 1.99.1, ulimit -n 8192:

  • cargo fmt --all -- --check -> pass
  • cargo check -p future-agent --all-targets -> pass
  • cargo clippy -p future-agent --all-targets -- -D warnings -> pass
  • cargo test -p future-agent --lib -> 3139 passed, 0 failed, 7 ignored (second run at the same SHA). The first run had one failure in prompt::tests::skill_locations_are_relative_to_their_named_scope, a pre-existing cross-test HOME race: TestHome rewrites HOME/FUTURE_HOME process-wide under a lock while that test reads the skill roots twice without taking it. It passes alone, the whole suite passes on rerun at the same SHA, and this branch touches neither that code nor that test.
  • desktop: npx tsc --noEmit pass, npx eslint on the five changed files pass, npx vitest run src/features/markdown/imageGallery.test.tsx -> 5 passed
  • packages: npx vitest run --config ../packages/markdown/vitest.config.ts -> 35 files / 789 tests passed
  • mobile: npx tsc --noEmit pass, npx jest --runInBand on the four changed suites -> 4 suites / 52 tests passed

User-visible changes

  • Image preview, desktop and mobile: before, opening one picture of a reply showed only that picture and stepping to the next meant closing it and finding the other; after, the preview knows the pictures of the reply it was opened from and pages them (arrow buttons, ArrowLeft/ArrowRight and a horizontal trackpad swipe on desktop; side buttons and a one-finger horizontal drag at fit zoom on mobile), both ends wrap, a 1 / 2 counter is shown, and a single-picture reply keeps its buttons hidden. Rollback: cef11e863.
  • Choice card rendering: before, a reply that wrote the card as a closed <futureos-choice> ... </futureos-choice> tag pair was shown as source text (the tags stayed text and the option: lines were joined into one paragraph) and the conversation was not treated as waiting on an answer; after, the pair is read as the card it stands for, the agent's badge reads the same shape, and a reply that spells futureos-choice without producing a card logs a once-per-run warning. Rollback: 1c1a53a69.

No defaults, timeouts, permissions, migrations or feature-flag states are touched.

A reply that draws several pictures opened each one on its own: the lightbox
showed that one image and stepping to the next meant closing it and finding the
other. The preview now knows the pictures of the reply it was opened from, so
both ends can walk the set.

Desktop: `MessageBlock` gives every assistant turn one gallery, shared by all of
that turn's text and tool segments (a nested `MarkdownContent` inherits it
instead of starting its own), and the lightbox pages it with the arrow buttons,
ArrowLeft/ArrowRight, and a horizontal trackpad swipe. Mobile: `TimelineCard`
gives the turn the same kind of gallery, and the full-screen viewer pages it
with the two side buttons and a one-finger horizontal drag at fit zoom; the
drag follows the finger and only commits past `PAGE_SWIPE_MIN`, so a wobble
still springs back. Both ends wrap, so the first picture's "previous" is the
last one rather than a dead end. A counter (`1 / 2`) and a single-picture reply
keeps its buttons hidden.

`RemoteConversationView` draws its transcript with the same `MessageBlock`, so
a remote conversation's pictures page exactly like a local one's.
A model wrote the card as `<futureos-choice>` … `</futureos-choice>` instead
of the fence (two consecutive replies, `future/deepseek-flash`, 2026-11-24,
while quoting the fence form correctly in their own prose). CommonMark kept
the tags as text and joined the `option:` lines into one paragraph, so the
reader got the card's source and the conversation was never flagged as
waiting on an answer.

The pair is now normalized into the fence it stands for and then goes through
`parseChoiceCard` — one parser, one set of field rules, no second reader. It
counts only when both tags are present and outside any other fence (a quoted
pair is an example, not an attempt), and the bare fence line a writer leaves
after the closing tag is dropped with it, so the card stays the reply's last
block instead of rendering read-only behind an empty code block.

The agent's badge reads the same shape (`normalize_choice_tags`), and a reply
that spells `futureos-choice` and yields no card now logs a greppable warning
(`choice card syntax without a card`) once per run — tolerance for one spelling
must not swallow the next.

Tests use the real failing reply verbatim (`choiceTagBlocks.test.ts`), the tag
form and the fence form are asserted to give the same answer, and half a pair,
the bare word and a quoted pair are all asserted to draw nothing. The prompt
(`agent/src/prompt/choice.md`) is unchanged: the fence is still the one spelling
it teaches.
@huichen
huichen enabled auto-merge (squash) November 24, 2026 09:31
@huichen
huichen merged commit d28b3a5 into main Nov 24, 2026
29 checks passed
@huichen
huichen deleted the pr/huichen branch November 24, 2026 09: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