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
Copy Markdown
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
op7418 added a commit that referenced this pull request Apr 12, 2026
…ion for Native Runtime

Two feature gaps where Native Runtime didn't match SDK Runtime, both
surfaced during post-hermes-upgrade manual testing:

── #1: Compression notification now human-readable ──

Before: chat/route.ts:402 emitted `message: 'context_compressed'` as
a machine string. useSSEStream's notification branch showed this raw
string in the status bar — users saw "context_compressed" flash by.

After: message is now `"Context compressed: N older messages summarized,
~X tokens saved"` with structured `stats: { messagesCompressed, tokensSaved }`
for future rich UI handling. Added `subtype: 'context_compressed'` for
dedicated frontend handlers.

── #3: AskUserQuestion tool for Native Runtime ──

Before: only SDK Runtime had AskUserQuestion (built into Claude Code CLI).
Native Runtime had no such tool, so the model could never ask structured
questions — the existing AskUserQuestionUI in PermissionPrompt.tsx was
unreachable dead UI code for Native Runtime users.

After:
- New builtin tool `src/lib/builtin-tools/ask-user-question.ts`
  registered in index.ts, condition 'always'
- Zod schema: 1-6 questions, each with 1-6 options, optional multiSelect
- Execute receives answers from permission flow (injected by frontend)
  and formats as Q/A pairs for the model
- permission-checker.ts: new ALWAYS_ASK_TOOLS set ensures AskUserQuestion
  (and ExitPlanMode) always show UI even in trust mode — without this,
  trust mode would auto-approve and return empty answers
- PermissionPrompt.tsx: NEVER_AUTO_APPROVE set prevents full_access mode
  from auto-approving AskUserQuestion — the UI must render so the user
  can answer

The data flow:
  Model → AskUserQuestion({ questions }) → permission wrapper intercepts
  → SSE permission_request → frontend AskUserQuestionUI renders
  → user picks options → updatedInput({ questions, answers }) → tool
  execute formats answers → model gets "Q: ... A: ..." string

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
KevinYoung-Kw referenced this pull request in KevinYoung-Kw/CodePilot Apr 15, 2026
**补充修复**
在 op7418#1 斜杠命令保留已有文本的修复基础上,进一步确保选择命令后光标自动定位到输入框尾部,而不是默认的首部。

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
KevinYoung-Kw referenced this pull request in KevinYoung-Kw/CodePilot Apr 15, 2026
**补充修复**
在 #1 斜杠命令保留已有文本的修复基础上,进一步确保选择命令后光标自动定位到输入框尾部,而不是默认的首部。

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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