How to Resume Sessions from Claude Code in jcode: A Complete Guide to Import and Conversion
jcode imports Claude Code sessions by converting their JSONL transcripts into native jcode format before resuming them through the standard session picker or CLI commands.
Resuming external AI coding sessions requires handling incompatible formats. The 1jehuang/jcode repository solves this by treating Claude Code conversations as foreign sessions that undergo a structured import pipeline. This workflow preserves message history while enabling jcode's advanced features like branching and provider switching.
Understanding the Foreign Session Model
Unlike native jcode sessions stored in the application's internal database, Claude Code sessions exist as disconnected JSONL transcript files on disk. The system recognizes these through the SessionSource::ClaudeCode variant, displaying them with a "🧵 Claude Code" badge in the TUI interface. When you attempt to resume one, jcode does not simply load the file—it performs a full conversion into the native session format.
This architecture ensures that once imported, Claude Code sessions gain access to jcode's provider-agnostic runtime, allowing you to continue conversations with different AI models or take advantage of jcode's session management features.
The Import and Resume Workflow
The resume process follows a three-stage pipeline involving discovery, conversion, and execution. Each stage is implemented across specific modules in the src/ directory.
Step 1: Discovery via the Session Picker
The session picker UI discovers available Claude Code sessions through the list_claude_code_sessions function in src/tui/session_picker/loading.rs. Each discovered session becomes a ResumeTarget::ClaudeCodeSession struct containing:
session_id: The unique Claude Code identifiersession_path: The filesystem path to the JSONL transcript
These entries appear in the picker interface (defined in src/tui/session_picker.rs between lines 72-86) alongside native sessions, distinguished by the SessionSource::ClaudeCode variant.
Step 2: Converting Claude Code Transcripts to jcode Format
When you select a Claude Code entry, the system invokes resolve_resume_target_to_jcode in src/import.rs (lines 71-89). This function orchestrates the conversion through import_session_from_file (lines 37-66), which performs several critical transformations:
- Parses the JSONL transcript containing the full conversation history
- Filters and reorders messages according to parent-uuid links to reconstruct the conversation tree
- Converts content blocks using
convert_content_blocksto translate Claude-specific formatting into jcode's nativeContentBlockstructures - Creates a new native session with the naming pattern
imported_cc_<id>and stores it in the jcode session database
The function returns a ResumeTarget::JcodeSession pointing to the newly created native session, effectively decoupling the resume logic from the original Claude Code file format.
Step 3: Resuming the Imported Session
Once converted, the session resumes through jcode's standard execution paths. In the inline interactive command handler (src/tui/app/inline_interactive.rs, lines 24-33), the resolved jcode target is passed to spawn_resume_target_in_new_terminal. If the system cannot spawn a new terminal window, resume_target_manual_command (in src/tui/app/helpers.rs, lines 437-453) generates a fallback CLI command for manual execution.
Alternatively, the backend API supports programmatic resume via Client::resume_session(&session_id), as demonstrated in the end-to-end tests at tests/e2e/provider_behavior.rs (lines 151-162), where the client sends a resume request and receives a resume-id to rehydrate provider-side context.
Interactive TUI Method
The simplest way to resume a Claude Code session uses the built-in session picker. Open the jcode interface and trigger the resume overlay:
/Resume
Type "claude" to filter the session list, then select the desired entry marked with the "🧵 Claude Code" badge. Upon selection, jcode automatically imports the transcript and resumes the conversation in a new terminal window, displaying a success message with the imported session name (e.g., imported_cc_12345abcd).
Programmatic Import and Resume
For automation or custom tooling, you can programmatically import and resume sessions using the Rust API:
use jcode::import;
// Reference the Claude Code session ID from list_claude_code_sessions
let claude_id = "12345abcd";
let target = jcode::tui::session_picker::ResumeTarget::ClaudeCodeSession {
session_id: claude_id.to_string(),
session_path: format!("{}/.jcode/claude_sessions/{}.jsonl",
dirs::home_dir().unwrap().display(),
claude_id),
};
// Convert to native jcode format
let jcode_target = import::resolve_resume_target_to_jcode(&target)?;
// jcode_target is now ResumeTarget::JcodeSession { session_id }
// Resume via the client API
let client = jcode::client::Client::new(...);
let resume_id = client.resume_session(&jcode_target.session_id()).await?;
This approach is essential when building custom session management tools or integrating jcode into larger development workflows.
Manual CLI Fallback
When the TUI cannot spawn a new terminal (for example, in restricted SSH sessions or containerized environments), jcode generates a manual fallback command. If you see the message "No terminal found. Resume manually:", execute the provided command:
jcode resume imported_cc_12345abcd
Replace imported_cc_12345abcd with the actual session ID displayed in the UI. This command bypasses the terminal spawning mechanism and resumes the session directly in your current shell context.
Summary
- Foreign Session Model: Claude Code sessions require import into native jcode format before resuming, identified by the
SessionSource::ClaudeCodebadge. - Core Import Function: The
resolve_resume_target_to_jcodefunction insrc/import.rshandles transcript parsing viaimport_session_from_fileandconvert_content_blocks. - Naming Convention: Imported sessions follow the pattern
imported_cc_<id>to distinguish them from native sessions. - Multiple Entry Points: Resume via the interactive TUI (
/Resumecommand), programmatic Rust API (Client::resume_session), or CLI fallback (jcode resume <id>). - File Locations: Key logic resides in
src/tui/session_picker.rs(discovery),src/import.rs(conversion), andsrc/tui/app/inline_interactive.rs(execution).
Frequently Asked Questions
Can I resume a Claude Code session without converting it to jcode format?
No, jcode requires all sessions to be in its native format to support features like multi-provider switching and persistent session management. The resolve_resume_target_to_jcode function in src/import.rs performs this mandatory conversion automatically when you select a Claude Code session from the picker.
Where does jcode look for Claude Code session files?
The list_claude_code_sessions function scans the standard Claude Code storage location, typically ~/.jcode/claude_sessions/ or the equivalent platform-specific path. Each session appears as a JSONL file named with the session ID, which the session picker loads and displays with the distinctive "🧵 Claude Code" badge.
What happens to my Claude Code conversation history after import?
The import_session_from_file function preserves all user and assistant messages by parsing the JSONL transcript, filtering content blocks, and reconstructing the conversation tree using parent-uuid links. However, the original Claude Code file remains untouched; jcode creates a new session (imported_cc_<id>) in its own database, leaving the source file intact for backup purposes.
Why does jcode create a new session ID instead of using the original Claude Code ID?
jcode maintains separate namespaces for native and imported sessions to prevent collisions and track provenance. The ResumeTarget::ClaudeCodeSession struct contains the original ID for reference, but the conversion process generates a new jcode-native session ID with the imported_cc_ prefix, ensuring the internal SessionStore can manage metadata like provider state and modification timestamps consistently.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →