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

Open
opened 2026-02-16 18:18:44 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/11724

State: open
Merged: No


Problem Description

This PR fixes three Windows-specific issues:

  1. Issue #11657: Windows CLI startup hanging when package manager detection commands hang
  2. Issue #11666: Windows deep link duplicate project creation due to inconsistent path normalization
  3. Issue #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

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/11724 **State:** open **Merged:** No --- ## Problem Description This PR fixes three Windows-specific issues: 1. **Issue #11657**: Windows CLI startup hanging when package manager detection commands hang 2. **Issue #11666**: Windows deep link duplicate project creation due to inconsistent path normalization 3. **Issue #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 - Fixes #11657 - Fixes #11666 - Fixes #11674
yindo added the pull-request label 2026-02-16 18:18:44 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#13909