Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
254 changes: 0 additions & 254 deletions KEYBOARD_BINDINGS_AUDIT.txt

This file was deleted.

File renamed without changes.
6 changes: 6 additions & 0 deletions internal/data/chronicle_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package data
import (
"io"
"os"
"os/exec"
"path/filepath"
"sync"

Expand Down Expand Up @@ -51,6 +52,11 @@ func startPTY(binary string) (io.ReadWriteCloser, error) {

// findCopilotBinary returns the path to copilot.exe on Windows.
func findCopilotBinary() string {
// Try PATH first (matches Unix behavior).
if p, err := exec.LookPath("copilot"); err == nil {
return p
}

candidates := []string{
filepath.Join(os.Getenv("ProgramFiles"), "nodejs", "node_modules",
"@github", "copilot", "node_modules", "@github", "copilot-win32-x64", "copilot.exe"),
Expand Down
27 changes: 26 additions & 1 deletion internal/data/mq_coverage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,10 @@ func TestLastReindexTime_EmptyWAL(t *testing.T) {
// ---------------------------------------------------------------------------

func TestFindCopilotBinary_NoCandidates(t *testing.T) {
// Set environment to non-existent paths.
// Set environment to non-existent paths and isolate PATH.
t.Setenv("ProgramFiles", filepath.Join(t.TempDir(), "nonexistent"))
t.Setenv("APPDATA", "")
t.Setenv("PATH", t.TempDir())

got := findCopilotBinary()
if got != "" {
Expand All @@ -179,6 +180,7 @@ func TestFindCopilotBinary_NoCandidates(t *testing.T) {
func TestFindCopilotBinary_WithAPPDATA(t *testing.T) {
tmp := t.TempDir()
t.Setenv("ProgramFiles", filepath.Join(tmp, "nonexistent"))
t.Setenv("PATH", filepath.Join(tmp, "emptypath"))

// Create the APPDATA candidate path.
appdata := filepath.Join(tmp, "appdata")
Expand Down Expand Up @@ -206,6 +208,7 @@ func TestFindCopilotBinary_WithProgramFiles(t *testing.T) {
progFiles := filepath.Join(tmp, "Program Files")
t.Setenv("ProgramFiles", progFiles)
t.Setenv("APPDATA", "")
t.Setenv("PATH", filepath.Join(tmp, "emptypath"))

candidatePath := filepath.Join(progFiles, "nodejs", "node_modules",
"@github", "copilot", "node_modules", "@github", "copilot-win32-x64")
Expand All @@ -223,6 +226,28 @@ func TestFindCopilotBinary_WithProgramFiles(t *testing.T) {
}
}

func TestFindCopilotBinary_ViaPath(t *testing.T) {
tmp := t.TempDir()
t.Setenv("ProgramFiles", filepath.Join(tmp, "nonexistent"))
t.Setenv("APPDATA", "")

// Place a copilot.exe on PATH.
binDir := filepath.Join(tmp, "bin")
if err := os.MkdirAll(binDir, 0o755); err != nil {
t.Fatalf("creating bin dir: %v", err)
}
fakeBinary := filepath.Join(binDir, "copilot.exe")
if err := os.WriteFile(fakeBinary, []byte("fake"), 0o755); err != nil {
t.Fatalf("writing fake binary: %v", err)
}
t.Setenv("PATH", binDir)

got := findCopilotBinary()
if got != fakeBinary {
t.Errorf("findCopilotBinary() = %q, want %q", got, fakeBinary)
}
}

// ---------------------------------------------------------------------------
// Maintain — 56% coverage, test error branches
// ---------------------------------------------------------------------------
Expand Down
33 changes: 22 additions & 11 deletions internal/platform/paths.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"path/filepath"
"runtime"
"strings"
"sync"
)

const (
Expand Down Expand Up @@ -58,20 +59,30 @@ func SessionStorePath() (string, error) {
const wslMountRoot = "/mnt/c/Users"

// isWSL reports whether the current process is running inside Windows
// Subsystem for Linux.
// Subsystem for Linux. The result is cached after the first call since
// the WSL status cannot change during a process lifetime.
func isWSL() bool {
// WSL2 (and recent WSL1) always set WSL_DISTRO_NAME.
if os.Getenv("WSL_DISTRO_NAME") != "" {
return true
}
// Older WSL1 may not set the env var; fall back to /proc/version.
data, err := os.ReadFile("/proc/version")
if err != nil {
return false
}
return strings.Contains(strings.ToLower(string(data)), "microsoft")
wslOnce.Do(func() {
// WSL2 (and recent WSL1) always set WSL_DISTRO_NAME.
if os.Getenv("WSL_DISTRO_NAME") != "" {
wslCached = true
return
}
// Older WSL1 may not set the env var; fall back to /proc/version.
data, err := os.ReadFile("/proc/version")
if err != nil {
return
}
wslCached = strings.Contains(strings.ToLower(string(data)), "microsoft")
})
return wslCached
}

var (
wslOnce sync.Once
wslCached bool
)

// findWindowsSessionStore scans Windows user-profile directories under the
// default WSL mount for a Copilot session store database.
func findWindowsSessionStore() string {
Expand Down
Loading
Loading