feat: built-in status line with usage quota display#44
Conversation
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>
|
Caution Review failedPull request was closed or merged during review 📝 WalkthroughWalkthroughThis 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
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
feat: built-in status line with usage quota display
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (4)
src/components/__tests__/BuiltinStatusLine.test.ts (1)
2-2: Use thesrc/alias in this test import.Please switch Line 2 to
src/components/BuiltinStatusLine.jsinstead of a relative path so the new test follows the repository import convention. As per coding guidelines, "Usesrc/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 deadKAIROSfeature 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 behindfeature(). As per coding guidelines, "Allfeature()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: Usesrc/...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 tosrc/...as well. As per coding guidelines, "Usesrc/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 tosrc/...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
⛔ Files ignored due to path filters (1)
QQ20260402-192932.pngis excluded by!**/*.png
📒 Files selected for processing (3)
src/components/BuiltinStatusLine.tsxsrc/components/StatusLine.tsxsrc/components/__tests__/BuiltinStatusLine.test.ts
- 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
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/components/StatusLine.tsx (1)
20-24: Consider removing unusedvimModeprop.The
vimModeprop is no longer used inStatusLineInner(it's not destructured on line 30). Keeping it asunknownis 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
📒 Files selected for processing (3)
src/components/BuiltinStatusLine.tsxsrc/components/StatusLine.tsxsrc/components/__tests__/BuiltinStatusLine.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- src/components/tests/BuiltinStatusLine.test.ts
|
@amDosion 这应该是一个独立于 CC 的需求吧, 这个不会合入主分支的, 但是可以等 V5 版本合入重构版 |
|
就是一个很小的改动,以前官方是需要脚本的方式实现的,现在是直接内置了. |
|
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>
|
Replacing with clean branch (no unrelated files) |

Summary
formatCountdownunit tests (6 tests passing)Screenshot
Display format:
Changes
src/components/BuiltinStatusLine.tsxsrc/components/StatusLine.tsxsrc/components/__tests__/BuiltinStatusLine.test.tsQQ20260402-192932.pngFeatures
rate_limit_fill/rate_limit_emptytheme colorsTest plan
bun test src/components/__tests__/BuiltinStatusLine.test.ts— 6 pass, 0 failbiome check— 0 errors on new files🤖 Generated with Claude Code
Summary by CodeRabbit
Release Notes
New Features
Documentation