codex-plugin-cc icon indicating copy to clipboard operation
codex-plugin-cc copied to clipboard

` /codex:transfer` fails with "did not record an imported thread" for both auto-detected and explicit --source

Open hoaza opened this issue 5 months ago • 1 comments

Description

codex-companion.mjs transfer consistently fails with an opaque error, both when auto-detecting the current Claude Code session and when passing an explicit, verified-valid --source path.

Steps to Reproduce

  1. From within an active Claude Code session (Windows, Git Bash), run: node "<plugin-root>/scripts/codex-companion.mjs" transfer
  2. Observe failure.
  3. Retry with an explicit, confirmed-existing .jsonl path instead of relying on auto-detection: node "<plugin-root>/scripts/codex-companion.mjs" transfer --source "C:\Users\lukas\.claude\projects\C--Users-lukas-source-repos-pfs-web-app\d845c3e0-b354-4895-8723-c0669d0aa03a.jsonl"
  4. Same failure, byte-for-byte identical error message.

Expected behavior

The session transfers into a resumable Codex thread, and the command prints a codex resume <id>.

Actual behavior

Both invocations fail identically:

(node:40764) [DEP0190] DeprecationWarning: Passing args to a child process with shell option true can lead to security vulnerabilities, as the arguments are not escaped, only concatenated. (Use node --trace-deprecation ... to show where the warning was created) Codex reported that the Claude import completed, but did not record an imported thread. Check the Codex app-server logs for the underlying import error.

Exit code 1. No further detail is surfaced — codex-companion.mjs status --all shows no job entry for the transfer attempt at all, so there's no job-id to inspect via status/result for more context.

Notes

  • The --source file was confirmed to exist, be a valid non-empty .jsonl, and live under the expected ~/.claude/projects/<project>/ directory — ruling out a source-resolution problem. Since the no-argument (auto-detect via CODEX_COMPANION_TRANSCRIPT_PATH) and explicit --source runs fail identically, the bug appears to be in the Codex-side import/thread-registration step itself, not in path resolution.
  • The [DEP0190] deprecation warning (child_process spawned with shell: true and unescaped args) fires on every invocation and may be worth addressing separately regardless of the main bug.

Environment

  • OS: Windows 11 Pro (10.0.26200)
  • Node.js: v24.15.0
  • Plugin path/version: .../plugins/cache/openai-codex/codex/1.0.5/scripts/codex-companion.mjs
  • Shell: Git Bash (MSYS)

hoaza avatar Jul 02 '26 08:07 hoaza

This is a false negative — on Windows the import actually succeeds and the thread is created. The failure is in the lookup that runs after the import.

Your notes rule out path resolution because the explicit --source run fails identically, and that reasoning is what makes this one hard to spot: the mismatch isn't on the source path you pass in, it's on the path Codex writes into the ledger afterwards. Both invocations converge on the same post-import lookup, so both fail the same way, byte for byte.

importedThreadIdForSource() in plugins/codex/scripts/lib/codex.mjs compares the ledger's source_path against fs.realpathSync(sourcePath) with strict equality — still record?.source_path === canonicalSource on main today. On Windows, Codex writes ledger records with the extended-length prefix:

{ "source_path": "\\\\?\\C:\\Users\\<you>\\.claude\\projects\\<project>\\<session>.jsonl" }

…while realpathSync returns the plain C:\Users\<you>\... form. The two never compare equal, the lookup returns null, and the caller throws the "did not record an imported thread" message for an import that worked.

Ten-second confirmation: run codex resume after a "failed" transfer. If the thread is sitting in the picker, this is the bug and your session is fine. ~/.codex/external_agent_session_imports.json will show the record with the \\?\ prefix.

Which patch to watch (edited 2026-08-07): I wrote one for this myself in #551, but it is closed and unmerged — I deleted the fork, which auto-closed it — and it was only half a fix anyway: it normalised the path but left the content_sha256 check in the same filter alone. That check fails on its own, because a live Claude transcript keeps growing while the transfer runs, so the hash Codex recorded at import time no longer matches the file when the lookup re-reads it. Here, 12 of 22 surviving transcripts had diverged that way.

#469 (open, by @ayobamiseun) is the one to watch — it snapshots the ledger before the import and falls back to the records Codex appends during it, covering both failure modes. It declares Fixes #417, so this issue should close when it lands. main is unfixed as of today.

The missing status --all job entry you mention looks like a separate problem — I haven't investigated that one, so I can't say whether it shares a cause.

If you need transfers working before this is fixed upstream, I put the same normalisation in a wrapper that confirms the imported thread from Codex's own state instead of trusting the return value: https://github.com/AndrewAvery7/claude-codex-bridge

AndrewAvery7 avatar Aug 07 '26 15:08 AndrewAvery7