Skip to content

Show menu pace token during early weekly window - #2853

Open
Yuxin-Qiao wants to merge 7 commits into
steipete:mainfrom
Yuxin-Qiao:fix/pace-token-early-window-2842
Open

Show menu pace token during early weekly window#2853
Yuxin-Qiao wants to merge 7 commits into
steipete:mainfrom
Yuxin-Qiao:fix/pace-token-early-window-2842

Conversation

@Yuxin-Qiao

@Yuxin-Qiao Yuxin-Qiao commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds the pace reserve percentage as a menu bar display token. During the early part of the weekly quota window, the pace estimate used to be hidden (no expected usage baseline yet), so the new token showed nothing even though a meaningful pace can be derived from elapsed window time.

The weekly menu-bar token now becomes eligible after one percent of the weekly window has elapsed, even when learned Codex history still predicts less than one percent expected usage. The returned pace value remains the existing learned or linear estimate; only token eligibility uses elapsed progress as an explicit fallback.

Scope

The one-percent elapsed floor applies only to the weekly token. sessionPace and automaticPace keep the existing three-percent floor (automatic can resolve to a session/primary window), and runsOut keeps the three-percent floor.

Changes

  • UsageStore+HistoricalPace: weeklyPace/menuBarLayoutPaceText gain the existing three-percent expected-use floor plus an optional elapsed-progress fallback.
  • Elapsed eligibility uses the same resolved pace window as the calculation, including calendar-month billing cycles instead of a fixed 30-day sentinel.
  • Status item, layout editor preview, and redraw signature: pass the one-percent elapsed fallback only for the weekly token; session, automatic, and Runs out keep the default three-percent floor.
  • Countdown scheduling: custom layouts containing the weekly pace token wake at the one-percent boundary so the token does not wait for an unrelated refresh.
  • Tests: call-site regression (menu bar layout pace opens weekly early but floors session and automatic at three percent), learned Codex history below one percent, early-window seam coverage, and an env-gated render-proof test (test_renderEarlyWeeklyPaceTokenProof) that renders the real menu-bar path to a PNG.
  • Tests also cover calendar-month elapsed resolution and the custom-layout wake boundary.
  • docs/ui.md: documents the weekly-only exception and preserves the three-percent behavior for session, automatic, and Runs out.

Evidence

Real menu-bar rendering path from the freshly built bundle, synthetic early-week snapshot (weekly 4h into the window at 2.38% expected; session 2min into 120min at 1.67% expected):

Early weekly pace token proof

Weekly shows W 5% · +3%; session and automatic hide the pace token (3% floor). Runs out also remains hidden in this early band.

Commands

swift test --disable-sandbox --filter HistoricalUsagePace
swift test --disable-sandbox --filter 'HistoricalUsagePace|MenuBarCountdownRefreshTests'
swift test --disable-sandbox --filter StatusItemBalanceDisplayTests
swift test --disable-sandbox --filter ProviderArchitectureGatekeeperTests
CODEXBAR_PACE_SCREENSHOT_DIR=docs/screenshots swift test --filter MenuLayoutScreenshotRenderTests
make check
swiftlint lint --strict --no-cache Sources/CodexBar/StatusItemController+CountdownRefresh.swift Sources/CodexBar/UsageStore+HistoricalPace.swift Tests/CodexBarTests/ProviderArchitectureGatekeeperTests.swift
swiftformat --lint Sources/CodexBar/StatusItemController+CountdownRefresh.swift Sources/CodexBar/UsageStore+HistoricalPace.swift Tests/CodexBarTests/ProviderArchitectureGatekeeperTests.swift
git diff --check

Focused HistoricalUsagePace and MenuBarCountdownRefresh tests: 68/68 passed. ProviderArchitectureGatekeeperTests: 38/38 passed. The learned-Codex, calendar-month, and custom-layout wake regressions pass. make check, lint, format, and diff checks are clean.

Closes #2842

@clawsweeper

clawsweeper Bot commented Aug 11, 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 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 11, 2026
@clawsweeper

clawsweeper Bot commented Aug 11, 2026

Copy link
Copy Markdown

