Skip to content

feat: built-in status line with usage quota display#44

Closed
amDosion wants to merge 14 commits into
claude-code-best:mainfrom
amDosion:feat/builtin-status-line
Closed

feat: built-in status line with usage quota display#44
amDosion wants to merge 14 commits into
claude-code-best:mainfrom
amDosion:feat/builtin-status-line

Conversation

@amDosion
Copy link
Copy Markdown
Collaborator

@amDosion amDosion commented Apr 2, 2026

Summary

  • Add a built-in status line that displays model name, context usage (with token counts), 5h session / 7d weekly rate limit progress bars with countdowns, and cumulative cost
  • No configuration needed — works out of the box by reading rate limit data from API response headers (zero extra API calls)
  • Remove external shell command status line path — only built-in implementation remains
  • Add formatCountdown unit tests (6 tests passing)

Screenshot

Built-in Status Line

Display format:

Opus 4.6 │ Context 2% (357/1m) │ Session 41% ██▊        30m │ Weekly 34% ███▍       2d2h │ $0.0004

Changes

File Change
src/components/BuiltinStatusLine.tsx New — built-in status line React/Ink component
src/components/StatusLine.tsx Simplified — removed external command path, uses BuiltinStatusLine directly
src/components/__tests__/BuiltinStatusLine.test.ts New — formatCountdown unit tests
QQ20260402-192932.png Screenshot of the status line in action

Features

  • Responsive layout: progress bars at >=100 cols, countdowns hidden at <60 cols
  • 60s countdown refresh: interval timer keeps reset countdowns current
  • Theme-aware: uses existing rate_limit_fill / rate_limit_empty theme colors
  • Graceful degradation: shows only model + context when no rate limit data available (first launch, non-subscriber)

Test plan

  • bun test src/components/__tests__/BuiltinStatusLine.test.ts — 6 pass, 0 fail
  • biome check — 0 errors on new files
  • Manual: verify status line displays on startup
  • Manual: verify rate limit bars appear after first API response
  • Manual: verify narrow terminal layout degrades gracefully

🤖 Generated with Claude Code

Summary by CodeRabbit

Release Notes

  • New Features

    • Enhanced status line now displays model name, context usage percentage, token counts, and total API cost
    • Real-time rate-limit tracking with countdown timers for usage reset windows
    • Adaptive formatting optimized for both wide and narrow terminals
  • Documentation

    • Added Claude Code Buddy System specification with implementation roadmap

unraid and others added 8 commits April 2, 2026 17:11
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
移除 shims/、xiaohongshu/、vendor/、旧版 docs、多余 src 组件等 107 个文件

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…st display

Adds a default built-in status line that shows model name, context usage with
token counts, 5h session and 7d weekly rate limit progress bars with countdowns,
and cumulative cost. No configuration needed — displays automatically when no
external statusLine command is configured. Refactors StatusLine.tsx into routing
component with ExternalStatusLine (existing) and BuiltinStatusLineWrapper (new).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Simplify StatusLine.tsx by removing the external shell command path
(ExternalStatusLine, buildStatusLineCommandInput, executeStatusLineCommand).
The built-in status line is now the only implementation — no configuration
needed, shows model, context, session/weekly quotas, and cost by default.
Also adds status line screenshot for documentation.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…st display

Adds a default built-in status line that shows model name, context usage with
token counts, 5h session and 7d weekly rate limit progress bars with countdowns,
and cumulative cost. No configuration needed — displays automatically when no
external statusLine command is configured. Refactors StatusLine.tsx into routing
component with ExternalStatusLine (existing) and BuiltinStatusLineWrapper (new).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Simplify StatusLine.tsx by removing the external shell command path
(ExternalStatusLine, buildStatusLineCommandInput, executeStatusLineCommand).
The built-in status line is now the only implementation — no configuration
needed, shows model, context, session/weekly quotas, and cost by default.
Also adds status line screenshot for documentation.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 2, 2026

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

This PR introduces a new companion buddy system with deterministic generation, persistence, and ASCII sprite rendering; refactors the status line component to render synchronously from local state instead of executing debounced async commands; and adds permissions configuration for command execution. The buddy system includes type definitions, PRNG/hashing utilities, animation logic, command handlers, and comprehensive implementation documentation.

Changes

