perf: background credits and dashboard fetch for regular refreshes#1078
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 55945600c8
ℹ️ 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".
86277c2 to
27edc3b
Compare
|
Codex review: needs real behavior proof before merge. Latest ClawSweeper review: 2026-05-22 19:42 UTC / May 22, 2026, 3:42 PM ET. Workflow note: Future ClawSweeper reviews update this same comment in place. How this review workflow works
Summary Reproducibility: yes. from source inspection: current main awaits credits in the refresh task group and awaits OpenAI dashboard refresh inline. I did not run tests because this review is read-only, but the PR adds blocking-loader tests that exercise regular refresh returning before those loaders complete. PR rating Rank-up moves:
What the crustacean ranks mean
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. Real behavior proof Risk before merge
Maintainer options:
Next step before merge Security Review detailsBest possible solution: Merge the scoped background-refresh implementation after the PR body includes redacted real behavior proof that a slow regular refresh returns promptly and later updates the active account’s credits, dashboard, and widget state. Do we have a high-confidence way to reproduce the issue? Yes, from source inspection: current main awaits credits in the refresh task group and awaits OpenAI dashboard refresh inline. I did not run tests because this review is read-only, but the PR adds blocking-loader tests that exercise regular refresh returning before those loaders complete. Is this the best way to solve the issue? Likely yes: the branch keeps forced refreshes synchronous, adds account-key coalescing/cancellation guards, and persists widget snapshots after background completion. The remaining blocker is runtime proof, not a clear code defect. Label justifications:
Acceptance criteria:
What I checked:
Likely related people:
Codex review notes: model gpt-5.5, reasoning high; reviewed against de7c25ba2ef0. |
Move refreshCreditsIfNeeded() and refreshOpenAIDashboardIfNeeded() into background tasks for non-forced refreshes. Add Task?-based coalescing guard for credits refresh to prevent unbounded stacking. Forced refreshes (manual) still await inline. Split from steipete#1073.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 27edc3b56e
ℹ️ 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".
| return | ||
| } | ||
|
|
||
| self.openAIDashboardBackgroundRefreshTask?.cancel() |
There was a problem hiding this comment.
Cancel active dashboard fetch when replacing background refresh
scheduleOpenAIDashboardRefreshIfNeeded only cancels openAIDashboardBackgroundRefreshTask, but the actual scrape is executed by refreshOpenAIDashboardIfNeeded, which spawns/stores a separate openAIDashboardRefreshTask (Task { ... } + await task.value). When a new key is scheduled (for example during account switches), the old scrape can keep running concurrently even after this cancellation, defeating the coalescing intent and allowing stale-account web work to continue in parallel.
Useful? React with 👍 / 👎.
|
ClawSweeper PR egg 🎁 Pass real behavior proof to wake the egg and unlock a hatchable treat. Where did the egg go?
|
27edc3b to
a9a8d1d
Compare
Summary
Background regular Codex web refreshes so the UI never blocks on slow network operations during the polling cycle. Add credits-refresh coalescing so repeated poll cycles cannot stack concurrent credits fetches.
Split from #1073 per review feedback. Related: #678.
What changed
For non-forced refreshes,
refreshCreditsIfNeeded()andrefreshOpenAIDashboardIfNeeded()now run in background tasks instead of blocking the regular refresh path. Credits refresh now uses aTask<Void, Never>?guard so a second poll skips starting another credits fetch while one is already in flight.Why
The regular refresh cycle was awaiting Codex credits and OpenAI dashboard web work inline, which could block the main thread for seconds during slow network scrapes. It also allowed repeated poll cycles to stack concurrent credits fetches without any coalescing.
How to verify
swift test --filter CodexManagedOpenAIWebRefreshTests ./Scripts/lint.sh format ./Scripts/lint.sh lint make checkNotable decisions
Task?reference instead of a boolean so the in-flight state is derived from the task itself.Not included