Repository navigation
Description
What happened
Expected: /export-codex (and the GUI export picker) writes the rollout JSONL and the state_5.sqlite index entry, so the exported conversation appears in Codex after a restart. This is what the README documents: export "Creates clean, standalone Codex rollouts … and SQLite index entries".
Actual: the rollout file is written correctly, but the threads row is never inserted when no sqlite3 executable is on PATH. Codex Desktop renders its conversation list from state_5.sqlite, so the exported conversation never appears — while the plugin still reports success.
The corresponding Codex migration scanner then separately records the rollout as failed and never recovers it:
rollout_migration_skipped_rollouts:
rollout_path = sessions/2026/10/22/rollout-...jsonl
skip_reason = failed
From the user's perspective the export "worked" and nothing shows up in Codex.
Commands involved: GUI export picker (Sync ▾ → 导出到 Codex), same as /export-codex.
Root cause
Two spots call the external CLI unconditionally, with no native fallback:
lib/export-codex.js:266 — workspace lookup:
const out = execFileSync('sqlite3', [db, "SELECT DISTINCT cwd FROM threads ..."])lib/export-codex.js:387 — index write:
try {
execFileSync('sqlite3', [db, sql], { stdio: 'pipe' })
ok = true
} catch {
ok = false // ← ENOENT swallowed here
}Both throw ENOENT when the CLI is absent. The lookup silently falls back to scanning rollout headers, and the write silently degrades to ok = false, surfacing only as (jsonl only — restart Codex) — which reads like a benign notice rather than "the thread will not appear at all".
Evidence that the DB read never runs
With a populated state_5.sqlite (100 rows, 9 distinct cwds, all stored with the Windows \\?\ extended-length prefix), getKnownCodexWorkspaces() returned only the 7 cwds discoverable from rollout headers — none of the prefixed forms. The query result is entirely absent, confirming the sqlite3 spawn never succeeded.
A related second bug surfaces once the query does run: Codex stores threads.cwd as \\?\D:\AI\DeepSeek Harness while DSH session metadata is D:\AI\DeepSeek Harness. Without normalizing the prefix, workspace matching fails even with a working SQLite backend.
Reproduction
- Have
sqlite3absent fromPATH. - Export any native DSH session to a workspace Codex already knows.
state_5.sqlitehas no row for the new thread id; the rollout file exists.- Restart Codex → the conversation is missing.
Suggested fix
Adopt the native-first pattern already introduced by @KKeygen in lib/codex-titles.mjs (PR #6), and apply it to the export path:
let DatabaseSync
try { ({ DatabaseSync } = require('node:sqlite')) } catch {}
if (DatabaseSync) { /* native */ } else { /* existing sqlite3 CLI */ }Two further details worth handling in the same change:
- Do not swallow the failure.
indexCodexThreadreturnsok, but callers only print(jsonl only — restart Codex). It should be reported as an error, since the thread will not appear at all. - Normalize
\\?\on read (workspace matching) and writethreads.cwd/threads.rollout_pathwith the prefix, matching Codex's own rows.
Local verification of that fix
I applied exactly this patch to a local 1.6.2 install and confirmed:
indexCodexThreadnow returnstrue; thethreadsrow is inserted.- Export log changes from
(jsonl only — restart Codex)to(indexed). getKnownCodexWorkspaces()returns all 9 DB cwds (normalized) instead of 7.- All 11 exported API functions and the export dry-run flow still work.
Happy to open this as a PR if useful — please say whether you'd prefer it built on top of PR #5/#6 or independently against main.
Environment
- Node: 24.18.1 (DSH Desktop host, Electron 44)
- dsh profile: desktop
- OS: Windows 11
sqlite3: not onPATH(no CLI installed)- Plugin version: 1.6.2
Activity