Fix long-running background load - #22
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 13f21343fa
ℹ️ 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".
| if cachedSocketURL?.path == failedPath { | ||
| cachedSocketURL = nil | ||
| } | ||
| failedSocketRetryAfter[failedPath] = Date().addingTimeInterval(CodexReconnectPolicy.maximumDelay) |
There was a problem hiding this comment.
Allow retries to reuse the current socket
When the proxy exits while the only valid Codex socket is still at the same path, this quarantines that path for the full 30 seconds; existingSocketCandidates then filters it out, so the scheduled 2/4/8-second reconnect attempts and retryNow() just report “missing socket” until the quarantine expires. This makes the manual diagnostic retry and the early backoff intervals ineffective after transient failures on a stable socket; clear/bypass the quarantine for explicit retries or align it with the actual scheduled delay.
Useful? React with 👍 / 👎.
| return candidates.max { lhs, rhs in | ||
| lhs.activityDate < rhs.activityDate | ||
| }?.url ?? rootURL |
There was a problem hiding this comment.
Re-resolve the active Codex database while polling
When both state databases exist and the root DB happens to be newer at app startup, this returns the root path; CodexDesktopStateReader captures that URL once in its initializer, so if Codex Desktop later writes to .codex/sqlite/state_5.sqlite or its WAL during the same app run, the background refresh keeps polling the stale root DB until restart. Since this heuristic is based on mutable activity timestamps, the reader needs to re-evaluate the active path during refresh (or otherwise switch when the sqlite/WAL becomes newer).
Useful? React with 👍 / 👎.
What changed
Why
Long-running background sessions could enter a rapid app-server reconnect loop. EOF callbacks, stale socket reuse, and stale database polling compounded CPU and I/O load over time, which could also slow WindowServer-dependent actions such as screenshots.
Validation
swift build --target VibelslandFreeCoreTestsswift test --skip-build --enable-swift-testing --no-parallel— 98 tests passedswift build -c release --target VibelslandFreeCoregit diff --checkFull GUI build remains unavailable with the current CommandLineTools-only Swift toolchain because
SwiftUIMacrosis missing.