Skip to content

Add per-provider menu bar percent window picker - #3124

Open
J2TeamNNL wants to merge 1 commit into
steipete:mainfrom
J2TeamNNL:upstream-pr/menu-bar-percent-window
Open

Add per-provider menu bar percent window picker#3124
J2TeamNNL wants to merge 1 commit into
steipete:mainfrom
J2TeamNNL:upstream-pr/menu-bar-percent-window

Conversation

@J2TeamNNL

Copy link
Copy Markdown
Contributor

Summary

The menu bar percent is driven by the layout's % tokens, each carrying its own
PercentWindow (session / weekly / automatic). That is expressive, but the layout
editor is the only place to change it. An account whose stored metric preference resolves
to the weekly lane shows a nearly-full weekly percent with no obvious way to switch to
session — confusing on plans where exhausting a session does not come close to filling the
week, since a quick glance at the menu bar reads as "almost out".

menu_bar_metric_title / menu_bar_metric_subtitle are still translated in all 22
catalogs but no longer referenced by any pane, which suggests this control used to exist
and was lost when layouts replaced the metric preference UI.

Changes

  • MenuBarPercentWindowPreference: maps the common case — every percent token in a layout
    reading the same window — onto a single Auto/Session/Weekly choice, with pure
    current(in:) / applied(to:) / hasPercentToken(in:) helpers.
  • ProviderMenuBarPercentWindowSettingsView: a picker in the provider pane that writes a
    per-provider layout override through the existing
    MenuBarLayoutEditorPersistence.activate.
  • Mixed layouts (e.g. Session · Weekly) report "Custom" and are left to the layout
    editor rather than being flattened. A layout with no percent token hides the picker.
  • Only top-level percent tokens are considered; tokens inside a conditional stay under the
    layout editor's control.
  • No new strings — this reuses the two already-translated, currently-unused keys.

Commands run

  • swift build --target CodexBar — clean (typechecks the whole module)
  • node Scripts/check-app-locales.mjsApp locales OK: Checked 22 catalogs against 1479 English keys.

Verification caveat

Developed on a machine with only CommandLineTools and no Xcode, so make test and
swiftlint could not run here (Testing module unavailable; swiftlint fails loading
sourcekitdInProc), and there is no screenshot of the new picker for the same reason.
Relying on CI for the suite — happy to iterate on anything it flags.

The menu bar percent comes from the layout's % tokens, each carrying its own
PercentWindow, and the layout editor is the only place to change them. An
account whose stored metric preference resolves to the weekly lane therefore
shows a nearly-full weekly percent with no obvious way to switch to session —
confusing on plans where exhausting a session does not fill the week. The
menu_bar_metric_title / menu_bar_metric_subtitle strings are already
translated but no longer used by any pane.

Add an Auto/Session/Weekly picker to the provider pane for the common case
where every percent in the layout reads the same window. Mixed layouts report
Custom and are left to the layout editor, and a layout with no percent hides
the picker entirely.
@clawsweeper

clawsweeper Bot commented Aug 21, 2026

Copy link
Copy Markdown

🦞👀
ClawSweeper picked this up.

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

@J2TeamNNL

Copy link
Copy Markdown
Contributor Author

Heads up: this touches the same spot in PreferencesProviderDetailView.swift as #3123. They are independent changes — whichever lands second needs a one-line rebase in that file.

@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: 0964dfd42e

ℹ️ 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 +47 to +50
MenuBarLayoutEditorPersistence.activate(
preference.applied(to: layout),
for: self.provider,
settings: self.settings)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Preserve the global menu-bar style when changing a provider window

When the user has selected the Critters or Bars style, this picker is still visible because the legacy layout resolution can contain a percent token. Choosing an option calls MenuBarLayoutEditorPersistence.activate, which sets menuBarIconStyle = .iconAndPercent; consequently a per-provider window change unexpectedly replaces the global style for every provider. The layout editor itself is disabled for non-percent styles in PreferencesMenuBarPane.swift, so this picker should likewise avoid activation or be hidden in those modes.

Useful? React with 👍 / 👎.

Comment on lines +25 to +27
ForEach(MenuBarPercentWindowPreference.allCases) { preference in
Text(preference.label).tag(MenuBarPercentWindowPreference?.some(preference))
}

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 Filter out windows the provider cannot render

