Skip to content

feat(statusline): add built-in context provider showing context window usage (#234) - #286

Open
innocarpe wants to merge 1 commit into
lessweb:mainfrom
innocarpe:feat/234-context-statusline
Open

feat(statusline): add built-in context provider showing context window usage (#234)#286
innocarpe wants to merge 1 commit into
lessweb:mainfrom
innocarpe:feat/234-context-statusline

Conversation

@innocarpe

Copy link
Copy Markdown

Summary

  • New built-in statusline provider type context renders the active session's context-window usage as a percentage, e.g. ctx 12%.

Why

Issue #234: users wanted to always see how much of the context window a session has consumed, without running a command. A statusline provider makes it visible at a glance.

How to use

{
  "statusline": {
    "enabled": true,
    "providers": [{ "type": "context", "color": "gray" }]
  }
}

Changes

  • packages/core/src/settings.ts: add the context provider type and its normalization.
  • packages/cli/src/ui/statusline/context-provider.ts (new): renders ctx N% from SessionInfo.activeTokens / maxContextTokens (empty when no active session).
  • packages/cli/src/ui/statusline/manager.ts: build the context provider.
  • Tests: context-provider.test.ts (percentage + empty-session), settings-and-notify.test.ts (normalization).

Validation

  • npm run typecheck
  • npm test — new tests pass ✅

Closes #234

…w usage (lessweb#234)

A new statusline provider type "context" renders the active session's context usage as a percentage (e.g. ctx 12%), using the existing SessionInfo activeTokens/maxContextTokens. Enable via statusline.providers: [{ type: "context" }] in settings.json.

(cherry picked from commit eda024d748a5c84b541966be9510eb69123bccf5)
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.

想时刻看到当前会话的上下文比例

1 participant