opencode icon indicating copy to clipboard operation
opencode copied to clipboard

feat(tui): add tool_output_expanded_default option

Open SBhojani opened this issue 5 months ago • 1 comments

Issue for this PR

No existing issue — small, self-contained TUI config addition.

Type of change

  • [ ] Bug fix
  • [x] New feature
  • [ ] Refactor / code improvement
  • [ ] Documentation

What does this PR do?

Adds a tool_output_expanded_default option to tui.json. When true, tool and shell-command output renders expanded by default instead of collapsing to a few lines behind "Click to expand". Defaults to false, so behaviour is unchanged unless you opt in.

It sets the initial value of the existing expanded signal in the two output renderers — GenericTool (maxLines 3) and Shell (maxLines 10) in routes/session/index.tsx — from ctx.tui.tool_output_expanded_default instead of hardcoding false. The field is added to the Info schema in config/index.tsx; resolve() already spreads ...input, so it flows through with no extra wiring. The "Click to expand" / "Click to collapse" toggle still works. Reasoning blocks are unaffected — this only touches tool/command output.

How did you verify your code works?

Built locally, set tool_output_expanded_default: true in tui.json, and ran shell commands with long output — they render expanded. Unset / false collapses as before. Also confirmed the generated tui.json schema includes the new key.

Screenshots / recordings

No new UI — the existing expanded output view, just shown by default. Can add a recording if preferred.

Checklist

  • [x] I have tested my changes locally
  • [x] I have not included unrelated changes in this PR

SBhojani avatar Jun 27 '26 17:06 SBhojani

Automated task review for PR #34246, refreshed 2026-06-28:

  • Current dev: 61a7f6db35e1b8284258de247b889edf14748234; PR head: c56aa7e8a5029cad28b8bd71b04bbd50bb06cdf1.
  • Branch freshness: PR remains 1 commit ahead and 7 commits behind current dev; merge-base is 5d63020dcd0bc75e4c7bdbc1db09c53e3d172dd1.
  • GitHub state: mergeable=MERGEABLE, but mergeStateStatus=BLOCKED; review decision is empty and there are no reviews.
  • Checks: GitHub PR checks currently shown by gh pr checks are passing: check-duplicates, check-standards, add-contributor-label, check-compliance.
  • Local merge validation: PR head merged cleanly into current origin/dev in isolated worktree /tmp/opencode-pr34246-validate; diff is limited to packages/tui/src/config/index.tsx and packages/tui/src/routes/session/index.tsx.
  • Focused validation passed locally in that worktree:
    • bun install --frozen-lockfile
    • bun run --cwd packages/tui typecheck
    • bun --cwd packages/tui test test/config.test.tsx (9 pass, 0 fail)
    • bun --cwd packages/opencode test test/config/tui.test.ts (33 pass, 3 skip, 0 fail)
    • bun --cwd packages/tui test test/cli/tui/inline-tool-wrap-snapshot.test.tsx (17 pass, 0 fail, 8 snapshots)
    • git diff --check --cached
  • Independent adversarial review found no functional/type code blocker. Low follow-ups: no committed targeted regression test for tool_output_expanded_default: true, and docs do not mention the new option.

Merge blocker from this session: do not merge while GitHub reports mergeStateStatus=BLOCKED. This authenticated viewer also has repository.viewerPermission=READ; the collaborator permission API returns 403, so this session cannot update the branch or merge the PR. Recommended next step: update/refresh the PR branch or clear the protected-branch blocker/review requirement, then rerun validation before merging.

andrei-hasna avatar Jun 27 '26 22:06 andrei-hasna

Automated task review refresh for PR #34246 at 2026-06-28T04:45:35Z:

  • Current dev: dfeb1b5051a05b359bd4af711b204d2c0342c5f4; PR head: c56aa7e8a5029cad28b8bd71b04bbd50bb06cdf1.
  • Branch freshness: PR is 1 commit ahead and 8 commits behind current dev; merge-base is 5d63020dcd0bc75e4c7bdbc1db09c53e3d172dd1.
  • GitHub state: mergeable=MERGEABLE, but mergeStateStatus=BLOCKED; reviewDecision is empty and there are no reviews.
  • Checks: GitHub PR checks currently shown by gh pr checks are passing: check-duplicates, check-standards, add-contributor-label, check-compliance.
  • Local merge validation: PR head merged cleanly into current origin/dev in isolated worktree /tmp/opencode-pr34246-current.DZOeoN; diff is limited to packages/tui/src/config/index.tsx and packages/tui/src/routes/session/index.tsx.
  • Focused validation passed locally in that worktree:
    • bun install --frozen-lockfile
    • git diff --check --cached
    • bun run --cwd packages/tui typecheck
    • bun --cwd packages/tui test test/config.test.tsx (9 pass, 0 fail)
    • bun --cwd packages/opencode test test/config/tui.test.ts (33 pass, 3 skip, 0 fail)
    • bun --cwd packages/tui test test/cli/tui/inline-tool-wrap-snapshot.test.tsx (17 pass, 0 fail, 8 snapshots)
  • Independent adversarial verifier found no functional/type/config/UI blocker. Residual non-blocking risks: no direct UI regression for tool_output_expanded_default: true, generated/public docs/schema not regenerated in this review, and plugin-facing TuiConfigView does not expose the field.

