Skip to content

feat(chat): show a tool call's flat arguments as rows - #1324

Merged
agegr merged 4 commits into
agegr:mainfrom
brynne8:feat/tool-argument-rows
Oct 20, 2026
Merged

agegr merged 4 commits into
agegr:mainfrom
brynne8:feat/tool-argument-rows

Conversation

@brynne8

@brynne8 brynne8 commented Oct 18, 2026

Copy link
Copy Markdown
Contributor

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 read reads as path, offset, limit; a write shows the path next to the text it wrote; a subagent call shows subagent_type and prompt; 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 edit call's edits[], 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.ts turns an input record into rows, or returns null for 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.tsx holds 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.
  • A card with a view of its own keeps it: a codemode call still shows its script and the calls the script made, and an applied patch still shows the split diff.
  • write loses its narrower getWrittenFileText() 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's main; 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) in lib/tool-fields.ts, which matches the existing (empty) placeholder in lib/file-upload.ts rather 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 bash call's flat arguments (command, timeout, run_in_background) table like any other call rather than being excluded.

Testing

bun test lib/tool-fields.test.mjs components/MessageView.test.mjs   # 48 pass, 0 fail
bun x tsc --noEmit                                                  # clean
bun run lint                                                        # clean
npm test    # Node 26.7.0, CI's runner: 2789 tests, 2788 pass, 1 skipped, 0 fail
bun test    # touched files green; whole-suite caveat below

Baseline npm test on origin/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:

  • rows for a read, a write (including its path, an extra mode argument and an (empty) value), a subagent call (Agent) and a flat MCP call;
  • no table for an edit call (edits[]), for an MCP argument holding an object/list, or for input that is still streaming (which keeps its raw text);
  • a multi-line value keeps its lines inside a 260px scrollable block, and a single-line value wraps in its cell, so nothing overflows the card.

Baseline on origin/main (git worktree add "$(mktemp -d)/base" origin/main, then bun test components/MessageView.test.mjs) — 37 pass, 5 fail, the failures being exactly the new expectations:

(fail) renders a write as its arguments, not as a JSON blob
(fail) every flat argument gets a row, so an extra one cannot hide
(fail) a read, a subagent and a flat MCP call show one row per argument
(fail) a long or multi-line value stays inside the card
(fail) a codemode call with no script or streaming input falls back to a plain body

Whole-suite caveat: the full bun test run does not complete in the review sandbox — it stalls after lib/mcp-sign-in.test.mjs and carries ~106 pre-existing failures there (Bun 1.4.3's node:module has neither stripTypeScriptTypes nor registerHooks, so several files fail at import). The same run on origin/main stalls 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 runs npm test, which is green.

Provenance

Source commit: 56a887d — "feat(chat): show a tool card's flat arguments as rows" on brynne8/pi-web-bun.

Adapted for this tree: that commit's shellCommand guard 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). The write special case it removes is the same getWrittenFileText() this tree had.

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.
@brynne8 brynne8 closed this Oct 18, 2026
@brynne8 brynne8 reopened this Oct 18, 2026
@brynne8 brynne8 closed this Oct 18, 2026
@brynne8 brynne8 reopened this Oct 18, 2026
@brynne8

brynne8 commented Oct 18, 2026

Copy link
Copy Markdown
Contributor Author

CI is green now (run 39085078903: checks pass 3m11s, e2e pass 3m44s).

The two earlier e2e reds on this branch were the known flake at e2e/run.mjs:496 — getByRole('button', { name: 'Show sidebar', exact: true }) timing out at the sidebar-toggle step that runs after the viewport returns from the mobile breakpoint. It is not this change: the branch touches only tool-card argument rendering and no sidebar or e2e file, and the same line has failed on other PRs (#1322, #1308). A fresh pull_request run passed both checks with no code change.

agegr and others added 2 commits October 19, 2026 21:40
…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]>
@agegr

agegr commented Oct 19, 2026

Copy link
Copy Markdown
Owner

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:

  • 0a207d135: a write of just a path and its text keeps Render write() tool content as readable file text #1024's file-text view. The card header already shows the path (getToolPreview()), so the path row repeated it and squeezed the file into a 260px box. The rows now also follow the chat font size setting (calc(12px + --chat-font-size-offset)), like the JSON body they replace, and the one-use KeyValueTable is folded into MessageView as ToolFieldRows.
  • 0b0a59da9: the same view in the demo/ copy of MessageView, so the demo's tool cards match.

A write with any other argument still gets your rows. tsc, lint and npm test pass on the branch merged with main.

@agegr
agegr merged commit 083fd11 into agegr:main Oct 20, 2026
3 checks passed
agegr pushed a commit that referenced this pull request Oct 20, 2026
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.
Hwwwww-dev pushed a commit to Hwwwww-dev/pi-web that referenced this pull request Oct 22, 2026
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).
agegr added a commit to sirenkovladd/pi-web that referenced this pull request Oct 29, 2026
…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]>
agegr added a commit that referenced this pull request Oct 29, 2026
* 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]>
windli2018 pushed a commit to aiti-ai/aiti-ai that referenced this pull request Nov 6, 2026
* 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]>
windli2018 pushed a commit to aiti-ai/aiti-ai that referenced this pull request Nov 6, 2026
…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.
windli2018 pushed a commit to aiti-ai/aiti-ai that referenced this pull request Nov 6, 2026
…#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]>
windli2018 pushed a commit to aiti-ai/aiti-ai that referenced this pull request Nov 8, 2026
* 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]>
windli2018 pushed a commit to aiti-ai/aiti-ai that referenced this pull request Nov 8, 2026
…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.
windli2018 pushed a commit to aiti-ai/aiti-ai that referenced this pull request Nov 8, 2026
…#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]>
windli2018 pushed a commit to aiti-ai/aiti-ai that referenced this pull request Nov 8, 2026
…#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]>
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.

2 participants