Repository navigation
fix(chat): show a shell command's text instead of escaped JSON - #1396
Conversation
…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 <noreply@anthropic.com>
|
Thanks for this. I checked it against current main. Since #1324, a finished bash call already shows I pushed a slimmer version on top. Instead of a bash/powershell name list, a second view and a hand-written partial-string decoder, the streamed input now goes through pi-ai's own The header keeps the plain command preview, and the timeout stays a row as on main. The demo uses |
Reproduce on main: run any multi-line
bashcall (e.g. a heredoc script) and expand its card. Finished calls showJSON.stringifyoutput with\nescapes; while the call streams, the card shows the rawrawInputJSON. Newlines never render as line breaks.Cause: the expanded card only had a dedicated view for
writetext, codemode scripts and patches; everything else fell back to JSON text, which by spec escapes newlines inside strings.Change:
bash/powershellcalls (newisBashToolName, matchinglib/tool-names.tsconventions) with exactly{ command, timeout? }now show the command text with real line breaks, finished and while streaming. Streaming input decodes thecommandstring up to the last chunk (mid-escape cuts included); unparseable input, empty commands and calls with extra arguments keep the old view, so nothing is hidden.(timeout Ns), as pi's TUI shows $ followed by the command and a timeout suffix; while streaming it shows the partial command instead of "Generating parameters" once it parses.demo/; topic note updated indocs/agents/sessions.md.Checks:
MessageView51/51 (3 new tests),tsc --noEmitclean, eslint clean (main + demo configs). Fullnpm test: 2870/2873 — the 2 failures (rpc-manager-chat-onlymodel naming, worktree listing) reproduce on cleanmainand are unrelated.Before

After
