Commit Graph
28 Commits
Author SHA1 Message Date
7418andClaude Opus 4.6 e86f0cfd8f perf: optimize polling with caching and event-driven approach (P1-2)
- CLI binary detection cached with 60s TTL
- Settings poll replaced with visibility/focus events
- Health check uses adaptive backoff (30s → 60s when stable)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-13 01:24:43 +08:00
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 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 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 183860587f fix: send images as multimodal vision content instead of file path references
Images were being saved to disk and referenced by text path in the prompt,
causing Claude to hallucinate about image contents since it never actually
saw the image data. Now images are sent as base64 content blocks via the
SDK's multimodal SDKUserMessage, enabling Claude's vision capability.
Non-image files continue to be saved to disk for Read tool access.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-09 20:51:23 +08:00
歸藏 8dcc19d077 fix: add graceful database shutdown (#20)
fix: add graceful database shutdown to prevent WAL file leaks
2026-02-09 16:08:07 +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
7418andClaude Opus 4.6 37cfaacaf0 fix: file upload bugs and UI adjustment
- Include base64 data in file metadata for chat display (fixes broken images)
- Use file-to-disk + Read tool approach instead of SDK multimodal
  messages (fixes slow response caused by invalid prompt format)
- Move attach button before folder picker in input toolbar

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-08 22:26:42 +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 746cea1eb7 fix: add graceful database shutdown to prevent WAL file leaks
The SQLite database connection was never explicitly closed when the
process exits. In WAL mode, this can leave behind -wal and -shm files
and risk data loss if the WAL hasn't been checkpointed.

Changes:
- Add closeDb() export for explicit database closure
- Register process shutdown handlers (exit, SIGTERM, SIGINT, SIGHUP)
  that call closeDb() before the process terminates
- Idempotent: multiple calls to closeDb() are safe
- After closeDb(), getDb() transparently re-opens the database
- Add 6 unit tests covering close, idempotency, reopen, data
  persistence, and WAL cleanup (all passing)
2026-02-08 21:37:35 +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
7418andClaude Opus 4.6 81125a233b fix: auto-detect git-bash path on Windows (closes #23)
Add findGitBash() to platform.ts that checks env var, common install
paths, and derives path from `where git`. Used in claude-client.ts
to set CLAUDE_CODE_GIT_BASH_PATH when not already configured.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-08 20:54:03 +08:00
歸藏 7d52a508a4 Merge pull request #17 from liuxiaopai-ai/fix/mcp-sse-http-transport
Code review approved: correct SDK type usage, backward compatible, comprehensive tests (11 cases).
2026-02-08 20:27:23 +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 7c8240fff0 fix: support SSE and HTTP transport types for MCP servers
The toSdkMcpConfig() function only handled stdio transport, discarding
the type, url, and headers fields. This meant SSE and HTTP MCP servers
configured through the Extensions page were silently converted to
broken stdio configs.

Changes:
- Import McpSSEServerConfig, McpHttpServerConfig, McpServerConfig types
  from the Claude Agent SDK
- Rewrite toSdkMcpConfig() to dispatch on config.type (stdio/sse/http)
- SSE configs: pass type, url, and optional headers to the SDK
- HTTP configs: pass type, url, and optional headers to the SDK
- stdio configs: pass command, args, env (unchanged behavior)
- Skip servers with missing required fields (url for SSE/HTTP, command
  for stdio) with a console warning instead of passing broken configs
- Do not include empty headers objects
- Add 11 unit tests covering all transport types, mixed configs,
  missing fields, and edge cases (all passing)

This aligns the implementation with the README which states:
'Supports stdio, sse, and http transport types.'
2026-02-08 15:58:15 +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
7418andClaude Opus 4.6 262b295f63 fix: use stable ~/.codepilot/ data directory to persist across updates
Previously the database path depended on app.getPath('userData') which
varies with app name changes (CodePilot vs codepilot vs Claude GUI).
Now uses a fixed ~/.codepilot/ directory for both dev and production.

Includes automatic migration: on first launch, if the DB doesn't exist
at the new path, it checks old locations (Application Support variants
and the old dev-mode data/ folder) and copies the database over.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-07 13:07:08 +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 f310fab397 fix: scroll bouncing during streaming and skills/cwd awareness
1. Change StickToBottom resize mode from "smooth" to "instant" to
   prevent scroll position bouncing when new streaming content
   arrives faster than the smooth animation completes.

2. Use SDK's preset append mode for system prompts instead of
   replacing Claude Code's default prompt. This preserves Claude
   Code's built-in awareness of skills (.claude/commands/), working
   directory context, and other default behaviors.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-07 00:18:52 +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 e4ae2154af fix: pass env to SDK subprocess and hide server Dock icon
1. Explicitly pass process.env to the Claude Agent SDK's env option,
   ensuring user shell env vars (ANTHROPIC_AUTH_TOKEN, ANTHROPIC_BASE_URL,
   etc.) reach the claude subprocess in packaged builds.
2. Spawn the standalone server via /bin/sh with exec to prevent the
   Electron binary from appearing as a separate Dock icon on macOS.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-06 23:06:52 +08:00
7418andClaude Opus 4.6 2e6fc2af7d fix: pass claude binary path to Agent SDK for packaged app
The SDK's query() function also needs to find the claude binary.
Added findClaudePath() in claude-client.ts and pass it via
pathToClaudeCodeExecutable option, fixing "Failed to create session"
in packaged builds where PATH is limited.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-06 22:23:18 +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