Skip to content

feat(usage): add Overview, Account, and Status panels - #251

Merged
ZouR-Ma merged 14 commits into
mainfrom
feature/usage-overview-account
Oct 16, 2026
Merged

ZouR-Ma merged 14 commits into
mainfrom
feature/usage-overview-account

Conversation

@ZouR-Ma

@ZouR-Ma ZouR-Ma commented Oct 14, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

Step Code needs an in-terminal view of local activity, personal plan quota, and runtime state. Add /usage with Overview and Account tabs and expand the independent /status command. These views use the existing editor area like /settings, keeping the footer below the panel.

Changes

  • Overview uses one accent color with density-based token levels and an explicit selected-date legend. It shows 365 local calendar days, project filtering, daily tokens/chats, recorded reasoning settings, and skill/plugin activity. A bounded worker reads a statistics-only JSONL projection into a rebuildable private cache. Fork/export origin metadata preserves attribution and deduplication when parent files disappear.
  • Account queries personal Plan quota and shows the current main-session summary. CODING windows and TOKEN buckets both show remaining percentages and bars; TOKEN buckets hide raw Credit amounts and retain reset/expiry times. Quota bars use 12 columns of reduced-height blocks. Missing percentages remain unavailable. Requests use identity/attempt generations, single-flight caching, cancellation, a 12-second timeout, monotonic TTL/cooldown, and reset/expiry boundaries.
  • Status reads local model, permissions, loaded AGENTS.md files, account metadata, session state, and cached quota remaining without making a network request.
  • Browser Plan sign-in and empty interactive startup check the same region's usage endpoint. A confirmed missing subscription and empty credit buckets open a choice of same-region Platform API-key entry, subscription page, recheck, or another account. Usable top-ups and exhausted plans keep their login. HTTP/network/validation failures warn without being classified as a missing plan; cancellation preserves the current view and unsubmitted credentials.
  • Existing core/usage-totals.ts owns entry selection and validation shared by session statistics, Account, and Overview. Activity recording uses existing extension hooks; command parsing and view lifecycle remain separate. No new dependency, event bus, session store, or background polling is introduced.
  • Usage and Status use ctx.ui.custom in its default inline mode: full terminal width, editor replacement, retained footer, and draft/focus restoration on Esc. Real host/terminal regressions cover regular/fullscreen modes and resizing. Node/Bun packaging includes the activity worker.

Behavior and compatibility

Supported forms are /usage, /usage overview, /usage account, /usage --refresh, and /usage account --refresh. Session and History are not separate tabs or commands. Model/gateway keys, platform profiles, and unknown profiles do not issue personal quota requests.

Activity scans do not migrate or rewrite session files. New sessions record statistics/provenance custom entries; fork/export manifests preserve copied usage attribution. Cache projections exclude message bodies, prompts, tool arguments, credentials, and errors. SDK hosts receive typed services and presentation models through existing extension composition. RPC uses its output bridge; other noninteractive consumers use their explicit output sink.

Account and the Plan availability check require schema 1 at GET /step_plan/v1/usage; each region must deploy that endpoint. HTTP 404 is an explicit deployment state, not evidence of a missing subscription. Overview and Status remain available locally. See account-usage.md for controls and limits, and the rendering pipeline for panel mounting.

Review order

The branch is rebased onto main at d0ec996. The first ten patches are unchanged by the rebase (git range-diff); subsequent commits align panel mounting and quota presentation with the existing terminal UI.

# Commit
1 feat(usage): unify session totals and preserve fork lineage
2 feat(usage): record request and resource provenance
3 feat(usage): scan local activity with a rebuildable cache
4 feat(usage): query personal plan quota with guarded caching
5 feat(usage): register usage and status command lifecycles
6 feat(cli): add usage and status terminal panels
7 test(usage): cover activity and quota lifecycle regressions
8 build(usage): package activity workers and document usage
9 test(mcp): await tool publication after StepPage preparation
10 refactor(usage): reuse session totals and isolate activity recording
11 fix(cli): mount usage and status in the editor area
12 fix(usage): clarify quota percentages and heatmap colors
13 fix(usage): simplify quota display and reduce bar height

| 14 | fix(auth): guide accounts without a plan to API-key login |

Validation

macOS arm64, Node v24.3.0, pnpm 9.15.9:

  • pnpm run check passed, including types, package/layer boundaries, frozen entry points, secret checks, public-source boundaries, and browser smoke.
  • pnpm run build:offline passed for the feature. Before the current full test run, pnpm run build in packages/coding-agent rebuilt its library, CLI entry, and Node bundle from current source.
  • TMPDIR=/tmp ./test.sh passed with isolated user resources and no provider credentials: coding-agent 4579 passed / 59 skipped; CLI 692 passed; providers 446 passed / 6 skipped; agent-core 539 passed / 1 skipped; remaining package/script suites passed.
  • From apps/cli, pnpm exec vitest --run test/usage-panel.test.ts test/tui-acceptance-snapshot.test.ts passed all 39 tests, including full/partial/exhausted/unknown Credit percentage cases for both Account and Status.
  • Live PTY runs of pnpm step and pnpm step --tui-mode fullscreen passed 30 checks each using an authorized CN TOKEN account. The checks cover local JSONL totals, calendar positions, scope/date controls, live quota fetch/refresh, cached Status, compact percentage bars and absence of raw Credit balances, 80×24 resize/scroll, footer placement, Esc and restored editor input. Both processes exited normally; account-specific evidence stays local.
  • Plan-login regressions cover both regions, usable top-ups, exhausted plans, unavailable/invalid/mismatched responses, API-key persistence, rechecking, cancellation and late responses. Six isolated real-PTY fixture runs of source and built launchers verify the missing-plan screen, same-region key entry, preserving credentials on cancel, submitting an overseas Platform key, top-up-only startup, and the 404 warning. All exit normally without a model-generation request; after a usable/unknown check, startup reaches the existing project-trust screen.
  • Six real extension-host/virtual-terminal mounting cases fail with the previous centered overlay and pass with inline mounting. They verify all three views at 80×24, 40×18, and 120×32, retained transcript/footer, arrow scrolling, live Status updates, Esc, callback cleanup, restored draft, and restored keyboard input.

Limitations

CI for the updated head is pending independent confirmation. Tests above establish macOS behavior; live overseas/CODING account integration, additional release platforms, and live terminal performance acceptance remain separate checks. The real-account smoke above covers one CN TOKEN account; other quota states are fixture-tested. Platform monetary bills, organization Credit, and cross-device activity history are outside this feature.

@ZouR-Ma
ZouR-Ma force-pushed the feature/usage-overview-account branch 2 times, most recently from 1eda90e to e56ed1a Compare October 15, 2026 06:10
@ZouR-Ma ZouR-Ma changed the title 新增 /usage Overview、Account 与本地 /status 面板 feat(usage): add Overview, Account, and Status panels Oct 15, 2026
@ZouR-Ma
ZouR-Ma force-pushed the feature/usage-overview-account branch from e56ed1a to 9211f2c Compare October 15, 2026 06:53
@ZouR-Ma
ZouR-Ma force-pushed the feature/usage-overview-account branch from a3c44d8 to dcf18f2 Compare October 15, 2026 11:50
Check personal Plan usage after browser login and during interactive
startup. Reuse same-region Platform key entry when a fresh response
confirms no subscription or usable top-up credits.

Preserve usable top-ups and exhausted-plan logins, report uncertain
checks, and cancel pending requests when leaving the login view.
@ZouR-Ma
ZouR-Ma merged commit d71175e into main Oct 16, 2026
2 checks passed
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