Skip to content

Enhancement: show each chained command on its own line in approvals - #5225

Open
stefanroex wants to merge 2 commits into
get-bb:mainfrom
stefanroex:format-long-shell-commands
Open

stefanroex wants to merge 2 commits into
get-bb:mainfrom
stefanroex:format-long-shell-commands

Conversation

@stefanroex

@stefanroex stefanroex commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Human comments

What was wrong

Agents often chain several commands into one line with &&, | and ;. The approval card shows that as a single line, and some get so long that it's hard to grasp what you're actually approving.

What changed

  • New formatShellCommandForDisplay in @bb/thread-view. Commands over 80 characters get a new line after each top-level &&, || and ;, and after pipes only if the line is still too long. It never breaks inside quotes, substitutions, subshells or if/for blocks, and returns anything it can't parse unchanged.
  • It only adds whitespace, so the card shows exactly what runs and the text is still valid shell.
  • The approval card uses it. The four-line preview and horizontal scroll for unsplittable lines stay as they were.

No wire, CLI or SDK changes. The timeline is unchanged.

How you verified

  • Unit tests for the formatter, and a banner test that fails against main.
  • pnpm exec turbo run typecheck lint test --filter=@bb/app --filter=@bb/thread-view passes.
  • Checked the Approval story in Ladle on desktop and mobile:
Before After
bb-command-format-approval-before bb-command-format-approval-after

AGENT GENERATED

Agents often write a sequence of shell commands as one long line,
chained with &&, || and pipes. That is hard to read, especially when
you have to approve it. formatShellCommandForDisplay puts each
chained command of a long one-liner on its own line, and only splits
a pipeline when its line is still too long.

It only adds line breaks after operators at the top level of the
command, never inside quotes, substitutions, subshells or if/for
blocks. The result is still valid shell and shows exactly what will
run. A command that already spans several lines, or that contains
something it does not fully understand (such as a case statement or
an unbalanced quote), is returned unchanged.
A long one-liner in the approval card now shows each chained command
on its own line, so you can see what an agent wants to run before you
approve it, instead of scrolling along one long line.

The card keeps its compact four-line preview: a long chain shows its
first four lines with a "Show N more lines" control, just like a
multi-line script.

This branch has not been deployed

No deployments
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