Commit Graph
34 Commits
Author SHA1 Message Date
7418andClaude Opus 4.6 af2830db9b feat: add cursor-based message pagination (P0-3)
Backend returns paginated messages with hasMore flag. Frontend shows
"Load earlier messages" button with scroll anchor preservation.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-13 01:24:27 +08:00
7418andClaude Opus 4.6 128ccf951c perf: convert sync file I/O to async in API routes (P0-2)
Replace all readFileSync/existsSync/readdirSync with fs.promises
equivalents to unblock the Node event loop under concurrency.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-13 01:24:21 +08:00
7418andClaude Opus 4.6 f3c49a9e49 fix: deduplicate attachment file writes (P0-1)
Upload route now passes persisted filePath to claude-client, which
reuses it instead of writing the file again.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-13 01:24:12 +08:00
7418andClaude Opus 4.6 d5b1d6eb9d feat: redesign settings page with sidebar navigation
Extract settings into General / Providers / Claude CLI sections with
a left sidebar layout. Keep Skills and MCP on the Extensions page.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-12 17:28:29 +08:00
7418andClaude Opus 4.6 a5cff792e3 fix: read MCP servers from both ~/.claude.json and ~/.claude/settings.json
Claude CLI stores user-scoped MCP servers in ~/.claude.json, while
CodePilot was only reading from ~/.claude/settings.json. Now both
the MCP list API and streamClaude merge configs from both sources.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-12 11:28:56 +08:00
7418andClaude Opus 4.6 4fa26032a4 feat: tool timeout auto-retry, file tree attachment, force stop button
- Add configurable tool timeout with auto-retry: when a tool exceeds the
  timeout threshold, abort and send a follow-up message asking Claude to
  try a different approach
- Add "+" button on file tree items to attach files directly to chat
  input via new /api/files/raw endpoint and custom event bridge
- Add force stop button in streaming status bar when tool runs >90s,
  with warning indicators at 60s
- Improve doc preview markdown rendering (padding, list indentation)
- Bump version to 0.10.0

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-12 00:33:21 +08:00
7418andClaude Opus 4.6 da07f1bd1b feat: draggable panel resize handles and remove extensions divider
Add ResizeHandle component for drag-to-resize side panels.
ChatListPanel (180–400px) and RightPanel (200–480px) widths
are persisted via localStorage. Also remove the border line
below the Extensions page tab selector.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-10 12:57:37 +08:00
7418andClaude Opus 4.6 74fb784f6d feat: auto update check and dangerously-skip-permissions mode
Add automatic update detection (checks GitHub Releases every 8h with
dialog prompt and blue dot on Settings icon) and a skip-permissions
toggle in Settings that uses the SDK's native bypassPermissions mode
to auto-approve all tool actions.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-09 23:14:42 +08:00
7418andClaude Opus 4.6 e4bbe8578a fix: persist file attachments so images/documents survive page reload
Previously uploaded files were only held in memory (optimistic message)
and lost when navigating away. Now:
- API route saves all uploaded files to .codepilot-uploads/ on disk
- File metadata (with filePath, not base64) is embedded in message content
- New /api/uploads endpoint serves persisted files
- FileAttachmentDisplay handles both base64 (in-memory) and filePath (DB)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-09 21:02:34 +08:00
7418andClaude Opus 4.6 9635585ab6 feat: blue theme migration and chat input UI polish
- Migrate purple/violet theme to blue across entire codebase (globals.css,
  ToolCallBlock, ChatListPanel, SkillEditor, SkillListItem, e2e tests)
- Increase input box border radius (rounded-md → rounded-2xl) and shadow
- Add arrow flip animation on mode/model selector dropdowns
- Change send button to circular with up-arrow icon
- Increase global Hugeicons stroke weight (1.5 → 2)
- Remove theme-colored focus ring on input box

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-09 19:48:06 +08:00
歸藏 487c0a5cb7 fix: prevent path traversal in file APIs (#16)
fix: prevent path traversal in file tree and preview APIs
2026-02-09 16:08:11 +08:00
歸藏 c2c53e9591 feat: import and resume Claude Code CLI sessions (#28)
feat: import and resume Claude Code CLI sessions (closes #10)
2026-02-09 16:08:02 +08:00
歸藏 336897cded fix: 支持读取 ~/.claude/skills/ 目录下的已安装技能 (#36)
fix: 支持读取 ~/.claude/skills/ 目录下的已安装技能
2026-02-09 16:07:58 +08:00
gy212andClaude Opus 4.6 61e3720ded fix: 支持读取 ~/.claude/skills/ 目录下的已安装技能 (#35)
问题:CodePilot 只扫描 ~/.agents/skills/,缺失了 ~/.claude/skills/ 路径,
导致用户通过 CLI 安装到该目录的技能无法在 CodePilot 中显示和使用。

修改内容:

后端:
- 列表接口 (GET /api/skills) 同时扫描 ~/.agents/skills/ 和 ~/.claude/skills/
- 通过 SHA1 内容哈希去重:同名同内容只保留一条,同名不同内容保留两条
- 详情接口 (GET/PUT/DELETE /api/skills/:name) 新增 ?source= 参数精确定位来源
- 详情接口使用 YAML front matter 的 name 字段匹配,修复列表能看到但点开 404 的问题
- 同名不同内容时返回 409,要求前端传 source 消歧

前端:
- SkillItem 类型新增 installedSource 字段
- Badge 显示 installed:claude 或 installed:agents 明确来源
- 保存/删除时携带 ?source= 防止误操作同名技能
- 聊天补全项描述追加来源提示
- 技能展开时精准请求对应来源

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-09 11:10:08 +08:00
7418andClaude Opus 4.6 a42c0e312d fix: resolve session switching stuck on loading spinner
Race condition when quickly switching chat sessions caused the UI to get
stuck on loading. Added cancellation flags and key-based remounting.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-09 10:19:25 +08:00
liuxiaopai-ai 187cc23127 feat: import and resume Claude Code CLI sessions (closes #10)
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
2026-02-08 22:04:12 +08:00
liuxiaopai-ai 0f05e4fd0f fix: address code review - fallback to homedir, validate baseDir, use afterAll
Address all 3 points from @op7418's review:

1. No baseDir fallback (severe): Both /api/files and /api/files/preview
   now fall back to os.homedir() when no baseDir is provided, preventing
   access to arbitrary system directories/files.

2. baseDir bypass via baseDir=/ (medium): Both APIs now validate that
   baseDir itself is within the user's home directory. Setting baseDir=/
   will be rejected with 403.

3. Test cleanup (minor): Replaced 'it(cleanup...)' with proper after()
   hook. Added 6 new tests for baseDir validation (18 total, all pass).
2026-02-08 21:36:56 +08:00
7418andClaude Opus 4.6 164f730da1 feat: add file upload and preview support (images and documents)
- Support image (JPEG/PNG/GIF/WebP, max 5MB) and document uploads
- Images sent as multimodal content blocks to Claude SDK
- Documents saved to temp dir for Claude's Read tool
- Emerald capsule badges in input for attached files
- Drag-and-drop, paste, and file picker support via PromptInput
- Chat display: image thumbnails with lightbox, file cards
- Lightbox uses Radix Dialog with prev/next navigation
- File metadata embedded in message content as HTML comments
- Compatible with existing slash command badge system

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-08 21:35:45 +08:00
liuxiaopai-ai 84de2d1de8 fix: prevent path traversal in file tree and preview APIs
The file tree API (/api/files) and file preview API (/api/files/preview)
had ineffective path safety checks that could allow reading arbitrary
files on the host system.

Issues fixed:
- /api/files: isPathSafe(resolvedDir, resolvedDir) always returns true
  since it compares the directory against itself
- /api/files/preview: isPathSafe(dirname, filePath) always returns true
  since a file is always inside its own parent directory

Changes:
- Add baseDir parameter to both APIs so the frontend can pass the
  session's working directory as a trust boundary
- When baseDir is provided, validate that the requested path is within it
- For /api/files/preview without baseDir, fall back to restricting access
  to the user's home directory (prevents /etc/passwd etc.)
- Add comprehensive unit tests covering path traversal, prefix attacks,
  symlink escapes, and edge cases (13 tests, all passing)

Security: This is a defense-in-depth measure. CodePilot runs locally so
the attack surface is limited, but proper validation prevents accidental
exposure when the dev server is bound to non-localhost interfaces.
2026-02-08 21:35:34 +08:00
7418andClaude Opus 4.6 e688b29210 fix: add scrollbar to skills list on extensions page (closes #3)
Add flex flex-col min-h-0 to the skills container so overflow-y-auto
in SkillsManager can properly trigger scrolling.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-08 20:54:15 +08:00
7418andClaude Opus 4.6 4617c71f34 fix: detect and display env var API config fallback (closes #22, closes #4)
Providers API now detects ANTHROPIC_API_KEY, ANTHROPIC_AUTH_TOKEN, and
ANTHROPIC_BASE_URL from environment. ProviderManager shows a banner
when env vars are detected, informing users they're used automatically
when no provider is active.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-08 20:54:10 +08:00
歸藏 5d62e8ce5d Merge pull request #18 from liuxiaopai-ai/fix/persist-structured-messages
Code review approved: high quality bug fix, backward compatible design, comprehensive tests (10 cases).
2026-02-08 20:27:27 +08:00
7418andClaude Opus 4.6 4e81eaa60b feat: fix slash commands, add badge UI, multi-provider management
Slash commands:
- Fix skills not appearing (removed non-existent `enabled` filter)
- Add badge/capsule UI for prompt-type commands (/compact, /review, etc.)
- SDK-native commands sent directly; CLI-only commands expanded to prompts
- /clear now resets SDK session and clears database messages
- /cost shows actual aggregated token usage statistics
- Keyboard: Backspace/Escape to remove badge, arrow keys auto-scroll popover
- Add /memory command for editing CLAUDE.md

Multi-provider management:
- CRUD API for API providers with SQLite storage
- ProviderManager UI with quick presets (GLM, Kimi, MiniMax, etc.)
- Dynamic model labels based on active provider
- Environment variable injection with conflict resolution

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-08 20:03:18 +08:00
liuxiaopai-ai 960d5906b8 fix: persist structured tool_use/tool_result blocks in messages
The collectStreamResponse() function only collected text events,
discarding tool_use and tool_result events. When a conversation was
resumed, all tool call context was lost — the user only saw the
text portions of Claude's responses.

Changes:
- Collect tool_use and tool_result SSE events as MessageContentBlock
  entries alongside text blocks
- Flush accumulated text into a text block before each tool_use to
  preserve the interleaved ordering (text → tool_use → tool_result →
  text → ...)
- Store messages with tool calls as JSON arrays of MessageContentBlock,
  using the existing type definitions in types/index.ts
- Text-only messages remain as plain strings for backward compatibility
  with existing message rendering (parseMessageContent handles both)
- Add 10 unit tests covering parsing, serialization, round-tripping,
  edge cases, and backward compatibility (all passing)

This enables future improvements like:
- Rendering tool call history in resumed conversations
- Showing which files were read/written in previous turns
- Exporting full conversation logs with tool context
2026-02-08 15:59:59 +08:00
7418andClaude Opus 4.6 0b1ae6c02f fix: Windows Claude CLI path discovery and Extensions scroll
- Fix Windows Claude CLI not found when installed as .exe or without
  extension in .local\bin (closes #6). Now searches all extensions
  (.cmd, .exe, .bat, and bare) for every candidate directory.
- Fix Extensions/Skills list not scrollable when many items exist.
  Change content container to overflow-hidden so internal ScrollArea
  works correctly. Add overflow-auto to McpManager for its own scroll.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-07 22:20:03 +08:00
xuxu777xuandClaude Opus 4.6 0234240066 feat: full Windows platform adaptation
- Add src/lib/platform.ts: cross-platform Claude CLI discovery
  (candidate paths, .cmd/.bat shell handling, where/which fallback)
- Refactor claude-status route and claude-client to use shared platform utils
- Electron main: Windows process spawning (windowsHide), PATH construction
  with AppData/npm dirs, titleBarOverlay, .ico icon support
- electron-builder.yml: add win/nsis build targets
- package.json: add electron:pack:win script
- FolderPicker: drive switcher dropdown for navigating between drives
- SkillsManager: fix duplicate key warning with filePath fallback

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-07 13:35:04 +08:00
xuxu777xuandClaude Opus 4.6 3ae44a7277 feat: add Windows drive switcher dropdown in FolderPicker
When navigating to a drive root on Windows (e.g. C:\), path.dirname
returns itself, disabling the "go up" button and trapping the user on
that drive. This adds a compact dropdown next to the up button that
lists all available drives (auto-detected via fs.accessSync), allowing
quick switching between drives. macOS/Linux are unaffected (empty array,
dropdown not rendered).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-07 13:29:59 +08:00
7418andClaude Opus 4.6 a5e9fc76a8 Fix streaming content disappearing on window switch and improve skills scanning
- Add useRef + visibilitychange/focus listener to re-sync streaming content
  when Electron window regains focus, preventing blank content flash
- Remove duplicate text SSE events from assistant handler (stream_event
  already provides real-time deltas)
- Make skills scanner recursive to find commands in subdirectories
- Add debug logging for skills directory resolution

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-07 02:23:53 +08:00
7418andClaude Opus 4.6 fab8b41966 fix: ensure Claude Code finds skills in ~/.claude/commands/
1. Skills API: accept optional cwd query param so project-level skills
   are scanned from the session's working directory, not the standalone
   server's process.cwd().
2. SDK env: explicitly set HOME so Claude Code can resolve ~/.claude/
   for global skills discovery in packaged builds.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-07 00:49:40 +08:00
7418andClaude Opus 4.6 8b27f69a6f feat: add optional API configuration for custom Anthropic endpoints
Add a new "API Configuration" section in settings for users who use
custom Anthropic-compatible APIs (e.g. via ai-claude-start). Users
can optionally set ANTHROPIC_AUTH_TOKEN and ANTHROPIC_BASE_URL in
CodePilot's settings UI. These are stored in SQLite and injected
into the Claude Code subprocess env only when configured.

Existing authentication methods (claude login, shell env vars) are
not affected - the API config is purely additive.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-06 23:17:49 +08:00
7418andClaude Opus 4.6 454c7b0e6c fix: show detailed error messages for session creation failures
Return full error stack traces from the sessions API and display
the actual server error in the frontend, instead of a generic
"Failed to create session" message.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-06 22:29:44 +08:00
7418andClaude Opus 4.6 2c5280cd77 fix: expand PATH search for claude binary in packaged app
The claude-status endpoint now searches common installation paths
(/usr/local/bin, /opt/homebrew/bin, ~/.npm-global/bin, ~/.local/bin,
~/.claude/bin) and uses `which` with expanded PATH as fallback,
fixing "Disconnected" status in packaged builds.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-06 22:01:07 +08:00
7418andClaude Opus 4.6 ff1fb38735 feat: CodePilot - desktop GUI for Claude Code
Full-featured desktop application built with Next.js + Electron:
- Streaming chat with Claude Code via Agent SDK
- Session management with SQLite persistence
- Project file tree and file preview
- MCP server and custom skills management
- Permission controls with Code/Plan/Ask modes
- Dark/light theme, token tracking
- macOS DMG packaging with electron-builder

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-06 21:04:05 +08:00
7418 6776cc6297 Initial commit from Create Next App 2026-02-06 10:39:12 +08:00