Skip to content

feat: fixed-bottom status bar with adaptive layout and resize watcher#245

Open
MicalLee0415 wants to merge 8 commits into
AI-Shell-Team:mainfrom
MicalLee0415:feat/statusbar
Open

feat: fixed-bottom status bar with adaptive layout and resize watcher#245
MicalLee0415 wants to merge 8 commits into
AI-Shell-Team:mainfrom
MicalLee0415:feat/statusbar

Conversation

@MicalLee0415

@MicalLee0415 MicalLee0415 commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Summary

Add a fixed-bottom status bar with adaptive 3-tier layout, pinned via ANSI scroll region (DECSTBM), and a background polling thread that keeps the scroll region correct during terminal resize.

Closes #35

Fields displayed

Wide (≥100 cols) Medium (70-99) Narrow (<70)
model │ cwd │ context tokens │ ↑in ↓out \ │ Nreq latency · state model │ cwd │ tokens │ ↑in ↓out │ Nreq · state tokens · state

Key changes (8 atomic commits)

  1. **\ eat(llm)**: \pricing.rs\ — \ModelPricing, \lookup_pricing(), \estimate_cost()\
  2. **\ eat(config)**: \StatusBarConfig\ with \�isible/\style/
    efresh_interval_ms/\pricing\ overrides
  3. **\ eat(i18n)**: status bar strings across all 6 locales
  4. **\ eat(shell)**: \statusbar.rs\ module — rendering, scroll region mgmt, 23 unit tests
  5. **\ eat(shell)**: Ctrl+T keybinding + /token show|hide\ slash commands
  6. **\ eat(shell)**: \AiHandler::context_budget_state()\ accessor
  7. **\ eat(shell)**: REPL integration — status bar lifecycle, API latency timing, resize watcher thread

Resize-during-read_line fix

Problem: DECSTBM was set once at startup. When the terminal was resized while
ead_line\ was blocking, the scroll region stayed stale, leaving the prompt and status bar stranded mid-screen.

Solution: A 200ms polling watcher thread detects terminal height changes during
ead_line\ and immediately calls
eassert_after_resize()\ — which saves cursor (DECSC), clears stale status bar rows at the old position, sets the new DECSTBM scroll region, and restores cursor (DECRC). The main loop's resize detection acts as a safety net after
ead_line\ returns.

Controls

  • Ctrl+T: Toggle status bar visibility
  • */token show* / **/token hide**: Explicit show/hide

Testing

  • \cargo check\ — clean (1 pre-existing dead_code warning)
  • 23/23 statusbar unit tests pass
  • tmux QA: resize taller (24→30), shorter (30→18), back (18→24) — all confirmed: status bar snaps to new bottom, old rows cleared, no duplication, prompt positioned correctly

Ultraworked with Sisyphus

MicalLee0415 and others added 8 commits June 15, 2026 17:26
Add ModelPricing struct, lookup_pricing(), and estimate_cost() for computing API costs based on model name, input/output token counts, and optional per-model pricing overrides.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Add StatusBarConfig struct with visible/style/refresh_interval_ms fields and optional per-model pricing overrides. Register in ConfigModel with serde defaults.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Add statusbar.notice.hidden key across all 6 locales (en/zh/ja/de/fr/es).

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Add statusbar module with Plan C adaptive layout (cwd, context tokens, I/O split, cost, request count, latency, state), ANSI scroll region management (enter/exit/reassert_after_resize), Ctrl+T toggle rendering, and 23 unit tests covering latency formatting, cwd shortening, progress bars, and state segments.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Bind Ctrl+T to a StatusToggleHandler that interrupts read_line so the main loop can toggle status bar visibility. Also add /token show and /token hide to slash command list.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Add context_budget_state() accessor so the status bar can display current token usage and budget percentage.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Wire status bar into the main REPL loop: enter/exit fixed mode on startup/shutdown, render status bar each iteration, time AI API calls for latency display, detect terminal resize, and spawn a background polling thread (200ms interval) that re-asserts the ANSI scroll region during read_line when the terminal is resized — preventing the prompt and status bar from being stranded mid-screen.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for the pull request. A maintainer will review it when available.

Please keep the PR focused, explain the why in the description, and make sure local checks pass before requesting review.

Contribution guide: https://github.com/AI-Shell-Team/aish/blob/main/CONTRIBUTING.md

@github-actions

Copy link
Copy Markdown
Contributor

This pull request description looks incomplete. Please update the missing sections below before review.

Missing items:

  • User-visible Changes
  • Compatibility
  • Change Type
  • Scope

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] Token额度显示

1 participant