Repository navigation
Codex conversations continue under every account - #30957
brennanb2025 wants to merge 29 commits into
Conversation
…erts Each Orca Codex account home kept its own Codex database while sharing the conversation files, so a revert or edit under one account left the others resuming older history, and History listed one row per rollout file. - Account homes now link their conversation folders to one store per host and point Codex's sqlite_home at it, migrated once in the background. - History keys Codex rows by thread id, picks the segment Codex resumes, and stitches inherited history from the revert's base. - Native chat resumes by thread id and reads transcripts across segments.
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
Walkthrough
Priority: Merge Risk:
|
There was a problem hiding this comment.
Actionable comments posted: 5
🧹 Nitpick comments: 1
src/main/codex/codex-current-rollout-selection.ts: 1
24-24: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick winCache the effective SQLite home per Codex home.
resolveEffectiveCodexSqliteHome(home)runs a synchronousreadFileSyncofconfig.tomlon every call. TheCodexSelectionCacheonly caches the database read, not this config read.The cost is high because of how
codexSessionAliasBeatscalls this function. It callsisCodexCurrentRollouttwice per comparison.dedupeScannedSessionsruns on every Codex row, and it runs twice per scan (after the parse and again inmergeSessions). In anunlimitedscan with thousands of Codex rows, the scan makes thousands of blocking file reads plus TOML scans on the scanning thread, and every read returns the same result.Memoize the
home → sqliteHomemapping in the scan cache. One option is to key a second map byhome.♻️ Proposed fix
-export type CodexSelectionCache = Map<string, Map<string, string> | null> +export type CodexSelectionCache = { + sqliteHomes: Map<string, string> + selections: Map<string, Map<string, string> | null> +} @@ - const sqliteHome = resolveEffectiveCodexSqliteHome(home) - if (!cache) { + if (!cache) { + const sqliteHome = resolveEffectiveCodexSqliteHome(home) return readCodexThreadRolloutFileNames(sqliteHome, name.threadId)?.get(name.threadId) ?? null } - let selection = cache.get(sqliteHome) + let sqliteHome = cache.sqliteHomes.get(home) + if (sqliteHome === undefined) { + sqliteHome = resolveEffectiveCodexSqliteHome(home) + cache.sqliteHomes.set(home, sqliteHome) + } + let selection = cache.selections.get(sqliteHome) if (selection === undefined) { selection = readCodexThreadRolloutFileNames(sqliteHome) - cache.set(sqliteHome, selection) + cache.selections.set(sqliteHome, selection) }Then initialize the cache in
withCodexCurrentRolloutScanas{ sqliteHomes: new Map(), selections: new Map() }.
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
4c5574ab-ddb5-4369-a5f2-6725123d384f
📒 Files selected for processing: 43
src/main/ai-vault/codex-current-rollout.tssrc/main/ai-vault/codex-session-root-dedup.test.tssrc/main/ai-vault/codex-session-root-dedup.tssrc/main/ai-vault/session-parse-cache-database.tssrc/main/ai-vault/session-scanner-accumulator.tssrc/main/ai-vault/session-scanner-codex-parser.tssrc/main/ai-vault/session-scanner-codex-paths.tssrc/main/ai-vault/session-scanner-codex-revert.test.tssrc/main/ai-vault/session-scanner-inherited-history.tssrc/main/ai-vault/session-scanner-parse-cache.tssrc/main/ai-vault/session-scanner.tssrc/main/codex-accounts/codex-managed-home-lifecycle.tssrc/main/codex-accounts/runtime-home-service-managed-home.tssrc/main/codex-accounts/runtime-home-service-per-account-migration.test.tssrc/main/codex/codex-config-mirror.tssrc/main/codex/codex-conversation-store.tssrc/main/codex/codex-current-rollout-selection.tssrc/main/codex/codex-minimum-version.test.tssrc/main/codex/codex-pinned-rollout-proof.test.tssrc/main/codex/codex-pinned-rollout-proof.tssrc/main/codex/codex-rollout-file-name.tssrc/main/codex/codex-rollout-lineage.tssrc/main/codex/codex-rollout-session-meta.tssrc/main/codex/codex-session-index-heal-state.tssrc/main/codex/codex-session-resume-home.tssrc/main/codex/codex-shared-store-config.tssrc/main/codex/codex-shared-store-migration.test.tssrc/main/codex/codex-shared-store-migration.tssrc/main/codex/codex-sqlite-home.tssrc/main/codex/codex-state-db.tssrc/main/codex/codex-structured-launch-resolution.test.tssrc/main/codex/codex-structured-launch-resolution.tssrc/main/codex/codex-structured-session-adapter.test.tssrc/main/codex/codex-structured-session-state.tssrc/main/codex/codex-structured-thread-open.test.tssrc/main/codex/codex-structured-thread-open.tssrc/main/codex/codex-structured-visuals.test.tssrc/main/native-chat/codex-transcript-lineage.tssrc/main/native-chat/session-file-id-layouts.tssrc/main/native-chat/session-file-resolver.tssrc/main/native-chat/transcript-reader.tssrc/main/native-chat/transcript-tail-reader.tssrc/main/preflight/codex-workspace-relative-path.test.ts
💤 Files with no reviewable changes: 4
- src/main/codex/codex-pinned-rollout-proof.test.ts
- src/main/codex/codex-structured-session-state.ts
- src/main/codex/codex-structured-visuals.test.ts
- src/main/codex/codex-pinned-rollout-proof.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.
…launch, and count Orca-only config as synced
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Actionable comments posted: 9

Review info
-
Run configuration-
- Source mode: Auto
- Repository: Unavailable
- Branch: Unavailable
- File: No configuration file from this repository applied
- Commit: Unavailable
- Layers: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
1d4dd968-111f-47ee-b9fc-5b9f1459e605
Files selected for processing: 63-
config/flaky-test-pattern-baseline.txtsrc/main/ai-vault/session-scanner-codex-paths.tssrc/main/ai-vault/session-scanner-codex-title-index.tssrc/main/ai-vault/session-scanner.tssrc/main/codex-accounts/codex-config-mirror.test.tssrc/main/codex-accounts/codex-config-mirror.tssrc/main/codex-accounts/codex-managed-home-lifecycle.tssrc/main/codex-accounts/guest-codex-account-homes.tssrc/main/codex-accounts/managed-codex-auth-readiness.tssrc/main/codex-accounts/runtime-home-catalog-probe-prep.test.tssrc/main/codex-accounts/runtime-home-managed-auth-recovery.test.tssrc/main/codex-accounts/runtime-home-mirror-login-copy.test.tssrc/main/codex-accounts/runtime-home-per-account-homes.test.tssrc/main/codex-accounts/runtime-home-read-only-launch-resolution.test.tssrc/main/codex-accounts/runtime-home-real-home-lane-routing.test.tssrc/main/codex-accounts/runtime-home-service-home-routing.tssrc/main/codex-accounts/runtime-home-service-launch.tssrc/main/codex-accounts/runtime-home-service-managed-home.tssrc/main/codex-accounts/runtime-home-service-per-account-migration.test.tssrc/main/codex-accounts/runtime-home-service-state.tssrc/main/codex-accounts/runtime-home-system-resource-materialization.test.tssrc/main/codex-accounts/runtime-home-wsl-managed-accounts.test.tssrc/main/codex-accounts/service-account-selection-and-removal.test.tssrc/main/codex-accounts/service-managed-home-removal-retries.test.tssrc/main/codex/codex-account-home-discovery.tssrc/main/codex/codex-account-session-bridge.test.tssrc/main/codex/codex-account-session-bridge.tssrc/main/codex/codex-account-session-index-heal.test.tssrc/main/codex/codex-account-session-index-heal.tssrc/main/codex/codex-ai-vault-session-resume.test.tssrc/main/codex/codex-ai-vault-session-resume.tssrc/main/codex/codex-config-mirror.tssrc/main/codex/codex-launch-home.test.tssrc/main/codex/codex-launch-home.tssrc/main/codex/codex-legacy-session-resume.test.tssrc/main/codex/codex-legacy-session-resume.tssrc/main/codex/codex-pane-launch-account.tssrc/main/codex/codex-runtime-home-launch-preparation.tssrc/main/codex/codex-session-bridge.test.tssrc/main/codex/codex-session-bridge.tssrc/main/codex/codex-session-resume-home.tssrc/main/codex/codex-session-resume-launch-preparation.tssrc/main/codex/codex-session-source-home.tssrc/main/codex/codex-shared-store-config.tssrc/main/codex/codex-state-db.tssrc/main/codex/codex-structured-launch-resolution.tssrc/main/codex/config-toml-runtime-owned-sections.tssrc/main/ipc/pty/host-env/types.tssrc/main/native-chat/structured-conversation-key.tssrc/main/orcad/orcad-account-services.tssrc/main/orcad/orcad-codex-account-homes.test.tssrc/main/orcad/orcad-codex-account-homes.tssrc/main/runtime/construction/runtime-construction-dependencies.tssrc/main/runtime/structured-agent-account-home.tssrc/main/runtime/structured-agent-cli-writers.test.tssrc/main/runtime/structured-agent-runtime-metadata.tssrc/main/runtime/structured-agent-runtime-registration-types.tssrc/main/startup/codex-launch-preparation.tssrc/main/startup/main-process-account-services.tssrc/main/wsl/wsl-orcad-account-env.test.tssrc/main/wsl/wsl-orcad-account-env.tssrc/shared/account-runtime-capabilities.tssrc/shared/global-settings-types.ts
Files with no reviewable changes: 7-
- src/main/codex-accounts/runtime-home-system-resource-materialization.test.ts
- src/main/codex/codex-session-bridge.test.ts
- src/main/codex/codex-legacy-session-resume.test.ts
- src/main/codex/codex-account-session-bridge.test.ts
- src/main/codex/codex-account-session-index-heal.test.ts
- src/main/startup/main-process-account-services.ts
- src/main/codex/codex-account-session-index-heal.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.
-
| safeRemoveTree(join(managedHomePath, 'auth.json')) | ||
| safeRemoveTree(join(managedHomePath, 'auth.lock')) |
There was a problem hiding this comment.
Confirm credential deletion before completing account removal.
If an authentication file is locked, safeRemoveTree suppresses the unlink error. CodexAccountSelection.remove has already removed the account from settings, so auth.json can remain on disk without a reported cleanup failure. Retry transient failures and report a persistent failure instead of treating credential deletion as complete. (raw.githubusercontent.com)
There was a problem hiding this comment.
Confirmed: the current selective remover can swallow a private auth unlink failure. This remains open for restoring bounded retries and the existing cleanup warning boundary while preserving conversation stores. Successful hook-authority revocation does not establish successful credential deletion.
There was a problem hiding this comment.
@brennanb2025 Agreed. The finding remains open. Credential deletion needs bounded retries and a warning on persistent failure, while preserving conversation stores. Successful hook-authority revocation is not proof that credential deletion succeeded.
✏️ Learnings added
-
Learnt from: brennanb2025 Repo: stablyai/orca PR: 30957 File: src/main/codex-accounts/codex-managed-home-lifecycle.ts:112-113 Timestamp: 2026-10-29T15:40:04.836Z Learning: Within repository "stablyai/orca", only for files matching one of ["src/main/codex-accounts/codex-managed-home-lifecycle.ts"]: When reviewing host account removal in src/main/codex-accounts/codex-managed-home-lifecycle.ts, verify that selective credential cleanup uses bounded retries for transient deletion failures and reports persistent failures through the cleanup warning boundary while preserving conversation stores. Do not treat successful hook-authority revocation as proof of successful credential deletion.Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.
You are interacting with an AI system.
[Medium impact] The change reaches Codex account launches, resumes, and History on host systems. The PR is not ready to merge because unreadable accounts can still block healthy resumes and hook updates, or hide account restart prompts. Findings
SummaryThis PR separates Codex login folders from conversation storage so account changes can keep using the same conversation database and writer locks.
|
| if (verdict.kind === 'indeterminate') { | ||
| throw verdict.error |
There was a problem hiding this comment.
One account blocks other resumes
A permission or disk error reading one retired account’s ownership marker produces indeterminate. This throw then aborts discovery for every account, including healthy ones. getHostCodexHomePathsForSessionDiscovery propagates the error into resume preparation, and title reads also use this inventory.
Skip unreadable entries for the current inventory without treating them as deleted. Report their errors separately so unrelated conversations remain usable.
Knowledge Base Used: AI Vault sessions
There was a problem hiding this comment.
This is the same outstanding permission-inventory failure described in #30957 (comment). Healthy offline-target restoration is covered, while unreadable account/root isolation remains pending. Keeping this thread open with that shared repair.
| if (owned.kind === 'indeterminate') { | ||
| throw owned.error |
There was a problem hiding this comment.
Unrelated accounts hide restart prompts
If an earlier account’s files are unreadable, accountOwnsCodexHome throws inside .find() or .some() before reaching the healthy account that owns the launched pane. The outer catch returns null, so spawn publication forgets the pane’s account. Later account changes produce no restart prompt, even though the terminal still uses the previous account.
Continue checking other candidates when an unrelated account is unreadable, without guessing its ownership.
There was a problem hiding this comment.
Modern host births now publish the final prepared account and actual home directly with the returned incarnation; both commit paths and qualified disk restart are covered by the targeted tests. The legacy candidate-search ownership-I/O case remains open, so this thread is not fully resolved by the modern publication change.
There was a problem hiding this comment.
Agreed. The modern publication changes cover the paths you listed, but they don’t address the legacy candidate-search case: an ownership I/O error for one account can still abort the search before the owning account is reached. I’ll keep this finding open; the legacy search needs to continue past unreadable unrelated candidates without guessing ownership.
| resolveTrustedHome: (account) => { | ||
| const resolved = this.resolveSelfContainedManagedHome(account) | ||
| if (resolved.kind === 'indeterminate') { | ||
| throw new ManagedCodexHomeTemporarilyUnavailableError() | ||
| } | ||
| return resolved.kind === 'owned' ? resolved.homePath : null |
There was a problem hiding this comment.
Unreadable accounts block hook updates
When one account folder is unreadable, this callback throws while collectRetainedCodexHookTargets is still building the home list. The per-home error handler has not started yet, so startup and later retries abandon all healthy homes too. Retained terminals miss hook repairs, and opting out can leave their hooks installed.
Catch inventory errors per account or family, keep the healthy targets, and retry the failed entries separately.
Knowledge Base Used: Agent integrations and hooks
There was a problem hiding this comment.
Confirmed from the collector source: an unreadable account can abort target collection before the per-target handler, preventing healthy retained-family repair and opt-out. The existing hook-file rename-failure fixture starts after collection and does not cover this input. The collector case remains unrepaired and this thread stays open.
Tracked in STA-11187.
Keep saved conversation identity independent of storage discovery, isolate retained-home observations, and settle healthy hook work during bounded retries. Preserve native stores while revoking account-private files. Tracked in STA-11187.
Use fixture-only file auth so the healthy adoption proof reaches prepared-store recognition before real create and send settlement. Tracked in STA-11187.
|
Closing: #42614 ("Keep one copy of Codex history shared by every account", merged 2026-11-16) replaces this. Each Codex session is now kept once and shared by every account. |
ELI5
Continuing a Codex conversation under another account could leave the first account with an older history after Undo. Each account had its own database selecting the conversation's current file. This change keeps each conversation in its original folder and lets every selected account use that folder's same database and writer locks.
What Changed
New conversations use the configured Codex session folder, or the system Codex home by default. Existing conversations stay where they were written. Terminal launches, native chats, restarts, Session History resumes and headless launches resolve the login and conversation folder through one resolver. An account gets a small launch folder containing its login links and directory links into that conversation folder; changing accounts changes the login without copying the conversation or its database.
The launch folder is created atomically and keyed by the canonical conversation-folder path. Its config points SQLite at that folder's effective database location and uses file credentials. Login, config, title indexes and caches retain their existing ownership rules. Removing an account removes its credentials while keeping its conversations and the directory aliases that Codex's database rows still reference.
The old per-rollout bridges and their native index-healing work are retired. This removes synchronous main-process filesystem work on every launch that was measured at roughly three seconds in a user profile. The in-place migration, migration journal and History lineage changes previously on this branch have been removed.
Why
Account credentials stay separate from conversation storage. Keeping one database and lock directory per conversation removes the account-switch Undo bug without changing a running terminal's home, moving saved conversations, replaying metadata or copying mutable rollout files.
Linked Issue
Tracked in STA-11187.
Visual Proof
N/A — no interface layout changes. The lane owner will attach the required running-app evidence for account switching, Undo and legacy resumes before readiness.
Testing
Review
The History scanner changes for revert lineage and one row per conversation are saved for the later History PR in this lane. The companion chat-account change makes already-open chats follow the current selection at their next turn; this PR supplies the shared resolver and storage behavior it needs.
Agent skill upstream boundary
Notes
codex resumeon the other folder while the chat is open can still open a pre-upgrade bridge alias under another lock folder. This shape exists today. Outside the scoped System default without a file login case below, Orca creates no new cross-folder rollout aliases, never starts that second writer itself, and compares thread ids across stores in its chat-versus-terminal admission. The old-shell case ends when terminals opened before the upgrade close.auth.jsonfile, a new conversation starts in~/.codex, even with a custom session source folder. When the System default Codex login isn’t a file (keychain, API-key provider, or signed out), continuing a conversation from another folder links it into~/.codexexactly as Orca’s terminal restart already does; its history can diverge between the two folders as on main. The current refusal must be replaced with that terminal mechanism, awaiting its no-overwrite link/copy before launch. This is the only exception to the named-store and no-new-rollout-alias rules; a System default file login and managed accounts keep them.Checklist