Skip to content

feat(web): cite a stretch of the transcript, tool calls included - #476

Merged
adampeterhiggins merged 2 commits into
mainfrom
ah/cite-tool-calls
Oct 22, 2026
Merged

adampeterhiggins merged 2 commits into
mainfrom
ah/cite-tool-calls

Conversation

@adampeterhiggins

Copy link
Copy Markdown
Owner

Citations could only quote text inside one assistant response, so there was no way to point an agent at a run of the conversation: what it said, the commands it ran, and what it concluded.

This adds transcript citations:

  • Drag across messages. A selection that runs from one message to another cites everything between: user messages, assistant responses, and the tool calls the drag passes over. Only the selected part of the first and last response is kept. Tool rows can't hold a text selection, so the ones included get a tint.
  • Shift-click tool calls. Shift-clicking a tool call picks it instead of expanding it. On its own it cites that call; with text selected it extends the quote to it. While picking, shift-clicking more tool calls or messages moves the end. A Cite button sits above the composer, and the pick survives scrolling. Escape, ✕ or a plain click clears it.
  • Chip and agent context. The chip reads what the excerpt spans ("1 message, 4 tool calls"), and its preview shows the excerpt as a short transcript. Agents receive the same rendering: each tool call's name, label, status and trimmed detail, plus ordered segments naming each item's id. Items hidden in collapsed tool groups or folded turns are included; reasoning is left out.
  • Go to source. Scrolls to the first cited item and briefly tints the rest.

How

AssistantCitation gains an optional segments array (message or tool-call ids in timeline order); text/markdown hold the rendered excerpt. Extending the existing type rather than adding a new one means every consumer (composer chips, queue and stash previews, titles, find, mobile, provider expansion, sending to another thread) handles excerpts without changes. Old citation links are byte-identical. A client without this change won't recognise a link carrying segments and will show it as a plain link.

Segments are built from the timeline entries, not the DOM, because LegendList recycles rows out of order and unmounts off-screen ones (transcriptCitation.logic.ts). Only the two ends of a drag are read from the DOM.

Screenshots

Dragging from one response to the next, across "Ran 4 commands":

Before After

Before, a cross-row selection offers no Cite button. After, the commands in the range are tinted (reasoning rows are not) and Cite appears.

Shift-clicking a command and then the response below it picks whole items, with the action above the composer:

The chip and its comment panel, then the chip's hover preview:

Comment panel Preview

Verification

  • New unit tests for the excerpt builder and the segments link format, and a browser test for drag, shift-click and Escape. Temporarily removing the shift-click interception makes the browser test fail.
  • Exercised on a seeded dev server with Playwright (the screenshots above). This turned up the Cite button rendering under the composer overlay, fixed in the second commit.
  • check:changed is clean for this change. Its remaining failures exist without it: knip's unused exports, a server typecheck error in ProviderInstanceRegistry.test.ts, and two "opens a nested diff" tests in MessagesTimeline.browser.test.tsx.
  • Docs: docs/user/composer.md and a new section in docs/fork-differences.md.

Not covered: mobile only renders excerpts as text (it doesn't create citations, as before), and I didn't test the desktop app separately from web.

Claude Opus 5.5 in T3 Code (Claude Code harness).

🤖 Generated with Claude Code

adampeterhiggins and others added 2 commits October 22, 2026 18:12
Dragging a selection across messages cites everything between, including
user messages and tool calls. Shift-clicking a tool call picks it, grows a
text selection to it, or extends a pick, with a Cite button at the foot of
the timeline. Citations carry ordered segments so the chip summarises the
excerpt, agents receive it as a short transcript, and going to the source
scrolls to and tints the cited items.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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