Cohort / File(s) Summary
Status Line Refactoring
src/components/StatusLine.tsx, src/components/BuiltinStatusLine.tsx
Removed debounced async command execution flow and replaced with synchronous rendering from local state. New BuiltinStatusLine component formats model name, context usage percentage, token counts, rate-limit sections with optional progress bars, total cost, and periodic countdown updates via 60-second interval when reset times are present. Simplified statusLineShouldDisplay to always return true.
Buddy System Type Definitions
docs/claude-buddy-system/src/buddy/types.ts
Added TypeScript interfaces and constants for companion data: Rarity, Species, Eye, Hat, StatName with corresponding metadata (weights, colors, base stats), and three-layer companion model (CompanionBones, CompanionSoul, Companion).
Buddy System Core Logic
docs/claude-buddy-system/src/buddy/companion.ts
Implemented deterministic companion generation via FNV-1a hashing and Mulberry32 PRNG (roll()), AI soul generation, and config persistence. Exports getCompanion() and getOrCreateCompanion() with optional AI callback, plus soul prompt builder and API payload interface.
Buddy System UI & Rendering
docs/claude-buddy-system/src/buddy/sprites.ts, docs/claude-buddy-system/src/buddy/CompanionWidget.ts
Added ASCII sprite frame templates per species with hat overlay, emoji fallback face, and sprite rendering logic. Companion widget exports animation constants, reaction threshold calculation, and hatch egg animation frames.
Buddy System Command & Reactions
docs/claude-buddy-system/src/buddy/buddyCommand.ts, docs/claude-buddy-system/src/buddy/buddyReaction.ts, docs/claude-buddy-system/src/buddy/useBuddyNotification.ts
Added /buddy local-jsx command with subcommands (off, on, pet) and companion card formatting. Reaction module includes API plumbing for POST /api/organizations/{orgId}/claude_code/buddy_react, reason type definitions, and system prompt builder. Notification utilities provide live status check and buddy mention detection.
Buddy System Documentation
docs/claude-buddy-system/README.md, docs/claude-buddy-system/IMPLEMENTATION-PLAN.md
Added comprehensive system overview documenting deterministic pet generation (species, rarity, attributes, appearance), AI soul creation, reaction triggers, and three-layer runtime gating (feature flag, date cutoff, GrowthBook experiment). Implementation plan specifies phased rollout with command dispatch, observer integration, config persistence, and test scenarios.
Permissions Configuration
.claude/.fuse_hidden0004746300000372
Added permissions manifest granting execution/read access for Git operations, filesystem discovery (find, ls, grep), Node tooling (bun, npx biome), GitHub CLI, and targeted searches for quota/utilization context.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

  • 合并最新主分支 #36: Modifies companion-generation logic including roll() seed handling and getCompanion() behavior in src/buddy/companion.ts, overlapping with core buddy system implementation.

Poem

🐰 A buddy sprite hops into the fold,
With souls rolled from hashes untold,
Status lines sync, no more delay,
Code Rabbit dances the modern way! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 78.79% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title clearly and specifically describes the main change: adding a built-in status line component with usage quota display, which aligns with the core addition of BuiltinStatusLine.tsx and refactoring of StatusLine.tsx.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@amDosion
Copy link
Copy Markdown
Collaborator Author

amDosion commented Apr 2, 2026

QQ20260402-193610

feat: built-in status line with usage quota display
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (4)
src/components/__tests__/BuiltinStatusLine.test.ts (1)

2-2: Use the src/ alias in this test import.

Please switch Line 2 to src/components/BuiltinStatusLine.js instead of a relative path so the new test follows the repository import convention. As per coding guidelines, "Use src/ path alias in imports (e.g., import { ... } from 'src/utils/...') as configured in tsconfig."

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/components/__tests__/BuiltinStatusLine.test.ts` at line 2, The test
imports formatCountdown using a relative path; update the import in
BuiltinStatusLine.test.ts to use the repository alias by replacing the relative
import with "src/components/BuiltinStatusLine.js" so the test follows the
project's `src/` import convention and still references the same exported symbol
formatCountdown.
src/components/StatusLine.tsx (2)

17-19: Remove the dead KAIROS feature gate.

Given this repository’s build rules, the branch on Line 18 can never execute, so statusLineShouldDisplay() is effectively unconditional. Please inline the current behavior or move the guard somewhere that is not behind feature(). As per coding guidelines, "All feature() flag calls must be treated as always returning false — any code behind a feature flag is dead code in this build."

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/components/StatusLine.tsx` around lines 17 - 19, The feature gate check
feature('KAIROS') in statusLineShouldDisplay is dead code; remove the
conditional branch and make the function unconditional by deleting the
feature('KAIROS') && getKairosActive() check and returning the current effective
value directly. Locate the function statusLineShouldDisplay and remove the
feature('KAIROS') expression (and any dependent getKairosActive() call in this
function), leaving the intended unconditional return behavior, or if the Kairos
guard must be preserved move the getKairosActive() check out of any feature()
guard into a runtime check elsewhere rather than behind feature('KAIROS').

5-15: Use src/... aliases consistently in this module.

