Skip to content

fix(studio): show the whole approval command and its invisible characters - #2329

Merged
peppescg merged 3 commits into
mainfrom
fix/studio-approval-command-view-2259
Oct 15, 2026
Merged

peppescg merged 3 commits into
mainfrom
fix/studio-approval-command-view-2259

Conversation

@peppescg

@peppescg peppescg commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Part of a 4-PR stack: #2329 → #2330 → #2331 → #2332. Review in any order; merge bottom-up.

Summary

A reviewer approving a shell command can now always see all of it, and sees exactly the characters that will run.

On the approval card, a command longer than the compact box shows its line count and a Show N more lines toggle that expands the whole command. Invisible formatting characters render as named badges such as ⟨U+202E⟩ in the command, raw, and JSON views, and a Contains invisible characters chip appears on the card when the arguments carry any. The set covers the bidirectional controls and marks (U+061C, U+200E, U+200F, U+202A to U+202E, U+2066 to U+2069), the zero-width characters (U+200B to U+200D, U+FEFF), the word joiner and invisible operators (U+2060 to U+2064), and the tag characters (U+E0000 to U+E007F). Copying still yields the exact original text. The verdict buttons, shortcuts, diff view, layout of the rest of the card, and the approval decision are unchanged.

What changed

Long commands (apps/web/src/features/chat/ask-args-view.tsx)

  • On the card, the command view shows its first 12 lines, which is what the compact box holds. A longer command adds a footer with the total line count ("60 lines") and a toggle: Show 48 more lines expands the whole command, Show first 12 lines collapses it.
  • A command whose wrapped lines overflow the box, such as one long line, gets the same footer with Show full command and Show less. Overflow is measured with the existing useIsTruncated hook, only while the command is collapsed.
  • The footer reuses the diff view's "Show all N lines" pattern: a border-t border-border/60 row and the same ghost Button (h-6 px-2 text-xs, muted), with aria-expanded and aria-controls pointing at the command.
  • For the command view only, the box's scroll cap moves from the frame onto the command text, so the line count, the toggle, and the timeout or temporary-storage row stay in view. Raw, JSON, and diff views keep the frame's cap.
  • The detail panel is unchanged: it shows the whole command, with no cap and no toggle.

Invisible characters (apps/web/src/features/chat/invisible-characters.tsx, new)

  • VisibleText renders each listed character as the design system's Badge (warning variant, existing tokens) with role="img" and the accessible name "invisible character U+202E". Text without one renders exactly as before, as a single text node.
  • The badge keeps the original character as its only text and draws the ⟨U+202E⟩ label with CSS (before:content-[attr(data-label)]). Selecting and copying read the DOM text, so the clipboard gets the exact original characters, never the label.
  • The badge is an inline-flex box, which isolates its content, so a bidirectional control inside it no longer reorders the text around it.
  • The command (and its temporary-storage scope), raw, and JSON views use it. The chip uses argsHaveInvisibleCharacters, which checks the arguments as sent and as their JSON decodes, since the command and JSON views show decoded text (a JSON escape such as \u202e shows as a badge there and as the escape text in the raw view).
  • The set is one constant: the issue's bidirectional controls (U+202A to U+202E, U+2066 to U+2069) and zero-width characters (U+200B to U+200D, U+FEFF), plus the implicit bidi marks (U+200E, U+200F, U+061C), the word joiner and invisible operators (U+2060 to U+2064), and the tag characters (U+E0000 to U+E007F).
  • A tag character is one code point stored as a surrogate pair. The pattern's u flag matches it as one, so it renders as one badge, named for the full code point (⟨U+E0041⟩), and copies as sent.
  • The variation selectors (U+FE00 to U+FE0F) stay out, so emoji keep their look.
  • U+200D (zero-width joiner), which is in the issue's set, also joins emoji ZWJ sequences, so an emoji such as a family or a profession emoji shows a badge between its parts. This is a deliberate trade-off: the joiner can hide in a command like any other zero-width character, so it stays in the set.

Docs

user-docs/operating/studio.md gains two sentences in "Review tool calls and plans": which characters show as badges, and that copied text keeps them.

Difference from the prototype

The prototype has no such handling. Its ask-args-view.tsx shows the command in the same fixed-height scroll box with no line count, and passes these characters through unchanged in every view. Both changes are deliberate additions beyond the prototype. Everything else on the card stays as the existing port has it.

Not in this PR

The transcript's tool-call summary line above the card and the Edit and Write diff view still show these characters as sent. Both are follow-ups. Meanwhile, the chip appears whenever an ask's arguments carry one, and Raw arguments shows them as badges.

No regression