Codex review: needs maintainer review before merge. Reviewed August 11, 2026, 2:27 AM ET / 06:27 UTC.

ClawSweeper review

What this changes

The branch allows the weekly menu-bar pace token to render after 1% of its resolved quota window has elapsed while leaving session, automatic, and Runs out tokens at the existing 3% threshold.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

The patch is technically coherent and well-proven, but it intentionally changes the documented 3% pace-display policy for existing weekly layouts; a repository maintainer should explicitly confirm that weekly-only compatibility change before merge.

Priority: P2
Reviewed head: 8e1a37fab1d166536f30ef257be72caabed7c2a0
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) Strong direct UI proof and focused regression coverage support a technically ready patch, with product-policy confirmation as the remaining merge decision.
Proof confidence 🦞 diamond lobster (5/6) ✨ media proof bonus Sufficient (screenshot): The PR body provides an after-fix screenshot from the freshly built menu-bar rendering path, showing weekly pace rendered while session, automatic, and Runs out remain gated.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (screenshot): The PR body provides an after-fix screenshot from the freshly built menu-bar rendering path, showing weekly pace rendered while session, automatic, and Runs out remain gated.
Evidence reviewed 5 items Current documented contract: Current main documents that pace tokens render an en dash during the first 3% of a window, so the proposed weekly exception is a user-visible policy change rather than a repair of an unspecified behavior.
Scoped implementation: The PR keeps the normal 3% expected-use threshold and adds a separate elapsed-progress fallback; its weekly call sites pass 1 while the other pace tokens retain defaults.
Existing feature provenance: The existing menu-bar pace-token surface was introduced by the merged history commit “Add menu bar pace layout tokens,” supporting that this PR expands its eligibility policy rather than introducing the token itself.
Findings None None.
Security None None.

How this fits together

CodexBar turns provider quota snapshots into menu-bar layout tokens. Pace calculation determines the signed weekly estimate, while the status-item scheduler wakes the menu bar when time alone makes that estimate eligible to render.

flowchart LR
A[Provider quota snapshot] --> B[Resolved pace window]
B --> C[Pace estimate]
C --> D[Eligibility threshold]
D --> E[Weekly menu-bar token]
D --> F[Refresh scheduler]
F --> E
Loading

Decision needed

Question Recommendation
Should existing Weekly pace layouts begin showing a signed estimate after 1% elapsed time while all other pace-related tokens retain the documented 3% threshold? Approve the weekly-only exception: Accept the visible 1–3% behavior change for Weekly pace and merge the already-scoped implementation.

Why: Current documentation establishes a uniform 3% threshold, and the provided policy statement is from a CONTRIBUTOR account rather than a verified repository maintainer decision.

Before merge

  • Resolve merge risk (P1) - Existing custom layouts containing Weekly pace will replace an en dash with an early signed estimate during the 1–3% elapsed-window band; this is deliberate only if maintainers accept the new weekly-only display policy.
  • Complete next step (P2) - A maintainer must approve or reject the weekly-only 1% display-policy exception before this otherwise ready branch can merge.
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Implementation and regression coverage production +141/-16, tests +331/-6, docs +5/-2, 1 screenshot added The implementation is accompanied by targeted coverage for the new eligibility, provider-specific calculation, and timer boundary behavior.

Merge-risk options

Maintainer options:

  1. Approve the weekly-only compatibility change (recommended)
    Explicitly accept that existing Weekly pace layouts show an estimate in the 1–3% band while other token types remain unchanged.
  2. Keep the 3% contract
    Pause or close the PR if maintainers prefer the documented uniform threshold over early weekly visibility.

Technical review

Best possible solution:

Confirm the weekly-only 1% exception as the intended product policy, then merge this bounded implementation while retaining the 3% default for session, automatic, and Runs out tokens.

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

Not applicable: this is a proposed display-policy enhancement rather than a report of broken existing behavior; the supplied fresh-bundle screenshot directly exercises the intended rendering path.

Is this the best way to solve the issue?

