Skip to content

feat(tui): add custom statusline command - #52764

Closed
rudolf-blue wants to merge 2 commits into
anomalyco:devfrom
rudolf-blue:custom-statusline
Closed

rudolf-blue wants to merge 2 commits into
anomalyco:devfrom
rudolf-blue:custom-statusline

Conversation

@rudolf-blue

Copy link
Copy Markdown

Issue for this PR

Closes #37464

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Adds a statusline option to the TUI config. It takes a shell command; the TUI pipes session state to it as JSON on stdin and shows the first line of stdout in the prompt footer.

{ "statusline": { "command": "~/.config/opencode/statusline.sh", "interval": 60 } }

It is a built-in TUI plugin that appends to the existing prompt.footer.status slot, so there is no new footer system. The command reruns when the payload changes (debounced 300ms) and, if interval is set, every that many seconds. A run still in flight is killed when a newer one starts, and each run times out after 5s. ANSI codes are stripped.

The stdin payload uses Claude Code's statusLine field names so scripts written for it work as they are. Filled in: session_id, cwd, version, model.id, model.display_name, workspace.current_dir, workspace.project_dir, cost.total_cost_usd, and context_window.{context_window_size,used_percentage,remaining_percentage,current_usage}. Anything opencode has no value for is left out.

The config key is statusline.command / interval instead of the issue's statusLine / refreshSeconds, to match the other keys in this config. Happy to rename.

I did not touch the docs. tui.mdx still describes the v1 config, so I was not sure where this belongs.

How did you verify your code works?

  • New tests in test/feature-plugins/prompt-statusline.test.tsx: the payload shape, a session ID that does not exist yet, stdin piping and first-line/ANSI handling against real commands, abort, and a full app fixture run that checks the output lands in the footer.
  • bun run test and bun typecheck in packages/tui pass (1441 pass, 0 fail).
  • I have not run it against a live server, only through the app test fixture.

Screenshots / recordings

From the app fixture, with a command that prints the model name in brackets:

 ╹▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
 /tmp/opencod...ages/tui:main [Demo Model] shift+tab agents  ctrl+p commands

Checklist

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

@github-actions

github-actions Bot commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

@thdxr
thdxr changed the base branch from v2 to dev October 10, 2026 19:27
@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

Automated PR Cleanup

Thank you for contributing to opencode.

Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions.

This PR was closed because it matched the following cleanup criteria:

  • The PR was created more than 1 month ago
  • The PR had fewer than 2 positive reactions
  • Positive reactions are counted as thumbs-up, heart, celebration, or rocket reactions on the PR

PRs created within the last month are not affected by this cleanup.

If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate.

Thanks again for taking the time to contribute.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE]: Custom statusLine via shell command (like Claude Code)

1 participant