Merge blocker from this session: do not merge while GitHub reports mergeStateStatus=BLOCKED. This authenticated viewer has repository.viewerPermission=READ, viewerCanUpdate=false, and viewerCanEnableAutoMerge=false, so this session cannot refresh the branch or merge the PR. Next step for a maintainer: update/refresh the PR branch or clear the protected-branch/review blocker, then rerun validation before merging.

andrei-hasna avatar Jun 28 '26 04:06 andrei-hasna

Automated task review refresh for PR #34246 at 2026-06-28T11:53:34Z:

I did not merge this PR.

Current state:

  • Current dev: 6ee817d0416cc902bdf1e05b0a3db1e94d07434a; PR head: c56aa7e8a5029cad28b8bd71b04bbd50bb06cdf1.
  • Branch freshness: PR is 1 commit ahead and 9 commits behind current dev; merge-base is 5d63020dcd0bc75e4c7bdbc1db09c53e3d172dd1.
  • GitHub state: mergeable=MERGEABLE, but mergeStateStatus=BLOCKED; reviewDecision is empty and there are no reviews.
  • Checks shown by gh pr checks are passing: check-duplicates, check-standards, add-contributor-label, check-compliance.

Local validation on a no-commit merge into current origin/dev passed:

  • bun install --frozen-lockfile

  • git diff --check --cached

  • cd packages/tui && bun run typecheck

  • cd packages/tui && bun test test/config.test.tsx (9 pass, 0 fail)

  • cd packages/opencode && bun test test/config/tui.test.ts (33 pass, 3 skip, 0 fail)

  • cd packages/tui && bun test test/cli/tui/inline-tool-wrap-snapshot.test.tsx (17 pass, 0 fail, 8 snapshots) Blockers before merge:

  • Legacy config migration: packages/opencode/src/config/tui-migrate.ts normalizeTui only preserves scroll_speed, scroll_acceleration, and diff_style from legacy opencode.json tui config. With this PR, tui.tool_output_expanded_default in legacy opencode.json would be stripped/ignored rather than migrated into tui.json.

  • Plugin-facing types: plugin api.tuiConfig is typed via PluginConfig['tui'], but generated SDK Config.tui currently only exposes scroll_speed, scroll_acceleration, and diff_style, so plugin authors cannot type-read api.tuiConfig.tool_output_expanded_default.

  • Repository policy/access: this viewer has repository.viewerPermission=READ, viewerCanUpdate=false, and viewerCanEnableAutoMerge=false, so this session cannot refresh the branch or merge even after code fixes.

Next step: add the migration/type coverage fixes or decide those surfaces are intentionally unsupported, clear the blocked review/protection state, update/refresh the branch if required, then rerun validation before merge.

andrei-hasna avatar Jun 28 '26 11:06 andrei-hasna

Blocked after current-dev merge review.

Evidence:

  • PR is open/non-draft and GitHub reports mergeable, but head c56aa7e8a5029cad28b8bd71b04bbd50bb06cdf1 is 243 commits behind current origin/dev (b7e4f1ef7433f83ba009eefa2997aeb81017f6ed).
  • Local no-commit merge into current origin/dev applied cleanly.
  • Validation on the local merge: packages/tui: bun typecheck passed; packages/opencode: bun test test/config/tui.test.ts --timeout 30000 passed (33 pass, 3 skip); git diff --cached --check clean.

Blockers before merge:

  1. tool_output_expanded_default is added to packages/tui/src/config/index.tsx, but legacy migration in packages/opencode/src/config/tui-migrate.ts only preserves scroll_speed, scroll_acceleration, and diff_style from nested legacy opencode.json tui config. A legacy tui: { tool_output_expanded_default: true } would be dropped during migration.
  2. Current dev has an execute renderer in packages/tui/src/routes/session/index.tsx that collapses runtime error output via outputPreview = collapseToolOutput(...); this stale PR only wires the new default into GenericTool and Shell, so the new option does not consistently apply to current tool/command output paths.
  3. No regression coverage was added for schema/default loading, legacy migration, or expanded/collapsed TUI output behavior.

Recommendation: update the PR for current dev by carrying the new key through migration, deciding/wiring behavior for Execute, and adding focused tests before merge.

andrei-hasna avatar Jul 05 '26 13:07 andrei-hasna