Repository navigation
feat(import): import and continue codex threads - #312
Merged
Merged
Conversation
nixuuu
force-pushed
the
feat/cli-import-4
branch
4 times, most recently
from
November 7, 2026 01:00
aea8095 to
71b3f11
Compare
nixuuu
force-pushed
the
feat/cli-import-4
branch
from
November 7, 2026 02:03
71b3f11 to
c6faba5
Compare
nixuuu
force-pushed
the
feat/cli-import-4
branch
from
November 7, 2026 02:43
c6faba5 to
182b7fd
Compare
Codex rollouts become Canopy threads through the adapter's own mapper, older rollouts without whole items included, and continue natively from a copy in the instance's private CODEX_HOME. See docs/import.md.
nixuuu
force-pushed
the
feat/cli-import-4
branch
from
November 7, 2026 03:14
182b7fd to
a27dca7
Compare
nixuuu
marked this pull request as ready for review
November 7, 2026 03:23
nixuuu
added a commit
that referenced
this pull request
Nov 7, 2026
…351) Imported Codex threads can fail on their first Canopy turn because their rollout names a custom CLI provider that does not exist in Canopy's private `CODEX_HOME`. Fixes: #312 Related: #345 ## Cause and fix - Keep the explicit `modelProvider` override from #345. Codex 0.164 accepts it, but 0.166 validates the saved provider before applying it. The real 0.166 binary reproduces the reported “which is no longer configured” refusal against a local fake API. - Before cold resume, normalize only the manifest-owned private rollout's session provider and its own settings snapshots to the thread's Canopy connection (`openai` or `canopy_<instance id>`). Use the existing staged, identity-checked copy writer and update the manifest, preserving Undo. Session ID, history, messages and turn references stay intact. - Paginated Codex sessions also read their saved provider from SQLite, including on path-based resume. Update only `threads.model_provider` in the private index, matching both session ID and verified rollout path. Do not create a database or change its schema; leave unknown schemas alone. Reject symbolic/hard links and special files in the index and SQLite companions. Source CLI files, configuration and databases remain untouched. Codex still enforces managed requirements on the selected connection. - Classify the missing-provider refusal as `connection_changed`, reusing the specific explanation and **Open provider settings** action from #345. Retain the native harness error under **Show details**. - Claude already receives the instance endpoint and selected model on resume; Grok loads the copied history and explicitly selects the thread model. Extend their real-CLI regressions with a conflicting source endpoint/model and a retired source model respectively. ## Already-imported threads The next cold resume repairs the existing private copy and its matching index entry, including copies that already failed with 0.166. No re-import, new conversation, history summary or gateway migration is needed. Copies without valid ownership evidence are not rewritten; harness refusals retain their specific classification. ## Validation - Passed: `bun install`, `bun run gen:check`, `bun run typecheck`, `bun run lint`, `bun run format:check`, and `bun run --cwd apps/web build`. - Real Codex 0.166 against a local fake API plus copy/index security regressions: **9 passed**, including native and proxy connections, failed old-copy recovery, a second cold resume, complete history, unchanged source and Undo. The standard installed Codex 0.164, Claude and Grok adapters also pass against local fake APIs. - Gateway↔worker import integration covers native continuation with the same session ID/history and an impossible override classified as `connection_changed`, retaining the native error and provider-settings recovery. - Full `bun run check:tmp`: **1772 passed, 161 skipped, 0 failed** (1933 tests across 317 files); no test temp-directory leaks. Its PostgreSQL container and volume were removed. `CANOPY_LIVE` stayed unset; no paid API calls or UI/E2E tests. - Final self-review and `git diff --check` passed. CI and external review are pending. ## Copy audit — docs/copy.md §8 Effective message before → after: “Canopy had an internal error. Retry. If it happens again, copy the details and report them.” → “Codex could not use this thread with the current connection. Restore its previous connection in provider settings, then retry.” The missing-provider variant now uses the existing actionable connection explanation; no new UI string or layout is introduced. | Checks | Result | |---|---| | 1–2: wording and glossary | Reuses #345's two short sentences, sentence case, punctuation, thread and provider-settings terminology. No native provider ID appears on the surface. | | 3–4: actions and errors | Existing **Open provider settings** and **Retry** actions; integration test verifies harness source, native code/message and `connection_changed`. Technical details use the existing **Show details** disclosure. | | 5–8: states, repetition, dependencies and soul | No new empty state or confirmation; no duplicate title/body fact; connection dependency and recovery are explicit; no humour. | | 9: text lengths and widths | No interpolated names, new labels, string changes or layout changes. Uses the same notice as #345; no browser or UI test was run in this task. | | 10: accessibility | Existing visible explanation and action labels convey meaning without colour, icon shape or position. |
This was referenced Nov 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stage 4 of 5 of the CLI import (stack A). Design:
docs/import.md.What it ships
CodexEventMapper(the one live threads use): turns fromtask_started…task_complete/turn_aborted, whole items fromevent_msg item_completed, shell calls and code cells from rawresponse_items, the prompt as the turn's input (no echo item). Older rollouts withoutitem_completedget messages, reasoning summaries, shell calls and compaction fromresponse_items andevent_msg user_message. Injected context is never a prompt.CODEX_HOME/sessions/YYYY/MM/DD/(archived rollouts too); the thread resumes it withthread/resumeby id. Undo removes the copy.Tests
apps/worker/src/import/codex-history.test.ts: fixture turns, command with output, reasoning, stable ids across page splits; synthetic older rollout (messages, reasoning, shell call, compaction, aborted and failed turns, broken line).apps/worker/src/import/codex-resume.test.ts: the real Codex app-server resumes the copied rollout by id against the fake endpoint; the request carries both earlier prompts and the tool output.tests/integration/import-codex.test.ts(fake app-server, now also resuming the real rollout layout): history without the prompt echo, command with output, reasoning, untouched rollouts; native import with copy andthread/resumeon a Canopy turn.CANOPY_LIVE=1): a real Codex thread learns a code word, is imported and resumed in the privateCODEX_HOME; the real model answers with the word. Passed on this machine.Copy audit
No new UI strings beyond stage 2's (Codex rows reuse the same labels).
Review fixes
Re-check fixes
Round 3 fixes
Round 4 fixes
Round 5 fixes
maskedRecord); scan previews and titles mask the whole record first. Covered bymasking.test.ts(all three CLIs) and the stage tests.Final review fixes
split-secrets.test.ts(in feat(import): import and continue grok sessions #313) covers a key split across Codex content and summary parts.