Skip to content

feat: Windows platform adaptation#1

Merged
op7418 merged 2 commits intoop7418:mainfrom
xuxu777xu:feat/windows-drive-switcher
Feb 7, 2026
Merged

feat: Windows platform adaptation#1
op7418 merged 2 commits intoop7418:mainfrom
xuxu777xu:feat/windows-drive-switcher

Conversation

@xuxu777xu
Copy link
Contributor

@xuxu777xu xuxu777xu commented Feb 7, 2026

Summary

CodePilot 原本仅支持 macOS,本 PR 添加完整的 Windows 平台适配,使其可以在 Windows 上正常构建、运行和使用。

Changes

跨平台基础设施

  • 新增 src/lib/platform.ts:统一的跨平台工具模块,包含 Claude CLI 发现逻辑(Windows .cmd/.bat shell 处理、where/which 回退)、PATH 扩展(AppData/npm 等 Windows 路径)
  • 重构 src/app/api/claude-status/route.ts:移除硬编码的 Unix 路径,改用共享的 platform 工具
  • 重构 src/lib/claude-client.ts:同上,并确保 USERPROFILE 和扩展 PATH 在 SDK 子进程中可用

Electron 主进程

  • electron/main.ts
    • Windows 进程派生使用 windowsHide 防止控制台窗口闪烁
    • PATH 构建适配 Windows 分隔符(;)和目录结构(AppData/npm)
    • 窗口标题栏适配:macOS hiddenInset / Windows hidden + titleBarOverlay
    • 图标适配:Windows 使用 .ico
    • loadUserShellEnv() 跳过非 macOS 平台

构建配置

  • electron-builder.yml:新增 win + nsis 构建目标,支持自定义安装目录、桌面/开始菜单快捷方式
  • package.json:新增 electron:pack:win 脚本,原 electron:pack 改为平台无关
  • build/icon.ico:Windows 应用图标

UI 适配

  • src/components/chat/FolderPicker.tsx:新增盘符下拉切换器,解决 Windows 盘符根目录无法向上导航的问题
  • src/app/api/files/browse/route.ts:API 返回可用 Windows 盘符列表
  • src/components/skills/SkillsManager.tsx:修复 key 重复警告

Test plan

  • Windows 上 npm run electron:pack:win 构建成功
  • 安装后启动,Claude CLI 自动检测并连接
  • 标题栏样式正确(隐藏标题栏 + overlay 控制按钮)
  • FolderPicker 盘符切换正常工作
  • macOS 上 npm run electron:pack:mac 构建无回归

🤖 Generated with Claude Code

xuxu777xu and others added 2 commits February 7, 2026 13:29
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>
- 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>
@xuxu777xu xuxu777xu changed the title feat: add Windows drive switcher in FolderPicker feat: Windows platform adaptation Feb 7, 2026
@op7418 op7418 merged commit b819eb7 into op7418:main Feb 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants