Skip to content

fix: honor usage direction in plugin cards - #2837

Merged
steipete merged 1 commit into
mainfrom
fix/user-plugin-usage-direction
Aug 10, 2026
Merged

fix: honor usage direction in plugin cards#2837
steipete merged 1 commit into
mainfrom
fix/user-plugin-usage-direction

Conversation

@steipete

Copy link
Copy Markdown
Owner

Summary

  • pass the existing Usage bars fill preference into user-installed provider menu cards
  • derive one clamped used/remaining presentation and use it for both percentage text and progress-bar fill
  • add focused remaining, used, and out-of-range regression coverage
  • document the user-visible fix for 0.49.2

Root cause

Built-in rich cards already normalize each metric to the selected used/remaining direction before rendering. The bespoke user-plugin card bypassed that model and hard-coded window.usedPercent, "% used", and a used-oriented bar. As a result, As remaining affected built-in cards but not user-installed providers.

The fix keeps this local to the user-plugin presentation boundary. CLI output, provider snapshots, and semantically fixed spend/headroom displays are unchanged.

Validation

  • CODEXBAR_SUPPRESS_TEST_KEYCHAIN_ACCESS=1 swift test --filter UserPluginQuotaPresentationTests — 3 tests passed
  • CODEXBAR_SUPPRESS_TEST_KEYCHAIN_ACCESS=1 swift test --filter 'StatusMenuUsageDisplayTests|UsageMenuCardLayoutTests' — 11 tests passed
  • make check — passed
  • structured autoreview — secret scan clean; no accepted/actionable findings
  • Developer-ID-signed before/after debug bundles exercised the real user-plugin card in the composited native menu

Native before/after proof

Both captures set Usage bars fill to As remaining and use the same deterministic local plugin snapshot: 4% used, 96% remaining. The manifest retains its existing approved identity; the temporary fetch body makes no network request. The surrounding Sub2API data is synthetic, and personal information is hidden.

Before (main) After (this PR)
User plugin card before: 4% used with remaining mode selected User plugin card after: 96% left with matching bar

Fixes #2749

@clawsweeper

clawsweeper Bot commented Aug 10, 2026

Copy link
Copy Markdown

🦞👀
ClawSweeper picked this up.

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

@clawsweeper clawsweeper Bot added P2 Normal priority bug or improvement with limited blast radius. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 10, 2026
@clawsweeper

clawsweeper Bot commented Aug 10, 2026

Copy link
Copy Markdown

Codex review: needs maintainer review before merge. Reviewed August 10, 2026, 6:35 AM ET / 10:35 UTC.

ClawSweeper review

What this changes

Routes the existing used-versus-remaining preference into user-installed provider cards so their percentage text and progress-bar fill use one clamped presentation.

Regression provenance

Possible regression — probable (reproduction; reviewed change). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

This owner-authored PR is a focused repair for the linked user-plugin card inconsistency and should remain open for normal merge validation. The submitted native before/after evidence and targeted regression tests support the change; required CI was still in progress at review time.

Priority: P2
Reviewed head: 5a422a14f44c75fc9aef9f308635cfb05ec63de2

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A focused, well-covered presentation repair with convincing native before/after evidence.
Proof confidence 🦞 diamond lobster (5/6) Not applicable: The contributor is the repository owner, so external-contributor proof gating does not apply; the PR nevertheless includes directly relevant native-menu before/after captures.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The contributor is the repository owner, so external-contributor proof gating does not apply; the PR nevertheless includes directly relevant native-menu before/after captures.
Evidence reviewed 6 items Current-main defect: Current main hard-codes both the user-plugin label as percent used and the bar as used percent, while built-in card metrics select used or remaining from the shared setting.
Patch behavior: The branch passes the setting into the plugin card and derives its label and bar percent from one clamped used/remaining presentation.
Shared presentation contract: Built-in menu-card metrics already choose used or remaining according to this setting, and UsageFormatter supplies the matching localized suffix.
Findings None None.
Security None None.

How this fits together

CodexBar collects provider usage snapshots and renders them in menu-bar cards. User-installed provider plugins have a dedicated card view that now consumes the same usage-direction setting as built-in cards before producing text and bar output.

flowchart LR
    A[Provider plugin snapshot] --> B[User plugin card]
    C[Usage-bars preference] --> D[Quota presentation]
    B --> D
    D --> E[Percentage label]
    D --> F[Progress bar]
    E --> G[Native menu card]
    F --> G
Loading