Pins first. test(studio): pin the approval card's argument views (ask-args-view.pinning.test.tsx, 8 tests) landed before the change and passes on the base and on this branch:

  • one-, three-, and twelve-line commands render exactly their text as plain text, with the same four controls (Raw arguments, Allow once, Always allow, Deny);
  • Raw arguments shows exactly the JSON sent, and other arguments show exactly their formatted JSON;
  • the card keeps the command, raw, JSON, and Edit diff views in a compact scroll box;
  • the detail panel shows a 60-line command whole, with no cap and no toggle.

No existing test was modified or deleted. Existing coverage of the diff limits ("more diff lines" on the card, Show all 61 lines in the detail panel), verdict order and tab stops, shortcuts, tone, and the plan card is unchanged and passes.

New tests. ask-args-view.test.tsx (61 tests):

  • a 60-line command shows "60 lines" and Show 48 more lines (aria-expanded, aria-controls), expands to the whole command with no scroll cap, and collapses again; 13 lines reads Show 1 more line; the timeout row stays outside the scroll box; a wrapped single line that overflows offers Show full command;
  • each of the issue's 13 code points renders as a badge with its label and accessible name in the command, raw, and JSON views, with the view's text unchanged;
  • one test per added range (the implicit bidi marks, the word joiner and invisible operators, and all 128 tag characters) checks the same in all three views, one badge per code point, in order;
  • a tag character, one surrogate pair, renders as one badge named U+E0041, and selecting the command or the raw arguments yields the exact original string;
  • emoji with variation selectors (U+FE0F, U+FE0E) render unchanged, with no badge and no chip;
  • a JSON-escaped character shows decoded in the command view and as sent in the raw view; the temporary-storage scope is badged too;
  • the chip appears only when the arguments carry such a character, including in a line the card has not expanded yet and in Edit arguments (whose diff stays unchanged);
  • selecting a whole command, raw, or JSON view yields the exact original string;
  • detection: every code point of each added range is found, and the neighbouring U+061B, U+061D, U+200A, U+2010, U+2029, U+202F, U+205F, U+2065, U+206A, U+FE00, U+FE0F, U+FEFE, U+FF00, U+DFFFF, and U+E0080 are left alone. U+200E, which this list held before the set grew, is now covered by the bidi-marks tests.

apps/web/e2e/approval-command-view.spec.ts (3 journeys, desktop and phone) checks in Chromium what Happy DOM can't: the count and toggle sit in view outside the command's scroll box; a long wrapped line offers Show full command; each badge is visible with its CSS label, including a tag character's; the words after a U+202E stay in reading order; and the clipboard gets the exact command and raw arguments, surrogate pair included. The screenshot runs measured the same order: on the base, "notes" in docs/<U+202E>notes.txt sits to the right of "txt" (488 px vs 460 px on desktop), and on this branch to its left (595 px vs 638 px).

Mutation proof. Each mutation was applied to the head and reverted. The unit runs cover the 61 new tests and the 8 pins:

Mutation Result
ask-args-view.tsx reverted to the base 28 fail; the 8 pins, detection, and emoji tests pass
Badge label drawn as text instead of with CSS 23 fail, including every copy and per-code-point test
No chip 8 fail
No line cap or toggle 6 fail, including the pin for the compact scroll box
U+FEFF dropped from the set 5 fail
Set cut back to the issue's 13 code points 7 fail: the three added-range tests, their three detection tests, and the tag-character test
Renderer advances one code unit past a match 2 fail: the tag block and the tag-character test
Badge label taken from the first code unit 2 fail: the tag block and the tag-character test
Variation selectors added to the set 3 fail: the emoji test and the U+FE00 and U+FE0F boundaries
Badge as a plain inline box (no isolation), browser the invisible-characters journey fails at the reading-order assertion on desktop and phone
The whole web change reverted, browser all 6 journeys fail

Screenshots

Each frame is Before (base 42b933fb4) | After (this branch) | Prototype (stack-08). The prototype column is its own fixture chat, with the pending ask's arguments replaced by the same command. Red boxes mark before/after differences of 40 px or more. Each tree was captured twice, and the runs match apart from 32 px of anti-aliasing at the left page edge of one phone frame. The frames use only the issue's characters, so the follow-up commit that extends the set leaves them unchanged.

Long command, desktop light. After shows the first 12 lines, "60 lines", and Show 48 more lines, with the timeout row in view. Deliberate deviation: the prototype shows the same scroll box as Before, with no line count.

Long command, desktop light

Invisible characters, desktop light. After shows each character as a badge and the Contains invisible characters chip, and "notes.txt" reads in order after the U+202E badge. Deliberate deviation: the prototype, like Before, renders the characters as sent, so the override reverses "notes.txt".

Invisible characters, desktop light

Long command: phone and dark

Long command, desktop dark
Long command, phone light
Long command, phone dark