Lines 5-15 still import through ../... even though Line 4 already uses the configured alias. Please normalize the rest of the block to src/... as well. As per coding guidelines, "Use src/ path alias in imports (e.g., import { ... } from 'src/utils/...') as configured in tsconfig."

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/components/StatusLine.tsx` around lines 5 - 15, The import block in
StatusLine.tsx mixes relative paths with the configured src/ alias; update all
imports (e.g., getSdkBetas, getKairosActive, getTotalCost, getTotalInputTokens,
getTotalOutputTokens, useMainLoopModel, ReadonlySettings, getRawUtilization,
Message type, calculateContextPercentages, getContextWindowForModel,
getLastAssistantMessage, getRuntimeMainLoopModel, renderModelName,
doesMostRecentAssistantMessageExceed200k, getCurrentUsage, and
BuiltinStatusLine) to use the src/ path alias (for example import { getSdkBetas
} from 'src/bootstrap/state' etc.) so the module consistently uses the alias
configured in tsconfig.
src/components/BuiltinStatusLine.tsx (1)

2-7: Switch this import block to src/... aliases.

The new component uses relative paths throughout Lines 2-7. Please normalize them to the configured tsconfig alias for consistency with the rest of the codebase. As per coding guidelines, "Use src/ path alias in imports (e.g., import { ... } from 'src/utils/...') as configured in tsconfig."

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/components/BuiltinStatusLine.tsx` around lines 2 - 7, The import block in
BuiltinStatusLine.tsx uses relative paths for formatCost, Box, Text,
formatTokens, ProgressBar, and useTerminalSize; update those imports to use the
tsconfig path alias form starting with 'src/' (e.g., import { formatCost } from
'src/cost-tracker', import { Box, Text } from 'src/ink', import { formatTokens }
from 'src/utils/format', import { ProgressBar } from
'src/components/design-system/ProgressBar', import { useTerminalSize } from
'src/hooks/useTerminalSize') so the module paths are consistent with the
project's configured aliases.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/components/__tests__/BuiltinStatusLine.test.ts`:
- Around line 5-28: The tests use a suite-level const now = Date.now() / 1000
while formatCountdown() also calls Date.now(), causing flakiness; fix by
stubbing Date.now() for this test file (or inside beforeAll/beforeEach) to
return a stable timestamp matching now * 1000 (and restore it in
afterAll/afterEach). Locate the tests referencing formatCountdown and the const
now in BuiltinStatusLine.test.ts and use a Jest-compatible spy/mock of
Date.now() so all assertions (including the 1h0m case) run deterministically.

In `@src/components/StatusLine.tsx`:
- Around line 42-57: The StatusLine mixes session-level totals with per-context
usage: replace the usedTokens value (currently set via getTotalInputTokens() +
getTotalOutputTokens()) with the tokens from the same currentUsage used to
compute contextPercentages (the object returned by
getCurrentUsage(messagesRef.current)). Update the usedTokens binding passed to
BuiltinStatusLine to use currentUsage's input/output token fields (sum of those)
so contextUsedPct (from calculateContextPercentages(currentUsage, ...)) and
usedTokens are derived from the same source; keep contextWindowSize and
totalCostUsd as-is.

---

Nitpick comments:
In `@src/components/__tests__/BuiltinStatusLine.test.ts`:
- Line 2: The test imports formatCountdown using a relative path; update the
import in BuiltinStatusLine.test.ts to use the repository alias by replacing the
relative import with "src/components/BuiltinStatusLine.js" so the test follows
the project's `src/` import convention and still references the same exported
symbol formatCountdown.

In `@src/components/BuiltinStatusLine.tsx`:
- Around line 2-7: The import block in BuiltinStatusLine.tsx uses relative paths
for formatCost, Box, Text, formatTokens, ProgressBar, and useTerminalSize;
update those imports to use the tsconfig path alias form starting with 'src/'
(e.g., import { formatCost } from 'src/cost-tracker', import { Box, Text } from
'src/ink', import { formatTokens } from 'src/utils/format', import { ProgressBar
} from 'src/components/design-system/ProgressBar', import { useTerminalSize }
from 'src/hooks/useTerminalSize') so the module paths are consistent with the
project's configured aliases.