Unclear pending product confirmation: the implementation is narrowly scoped and preserves the other token thresholds, but maintainers must choose whether the documented 3% contract should have this weekly exception.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P2: This is a bounded menu-bar behavior improvement with limited blast radius, not an urgent regression.
  • merge-risk: 🚨 compatibility: Merging changes what established Weekly pace layouts display during the early 1–3% window.
  • 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. Sufficient (screenshot): The PR body provides an after-fix screenshot from the freshly built menu-bar rendering path, showing weekly pace rendered while session, automatic, and Runs out remain gated.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body provides an after-fix screenshot from the freshly built menu-bar rendering path, showing weekly pace rendered while session, automatic, and Runs out remain gated.
  • proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence. The PR body provides an after-fix screenshot from the freshly built menu-bar rendering path, showing weekly pace rendered while session, automatic, and Runs out remain gated.

Evidence

What I checked:

  • Current documented contract: Current main documents that pace tokens render an en dash during the first 3% of a window, so the proposed weekly exception is a user-visible policy change rather than a repair of an unspecified behavior. (docs/ui.md:38, 8d113c642516)
  • Scoped implementation: The PR keeps the normal 3% expected-use threshold and adds a separate elapsed-progress fallback; its weekly call sites pass 1 while the other pace tokens retain defaults. (Sources/CodexBar/UsageStore+HistoricalPace.swift:56, 8e1a37fab1d1)
  • Existing feature provenance: The existing menu-bar pace-token surface was introduced by the merged history commit “Add menu bar pace layout tokens,” supporting that this PR expands its eligibility policy rather than introducing the token itself. (Sources/CodexBar/UsageStore+HistoricalPace.swift:54, f93e3ed460ad)
  • Current-main status: The PR head is not contained by the checked-out main branch or a release tag, so this weekly-only behavior is not already implemented or shipped. (8e1a37fab1d1)
  • After-fix behavior proof: The PR supplies a freshly built menu-bar rendering screenshot and focused coverage for learned Codex history, calendar-month resolution, weekly-only call sites, and the 1% refresh boundary. (docs/screenshots/early-weekly-pace-token-proof.png, 8e1a37fab1d1)

Likely related people:

  • Peter Steinberger: Recent current-main history includes the provider-special-case refactor and the currently checked-out pace/menu-bar implementation. (role: recent pace and menu-bar area contributor; confidence: high; commits: 61fbe9fac507, 330ae4384b18; files: Sources/CodexBar/UsageStore+HistoricalPace.swift, Sources/CodexBar/StatusItemController+MenuBarLayout.swift, Sources/CodexBar/StatusItemController+CountdownRefresh.swift)
  • Petr Kratochvíl: Merged commit f93e3ed introduced the existing menu-bar pace layout tokens that this PR extends. (role: introduced the menu-bar pace-token feature; confidence: high; commits: f93e3ed460ad; files: Sources/CodexBar/UsageStore+HistoricalPace.swift, Sources/CodexBar/StatusItemController+MenuBarLayout.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.

History

Review history (7 earlier review cycles)
  • reviewed 2026-08-11T02:17:41.130Z sha 6914e0b :: needs real behavior proof before merge. :: [P2] Restrict the one-percent floor to weekly tokens
  • reviewed 2026-08-11T03:44:37.973Z sha 6963256 :: needs real behavior proof before merge. :: [P2] Gate early Codex pace on elapsed weekly progress | [P2] Keep the lower floor off the run-out token
  • reviewed 2026-08-11T04:15:17.406Z sha b35d9a5 :: needs changes before merge. :: [P2] Gate learned Codex pace on elapsed weekly progress | [P2] Keep the early floor off the run-out token | [P3] Document the weekly-only threshold exception
  • reviewed 2026-08-11T05:00:23.780Z sha 0cd048f :: needs changes before merge. :: [P2] Measure elapsed progress on the resolved pace window | [P2] Schedule a redraw when weekly pace crosses 1%
  • reviewed 2026-08-11T05:15:33.837Z sha 1bf1bae :: needs maintainer review before merge. :: none
  • reviewed 2026-08-11T05:44:58.130Z sha 8e1a37f :: needs maintainer review before merge. :: none
  • reviewed 2026-08-11T05:49:51.041Z sha 8e1a37f :: needs maintainer review before merge. :: none

@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: 6914e0b215

ℹ️ 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".

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

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".


guard let resolved else { return nil }
guard resolved.expectedUsedPercent >= Self.minimumPaceExpectedPercent else { return nil }
guard resolved.expectedUsedPercent >= minimumExpectedPercent else { return nil }

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 Gate early Codex pace on elapsed progress

For Codex users with historical tracking enabled and a mature dataset whose prior weeks have little usage in the first few hours, CodexHistoricalPaceEvaluator can return a learned expectedUsedPercent below 1% even after more than 1% of the weekly window has elapsed. This guard then still suppresses the menu token—for example, roughly 20 histories that remain flat for four hours produce an expectation around 0.78% at four hours—so the change does not reliably fix the early-window behavior for the provider-specific path. Gate menu-token eligibility on elapsed window progress (or otherwise preserve a linear floor), and cover the Codex historical branch rather than only .zai.

AGENTS.md reference: AGENTS.md:L5-L5

Useful? React with 👍 / 👎.

@Yuxin-Qiao
Yuxin-Qiao force-pushed the fix/pace-token-early-window-2842 branch from 6914e0b to 6963256 Compare August 11, 2026 03:37

@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: b35d9a5357

ℹ️ 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".

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

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

provider: provider,
window: $0,
now: now,
minimumExpectedPercent: windows.weekly != nil ? 1 : 3)

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 Keep the early floor scoped to the weekly pace token

