Repository navigation
fix(account-switcher): support async utility-process connection proxy - #1710
Conversation
ilysenko
left a comment
There was a problem hiding this comment.
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.jsandearly-bootstrap-916-*.js), so line 24 throws and the test recordsprobeFailed. - 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()to0without awaiting it. - The added
connectionStatefield is not what the real proxy reads (it derives the state fromstate.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.
|
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. |
Summary
With
account-switcherenabled 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.41037main bundle (early-bootstrap-916-*.js),app-server-host.js, and live runtime verification:AppServerConnectioninto the NodeService utility process (app-server-host.js) and replaced the main-process handle with an RPC proxy whosegetPendingRequestCountis nowasync(async (...e) => (await this.#tL()).getPendingRequestCount(...e)).assertIdle()calledclient.getPendingRequestCount() !== 0withoutawait, comparing the returnedPromiseto0(alwaystrue).getPendingRequestCount()on a disconnecteddurableproxy invokesthis.open(), which would wake an initially disconnected cloud connection during idle checks.clearAuthTokenCache(). OnceassertIdle()passes, callingclient.clearAuthTokenCache()inrestore()andadd()throws aTypeError(afterauth.jsonhas already been written inrestore()). Insideapp-server-host.js,restart({ intent: "reconnect" })->stopProcess()and theaccount/login/completednotification handler already clear the auth token cache.Changes:
client.getPendingRequestCount()inassertIdle(), and skip disconnecteddurableclients (client.getConnectionState() === "disconnected") so lazy cloud connections remain untouched.client.clearAuthTokenCache()calls fromrestore()andadd(), and remove the obsoleteclearAuthTokenCachestubs fromtest.jsandnative-probe.js.add()to{ methods: ["account/login/completed"] }.test.jsfixtures to match the asyncgetPendingRequestCount()+getConnectionState()proxy contract and add a regression test ensuring a disconnecteddurablehost is not opened duringswitchoradd.Affected: only the opt-in
account-switcherfeature, 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_APPandCODEX_ACCOUNT_SWITCHER_NATIVE_APP, covered in CI).enabled: ["account-switcher"]) against verifiedchatgpt_26.1117.41037_amd64.deb:applied=2.git diff --check: clean.x86_64) against26.1117.41037: switched between two saved ChatGPT accounts (team->plus->team) without errors and confirmed account principal and usage limits refreshed for each account.CODEX_ACCOUNT_SWITCHER_NATIVE_APP); Add account is covered by unit tests and the bundled CLI test.Checklist