Skip to content

Fix long-running background load - #22

Merged
shinteni merged 1 commit into
mainfrom
codex/fix-background-load
Aug 6, 2026
Merged

Fix long-running background load#22
shinteni merged 1 commit into
mainfrom
codex/fix-background-load

Conversation

@shinteni

@shinteni shinteni commented Aug 6, 2026

Copy link
Copy Markdown
Owner

What changed

  • make the Codex live bridge clean up pipe readers and stale process callbacks
  • allow only one reconnect task and back off rapid proxy failures up to 30 seconds
  • cool down failed IPC sockets and cap unframed stdout buffering
  • select the actively updated Codex state database, including WAL activity
  • stop stale activity markers from keeping background polling at the fast cadence

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 VibelslandFreeCoreTests
  • swift test --skip-build --enable-swift-testing --no-parallel — 98 tests passed
  • swift build -c release --target VibelslandFreeCore
  • git diff --check

Full GUI build remains unavailable with the current CommandLineTools-only Swift toolchain because SwiftUIMacros is missing.

@shinteni
shinteni merged commit e6c8a0c into main Aug 6, 2026
1 check passed
@shinteni
shinteni deleted the codex/fix-background-load branch August 6, 2026 14:56

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

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 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 👍 / 👎.

Comment on lines +91 to +93
return candidates.max { lhs, rhs in
lhs.activityDate < rhs.activityDate
}?.url ?? rootURL

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 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 👍 / 👎.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant