Skip to content
Source
Sign inSign up
pingdotgg/t3code

feat(orchestration): import an existing Claude Code or Codex session by ID #4617

ClosedBil0000(GitHub profile, opens in a new tab)wants to merge 13 commits intomain fromrefs/pull/4617/headopened View on GitHub

Why

T3 Code can only continue sessions it started. A Claude Code CLI session or a codex thread already on the machine has a transcript on disk and is fully resumable, but there is no way to open it here. Starting work in a terminal and wanting to finish it in the web UI means starting over.

What

Import session... in the command palette takes one session id.

The server reads where that session ran, creates the thread in the project covering that workspace, starts the provider session with a resume cursor, and copies the prior conversation into the transcript. The next turn continues inside the original provider session — the model still has its full context, because nothing is replayed to it.

  • The thread lands in the right project automatically. orchestration.resolveImportSession reads the session's working directory before anything is created. If a project already covers it, the thread goes there regardless of which project is open.
  • If no project covers it, the dialog says so and the button becomes Add project & import. Nothing is created without a second press.
  • /status is surfaced under the field as the fastest way to get a session id.

Claude Code and Codex only. No session picker, no listSessions browsing, no other providers.

How it fits together

PieceChange
Contractsthread.messages.import command and its thread.messages-imported event, plus the two RPC payloads
Decidercommand → event
Projectionapplied through the existing message projection — no new table, no migration
ServerresolveImportSession (read scope) and importThread (operate scope)
ClientresolveImportSession / importThread operations and the palette dialog

thread.messages.import is in the internal command union: only the server dispatches it, so a client cannot write a transcript.

Imported message ids are derived from the thread id, provider, zero-padded transcript index, and source message id — stable ordering, and a repeated import cannot duplicate rows.

A failure after the thread exists deletes that thread, and ThreadDeletionReactor stops the provider session behind it, so a failed import leaves nothing running and nothing in the sidebar.

Supporting changes

Two small provider changes were needed and are split into their own commits:

  • ProviderService gains readThread. The adapter registry is not visible past ProviderServiceLive, so an RPC handler had no way to read a provider thread snapshot.
  • The codex thread snapshot now carries the thread's workspace root and last activity time. thread/read already returned both and the adapter dropped them; without them, codex imports could not get the same workspace check as Claude. Codex reports those stamps in Unix seconds, so they are converted at the boundary and the field name carries the unit.

Commits

The branch is nine commits, each of which typechecks on its own:

  1. feat(provider): expose readThread on the ProviderService facade
  2. feat(provider): carry codex workspace root and last activity on thread snapshots
  3. feat(orchestration): add the thread.messages.import command and its event
  4. feat(orchestration): map provider transcripts to imported thread messages
  5. feat(orchestration): project imported thread messages
  6. fix(relay): do not publish agent awareness for an imported transcript
  7. feat(orchestration): resume an existing provider session into a new thread
  8. feat(client-runtime): add the session-import operations
  9. feat(web): add the Import session command palette action

Verification

Focused tests, per AGENTS.md:

vp test run apps/server/src/orchestration/ \
  apps/server/src/provider/Layers/CodexSessionRuntime.test.ts \
  apps/server/src/provider/Layers/CodexAdapter.test.ts \
  apps/server/src/relay/AgentAwarenessRelay.test.ts \
  apps/server/src/server.test.ts \
  apps/web/src/components/CommandPalette.logic.test.ts \
  packages/client-runtime/src/state/threadReducer.test.ts

Test Files  25 passed (25)
     Tests  410 passed (410)

Typecheck and format clean across contracts, client-runtime, server, web and mobile.

Manually, against a real Claude Code session:

  1. claude -p "Remember this fact for later: the import canary code is FERRET-4412. Reply with exactly: OK" inside a project directory.
  2. Copy the id (/status, or from ~/.claude/projects/<project>/).
  3. From a different project, run Import session... and paste it.
  4. The thread appears under the project the session actually ran in, with both prior messages rendered.
  5. Ask "What is the import canary code?" — the resumed session answers FERRET-4412. The canary only exists in the on-disk transcript, so this confirms the real session resumed rather than the copied messages being replayed.
  6. Repeat with a folder that is not a project yet: the dialog reports it and offers Add project & import.
  7. Repeat with a bogus UUID: an actionable error, and no thread is left behind.

Not covered

Codex was not exercised at runtime — no codex CLI on the machine used. Its transcript mapper, workspace check and timestamp conversion are unit-tested; the live resume path is not.

Video

https://github.com/user-attachments/assets/23c0229f-bfed-4e5d-a16f-33f4bc5b6f21

Note

Add import of existing Claude Code or Codex sessions by ID into new threads

  • Adds resolveImportSession and importThread RPC endpoints on the WebSocket layer, allowing clients to look up an external session and import its transcript into a new orchestration thread.
  • New importThread.ts factory orchestrates the full flow: validates provider support (claudeAgent/codex), creates a thread, converts the external transcript via importedMessages.ts, dispatches thread.messages.import and thread.session.set, and cleans up via thread.delete on failure.
  • Adds a thread.messages-imported event type through the full stack: contracts, decider, projector, projection pipeline, and client-side reducer, with deduplication by messageId.
  • Adds an ImportSessionDialog UI component in the web app, accessible via a new "Import session..." action in the command palette, which guides the user through provider selection, session ID input, optional project creation, and navigation to the imported thread.
  • Risk: if the import flow is interrupted after thread creation but before cleanup completes, a partial thread may remain.