Before merge

  • Resolve merge risk (P1) - Required macOS and Linux build/test checks were still in progress at review time; merge the reviewed head only after they conclude successfully.
  • Complete next step (P2) - No repair lane is needed: the patch is coherent and the remaining action is normal merge validation on this owner-authored PR.
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Patch scope 3 files affected: production +18/-2, tests +28, release note +1 The implementation is confined to the user-plugin presentation boundary and adds direct mode and bounds coverage.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #2749
Summary: This PR is the concrete candidate fix for the linked user-plugin usage-direction mismatch.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Land this localized presentation repair once the required checks validate the reviewed head, leaving provider snapshots and CLI semantics unchanged.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Land this localized presentation repair once the required checks validate the reviewed head, leaving provider snapshots and CLI semantics unchanged.

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

Yes. The PR provides a deterministic current-main before/after native-menu scenario using the same local plugin snapshot and the remaining-mode preference, alongside focused presentation tests.

Is this the best way to solve the issue?

Yes. Passing the existing setting into the separate plugin-card presentation boundary reuses the established built-in-card behavior without altering provider data or unrelated output.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against abad945bc07f.

Labels

Label changes:

  • add P2: This fixes a visible preference inconsistency in user-installed provider cards without data, security, or availability impact.
  • add proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence. The contributor is the repository owner, so external-contributor proof gating does not apply; the PR nevertheless includes directly relevant native-menu before/after captures.
  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The contributor is the repository owner, so external-contributor proof gating does not apply; the PR nevertheless includes directly relevant native-menu before/after captures.

Label justifications:

  • P2: This fixes a visible preference inconsistency in user-installed provider cards without data, security, or availability impact.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The contributor is the repository owner, so external-contributor proof gating does not apply; the PR nevertheless includes directly relevant native-menu before/after captures.
  • proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence. The contributor is the repository owner, so external-contributor proof gating does not apply; the PR nevertheless includes directly relevant native-menu before/after captures.

Evidence

What I checked:

Likely related people:

  • steipete: Current-main history attributes the initial user-installed provider-plugin work and subsequent plugin-card changes to this owner. (role: original feature author and recent area contributor; confidence: high; commits: a82f509ea8e7, f5a1f799186e; files: Sources/CodexBar/StatusItemController+UserPlugins.swift)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5a422a14f4

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines 157 to 160
UsageProgressBar(
percent: window.usedPercent,
percent: presentation.percent,
tint: self.tint,
accessibilityLabel: "\(title) usage")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Use remaining semantics for plugin bar accessibility

When Usage bars fill is set to As remaining, this now feeds the remaining percentage into UsageProgressBar, but the accessibility label still hard-codes "Primary usage"/"Secondary usage". VoiceOver users therefore hear an inverted value such as “Primary usage, 96 percent” while the visual label says “96% left”; derive the label from showUsed (as the built-in cards do with usage used vs usage remaining) so the announced semantics match the configured direction.

Useful? React with 👍 / 👎.

@steipete
steipete merged commit b093129 into main Aug 10, 2026
9 checks passed
@steipete
steipete deleted the fix/user-plugin-usage-direction branch August 10, 2026 10:59
@steipete

Copy link
Copy Markdown
Owner Author

Landed on main as b093129a4f94b54dfc94a993f5686246e4145226.

Tested:

  • CODEXBAR_SUPPRESS_TEST_KEYCHAIN_ACCESS=1 swift test --filter UserPluginQuotaPresentationTests — 3 tests passed.
  • CODEXBAR_SUPPRESS_TEST_KEYCHAIN_ACCESS=1 swift test --filter 'StatusMenuUsageDisplayTests|UsageMenuCardLayoutTests' — 11 tests passed.
  • make check — passed.
  • Structured autoreview — secret scan clean; no accepted/actionable findings.
  • Developer-ID-signed before/after debug bundles used the same approved local plugin manifest and deterministic 4%-used snapshot with As remaining selected. The native menu changed from 4% used with an empty bar to 96% left with a matching full bar; screenshots are in the PR body.
  • Exact-head CI run https://github.com/steipete/CodexBar/actions/runs/31379609222 — all 9 checks passed, including lint, both macOS test shards, Linux glibc ARM64/x86_64, Linux musl, aggregate check, and GitGuardian.

No provider payload, CLI output, or fixed-semantics spend/headroom surface changed; the repair is confined to user-plugin menu-card presentation.

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. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CodexBar does not respect "Usage bars fill" setting for displayed percentages

1 participant