Skip to content

Claude: finish the /usage capture on weekly-only plans - #5070

Open
mjaverto wants to merge 1 commit into
steipete:mainfrom
mjaverto:fix/claude-weekly-only-usage-capture
Open

mjaverto wants to merge 1 commit into
steipete:mainfrom
mjaverto:fix/claude-weekly-only-usage-capture

Conversation

@mjaverto

Copy link
Copy Markdown
Contributor

Fixes #5066.

On a plan without a five-hour window, /usage draws no "Current session" row. The capture's stop condition only accepted a session value, so ClaudeCLISession.captureExclusive waited out its 20 s deadline and kept sending Enter into the open panel every 0.8 s, although parsing already handles these panels (#4914).

  • usageCaptureHasSessionValue(_:) becomes usageCaptureHasQuotaValue(_:): the first quota label, "Current session" or else "Current week", followed by a percentage before the usage-insights section. A panel with a session row behaves as before, since that label comes first.
  • ClaudeCLISession uses it for usagePanelOpen, so the Enter retries also stop once the weekly quota is drawn.
  • The Refreshing… guard and the insights cut-off are unchanged. isUsageStillLoading uses the same helper.
  • docs/claude.md and the unreleased changelog are updated.

Tests

  • ClaudeCLIScreenProbeTests: a weekly-only panel completes the capture, a weekly label still loading does not, and the parsed snapshot keeps the session absent with the weekly and scoped rows.
  • TTYIntegrationTests: a fake claude draws a weekly-only panel. The probe returns the weekly quota and sends no Enter after the panel is drawn.
  • make test-fast FILTER='Claude(CLI|StatusProbe|WeeklyOnly|DirectUsage|UsageInsights|Resilience|Incomplete)|StatusProbeTests|TTYIntegrationTests': 418 tests in 30 suites passed.
  • Negative control: with the Sources/ change reverted, exactly the two new tests fail (usageCaptureIsComplete false for the weekly-only panel; the fake CLI logs Enter presses until the timeout). The other 12 tests in those suites pass.
  • make check: passed, SwiftLint 0 violations.

Live

codexbar usage --provider claude --source cli --format json on a weekly-only plan (Claude Code 2.1.322, macOS 27.2.1), two runs each, CODEXBAR_DISABLE_KEYCHAIN_ACCESS=1:

run 1 run 2 /usage capture
0.84.0 (Homebrew) 31.5 s 31.3 s 26 s
this branch (debug build) 10.4 s 10.2 s 5 s

Both return the same windows: primary null, weekly and Fable present, no error. Most of the remaining time is startup and the /status capture.

The serve caching question in #5066 is not part of this PR.

A plan without a five-hour window draws no "Current session" row, so the
capture never saw its stop condition and waited out the full 20 s timeout,
pressing Enter into the open panel every 0.8 s meanwhile. The capture now
ends once the first quota row has its value, the session row or the weekly
row, which also stops the Enter retries.

Refs steipete#5066
@clawsweeper

clawsweeper Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-12T13:34:51.762324Z c0507ef PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal priority bug or improvement with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 12, 2026
@clawsweeper

clawsweeper Bot commented Nov 12, 2026

Copy link
Copy Markdown

Codex review: needs real behavior proof before merge.

What this changes

Recognize weekly quota values when Claude omits the session row, allowing capture to finish and stopping repeated Enter presses.

Example: Claude displays no Current session row and shows Current week at 55% used.

  • Before: The capture waits until its 20-second deadline and continues sending Enter.
  • After: The weekly value satisfies quota detection, suppressing Enter and allowing capture to finish after settling.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The implementation is focused and source-correct, with meaningful reported negative controls; captured real-behavior evidence remains incomplete.
Proof confidence 🦪 silver shellfish (2/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Weekly-only Claude accounts incur unnecessary CLI waits and can time out through the default HTTP provider budget.
Reason: The supported account shape already parses correctly; repairing capture readiness restores useful behavior without changing defaults or public contracts.

Merge readiness

⛔ Blocked before merge - 1 item remains

This PR addresses a current weekly-only Claude capture bug with a focused change; no introduced correctness or security defect was found.

Priority: P2
Reviewed head: c0507ef23de1aa4467f88e0c04dfde24141b2504

Before merge

  • Add real behavior proof - The Live section describes a well-targeted weekly-only CLI run and measured improvement, but its timing table and narrative do not include captured after-fix output exercising ClaudeStatusProbe through the shipped command. After adding proof, update the PR body, then request a new review with @clawsweeper re-review. The PR author or someone with repository write access can request it.

Findings

None.

Tests

  • Missing end-to-end proof: Attach a redacted terminal screenshot, output, or logs from the reported branch CLI run showing prompt completion and retained weekly windows; redact credentials, IPs, and non-public endpoints.
Agent review details

How this fits together

The Claude provider launches the Claude CLI through a shared PTY session, renders its terminal output, detects quota readiness, and parses the captured panel into usage windows.

flowchart LR
 A[Usage request] --> B[Claude status probe]
 B --> C[Shared PTY session]
 C --> D[Claude CLI usage panel]
 D --> E[Rendered terminal frame]
 E --> F[Quota completion check]
 F --> G[Parsed usage windows]
Loading

Technical review

Best possible solution:

Extend the existing shared quota predicate to weekly-only panels while retaining refresh, insights, and deadline safeguards.

Do we have a high-confidence way to reproduce the issue?

Main's session-only predicate cannot accept the reported weekly-only panel, and the capture loop consequently retains its deadline and Enter retries; no tests or live probes were run during this read-only review.

Is this the best way to solve the issue?

This repairs the existing recognition owner directly without adding state or another capture path, and keeps the separate serve caching proposal outside scope.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 7447bc77c249.

Provenance checked

  • Quota completion and Enter suppression keeps the original intent (e059a78: Wait for a quota value rather than stopping on a label; later commits excluded insights percentages and preserved refreshing panels.)
  • Loading detection keeps the original intent (354e0b6: Reject captures that still contain loading text without usable quota data.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 4037ac3 adds Sources/CodexBarCore/Providers/Claude/ClaudeStatusProbe.swift:1523 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 4037ac316dbd; files: Sources/CodexBarCore/Providers/Claude/ClaudeStatusProbe.swift)
  • bobbywang: Raw commit a96e58f adds Sources/CodexBarCore/Providers/Claude/ClaudeStatusProbe.swift:285 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: a96e58f30197; files: Sources/CodexBarCore/Providers/Claude/ClaudeStatusProbe.swift)

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Review metrics

Metric Value Why it matters
Production and regression scope Production +7/-5; tests +80/-6 The production change stays within the existing predicate and callers; two complementary regressions cover screen readiness and PTY Enter suppression.

Labels

Label changes:

  • add P2: The bug delays a supported Claude account shape and can exceed the default serve provider deadline, with a documented timeout workaround.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Label justifications:

  • P2: The bug delays a supported Claude account shape and can exceed the default serve provider deadline, with a documented timeout workaround.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed November 12, 2026, 8:46 AM ET / 13:46 UTC.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal priority bug or improvement with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Claude CLI source waits out the 20 s /usage timeout on weekly-only plans

1 participant