Skip to content

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

Rust

render provider login inline under the chat (#2331)

ktf5859162cc5c
diff --git a/packages/coding-agent/.changes/eng-6135-inline-login.md b/packages/coding-agent/.changes/eng-6135-inline-login.md
new file mode 100644
index 0000000000..fbe63e24c0
--- /dev/null
+++ b/packages/coding-agent/.changes/eng-6135-inline-login.md
@@ -0,0 +1,6 @@
+- Changed provider logins, including the in-flow team and account selectors, to render inline under the chat in the compact picker style instead of a centered full-pane modal.
+- Changed finishing a provider login to stay on the providers tab instead of forcing the models picker open; the models tab refreshes in the background so it is ready when opened.
+- Added a separator rule above the inline provider login panel so the login section stands out from the conversation above it.
+- Tightened the inline provider login panel: the sign-in link and provider guidance lead the panel, the repeated browser-open copy and section labels are gone, and the paste field keeps a single key-hint line.
+- Fixed inline menu panels dropping their subtitle, so multi-line provider prompts keep every instruction line.
+- Renamed the Prime team selection heading to "Select a Prime Team:".
diff --git a/packages/coding-agent/src/modes/interactive/auth-flows.ts b/packages/coding-agent/src/modes/interactive/auth-flows.ts
index 6e7e7e76ae..f3556e1562 100644
--- a/packages/coding-agent/src/modes/interactive/auth-flows.ts
+++ b/packages/coding-agent/src/modes/interactive/auth-flows.ts
@@ -1,6 +1,6 @@
import * as path from "node:path";
import { getProviders, type OAuthProviderId, type OAuthSelectPrompt } from "@earendil-works/pi-ai";
-import type { OverlayHandle, TUI } from "@earendil-works/pi-tui";
+import type { Component, TUI } from "@earendil-works/pi-tui";
import { getAuthPath, getDocsPath } from "../../config.js";
import type { ModelRegistry } from "../../core/model-registry.js";
import {
@@ -19,7 +19,6 @@ import {
} from "../../core/prime-inference-auth.js";
import { BUILT_IN_PROVIDER_DISPLAY_NAMES } from "../../core/provider-display-names.js";
import { SERPER_CREDENTIAL_ID, SERPER_CREDENTIAL_NAME } from "../../core/websearch-credential.js";
-import { showFullPaneOverlay } from "./components/centered-overlay.js";
import { ExtensionSelectorComponent } from "./components/extension-selector.js";
import { LoginDialogComponent } from "./components/login-dialog.js";
import {
@@ -97,6 +96,14 @@ export interface ProviderAuthFlowsHost {
readonly modelRegistry: ModelRegistry;
showStatus(message: string): void;
showError(message: string): void;
+ /**
+ * Mount a provider-auth panel (login dialog or in-flow selector) in place of
+ * the prompt area. Returns a callback that unmounts the panel and restores
+ * the previous content and focus.
+ */
+ showAuthPanel(component: Component): () => void;
+ /** Terminal rows available to auth panels; selectors size their lists to it. */
+ getAuthPanelRows(): number;
/** Models currently visible to the host; used to detect providers configured via external credentials. */
getAvailableModels(): Promise<ReadonlyArray<{ provider: string }>>;
/** Invoked after stored credentials change so the host can refresh dependent UI. */
@@ -146,27 +153,23 @@ export class ProviderAuthFlows {
}
return new Promise((resolve) => {
- let handle: OverlayHandle | undefined;
- const close = () => {
- handle?.hide();
- this.host.ui.requestRender();
- };
+ let close: (() => void) | undefined;
const selector = new OAuthSelectorComponent(
"login",
this.host.modelRegistry.authStorage,
providerOptions,
async (providerOption: AuthSelectorProvider) => {
- close();
+ close?.();
resolve(await this.loginProvider(providerOption));
},
() => {
- close();
+ close?.();
resolve({ status: "cancelled" });
},
(providerId) => this.host.modelRegistry.getProviderAuthStatus(providerId),
- { getRows: () => this.host.ui.terminal.rows, initialCategory },
+ { getRows: () => this.host.getAuthPanelRows(), initialCategory, inline: true },
);
- handle = showFullPaneOverlay(this.host.ui, selector, 78);
+ close = this.host.showAuthPanel(selector);
});
}
@@ -194,17 +197,13 @@ export class ProviderAuthFlows {
}
return new Promise((resolve) => {
- let handle: OverlayHandle | undefined;
- const close = () => {
- handle?.hide();
- this.host.ui.requestRender();
- };
+ let close: (() => void) | undefined;
const selector = new OAuthSelectorComponent(
"logout",
this.host.modelRegistry.authStorage,
providerOptions,
async (providerOption: AuthSelectorProvider) => {
- close();
+ close?.();
try {
this.host.modelRegistry.authStorage.logout(providerOption.id);
@@ -222,13 +221,13 @@ export class ProviderAuthFlows {
}
},
() => {
- close();
+ close?.();
resolve(null);
},
undefined,
- { getRows: () => this.host.ui.terminal.rows },
+ { getRows: () => this.host.getAuthPanelRows(), inline: true },
);
- handle = showFullPaneOverlay(this.host.ui, selector, 78);
+ close = this.host.showAuthPanel(selector);
});
}
@@ -343,11 +342,7 @@ export class ProviderAuthFlows {
private async showBedrockSetupDialog(providerId: string, providerName: string): Promise<AuthenticationResult> {
const dialog = new LoginDialogComponent(this.host.ui, providerId, () => {}, providerName, "Amazon Bedrock setup");
- const handle = showFullPaneOverlay(this.host.ui, dialog, 88);
- const closeDialog = () => {
- handle.hide();
- this.host.ui.requestRender();
- };
+ const closeDialog = this.host.showAuthPanel(dialog);
try {
await dialog.showContinueInfo([
@@ -378,25 +373,21 @@ export class ProviderAuthFlows {
currentTeamId: string | undefined,
): Promise<PrimeTeam | null | undefined> {
return new Promise((resolve) => {
- let handle: OverlayHandle | undefined;
- const close = () => {
- handle?.hide();
- this.host.ui.requestRender();
- };
+ let close: (() => void) | undefined;
const selector = new PrimeTeamSelectorComponent(
teams,
currentTeamId,
(team) => {
- close();
+ close?.();
resolve(team);
},
() => {
- close();
+ close?.();
resolve(undefined);
},
- { getRows: () => this.host.ui.terminal.rows },
+ { getRows: () => this.host.getAuthPanelRows() },
);
- handle = showFullPaneOverlay(this.host.ui, selector, 78);
+ close = this.host.showAuthPanel(selector);
});
}
@@ -489,15 +480,7 @@ export class ProviderAuthFlows {
PRIME_INFERENCE_PROVIDER_NAME,
);
- const handle = showFullPaneOverlay(this.host.ui, dialog, {
- maxContentWidth: 88,
- suspendFullscreenMouse: true,
- });
-
- const closeDialog = () => {
- handle.hide();
- this.host.ui.requestRender();
- };
+ const closeDialog = this.host.showAuthPanel(dialog);
// The browser challenge gets its own controller so a manually pasted key
// can stop the polling without tearing down the dialog.
@@ -613,15 +596,7 @@ export class ProviderAuthFlows {
PRIME_AGENT_TRACES_PROVIDER_NAME,
);
- const handle = showFullPaneOverlay(this.host.ui, dialog, {
- maxContentWidth: 88,
- suspendFullscreenMouse: true,
- });
-
- const closeDialog = () => {
- handle.hide();
- this.host.ui.requestRender();
- };
+ const closeDialog = this.host.showAuthPanel(dialog);
const browserAbort = new AbortController();
const onDialogAbort = () => browserAbort.abort();
@@ -722,12 +697,7 @@ export class ProviderAuthFlows {
): Promise<AuthenticationResult> {
const dialog = new LoginDialogComponent(this.host.ui, providerId, (_success, _message) => {}, providerName);
- const handle = showFullPaneOverlay(this.host.ui, dialog, 88);
-
- const closeDialog = () => {
- handle.hide();
- this.host.ui.requestRender();
- };
+ const closeDialog = this.host.showAuthPanel(dialog);
try {
const apiKey = (await dialog.showPrompt("Enter API key:")).trim();
@@ -750,31 +720,24 @@ export class ProviderAuthFlows {
}
}
- private showOAuthLoginSelect(dialogHandle: OverlayHandle, prompt: OAuthSelectPrompt): Promise<string | undefined> {
+ private showOAuthLoginSelect(prompt: OAuthSelectPrompt): Promise<string | undefined> {
return new Promise((resolve) => {
- dialogHandle.setHidden(true);
- let selectorHandle: OverlayHandle | undefined;
- const restoreDialog = () => {
- selectorHandle?.hide();
- dialogHandle.setHidden(false);
- dialogHandle.focus();
- this.host.ui.requestRender();
- };
+ let close: (() => void) | undefined;
const labels = prompt.options.map((option) => option.label);
const selector = new ExtensionSelectorComponent(
prompt.message,
labels,
(optionLabel) => {
- restoreDialog();
+ close?.();
resolve(prompt.options.find((option) => option.label === optionLabel)?.id);
},
() => {
- restoreDialog();
+ close?.();
resolve(undefined);
},
- { getRows: () => this.host.ui.terminal.rows },
+ { getRows: () => this.host.getAuthPanelRows(), inline: true },
);
- selectorHandle = showFullPaneOverlay(this.host.ui, selector, 76);
+ close = this.host.showAuthPanel(selector);
});
}
@@ -791,10 +754,7 @@ export class ProviderAuthFlows {
const dialog = new LoginDialogComponent(this.host.ui, providerId, (_success, _message) => {}, providerName);
- const dialogHandle = showFullPaneOverlay(this.host.ui, dialog, {
- maxContentWidth: 88,
- suspendFullscreenMouse: true,
- });
+ const closeDialog = this.host.showAuthPanel(dialog);
let manualCodeResolve: ((code: string) => void) | undefined;
let manualCodeReject: ((err: Error) => void) | undefined;
@@ -803,11 +763,6 @@ export class ProviderAuthFlows {
manualCodeReject = reject;
});
- const closeDialog = () => {
- dialogHandle.hide();
- this.host.ui.requestRender();
- };
-
try {
await this.host.modelRegistry.authStorage.login(providerId as OAuthProviderId, {
onAuth: (info: { url: string; instructions?: string }) => {
@@ -841,7 +796,7 @@ export class ProviderAuthFlows {
dialog.showProgress(message);
},
- onSelect: (prompt: OAuthSelectPrompt) => this.showOAuthLoginSelect(dialogHandle, prompt),
+ onSelect: (prompt: OAuthSelectPrompt) => this.showOAuthLoginSelect(prompt),
onManualCodeInput: () => manualCodePromise,
diff --git a/packages/coding-agent/src/modes/interactive/components/extension-selector.ts b/packages/coding-agent/src/modes/interactive/components/extension-selector.ts
index c9dec2cd11..561af520ab 100644
--- a/packages/coding-agent/src/modes/interactive/components/extension-selector.ts
+++ b/packages/coding-agent/src/modes/interactive/components/extension-selector.ts
@@ -13,6 +13,7 @@ export interface ExtensionSelectorOptions {
tui?: TUI;
timeout?: number;
getRows?: () => number;
+ inline?: boolean;
}
const PREFERRED_VISIBLE_OPTIONS = 8;
@@ -49,6 +50,7 @@ export class ExtensionSelectorComponent extends Container {
compactItemRows: 1,
});
private readonly viewport: MenuViewportProvider;
+ private readonly inline: boolean;
constructor(
title: string,
@@ -62,6 +64,7 @@ export class ExtensionSelectorComponent extends Container {
this.options = options;
this.onSelectCallback = onSelect;
this.onCancelCallback = onCancel;
+ this.inline = opts?.inline === true;
const header = splitTitleAndDescription(title);
this.baseTitle = header.title;
this.reservedRows = OPTION_LIST_RESERVED_BASE_ROWS + header.descriptionRows;
@@ -71,6 +74,7 @@ export class ExtensionSelectorComponent extends Container {
this.panel = new MenuPanel({
title: header.title,
subtitle: header.description,
+ inline: this.inline,
});
this.addChild(this.panel);
@@ -83,9 +87,9 @@ export class ExtensionSelectorComponent extends Container {
);
}
- this.listContainer = new MenuList({ compact: true });
+ this.listContainer = new MenuList({ compact: true, inline: this.inline });
this.panel.addChild(this.listContainer);
- this.panel.addChild(new Spacer(1));
+ if (!this.inline) this.panel.addChild(new Spacer(1));
this.panel.addChild(
new Text(
rawKeyHint("↑↓", "navigate") +
@@ -128,6 +132,7 @@ export class ExtensionSelectorComponent extends Container {
new MenuRow({
primary: this.options[i] ?? "",
selected: isSelected,
+ inline: this.inline,
}),
);
}
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 f03cf8fd0c..55d765a05f 100644
--- a/packages/coding-agent/src/modes/interactive/components/login-dialog.ts
+++ b/packages/coding-agent/src/modes/interactive/components/login-dialog.ts
@@ -9,10 +9,7 @@ import {
Spacer,
Text,
type TUI,
- truncateToWidth,
- visibleWidth,
} from "@earendil-works/pi-tui";
-import { PRIME_BUTTERFLY_LOGO } from "../../../themes/prime-logo.js";
import { execFileHidden } from "../../../utils/child-process.js";
import { copyToClipboard } from "../../../utils/clipboard.js";
import { theme } from "../theme/theme.js";
@@ -20,18 +17,6 @@ import { formatKeyText, keyHint } from "./keybinding-hints.js";
import { MenuPanel, MenuSearchInput } from "./menu-panel.js";
import { shouldTreatAsBack } from "./modal-back.js";
-const PRIME_INFERENCE_PROVIDER_ID = "prime-inference";
-const PRIME_LOGO_LINES = PRIME_BUTTERFLY_LOGO.split("\n");
-const PRIME_LOGO_WIDTH = PRIME_LOGO_LINES.reduce((max, line) => Math.max(max, visibleWidth(line)), 0);
-
-function centeredLine(text: string, width: number): string {
- const safeWidth = Math.max(1, width);
- const content = truncateToWidth(text, safeWidth, "");
- const padding = Math.max(0, safeWidth - visibleWidth(content));
- const left = Math.floor(padding / 2);
- return " ".repeat(left) + content + " ".repeat(padding - left);
-}
-
function isTextEntryKeybinding(key: string): boolean {
const parts = key.toLowerCase().split("+");
const keyPart = parts.at(-1);
@@ -42,38 +27,13 @@ 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.
- }
-
- render(width: number): string[] {
- const safeWidth = Math.max(1, width);
- const logoWidth = Math.min(PRIME_LOGO_WIDTH, safeWidth);
- const logoLines = PRIME_LOGO_LINES.map((line) => {
- const paddedLogoLine = line + " ".repeat(Math.max(0, PRIME_LOGO_WIDTH - visibleWidth(line)));
- return centeredLine(theme.fg("text", truncateToWidth(paddedLogoLine, logoWidth, "")), safeWidth);
- });
- return [
- ...logoLines,
- centeredLine("", safeWidth),
- centeredLine(theme.fg("text", "Login to Prime Inference"), safeWidth),
- centeredLine(
- theme.fg("muted", "Connect your Prime Intellect account to enable Prime Inference models."),
- safeWidth,
- ),
- ];
- }
-}
-
/**
- * Login dialog component - replaces editor during OAuth login flow
+ * Login dialog component - replaces the prompt area during provider login flows
*/
export class LoginDialogComponent extends Container implements Focusable {
private contentContainer: Container;
private input: MenuSearchInput;
private tui: TUI;
- private readonly isPrimeInference: boolean;
private abortController = new AbortController();
private inputResolver?: (value: string) => void;
private inputRejecter?: (error: Error) => void;
@@ -108,13 +68,10 @@ export class LoginDialogComponent extends Container implements Focusable {
const providerInfo = getOAuthProviders().find((p) => p.id === providerId);
const providerName = providerNameOverride || providerInfo?.name || providerId;
- this.isPrimeInference = providerId === PRIME_INFERENCE_PROVIDER_ID;
const title = titleOverride ?? `Login to ${providerName}`;
- const panel = new MenuPanel({
- title: this.isPrimeInference ? "" : title,
- subtitle: this.isPrimeInference ? undefined : "Complete this step to continue setup.",
- });
+ // The top rule keeps the inline login section separate from the transcript.
+ const panel = new MenuPanel({ title, inline: true, topRule: true });
this.addChild(panel);
// Dynamic content area
@@ -122,7 +79,7 @@ export class LoginDialogComponent extends Container implements Focusable {
panel.addChild(this.contentContainer);
// Input (always present, used when needed)
- this.input = new MenuSearchInput("Paste value");
+ this.input = new MenuSearchInput("Paste value", true);
this.input.onSubmit = () => {
if (this.inputResolver) {
this.inputResolver(this.input.getValue());
@@ -157,19 +114,16 @@ 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.authActions = new Text(this.getAuthActionsText(), 0, 0);
- this.contentContainer.addChild(this.authActions);
-
+ // Provider instructions already describe the browser step.
if (instructions) {
- this.contentContainer.addChild(new Spacer(1));
this.addInstructions(instructions);
+ } else {
+ this.addMutedText("Complete the sign-in in your browser.");
}
+ this.authActions = new Text(this.getAuthActionsText(), 0, 0);
+ this.contentContainer.addChild(this.authActions);
// Try to open browser
const [command, ...args] =
@@ -192,17 +146,39 @@ export class LoginDialogComponent extends Container implements Focusable {
*/
showManualInput(prompt: string): Promise<string> {
this.addSectionSpacer();
- this.addSectionTitle("Manual fallback");
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.addInputField();
this.tui.requestRender();
return this.waitForInput();
}
+ /** Append content while keeping the key-hint row as the panel's last row. */
+ private addChildAboveHints(component: Component): void {
+ if (!this.authActions) {
+ this.contentContainer.addChild(component);
+ return;
+ }
+ this.contentContainer.removeChild(this.authActions);
+ this.contentContainer.addChild(component);
+ this.contentContainer.addChild(this.authActions);
+ this.authActions.setText(this.getAuthActionsText());
+ }
+
+ /** Append the paste field plus the single key-hint line at the panel bottom. */
+ private addInputField(): void {
+ this.contentContainer.removeChild(this.input);
+ if (this.authActions) {
+ this.contentContainer.removeChild(this.authActions);
+ } else {
+ this.authActions = new Text(this.getAuthActionsText(), 0, 0);
+ }
+ this.contentContainer.addChild(this.input);
+ this.inputVisible = true;
+ this.contentContainer.addChild(this.authActions);
+ this.authActions.setText(this.getAuthActionsText());
+ }
+
/**
* Wait for the next submission of the already-visible input.
*/
@@ -223,15 +199,7 @@ export class LoginDialogComponent extends Container implements Focusable {
if (placeholder) {
this.contentContainer.addChild(new Text(theme.fg("muted", `e.g., ${placeholder}`), 0, 0));
}
- 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")}`),
- 0,
- ),
- );
+ this.addInputField();
this.input.setValue("");
this.tui.requestRender();
@@ -281,8 +249,11 @@ export class LoginDialogComponent extends Container implements Focusable {
*/
showWaiting(message: string): void {
this.addSectionSpacer();
- this.contentContainer.addChild(new Text(theme.fg("accent", message), 0, 0));
- this.contentContainer.addChild(new Text(theme.fg("muted", keyHint("tui.select.cancel", "cancel")), 0, 0));
+ this.addChildAboveHints(new Text(theme.fg("accent", message), 0, 0));
+ if (!this.authActions) {
+ this.authActions = new Text(this.getAuthActionsText(), 0, 0);
+ this.contentContainer.addChild(this.authActions);
+ }
this.tui.requestRender();
}
@@ -294,7 +265,7 @@ export class LoginDialogComponent extends Container implements Focusable {
this.startContent();
this.addSectionTitle("Preparing authentication");
}
- this.contentContainer.addChild(new Text(theme.fg("muted", message), 0, 0));
+ this.addChildAboveHints(new Text(theme.fg("muted", message), 0, 0));
this.tui.requestRender();
}
@@ -304,11 +275,6 @@ export class LoginDialogComponent extends Container implements Focusable {
this.authActions = undefined;
// The cleared panel no longer shows the paste field.
this.inputVisible = false;
- if (this.isPrimeInference) {
- this.contentContainer.addChild(new PrimeLoginHeader());
- this.contentContainer.addChild(new Spacer(1));
- return;
- }
this.contentContainer.addChild(new Spacer(1));
}
@@ -317,7 +283,7 @@ export class LoginDialogComponent extends Container implements Focusable {
this.startContent();
return;
}
- this.contentContainer.addChild(new Spacer(1));
+ this.addChildAboveHints(new Spacer(1));
}
private addInstructions(instructions: string): void {
@@ -327,7 +293,6 @@ export class LoginDialogComponent extends Container implements Focusable {
this.contentContainer.addChild(new Text(theme.bold(theme.fg("text", codeMatch[1])), 0, 0));
return;
}
- this.addLabel("Next step");
this.contentContainer.addChild(new Text(theme.fg("text", instructions), 0, 0));
}
@@ -359,7 +324,8 @@ export class LoginDialogComponent extends Container implements Focusable {
: status === "failed"
? theme.fg("error", "Failed to copy sign-in link")
: undefined;
- return [statusText, copyHint, keyHint("tui.select.cancel", "cancel")]
+ const submitHint = this.inputVisible ? keyHint("tui.select.confirm", "submit") : undefined;
+ return [submitHint, statusText, copyHint, keyHint("tui.select.cancel", "cancel")]
.filter((part): part is string => part !== undefined)
.join(" ");
}
diff --git a/packages/coding-agent/src/modes/interactive/components/menu-panel.ts b/packages/coding-agent/src/modes/interactive/components/menu-panel.ts
index 9079f4e909..f41366b2dc 100644
--- a/packages/coding-agent/src/modes/interactive/components/menu-panel.ts
+++ b/packages/coding-agent/src/modes/interactive/components/menu-panel.ts
@@ -13,6 +13,8 @@ interface MenuPanelOptions {
title: string;
subtitle?: string;
inline?: boolean;
+ /** Inline only: prefix the panel with a full-width separator rule. */
+ topRule?: boolean;
}
export interface MenuViewportProvider {
@@ -259,7 +261,16 @@ export class MenuPanel extends Container {
override render(width: number): string[] {
if (this.options.inline) {
const lines: string[] = [];
+ if (this.options.topRule) {
+ lines.push(theme.fg("borderMuted", "─".repeat(Math.max(0, width))));
+ }
if (this.title) lines.push(theme.fg("muted", ` ${this.title}`));
+ const subtitle = this.options.subtitle?.trim();
+ if (subtitle) {
+ for (const line of wrapTextWithAnsi(subtitle, getMenuPanelInnerWidth(width, true))) {
+ lines.push(` ${theme.fg("muted", line)}`);
+ }
+ }
for (const child of this.children) {
lines.push(
...child
diff --git a/packages/coding-agent/src/modes/interactive/components/prime-team-selector.ts b/packages/coding-agent/src/modes/interactive/components/prime-team-selector.ts
index 62b438815d..30b6dd24c4 100644
--- a/packages/coding-agent/src/modes/interactive/components/prime-team-selector.ts
+++ b/packages/coding-agent/src/modes/interactive/components/prime-team-selector.ts
@@ -1,4 +1,4 @@
-import { Container, type Focusable, fuzzyFilter, getKeybindings, Spacer, TruncatedText } from "@earendil-works/pi-tui";
+import { Container, type Focusable, fuzzyFilter, getKeybindings, TruncatedText } from "@earendil-works/pi-tui";
import type { PrimeTeam } from "../../../core/prime-inference-auth.js";
import { theme } from "../theme/theme.js";
import {
@@ -47,12 +47,13 @@ export class PrimeTeamSelectorComponent extends Container implements Focusable {
this.filteredOptions = this.allOptions;
const panel = new MenuPanel({
- title: "Prime Team",
+ title: "Select a Prime Team:",
subtitle: "Choose which account pays for Prime Inference usage.",
+ inline: true,
});
this.addChild(panel);
- this.searchInput = new MenuSearchInput("Search teams");
+ this.searchInput = new MenuSearchInput("Search teams", true);
this.searchInput.onSubmit = () => {
const selected = this.filteredOptions[this.selectedIndex];
if (selected) {
@@ -60,9 +61,8 @@ export class PrimeTeamSelectorComponent extends Container implements Focusable {
}
};
panel.addChild(this.searchInput);
- panel.addChild(new Spacer(1));
- this.listContainer = new MenuList({ compact: () => this.listLayout.compact });
+ this.listContainer = new MenuList({ compact: () => this.listLayout.compact, inline: true });
panel.addChild(this.listContainer);
this.filterOptions("");
}
@@ -130,6 +130,7 @@ export class PrimeTeamSelectorComponent extends Container implements Focusable {
secondary: this.getSecondary(option),
meta: this.getMeta(option),
selected: i === this.selectedIndex,
+ inline: true,
}),
);
}
diff --git a/packages/coding-agent/src/modes/interactive/interactive-mode.ts b/packages/coding-agent/src/modes/interactive/interactive-mode.ts
index d78fa34274..445dabc4a9 100644
--- a/packages/coding-agent/src/modes/interactive/interactive-mode.ts
+++ b/packages/coding-agent/src/modes/interactive/interactive-mode.ts
@@ -29,6 +29,7 @@ import {
CombinedAutocompleteProvider,
type Component,
Container,
+ isFocusable,
Loader,
type LoaderIndicatorOptions,
Markdown,
@@ -1050,6 +1051,7 @@ export class InteractiveMode {
private connectionModelsRefreshVersion = 0;
private connectionModelsRefreshInFlight: { version: number; promise: Promise<AgentConnectionModel[]> } | undefined;
private closeConfigurationMenu: (() => void) | undefined;
+ private inlineAuthPanelClosers: (() => void)[] = [];
private configurationModelSelection: Promise<void> | undefined;
private connectionState: AgentConnectionState | undefined;
private connectionResourceSnapshot: AgentConnectionResourceSnapshot | undefined;
@@ -1896,7 +1898,9 @@ export class InteractiveMode {
}
splash.showProgress("Signing in to Prime Intellect...");
- const authResult = await this.createAuthFlows().runPrimeInferenceLogin();
+ // The splash covers the whole screen, so the login panel must render as an
+ // overlay above it instead of inline behind it.
+ const authResult = await this.createAuthFlows({ overlay: true }).runPrimeInferenceLogin();
if (authResult.status !== "success") {
splash.dismiss();
return;
@@ -3578,6 +3582,12 @@ export class InteractiveMode {
}
private resetExtensionUI(): void {
+ // Close inline auth panels before the configuration menu so a restored
+ // menu is still torn down by the closeConfigurationMenu call below.
+ // Innermost panels close first, ending at the pre-login content.
+ for (const close of this.inlineAuthPanelClosers.splice(0).reverse()) {
+ close();
+ }
this.closeConfigurationMenu?.();
this.cancelActiveConnectionExtensionUiRequests();
this.closeHeartbeatManager();
@@ -8372,7 +8382,6 @@ export class InteractiveMode {
this.getCachedModelCandidates(),
this.connectionConfiguredProviders,
);
- menu.setActiveTab("models");
refreshModels(true);
})
.catch((error) => {
@@ -8846,12 +8855,26 @@ export class InteractiveMode {
});
}
- private createAuthFlows(): ProviderAuthFlows {
+ private createAuthFlows(options: { overlay?: boolean } = {}): ProviderAuthFlows {
+ const showAuthPanel = options.overlay
+ ? (component: Component) => {
+ const handle = this.showFullPaneOverlay(component, {
+ maxContentWidth: 88,
+ suspendFullscreenMouse: true,
+ });
+ return () => {
+ handle.hide();
+ this.ui.requestRender();
+ };
+ }
+ : (component: Component) => this.showInlineAuthPanel(component);
return new ProviderAuthFlows({
ui: this.ui,
modelRegistry: this.modelRegistry,
showStatus: (message) => this.showStatus(message),
showError: (message) => this.showError(message),
+ showAuthPanel,
+ getAuthPanelRows: () => Math.max(1, Math.min(20, this.ui.terminal.rows - 3)),
getAvailableModels: () => this.getConnectionAvailableModels(),
onAuthChanged: async () => {
await this.refreshConnectionModelsAfterAuthChange();
@@ -8865,6 +8888,40 @@ export class InteractiveMode {
});
}
+ /**
+ * Mount a provider-auth panel inline in place of the prompt area, matching
+ * the inline pickers. Returns a callback that unmounts the panel and
+ * restores the previous content and focus. Closers are tracked in a stack
+ * because in-flow selectors mount on top of the login dialog;
+ * resetExtensionUI tears the whole stack down on session resets. Each
+ * closer runs once, so a reset cannot stomp a picker opened afterwards.
+ */
+ private showInlineAuthPanel(component: Component): () => void {
+ const previousChildren = [...this.editorContainer.children];
+ const previousFocus = previousChildren.find((child) => isFocusable(child) && child.focused) ?? this.editor;
+ this.editorContainer.clear();
+ this.editorContainer.addChild(component);
+ this.ui.setFocus(component);
+ this.ui.requestRender();
+ let closed = false;
+ const close = () => {
+ if (closed) return;
+ closed = true;
+ const index = this.inlineAuthPanelClosers.indexOf(close);
+ if (index !== -1) {
+ this.inlineAuthPanelClosers.splice(index, 1);
+ }
+ this.editorContainer.clear();
+ for (const child of previousChildren) {
+ this.editorContainer.addChild(child);
+ }
+ this.ui.setFocus(previousFocus);
+ this.ui.requestRender();
+ };
+ this.inlineAuthPanelClosers.push(close);
+ return close;
+ }
+
private async prepareForModelSelectionAfterLogin(authResult: AuthenticationResult): Promise<boolean> {
const currentModel = this.getCurrentModel();
// The agent core uses unknown/unknown as its no-model sentinel.
diff --git a/packages/coding-agent/test/auth-flows.test.ts b/packages/coding-agent/test/auth-flows.test.ts
index 08853cc830..50f53b790e 100644
--- a/packages/coding-agent/test/auth-flows.test.ts
+++ b/packages/coding-agent/test/auth-flows.test.ts
@@ -12,6 +12,9 @@ import { PRIME_INFERENCE_PROVIDER_ID } from "../src/core/prime-inference-auth.js
import { createAgentSession } from "../src/core/sdk.js";
import { SessionManager } from "../src/core/session-manager.js";
import { ProviderAuthFlows, type ProviderAuthFlowsHost } from "../src/modes/interactive/auth-flows.js";
+import { ExtensionSelectorComponent } from "../src/modes/interactive/components/extension-selector.js";
+import { LoginDialogComponent } from "../src/modes/interactive/components/login-dialog.js";
+import { OAuthSelectorComponent } from "../src/modes/interactive/components/oauth-selector.js";
import { initTheme } from "../src/modes/interactive/theme/theme.js";
function jsonResponse(body: unknown, status: number = 200): Response {
@@ -50,10 +53,12 @@ function createHost(authStorage: AuthStorage): {
statusMessages: string[];
errorMessages: string[];
overlays: Component[];
+ panels: Component[];
} {
const statusMessages: string[] = [];
const errorMessages: string[] = [];
const overlays: Component[] = [];
+ const panels: Component[] = [];
const modelRegistry = {
authStorage,
refresh: vi.fn(),
@@ -68,11 +73,22 @@ function createHost(authStorage: AuthStorage): {
modelRegistry,
showStatus: (message) => statusMessages.push(message),
showError: (message) => errorMessages.push(message),
+ showAuthPanel: (component) => {
+ panels.push(component);
+ return () => {
+ const index = panels.lastIndexOf(component);
+ if (index !== -1) {
+ panels.splice(index, 1);
+ }
+ };
+ },
+ getAuthPanelRows: () => 24,
getAvailableModels: async () => [],
},
statusMessages,
errorMessages,
overlays,
+ panels,
};
}
@@ -194,21 +210,24 @@ describe("ProviderAuthFlows", () => {
writeFileSync(join(defaultPrimeDir, "config.json"), JSON.stringify({ api_key: "prime-cli-key" }));
const authStorage = AuthStorage.create(authJsonPath, { usePrimeCliConfig: false });
const fetchMock = vi.spyOn(globalThis, "fetch").mockRejectedValue(new Error("offline"));
- const { host, overlays } = createHost(authStorage);
+ const { host, overlays, panels } = createHost(authStorage);
const result = new ProviderAuthFlows(host).runPrimeInferenceLogin();
await vi.waitFor(() => expect(fetchMock).toHaveBeenCalledOnce());
expect(String(fetchMock.mock.calls[0]?.[0])).toBe("https://api.primeintellect.ai/api/v1/auth_challenge/generate");
- overlays[0]?.handleInput?.("\x1b");
+ panels[0]?.handleInput?.("\x1b");
await expect(result).resolves.toEqual({ status: "cancelled" });
expect(authStorage.has(PRIME_INFERENCE_PROVIDER_ID)).toBe(false);
+ // The login dialog mounts inline in the host, never as an overlay.
+ expect(overlays).toHaveLength(0);
});
it("does not offer logout for credentials owned only by the Prime CLI", async () => {
writeFileSync(primeConfigPath, JSON.stringify({ api_key: "prime-cli-key" }));
const authStorage = AuthStorage.create(authJsonPath, { primeCliConfigPath: primeConfigPath });
- const { host, overlays } = createHost(authStorage);
+ const { host, overlays, panels } = createHost(authStorage);
await expect(new ProviderAuthFlows(host).runLogout()).resolves.toBeNull();
expect(overlays).toHaveLength(0);
+ expect(panels).toHaveLength(0);
expect(JSON.parse(readFileSync(primeConfigPath, "utf-8"))).toEqual({ api_key: "prime-cli-key" });
});
@@ -237,13 +256,14 @@ describe("ProviderAuthFlows", () => {
return jsonResponse({ data: [], total_count: 0 });
throw new Error(`Unexpected URL: ${url}`);
});
- const { host, overlays, errorMessages } = createHost(authStorage);
+ const { host, overlays, panels, errorMessages } = createHost(authStorage);
const result = new ProviderAuthFlows(host).runPrimeInferenceLogin();
await vi.waitFor(() =>
- expect(stripAnsi(overlays[0]?.render(80).join("\n") ?? "")).toContain("Paste a Prime API key below:"),
+ expect(stripAnsi(panels[0]?.render(80).join("\n") ?? "")).toContain("Paste a Prime API key below:"),
);
- overlays[0]?.handleInput?.("manual-key");
- overlays[0]?.handleInput?.("\r");
+ expect(overlays).toHaveLength(0);
+ panels[0]?.handleInput?.("manual-key");
+ panels[0]?.handleInput?.("\r");
await expect(result).resolves.toMatchObject({ status: "success" });
expect(errorMessages).toEqual([]);
expect(urls).toEqual([
@@ -275,15 +295,76 @@ describe("ProviderAuthFlows", () => {
it("opens login on the requested MCP Connections category", async () => {
const authStorage = AuthStorage.create(authJsonPath, { usePrimeCliConfig: false });
- const { host, overlays } = createHost(authStorage);
+ const { host, overlays, panels } = createHost(authStorage);
const loginResult = new ProviderAuthFlows(host).runLogin({ initialCategory: "service" });
- expect(overlays).toHaveLength(1);
- const output = stripAnsi(overlays[0]?.render(80).join("\n") ?? "");
+ expect(overlays).toHaveLength(0);
+ expect(panels).toHaveLength(1);
+ expect(panels[0]).toBeInstanceOf(OAuthSelectorComponent);
+ const output = stripAnsi(panels[0]?.render(80).join("\n") ?? "");
expect(output).toContain("Serper (web search)");
expect(output).not.toContain("Anthropic");
- overlays[0]?.handleInput?.("\x1b");
+ panels[0]?.handleInput?.("\x1b");
await expect(loginResult).resolves.toEqual({ status: "cancelled" });
+ expect(panels).toHaveLength(0);
+ });
+
+ it("mounts the API key login dialog inline and unmounts it after submitting", async () => {
+ const authStorage = AuthStorage.create(authJsonPath, { usePrimeCliConfig: false });
+ const { host, overlays, panels, statusMessages } = createHost(authStorage);
+
+ const loginPromise = new ProviderAuthFlows(host).loginProvider({
+ id: "xai",
+ name: "xAI (Grok)",
+ authType: "api_key",
+ });
+
+ await vi.waitFor(() => expect(stripAnsi(panels[0]?.render(80).join("\n") ?? "")).toContain("Enter API key:"));
+ expect(panels[0]).toBeInstanceOf(LoginDialogComponent);
+ expect(overlays).toHaveLength(0);
+ panels[0]?.handleInput?.("test-key");
+ panels[0]?.handleInput?.("\r");
+
+ await expect(loginPromise).resolves.toMatchObject({ status: "success", providerId: "xai" });
+ expect(panels).toHaveLength(0);
+ expect(authStorage.get("xai")).toEqual({ type: "api_key", key: "test-key" });
+ expect(statusMessages.join("\n")).toContain("Saved API key for xAI (Grok)");
+ });
+
+ it("restores the login dialog after an in-flow account selection", async () => {
+ const authStorage = AuthStorage.create(authJsonPath, { usePrimeCliConfig: false });
+ const { host, panels } = createHost(authStorage);
+ const loginSpy = vi.spyOn(authStorage, "login").mockImplementation(async (_providerId, handlers) => {
+ await handlers?.onSelect?.({
+ message: "Choose an account",
+ options: [
+ { id: "personal", label: "Personal" },
+ { id: "business", label: "Business" },
+ ],
+ });
+ });
+
+ const loginPromise = new ProviderAuthFlows(host).loginProvider({
+ id: "anthropic",
+ name: "Anthropic",
+ authType: "oauth",
+ });
+
+ await vi.waitFor(() => expect(panels).toHaveLength(2));
+ expect(panels[0]).toBeInstanceOf(LoginDialogComponent);
+ expect(panels[1]).toBeInstanceOf(ExtensionSelectorComponent);
+ const selectorOutput = stripAnsi(panels[1]?.render(80).join("\n") ?? "");
+ expect(selectorOutput).toContain("Choose an account");
+ expect(selectorOutput).toContain("Personal");
+ expect(selectorOutput).toContain("Business");
+
+ panels[1]?.handleInput?.("\r");
+
+ await expect(loginPromise).resolves.toMatchObject({ status: "success", providerId: "anthropic" });
+ // Selecting an option unmounts the selector and restores the login dialog,
+ // which is then unmounted when the flow finishes.
+ expect(panels).toHaveLength(0);
+ expect(loginSpy).toHaveBeenCalledOnce();
});
});
diff --git a/packages/coding-agent/test/extension-selector.test.ts b/packages/coding-agent/test/extension-selector.test.ts
index 88a704f318..2230fca464 100644
--- a/packages/coding-agent/test/extension-selector.test.ts
+++ b/packages/coding-agent/test/extension-selector.test.ts
@@ -18,6 +18,25 @@ describe("ExtensionSelectorComponent", () => {
initTheme("dark");
});
+ it("renders every line of a multiline prompt in inline mode", () => {
+ const selector = new ExtensionSelectorComponent(
+ "Choose an account\nSign in with the account you want to use with Prime Agent.",
+ ["Personal", "Business"],
+ vi.fn(),
+ vi.fn(),
+ { getRows: () => 24, inline: true },
+ );
+
+ const output = stripAnsi(selector.render(88).join("\n"));
+ const lines = output.split("\n");
+ const titleIndex = lines.findIndex((line) => line.includes("Choose an account"));
+
+ expect(titleIndex).toBe(0);
+ expect(lines[titleIndex + 1]).toContain("Sign in with the account you want to use with Prime Agent.");
+ expect(output).toContain("Personal");
+ expect(output).toContain("Business");
+ });
+
it("renders a multiline prompt with compact option rows", () => {
const selector = new ExtensionSelectorComponent(
[
diff --git a/packages/coding-agent/test/interactive-mode-status.test.ts b/packages/coding-agent/test/interactive-mode-status.test.ts
index c681233648..de458155f5 100644
--- a/packages/coding-agent/test/interactive-mode-status.test.ts
+++ b/packages/coding-agent/test/interactive-mode-status.test.ts
@@ -2507,6 +2507,7 @@ describe("InteractiveMode model selection persistence", () => {
getLoginProviderOptions(): ReadonlyArray<AuthSelectorProvider>;
loginProvider(provider: AuthSelectorProvider): Promise<AuthenticationResult>;
};
+ prepareForModelSelectionAfterLogin(authResult: AuthenticationResult): Promise<boolean>;
ensureModelProviderConfigured(
model: AgentConnectionModel,
authFlows: ReturnType<ModelSelectorHarness["createAuthFlows"]>,
@@ -2626,6 +2627,7 @@ describe("InteractiveMode model selection persistence", () => {
getLoginProviderOptions: () => options.providerOptions ?? [],
loginProvider: options.loginProvider ?? (async () => ({ status: "cancelled" as const })),
}));
+ fakeThis.prepareForModelSelectionAfterLogin = selectorPrototype.prepareForModelSelectionAfterLogin;
fakeThis.applySelectedModel = options.applySelectedModel ?? vi.fn(async () => {});
fakeThis.ensureModelProviderConfigured = selectorPrototype.ensureModelProviderConfigured;
fakeThis.completeModelSelection = selectorPrototype.completeModelSelection;
@@ -3062,6 +3064,47 @@ describe("InteractiveMode model selection persistence", () => {
await expect(result).resolves.toBeUndefined();
});
+ test("keeps the providers tab after a successful provider login", async () => {
+ const provider: AuthSelectorProvider = { id: "openai", name: "OpenAI", authType: "api_key" };
+ const loginProvider = vi.fn(async (): Promise<AuthenticationResult> => {
+ // Successful logins store the credential, so the row flips to configured.
+ fakeThis.uiServices.modelRegistry.authStorage.set(provider.id, {
+ type: "api_key",
+ key: "test-key",
+ });
+ return {
+ status: "success",
+ providerId: provider.id,
+ providerName: provider.name,
+ authType: provider.authType,
+ };
+ });
+ const { fakeThis, getSelector } = createSelectorHarness({
+ connectionModels: [createModel("openai", "gpt-5.5")],
+ providerOptions: [provider],
+ loginProvider,
+ });
+ const prepareForModelSelection = vi.spyOn(fakeThis, "prepareForModelSelectionAfterLogin");
+
+ const result = fakeThis.showConfigurationMenu("providers");
+
+ expect(getSelector().getActiveTab()).toBe("providers");
+ getSelector().handleInput("\r");
+ await flushAsyncWork();
+
+ expect(loginProvider).toHaveBeenCalledWith(provider);
+ expect(prepareForModelSelection).toHaveBeenCalledTimes(1);
+ // Finishing a login stays on the providers tab with the provider configured.
+ expect(getSelector().getActiveTab()).toBe("providers");
+ expect(fakeThis.editorContainer.children).toEqual([getSelector()]);
+ expect(fakeThis.ui.setFocus).toHaveBeenLastCalledWith(getSelector());
+ expect(stripAnsi(getSelector().render(120).join("\n"))).toContain("configured");
+
+ getSelector().handleInput("\x1b");
+ await expect(result).resolves.toBeUndefined();
+ expect(fakeThis.editorContainer.children).toEqual([fakeThis.editor]);
+ });
+
test("refreshes model selector results in the background without clearing search", async () => {
const alpha = createModel("openai", "alpha");
const beta = { ...createModel("openai", "beta"), name: "Beta Model" };
@@ -5759,3 +5802,165 @@ test("session teardown removes a running refine loader without remounting anythi
expect((fakeThis as unknown as { refineLoader?: unknown }).refineLoader).toBeUndefined();
expect((fakeThis as unknown as { syncWorkingLoader: () => void }).syncWorkingLoader).not.toHaveBeenCalled();
});
+
+test("session reset tears down an inline auth panel and restores the editor", () => {
+ initTheme("dark");
+ const editor = new Input();
+ const editorContainer = new Container();
+ editorContainer.addChild(editor);
+ const setFocus = vi.fn();
+ const fakeThis = {
+ editor,
+ editorContainer,
+ ui: { requestRender: vi.fn(), setFocus, hideOverlay: vi.fn(), terminal: { rows: 24 } } as unknown as TUI,
+ inlineAuthPanelClosers: [] as Array<() => void>,
+ cancelActiveConnectionExtensionUiRequests: vi.fn(),
+ closeHeartbeatManager: vi.fn(),
+ clearExtensionTerminalInputListeners: vi.fn(),
+ setExtensionFooter: vi.fn(),
+ setExtensionHeader: vi.fn(),
+ clearExtensionWidgets: vi.fn(),
+ footerDataProvider: { clearExtensionStatuses: vi.fn() },
+ footer: { invalidate: vi.fn() },
+ autocompleteProviderWrappers: [],
+ setCustomEditorComponent: vi.fn(),
+ setupAutocompleteProvider: vi.fn(),
+ defaultEditor: {},
+ updateTerminalTitle: vi.fn(),
+ refreshTopBarCost: vi.fn(),
+ setWorkingIndicator: vi.fn(),
+ } as unknown as InteractiveMode;
+ Object.setPrototypeOf(fakeThis, InteractiveMode.prototype);
+ const prototype = InteractiveMode.prototype as unknown as {
+ showInlineAuthPanel(component: Component): () => void;
+ resetExtensionUI(): void;
+ };
+ const closers = () => (fakeThis as unknown as { inlineAuthPanelClosers: unknown[] }).inlineAuthPanelClosers;
+
+ const panel = new Container();
+ const close = prototype.showInlineAuthPanel.call(fakeThis, panel);
+
+ expect(editorContainer.children).toEqual([panel]);
+ expect(closers()).toEqual([close]);
+
+ prototype.resetExtensionUI.call(fakeThis);
+
+ expect(editorContainer.children).toEqual([editor]);
+ expect(setFocus).toHaveBeenLastCalledWith(editor);
+ expect(closers()).toEqual([]);
+
+ // The auth flow's own close runs after the reset and must not restore the
+ // stale pre-panel content over a picker opened in the meantime.
+ const otherPicker = new Container();
+ editorContainer.clear();
+ editorContainer.addChild(otherPicker);
+ close();
+ expect(editorContainer.children).toEqual([otherPicker]);
+});
+
+test("session reset tears down stacked inline auth panels innermost first", () => {
+ initTheme("dark");
+ const editor = new Input();
+ const editorContainer = new Container();
+ editorContainer.addChild(editor);
+ const fakeThis = {
+ editor,
+ editorContainer,
+ ui: { requestRender: vi.fn(), setFocus: vi.fn(), hideOverlay: vi.fn(), terminal: { rows: 24 } } as unknown as TUI,
+ inlineAuthPanelClosers: [] as Array<() => void>,
+ cancelActiveConnectionExtensionUiRequests: vi.fn(),
+ closeHeartbeatManager: vi.fn(),
+ clearExtensionTerminalInputListeners: vi.fn(),
+ setExtensionFooter: vi.fn(),
+ setExtensionHeader: vi.fn(),
+ clearExtensionWidgets: vi.fn(),
+ footerDataProvider: { clearExtensionStatuses: vi.fn() },
+ footer: { invalidate: vi.fn() },
+ autocompleteProviderWrappers: [],
+ setCustomEditorComponent: vi.fn(),
+ setupAutocompleteProvider: vi.fn(),
+ defaultEditor: {},
+ updateTerminalTitle: vi.fn(),
+ refreshTopBarCost: vi.fn(),
+ setWorkingIndicator: vi.fn(),
+ } as unknown as InteractiveMode;
+ Object.setPrototypeOf(fakeThis, InteractiveMode.prototype);
+ const prototype = InteractiveMode.prototype as unknown as {
+ showInlineAuthPanel(component: Component): () => void;
+ resetExtensionUI(): void;
+ };
+ const closers = () => (fakeThis as unknown as { inlineAuthPanelClosers: unknown[] }).inlineAuthPanelClosers;
+
+ const dialog = new Container();
+ const closeDialog = prototype.showInlineAuthPanel.call(fakeThis, dialog);
+ const teamSelector = new Container();
+ const closeSelector = prototype.showInlineAuthPanel.call(fakeThis, teamSelector);
+ expect(editorContainer.children).toEqual([teamSelector]);
+ expect(closers()).toEqual([closeDialog, closeSelector]);
+
+ prototype.resetExtensionUI.call(fakeThis);
+
+ expect(editorContainer.children).toEqual([editor]);
+ expect(closers()).toEqual([]);
+
+ // Late closes from the interrupted flows stay no-ops.
+ editorContainer.clear();
+ editorContainer.addChild(new Container());
+ closeSelector();
+ closeDialog();
+ expect(editorContainer.children).toHaveLength(1);
+});
+
+test("normal inline auth panel close unwinds the tracked session-reset stack", () => {
+ initTheme("dark");
+ const editor = new Input();
+ const editorContainer = new Container();
+ editorContainer.addChild(editor);
+ const fakeThis = {
+ editor,
+ editorContainer,
+ ui: { requestRender: vi.fn(), setFocus: vi.fn(), hideOverlay: vi.fn(), terminal: { rows: 24 } } as unknown as TUI,
+ inlineAuthPanelClosers: [] as Array<() => void>,
+ cancelActiveConnectionExtensionUiRequests: vi.fn(),
+ closeHeartbeatManager: vi.fn(),
+ clearExtensionTerminalInputListeners: vi.fn(),
+ setExtensionFooter: vi.fn(),
+ setExtensionHeader: vi.fn(),
+ clearExtensionWidgets: vi.fn(),
+ footerDataProvider: { clearExtensionStatuses: vi.fn() },
+ footer: { invalidate: vi.fn() },
+ autocompleteProviderWrappers: [],
+ setCustomEditorComponent: vi.fn(),
+ setupAutocompleteProvider: vi.fn(),
+ defaultEditor: {},
+ updateTerminalTitle: vi.fn(),
+ refreshTopBarCost: vi.fn(),
+ setWorkingIndicator: vi.fn(),
+ } as unknown as InteractiveMode;
+ Object.setPrototypeOf(fakeThis, InteractiveMode.prototype);
+ const prototype = InteractiveMode.prototype as unknown as {
+ showInlineAuthPanel(component: Component): () => void;
+ resetExtensionUI(): void;
+ };
+ const closers = () => (fakeThis as unknown as { inlineAuthPanelClosers: unknown[] }).inlineAuthPanelClosers;
+
+ const dialog = new Container();
+ const closeDialog = prototype.showInlineAuthPanel.call(fakeThis, dialog);
+ const teamSelector = new Container();
+ const closeSelector = prototype.showInlineAuthPanel.call(fakeThis, teamSelector);
+
+ // The selector unwinds first and re-tracks the dialog underneath it.
+ closeSelector();
+ expect(editorContainer.children).toEqual([dialog]);
+ expect(closers()).toEqual([closeDialog]);
+
+ closeDialog();
+ expect(editorContainer.children).toEqual([editor]);
+ expect(closers()).toEqual([]);
+
+ // A session reset after the panels already closed restores nothing extra.
+ editorContainer.clear();
+ editorContainer.addChild(new Container());
+ prototype.resetExtensionUI.call(fakeThis);
+ expect(editorContainer.children).toHaveLength(1);
+});
diff --git a/packages/coding-agent/test/login-dialog.test.ts b/packages/coding-agent/test/login-dialog.test.ts
index 28a55889ab..b9682af645 100644
--- a/packages/coding-agent/test/login-dialog.test.ts
+++ b/packages/coding-agent/test/login-dialog.test.ts
@@ -51,18 +51,20 @@ describe("LoginDialogComponent", () => {
const dialog = new LoginDialogComponent(createFakeTui(), "anthropic", () => {}, "Anthropic");
dialog.showAuth("https://example.com/oauth?client_id=test", "Complete login in your browser.");
- const output = stripAnsi(dialog.render(88).join("\n"));
+ const lines = dialog.render(88);
+ const output = stripAnsi(lines.join("\n"));
expect(output).toContain("Login to Anthropic");
- 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");
- expect(output).not.toContain("─");
expect(output).not.toContain("> ");
+ // The top rule separates the inline login section from the chat above;
+ // no other borders surround the content.
+ const ruleLines = lines.filter((line) => stripAnsi(line).includes("─"));
+ expect(ruleLines).toHaveLength(1);
+ expect(stripAnsi(lines[0] ?? "")).toBe("─".repeat(88));
});
it("copies the raw sign-in URL with the configured shortcut", async () => {
@@ -152,7 +154,9 @@ describe("LoginDialogComponent", () => {
const firstLogoLine = PRIME_BUTTERFLY_LOGO.split("\n")[0]?.trim() ?? "";
expect(output).toContain("Login to Prime Inference");
- expect(output).toContain(firstLogoLine);
+ // The compact inline panel never renders the butterfly logo.
+ expect(firstLogoLine).not.toBe("");
+ expect(output).not.toContain(firstLogoLine);
expect(output).toContain("Verification code");
expect(output).toContain("abc-123");
expect(output).not.toContain("click to open");
@@ -170,7 +174,7 @@ describe("LoginDialogComponent", () => {
expect(output).not.toContain("Status");
});
- it("keeps the Prime Inference brand header centered and within the panel", () => {
+ it("renders the Prime Inference login with the compact inline header", () => {
const dialog = new LoginDialogComponent(createFakeTui(), "prime-inference", () => {}, "Prime Inference");
dialog.showProgress("Checking existing Prime CLI credentials...");
@@ -179,11 +183,12 @@ describe("LoginDialogComponent", () => {
const titleLine = output.split("\n").find((line) => line.includes("Login to Prime Inference"));
const titleOffset = titleLine?.indexOf("Login to Prime Inference") ?? -1;
- expect(titleOffset).toBeGreaterThan(20);
- expect(output).toContain("Connect your Prime Intellect account to enable Prime Inference models.");
+ // The title leads the inline panel.
+ expect(titleOffset).toBe(1);
+ expect(output).not.toContain("Connect your Prime Intellect account to enable Prime Inference models.");
expect(output).toContain("Preparing authentication");
for (const line of lines) {
- expect(visibleWidth(line)).toBe(88);
+ expect(visibleWidth(line)).toBeLessThanOrEqual(88);
}
});
@@ -211,7 +216,7 @@ describe("LoginDialogComponent", () => {
await expect(second).resolves.toBe("pk");
});
- it("renders API key prompts without shell input markers", () => {
+ it("renders API key prompts with the bordered inline input", () => {
const dialog = new LoginDialogComponent(createFakeTui(), "openai", () => {}, "OpenAI");
void dialog.showPrompt("Enter API key:");
@@ -219,7 +224,55 @@ describe("LoginDialogComponent", () => {
expect(output).toContain("Login to OpenAI");
expect(output).toContain("Enter API key:");
- expect(output).not.toContain("─");
- expect(output).not.toContain("> ");
+ // The paste field matches the inline picker search box.
+ expect(output).toContain("─");
+ expect(output).toContain("Paste value");
+ // One key-hint line carries submit and cancel.
+ expect(output).toContain("Enter submit");
+ expect(output).toContain("Esc/Ctrl+C cancel");
+ });
+
+ it("keeps the key-hint row last while waiting and polling", () => {
+ const dialog = new LoginDialogComponent(createFakeTui(), "github-copilot", () => {}, "GitHub Copilot");
+
+ dialog.showAuth("https://example.com/device");
+ dialog.showWaiting("Waiting for browser authentication...");
+ let rows = stripAnsi(dialog.render(88).join("\n"))
+ .split("\n")
+ .filter((line) => line.trim().length > 0);
+
+ expect(rows.at(-1)).toContain("cancel");
+ expect(rows.at(-1)).toContain("copy");
+ expect(rows.at(-2)).toContain("Waiting for browser authentication...");
+
+ dialog.showProgress("Waiting for browser sign-in...");
+ rows = stripAnsi(dialog.render(88).join("\n"))
+ .split("\n")
+ .filter((line) => line.trim().length > 0);
+
+ expect(rows.at(-1)).toContain("cancel");
+ expect(rows.at(-2)).toContain("Waiting for browser sign-in...");
+ expect(rows.at(-3)).toContain("Waiting for browser authentication...");
+ });
+
+ it("wraps long sign-in URLs into per-line hyperlinks with the full url", () => {
+ setCapabilities({ images: null, trueColor: true, hyperlinks: true });
+ const dialog = new LoginDialogComponent(createFakeTui(), "anthropic", () => {}, "Anthropic");
+ const url = "https://example.com/oauth/authorize?client_id=test-client-123456&response_type=code&scope=openid";
+
+ dialog.showAuth(url);
+ const lines = dialog.render(40);
+ const urlLines = lines.filter((line) => line.includes("\x1b]8;;"));
+
+ // The wrapped URL keeps its hyperlink on every line: each segment re-opens
+ // with the full url and closes again, so any line opens the whole link.
+ expect(urlLines.length).toBeGreaterThan(1);
+ for (const line of urlLines) {
+ expect(line).toContain(`\x1b]8;;${url}\x07`);
+ expect(line).toContain("\x1b]8;;\x07");
+ expect(visibleWidth(line)).toBe(40);
+ }
+ const visibleUrl = urlLines.map((line) => stripAnsi(line).trim()).join("");
+ expect(visibleUrl).toContain(url);
});
});
diff --git a/packages/coding-agent/test/menu-panel.test.ts b/packages/coding-agent/test/menu-panel.test.ts
index bfc6f30a3e..a027757fd8 100644
--- a/packages/coding-agent/test/menu-panel.test.ts
+++ b/packages/coding-agent/test/menu-panel.test.ts
@@ -47,6 +47,45 @@ describe("MenuPanel", () => {
}
});
+ it("renders an optional top rule above inline panels", () => {
+ const createPanel = (topRule: boolean): MenuPanel => {
+ const panel = new MenuPanel({ title: "Login to Provider", inline: true, topRule });
+ panel.addChild(new StaticComponent());
+ return panel;
+ };
+
+ const withRule = createPanel(true).render(24);
+ expect(withRule[0]).toContain(theme.getFgAnsi("borderMuted"));
+ expect(stripAnsi(withRule[0] ?? "")).toBe("─".repeat(24));
+ expect(stripAnsi(withRule[1] ?? "").trim()).toBe("Login to Provider");
+ for (const line of withRule) {
+ expect(visibleWidth(line)).toBe(24);
+ }
+
+ const withoutRule = createPanel(false).render(24);
+ expect(stripAnsi(withoutRule[0] ?? "").trim()).toBe("Login to Provider");
+ expect(withoutRule.join("")).not.toContain("─");
+ });
+
+ it("renders the subtitle under the title in inline panels", () => {
+ const panel = new MenuPanel({
+ title: "Choose an account",
+ subtitle: "Sign in with the account you want to use.",
+ inline: true,
+ });
+ panel.addChild(new StaticComponent());
+
+ const lines = panel.render(60);
+ const output = lines.map((line) => stripAnsi(line));
+
+ expect(output[0]?.trim()).toBe("Choose an account");
+ expect(output[1]?.trim()).toBe("Sign in with the account you want to use.");
+ expect(output[2]?.trim()).toBe("first");
+ for (const line of lines) {
+ expect(visibleWidth(line)).toBe(60);
+ }
+ });
+
it("renders search fields without the shell prompt", () => {
const field = new MenuSearchInput("Search models");
const output = stripAnsi(field.render(24).join("\n"));
diff --git a/packages/coding-agent/test/prime-team-selector.test.ts b/packages/coding-agent/test/prime-team-selector.test.ts
index 51607ef127..b30b4b095b 100644
--- a/packages/coding-agent/test/prime-team-selector.test.ts
+++ b/packages/coding-agent/test/prime-team-selector.test.ts
@@ -27,7 +27,7 @@ describe("PrimeTeamSelectorComponent", () => {
const output = stripAnsi(selector.render(100).join("\n"));
- expect(output).toContain("Prime Team");
+ expect(output).toContain("Select a Prime Team:");
expect(output).toContain("Personal");
expect(output).toContain("personal account");
expect(output).toContain("Research");
diff --git a/packages/coding-agent/test/suite/regressions/4658-onboarding-transitions.test.ts b/packages/coding-agent/test/suite/regressions/4658-onboarding-transitions.test.ts
index b4fedfadf0..57475c4125 100644
--- a/packages/coding-agent/test/suite/regressions/4658-onboarding-transitions.test.ts
+++ b/packages/coding-agent/test/suite/regressions/4658-onboarding-transitions.test.ts
@@ -1,4 +1,4 @@
-import { Container, Input, setKeybindings, type TUI } from "@earendil-works/pi-tui";
+import { type Component, Container, Input, setKeybindings, Text, type TUI } from "@earendil-works/pi-tui";
import { afterEach, beforeEach, describe, expect, test, vi } from "vitest";
import { KeybindingsManager } from "../../../src/core/keybindings.js";
import type { ModelRegistry } from "../../../src/core/model-registry.js";
@@ -33,6 +33,7 @@ interface ConfigurationHarness {
editor: Input;
editorContainer: Container;
ui: TUI;
+ inlineAuthPanelClosers: Array<() => void>;
uiServices: {
modelRegistry: ModelRegistry;
settingsManager: Harness["settingsManager"];
@@ -108,6 +109,10 @@ describe("ENG-4658 onboarding transitions", () => {
const onboarding = fakeThis.runOnboardingFlow(false);
await vi.waitFor(() => expect(fakeThis.showConfigurationMenu).toHaveBeenCalledWith("models"));
+ // The splash covers the screen, so onboarding logins must mount above it
+ // as overlays instead of inline behind it.
+ expect(fakeThis.createAuthFlows).toHaveBeenCalledWith({ overlay: true });
+
expect(order.slice(-2)).toEqual(["dismiss", "configuration:models"]);
configuration.resolve();
await onboarding;
@@ -123,7 +128,7 @@ describe("ENG-4658 onboarding transitions", () => {
]);
});
- test("keeps the inline picker mounted during authentication and restores the draft after closing", async () => {
+ test("swaps the inline picker for the login panel and restores the draft after closing", async () => {
const harness = await createHarness();
harnesses.push(harness);
const login = deferred<AuthenticationResult>();
@@ -138,6 +143,7 @@ describe("ENG-4658 onboarding transitions", () => {
requestRender: vi.fn(),
setFocus: vi.fn(),
} as unknown as TUI;
+ fakeThis.inlineAuthPanelClosers = [];
fakeThis.uiServices = {
modelRegistry: harness.session.modelRegistry,
settingsManager: harness.settingsManager,
@@ -146,9 +152,19 @@ describe("ENG-4658 onboarding transitions", () => {
fakeThis.getScopedModelState = () => [];
fakeThis.getCurrentModel = () => model;
fakeThis.getModelSelectorRefreshPromise = () => undefined;
+ const showInlineAuthPanel = (
+ InteractiveMode.prototype as unknown as {
+ showInlineAuthPanel(component: Component): () => void;
+ }
+ ).showInlineAuthPanel;
+ const loginPanel = new Text("Login panel", 0, 0);
fakeThis.createAuthFlows = () => ({
getLoginProviderOptions: () => [{ id: model.provider, name: model.provider, authType: "api_key" }],
- loginProvider: () => login.promise,
+ loginProvider: () => {
+ const close = showInlineAuthPanel.call(fakeThis, loginPanel);
+ void login.promise.then(() => close());
+ return login.promise;
+ },
});
fakeThis.showError = vi.fn();
fakeThis.showStatus = vi.fn();
@@ -158,13 +174,12 @@ describe("ENG-4658 onboarding transitions", () => {
expect(menu).toBeInstanceOf(ConfigurationMenuComponent);
menu.handleInput("\r");
- expect(fakeThis.editorContainer.children).toEqual([menu]);
+ expect(fakeThis.editorContainer.children).toEqual([loginPanel]);
expect(fakeThis.editor.getValue()).toBe("draft prompt");
login.resolve({ status: "cancelled" });
- await vi.waitFor(() => expect(fakeThis.ui.setFocus).toHaveBeenCalledTimes(2));
+ await vi.waitFor(() => expect(fakeThis.editorContainer.children).toEqual([menu]));
expect(fakeThis.ui.setFocus).toHaveBeenLastCalledWith(menu);
- expect(fakeThis.editorContainer.children).toEqual([menu]);
menu.handleInput("\x1b");
await expect(configuration).resolves.toBeUndefined();
expect(fakeThis.editorContainer.children).toEqual([fakeThis.editor]);