Skip to content

A self-improving RLM agent for coding workflows and long-running autonomous tasks.

Rust

Add login URL copy action (#647)

halleriteebfe770ef61b
diff --git a/README.md b/README.md
index 1d6f850c5f..b5646bd6cb 100644
--- a/README.md
+++ b/README.md
@@ -78,7 +78,7 @@ prime-agent shutdown [--force] # Stop every agent, worker, and background
```
## Built for Long-Running Work
-Prime Agent is built for long-running work, especially for evaluations in research. These features are available in the TUI, and when run autonomously.
+Prime Agent is built for long-running work, especially for evaluations in research. These features are available in the TUI, and when run autonomously.
- **Continual Harness:** `/refine` can persist focused, reviewable lessons as supplemental prompts, memories, reusable skill descriptions, or subagent specifications, with recorded refinement history. It does not replace packaging and reviewing new executable skills.
- **Direct agent-to-agent communication:** running agents and retained subagents can discover one another, exchange messages, and steer active work.
diff --git a/packages/coding-agent/CHANGELOG.md b/packages/coding-agent/CHANGELOG.md
index f7100b579a..e766736e7a 100644
--- a/packages/coding-agent/CHANGELOG.md
+++ b/packages/coding-agent/CHANGELOG.md
@@ -2,6 +2,7 @@
## [Unreleased]
+- Added a configurable copy action to login dialogs so raw sign-in URLs can be copied without selecting wrapped text ([#643](https://github.com/PrimeIntellect-ai/prime-agent/issues/643)).
- Added privacy-safe pseudonymous product analytics for onboarding, command use, execution modes, run outcomes, TTFT, latency, usage, tools, retries, and compactions, with disclosure and opt-out controls ([ENG-4682](https://linear.app/primeintellect/issue/ENG-4682/add-privacy-safe-posthog-analytics-to-prime-agent)).
- Changed sent agent messages in the IPython cell UI to show only the message text with a `╰─` gutter when expanded, matching received messages, and hid the raw `agent_message.send` receipt dictionary.
- Fixed Homebrew installs attempting to self-update their versioned Cellar keg instead of directing users to `brew upgrade prime-agent` ([#844](https://github.com/PrimeIntellect-ai/prime-agent/issues/844))
diff --git a/packages/coding-agent/docs/keybindings.md b/packages/coding-agent/docs/keybindings.md
index 8ea87a7ed6..2f21fc7c85 100644
--- a/packages/coding-agent/docs/keybindings.md
+++ b/packages/coding-agent/docs/keybindings.md
@@ -98,6 +98,7 @@ Modifier combinations: `ctrl+shift+x`, `alt+ctrl+x`, `ctrl+shift+alt+x`, `ctrl+1
| `app.suspend` | `ctrl+z` (none on Windows) | Suspend to background |
| `app.editor.external` | `ctrl+g` | Open in external editor (`$VISUAL` or `$EDITOR`) |
| `app.clipboard.pasteImage` | `ctrl+v` (`alt+v` on Windows) | Paste image from clipboard |
+| `app.clipboard.copyLoginUrl` | `c`, `alt+c` | Copy the sign-in URL from a login dialog |
### Sessions
diff --git a/packages/coding-agent/src/core/keybindings.ts b/packages/coding-agent/src/core/keybindings.ts
index a0762e44f9..a880b56320 100644
--- a/packages/coding-agent/src/core/keybindings.ts
+++ b/packages/coding-agent/src/core/keybindings.ts
@@ -30,6 +30,7 @@ export interface AppKeybindings {
"app.message.followUp": true;
"app.message.dequeue": true;
"app.clipboard.pasteImage": true;
+ "app.clipboard.copyLoginUrl": true;
"app.session.new": true;
"app.session.tree": true;
"app.session.fork": true;
@@ -118,6 +119,10 @@ export const KEYBINDINGS = {
defaultKeys: process.platform === "win32" ? "alt+v" : "ctrl+v",
description: "Paste image from clipboard",
},
+ "app.clipboard.copyLoginUrl": {
+ defaultKeys: ["c", "alt+c"],
+ description: "Copy login URL",
+ },
"app.session.new": { defaultKeys: [], description: "Start a new session" },
"app.session.tree": { defaultKeys: [], description: "Open session tree" },
"app.session.fork": { defaultKeys: [], description: "Fork current session" },
diff --git a/packages/coding-agent/src/modes/interactive/components/login-dialog.ts b/packages/coding-agent/src/modes/interactive/components/login-dialog.ts
index 60934fbcd0..be41de0a3b 100644
--- a/packages/coding-agent/src/modes/interactive/components/login-dialog.ts
+++ b/packages/coding-agent/src/modes/interactive/components/login-dialog.ts
@@ -14,8 +14,9 @@ import {
} from "@earendil-works/pi-tui";
import { execFile } from "child_process";
import { PRIME_BUTTERFLY_LOGO } from "../../../themes/prime-logo.js";
+import { copyToClipboard } from "../../../utils/clipboard.js";
import { theme } from "../theme/theme.js";
-import { keyHint } from "./keybinding-hints.js";
+import { formatKeyText, keyHint } from "./keybinding-hints.js";
import { MenuPanel, MenuSearchInput } from "./menu-panel.js";
import { shouldTreatAsBack } from "./modal-back.js";
@@ -31,6 +32,16 @@ function centeredLine(text: string, width: number): string {
return " ".repeat(left) + content + " ".repeat(padding - left);
}
+function isTextEntryKeybinding(key: string): boolean {
+ const parts = key.toLowerCase().split("+");
+ const keyPart = parts.at(-1);
+ return !parts.includes("ctrl") && !parts.includes("alt") && (keyPart === "space" || keyPart?.length === 1);
+}
+
+function isPrintableInput(data: string): boolean {
+ return data.length === 1 && data >= " " && data !== "\x7f";
+}
+
class PrimeLoginHeader implements Component {
invalidate(): void {
// Header render is derived from the current theme.
@@ -72,6 +83,8 @@ export class LoginDialogComponent extends Container implements Focusable {
private inputVisible = false;
private continueResolver?: () => void;
private continueRejecter?: (error: Error) => void;
+ private authUrl?: string;
+ private authActions?: Text;
// Focusable implementation - propagate to input for IME cursor positioning
private _focused = false;
@@ -143,13 +156,15 @@ export class LoginDialogComponent extends Container implements Focusable {
*/
showAuth(url: string, instructions?: string): void {
this.startContent();
+ this.authUrl = url;
this.addSectionTitle("Browser sign-in");
this.addMutedText("The sign-in page should already be opening. If it did not open, use the link below.");
this.contentContainer.addChild(new Spacer(1));
this.addLabel("Sign-in link");
const linkedUrl = getCapabilities().hyperlinks ? `\x1b]8;;${url}\x07${url}\x1b]8;;\x07` : url;
this.contentContainer.addChild(new Text(theme.fg("text", linkedUrl), 0, 0));
- this.contentContainer.addChild(new Text(theme.fg("muted", keyHint("tui.select.cancel", "cancel")), 0, 0));
+ this.authActions = new Text(this.getAuthActionsText(), 0, 0);
+ this.contentContainer.addChild(this.authActions);
if (instructions) {
this.contentContainer.addChild(new Spacer(1));
@@ -181,6 +196,7 @@ export class LoginDialogComponent extends Container implements Focusable {
this.addMutedText(prompt);
this.contentContainer.addChild(this.input);
this.inputVisible = true;
+ this.authActions?.setText(this.getAuthActionsText());
this.contentContainer.addChild(new Text(theme.fg("muted", keyHint("tui.select.cancel", "cancel")), 0, 0));
this.tui.requestRender();
@@ -209,6 +225,7 @@ export class LoginDialogComponent extends Container implements Focusable {
}
this.contentContainer.addChild(this.input);
this.inputVisible = true;
+ this.authActions?.setText(this.getAuthActionsText());
this.contentContainer.addChild(
new Text(
theme.fg("muted", `${keyHint("tui.select.confirm", "submit")} ${keyHint("tui.select.cancel", "cancel")}`),
@@ -283,6 +300,8 @@ export class LoginDialogComponent extends Container implements Focusable {
private startContent(): void {
this.contentContainer.clear();
+ this.authUrl = undefined;
+ this.authActions = undefined;
// The cleared panel no longer shows the paste field.
this.inputVisible = false;
if (this.isPrimeInference) {
@@ -324,9 +343,58 @@ export class LoginDialogComponent extends Container implements Focusable {
this.contentContainer.addChild(new Text(theme.fg("muted", text), 0, 0));
}
+ private getAuthActionsText(status?: "copied" | "failed"): string {
+ const configuredCopyKeys = getKeybindings().getKeys("app.clipboard.copyLoginUrl");
+ const copyKeys = this.inputVisible
+ ? configuredCopyKeys.filter((key) => !isTextEntryKeybinding(key))
+ : configuredCopyKeys.slice(0, 1);
+ const copyHint =
+ copyKeys.length > 0
+ ? theme.fg("dim", formatKeyText(copyKeys.join("/"))) +
+ theme.fg("muted", ` ${status === "failed" ? "retry" : "copy"}`)
+ : undefined;
+ const statusText =
+ status === "copied"
+ ? theme.fg("success", "Copied sign-in link")
+ : status === "failed"
+ ? theme.fg("error", "Failed to copy sign-in link")
+ : undefined;
+ return [statusText, copyHint, keyHint("tui.select.cancel", "cancel")]
+ .filter((part): part is string => part !== undefined)
+ .join(" ");
+ }
+
+ private async copyAuthUrl(): Promise<void> {
+ const url = this.authUrl;
+ const actions = this.authActions;
+ if (!url || !actions) return;
+
+ try {
+ await copyToClipboard(url);
+ if (this.authUrl === url && this.authActions === actions) {
+ actions.setText(this.getAuthActionsText("copied"));
+ this.tui.requestRender();
+ }
+ } catch {
+ if (this.authUrl === url && this.authActions === actions) {
+ actions.setText(this.getAuthActionsText("failed"));
+ this.tui.requestRender();
+ }
+ }
+ }
+
handleInput(data: string): void {
const kb = getKeybindings();
+ if (
+ this.authUrl &&
+ kb.matches(data, "app.clipboard.copyLoginUrl") &&
+ (!this.inputVisible || !isPrintableInput(data))
+ ) {
+ void this.copyAuthUrl();
+ return;
+ }
+
// Left arrow acts as "back" like Esc. While the editable field is actually
// shown, only treat it as back at the start of the text so left still moves
// the cursor mid-edit; on info/continue screens there is no field to guard.
diff --git a/packages/coding-agent/test/login-dialog.test.ts b/packages/coding-agent/test/login-dialog.test.ts
index a34a290857..34e7695bdc 100644
--- a/packages/coding-agent/test/login-dialog.test.ts
+++ b/packages/coding-agent/test/login-dialog.test.ts
@@ -1,11 +1,19 @@
-import { resetCapabilitiesCache, setCapabilities, type TUI, visibleWidth } from "@earendil-works/pi-tui";
+import {
+ resetCapabilitiesCache,
+ setCapabilities,
+ setKeybindings,
+ type TUI,
+ visibleWidth,
+} from "@earendil-works/pi-tui";
import stripAnsi from "strip-ansi";
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
+import { KeybindingsManager } from "../src/core/keybindings.js";
import { LoginDialogComponent } from "../src/modes/interactive/components/login-dialog.js";
import { initTheme } from "../src/modes/interactive/theme/theme.js";
import { PRIME_BUTTERFLY_LOGO } from "../src/themes/prime-logo.js";
const mocks = vi.hoisted(() => ({
+ copyToClipboard: vi.fn(),
execFile: vi.fn(),
}));
@@ -13,6 +21,10 @@ vi.mock("child_process", () => ({
execFile: mocks.execFile,
}));
+vi.mock("../src/utils/clipboard.js", () => ({
+ copyToClipboard: mocks.copyToClipboard,
+}));
+
function createFakeTui(): TUI {
return {
requestRender: vi.fn(),
@@ -25,6 +37,9 @@ describe("LoginDialogComponent", () => {
});
beforeEach(() => {
+ setKeybindings(new KeybindingsManager());
+ mocks.copyToClipboard.mockReset();
+ mocks.copyToClipboard.mockResolvedValue(undefined);
mocks.execFile.mockClear();
});
@@ -42,6 +57,7 @@ describe("LoginDialogComponent", () => {
expect(output).toContain("Browser sign-in");
expect(output).toContain("Sign-in link");
expect(output).toContain("https://example.com/oauth?client_id=test");
+ expect(output).toContain("C copy");
expect(output).toContain("Next step");
expect(output).toContain("Complete login in your browser.");
expect(output).not.toContain("click to open");
@@ -49,6 +65,31 @@ describe("LoginDialogComponent", () => {
expect(output).not.toContain("> ");
});
+ it("copies the raw sign-in URL with the configured shortcut", async () => {
+ const dialog = new LoginDialogComponent(createFakeTui(), "anthropic", () => {}, "Anthropic");
+ const url = "https://example.com/oauth?client_id=test&redirect_uri=https%3A%2F%2Flocalhost%2Fcallback";
+
+ dialog.showAuth(url);
+ dialog.handleInput("c");
+
+ await vi.waitFor(() => expect(mocks.copyToClipboard).toHaveBeenCalledWith(url));
+ expect(stripAnsi(dialog.render(48).join("\n"))).toContain("Copied sign-in link");
+ });
+
+ it("honors a customized login URL copy shortcut", async () => {
+ setKeybindings(new KeybindingsManager({ "app.clipboard.copyLoginUrl": "ctrl+y" }));
+ const dialog = new LoginDialogComponent(createFakeTui(), "anthropic", () => {}, "Anthropic");
+ const url = "https://example.com/oauth";
+
+ dialog.showAuth(url);
+ expect(stripAnsi(dialog.render(88).join("\n"))).toContain("Ctrl+Y copy");
+ dialog.handleInput("c");
+ expect(mocks.copyToClipboard).not.toHaveBeenCalled();
+
+ dialog.handleInput("\x19");
+ await vi.waitFor(() => expect(mocks.copyToClipboard).toHaveBeenCalledWith(url));
+ });
+
it.each([
["darwin", []],
["linux", []],