Skip to content

fix(web): terminal citation previews look like the terminal - #312

Merged
adampeterhiggins merged 4 commits into
mainfrom
ah/fix-terminal-citation-preview
Oct 14, 2026
Merged

adampeterhiggins merged 4 commits into
mainfrom
ah/fix-terminal-citation-preview

Conversation

@adampeterhiggins

@adampeterhiggins adampeterhiggins commented Oct 14, 2026 •

Copy link
Copy Markdown
Owner

Hovering a terminal citation chip showed its output as plain text in the app's code font without wrapping, inside a fixed-width popover. Long lines got cut off behind a horizontal scroll, Nerd Font prompt glyphs showed as empty boxes, and every colour was lost.

  • Wrapping. The preview wraps long lines and scrolls only vertically.
  • Font. The preview follows the terminal font settings (family, size, line height, including the Advanced typography split) through the same terminalFontFamily stack the terminal uses. The terminal's bundled Symbols Nerd Font is now also declared in CSS, limited to the private-use range, so DOM text draws powerline separators and devicons. It only downloads when one of those glyphs is on screen.
  • Colours. Adding a selection to chat also reads it from Ghostty as VT output (ghostty_terminal_selection_format_buf with emit = VT). That output begins with the whole 256-colour palette as OSC 4 (about 6 KB), so the capture keeps only text and SGR sequences, and drops the copy when it has no styles or exceeds 128 KB. It is stored as an optional styledText on TerminalContextRecord, so chips in sent messages keep their colours too. The preview parses it into styled runs drawn with the terminal theme's palette, 256-colour cube and background. Consecutive runs that share a background are painted as one box, because adjacent same-colour boxes at fractional pixel offsets leave an antialiased hairline seam between them. Agents still receive only the plain text; the provider formatters do not read the new field.

Excerpts added before this change have no styledText and show plain text. Mobile shows terminal context in a sheet without a hover preview and is unchanged. docs/fork-differences.md has a new entry.

Tests cover the SGR parser, what the capture keeps and drops, and a real Ghostty selection round trip. Checked in the web client by adding coloured git log, git status, ANSI and 256-colour output and a powerline prompt to the composer.

Before After After (prompt)
Terminal preview before: lines cut off, glyphs as boxes, no colour Terminal preview after: wrapped, coloured git output Terminal preview after: coloured powerline prompt

Made with Claude Opus 5.5 in Claude Code, running in T3 Code.

🤖 Generated with Claude Code

adampeterhiggins and others added 2 commits October 14, 2026 15:28
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The preview now follows the terminal's font family, size and line height
settings, and the bundled Nerd Font symbols are available to DOM text, so
powerline prompt glyphs render as they do in the terminal.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@adampeterhiggins adampeterhiggins changed the title fix(web): terminal citation previews wrap long lines fix(web): terminal citation previews wrap lines and use the terminal font Oct 14, 2026
Adding a terminal selection to chat now also captures it from Ghostty as
VT text, keeping only SGR sequences, and stores it as an optional
styledText on the terminal context record. The hover preview parses it
into styled runs drawn with the terminal theme's palette and background.
Agents still receive only the plain text.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@adampeterhiggins adampeterhiggins changed the title fix(web): terminal citation previews wrap lines and use the terminal font fix(web): terminal citation previews look like the terminal Oct 14, 2026
Consecutive runs that share a background now sit in one background box.
Cells land on fractional pixels, so two adjacent boxes of the same color
each antialiased their shared edge and left a light seam, most visible
after powerline separators.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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