Repository navigation
feat(chat): show a tool call's flat arguments as rows - #1324
Conversation
A tool card replaced its arguments with an indented JSON blob, so a read's scope, a write's path and a subagent's prompt all read as source text. One row per argument suits any call whose arguments are single values. The rule is structural rather than a list of tool names or keys, so package and MCP tools are covered with nothing to maintain, and it is all of the arguments or none: one object or array value — an `edit` call's `edits[]`, an MCP argument holding a list — takes the whole card back to the JSON, because a row that quietly drops a subtree is an argument the user never sees. - `lib/tool-fields.ts` turns an input record into rows or returns `null`, so the fallback is one value rather than a case in the component. - `components/KeyValueTable.tsx` holds the rows and the capped value block a value with newlines of its own scrolls inside, keeping them as lines. - A card with a richer view keeps it: codemode (the script and its calls) and an applied patch (the split diff). - `write` loses its narrower `getWrittenFileText()`: it printed the file's text and dropped the path the call was about. - Checked in a headless render, not only in assertions: rows for read, write, Agent and flat MCP arguments; no table for `edits[]`, for an MCP argument carrying a list, or for input still streaming; multi-line values scroll inside 260px and nothing overflows the card.
|
CI is green now (run 39085078903: The two earlier e2e reds on this branch were the known flake at |
…t rows A write of just a path and its text keeps the file-text view from agegr#1024: the card's header already shows the path, so a path row repeated it and capped the file in a 260px box. The rows now follow the chat font size setting (calc(12px + --chat-font-size-offset)) like the JSON body they replace. The one-use KeyValueTable component folds into MessageView as ToolFieldRows. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Copy lib/tool-fields.ts and the rows view into the demo's MessageView, with the write file-text view the app has, so demo tool cards match. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Thanks @brynne8, this reads much better for calls with multi-line arguments like a subagent prompt or a heredoc command, and the all-or-nothing rule for nested values is the right call. I pushed two small commits on top:
A write with any other argument still gets your rows. tsc, lint and |
# Conflicts: # AGENTS.md
Returning from the mobile breakpoint restores the desktop sidebar preference in an
effect, so the toggle can swap from "Show sidebar" to "Hide sidebar" between the
`isVisible()` check and the click. The click then waits its full 30s for a button
that will not come back, and the suite dies with
locator.click: Timeout 30000ms exceeded. waiting for
getByRole('button', { name: 'Show sidebar', exact: true }) at e2e/run.mjs:496:60
Seen on several unrelated PRs (#1322, #1324 ourselves, #1308 from another
contributor).
The click now retries against a short deadline and only its own timeout is
ignored; the wait for "Hide sidebar" that follows still fails if the sidebar never
opens, so a real regression is not hidden. The fork's earlier 947c7fe reload
fallback does not cover this signature: it fires only when neither toggle appears
within its 10s bound.
Keeps the dev-side features (keepalive dock, turnRendered chat, ThinkingRow paging, minimap, chat-only, mobile PWA) and takes main's architecture where it superseded local copies (lease/reattach stream model agegr#1328, applyLoadedAgentState, live active time agegr#1334, tool argument rows agegr#1324, patch two-column view agegr#1325, search highlights).
…of a shell special case Main already shows a finished bash call's command as a row whose block keeps its real line breaks (lib/tool-fields.ts, agegr#1324); only input still streaming fell back to the raw JSON with `\n` escapes. Rather than a bash/powershell name list, a second view and a hand-written partial string decoder, feed the streamed text through pi-ai's parseStreamingJson() (the partial arguments pi's TUI hands renderCall while a call streams) into the existing rows. Structural like the rows themselves: any tool whose arguments so far are flat gets them as rows (a multi-line command, a codemode script, a write's text); nothing parsed yet or a nested argument begun keeps the raw text. The parse runs only for an expanded card. The demo has no pi-ai and calls partial-json, the parser parseStreamingJson() wraps. Reverts the PR's isBashToolName, BashCommandView, header preview and decoder. Co-Authored-By: Claude Opus 5.5 <[email protected]>
* fix(chat): show a shell command's text instead of escaped JSON * fix(chat): read streaming tool input with pi's partial parse instead of a shell special case Main already shows a finished bash call's command as a row whose block keeps its real line breaks (lib/tool-fields.ts, #1324); only input still streaming fell back to the raw JSON with `\n` escapes. Rather than a bash/powershell name list, a second view and a hand-written partial string decoder, feed the streamed text through pi-ai's parseStreamingJson() (the partial arguments pi's TUI hands renderCall while a call streams) into the existing rows. Structural like the rows themselves: any tool whose arguments so far are flat gets them as rows (a multi-line command, a codemode script, a write's text); nothing parsed yet or a nested argument begun keeps the raw text. The parse runs only for an expanded card. The demo has no pi-ai and calls partial-json, the parser parseStreamingJson() wraps. Reverts the PR's isBashToolName, BashCommandView, header preview and decoder. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Alex Yang <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
* feat(chat): show a tool call's flat arguments as rows A tool card replaced its arguments with an indented JSON blob, so a read's scope, a write's path and a subagent's prompt all read as source text. One row per argument suits any call whose arguments are single values. The rule is structural rather than a list of tool names or keys, so package and MCP tools are covered with nothing to maintain, and it is all of the arguments or none: one object or array value — an `edit` call's `edits[]`, an MCP argument holding a list — takes the whole card back to the JSON, because a row that quietly drops a subtree is an argument the user never sees. - `lib/tool-fields.ts` turns an input record into rows or returns `null`, so the fallback is one value rather than a case in the component. - `components/KeyValueTable.tsx` holds the rows and the capped value block a value with newlines of its own scrolls inside, keeping them as lines. - A card with a richer view keeps it: codemode (the script and its calls) and an applied patch (the split diff). - `write` loses its narrower `getWrittenFileText()`: it printed the file's text and dropped the path the call was about. - Checked in a headless render, not only in assertions: rows for read, write, Agent and flat MCP arguments; no table for `edits[]`, for an MCP argument carrying a list, or for input still streaming; multi-line values scroll inside 260px and nothing overflows the card. * fix(chat): keep the write file view and the chat font size in argument rows A write of just a path and its text keeps the file-text view from agegr#1024: the card's header already shows the path, so a path row repeated it and capped the file in a 260px box. The rows now follow the chat font size setting (calc(12px + --chat-font-size-offset)) like the JSON body they replace. The one-use KeyValueTable component folds into MessageView as ToolFieldRows. Co-Authored-By: Claude Opus 5.5 <[email protected]> * feat(demo): mirror a tool call's flat arguments as rows Copy lib/tool-fields.ts and the rows view into the demo's MessageView, with the write file-text view the app has, so demo tool cards match. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Alex Yang <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
…gr#1326) Returning from the mobile breakpoint restores the desktop sidebar preference in an effect, so the toggle can swap from "Show sidebar" to "Hide sidebar" between the `isVisible()` check and the click. The click then waits its full 30s for a button that will not come back, and the suite dies with locator.click: Timeout 30000ms exceeded. waiting for getByRole('button', { name: 'Show sidebar', exact: true }) at e2e/run.mjs:496:60 Seen on several unrelated PRs (agegr#1322, agegr#1324 ourselves, agegr#1308 from another contributor). The click now retries against a short deadline and only its own timeout is ignored; the wait for "Hide sidebar" that follows still fails if the sidebar never opens, so a real regression is not hidden. The fork's earlier 947c7fe reload fallback does not cover this signature: it fires only when neither toggle appears within its 10s bound.
…#1396) * fix(chat): show a shell command's text instead of escaped JSON * fix(chat): read streaming tool input with pi's partial parse instead of a shell special case Main already shows a finished bash call's command as a row whose block keeps its real line breaks (lib/tool-fields.ts, agegr#1324); only input still streaming fell back to the raw JSON with `\n` escapes. Rather than a bash/powershell name list, a second view and a hand-written partial string decoder, feed the streamed text through pi-ai's parseStreamingJson() (the partial arguments pi's TUI hands renderCall while a call streams) into the existing rows. Structural like the rows themselves: any tool whose arguments so far are flat gets them as rows (a multi-line command, a codemode script, a write's text); nothing parsed yet or a nested argument begun keeps the raw text. The parse runs only for an expanded card. The demo has no pi-ai and calls partial-json, the parser parseStreamingJson() wraps. Reverts the PR's isBashToolName, BashCommandView, header preview and decoder. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Alex Yang <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
* feat(chat): show a tool call's flat arguments as rows A tool card replaced its arguments with an indented JSON blob, so a read's scope, a write's path and a subagent's prompt all read as source text. One row per argument suits any call whose arguments are single values. The rule is structural rather than a list of tool names or keys, so package and MCP tools are covered with nothing to maintain, and it is all of the arguments or none: one object or array value — an `edit` call's `edits[]`, an MCP argument holding a list — takes the whole card back to the JSON, because a row that quietly drops a subtree is an argument the user never sees. - `lib/tool-fields.ts` turns an input record into rows or returns `null`, so the fallback is one value rather than a case in the component. - `components/KeyValueTable.tsx` holds the rows and the capped value block a value with newlines of its own scrolls inside, keeping them as lines. - A card with a richer view keeps it: codemode (the script and its calls) and an applied patch (the split diff). - `write` loses its narrower `getWrittenFileText()`: it printed the file's text and dropped the path the call was about. - Checked in a headless render, not only in assertions: rows for read, write, Agent and flat MCP arguments; no table for `edits[]`, for an MCP argument carrying a list, or for input still streaming; multi-line values scroll inside 260px and nothing overflows the card. * fix(chat): keep the write file view and the chat font size in argument rows A write of just a path and its text keeps the file-text view from agegr#1024: the card's header already shows the path, so a path row repeated it and capped the file in a 260px box. The rows now follow the chat font size setting (calc(12px + --chat-font-size-offset)) like the JSON body they replace. The one-use KeyValueTable component folds into MessageView as ToolFieldRows. Co-Authored-By: Claude Opus 5.5 <[email protected]> * feat(demo): mirror a tool call's flat arguments as rows Copy lib/tool-fields.ts and the rows view into the demo's MessageView, with the write file-text view the app has, so demo tool cards match. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Alex Yang <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
…gr#1326) Returning from the mobile breakpoint restores the desktop sidebar preference in an effect, so the toggle can swap from "Show sidebar" to "Hide sidebar" between the `isVisible()` check and the click. The click then waits its full 30s for a button that will not come back, and the suite dies with locator.click: Timeout 30000ms exceeded. waiting for getByRole('button', { name: 'Show sidebar', exact: true }) at e2e/run.mjs:496:60 Seen on several unrelated PRs (agegr#1322, agegr#1324 ourselves, agegr#1308 from another contributor). The click now retries against a short deadline and only its own timeout is ignored; the wait for "Hide sidebar" that follows still fails if the sidebar never opens, so a real regression is not hidden. The fork's earlier 947c7fe reload fallback does not cover this signature: it fires only when neither toggle appears within its 10s bound.
…#1396) * fix(chat): show a shell command's text instead of escaped JSON * fix(chat): read streaming tool input with pi's partial parse instead of a shell special case Main already shows a finished bash call's command as a row whose block keeps its real line breaks (lib/tool-fields.ts, agegr#1324); only input still streaming fell back to the raw JSON with `\n` escapes. Rather than a bash/powershell name list, a second view and a hand-written partial string decoder, feed the streamed text through pi-ai's parseStreamingJson() (the partial arguments pi's TUI hands renderCall while a call streams) into the existing rows. Structural like the rows themselves: any tool whose arguments so far are flat gets them as rows (a multi-line command, a codemode script, a write's text); nothing parsed yet or a nested argument begun keeps the raw text. The parse runs only for an expanded card. The demo has no pi-ai and calls partial-json, the parser parseStreamingJson() wraps. Reverts the PR's isBashToolName, BashCommandView, header preview and decoder. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Alex Yang <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
…#1396) * fix(chat): show a shell command's text instead of escaped JSON * fix(chat): read streaming tool input with pi's partial parse instead of a shell special case Main already shows a finished bash call's command as a row whose block keeps its real line breaks (lib/tool-fields.ts, agegr#1324); only input still streaming fell back to the raw JSON with `\n` escapes. Rather than a bash/powershell name list, a second view and a hand-written partial string decoder, feed the streamed text through pi-ai's parseStreamingJson() (the partial arguments pi's TUI hands renderCall while a call streams) into the existing rows. Structural like the rows themselves: any tool whose arguments so far are flat gets them as rows (a multi-line command, a codemode script, a write's text); nothing parsed yet or a nested argument begun keeps the raw text. The parse runs only for an expanded card. The demo has no pi-ai and calls partial-json, the parser parseStreamingJson() wraps. Reverts the PR's isBashToolName, BashCommandView, header preview and decoder. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Alex Yang <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
What it does
A tool card expands to one label/value row per argument when every argument is a single value, instead of the indented JSON blob it shows today. A
readreads aspath,offset,limit; awriteshows the path next to the text it wrote; a subagent call showssubagent_typeandprompt; an MCP call shows its own arguments (query,limit).The rule is structural, not a list of tool names or keys, so package and MCP tools are covered with nothing to keep current. It is also all-or-none: one object or array value — an
editcall'sedits[], an MCP argument holding a list — takes the whole card back to the JSON, because a one-level table cannot show a tree and a row that quietly drops a subtree is an argument the user never sees.lib/tool-fields.tsturns an input record into rows, or returnsnullfor anything that is not a flat record (nested, empty, not an object), so the fallback is one value rather than a case in the component.components/KeyValueTable.tsxholds the rows and the capped value block a multi-line value scrolls inside (260px), keeping its own newlines instead of folding them into one line.writeloses its narrowergetWrittenFileText()view, which printed the file's text and dropped the path the call was actually about; the table covers the same ground including the file name.Why it matters
Today every tool call replaces its arguments with an indented JSON blob, so a read's scope, a write's path and a subagent's prompt all read as source text rather than as the facts they are — a reading cost on every expanded card. The row form was already used for other structured output in this codebase, and it suits any call whose arguments are single values.
Scope
One change split out of a Bun-running fork (
brynne8/pi-web-bun) into a single-purpose branch on today'smain; one feature per PR.Touched:
lib/tool-fields.ts(new),lib/tool-fields.test.mjs(new),components/KeyValueTable.tsx(new),components/MessageView.tsx,components/MessageView.test.mjs,docs/agents/sessions.md,AGENTS.md. No unrelated forked code, no new i18n key: the only new literal is the empty-argument placeholder(empty)inlib/tool-fields.ts, which matches the existing(empty)placeholder inlib/file-upload.tsrather than a card label.The card's shell view is not part of this branch: that view lives in a separate fork-only change and does not exist upstream, so a
bashcall's flat arguments (command,timeout,run_in_background) table like any other call rather than being excluded.Testing
Baseline
npm testonorigin/main: 2778 tests, 2777 pass, 1 skipped, 0 fail. This branch adds 11 tests, all passing; no failing test on either side.The new rendering is asserted in a headless render, not only in unit assertions:
read, awrite(including its path, an extramodeargument and an(empty)value), a subagent call (Agent) and a flat MCP call;editcall (edits[]), for an MCP argument holding an object/list, or for input that is still streaming (which keeps its raw text);Baseline on
origin/main(git worktree add "$(mktemp -d)/base" origin/main, thenbun test components/MessageView.test.mjs) — 37 pass, 5 fail, the failures being exactly the new expectations:Whole-suite caveat: the full
bun testrun does not complete in the review sandbox — it stalls afterlib/mcp-sign-in.test.mjsand carries ~106 pre-existing failures there (Bun 1.4.3'snode:modulehas neitherstripTypeScriptTypesnorregisterHooks, so several files fail at import). The same run onorigin/mainstalls identically with ~106 failures across ~44 files; the four files whose results differed between the two runs under load all pass when re-run on both sides (lib/agent-event-stream,lib/web-auth,lib/mcp-host,lib/file-tree-visibility,lib/mcp-tool-display: 76 pass / 13 fail each, identical). CI runsnpm test, which is green.Provenance
Source commit:
56a887d— "feat(chat): show a tool card's flat arguments as rows" onbrynne8/pi-web-bun.Adapted for this tree: that commit's
shellCommandguard belongs to a separate fork-only shell card (BashCommand) that does not exist upstream, so the guard here covers the views this tree actually has (streaming input, codemode, applied patch). Thewritespecial case it removes is the samegetWrittenFileText()this tree had.