When a layout contains .runsOut and the weekly window has only reached 1–3% expected usage, this also lowers the forecast's guard and starts showing an exhaustion estimate based on just the first few hours. runsOut is a separate token from the signed weekly pace token, so it should retain the existing 3% floor; the mirrored calculation in MenuBarLayoutEditor.liveData should do the same.

Useful? React with 👍 / 👎.

@clawsweeper clawsweeper Bot added proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. proof: sufficient Contributor real behavior proof is sufficient. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed 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 11, 2026
@Yuxin-Qiao

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 11, 2026

Copy link
Copy Markdown

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@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: 0cd048f1e0

ℹ️ 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".

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

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +53 to +55
let elapsedFloorMet = minimumElapsedPercent.map { minimum in
(Self.windowElapsedPercent(window: window, now: now) ?? 0) >= minimum
} ?? false

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 the resolved window for the elapsed floor

For providers whose semantic weekly lane is a calendar-month quota represented by a 30-day sentinel (for example, Notion's monthly lane), pace is correctly calculated from paceWindow, but this new eligibility check measures the original sentinel window. At the start of a 28-day February cycle it therefore reports two days (6.7%) already elapsed and exposes the pace token immediately instead of after 1%; a 31-day cycle delays it by roughly a day. Measure elapsed progress against the same resolved calendar window used to calculate resolved.

Useful? React with 👍 / 👎.

Comment on lines +86 to +90
weeklyPace: self.store.menuBarLayoutPaceText(
provider: provider,
window: windows.weekly,
now: now,
minimumElapsedPercent: 1),

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 Schedule a redraw when weekly pace crosses 1%

When a snapshot is rendered before the new 1% boundary, this call returns nil and the status item shows a dash, but crossing the boundary changes only Date() and does not trigger Observation. In particular, with manual refresh and a custom layout containing only the weekly pace token, UsageStore.startTimer has no polling timer and scheduleMenuBarCountdownRefreshIfNeeded schedules custom-layout wakes only for reset tokens, so the new pace can remain hidden indefinitely until an unrelated update or manual refresh. Schedule an icon refresh for the eligibility boundary when this token is present.

Useful? React with 👍 / 👎.

@Yuxin-Qiao

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 11, 2026

Copy link
Copy Markdown

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Aug 11, 2026
@Yuxin-Qiao

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 11, 2026

Copy link
Copy Markdown

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Aug 11, 2026
@Yuxin-Qiao

Copy link
Copy Markdown
Contributor Author

Maintainer decision: accept the weekly-only 1% elapsed eligibility for existing and custom weekly pace layouts. Keep the established 3% floor for session, automatic, and Runs out tokens.

@Yuxin-Qiao

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

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. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. proof: sufficient Contributor real behavior proof is sufficient. 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.

Add pace reserve percentage as a menu bar display token

1 participant