Skip to content

feat: render an assistant message with its sources, checks and failure states - #558

Merged
caitlon merged 5 commits into
devfrom
feat/assistant-message-render
Oct 9, 2026
Merged

caitlon merged 5 commits into
devfrom
feat/assistant-message-render

Conversation

@caitlon

@caitlon caitlon commented Oct 9, 2026

Copy link
Copy Markdown
Owner

Problem

An answer needs its sources, its grounding checks and its failure states shown next to the text, and a stored message can come back from sessionStorage with nested fields in any shape.

Change

Adds AssistantMessage. A user message renders as plain text, never as markdown; an assistant message renders through AssistantMarkdown, which gets the source numbers only once the turn is done, so a citation in a streaming, cut, stopped or failed answer stays plain text instead of reading as a missing source. Sources show as compact rows [n] Title · Section (no separator when the section is empty) with the anchor id the citations point at; a row is a button, and only one row is open at a time, showing the snippet as a text node when there is one, the layer, and for a public source with an https: URL a link opening in a new tab with rel="noopener noreferrer". A local source never links and carries a "Local copy" badge. Clicking a citation opens its row and scrolls to it once it has opened. numbers_grounded: false and citations_valid: false each add one amber line, the first listing the unconfirmed numbers when there are any; the tools the assistant used show as one muted line, with an unknown tool name shown as is. An error turn shows fixed text chosen by its status code (429 with minutes when retryAfter is a positive number, 503, 404, anything else), never the error detail; a cut turn keeps its partial text muted with an "interrupted" block, and a cut with blank text shows the block without the line that points at the partial text; a cancelled turn shows a "Stopped" note, with the partial-answer line only when there is text. An optional onRetry adds a "Try again" button to the red block. message-shape.ts re-checks sources, toolsUsed and checks and drops what does not fit. Code blocks keep their line breaks; the allowlist from the previous PR drops pre. New message.* strings in en and cs.

Verification

New tests in AssistantMessage.test.tsx and message-shape.test.ts cover public, http:, javascript: and local sources, the one-open-row rule, citations opening their row, malformed nested fields, both checks lines in both directions, known and unknown tools, each error code without the detail, cut with and without text, an error with partial text, whitespace-only content, a snippet holding HTML, cancelled, onRetry, and a user message not read as markdown. AssistantMarkdown.test.tsx gains cases for adjacent citations, a citation opening the line, and the citation anchor node surviving appended content. npm run lint, npm run typecheck, npm run test:coverage, ./scripts/ci/ci-local.sh lint and ./scripts/ci/ci-local.sh test are green.

Migrations

None.

Screenshots

None, the panel wires the component in a later PR.

@caitlon caitlon added this to the v1.1-polish milestone Oct 9, 2026
@caitlon caitlon added type:feature New functionality area:frontend React frontend labels Oct 9, 2026
@greptile-apps

greptile-apps Bot commented Oct 9, 2026

Copy link
Copy Markdown

Automatic reviews are disabled for this repository.

@caitlon caitlon self-assigned this Oct 9, 2026
@github-actions github-actions Bot added the size:L 601 to 1000 changed lines. Over the 300 to 600 target. label Oct 9, 2026
@sonarqubecloud

sonarqubecloud Bot commented Oct 9, 2026

Copy link
Copy Markdown

@caitlon
caitlon merged commit 1a27806 into dev Oct 9, 2026
20 checks passed
@caitlon
caitlon deleted the feat/assistant-message-render branch October 9, 2026 23:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:frontend React frontend size:L 601 to 1000 changed lines. Over the 300 to 600 target. type:feature New functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant