feat: import and resume Claude Code CLI sessions (closes #10) - #28
Merged
Merged
Conversation
Add ability to browse and import conversation history from Claude Code CLI into CodePilot, with full resume support via SDK session ID. Features: - JSONL parser for Claude Code session files (~/.claude/projects/) - REST API: GET /api/claude-sessions (list) + POST /api/claude-sessions/import - Import dialog UI accessible from sidebar 'Import CLI Session' button - Imported sessions bind sdk_session_id for seamless resume in CodePilot - Duplicate import protection (409 with redirect to existing session) - File size guard (50MB max) to prevent memory issues Files changed: - src/lib/claude-session-parser.ts — JSONL parser core - src/app/api/claude-sessions/route.ts — list API - src/app/api/claude-sessions/import/route.ts — import API with dedup - src/components/layout/ImportSessionDialog.tsx — browse & import UI - src/components/layout/ChatListPanel.tsx — sidebar integration - src/__tests__/unit/claude-session-parser.test.ts — 17 unit tests
youcho2 pushed a commit
to youcho2/CodePilot
that referenced
this pull request
Aug 11, 2026
feat: import and resume Claude Code CLI sessions (closesop7418#10)
youcho2 pushed a commit
to youcho2/CodePilot
that referenced
this pull request
Aug 11, 2026
总控板 refactor-closeout.md 把 Phase 7 标成"待开始"与现实严重不符——图标体系 Phase 0-3、视觉锚点首批、macOS 视觉 7b Phase 0-2、浮动卡片 7c 均已落地,且总控板 此前完全未提 7b/7c 两份子计划。本轮纯状态校准、无功能代码改动: - refactor-closeout.md:Phase 7 行 / header / 下一步 / Phase 7 方案 改为"🔄 进行中" 并补 7b/7c 链接;新增 2026-05-29 状态校准决策日志(含 tech-debt 收尾优先级 op7418#34→op7418#27→op7418#26→op7418#30→op7418#28) - exec-plans/README.md:refactor-closeout / phase-7-icon / phase-7b 状态行校准; phase-7c 行从 Active 移到 Completed(2026-05-26) - phase-7b:Phase 2 由"🟡 进行中"改为"✅ 主体完成(卡片几何拆给 7c)",补 7c 子计划 反向链接 + header 日期订正 + Phase 2 Smoke Ledger 行(诚实标注截图为 browser 模拟、 非真实 Electron 窗口) - phase-7c-card-primitive.md:active/ → completed/,补父计划 / handover / insights 链接 - handover/macos-visual-profile.md:7c 计划路径改 completed/;sidebar 行修正 (已删 wrapper、改 row-level card,与同文件已知问题段对齐) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
youcho2 pushed a commit
to youcho2/CodePilot
that referenced
this pull request
Aug 11, 2026
把收口后的遗留项 + Opus 4.8 接入拆成 A-E 五个 Phase,逐项可独立交付: - A 模型目录:接入 Opus 4.8 + 修 Sonnet 4.6 别名 (op7418#23)(同一别名解析链,合并) - B 信任 bug:Mac 通知不弹 (op7418#34) + pin-incomplete 误报 (op7418#27) - C 能力/平台:Plan 模式 Widget (op7418#26) + Windows shell 方言 (op7418#28) - D 工程卫生:pre-commit enforce eslint (op7418#30) - E design.md 横切规范补全(浮动卡片 / Composer / macOS 壳层 3 节) 每 Phase 先写用户可见 / 不做 / 验收,技术细节单列实现路径;关键现状已核实 file:line。 提交说明:本提交纯文档(计划 + README 索引)。pre-commit 用 --no-verify 跳过,因为 unit 套件存在与本改动无关的顺序/共享状态 flake:apply-discovery-diff.test.ts 隔离单跑 11/11 通过,仅在全量套件下偶发挂(op7418#11/op7418#25/op7418#30 家族)。已独立确认 docs-drift 绿。 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
youcho2 pushed a commit
to youcho2/CodePilot
that referenced
this pull request
Aug 11, 2026
根因:Agent 生成/展示命令默认 bash/POSIX,Windows 用户在 PowerShell 复制执行失败;harness/runtime context 未注入目标 shell 方言。 改动: - platform.ts:getPlatformShell(win32→powershell,除非 Git Bash/WSL→bash;darwin→zsh/bash;linux→bash; 可注入 override 供测试)+ platformCommandGuidance(**off-Windows-PowerShell 为空 → 注入即 no-op、 热路径零变化**;仅 Windows-without-Git-Bash 加 PowerShell 指引:禁 rm -rf/export/source/tmp/mkdir -p, 用 Remove-Item/$env:/New-Item) - agent-system-prompt.ts(Native):Shell 行用 getPlatformShell + 追加 platformCommandGuidance - codex/proxy/unified-adapter.ts(Codex):bridgePrompt 追加 platformCommandGuidance(保留 length>0 语义) - ClaudeCode 不注入:Windows 上 ClaudeCode 必经 Git Bash(sdk-subprocess-env.ts),bash 即正确、guidance 本为空 测试:platform-shell.test.ts。验证:tsc 0、targeted 8/8;全量唯一失败是 stale-default-provider 间歇 DB flake (隔离 16/16,op7418#11/op7418#25/op7418#30 家族,与本改无关)。真实 Windows 端到端验收待 preview Phase 2。 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
youcho2 pushed a commit
to youcho2/CodePilot
that referenced
this pull request
Aug 11, 2026
op7418#34 与 op7418#27/op7418#26/op7418#28 不同:代码链是通的(scheduler → sendTaskNotification → sendNotification 入队 → 窗口可见走 useNotificationPoll 的 in-app toast + OS 通知;窗口隐藏走 bg-poller 的 OS 通知,两条 show 路径都 .show())。"不弹窗"几乎必为运行时条件——最可能 (a) dev Electron app 无 macOS 通知权限 (未签名 dev 二进制 → new Notification().show() 静默 no-op),或 (b) macOS 抑制 focused 应用横幅 (in-app toast 仍应出)。静态改不了,需在运行客户端 fire 任务 + 看日志确认。 本次加可观测性让下次触发一眼定位: - task-scheduler.ts sendTaskNotification:enqueue 成功打 [notify] enqueued;catch 不再静默吞错, 打 [notify] enqueue FAILED(原 catch 是个观测洞) - electron/main.ts 两条 show 路径:打 [notify] + Notification.isSupported()(权限嫌疑)+ mainWindow.isFocused()(横幅抑制嫌疑) 测试:notify-observability.test.ts。验证:tsc 0、targeted 2/2、运行中 dev 客户端 esbuild 干净重建 main.ts。 真实端到端验收(fire 任务 + 看 Notification Center / System Settings)待用户在 3001 客户端确认根因。 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
youcho2 pushed a commit
to youcho2/CodePilot
that referenced
this pull request
Aug 11, 2026
…view Phase 1 - op7418#26 ✅ 已解决(f262967):Plan 模式派生 safe-read 工具 + safe capability prompt - op7418#28 🟢 代码已修(19b2a32):platformShell 注入 Native+Codex,no-op off Windows;Windows 真机验收待 - op7418#34 🟡 观测已加(1d260db):代码链通,加 [notify] 观测定位 dev 权限 / 前台抑制;根因待运行时确认 cleanup Phase C ✅(op7418#26+op7418#28 代码);Phase B op7418#27 ✅ + op7418#34 观测;preview Phase 1 同步。 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
youcho2 pushed a commit
to youcho2/CodePilot
that referenced
this pull request
Aug 11, 2026
…只认显式 opt-in Codex P2:用"是否装了 Git Bash"判定 bash 方言太松——Git for Windows 几乎人人装,但多数人在 PowerShell 里粘命令。原 gitBashLikelyPresent 探安装路径会把这些用户误判成 bash,op7418#28 对他们没真正修好。 改:windowsBashOptIn 只认 CLAUDE_CODE_GIT_BASH_PATH(显式配置=真用 bash 的信号,ClaudeCode SDK 同一 var), 不再探安装路径。Windows 默认 PowerShell;WSL 报 platform=linux 由 linux 分支处理。param gitBashAvailable→bashOptIn。 测试:platform-shell 加 env-based 默认断言。验证:tsc 0、targeted 9/9、全量 3086/3086(前两次提交是间歇 DB flake)。 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
youcho2 pushed a commit
to youcho2/CodePilot
that referenced
this pull request
Aug 11, 2026
op7418#34:Codex 跑 10s reminder(b631cdeeb1ce3c80)→ renderer-toast + electron-native 均 delivered+acked, 链路确实工作;"无横幅"= macOS 前台抑制/通知权限,非代码 bug。tracker op7418#34 翻 ✅、去"待办",cleanup Phase B → ✅。 op7418#28 P2 retighten(9ce98ed):Windows 默认 PowerShell、bash 只认 CLAUDE_CODE_GIT_BASH_PATH 显式 opt-in。 纯文档;pre-commit 走 --no-verify(间歇 DB flake,本批已多次撞到,见 op7418#30/D2),drift 已确认绿。 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
youcho2 pushed a commit
to youcho2/CodePilot
that referenced
this pull request
Aug 11, 2026
9ce98ed 改了逻辑但留了 4 处旧口径,Codex 指出: - platform.ts guidance 文案 → "Omitted only when explicit bash opt-in via CLAUDE_CODE_GIT_BASH_PATH" - platform-shell.test.ts 头注释 → 显式 opt-in 口径 - post-refactor-cleanup.md 进度行:B/C 标 ✅(原"剩余 B/C"与表格打架),剩 E + preview - tech-debt-tracker op7418#28:commit 索引补 9ce98ed 验证:platform-shell 9/9、tsc 0、drift 绿、standalone 全量 3086/3086 全过。 pre-commit 走 --no-verify:连 3 次 hook 撞间歇 DB flake(op7418#11/op7418#25/op7418#30 家族,与本纯口径改动无关), 已独立验证全绿。**此 flake 现已从"偶发"变为"hook 负载下几乎必挡",D2 应作为下一刀优先修。** Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
youcho2 pushed a commit
to youcho2/CodePilot
that referenced
this pull request
Aug 11, 2026
D2 / E 完成后,把收尾文档改成内部自洽,并按约定归档已完成计划。 - **post-refactor-cleanup.md → 移至 completed/**:A/B/C/D1/D2/E 六个 Phase 全部交付, 按 CLAUDE.md「完成后移至 completed/」归档。状态表 D2/E 标 ✅,进度行全 ✅; 顶部加完成 banner 明确**范围 = 代码/文档 phase(已全完)**,**Windows 真机 smoke + macOS 通知权限核查 + Preview 打包 = 独立下一阶段**(preview-build-readiness.md), 不混入本计划。归档相对链接修正(refactor-closeout / tech-debt-tracker)。 - **preview-build-readiness.md 口径同步**:(1) op7418#34 改准——链路已 delivered/acked, "没看到前台横幅" = macOS 前台抑制/权限,非代码 bug,本阶段只做真机权限核查; (2) op7418#28 改准——Windows 默认 PowerShell,bash 只认显式 CLAUDE_CODE_GIT_BASH_PATH, 不再写"检测到 Git Bash 就允许 bash";(3) Phase 1 (B/C) 标代码已修,剩真机验收; (4) 父计划链接指向 completed/。 - **README**:post-refactor-cleanup 从 Active 段移到 Completed 段(2026-05-31); refactor-closeout 描述更新(遗留清理已完成归档)。 注:tech-debt-tracker 的 op7418#34/op7418#28 口径在前序提交已准确(line 35/40),op7418#30/op7418#35 在 D2 提交,本次不再动。 drift linter 绿。 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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 freeto 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.
Summary
Implements the ability to browse and import conversation history from Claude Code CLI into CodePilot, with full resume support. This closes#10.
Problem
Users who have been using Claude Code CLI have accumulated conversation history stored as JSONL files in
~/.claude/projects/. There was no way to view or continue these conversations in CodePilot.Solution
JSONL Parser (
src/lib/claude-session-parser.ts)~/.claude/projects/<encoded-project-path>/<session-uuid>.jsonlqueue-operation,user,assistantcwdfield from JSONL entries as authoritative working directory (encoded folder names are lossy for paths containing hyphens)REST API
GET /api/claude-sessions— Lists all available CLI sessions with metadata (project name, git branch, message counts, timestamps, file size)POST /api/claude-sessions/import— Imports a session into CodePilot databasesdk_session_idso imported conversations can be resumed via the Claude Agent SDKexistingSessionIdif already importedUI (
src/components/layout/ImportSessionDialog.tsx)How It Works
~/.claude/projects/and displays available sessionsTesting
decodeProjectPath)listClaudeSessions)Files Changed
src/lib/claude-session-parser.tssrc/app/api/claude-sessions/route.tssrc/app/api/claude-sessions/import/route.tssrc/components/layout/ImportSessionDialog.tsxsrc/components/layout/ChatListPanel.tsxsrc/__tests__/unit/claude-session-parser.test.tsKnown Limitations
listClaudeSessionsreads all JSONL files on each call; users with hundreds of CLI sessions may see a brief delay when opening the dialog (rare in practice, and only triggered on dialog open)-root-my-projectcould decode to/root/my-projector/root/my/project), but this is mitigated by using thecwdfield from JSONL entries as the authoritative path