Skip to content

fix(account-switcher): support async utility-process connection proxy - #1710

Merged
ilysenko merged 3 commits into
ilysenko:mainfrom
Adiker:cursor/fix-account-switcher-utility-proxy
Nov 23, 2026
Merged

ilysenko merged 3 commits into
ilysenko:mainfrom
Adiker:cursor/fix-account-switcher-utility-proxy

Conversation

@Adiker

@Adiker Adiker commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Summary

With account-switcher enabled on official Linux 26.1117.41037, both Switch account and Add account fail immediately with "Wait for pending requests and active tasks to finish before switching accounts.", even when the app is completely idle.

Root causes, confirmed from the signed 26.1117.41037 main bundle (early-bootstrap-916-*.js), app-server-host.js, and live runtime verification:

  • Upstream moved AppServerConnection into the NodeService utility process (app-server-host.js) and replaced the main-process handle with an RPC proxy whose getPendingRequestCount is now async (async (...e) => (await this.#tL()).getPendingRequestCount(...e)). assertIdle() called client.getPendingRequestCount() !== 0 without await, comparing the returned Promise to 0 (always true).
  • Calling getPendingRequestCount() on a disconnected durable proxy invokes this.open(), which would wake an initially disconnected cloud connection during idle checks.
  • The main-process proxy no longer exposes clearAuthTokenCache(). Once assertIdle() passes, calling client.clearAuthTokenCache() in restore() and add() throws a TypeError (after auth.json has already been written in restore()). Inside app-server-host.js, restart({ intent: "reconnect" }) -> stopProcess() and the account/login/completed notification handler already clear the auth token cache.

Changes:

  • Await client.getPendingRequestCount() in assertIdle(), and skip disconnected durable clients (client.getConnectionState() === "disconnected") so lazy cloud connections remain untouched.
  • Remove the obsolete client.clearAuthTokenCache() calls from restore() and add(), and remove the obsolete clearAuthTokenCache stubs from test.js and native-probe.js.
  • Scope the login notification subscription in add() to { methods: ["account/login/completed"] }.
  • Update test.js fixtures to match the async getPendingRequestCount() + getConnectionState() proxy contract and add a regression test ensuring a disconnected durable host is not opened during switch or add.

Affected: only the opt-in account-switcher feature, across all package formats and architectures. No change to the launcher, packaging, core patch registry, or upstream trust path.

Validation

  • CODEX_ACCOUNT_SWITCHER_CLI=/opt/codex-desktop/resources/codex node --test linux-features/account-switcher/test.js scripts/lib/linux-features.test.js: 74 pass, 0 fail (2 skipped: CODEX_SIGNED_EXTRACTED_APP and CODEX_ACCOUNT_SWITCHER_NATIVE_APP, covered in CI).
  • Feature-alone official-bundle build (enabled: ["account-switcher"]) against verified chatgpt_26.1117.41037_amd64.deb: applied=2.
  • git diff --check: clean.
  • Manual end-to-end verification on EndeavourOS (pacman, KDE/Wayland, x86_64) against 26.1117.41037: switched between two saved ChatGPT accounts (team -> plus -> team) without errors and confirmed account principal and usage limits refreshed for each account.
  • Not tested manually: Add account OAuth flow in the live desktop app and the native Owl probe (CODEX_ACCOUNT_SWITCHER_NATIVE_APP); Add account is covered by unit tests and the bundled CLI test.

Checklist

  • This pull request is ready for review and is no longer a draft.
  • I followed CONTRIBUTING.md, kept the change focused, edited source files rather than generated output, and removed unrelated changes.
  • If this fixes upstream drift, it targets only the latest signed stable OpenAI Linux package and removes obsolete fallback code and tests.
  • I added or updated relevant tests, ran the validation listed above, and confirmed that required CI checks pass.
  • I reviewed the final diff with my coding agent using maximum reasoning effort, addressed all findings, and reran the relevant tests.

@Adiker
Adiker marked this pull request as ready for review November 22, 2026 16:24

@ilysenko ilysenko left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for tracking this down — the runtime fix matches the signed 26.1117.41037 bundle: the main-process proxy exposes getConnectionState() and an async getPendingRequestCount(), no longer exposes clearAuthTokenCache(), and honors the { methods } subscription filter. One thing needs to change before merge:

linux-features/account-switcher/native-probe.js still targets the retired in-process connection. Per CONTRIBUTING.md, a drift fix must also remove or update obsolete tests in the same change. Against the current official bundle the probe cannot pass:

  • The three source anchors now match two modules (app-server-host.js and early-bootstrap-916-*.js), so line 24 throws and the test records probeFailed.
  • The new proxy defines its methods as instance fields, not prototype methods, so the class filter finds nothing, and Object.create(prototype) cannot reproduce its private state.
  • Line 83 still compares lazy.getPendingRequestCount() to 0 without awaiting it.
  • The added connectionState field is not what the real proxy reads (it derives the state from state.snapshot).

This probe is not run in CI (CODEX_ACCOUNT_SWITCHER_NATIVE_APP is never set), so the green checks do not cover it. Please either rewrite the probe against the current proxy contract (async pending count, getConnectionState(), no clearAuthTokenCache) and confirm it passes against 26.1117.41037, or remove the probe together with its test in test.js and the README section that describes it.

Before requesting re-review, please run the complete updated base-to-head diff through your own code-review model, fix every blocker it reports, rerun it, and repeat until it reports no remaining blockers.

@Adiker

Adiker commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the detailed review and for identifying the stale probe. I chose the removal option: the obsolete native probe, its test, and its README instructions are removed in 8fc6578.

Validation: the account-switcher test suite passed (34 passed; the two optional CLI and signed-bundle contract tests were skipped), and a build with only account-switcher enabled succeeded against the verified signed 26.1117.41037 amd64 package, applying both feature patches. I also had the complete base-to-head diff independently reviewed; no blockers were reported.

Thanks again for catching the gap in CI coverage.

@ilysenko ilysenko left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks — removing the stale probe, its test and the README section resolves the blocker. The runtime fix matches the signed 26.1117.41037 proxy contract, and CI is green on 8fc6578. Approving.

@ilysenko
ilysenko merged commit 1b05b0f into ilysenko:main Nov 23, 2026
14 checks passed
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.

2 participants