Skip to content

fix(codex): index a new WSL account home before bridging history into it - #23843

Closed
brennanb2025 wants to merge 3 commits into
mainfrom
brennanb2025/fu-wsl-account-bridge
Closed

brennanb2025 wants to merge 3 commits into
mainfrom
brennanb2025/fu-wsl-account-bridge

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 6 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​480 $\color{#cf222e}{\Huge{\mathbf{−}}}$​11 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​469
Prod 5 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​326 $\color{#cf222e}{\Huge{\mathbf{−}}}$​44 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​282

What this fixes: On Windows, adding a new Codex account for a WSL project, when you already have a large Codex history in WSL, leaves Codex unable to start in that project for many minutes. This is the WSL twin of the bug #22971 fixed for non-WSL accounts. #22971 changed only the non-WSL history bridge; WSL accounts use a separate bridge that still linked history in the old order. Found in the follow-up review of #22971 (issue #20669).

Who is affected: Windows users who add or switch to an Orca-managed Codex account for a WSL project and have a large history in the distro's Codex folder. The more history, the longer the outage.

Not affected: macOS, Linux, non-WSL Windows accounts (already fixed by #22971), SSH, the default WSL Codex setup with no Orca-managed account, and small histories (40 conversations indexed instantly before and after).

ELI5

Codex keeps an index of your past conversations. When Orca creates a new account for WSL, it copies links to all your old conversations into that account's folder so /resume can still find them. It did that before Codex had ever opened the folder, so Codex's first start had to index everything at once. Every other Codex that tried to start meanwhile gave up after 30 seconds. Now Orca lets Codex open the empty folder first, then adds the history, then has Codex index it quietly in the background, newest first. That is the same order #22971 uses outside WSL.

What Changed

Before (measured on a Windows machine with WSL Ubuntu 24.04, real Codex 0.151, 16,000 synthetic 1 MB conversations, current main):

  • All 16,000 conversations were linked into the new account's folder before any Codex opened it.
  • Opening a Codex chat in the WSL project showed "Codex could not start because its session-history index is still incomplete…" (screenshot below). The chat's own Codex claimed the indexing, died at 1,471 of 16,000, and left the index marked as running with no Codex alive.
  • Retrying 5.5 minutes later failed the same way.
  • Codex holds that stranded claim for 15 minutes. The first retry after the claim expired, at about 21 minutes, re-indexed everything, so Codex could start only about 22 minutes after the account was added.

After (same machine, same history, this branch):

  • The account's Codex index is created, complete and empty, before anything is linked (index at 02:35:41; linking starts right after).
  • The Codex chat opens straight away and runs a turn while background indexing is still working through the history.
  • Codex's database-only list, which is what /resume loads first, already shows 79 conversations for the project, newest first, after about 2,000 of 16,000 were indexed. Indexing continues in the background.
  • All 16,000 were indexed about 19 minutes after the account was added, and every pending marker was gone. The run included a quit and relaunch of Orca part-way through.
    • At the quit, 6,900 markers were left, and no Codex process stayed alive on the account.
    • After the relaunch, the first Codex launch resumed indexing from there.
  • Small history (40 conversations): linked and indexed within a few seconds, the same as before.

Mechanism:

  1. Before linking, the WSL bridge starts the distro's own codex app-server on the account's folder once per Orca run, using the same short, read-only invocation as the other background Codex processes, run through wsl.exe with the helpers docs/reference/wsl-command-execution.md requires.
  2. The existing in-distro link script now also writes an empty marker, <account home>/.orca-index-pending/<rollout name>, for each conversation it newly links. It prints the markers that are still pending, newest first, before its summary line.
  3. Orca feeds those threads to fix(codex): index a new account home before bridging history into it #22971's indexing path: the shared readCodexThreadsForIndexHeal loop via healPendingCodexAccountThreads, with the same batch size, newest-first order and per-home memory of failed reads.
    • Each batch runs through the distro's Codex.
    • After each batch, the markers of threads Codex indexed (or that no longer exist) are deleted.
    • A failed read keeps its marker and is retried after Orca restarts.
  4. Quit stops the WSL bridge the same way it stops the native one.

Deliberate differences from the non-WSL path:

  • The startup check in step 1 runs once per account per Orca run even when there is no history to link. The non-WSL path reads SQLite to skip it, and Windows can't do that here.
  • While a large first indexing pass is running, the next Codex launch joins it rather than starting another. So conversations created during those minutes are linked on the first launch after it finishes. The non-WSL bridge from fix(codex): index a new account home before bridging history into it #22971 behaves the same way.

Why markers instead of the native diff: #22971 decides what to index by reading Codex's SQLite database directly. Windows cannot do that for a WSL folder. I measured three ways:

  • A normal read-only open over \\wsl.localhost fails with "database is locked", even with no Codex running. The repo already documents this for other SQLite readers.
  • The no-locking mode (win32-none) fails too.
  • An immutable open succeeds but returns stale data, because Codex leaves recent writes in its -wal file. It showed running / 35 rows while the truth inside the distro was complete / 40.

The distro may not have python3, node or sqlite3, so there is nothing reliable to read the database inside WSL either. A marker per linked conversation is the smallest durable record of "Codex still has to index this". It is created in the same step as the link, and it goes away when indexing settles it or when the account folder is deleted.

The legacy WSL auth migration reuses the same script body. It never turns markers on, so its behavior and its 16 KB output limit are unchanged (a test pins that).

Why

  • Same fix, same machinery: the root cause is the same ordering bug fix(codex): index a new account home before bridging history into it #22971 removed, so this applies the same ordering and reuses its indexing loop rather than building a parallel one. The only WSL-specific parts are how Orca learns "the index is complete" (Codex's own startup gate) and "what is left to index" (the markers), because the native way (reading SQLite) is impossible from Windows.
  • Rejected alternatives:
    • Ordering only, no indexing: this fixes the stall, but Codex's /resume hides unindexed conversations once a folder has any indexed one, so linked history would vanish.
    • Asking Codex to list every indexed thread (thread/list): that listing filters by provider, source kind and archive state by default, which varies between Codex versions. For example, the test machine's WSL config uses a custom provider, and the default listing returned 0 of 40 threads.
    • A per-home log of indexed threads: it would store a second copy of Codex's own state, with nothing to check it against.
  • One side benefit of step 1: an older WSL account whose index is stuck running from before this fix gets repaired by that same background Codex once Codex's 15-minute claim expires, because a Codex that wins the claim finishes the indexing. I did not run that case end to end.

Linked Issue

Refs #20669 (fixed for non-WSL accounts by #22971; this is the WSL path it did not cover).

Visual Proof

Before (main, 45 s after opening a Codex chat on a new WSL account with 16,000 conversations):

b-main-01-codex-after-45s.png

After (this branch, same setup: the chat is open and running a turn while history indexes in the background):

b-pr-03-after-send.png

Testing

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

Windows + WSL (Windows high spec box, Ubuntu 24.04, Codex 0.151):

  • Electron dev builds of main and of this branch, each with an isolated profile and Windows home, launched in the background.
  • One synthetic managed WSL account per run with a made-up token. History came from a synthetic folder through the per-distro history-source setting, so the real WSL ~/.codex was never a source.
  • A sampler inside the distro recorded, every 2 s, the index status and row count, the number of linked files, and the live Codex processes on that account folder.
  • The real Windows and WSL ~/.codex / ~/.claude config files were byte-identical before and after every run.

Unit tests:

  • wsl-codex-session-bridge-index.test.ts, new, covers the pipeline:
    • the index is completed before anything is linked;
    • nothing is linked when Codex can't start;
    • the startup check runs once per home;
    • pending markers are indexed newest first through the distro's Codex, and their markers cleared afterwards;
    • a failed read keeps its marker;
    • a partial link failure still indexes what was linked;
    • a clipped marker list is skipped;
    • nothing runs after quit starts.
  • wsl-codex-session-bridge-script.test.ts, new, runs the real script in bash:
    • markers are written only for newly linked conversation files, and listed newest first;
    • leftover markers are reported when the history source is gone;
    • the marker of a conversation that failed to link is dropped;
    • output is unchanged when markers are off.
  • The shared indexing loop has a new per-batch callback; there are tests for it and for the WSL Codex invocation.
  • Affected suites: 139/139 pass. tc:node, oxlint and check:code-quality:changed are clean.

Platforms: Windows + WSL (manual, above). The macOS / Linux unit tests exercise the bash script directly. SSH is not affected: account history bridging is local-only.

Review

Agent skill upstream boundary

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

  • Cross-platform: WSL-only code path, gated as before (startWslSessionBridgeForLaunch runs only on Windows). The Codex commands follow docs/reference/wsl-command-execution.md.
  • Performance:
    • Background only; nothing blocks a launch.
    • A normal launch still starts one wsl.exe for the link script. The startup check adds one short Codex start per account per Orca run.
    • Indexing a large history costs the same Codex work as a single first index, just spread over batches of 50 (about 320 short Codex starts for 16,000 conversations).
    • No SQLite or file access over \\wsl.localhost on Orca's main thread was added.
  • Backwards compatibility: accounts from before this change keep their existing links. Only conversations linked from now on get markers; older hidden history in those accounts is not re-indexed by this PR.
  • Not verified: a real second Codex login opening the real /resume picker. I used Codex's database-only list, which is what that picker loads first.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred): tc:node, oxlint, check:code-quality:changed and the affected suites pass locally; CI typecheck, tests, static analysis and both packages pass

@brennanb2025

brennanb2025 commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor Author

Status: ready for review, not merged

What it fixes: a new Orca-managed Codex account for a WSL project can't start Codex for many minutes when the distro has a large Codex history. This is the WSL path #22971 didn't cover.

Validated on a Windows machine with WSL Ubuntu 24.04 and the distro's real Codex 0.151:

  • Before (main, 16,000 conversations): "Codex could not start because its session-history index is still incomplete…" for about 22 minutes. A retry at 5.5 minutes failed the same way.
  • After (this branch, same history):
    • The account's index is complete before anything is linked.
    • The Codex chat opens immediately.
    • The /resume database list shows project history, newest first, within about 2 minutes, and all 16,000 conversations are indexed in about 19 minutes.
    • Quitting Orca mid-way and relaunching resumes indexing where it left off.
  • Final head 6274b4564d8 (2,000 conversations plus one oddly named file): everything indexed, no leftover pending markers, and no errors.
  • Small history (40 conversations): unchanged. It is indexed within seconds, as before.
  • Real config safety: the machine's real Windows and WSL ~/.codex / ~/.claude config files were byte-identical before and after.

Review:

  • Three review loops:
    1. Loop 1 fixed a marker-count bug, where one odd file name disabled indexing for an account.
    2. Loop 2 was clean.
    3. Loop 3 was clean, after a readiness-check fix so a marker with no thread id is cleared instead of lingering.
  • The readiness checklist ran at the start and at the end: no P0 or P1. The accepted P2s are disclosed in the body under "Deliberate differences from the non-WSL path".
  • tc:node, oxlint and the changed-lines quality gate are clean, and the affected unit suites pass.

CI: everything passes at 6274b4564d8: typecheck, all 5 test shards, relay integration, static analysis, both packages, and the Codex index-heal contract.

Not verified:

  • a real second Codex login and the real /resume picker (I used the database-only list that picker loads first);
  • repair of an account from before this fix whose index is already stuck.

Out of scope, noted for follow-up:

  • The existing WSL "background recovery" for a stuck index can't read the WSL database from Windows, so it never helps.
  • The legacy WSL auth migration also links history without this ordering.

@brennanb2025
brennanb2025 marked this pull request as ready for review September 29, 2026 10:15
@greptile-apps

greptile-apps Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 4/5

[High risk] Adds indexing logic to WSL session bridge startup.

The PR does not appear safe to merge while valid WSL history can lose its pending index marker.

Findings

  1. P1 Valid history loses its marker ▶

Summary

The PR opens and completes a managed WSL Codex home’s index before linking history, then uses pending markers to index linked conversations newest first. No new finding was identified since the previous review; the earlier finding remains outstanding.

Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[Open managed WSL Codex home] --> B[Complete startup index]
  B --> C[Link history and write pending markers]
  C --> D[Read pending threads newest first]
  D --> E[Clear settled markers]
Loading

Reviews (2) · Last reviewed commit: "fix(codex): clear a WSL index marker who..."

Comment on lines +142 to +148
const rollout = parseCodexRolloutThreadId(rolloutName)
if (rollout) {
pendingThreads.set(rollout.threadId, rollout.rolloutStamp)
markerByThreadId.set(rollout.threadId, rolloutName)
} else {
markersWithoutThread.push(rolloutName)
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Valid history loses its marker

If a WSL history source contains a dated rollout-<uuid>.jsonl conversation, the link script creates a pending marker for it, but this parser accepts only rollout-<timestamp>-<uuid>.jsonl. The bridge deletes the marker without asking Codex to index the thread. That conversation remains absent from the indexed /resume list, and later launches have no marker to retry.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ℹ️ No critical issues — one design question and a couple of nits.

Reviewed changes

  • The missing WSL twin of #22971. bridgeAndIndexWslCodexSessions now opens the managed home's Codex state DB first (createCodexAccountStateDb with a 15-minute timeout, once per home per Orca run, through a new WSL buildWslHealInvocation), skips linking if it cannot, then links history, then drives thread/read over the newly linked rollouts via the shared heal loop.
  • Per-rollout marker files record pending index work. The bridge shell script writes <account home>/.orca-index-pending/<rollout name> for each newly linked rollout, drops it when the link failed, and prints the pending names (newest first) before a summary that counts them. The host parses them, indexes them, and deletes markers as each thread settles.
  • Shared the heal loop and added a per-batch hook. healCodexAccountSessionIndex was split so healPendingCodexAccountThreads can be reused by the WSL path; readCodexThreadsForIndexHeal gained afterBatch (runs on success and in the catch path; a failure is logged, not fatal).
  • Partial link failures no longer strand the marker list. syncWslCodexSessionsIntoManagedHome parses the summary even on a non-zero exit and reports bridgeFailed, so one unlinkable file cannot suppress indexing of everything else.

ℹ️ Pre-existing hidden history in already-created WSL accounts stays hidden

The fix only creates markers for rollouts it links from now on, so an account that already has bridged-but-unindexed history from before this change never gets that history indexed — it stays hidden from /resume. The PR body scopes this out, so this is a check that the call is deliberate rather than an objection.

Technical details
# Existing linked-but-unindexed WSL history is never recovered

## Affected sites
- `src/main/codex/wsl-codex-session-bridge.ts:141` — `pendingThreads` is built only from `summary.pendingRollouts`, i.e. markers written on this launch.
- `src/main/codex/wsl-codex-session-bridge-script.ts:96` — a marker is written only when the loop creates a new `target_file`; an already-linked rollout hits the `continue` at line 61.
- `src/main/codex/wsl-codex-session-bridge.ts:122` — the startup probe only brings the state DB to `complete`; it does not index rollouts linked after Codex's one-shot backfill.

## Required outcome
Decide whether the population the bug actually hit (accounts whose first index never completed) should get a one-time marker sweep of `<managed home>/sessions` on the first run after upgrade, or whether leaving that history hidden is acceptable. The PR body says it is out of scope; confirm that is intended.

## Suggested approach (optional)
On a home that has no markers yet, have the bridge script walk `managed_sessions_root` for `rollout-*.jsonl` without a marker and create one, then let the existing `thread/read` heal settle or drop them. Cost is bounded by the same indexing pass this PR already runs; already-indexed threads resolve as `healed` cheaply.

## Open questions for the human (optional)
- Is the unrecovered old-history population small enough to leave, or is it the common case for the users who reported #20669?

ℹ️ Nitpicks

  • src/main/codex/wsl-codex-session-bridge.test.ts:121 — the test name "throws on a non-zero exit so the background wrapper logs and swallows it" no longer matches the contract: a non-zero exit with a parsed summary now returns bridgeFailed: true and throws only later in bridgeAndIndexWslCodexSessions, while an unparseable summary throws here. Consider renaming so the next reader does not assume non-zero always throws at this call.

Pullfrog  | Fix it ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@coderabbitai

coderabbitai Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

📝 Walkthrough

Walkthrough

The WSL session bridge now waits for a managed Codex home index before syncing sessions. The script records and reports pending rollout markers. The bridge parses those markers, heals matching threads, and clears markers for outcomes other than failed reads. The change also adds configurable healing timeouts, batch callbacks, shutdown checks, and tests for the marker and healing flows.

Priority: ➖ Normal

Merge Risk: 🔵 Low · up to 57390

A ledger write failure may cause a thread to be skipped on future recovery; fix the ordering before merge.

Security Architecture Review

Security architecture risk: 🔵 Low · up to 57390

The change remains scoped to local WSL account-history processing. The examined paths preserve account and distro targeting and retain unfinished work for recovery. No introduced security weakness was established, but incomplete exposure and comparison coverage prevents a minimal-risk assessment.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • observed — The inspected operations bridge the selected distro's source history into a managed account home, initialize and heal that home's index, and mutate its pending-marker directory. This bounds the demonstrated filesystem scope, but does not establish complete cross-account exposure coverage.

Trust Boundaries and Controls

  • observed — UNC home paths must match the selected distro; otherwise only absolute Linux paths are accepted. Shell assignments use the existing quoting helper. Marker cleanup passes names as positional arguments to rm -f -- after changing into the pending-marker directory, rather than interpolating names into shell code.

Resilience and Maintainability Implications

  • observed — Cleanup excludes failed reads. Unprocessed reads are not reported as settled, and marker-cleanup failures are logged without interrupting later batches. A parsed partial-link failure still allows pending work to be healed before the bridge reports failure, containing one file's failure rather than stranding the entire batch.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 39.13% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 23 functions across 11 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: indexing a new WSL account home before bridging Codex history.
Description check ✅ Passed The description is complete and aligned with the repository template. It explains the problem, user impact, implementation, rationale, alternatives, linked issue, visual proof, testing, platform scope…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

The WSL history bridge hardlinked every conversation into a new managed
account home before Codex had opened it, so Codex's first open had to index
all of it and every other Codex on that home gave up after 30s. Apply the
native ordering from #22971 inside the distro: Codex brings the home's index
to complete first, history is linked after, and the shared thread/read loop
indexes it newest first. Windows cannot read the guest's Codex sqlite over
9p, so a marker per linked rollout records the pending indexing work and
dies once thread/read settles it.
…not a Codex thread

The launch bridge counted only Codex-shaped marker names against the script's
pendingFiles total, so a single rollout-*.jsonl without a thread id made the
count mismatch on every launch and skipped the home's whole index heal. Count
every listed marker for the completeness check and index the parseable ones.
…read id

thread/read can never settle such a marker, so it was listed on every launch
with nothing to remove it.
@brennanb2025
brennanb2025 force-pushed the brennanb2025/fu-wsl-account-bridge branch from 6274b45 to 57390a5 Compare September 30, 2026 01:28

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: ef65e5db-9bd5-4a23-85ea-e3dfd5dd82d8

📥 Commits

Reviewing files that changed from the base of the PR and between 6274b45 and 57390a5.

📒 Files selected for processing (1)
  • src/main/codex/codex-session-index-heal.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.

Comment on lines +228 to +230
const outcome = await readOneThread(rpc, thread.threadId)
settled.push({ threadId: thread.threadId, outcome })
onOutcome(thread, outcome)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

#!/bin/bash
set -e
printf '%s\n' '--- changed-file diff ---'
git diff --no-ext-diff --unified=50 f09458796db5886abd0be00f726a0b5a302e6a04 57390a5ad6f7ff1563da0333cb5cfe60225d9e50 -- src/main/codex/codex-session-index-heal.ts
printf '%s\n' '--- current module outline ---'
ast-grep outline src/main/codex/codex-session-index-heal.ts
printf '%s\n' '--- current module relevant ranges ---'
rg -n -C 12 'settled|onOutcome|runAfterBatch|afterBatch|recordHealOutcome|pending|marker' src/main/codex/codex-session-index-heal.ts
printf '%s\n' '--- repository bindings ---'
rg -n -C 10 'recordHealOutcome|afterBatch|runAfterBatch|pending.*marker|marker.*pending|clear.*pending|delete.*pending' src

Repository: stablyai/orca

Length of output: 45663


🤖 get_repo_knowledge executed:

get_repo_knowledge stablyai/orca /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/learnings /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/conventions

Length of output: 17103


🏁 Script executed:

#!/bin/bash
set -e
printf '%s\n' '--- changed files ---'
git diff --name-only f09458796db5886abd0be00f726a0b5a302e6a04 57390a5ad6f7ff1563da0333cb5cfe60225d9e50
printf '%s\n' '--- exact callback bindings ---'
rg -n -C 14 'afterBatch|readCodexThreadsForIndexHeal|runCodexSessionIndexHeal|recordHealOutcome' src/main/codex src/main --glob '*.ts'
printf '%s\n' '--- heal state implementation ---'
wc -l src/main/codex/codex-session-index-heal-state.ts
cat -n src/main/codex/codex-session-index-heal-state.ts

Repository: stablyai/orca

Length of output: 42260


🏁 Script executed:

#!/bin/bash
set -e
cat -n src/main/codex/wsl-codex-session-bridge.ts | sed -n '130,225p'
printf '%s\n' '--- marker helper bindings ---'
rg -n -C 12 'clearIndexPendingMarkers|index pending|pending marker|write.*marker|unlink|rmSync' src/main/codex/wsl-codex-session-bridge.ts src/main/codex/wsl-codex-session-bridge-script.ts src/main/codex

Repository: stablyai/orca

Length of output: 45665


Record the read only after persisting its outcome.

For a healed or missing read, recordHealOutcome can throw when the ledger write fails. The current order still adds that read to settled, and the WSL afterBatch callback then removes its pending marker. The next pass has neither the marker nor a ledger record.

Suggested fix
-            settled.push({ threadId: thread.threadId, outcome })
             onOutcome(thread, outcome)
+            settled.push({ threadId: thread.threadId, outcome })
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const outcome = await readOneThread(rpc, thread.threadId)
settled.push({ threadId: thread.threadId, outcome })
onOutcome(thread, outcome)
const outcome = await readOneThread(rpc, thread.threadId)
onOutcome(thread, outcome)
settled.push({ threadId: thread.threadId, outcome })

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ No new issues found.

Reviewed changes

The two commits since the prior pullfrog review (6274b45) close a marker-counting edge case in the WSL account history bridge:

  • A marker whose name is not a Codex thread no longer stalls the whole home's heal. parseWslSessionBridgeSummary now validates pendingFiles against every rollout-* marker line, so one rollout-*.jsonl without a parseable thread id can no longer fail the count on every launch and skip indexing everything else.
  • Such markers are cleared instead of reported forever. pendingRollouts now carries the full marker list; the bridge splits parseable names into pendingThreads/markerByThreadId and clears the rest through a new clearIndexPendingMarkers helper (also reused by clearSettledIndexPendingMarkers), since thread/read can never settle them.
  • Tests pin both halves. A new case asserts the parseable marker is still indexed while the non-thread marker is cleared, and the shared-loop and script suites continue to cover the ordering and marker lifecycle.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

nwparker added a commit that referenced this pull request Oct 25, 2026
… it (carries #23843) (#33630)

New WSL Codex managed accounts no longer link all past rollouts before Codex first opens the home (which stalled startup past Codex's 30s backfill gate or left later-linked sessions unindexed): Codex opens the home first, then history is linked and indexed in background batches newest-first, resumable across restarts — matching #22971's non-WSL order.

Supersedes #23843

Co-authored-by: Brennan Benson <[email protected]>
@nwparker

Copy link
Copy Markdown
Contributor

Closing as superseded by #33630 (merged), which carries this fix for indexing a new WSL account home before bridging history. Thanks @brennanb2025!

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

2 participants