ClaudeMods
☰
ZH-CN
● 0 人在线 · 浏览 0 次
赞助提交作品
GitHub 仓库 · 发布者 sgmonda

statusbar

Claude Code Desktop 的会话状态栏:显示 5 小时和每周用量上限、距离重置的时间、会话和轮次时钟,以及运行中的子 agent、后台任务和计划唤醒(早期体验版)。

已翻译

关于这个 mod

适用于 Claude Code Desktop(Code 标签页)的会话状态栏。statusLine 设置只在终端中运行;此插件会在桌面应用的提示符上方绘制同类状态栏,包括带重置倒计时的用量条、会话和轮次时钟、后台活动数量,以及可选的成本。通过官方插件目录或仓库 marketplace 安装;在 pluginConfigs.statusbar 下配置 surfaces 和 showCost。它不会向外发送任何内容,只运行只读 git 命令,并使用 function-hooks(session.start、session.measure、turn.start、turn.complete、classic.Stop、ui.render)。采用 MIT 授权,需要 Claude Code 2.1.286 或更高版本。

安装

请先查看作者 README 确认 marketplace 和插件名称;命令可能随仓库结构改变。

claude plugin marketplace add sgmonda/statusbar
claude plugin install statusbar
原文 / README

Status Bar

A session status bar for Claude Code Desktop (the Code tab). The statusLine setting only runs in the terminal; this plugin draws the same kind of line above the prompt in the desktop app:

SESSION  ████░░░░  ↻ 02h 15m    ·   WEEK  ██████░░  ↻ 3d 04h    ·   AGENTS 2        TOTAL TIME  01:23:05    ·   CURRENT  00:42

And in the terminal, with surfaces: all:

my-repo ▸ fix-login (feat/oauth) · Opus 5.5 (ctx 42%)
SESSION ████░░░░ ↻ 02h 15m  ·  WEEK ██████░░ ↻ 3d 04h  ·  AGENTS 2      TOTAL TIME 01:23:05  ·  CURRENT 00:42
  • Usage limits: your 5-hour session and weekly windows as bars that grow and shrink with the room the line leaves free, 4 to 20 cells (green below 50%, amber below 80%, red above), with the time until each resets. They appear on subscription plans once the first response has reported them.
  • Time, at the right edge: how long the session has run (TOTAL TIME, as HH:MM:SS) and the turn's clock (CURRENT): live while Claude works, the last turn's length, dimmed, between turns.
  • Background activity, only when there is some: running subagents (AGENTS), other background tasks such as shells, monitors and workflows (TASKS), and scheduled wakeups and cron tasks (CRON). Background tasks and wakeups are counted at the end of each turn.
  • Cost (optional): the session's cost in USD, as /cost totals it.
  • In the terminal (with surfaces: all) a row above adds the repository, worktree and branch, the model and the context fill, which Claude Desktop already shows around the prompt; the usage row below reads the same as on the desktop, spaced tighter for a monospaced font.

Figures are drawn in monospace so the clocks do not jitter as they tick: Claude Desktop's font is proportional and no element takes a font, so the bar uses Unicode's mathematical monospace digits there (the terminal is monospaced already).

It refreshes after each turn and whenever a usage window moves a point, as the engine reports it, plus once a minute so countdowns and branch changes stay current. The session and turn clocks tick every second; while a turn runs, subagents are counted every five.

Early access. This plugin is built on Claude Code's function-hooks API, which may change between releases. It needs Claude Code 2.1.286 or later.

Install

From the official directory:

/plugin install statusbar@claude-plugins-official

Or straight from this repository:

/plugin marketplace add sgmonda/statusbar
/plugin install statusbar@sgmonda

Settings

Open the config menu (/config) and find the plugin's rows, or set them under pluginConfigs.statusbar in ~/.claude/settings.json:

| Setting | Values | Default | What it does | | --- | --- | --- | --- | | surfaces | desktop, all | desktop | desktop draws the bar only in Claude Desktop; all also draws it in the terminal, above the prompt. | | showCost | true, false | false | Adds the session's cost. |

The bar lives in the band above the prompt: collapse it with ctrl+x ctrl+a.

What it runs, reads and sends

It sends nothing out. The plugin makes no network calls and writes no files. Everything it reads is drawn in the bar on your own screen and kept in the session's memory; it never leaves your machine.

Programs it runs. Only git, to show the repository, worktree and branch in the terminal row: three read-only commands in the session's directory, with --no-optional-locks so they never take a lock, each written out in full in hooks/register.tsx, once when the session starts, after each turn and once a minute:

| Command | Why | | --- | --- | | git --no-optional-locks rev-parse --path-format=absolute --git-dir --git-common-dir --show-toplevel | The repository's root, and whether the session is in a linked worktree. | | git --no-optional-locks symbolic-ref --short -q HEAD | The current branch, also on a branch with no commits yet. | | git --no-optional-locks rev-parse --short HEAD | The short commit hash, shown on a detached HEAD. |

What it reads from Claude Code. The session's usage figures (rate limits, context fill, cost), its start time, working directory and model, and the list of running subagents. It does not read the conversation's messages.

Hooks. Each one observes and passes the event on unchanged:

| Hook | What it does | | --- | --- | | session.start | Takes the first reading and starts the refresh timers. | | session.measure | Refreshes the figures when Claude Code reports new usage. | | turn.start, turn.complete | Start and stop the turn clock; recount subagents. | | classic.Stop | Reads the count of background tasks and scheduled wakeups from the Stop event; changes nothing in it and affects no Stop hook of yours. | | ui.render (AbovePrompt) | Draws the bar in the band above the prompt; draws nothing and passes the band on where the bar is off (surfaces) or a survey holds it. |

The manifest's types field names types/index.d.ts, the contract of the values the plugin keeps in the session's state. Claude Code's claude plugin validate holds the hooks module to it.

Development

claude plugin validate .
claude plugin test .
claude --plugin-dir .

To load it in Claude Desktop while you work on it, add the folder to env in ~/.claude/settings.json:

{ "env": { "CLAUDE_CODE_PLUGIN_DIRS": "/path/to/this/repo" } }

Type-check with tsc -p . after running /plugin-types in a session (it writes the API declarations to .claude/types).

The pure logic (bars, countdowns, clocks, git place, widths) lives in hooks/format.ts; hooks/register.tsx holds the hooks and the drawing, and types/index.d.ts the contract of the values the plugin keeps in $.state.

License

MIT

更多类似作品