Skip to content

Commit e53891b

Browse files
author
Prompsit CI
committed
Mirror d560cd7 (2026-04-10)
1 parent 0d4952f commit e53891b

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

src/commands/device-flow.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Coordinates: initiate → display code → open browser → poll → return credentials.
33
// Works in both CLI mode (ora spinner) and REPL mode (terminal.dim).
44

5-
import { spawn } from "node:child_process";
5+
import { execFileSync, spawn } from "node:child_process";
66
import ora, { type Ora } from "ora";
77
import type { AuthResource } from "../api/resources/auth.ts";
88
import { getApiClient } from "../api/client.ts";
@@ -47,7 +47,18 @@ async function openBrowser(url: string): Promise<boolean> {
4747
cmd = "open";
4848
args = [url];
4949
} else {
50-
cmd = "xdg-open";
50+
// Linux/WSL: fallback chain (GitHub CLI pattern — cli/browser)
51+
// wslview works in WSL, xdg-open works in native Linux
52+
const found = ["xdg-open", "wslview"].find((c) => {
53+
try {
54+
execFileSync("which", [c], { stdio: "ignore" });
55+
return true;
56+
} catch {
57+
return false;
58+
}
59+
});
60+
if (!found) return false;
61+
cmd = found;
5162
args = [url];
5263
}
5364

0 commit comments

Comments
 (0)