Skip to content

Bug: OpenCode provider always disabled on Windows #21

@tonyparkdev

Description

@tonyparkdev

Description

On Windows, is_opencode_available() always returns false because check_opencode_available() in src/services/opencode.rs has a #[cfg(windows)] { return false; } block before the COKAC_OPENCODE_PATH environment variable check and the where opencode fallback.

This means:

  1. The OpenCode provider always shows ✗ on Windows
  2. Setting COKAC_OPENCODE_PATH has no effect
  3. The where opencode detection code (line 76-83) is unreachable dead code

Steps to Reproduce

  1. Install OpenCode on Windows (npm install -g opencode-ai)
  2. Optionally set COKAC_OPENCODE_PATH environment variable
  3. Run cokacdir --ccserver <token>
  4. Observe OpenCode shows ✗

Root Cause

// src/services/opencode.rs
fn check_opencode_available() -> bool {
    #[cfg(windows)]
    {
        return false;  // ← Runs BEFORE COKAC_OPENCODE_PATH check
    }

    if let Ok(val) = std::env::var("COKAC_OPENCODE_PATH") {
        // Never reached on Windows
    }

    #[cfg(windows)]
    {
        // where opencode — also never reached (dead code)
    }
}

Proposed Fix

Remove the early return false and move COKAC_OPENCODE_PATH check first, so the where opencode fallback can also execute on Windows.

Environment

  • OS: Windows 11 Enterprise
  • OpenCode: 1.3.12 (npm)
  • cokacdir: latest main

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions