Skip to content

fix(opencode): show bash commands instead of repeating their output - #7989

Open
brynne8 wants to merge 2 commits into
pingdotgg:mainfrom
brynne8:fix/opencode-bash-command-preview
Open

fix(opencode): show bash commands instead of repeating their output#7989
brynne8 wants to merge 2 commits into
pingdotgg:mainfrom
brynne8:fix/opencode-bash-command-preview

Conversation

@brynne8

@brynne8 brynne8 commented Aug 23, 2026

Copy link
Copy Markdown

Fixes #7307

Problem

With the OpenCode provider, bash tool calls showed the command output as the collapsed row title and the same output again inside the expanded body — the actual command being run was never visible (see screenshot in #7307). Claude and Codex users were not affected.

Root cause

The OpenCode adapter emitted item.completed with detail set to the command's output (part.state.output) while never reading the real invocation at part.state.input.command. For command_execution items, clients fall back to treating detail as the command when no structured command field is present, so:

  • collapsed title := command fallback = output
  • expanded body := command block + detail block = output twice
  • the actual command was dropped entirely

Fix

Adapter-side, one place fixes web/desktop/mobile. The message.part.updated handler now projects command tools into the payload shape clients already render for Claude/Codex:

  • detail / data.command carry the command (state.input.command)
  • on completion the output moves to data.rawOutput.content, which clients render once in the expanded view
  • the unread raw data.state blob is no longer sent (nothing consumed it; it duplicated the whole output over the websocket)

Error states keep surfacing state.error; non-command tools are unchanged.

Testing

  • Added an adapter test asserting running/completed projections (OpenCodeAdapter.test.ts)
  • Added a client-shape test asserting the OpenCode payload renders as command + single output (session-logic.command-output.test.ts)

Worked on by ox-alpha via opencode.


Note

Medium Risk
Changes provider event payloads for command tools, including dropping data.state. Low blast radius but it is a wire-format change for OpenCode tool items.

Overview
Fixes OpenCode bash rows showing stdout as the collapsed title (and again in the expanded body) instead of the actual command (#7307).

OpenCodeAdapter now reads state.input.command for command_execution items. detail/data.command carry the invocation; completed output moves to data.rawOutput.content. Failures still use state.error as detail while keeping data.command. The unused data.state blob is no longer sent.

A client work-log test confirms the new payload renders as command + a single output block.

Reviewed by Cursor Bugbot for commit e343705. Bugbot is set up for automated code reviews on this repo. Configure here.

Note

Fix OpenCodeAdapter to show bash commands instead of repeating output

  • Modifies tool-part event projection in OpenCodeAdapter.ts to set payload.detail to the command string for command_execution items, and to payload.data.rawOutput for the tool output on completion
  • Adds commandFromToolInput helper to extract a trimmed command from a tool part's state.input.command
  • For error states, payload.detail shows the failure reason while payload.data.command preserves the original command
  • Behavioral Change: removes the entire state object from payload.data; consumers expecting data.state must use data.command and data.rawOutput instead

Macroscope summarized e343705.

OpenCode bash tool calls rendered the command output as the collapsed
row title and again inside the expanded body while the actual command
was never visible (pingdotgg#7307). The adapter dropped `state.input.command`
and stuffed the output into `detail`, so clients fell back to reading
`detail` as the command.

Project the invocation into the shape clients already render for
Claude/Codex: `detail`/`data.command` carry the command and the output
moves to `data.rawOutput.content`. The unread raw `state` blob is no
longer duplicated over the wire.

Worked on by ox-alpha via opencode.
@coderabbitai

coderabbitai Bot commented Aug 23, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 1ba432d1-846c-4f54-aedd-7e7fc861e8bb

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:S 10-29 changed lines (additions + deletions). labels Aug 23, 2026
Comment thread apps/server/src/provider/Layers/OpenCodeAdapter.ts Outdated

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want fixes drafted automatically? Bugbot Autofix can create code changes for findings. A team admin can enable Autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit f08593b. Configure here.

Comment thread apps/server/src/provider/Layers/OpenCodeAdapter.ts
@macroscopeapp

macroscopeapp Bot commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Skipped

Macroscope did not run approvability analysis for this PR. Macroscope could not determine whether this PR modifies its approvability configuration, so the PR was not approved automatically. A PR that may change the rules that govern approval is never approved automatically.

The command-as-detail preference also applied to errored parts, and
with data.state gone the error text was dropped entirely. Errored
command parts now keep state.error as detail while the invocation
stays in data.command.

Worked on by ox-alpha via opencode.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S 10-29 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Bash toolcall does not show the command being ran, just the output twice.

1 participant