Skip to content

fix: Windows CLI and deep link issues (#11657, #11666, #11674)#11724

Open
01luyicheng wants to merge 44 commits intoanomalyco:devfrom
01luyicheng:dev
Open

fix: Windows CLI and deep link issues (#11657, #11666, #11674)#11724
01luyicheng wants to merge 44 commits intoanomalyco:devfrom
01luyicheng:dev

Conversation

@01luyicheng
Copy link
Contributor

@01luyicheng 01luyicheng commented Feb 2, 2026

Problem Description

This PR fixes three Windows-specific issues:

  1. Issue Windows: opencode CLI hangs at startup when running internal npm list / npm config get registry #11657: Windows CLI startup hanging when package manager detection commands hang
  2. Issue [Windows] Opening with deep link duplicates projects #11666: Windows deep link duplicate project creation due to inconsistent path normalization
  3. Issue [BUG]: (app): Clicking on overflowed tab on the right in the file view/review section does not scroll it into view #11674: Windows reserved device names causing directory check failures

Issue #11657 - CLI Startup Hang

The CLI would hang indefinitely on Windows when package manager detection commands (npm, yarn, pnpm, etc.) didn't respond. This occurred because the detection process had no timeout mechanism.

Solution: Added 5-second timeout protection using existing withTimeout utility from @/util/timeout. This prevents the CLI from hanging and allows graceful fallback to other detection methods.

Issue #11666 - Deep Link Duplicate Projects

When using deep links (e.g., opencode://open-project?directory=C:\Users\Project) to open projects, different path representations were treated as different projects, causing duplicate project entries to be created.

Problem Examples: The following paths represent the same physical directory on Windows but were treated as different projects:

  • C:\Users\Project vs c:\users\project (different case)
  • C:/Users/Project vs C:\Users\Project (different slash type)
  • C:\Users\Project\ vs C:\Users\Project (trailing slash)

Solution: Implemented unified path normalization for Windows:

  • Convert to lowercase for case-insensitive comparison
  • Normalize all slashes to forward slashes
  • Remove trailing slashes
  • Apply normalization consistently across all project comparison logic

Issue #11674 - Reserved Device Names

Windows reserved device names (CON, PRN, AUX, NUL, COM1-9, LPT1-9) were causing directory check failures when included in project paths.

Solution: Added validation to prevent Windows reserved device names from being added to directory checks.

Changes

Modified Files

  • packages/opencode/src/installation/index.ts - Add timeout protection for package manager detection
  • packages/app/src/pages/layout.tsx - Implement path normalization for project comparison
  • packages/app/src/context/server.tsx - Use normalized paths for project operations
  • packages/opencode/src/cli/cmd/tui/util/clipboard.ts - Remove deprecated API call
  • packages/opencode/src/cli/cmd/tui/app.tsx - Remove unsupported autoFocus property

Important Note About TypeCheck

Note: The autoFocus property was removed from CliRendererConfig as it's not supported by the current version of @opentui/core. This is a code fix, not just a local environment issue.

Other potential TypeCheck errors related to missing dependencies (e.g., @gitlab/gitlab-ai-provider VERSION export, ai-gateway-provider modules) are local environment issues. The remote repository's bun.lock already contains all required dependencies (@gitlab/gitlab-ai-provider@3.4.0, ai-gateway-provider@2.3.1). These should resolve automatically in CI.

Testing

  • ✅ Manual testing on Windows for all three issues
  • ✅ Path normalization tested with various path formats
  • ✅ Timeout protection tested with hanging package manager commands
  • ✅ Reserved device names validation tested

Related Issues

@github-actions
Copy link
Contributor

github-actions bot commented Feb 2, 2026

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions
Copy link
Contributor

github-actions bot commented Feb 2, 2026

The following comment was made by an LLM, it may be inaccurate:

Potential Duplicate Found

PR #11668: fix(app): normalize Windows paths for consistent project matching

This PR appears to be directly related to the current PR #11724. Both are addressing the same issue of normalizing Windows paths to prevent duplicate project creation. PR #11668 likely implements the same or very similar solution (path normalization for consistent project matching on Windows). You should check if this PR is already merged or if it's addressing the same issue to determine if PR #11724 is redundant.

01luyicheng added 9 commits February 4, 2026 18:35
…ory checks and simplify bash description parameter
- 使用Promise.race()包装check.command()调用
- 添加5秒超时保护,防止包管理器检测命令挂起
- 捕获超时错误并继续尝试下一个检测
- 添加中文注释说明修复内容
- 使用项目已有的withTimeout工具函数替代手动实现,避免内存泄漏
- 为包管理器检测添加5秒超时保护
- 添加调试日志(debug/info/warn)便于问题排查
- 改进错误信息,包含包管理器名称
- 将超时时间定义为常量TIMEOUT_MS,并添加TODO注释说明未来需要移到配置文件

修复内容:
- packages/opencode/src/installation/index.ts: method()函数

测试:TypeCheck通过(12个任务全部成功)
- 在server.tsx中添加normalizePathForComparison函数,统一处理Windows路径规范化
- 在layout.tsx中添加normalizePathForComparison函数,统一处理Windows路径规范化
- 修改workspaceKey函数使用规范化路径
- 修改parseDeepLink函数返回规范化路径
- 修改项目去重逻辑使用规范化路径比较
- 修改所有路径比较的地方使用规范化路径,包括:
  - currentProject
  - closeProject
  - SortableProject.selected
  - handleDragOver
  - handleWorkspaceDragOver
  - SortableWorkspace.local和active
  - ProjectDragOverlay
  - SortableProject.active
  - label函数
  - workspaceIds函数

修复内容:
- 统一斜杠为正斜杠
- 统一为小写(Windows)
- 移除末尾斜杠

这确保了在Windows上,同一物理路径的不同表示形式(大小写、斜杠类型、末尾斜杠)不会被当作不同项目。
- 创建共享工具模块 packages/app/src/utils/path.ts
- 将 normalizePathForComparison 函数移至共享模块
- 添加完整的 JSDoc 注释和输入验证
- 修复 parseDeepLink 返回原始路径而非规范化路径
- 统一 workspaceKey 的使用,仅使用规范化路径作为键
- 消除 server.tsx 和 layout.tsx 中的重复代码
- 修复类型安全问题,添加显式返回类型声明

修复Issue anomalyco#11666: Windows路径规范化不一致导致重复创建项目
The copyToClipboardOSC52 method was removed from @opentui/core in recent updates.
This commit removes the call to this deprecated method and falls back to
using the native clipboard methods (clipboardy, osascript, wl-copy, xclip, etc.)
- 在server.tsx中添加normalizePathForComparison函数,统一处理Windows路径规范化
- 在layout.tsx中添加normalizePathForComparison函数,统一处理Windows路径规范化
- 修改workspaceKey函数使用规范化路径
- 修改parseDeepLink函数返回规范化路径
- 修改项目去重逻辑使用规范化路径比较
- 修改所有路径比较的地方使用规范化路径,包括:
  - currentProject
  - closeProject
  - SortableProject.selected
  - handleDragOver
  - handleWorkspaceDragOver
  - SortableWorkspace.local和active
  - ProjectDragOverlay
  - SortableProject.active
  - label函数
  - workspaceIds函数

修复内容:
- 统一斜杠为正斜杠
- 统一为小写(Windows)
- 移除末尾斜杠

这确保了在Windows上,同一物理路径的不同表示形式(大小写、斜杠类型、末尾斜杠)不会被当作不同项目。
- 创建共享工具模块 packages/app/src/utils/path.ts
- 将 normalizePathForComparison 函数移至共享模块
- 添加完整的 JSDoc 注释和输入验证
- 修复 parseDeepLink 返回原始路径而非规范化路径
- 统一 workspaceKey 的使用,仅使用规范化路径作为键
- 消除 server.tsx 和 layout.tsx 中的重复代码
- 修复类型安全问题,添加显式返回类型声明

修复Issue anomalyco#11666: Windows路径规范化不一致导致重复创建项目
@01luyicheng 01luyicheng changed the title fix: 修复Windows上深度链接重复创建项目问题(Issue #11666) fix: Windows CLI and deep link issues (#11657, #11666, #11674) Feb 4, 2026
adamdotdevin and others added 24 commits February 5, 2026 16:22
- 使用fileURLToPath替代new URL().pathname以正确处理Windows路径
- 修改packages/sdk/js/package.json的build脚本使用bun run
- 修复的文件:
  - packages/sdk/js/script/build.ts
  - packages/sdk/js/script/publish.ts
  - packages/plugin/script/publish.ts
  - script/publish.ts
  - packages/sdk/js/package.json

这些修复解决了Windows CI测试失败的问题。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Comments