Invisible characters: phone and dark

Invisible characters, desktop dark
Invisible characters, phone light
Invisible characters, phone dark

The card alone: collapsed, expanded, and raw arguments

Long command, collapsed:

Card, long command, desktop light
Card, long command, desktop dark
Card, long command, phone light
Card, long command, phone dark

Long command, after Show 48 more lines (Before and Prototype have no toggle, so they show their only state):

Card, long command expanded, desktop light
Card, long command expanded, desktop dark
Card, long command expanded, phone light
Card, long command expanded, phone dark

Invisible characters, command view:

Card, invisible characters, desktop light
Card, invisible characters, desktop dark
Card, invisible characters, phone light
Card, invisible characters, phone dark

Invisible characters, Raw arguments:

Card, raw arguments, desktop light
Card, raw arguments, desktop dark
Card, raw arguments, phone light
Card, raw arguments, phone dark

Gates

All gates ran through the shared gate lock, on this branch's head ca850bc9a, which is unchanged by the stack assembly (it sits directly on main).

Gate Base (42b933fb4) This branch (ca850bc9a)
task studio:check web 169 files, 1419 tests; server 26 files, 210 tests; generated check clean web 171 files, 1488 tests (+69); server 26 files, 210 tests; generated check clean
task studio:browser 148 tests: 118 passed, 30 skipped 154 tests: 124 passed, 30 skipped
task docs passes: matlatl strict checks 185 documents and 1,816 references with 0 broken links or anchors, 0 orphans, and 0 unreachable pages; the regenerated references show no drift

The 30 skipped journeys are the phone-only checks on the desktop project, as on the base. The +69 web tests are the 8 pins and the 61 new tests; the 6 new browser tests are the 3 journeys in both projects.

Closes #2259
Part of #2210

🤖 Generated with Claude Code

peppescg and others added 3 commits October 14, 2026 15:05
Pin what #2259 must not change before it changes the command view: an
ordinary command, its raw arguments, and a JSON view keep exactly their
text and the card's controls; the card keeps each view in its compact
scroll box; the Edit diff keeps its box; and the detail panel shows a
long command whole, with no cap and no toggle.

Refs #2259

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…ters

The approval card's command view showed a long command's first lines in a
fixed-height scroll box, with nothing saying more followed. It also
passed bidirectional controls and zero-width characters through
unchanged, so the text a reviewer read could differ from the text that
runs.

- A command longer than 12 lines shows its first 12, its line count, and
  a "Show N more lines" toggle that expands the whole command. A command
  whose wrapped lines overflow the box gets "Show full command". The
  detail panel still shows the whole command.
- The command, raw, and JSON views show U+202A-U+202E, U+2066-U+2069,
  U+200B-U+200D, and U+FEFF as badges such as ⟨U+202E⟩, named
  "invisible character U+202E" for assistive technology. The badge keeps
  the character as its text and draws the label with CSS, so copying
  yields the exact original text, and its box stops a bidirectional
  control from reordering the text around it.
- A "Contains invisible characters" chip appears beside Raw arguments
  when the arguments carry any, as sent or JSON-escaped.

The verdict buttons, shortcuts, diff view, and approval decision are
unchanged.

Closes #2259

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Extend the approval card's invisible-character set beyond the issue's
code points:

- the implicit bidi marks U+200E, U+200F, and U+061C;
- the word joiner U+2060 and the invisible operators U+2061-U+2064;
- the tag characters U+E0000-U+E007F. Each is one code point stored as a
  surrogate pair, which the pattern's u flag matches as one, so it
  renders as one badge and copies as sent.

The variation selectors U+FE00-U+FE0F stay out, so emoji keep their
look.

The detection boundary test no longer lists U+200E, which joined the
set; it gains U+061B, U+061D, U+2010, U+205F, U+FE00, U+FE0F, U+DFFFF,
and U+E0080. The browser journey adds a tag character.

Refs #2259

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@kantord

kantord commented Oct 14, 2026

Copy link
Copy Markdown
Member

Not a blocker for this PR, but looking at the screenshots, it would be nice to have syntax highlighting for bash commands, or integrating a bash explainer (I think there are open source packages for that)

In any case if you agree this would be more like a follow up question for James than anything

@peppescg
peppescg merged commit 1210721 into main Oct 15, 2026
31 checks passed
@peppescg
peppescg deleted the fix/studio-approval-command-view-2259 branch October 15, 2026 08:29
@toolhive-release-app toolhive-release-app Bot mentioned this pull request Oct 20, 2026
2 tasks

This branch was successfully deployed

1 active deployment
Preview — ca850bc9 Deployed Oct 14, 2026 by vercel[bot]
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.

Studio chat: show long and invisible-character shell commands faithfully on the approval card

2 participants