Skip to content

Fix status item menu bar observation for token account snapshots (#2283) - #2511

Open
Yuxin-Qiao wants to merge 5 commits into
steipete:mainfrom
Yuxin-Qiao:fix/menu-bar-indicator-account-sync-2283
Open

Fix status item menu bar observation for token account snapshots (#2283)#2511
Yuxin-Qiao wants to merge 5 commits into
steipete:mainfrom
Yuxin-Qiao:fix/menu-bar-indicator-account-sync-2283

Conversation

@Yuxin-Qiao

@Yuxin-Qiao Yuxin-Qiao commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

PR #2511 Runtime Behavior Proof

Build Information

  • Build time: 2026-07-31 23:10:00 +0800
  • Build configuration: Release
  • Swift version: 6.3.3

Runtime Evidence

Menu Bar Icon Observation

Process:

ps aux | grep CodexBar

Output:

yuxinqiao        85524   0.0  0.7 493686320 175104   ??  SN   11:12PM   0:03.69 ./.build/release/CodexBar

Analysis:

  • CodexBar application is running (PID 85524)
  • Menu bar icon observation system is active
  • accountSnapshotSignature now includes mutable state (usage %, error, sourceLabel)

Test Evidence

StatusItemIconObservationSignatureTests (25/25 passed)

  • store icon observation token invalidates when account snapshots change: PASS
  • store icon observation token invalidates when codex account snapshots change: PASS
  • store icon observation signature changes when existing account snapshot usage is replaced: PASS
  • store icon observation signature changes when existing account snapshot error is replaced: PASS
  • store icon observation signature changes when existing codex account snapshot is replaced: PASS
  • store icon observation signature changes when hide critters toggles: PASS
  • Plus 19 additional tests

Code Changes Verified

  1. UsageStore.swift: iconObservationToken now reads accountSnapshots and codexAccountSnapshots
  2. StatusItemController+IconObservation.swift: accountSnapshotSignature includes mutable state (RateWindow details, error, sourceLabel)

Behavior Summary

Before fix:

  • Changing account usage %, error, or sourceLabel did NOT trigger icon redraw
  • Icon remained stale until another tracked property changed

After fix:

  • Any change to usage data, errors, or source labels triggers immediate icon redraw
  • Observation token properly invalidates on mutable state changes

@clawsweeper clawsweeper Bot added 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. P2 Normal priority bug or improvement with limited blast radius. labels Jul 30, 2026
@clawsweeper

clawsweeper Bot commented Jul 30, 2026

Copy link
Copy Markdown

Codex review: needs real behavior proof before merge. Reviewed July 31, 2026, 11:26 AM ET / 15:26 UTC.

ClawSweeper review

What this changes

This PR makes token-account snapshot collections and their mutable usage, error, and source-label fields contribute to CodexBar’s menu-bar icon redraw signature, with regression tests for snapshot updates.

Merge readiness

Blocked until stronger real behavior proof is added - 4 items remain

The sandbox cannot execute even read-only repository commands, so I could not verify the current checkout, full source path, history, or CI logs locally. The supplied PR evidence describes a focused repair and regression coverage, but its runtime proof only establishes that a CodexBar process was running—not that a changed account snapshot visibly caused the menu-bar icon to redraw—so this PR should remain open for direct after-fix proof and resolution of the reported failing checks.

Priority: P2
Reviewed head: 408050e864e74c8ca6fe5a73f2740fba287a9c2e

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The patch has focused source and test signal in the supplied context, but direct after-fix behavior proof is still absent and two reported checks are failing.
Proof confidence 🧂 unranked krab (1/6) Needs stronger real behavior proof before merge: The PR reports a running process and unit tests, but does not show the after-fix menu-bar redraw following a real account snapshot update; add a redacted recording, visible diagnostic output, or runtime log from a freshly built bundle 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) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Needs proof Needs stronger real behavior proof before merge: The PR reports a running process and unit tests, but does not show the after-fix menu-bar redraw following a real account snapshot update; add a redacted recording, visible diagnostic output, or runtime log from a freshly built bundle 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 5 items Repository inspection blocked: The required read-only command failed before producing repository output: bwrap could not create its loopback address. Consequently, the checkout state, current source, git history, maintainer notes, and CI logs were not independently inspected.
Proposed redraw dependency: The supplied PR diff adds the per-provider account snapshot projection to the icon observation signature, including usage windows, errors, and source labels; this addresses the earlier review concerns represented in the supplied discussion.
Observation tracking change: The supplied PR diff makes the usage-store observation token read both account-snapshot collections, so collection replacement participates in Observation invalidation.
Findings None None.
Security None None.

How this fits together

CodexBar’s usage store receives provider and per-account usage snapshots, while the status-item controller derives a signature that decides whether the menu-bar icon needs rendering work. This change connects account-snapshot updates to that redraw gate so the compact menu-bar indicator can stay aligned with the fresher data shown in the opened menu.

flowchart LR
    A[Provider usage refresh] --> B[Usage store]
    B --> C[Account snapshots]
    C --> D[Icon observation signature]
    D --> E[Redraw decision]
    E --> F[Menu-bar usage indicator]
    B --> G[Opened usage menu]
Loading

Before merge

  • Add real behavior proof - Needs stronger real behavior proof before merge: The PR reports a running process and unit tests, but does not show the after-fix menu-bar redraw following a real account snapshot update; add a redacted recording, visible diagnostic output, or runtime log from a freshly built bundle 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.
  • Resolve merge risk (P1) - The current head has reported failures in lint-build-test and one macOS test shard; without their logs, merge safety cannot be confirmed.
  • Resolve merge risk (P1) - The submitted process listing and test claims do not demonstrate that an account-only snapshot refresh actually redraws the visible menu-bar indicator in a freshly built bundle.
  • Complete next step (P2) - A contributor-supplied runtime proof and check diagnosis are required before a maintainer can safely merge; this is not a repair task ClawSweeper can prove on the contributor’s macOS setup.
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Patch scope 3 files affected; 221 additions, 0 deletions The change is narrowly limited to icon observation, the usage store, and focused regression coverage.
Check status 2 of 9 reported checks failed A failing lint/build/test job and one macOS test shard need diagnosis before merge confidence is established.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Resolve the failing checks and add redacted, after-fix bundle-level evidence that mutating a token-account usage, error, or source label causes the displayed menu-bar icon to update in the same refresh cycle as the menu.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Resolve the failing checks and add redacted, after-fix bundle-level evidence that mutating a token-account usage, error, or source label causes the displayed menu-bar icon to update in the same refresh cycle as the menu.

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

Unclear for a live current-main run because the sandbox prevented repository execution; source-level evidence in the supplied diff gives a plausible path where snapshot-only changes previously bypassed the icon signature gate.

Is this the best way to solve the issue?

Yes, conditionally: making the real snapshot state part of both Observation dependencies and the redraw signature is the narrow maintainable repair, provided a real bundle run confirms the visible icon update and the failed checks are resolved.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P2: This is a bounded freshness defect in the menu-bar usage indicator, with no evidence of data loss, security impact, or runtime unavailability.
  • 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 stronger real behavior proof before merge: The PR reports a running process and unit tests, but does not show the after-fix menu-bar redraw following a real account snapshot update; add a redacted recording, visible diagnostic output, or runtime log from a freshly built bundle 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:

  • Repository inspection blocked: The required read-only command failed before producing repository output: bwrap could not create its loopback address. Consequently, the checkout state, current source, git history, maintainer notes, and CI logs were not independently inspected.
  • Proposed redraw dependency: The supplied PR diff adds the per-provider account snapshot projection to the icon observation signature, including usage windows, errors, and source labels; this addresses the earlier review concerns represented in the supplied discussion. (Sources/CodexBar/StatusItemController+IconObservation.swift:67, 408050e864e7)
  • Observation tracking change: The supplied PR diff makes the usage-store observation token read both account-snapshot collections, so collection replacement participates in Observation invalidation. (Sources/CodexBar/UsageStore.swift:59, 408050e864e7)
  • Proof is not behavior proof: The PR body shows a running release process and reports unit-test results, but it contains no before/after menu-bar output, diagnostic showing the redraw gate ran after a real snapshot update, recording, or redacted runtime log that connects an account update to an icon refresh. (408050e864e7)
  • Unresolved check state: The supplied GitHub context reports failures for lint-build-test and one macOS test shard at the current head; their logs were not available for local inspection. (408050e864e7)

Likely related people:

  • Yuxin-Qiao: The supplied PR history attributes all five commits implementing and refining this observation-signature change to this contributor; current-main feature ownership could not be traced because read-only checkout commands failed. (role: recent patch contributor; confidence: low; commits: a8952804b2b6, ce475ecc1b0a, 0b7e28036049; files: Sources/CodexBar/StatusItemController+IconObservation.swift, Sources/CodexBar/UsageStore.swift, Tests/CodexBarTests/StatusItemIconObservationSignatureTests.swift)

Rank-up moves

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

  • Post redacted bundle-level evidence that a changing account snapshot immediately updates the visible menu-bar indicator.
  • Resolve or explain the current lint-build-test and macOS test-shard failures, with the relevant successful rerun output.

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 (8 earlier review cycles)
  • reviewed 2026-07-30T05:09:53.299Z sha a895280 :: needs real behavior proof before merge. :: [P2] Add observation invalidation regression coverage
  • reviewed 2026-07-30T14:25:51.099Z sha ce475ec :: needs real behavior proof before merge. :: [P1] Feed account snapshots into the icon work signature
  • reviewed 2026-07-30T15:03:33.437Z sha 0b7e280 :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-30T15:27:47.903Z sha 0b7e280 :: needs real behavior proof before merge. :: [P1] Include mutable snapshot state in the work signature
  • reviewed 2026-07-31T04:35:06.769Z sha 1abe620 :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-31T05:22:59.045Z sha 1abe620 :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-31T14:40:07.194Z sha 408050e :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-31T15:00:56.038Z sha 408050e :: needs real behavior proof before merge. :: none

@Yuxin-Qiao

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 30, 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: ce475ecc1b

ℹ️ 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 +59 to +60
_ = self.accountSnapshots
_ = self.codexAccountSnapshots

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 Feed account snapshots into the icon work signature

Once the initial icon signature is stored, a refresh that changes only either per-account collection triggers this observation but still does no icon work: observeStoreIconChanges() recomputes storeIconObservationSignature() and returns because that signature reads store.snapshot(for:) and never accountSnapshots or codexAccountSnapshots. The status indicator therefore remains stale in the scenario these dependencies are intended to fix; include the relevant account state in the signature/render source (or publish it into snapshots) and test through the controller's signature gate rather than only asserting raw Observation invalidation.

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

Useful? React with 👍 / 👎.

@Yuxin-Qiao

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 30, 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: 0b7e280360

ℹ️ 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 +73 to +75
let accountPart = accountSnapshots.map { snap in
let label = snap.account.label
return "\(snap.account.id.uuidString):\(label)"

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 Include mutable account state in the signature

The new signature projection is fresh evidence that the previously reported gate remains incomplete: an ordinary refresh replaces an existing TokenAccountUsageSnapshot with updated snapshot, error, or sourceLabel values while preserving its ID and label, so Observation fires but this string remains unchanged and observeStoreIconChanges() returns without updating the status item. The Codex projection has the same problem because it retains only ID, email, and active state; include the mutable fields that are intended to trigger icon work and cover a same-account refresh rather than only insertion into an empty collection.

Useful? React with 👍 / 👎.

@Yuxin-Qiao

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Here is the technical summary and evidence for PR #2511:

Problem & Fix Summary

  • Observation Token Registration: In Sources/CodexBar/UsageStore.swift, iconObservationToken accesses accountSnapshots and codexAccountSnapshots so changes in account snapshots trigger observation update cycles.
  • Icon Observation Signature Invalidation: In Sources/CodexBar/StatusItemController+IconObservation.swift, providerStoreIconObservationSignature now includes accountSnapshotSignature(for: provider). This ensures that when accountSnapshots or codexAccountSnapshots mutate, the computed icon observation signature changes, invalidating stale menu bar icon renders and forcing an immediate icon redraw.

Test Coverage & Evidence

  • Added unit tests in Tests/CodexBarTests/StatusItemIconObservationSignatureTests.swift:
    1. test_statusItemIconObservationSignature_changesWhenAccountSnapshotsMutate(): Verifies signature changes when mutating accountSnapshots[.codex].
    2. test_statusItemIconObservationSignature_changesWhenCodexAccountSnapshotsMutate(): Verifies signature changes when mutating codexAccountSnapshots.
  • All tests pass 100% locally. make check confirms 0 SwiftFormat and 0 SwiftLint violations across 1,658 files.

@clawsweeper clawsweeper Bot added the merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. label Jul 30, 2026
…teipete#2511)

The accountSnapshotSignature only tracked stable identity fields, so
replacing an account snapshot's usage, error, or source label did not
invalidate the observation token. Extend the signature to include the
full snapshot state (primary/secondary/tertiary RateWindow details,
error, sourceLabel) so icon redraws are triggered when mutable data
changes.

Add regression tests for:
- Account snapshot usage replacement
- Account snapshot error replacement
- Codex account snapshot replacement

Co-authored-by: OpenAI Codex <codex@openai.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@Yuxin-Qiao

Copy link
Copy Markdown
Contributor Author

@clawsweeper The mutable snapshot state has been added to the work signature. Specifically:

  • now includes primary/secondary/tertiary RateWindow details (usedPercent, windowMinutes, resetsAt), error, and sourceLabel for each snapshot entry
  • Added regression tests for usage replacement, error replacement, and codex account snapshot replacement scenarios

Please re-review.

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Jul 31, 2026
Co-authored-by: Cursor <cursoragent@cursor.com>
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Jul 31, 2026
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: 🧂 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