Skip to content

perf(codex): preserve active usage when removing an inactive account - #24944

Closed
kazu-42 wants to merge 2 commits into
stablyai:mainfrom
kazu-42:kazu-42/codex-inactive-removal-performance
Closed

kazu-42 wants to merge 2 commits into
stablyai:mainfrom
kazu-42:kazu-42/codex-inactive-removal-performance

Conversation

@kazu-42

@kazu-42 kazu-42 commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

Deleting another saved Codex account should not temporarily clear the account you are currently using from the usage display. This skips the unnecessary runtime work and quota probe when the selected host account remains unchanged and its home is trusted.

What Changed

Compare the runtime selections before and after removal, including invalid selections that need pruning. Reuse the existing read-only managed-home ownership check. When removing a host account, every selection is unchanged, and the selected host home is trusted, skip runtime reconciliation and the forced quota refresh. Account removal, managed-home cleanup, and eviction of the removed account's cached usage still run.

Active removal, every WSL account removal, system-default host selection, stale WSL selections, and untrusted or unreadable homes keep the normal reconciliation and refresh path. A trusted host home does not establish ownership of a WSL home.

Why

refreshForCodexAccountChange() clears the current usage view before a forced probe. Running it for an inactive account causes avoidable flicker and provider work. A selection comparison alone is insufficient because an unchanged account ID can still point at an invalid home; the existing ownership check keeps that self-healing path available.

Linked Issue

Fixes #24942

This is the separate performance change requested in #11655 (comment).

Visual Proof

N/A — no controls, layout, or styling are added. Automated before/after evidence uses the real runtime-home service: the unchanged trusted-account case invoked a sync before this patch and now invokes neither sync nor quota refresh, while cleanup and cache eviction still occur. Native app footage of the quota display was not recorded.

Testing

Local macOS verification against main at 9a1bef48e4d7:

  • Two focused suites: 15 tests passed, including six performance regressions.
  • The unchanged-host and WSL shortcut regressions failed before their fixes and passed afterward.
  • Node typecheck passed.
  • Changed-code quality: zero new findings across four files.
  • Staged lint, React Doctor, formatting, and whitespace checks passed.

Tests cover inactive host removal with a trusted active home, active removal, a missing ownership marker, system-default selection, a stale WSL selection, and WSL removal with a trusted host home. All test processes use ORCA_BACKGROUND_LAUNCH=1. The package scripts' local binaries were invoked directly because the workstation's pnpm 12 launcher fails with Unknown system error -8.

  • Native app manual acceptance
  • Automated tests added

Native Windows/WSL, a paired SSH runtime, and packaging were not run locally.

AI Disclosure

Implemented with OpenAI Codex (GPT-6), with local automated verification.

Review

Draft: the durability work must land first. #25308 replaces #11655 with removal committed through the existing durable writer before runtime synchronization and credential cleanup. This branch still contains only the separate four-file performance change; it has not been adapted to the replacement yet.

The old integration branch, based on #11655 at 3fa11d53fa96, is retained for history. It uses the superseded Store-preview design and must not be applied to #25308. Its earlier test results do not validate integration with the replacement.

After #25308 merges, adapt the performance guard to the actual merged source and revalidate commit-before-delete, pending cleanup/retry, unchanged host usage, active removal, WSL removal and ownership uncertainty before marking this PR ready. The optimization must never skip the durable removal or cleanup record. Durability remains outside this PR's diff.

Agent skill upstream boundary

  • Not applicable; no upstream skill-installer source or assets are copied.

Notes

No new dependencies, wire fields, processes, or deletion rules. The read-only ownership check runs on the execution host that owns the account store. An inconclusive verdict uses the normal path; it never proves a home absent. The optimization can be reverted independently of account-removal durability.

Checklist

  • Small, focused change
  • Before/after behavior, mechanism, and rationale explained
  • Native app visual proof
  • Self-reviewed ownership, recovery, and performance conditions
  • Cross-platform and SSH ownership considered
  • Full CI and build matrix; focused local checks above passed

@nwparker

Copy link
Copy Markdown
Contributor

Closing as not planned. This only saves work during occasional deletion of an inactive account, with no quantified material production gain. The PR is also draft and explicitly awaits integration with its durability prerequisite. The identity guard is sensible, but we are not adding a standalone cache-policy optimization for an unmeasured rare operation.

@nwparker nwparker closed this Oct 11, 2026
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.

[Bug]: Removing an inactive Codex account refreshes the active account usage

2 participants