Presenting all three choices lets balance-only providers select unusable windows. For example, Mistral snapshots deliberately have both primary and secondary set to nil, so its semantic session and weekly windows are nil; selecting either option here replaces the useful Automatic spend text with an unavailable percent. The choices should be constrained using provider capabilities/metadata, or the control should be hidden when no session or weekly quota exists.

Useful? React with 👍 / 👎.

@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. P2 Normal priority bug or improvement with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 21, 2026
@clawsweeper

clawsweeper Bot commented Aug 21, 2026

Copy link
Copy Markdown

Codex review: needs real behavior proof before merge. Reviewed August 21, 2026, 12:22 PM ET / 16:22 UTC.

ClawSweeper review

What this changes

The PR adds a per-provider Auto, Session, or Weekly picker that rewrites top-level percent tokens in the resolved menu-bar layout.

Merge readiness

Blocked until real behavior proof is added - 8 items remain

Keep open: the feature is plausible, but the current picker can change an existing global menu-bar style and can select unavailable windows for Mistral. It also needs contributor-provided after-fix UI evidence before merge.

Priority: P2
Reviewed head: 0964dfd42ec65183ee5f555c386e8a76e2893717
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The feature has a focused implementation and tests, but two concrete compatibility defects plus missing real behavior proof keep it from merge-ready quality.
Proof confidence 🧂 unranked krab (1/6) Needs real behavior proof before merge: Build and locale-check claims are useful supplemental validation, but the PR provides no after-fix settings interaction or menu-bar result; add redacted runtime proof before merge. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Patch quality 🦐 gold shrimp (3/6) 2 actionable review findings remain.

Verification

Check Result Evidence
Real behavior Needs proof Needs real behavior proof before merge: Build and locale-check claims are useful supplemental validation, but the PR provides no after-fix settings interaction or menu-bar result; add redacted runtime proof before merge. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed 7 items Style-changing persistence path: The new picker resolves a layout regardless of the selected menu-bar style, then calls the layout-editor activation helper when a choice changes.
Existing style contract: The existing menu-bar pane disables layout editing unless Icon + percent is selected, while the shared activation helper sets that global style before persisting a layout.
Mistral capability boundary: Mistral supports only Automatic and Monthly Plan menu-bar metrics; it does not expose semantic Session or Weekly windows.
Findings 2 actionable findings [P1] Keep non-percent menu-bar styles unchanged
[P2] Offer only windows the provider can render
Security None None.

Live Verification

Command: swift build --target CodexBar

Result: FAIL (failed) — execution before step 1 run: sh -lc pnpm install --ignore-scripts --frozen-lockfile failed: ! Corepack is about to download https://registry.npmjs.org/pnpm/-/pnpm-11.22.0.tgz

sh -lc pnpm install --ignore-scripts --frozen-lockfile failed: ! Corepack is about to download https://registry.npmjs.org/pnpm/-/pnpm-11.22.0.tgz

Assertions:

  • FAIL expect_output: Build complete

How this fits together

CodexBar resolves global or provider-specific menu-bar layouts into tokens that render provider usage in the macOS menu bar. The provider settings pane persists layout overrides, which feed the next menu-bar render.

flowchart LR
A[Provider usage snapshot] --> B[Resolved menu bar layout]
B --> C[Percent tokens and windows]
C --> D[Provider settings picker]
D --> E[Persisted provider layout override]
E --> B
C --> F[Menu bar display]
Loading

Decision needed

Question Recommendation
Should CodexBar add this per-provider shortcut that creates layout overrides, rather than keeping percent-window selection solely in the layout editor? Sponsor a constrained picker: Keep the shortcut only for Icon + percent mode and only for windows the selected provider can render.

Why: The PR adds a new settings surface and persistence behavior; code fixes can make it safe, but maintainers should confirm that this shortcut belongs in the provider pane.

Before merge

  • Add real behavior proof - Needs real behavior proof before merge: Build and locale-check claims are useful supplemental validation, but the PR provides no after-fix settings interaction or menu-bar result; add redacted runtime proof before merge. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Keep non-percent menu-bar styles unchanged (P1) - The picker is visible whenever the resolved legacy layout contains a percent token, including Critters and Bars. Selecting a value calls activate, which sets the global style to Icon + percent; hide or disable this control unless that style is already active.
  • Offer only windows the provider can render (P2) - Every provider receives Session and Weekly choices, but Mistral advertises only Automatic and Monthly Plan metrics. Selecting either unsupported window rewrites its Automatic token and the renderer produces an unavailable value; derive the options from provider capabilities or hide the control when no semantic quota window exists.
  • Resolve merge risk (P1) - Selecting a provider window while Critters or Bars is active silently switches the global menu-bar style to Icon + percent.
  • Resolve merge risk (P1) - Mistral users can select Session or Weekly even though those semantic windows are unavailable, replacing useful Automatic monthly-plan output with an unavailable value.
  • Resolve merge risk (P1) - No after-fix interactive proof establishes that the picker persists and renders the intended provider-specific result.
  • Complete next step (P2) - A sponsor must confirm the new provider-pane surface, and the contributor must supply real behavior proof after the concrete compatibility repairs.