Macroscope summarized db5946c.
    1. coderabbitai[bot](GitHub profile, opens in a new tab)commented

      Important

      Review skipped

      Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

      ⚙️ Run configuration

      Configuration used: Repository UI

      Review profile: CHILL

      Plan: Pro Plus

      Run ID: f31aa5e6-4472-4e7b-ae0f-82abb58d09db

      You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

      Use the checkbox below for a quick retry:

      • 🔍 Trigger review
      ✨ Finishing Touches
      🧪 Generate unit tests (beta)
      • Create PR with unit tests

      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.
    2. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched

    3. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      🟡 Medium

      https://github.com/pingdotgg/t3code/blob/e48610f268970cb7559d3ffde33889d52c408c56/apps/web/src/components/CommandPalette.tsx#L429

      When ImportSessionDialog is open, pressing the command-palette shortcut still calls toggleOpen() and reopens CommandDialog on top of the import dialog, producing two overlapping modals with conflicting focus handling. The global keydown listener in the useEffect at line 420 does not check whether importSession is non-null, so it toggles the palette even while the import flow is active. Consider guarding the shortcut handler so it skips when importSession is set, or closing the import dialog before reopening the palette.

      ✅ Resolved in db5946cee1a3d199db594ab18c30046f9b66cc49

    4. Effect Service Conventions — 1 finding.

      The importFailure helper in apps/server/src/orchestration/importThread.ts is a pure error-construction mapper, which the conventions ask to avoid. See the inline comment.

      Posted via Macroscope — Effect Service Conventions
    5. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      Approvability

      Verdict: Needs human review

      This PR introduces a complete new feature for importing Claude Code and Codex sessions, including new RPC endpoints, orchestration events, external SDK integration, and a new UI dialog workflow. New features with this scope of cross-cutting changes and external integrations warrant human review.

      You can customize Macroscope's approvability policy. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    6. Fixed in fcb9ee59c. Guarded the shortcut and added importSession to the effect deps so the listener sees the current value:

      if (command !== "commandPalette.toggle" || importSession !== null) {
        return;
      }
    7. Sorry, I'm unable to act on this request because you do not have permissions within this repository.

    8. All five review findings addressed, one commit each, pushed as db5946cee.

      FindingCommit
      High — import option bound to a custom instance instead of the default581459f89
      Palette shortcut stacked a second modal over the import dialogfcb9ee59c
      Retry after a created project built a duplicate and hit the workspace invariantb5250c8f9
      tapError skipped compensation on interruptiondb5946cee
      importFailure relocated error construction away from the boundarydb5946cee

      Each was reproduced before being changed. The interruption one has a regression test that forks the import, interrupts it during startSession, and asserts the compensating thread.delete — it fails against the previous implementation.

      Test Files  23 passed (23)
           Tests  364 passed (364)

      Typecheck, lint and format clean across contracts, client-runtime, server, web and mobile.

    9. I want to be able to look up stuff from old conversations with a decent UI. Thanks a lot for this PR - I would absolutey love it to get merged. There are many reasons for me to not want to use claude code and its annoying terminal UI. The main reason for me is, that it is completely impossible to get a decent overview over current/previous conversations.

    10. I want to be able to look up stuff from old conversations with a decent UI.

      Thanks a lot for this PR - I would absolutey love it to get merged.

      There are many reasons for me to not want to use claude code and its annoying terminal UI.

      The main reason for me is, that it is completely impossible to get a decent overview over current/previous conversations.

      Happy to hear that man

      Just didnt get what you mean, can you plz briefly explain exactly what you want?

      I will make sure to add your request if its smth useful :)

    11. @Bil0000 Apologies, with my previous comment I did not mean to suggest that something about the PR needs to change for my usecase.

      I was merely venting about how the TUI in cladue code is not good to navigate conversations, Codex or T3-Code are much better at that. This ist the main reason I want to move my old Claude conversations/threads to T3 code, and why I like your PR (in the meantime until this gets merged, i have just created a small python script for myself)

      If I were to suggest anything to add at all: I have not checked out your branch and tested it, but If I understand it correctly, your PR adds a command that allows to import conversations into an existing thread.

      I would consider it useful, if there was any way

      • to create a thread from scratch that corresponds to a claude code conversation (maybe that is already effectively possible if your import is the first command which also creates the thread?)
      • a way to batch-import multiple conversations as new/corresponding threads

      While not strictly necessary, I could see that this would be a nice addition to make t3-code adoption a bit easier

    12. Closing in favor of #2829 (orchestration V2).

      #2829 deletes the V1 orchestration layer this PR builds on — apps/server/src/orchestration/**, provider/Layers/*Adapter.ts and provider/Services/** are removed and replaced by apps/server/src/orchestration-v2/**, with the IPC surface renamed to ORCHESTRATION_V2_WS_METHODS. The files this PR touches either no longer exist or are rewritten, so it can't be rebased — it would need reimplementing against the V2 adapters.

      This is not a judgement on the change itself. Several of these are real gaps we still want fixed; the base just moved out from under them.

      Once #2829 merges, please rebase onto main, port the change to the V2 equivalent, and reopen (or open a fresh PR). Ping me and I'll prioritise the review.

    13. juliusmarminge closed this

    14. @juliusmarminge reimplemented against the V2 orchestrator as #5499, targeting the #2829 branch so it can rebase trivially once that merges. Same UX as this PR plus two-way transcript sync (T3 turns land back in the provider's own session file, and turns made in the CLI after import sync into the thread). Verified live against a real Claude Code session — details in the PR description.

Sign in to join this conversation.