[PR #1673] [CLOSED] feat(auth): improve Windows browser opening with fallback methods #10014

Closed
opened 2026-02-16 18:14:33 -05:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/anomalyco/opencode/pull/1673
Author: @Haadka
Created: 8/7/2025
Status: Closed

Base: devHead: feature/windows-virus-warning-auth


📝 Commits (1)

  • a83ff19 fix: Windows browser opening fallback methods

📊 Changes

2 files changed (+142 additions, -18 deletions)

View changed files

📝 packages/opencode/src/cli/cmd/auth.ts (+40 -18)
packages/opencode/src/util/windows.ts (+102 -0)

📄 Description

Problem

Fixes #1103

On Windows, antivirus software can block or delete PowerShell execution during authentication flows, causing browser opening to fail completely. This particularly affects Claude Pro/Max authentication where automatic browser opening is required for OAuth flows.

Solution

This PR adds smart Windows-specific fallback methods for opening URLs safely:

Changes Made

  1. New WindowsUtils module (src/util/windows.ts):

    • Platform detection for Windows-specific handling
    • Multiple fallback methods for opening URLs:
      • start "" command (cleanest approach)
      • rundll32 url.dll,FileProtocolHandler (Windows native)
      • explorer command (backup method)
    • User-friendly error messages with actionable guidance
  2. Enhanced authentication (src/cli/cmd/auth.ts):

    • Replaced direct open() calls with smart safeOpenUrl() function
    • Automatic fallback through multiple Windows-native methods
    • Clear error messages when all methods fail

Benefits

  • Resolves authentication failures on Windows due to antivirus blocking
  • Graceful degradation - tries multiple methods before giving manual instructions
  • Better user experience - helpful error messages instead of cryptic failures
  • No breaking changes - maintains existing behavior on non-Windows platforms

Testing

I've reproduced the original issue locally on Windows and confirmed these changes resolve the authentication blocking issue.

Files Changed

  • packages/opencode/src/util/windows.ts - New Windows utilities module
  • packages/opencode/src/cli/cmd/auth.ts - Enhanced authentication with fallbacks

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/anomalyco/opencode/pull/1673 **Author:** [@Haadka](https://github.com/Haadka) **Created:** 8/7/2025 **Status:** ❌ Closed **Base:** `dev` ← **Head:** `feature/windows-virus-warning-auth` --- ### 📝 Commits (1) - [`a83ff19`](https://github.com/anomalyco/opencode/commit/a83ff1974a6dd454b060f651dbd0b80c79accf58) fix: Windows browser opening fallback methods ### 📊 Changes **2 files changed** (+142 additions, -18 deletions) <details> <summary>View changed files</summary> 📝 `packages/opencode/src/cli/cmd/auth.ts` (+40 -18) ➕ `packages/opencode/src/util/windows.ts` (+102 -0) </details> ### 📄 Description ## Problem Fixes #1103 On Windows, antivirus software can block or delete PowerShell execution during authentication flows, causing browser opening to fail completely. This particularly affects Claude Pro/Max authentication where automatic browser opening is required for OAuth flows. ## Solution This PR adds smart Windows-specific fallback methods for opening URLs safely: ### Changes Made 1. **New `WindowsUtils` module** (`src/util/windows.ts`): - Platform detection for Windows-specific handling - Multiple fallback methods for opening URLs: - `start ""` command (cleanest approach) - `rundll32 url.dll,FileProtocolHandler` (Windows native) - `explorer` command (backup method) - User-friendly error messages with actionable guidance 2. **Enhanced authentication** (`src/cli/cmd/auth.ts`): - Replaced direct `open()` calls with smart `safeOpenUrl()` function - Automatic fallback through multiple Windows-native methods - Clear error messages when all methods fail ### Benefits - ✅ **Resolves authentication failures** on Windows due to antivirus blocking - ✅ **Graceful degradation** - tries multiple methods before giving manual instructions - ✅ **Better user experience** - helpful error messages instead of cryptic failures - ✅ **No breaking changes** - maintains existing behavior on non-Windows platforms ### Testing I've reproduced the original issue locally on Windows and confirmed these changes resolve the authentication blocking issue. ## Files Changed - `packages/opencode/src/util/windows.ts` - New Windows utilities module - `packages/opencode/src/cli/cmd/auth.ts` - Enhanced authentication with fallbacks --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-02-16 18:14:33 -05:00
yindo closed this issue 2026-02-16 18:14:33 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#10014