In `@src/components/StatusLine.tsx`:
- Around line 17-19: The feature gate check feature('KAIROS') in
statusLineShouldDisplay is dead code; remove the conditional branch and make the
function unconditional by deleting the feature('KAIROS') && getKairosActive()
check and returning the current effective value directly. Locate the function
statusLineShouldDisplay and remove the feature('KAIROS') expression (and any
dependent getKairosActive() call in this function), leaving the intended
unconditional return behavior, or if the Kairos guard must be preserved move the
getKairosActive() check out of any feature() guard into a runtime check
elsewhere rather than behind feature('KAIROS').
- Around line 5-15: The import block in StatusLine.tsx mixes relative paths with
the configured src/ alias; update all imports (e.g., getSdkBetas,
getKairosActive, getTotalCost, getTotalInputTokens, getTotalOutputTokens,
useMainLoopModel, ReadonlySettings, getRawUtilization, Message type,
calculateContextPercentages, getContextWindowForModel, getLastAssistantMessage,
getRuntimeMainLoopModel, renderModelName,
doesMostRecentAssistantMessageExceed200k, getCurrentUsage, and
BuiltinStatusLine) to use the src/ path alias (for example import { getSdkBetas
} from 'src/bootstrap/state' etc.) so the module consistently uses the alias
configured in tsconfig.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 7795d2b2-6e4a-4dba-a31f-9a08ad0768f1

📥 Commits

Reviewing files that changed from the base of the PR and between 006ad97 and 0b77c39.

⛔ Files ignored due to path filters (1)
  • QQ20260402-192932.png is excluded by !**/*.png
📒 Files selected for processing (3)
  • src/components/BuiltinStatusLine.tsx
  • src/components/StatusLine.tsx
  • src/components/__tests__/BuiltinStatusLine.test.ts

Comment thread src/components/__tests__/BuiltinStatusLine.test.ts Outdated
Comment thread src/components/StatusLine.tsx
unraid and others added 2 commits April 2, 2026 19:50
- Mock Date.now() in tests to eliminate flakiness from clock drift
- Use currentUsage (same source as contextUsedPct) for usedTokens instead
  of cumulative session totals, fixing data inconsistency
- Switch all imports to src/ path aliases for consistency
- Remove dead feature('KAIROS') gate (always returns false in this build)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
# Conflicts:
#	src/components/BuiltinStatusLine.tsx
#	src/components/StatusLine.tsx
#	src/components/__tests__/BuiltinStatusLine.test.ts
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
src/components/StatusLine.tsx (1)

20-24: Consider removing unused vimMode prop.

The vimMode prop is no longer used in StatusLineInner (it's not destructured on line 30). Keeping it as unknown is a temporary workaround — consider removing it entirely and updating the call sites.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/components/StatusLine.tsx` around lines 20 - 24, The Props type in
StatusLine.tsx declares an unused vimMode field; remove vimMode from the Props
type declaration and from any related prop typing (e.g., the StatusLineInner
component's props) and then update all call sites that pass vimMode so they no
longer supply it (search for StatusLine or StatusLineInner usages). Ensure there
are no remaining references to vimMode in this file or imported types and run
typechecks to confirm the prop shape matches everywhere (retain messagesRef and
lastAssistantMessageId as the remaining props).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/components/StatusLine.tsx`:
- Around line 20-24: The Props type in StatusLine.tsx declares an unused vimMode
field; remove vimMode from the Props type declaration and from any related prop
typing (e.g., the StatusLineInner component's props) and then update all call
sites that pass vimMode so they no longer supply it (search for StatusLine or
StatusLineInner usages). Ensure there are no remaining references to vimMode in
this file or imported types and run typechecks to confirm the prop shape matches
everywhere (retain messagesRef and lastAssistantMessageId as the remaining
props).

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 54839562-98a6-499d-b605-e59e4df9bae8

📥 Commits

Reviewing files that changed from the base of the PR and between 0b77c39 and d3363e8.

📒 Files selected for processing (3)
  • src/components/BuiltinStatusLine.tsx
  • src/components/StatusLine.tsx
  • src/components/__tests__/BuiltinStatusLine.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/components/tests/BuiltinStatusLine.test.ts

@claude-code-best
Copy link
Copy Markdown
Owner

@amDosion 这应该是一个独立于 CC 的需求吧, 这个不会合入主分支的, 但是可以等 V5 版本合入重构版

@amDosion
Copy link
Copy Markdown
Collaborator Author

amDosion commented Apr 2, 2026

就是一个很小的改动,以前官方是需要脚本的方式实现的,现在是直接内置了.

@claude-code-best
Copy link
Copy Markdown
Owner

thanks @amDosion

Clean up files that should not be in the PR:
- QQ20260402-192932.png (local screenshot)
- src/components/__tests__/BuiltinStatusLine.test.ts (dev test)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@amDosion
Copy link
Copy Markdown
Collaborator Author

amDosion commented Apr 2, 2026

Replacing with clean branch (no unrelated files)

@amDosion amDosion closed this Apr 2, 2026
@amDosion amDosion deleted the feat/builtin-status-line branch April 3, 2026 11:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants