A self-improving RLM agent for coding workflows and long-running autonomous tasks.
Rust
fix(coding-agent): launch OAuth URLs without shell (#457)
Sebastian Müller103a0a055547
diff --git a/packages/coding-agent/CHANGELOG.md b/packages/coding-agent/CHANGELOG.mdindex d47bd93aad..f5c41299de 100644--- a/packages/coding-agent/CHANGELOG.md+++ b/packages/coding-agent/CHANGELOG.md@@ -2,6 +2,7 @@## [Unreleased]+- Fixed OAuth browser launch URLs being interpreted by the system shell.- Changed long live session opens to render a bounded recent transcript tail while preserving full prompt history ([#343](https://github.com/PrimeIntellect-ai/prime-agent/pull/343) by [@sethkarten](https://github.com/sethkarten)).## [0.3.2] - 2026-07-20diff --git a/packages/coding-agent/src/modes/interactive/components/login-dialog.ts b/packages/coding-agent/src/modes/interactive/components/login-dialog.tsindex 91e0c4fd38..60934fbcd0 100644--- a/packages/coding-agent/src/modes/interactive/components/login-dialog.ts+++ b/packages/coding-agent/src/modes/interactive/components/login-dialog.ts@@ -1,3 +1,4 @@+import { win32 } from "node:path";import { getOAuthProviders } from "@earendil-works/pi-ai/oauth";import {type Component,@@ -11,7 +12,7 @@ import {truncateToWidth,visibleWidth,} from "@earendil-works/pi-tui";-import { exec } from "child_process";+import { execFile } from "child_process";import { PRIME_BUTTERFLY_LOGO } from "../../../themes/prime-logo.js";import { theme } from "../theme/theme.js";import { keyHint } from "./keybinding-hints.js";@@ -156,8 +157,17 @@ export class LoginDialogComponent extends Container implements Focusable {}// Try to open browser- const openCmd = process.platform === "darwin" ? "open" : process.platform === "win32" ? "start" : "xdg-open";- exec(`${openCmd} "${url}"`);+ const [command, ...args] =+ process.platform === "darwin"+ ? ["open", url]+ : process.platform === "win32"+ ? [+ win32.join(process.env.SystemRoot ?? "C:\\Windows", "System32", "rundll32.exe"),+ "url.dll,FileProtocolHandler",+ url,+ ]+ : ["xdg-open", url];+ execFile(command, args, () => {});this.tui.requestRender();}diff --git a/packages/coding-agent/test/login-dialog.test.ts b/packages/coding-agent/test/login-dialog.test.tsindex a231e03148..a34a290857 100644--- a/packages/coding-agent/test/login-dialog.test.ts+++ b/packages/coding-agent/test/login-dialog.test.ts@@ -6,11 +6,11 @@ import { initTheme } from "../src/modes/interactive/theme/theme.js";import { PRIME_BUTTERFLY_LOGO } from "../src/themes/prime-logo.js";const mocks = vi.hoisted(() => ({- exec: vi.fn(),+ execFile: vi.fn(),}));vi.mock("child_process", () => ({- exec: mocks.exec,+ execFile: mocks.execFile,}));function createFakeTui(): TUI {@@ -25,7 +25,7 @@ describe("LoginDialogComponent", () => {});beforeEach(() => {- mocks.exec.mockClear();+ mocks.execFile.mockClear();});afterEach(() => {@@ -47,7 +47,30 @@ describe("LoginDialogComponent", () => {expect(output).not.toContain("click to open");expect(output).not.toContain("─");expect(output).not.toContain("> ");- expect(mocks.exec).toHaveBeenCalledOnce();+ });++ it.each([+ ["darwin", []],+ ["linux", []],+ ["win32", ["url.dll,FileProtocolHandler"]],+ ] as const)("passes hostile URLs as a single argument on %s", (platform, prefixArgs) => {+ const platformSpy = vi.spyOn(process, "platform", "get").mockReturnValue(platform);+ try {+ const dialog = new LoginDialogComponent(createFakeTui(), "anthropic", () => {}, "Anthropic");+ const url = "https://example.com/oauth?state=$(touch /tmp/pwned);whoami&pipe=|id";+ const command =+ platform === "darwin"+ ? "open"+ : platform === "linux"+ ? "xdg-open"+ : `${process.env.SystemRoot ?? String.raw`C:\Windows`}\\System32\\rundll32.exe`;++ dialog.showAuth(url);++ expect(mocks.execFile).toHaveBeenCalledWith(command, [...prefixArgs, url], expect.any(Function));+ } finally {+ platformSpy.mockRestore();+ }});it("renders sign-in URLs as OSC 8 hyperlinks when supported", () => {