Files
orca/src/main/codex/codex-state-db-test-fixture.ts
T
Kelvin AmoabaandBrennan Benson b6c2de9f92 fix(codex): index a new account home before bridging history into it (#22971)
* fix(codex): index a new account home before bridging history into it

Codex indexes every rollout present when it first creates its state DB, and
the TUI gives up after 30s, so large histories broke a new account's launch.

Fixes #20669

* test(codex): keep the account migration test from starting the real Codex binary

Selecting an account starts the history bridge, which spawned codex app-server
on the fixture homes and raced the test's temp-dir cleanup.

* fix(codex): index a new account's most recent bridged history first

Indexing a large history takes minutes, and Codex's /resume hides unindexed
threads once a directory has any indexed one, so recent conversations stayed
missing until the heal reached them in directory-listing order.

* test(codex): cover the history bridge's quit, no-history and failed-link guards

Drop the stop check before creating the state DB: it ran in the same tick as
the check at bridge start, so it could never observe a quit.

* test(codex): make the account heal tests fail closed instead of reaching a real codex

Fake invocations now point at a nonexistent binary and a throwaway CODEX_HOME,
and cover per-home failure memory and a session that fails during quit.

---------

Co-authored-by: Brennan Benson <79079362+brennanb2025@users.noreply.github.com>
2026-09-29 01:09:11 -07:00

15 lines
592 B
TypeScript

import { mkdirSync } from 'node:fs'
import { join } from 'node:path'
import SyncDatabase from '../sqlite/sync-database'
/** Writes a Codex state DB whose startup backfill reports `status`. */
export function writeCodexStateDbBackfillStatus(codexHomePath: string, status: string): void {
mkdirSync(codexHomePath, { recursive: true })
const db = new SyncDatabase(join(codexHomePath, 'state_5.sqlite'))
db.exec(
'CREATE TABLE backfill_state (id INTEGER PRIMARY KEY, status TEXT NOT NULL); ' +
`INSERT INTO backfill_state (id, status) VALUES (1, '${status}')`
)
db.close()
}