Findings

  • [P1] Keep non-percent menu-bar styles unchanged — Sources/CodexBar/ProviderMenuBarPercentWindowSettingsView.swift:47-50
  • [P2] Offer only windows the provider can render — Sources/CodexBar/ProviderMenuBarPercentWindowSettingsView.swift:25-26
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Code and test growth production +128, tests +61 across 4 files The focused implementation is accompanied by pure layout-token tests, but it does not cover style preservation or provider capability filtering.

Merge-risk options

Maintainer options:

  1. Repair compatibility before merge (recommended)
    Gate the picker on Icon + percent mode and filter choices by provider-renderable windows before obtaining fresh behavior proof.

Technical review

Best possible solution:

If sponsored, show the picker only in Icon + percent mode, limit choices to renderable provider windows, add focused coverage, and provide a redacted after-fix settings/menu-bar demonstration.

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

Yes, from source: choose a window while Critters or Bars is selected and the picker invokes the helper that sets Icon + percent; Mistral can likewise select a Session or Weekly token that has no render window. No live app run was performed in this read-only review.

Is this the best way to solve the issue?

No. Reusing the layout editor's activating persistence helper is unsafe outside Icon + percent mode, and the unfiltered options disregard provider capabilities; a gated, capability-aware picker is the narrower maintainable path.

Full review comments:

  • [P1] Keep non-percent menu-bar styles unchanged — Sources/CodexBar/ProviderMenuBarPercentWindowSettingsView.swift:47-50
    The picker is visible whenever the resolved legacy layout contains a percent token, including Critters and Bars. Selecting a value calls activate, which sets the global style to Icon + percent; hide or disable this control unless that style is already active.
    Confidence: 0.99
  • [P2] Offer only windows the provider can render — Sources/CodexBar/ProviderMenuBarPercentWindowSettingsView.swift:25-26
    Every provider receives Session and Weekly choices, but Mistral advertises only Automatic and Monthly Plan metrics. Selecting either unsupported window rewrites its Automatic token and the renderer produces an unavailable value; derive the options from provider capabilities or hide the control when no semantic quota window exists.
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.99

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P2: The feature is user-facing and can alter an existing menu-bar preference, but it affects users only after interacting with the new control.
  • add merge-risk: 🚨 compatibility: The shared persistence helper changes the global menu-bar style, so a per-provider choice can unexpectedly change every provider's display mode.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦐 gold shrimp.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: Build and locale-check claims are useful supplemental validation, but the PR provides no after-fix settings interaction or menu-bar result; add redacted runtime proof before merge. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Label justifications:

  • P2: The feature is user-facing and can alter an existing menu-bar preference, but it affects users only after interacting with the new control.
  • merge-risk: 🚨 compatibility: The shared persistence helper changes the global menu-bar style, so a per-provider choice can unexpectedly change every provider's display mode.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: Build and locale-check claims are useful supplemental validation, but the PR provides no after-fix settings interaction or menu-bar result; add redacted runtime proof before merge. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Introduced the menu-bar layout editor and the activation behavior that this picker reuses. (role: layout-editor feature author; confidence: high; commits: 0f070a38fa7f, 93bff51f8379; files: Sources/CodexBar/MenuBarLayoutEditor.swift, Sources/CodexBar/PreferencesMenuBarPane.swift)
  • Kiran Magic: Recent Mistral work preserved its monthly-plan layout behavior and documented its exceptional rendering path. (role: recent Mistral layout contributor; confidence: high; commits: d58b102b3e27, 552761d26110; files: Sources/CodexBarCore/Providers/Mistral/MistralProviderDescriptor.swift, docs/mistral.md)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Preserve Critters and Bars when changing a provider preference.
  • Filter or hide unsupported Session and Weekly options, including Mistral.
  • Add a redacted after-fix settings/menu-bar run to the PR body for re-review.

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.

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

Labels

merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. P2 Normal priority bug or improvement with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. 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.

1 participant