Skip to content

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

Rust

simplify prompt bar controls (#2183)

kt126b43c0ce4f
diff --git a/packages/coding-agent/.changes/ui-prompt-bar.md b/packages/coding-agent/.changes/ui-prompt-bar.md
new file mode 100644
index 0000000000..eebaf2b9ac
--- /dev/null
+++ b/packages/coding-agent/.changes/ui-prompt-bar.md
@@ -0,0 +1,10 @@
+- Moved muted conversation detail status directly above the prompt beside an ellipsized recap, with one blank line separating the row from the chat.
+- Showed model IDs with colon-separated lowercase effort and context usage in the bottom-right tray.
+- Kept fast mode beside model and effort, renamed session navigation to manage, and removed the repeated shortcut guide hint below the prompt.
+- Hid the tray and subagents summary while pickers are open and showed depth only for subagent sessions.
+- Kept slash command autocomplete completion-only: Tab or Enter completes the command, and pressing Enter again runs it.
+- Removed unsolicited feature-discovery tips during agent runs and example prompts from the startup splash and editor.
+- Removed the extra blank line above recap and detail status when no extension widget is shown.
+- Kept the tray and subagent summary visible during slash-command autocomplete while hiding them for actual pickers.
+- Renamed conversation detail states to Collapsed mode, Details mode, and Expanded mode.
+- Prevented hidden subagent summaries from taking focus while a picker is open.
diff --git a/packages/coding-agent/src/core/slash-commands.ts b/packages/coding-agent/src/core/slash-commands.ts
index 5f3091e1e0..d1d9a9f243 100644
--- a/packages/coding-agent/src/core/slash-commands.ts
+++ b/packages/coding-agent/src/core/slash-commands.ts
@@ -86,7 +86,7 @@ interface BuiltinSlashCommandAlias {
const CANONICAL_BUILTIN_SLASH_COMMANDS: ReadonlyArray<BuiltinSlashCommand> = [
{ name: "settings", description: "Open settings menu" },
- { name: "model", description: "Select model (opens selector UI)", argumentHint: "[search]", takesArgument: true },
+ { name: "model", description: "Select model (opens selector UI)", argumentHint: "[search]" },
{ name: "effort", description: "Select reasoning/thinking level (opens selector UI)", argumentHint: "[level]" },
{ name: "fast", description: "Toggle OpenAI Fast mode" },
{ name: "scoped-models", description: "Enable/disable models for Ctrl+P cycling" },
diff --git a/packages/coding-agent/src/modes/interactive/components/custom-editor.ts b/packages/coding-agent/src/modes/interactive/components/custom-editor.ts
index ee505f92b0..13e318471a 100644
--- a/packages/coding-agent/src/modes/interactive/components/custom-editor.ts
+++ b/packages/coding-agent/src/modes/interactive/components/custom-editor.ts
@@ -24,7 +24,6 @@ export interface CustomEditorOptions extends EditorOptions {
export class CustomEditor extends Editor {
private keybindings: KeybindingsManager;
private defaultPromptPrefix: string;
- private readonly configuredPaddingX: number;
private placeholder: string | undefined;
private readonly placeholderColor: (text: string) => string;
private readonly isArgumentCommand: (name: string) => boolean;
@@ -47,7 +46,6 @@ export class CustomEditor extends Editor {
super(tui, theme, { ...options, promptPrefix });
this.keybindings = keybindings;
this.defaultPromptPrefix = promptPrefix;
- this.configuredPaddingX = options?.paddingX ?? 0;
this.placeholder = options?.placeholder;
this.placeholderColor = options?.placeholderColor ?? ((text) => text);
this.isArgumentCommand = options?.isArgumentCommand ?? (() => false);
@@ -284,7 +282,7 @@ export class CustomEditor extends Editor {
private getEffectivePaddingX(width: number): number {
const maxPadding = Math.max(0, Math.floor((width - 1) / 2));
- const configuredPaddingX = Math.min(this.configuredPaddingX, maxPadding);
+ const configuredPaddingX = Math.min(this.getPaddingX(), maxPadding);
return this.backgroundColor !== undefined
? Math.min(Math.max(configuredPaddingX, 2), maxPadding)
: configuredPaddingX;
diff --git a/packages/coding-agent/src/modes/interactive/components/feature-hint.ts b/packages/coding-agent/src/modes/interactive/components/feature-hint.ts
deleted file mode 100644
index acbe3aa420..0000000000
--- a/packages/coding-agent/src/modes/interactive/components/feature-hint.ts
+++ /dev/null
@@ -1,46 +0,0 @@
-import { type Component, truncateToWidth, visibleWidth } from "@earendil-works/pi-tui";
-import { theme } from "../theme/theme.js";
-
-const LABEL = "Hint:";
-const SHIMMER_RADIUS = 1;
-const SHIMMER_PAUSE_FRAMES = 14;
-
-export const FEATURE_HINT_ANIMATION_INTERVAL_MS = 160;
-
-function renderLabelShimmer(characters: string[], frame: number): string {
- if (characters.length === 0) return "";
-
- const travelFrames = characters.length + SHIMMER_RADIUS * 2;
- const phase = frame % (travelFrames + SHIMMER_PAUSE_FRAMES);
- const center = phase - SHIMMER_RADIUS;
- return characters
- .map((character, index) =>
- theme.fg(Math.abs(index - center) <= SHIMMER_RADIUS ? "muted" : "thinkingText", character),
- )
- .join("");
-}
-
-export class FeatureHintComponent implements Component {
- private frame = 0;
-
- constructor(private readonly text: string) {}
-
- advance(): void {
- this.frame++;
- }
-
- invalidate(): void {}
-
- render(width: number): string[] {
- const paddingX = width > 2 ? 1 : 0;
- const availableWidth = Math.max(1, width - paddingX * 2);
- const displayText = truncateToWidth(`${LABEL} ${this.text}`, availableWidth);
- const characters = Array.from(displayText);
- const labelLength = Math.min(LABEL.length, characters.length);
- const label = renderLabelShimmer(characters.slice(0, labelLength), this.frame);
- const hint = theme.fg("muted", characters.slice(labelLength).join(""));
- const line = `${" ".repeat(paddingX)}${label}${hint}`;
-
- return [line + " ".repeat(Math.max(0, width - visibleWidth(line))), " ".repeat(width)];
- }
-}
diff --git a/packages/coding-agent/src/modes/interactive/components/keybinding-hints.ts b/packages/coding-agent/src/modes/interactive/components/keybinding-hints.ts
index 22d681d7c1..618b0e6399 100644
--- a/packages/coding-agent/src/modes/interactive/components/keybinding-hints.ts
+++ b/packages/coding-agent/src/modes/interactive/components/keybinding-hints.ts
@@ -74,3 +74,9 @@ export function expandCollapseHint(keybinding: Keybinding, expanded: boolean): s
export function rawKeyHint(key: string, description: string): string {
return theme.fg("dim", formatKeyText(key)) + theme.fg("muted", ` ${description}`);
}
+
+export function formatConversationDetailStatus(allOutput: boolean, details: boolean): string {
+ const label = allOutput ? "Expanded" : details ? "Details" : "Collapsed";
+ const key = keyText("app.tools.expand", { primaryOnly: true });
+ return `${label} mode${key ? ` (${key} to ${allOutput ? "collapse" : "expand"})` : ""}`;
+}
diff --git a/packages/coding-agent/src/modes/interactive/components/prompt-context-line.ts b/packages/coding-agent/src/modes/interactive/components/prompt-context-line.ts
new file mode 100644
index 0000000000..a8f20ac35a
--- /dev/null
+++ b/packages/coding-agent/src/modes/interactive/components/prompt-context-line.ts
@@ -0,0 +1,32 @@
+import { type Component, truncateToWidth, visibleWidth } from "@earendil-works/pi-tui";
+import { theme } from "../theme/theme.js";
+
+/** Plain terminal row immediately above the prompt, shared by recap and conversation detail status. */
+export class PromptContextLine implements Component {
+ constructor(
+ private readonly getRecap: () => string | undefined,
+ private readonly getRightLabel: (maxWidth: number) => string | undefined,
+ ) {}
+
+ render(width: number): string[] {
+ if (width < 1) return [];
+ const paddingX = width > 2 ? 1 : 0;
+ const contentWidth = width - paddingX * 2;
+ const recap = this.getRecap()?.replace(/\s+/g, " ").trim();
+ const left = recap ? `Recap: ${recap}` : "";
+ const maxRightWidth = left ? Math.max(1, contentWidth - 3) : contentWidth;
+ const right = truncateToWidth(this.getRightLabel(maxRightWidth) ?? "", maxRightWidth, "");
+ if (!left && !right) return [];
+ const gap = left && right ? 2 : 0;
+ const leftWidth = Math.max(0, contentWidth - visibleWidth(right) - gap);
+ const renderedLeft = truncateToWidth(left, leftWidth, "…");
+ const space = " ".repeat(Math.max(0, contentWidth - visibleWidth(renderedLeft) - visibleWidth(right)));
+ const row = " ".repeat(paddingX) + theme.fg("dim", renderedLeft) + space + right + " ".repeat(paddingX);
+ // Separate the context row from the chat while keeping it adjacent to the prompt.
+ return ["", row];
+ }
+
+ invalidate(): void {
+ // Read live recap and detail status on every render.
+ }
+}
diff --git a/packages/coding-agent/src/modes/interactive/components/subagent-summary-line.ts b/packages/coding-agent/src/modes/interactive/components/subagent-summary-line.ts
index 600402a045..0961d634d6 100644
--- a/packages/coding-agent/src/modes/interactive/components/subagent-summary-line.ts
+++ b/packages/coding-agent/src/modes/interactive/components/subagent-summary-line.ts
@@ -76,6 +76,7 @@ export class SubagentSummaryLine implements Component, Focusable {
private readonly getLocationLabel: () => string | undefined = () => undefined,
private readonly getContextLabel: () => string | undefined = () => undefined,
private readonly getOverrideLabel: () => string | undefined = () => undefined,
+ private readonly getPickerOpen: () => boolean = () => false,
) {}
setSubagentCounts(counts: SubagentSummaryCounts): void {
@@ -87,7 +88,7 @@ export class SubagentSummaryLine implements Component, Focusable {
}
isSelectable(): boolean {
- return this.counts.total > 0 && this.openable;
+ return !this.getPickerOpen() && this.counts.total > 0 && this.openable;
}
handleInput(data: string): void {
@@ -108,12 +109,13 @@ export class SubagentSummaryLine implements Component, Focusable {
}
render(width: number): string[] {
+ if (this.getPickerOpen()) return [];
const lines = this.renderInfoLine(width);
if (this.counts.total === 0) return lines;
if (width < 2) return lines;
const safeWidth = width;
const inner = safeWidth - 2;
- const label = theme.fg("accent", "subagents");
+ const label = theme.fg("accent", "subagents");
const top = truncateToWidth(
`${theme.fg("border", "╭─ ")}${label}${theme.fg("border", ` ${"─".repeat(Math.max(0, inner - 3 - visibleWidth(label)))}╮`)}`,
safeWidth,
diff --git a/packages/coding-agent/src/modes/interactive/feature-hints.ts b/packages/coding-agent/src/modes/interactive/feature-hints.ts
deleted file mode 100644
index 8b3d8134ef..0000000000
--- a/packages/coding-agent/src/modes/interactive/feature-hints.ts
+++ /dev/null
@@ -1,137 +0,0 @@
-import type { AppKeybinding } from "../../core/keybindings.js";
-
-export interface FeatureHintContext {
- getKeybinding(action: AppKeybinding): string | undefined;
- isResidentSession: boolean;
-}
-
-interface FeatureHintDefinition {
- id: string;
- getText(context: FeatureHintContext): string | undefined;
-}
-
-export interface FeatureHint {
- id: string;
- text: string;
-}
-
-export const FEATURE_HINTS: readonly FeatureHintDefinition[] = [
- {
- id: "side-question",
- getText: () => "Use /btw <question> to ask questions without interrupting your agent.",
- },
- {
- id: "prompt-stash",
- getText: ({ getKeybinding }) => {
- const key = getKeybinding("app.prompt.stash");
- return key ? `Press ${key} to stash your prompt and restore it later.` : undefined;
- },
- },
- {
- id: "follow-up",
- getText: ({ getKeybinding }) => {
- const key = getKeybinding("app.message.followUp");
- return key ? `Press ${key} to send a message after your agent finishes.` : undefined;
- },
- },
- {
- id: "heartbeat",
- getText: () => "Use /heartbeat every 10m <instruction> to repeat a task on a schedule.",
- },
- {
- id: "subagents",
- getText: () => "Prime Agent can delegate tasks to subagents and run them in parallel.",
- },
- {
- id: "agents-view",
- getText: ({ getKeybinding, isResidentSession }) => {
- if (!isResidentSession) return undefined;
- const key = getKeybinding("app.agents.back");
- return key ? `Hit ${key} for Session View: search running, idle, and inactive sessions.` : undefined;
- },
- },
- {
- id: "session-rewind",
- getText: () => "Run /tree to open the session tree and return to a previous message.",
- },
- {
- id: "steering",
- getText: () => "Send a message while your agent works to steer its current task.",
- },
- {
- id: "agent-messaging",
- getText: () => "Agents can message each other to share context and coordinate their work.",
- },
- {
- id: "goal",
- getText: () => "Use /goal <objective> to keep your agent working until the goal is complete.",
- },
- {
- id: "refine",
- getText: () => "Use /refine to turn useful lessons into reusable skills, memory, and prompts.",
- },
- {
- id: "trace-sharing",
- getText: () => "Share traces with Prime Intellect using /traces on to train open-source LLMs.",
- },
- {
- id: "persistent-ipython",
- getText: () => "Compaction removes kernel variables over 16 MiB; smaller state persists.",
- },
- {
- id: "context-usage",
- getText: () => "Use /context to check token usage, cost, and remaining context.",
- },
- {
- id: "session-fork",
- getText: () => "Use /fork to start a new session from an earlier prompt.",
- },
- {
- id: "compaction",
- getText: () => "Use /compact <instructions> to summarize old messages and free up context.",
- },
- {
- id: "auto-compaction",
- getText: () => "Prime Agent automatically compacts long sessions before context fills up.",
- },
- {
- id: "auto-refine",
- getText: () => "Prime Agent self-improves by refining skills, memories, prompts, and subagents.",
- },
- {
- id: "background-running",
- getText: ({ isResidentSession }) =>
- isResidentSession ? "You can close the terminal while your agent keeps running in the background." : undefined,
- },
-] as const;
-
-export class FeatureHintDeck {
- private remaining: FeatureHint[] = [];
- private previousId: string | undefined;
-
- next(context: FeatureHintContext): FeatureHint | undefined {
- if (this.remaining.length === 0) {
- this.refill(context);
- }
- const hint = this.remaining.pop();
- if (hint) {
- this.previousId = hint.id;
- }
- return hint;
- }
-
- private refill(context: FeatureHintContext): void {
- const hints = FEATURE_HINTS.flatMap((hint) => {
- const text = hint.getText(context);
- return text ? [{ id: hint.id, text }] : [];
- });
- for (let index = hints.length - 1; index > 0; index--) {
- const target = Math.floor(Math.random() * (index + 1));
- [hints[index], hints[target]] = [hints[target]!, hints[index]!];
- }
- if (hints.length > 1 && hints[hints.length - 1]?.id === this.previousId) {
- [hints[0], hints[hints.length - 1]] = [hints[hints.length - 1]!, hints[0]!];
- }
- this.remaining = hints;
- }
-}
diff --git a/packages/coding-agent/src/modes/interactive/interactive-mode.ts b/packages/coding-agent/src/modes/interactive/interactive-mode.ts
index 7cd3c24313..59f648a4a1 100644
--- a/packages/coding-agent/src/modes/interactive/interactive-mode.ts
+++ b/packages/coding-agent/src/modes/interactive/interactive-mode.ts
@@ -205,14 +205,20 @@ import { type FileChangeSummary, formatTotalChangeSummary, mergeTurnFileChanges
import { ExtensionEditorComponent } from "./components/extension-editor.js";
import { ExtensionInputComponent } from "./components/extension-input.js";
import { ExtensionSelectorComponent } from "./components/extension-selector.js";
-import { FEATURE_HINT_ANIMATION_INTERVAL_MS, FeatureHintComponent } from "./components/feature-hint.js";
import { FooterComponent } from "./components/footer.js";
import { HeartbeatManagerComponent } from "./components/heartbeat-manager.js";
import { InjectedPromptMessageComponent, isInjectedPromptMessage } from "./components/injected-prompt-message.js";
-import { formatKeyText, keyHint, keyText, rawKeyHint } from "./components/keybinding-hints.js";
+import {
+ formatConversationDetailStatus,
+ formatKeyText,
+ keyHint,
+ keyText,
+ rawKeyHint,
+} from "./components/keybinding-hints.js";
import { createMermaidMarkdownTransform } from "./components/mermaid.js";
import type { AuthSelectorProvider } from "./components/oauth-selector.js";
import { PrimeOnboardingSplashComponent } from "./components/prime-onboarding-splash.js";
+import { PromptContextLine } from "./components/prompt-context-line.js";
import { styleArgumentTokens } from "./components/prompt-highlight.js";
import {
MalformedRefinementOutcomeMessageComponent,
@@ -242,7 +248,6 @@ import {
import { TreeSelectorComponent } from "./components/tree-selector.js";
import { UserMessageComponent } from "./components/user-message.js";
import { UserMessageSelectorComponent } from "./components/user-message-selector.js";
-import { FeatureHintDeck } from "./feature-hints.js";
import { scopeHeartbeatsToSession } from "./heartbeat-scope.js";
import {
collectMarkedImages,
@@ -296,20 +301,6 @@ interface PendingToolCallRenderInput {
const HEARTBEAT_LEGACY_PROMPT_MIN_TOLERANCE_MS = 15_000;
const HEARTBEAT_LEGACY_PROMPT_MAX_TOLERANCE_MS = 120_000;
const MODEL_CATALOG_REFRESH_TTL_MS = 60_000;
-const FEATURE_HINT_DELAY_MS = 5_000;
-
-export const START_HINTS = [
- 'Try "refactor @<filepath>"',
- 'Try "fix bugs in @<filepath>"',
- 'Try "add tests for @<filepath>"',
- 'Try "explain how @<filepath> works"',
- 'Try "improve performance in @<filepath>"',
-] as const;
-
-export function getRandomStartHint(random = Math.random): (typeof START_HINTS)[number] {
- return START_HINTS[Math.floor(random() * START_HINTS.length)] ?? START_HINTS[0];
-}
-
function isLabeledQueuedPreview(message: string): boolean {
return (
message.startsWith(`${HEARTBEAT_PROMPT_PREVIEW_LABEL}: `) ||
@@ -931,7 +922,6 @@ export class InteractiveMode {
private statusContainer: Container;
private queuedMessagesContainer: Container;
private sideQuestionContainer: Container;
- private featureHintContainer: Container;
private defaultEditor: CustomEditor;
private editor: EditorComponent;
private readonly promptStashStore: ClientPromptStashStore | undefined;
@@ -954,7 +944,6 @@ export class InteractiveMode {
// Stored so the same manager can be injected into custom editors, selectors, and extension UI.
private keybindings: KeybindingsManager;
private version: string;
- private readonly startHint = getRandomStartHint();
private isInitialized = false;
private onInputCallback?: (text: string | undefined) => void;
private submittedInputBehavior: "steer" | "followUp" = "steer";
@@ -974,14 +963,6 @@ export class InteractiveMode {
// Start of the in-flight run; survives loader teardown so the elapsed display doesn't reset on re-entry.
private turnStartedAt: number | undefined = undefined;
private workingTimer: NodeJS.Timeout | undefined = undefined;
- private readonly featureHintDeck = new FeatureHintDeck();
- private currentFeatureHint: string | undefined;
- private featureHintEligibleAt = 0;
- private featureHintTimer: NodeJS.Timeout | undefined;
- private featureHintAnimationTimer: NodeJS.Timeout | undefined;
- private featureHintComponent: FeatureHintComponent | undefined;
- private featureHintRunPending = false;
- private featureHintSuppressedByQueue = false;
private pulseTimer: NodeJS.Timeout | undefined = undefined;
private pulseFrame = 0;
private readonly activityTracker = new AgentActivityTracker();
@@ -1175,7 +1156,6 @@ export class InteractiveMode {
this.statusContainer = new Container();
this.queuedMessagesContainer = new Container();
this.sideQuestionContainer = new Container();
- this.featureHintContainer = new Container();
this.widgetContainerAbove = new Container();
this.widgetContainerBelow = new Container();
this.recapContainer = new Container();
@@ -1187,8 +1167,6 @@ export class InteractiveMode {
paddingX: editorPaddingX,
autocompleteMaxVisible,
isArgumentCommand: builtinSlashCommandTakesArgument,
- placeholder: this.startHint,
- placeholderColor: (text) => theme.fg("dim", text),
});
this.editor = this.defaultEditor;
this.mainContainer = new Container();
@@ -1205,6 +1183,7 @@ export class InteractiveMode {
() => this.getTrayLocationLabel(),
() => this.getTrayContextLabel(),
() => this.getTrayOverrideLabel(),
+ () => this.isInlinePickerOpen(),
);
this.subagentSummaryLine.setOpenable(this.options.returnToAgentsView === true);
this.subagentSummaryLine.onOpen = () => void this.openScopedAgentsView();
@@ -1351,7 +1330,7 @@ export class InteractiveMode {
aliases: command.aliases,
description: command.description,
argumentHint: command.argumentHint,
- takesArgument: command.takesArgument,
+ takesArgument: command.takesArgument === true,
}));
const modelCommand = slashCommands.find((command) => command.name === "model");
@@ -1490,8 +1469,7 @@ export class InteractiveMode {
verboseInstructions,
{
topPadding: true,
- getHideStartHint: () => !this.isNewChat(),
- getStartHint: () => this.startHint,
+ getHideStartHint: () => true,
},
);
this.headerContainer.addChild(this.builtInHeader);
@@ -1503,12 +1481,13 @@ export class InteractiveMode {
}
this.mainContainer.addChild(this.mainViewContainer);
- this.renderWidgets(); // Initialize with default spacer
+ this.renderWidgets();
this.mainContainer.addChild(this.widgetContainerAbove);
this.renderRecap();
for (const container of this.getPromptContextContainers()) {
this.mainContainer.addChild(container);
}
+ this.mainContainer.addChild(this.recapContainer);
this.mainContainer.addChild(this.editorContainer);
this.mainContainer.addChild(this.subagentSummaryLine);
this.mainContainer.addChild(this.widgetContainerBelow);
@@ -2907,7 +2886,6 @@ export class InteractiveMode {
}
private resetCurrentSessionRenderState(options?: { clearPromptStash?: boolean }): void {
- this.endFeatureHintRun();
this.chatContainer.clear();
this.shortcutGuideContainer.clear();
this.pendingMessagesContainer.clear();
@@ -2917,7 +2895,6 @@ export class InteractiveMode {
// The selection and its stashed draft belong to the previous session;
// every editor draft is cleared below, so discard rather than restore.
this.queueSelection.reset();
- this.featureHintSuppressedByQueue = false;
if (options?.clearPromptStash) {
this.promptStash = undefined;
if (this.promptStashState) this.promptStashState.queuedStashes = undefined;
@@ -3301,11 +3278,9 @@ export class InteractiveMode {
this.loadingAnimation = this.createWorkingLoader();
this.statusContainer.addChild(this.loadingAnimation);
this.startWorkingTimer();
- this.startFeatureHintPresentation();
}
private stopWorkingLoader(): void {
- this.clearFeatureHintPresentation();
if (this.workingTimer) {
clearInterval(this.workingTimer);
this.workingTimer = undefined;
@@ -3318,112 +3293,6 @@ export class InteractiveMode {
this.statusContainer.clear();
}
- private startFeatureHintPresentation(): void {
- this.clearFeatureHintPresentation();
- if (this.shouldSuppressFeatureHint()) {
- return;
- }
- if (this.featureHintEligibleAt === 0) {
- this.featureHintEligibleAt = Date.now() + FEATURE_HINT_DELAY_MS;
- }
- const delay = Math.max(0, this.featureHintEligibleAt - Date.now());
- if (delay === 0) {
- this.showFeatureHint();
- return;
- }
- this.featureHintTimer = setTimeout(() => {
- this.featureHintTimer = undefined;
- this.showFeatureHint();
- }, delay);
- this.featureHintTimer.unref?.();
- }
-
- private showFeatureHint(): void {
- if (
- this.shouldSuppressFeatureHint() ||
- !this.loadingAnimation ||
- !this.shouldShowWorkingLoader() ||
- !this.statusContainer.children.includes(this.loadingAnimation)
- ) {
- return;
- }
- if (!this.currentFeatureHint) {
- const hint = this.featureHintDeck.next({
- getKeybinding: (action) => {
- const key = keyText(action);
- return key ? this.capitalizeKey(key) : undefined;
- },
- isResidentSession: this.options.returnToAgentsView === true,
- });
- this.currentFeatureHint = hint?.text;
- }
- if (!this.currentFeatureHint) {
- return;
- }
- this.featureHintComponent = new FeatureHintComponent(this.currentFeatureHint);
- this.featureHintContainer.addChild(this.featureHintComponent);
- this.renderRecap();
- this.featureHintAnimationTimer = setInterval(() => {
- this.featureHintComponent?.advance();
- this.ui.requestRender();
- }, FEATURE_HINT_ANIMATION_INTERVAL_MS);
- this.featureHintAnimationTimer.unref?.();
- this.ui.requestRender();
- }
-
- private clearFeatureHintPresentation(): void {
- if (this.featureHintTimer) {
- clearTimeout(this.featureHintTimer);
- this.featureHintTimer = undefined;
- }
- if (this.featureHintAnimationTimer) {
- clearInterval(this.featureHintAnimationTimer);
- this.featureHintAnimationTimer = undefined;
- }
- if (this.featureHintComponent) {
- this.featureHintContainer.removeChild(this.featureHintComponent);
- this.featureHintComponent = undefined;
- this.renderRecap();
- }
- }
-
- private resumeFeatureHintPresentation(): void {
- if (
- !this.shouldSuppressFeatureHint() &&
- this.loadingAnimation &&
- this.shouldShowWorkingLoader() &&
- this.statusContainer.children.includes(this.loadingAnimation)
- ) {
- this.startFeatureHintPresentation();
- }
- }
-
- private shouldSuppressFeatureHint(): boolean {
- const { steering, followUp } = this.getAllQueuedMessages();
- return steering.length > 0 || followUp.length > 0;
- }
-
- private endFeatureHintRun(): void {
- this.clearFeatureHintPresentation();
- this.currentFeatureHint = undefined;
- this.featureHintEligibleAt = 0;
- this.featureHintRunPending = false;
- }
-
- private prepareFeatureHintRun(message: AgentMessage): void {
- if (!this.featureHintRunPending) return;
- if (message.role === "assistant") {
- this.featureHintRunPending = false;
- return;
- }
- if (!startsAgentRun(message)) return;
-
- this.endFeatureHintRun();
- if (this.shouldShowWorkingLoader()) {
- this.startFeatureHintPresentation();
- }
- }
-
private updateWorkingPulse(): void {
const active = this.isAgentStreaming();
if (!active) {
@@ -3671,42 +3540,37 @@ export class InteractiveMode {
private renderWidgets(): void {
if (!this.widgetContainerAbove || !this.widgetContainerBelow) return;
- this.renderWidgetContainer(this.widgetContainerAbove, this.extensionWidgetsAbove, true, true);
- this.renderWidgetContainer(this.widgetContainerBelow, this.extensionWidgetsBelow, false, false);
+ this.renderWidgetContainer(this.widgetContainerAbove, this.extensionWidgetsAbove, true);
+ this.renderWidgetContainer(this.widgetContainerBelow, this.extensionWidgetsBelow, false);
this.ui.requestRender();
}
private renderRecap(): void {
if (!this.recapContainer) return;
this.recapContainer.clear();
- const recap = this.sessionRecap?.trim();
const showChanges = !this.isAgentStreaming() && this.agentRunFileChanges.size > 0;
if (showChanges) {
this.recapContainer.addChild(
new TruncatedText(formatTotalChangeSummary([...this.agentRunFileChanges.values()]), 1, 0),
);
}
- if (recap) {
- this.recapContainer.addChild(new TruncatedText(theme.fg("dim", `Recap: ${recap}`), 1, 0));
- }
- if ((recap || showChanges) && !this.featureHintComponent) {
- this.recapContainer.addChild(new Spacer(1));
- }
+ this.recapContainer.addChild(
+ new PromptContextLine(
+ () => this.sessionRecap,
+ (maxWidth) => this.getPromptContextLabel(maxWidth),
+ ),
+ );
this.ui.requestRender();
}
private renderWidgetContainer(
container: Container,
widgets: Map<string, Component & { dispose?(): void }>,
- spacerWhenEmpty: boolean,
leadingSpacer: boolean,
): void {
container.clear();
if (widgets.size === 0) {
- if (spacerWhenEmpty) {
- container.addChild(new Spacer(1));
- }
return;
}
@@ -5423,9 +5287,6 @@ export class InteractiveMode {
this.updateConnectionStateFromEvent(event);
// A new user message resets the activity tracker to 0, so the in-flight baseline must
// reset with it. (agent_start on auto-retry does not reset the tracker.)
- if (event.type === "message_start") {
- this.prepareFeatureHintRun(event.message);
- }
if (event.type === "message_start" && (event.message.role === "user" || isAgentSessionMessage(event.message))) {
this.contextUsageTokenBaseline = 0;
this.clearShortcutGuide();
@@ -5437,7 +5298,6 @@ export class InteractiveMode {
switch (event.type) {
case "agent_start":
- this.featureHintRunPending = this.getRetryAttempt() === 0;
this.resetPendingToolState();
this.renderRecap();
if (this.settingsManager.getShowTerminalProgress()) {
@@ -6084,7 +5944,8 @@ export class InteractiveMode {
}
private focusSubagentSummary(): boolean {
- if (!this.subagentSummaryLine.isSelectable() || this.getTrayOverrideLabel()) return false;
+ if (this.isInlinePickerOpen() || !this.subagentSummaryLine.isSelectable() || this.getTrayOverrideLabel())
+ return false;
this.ui.setFocus(this.subagentSummaryLine);
this.ui.requestRender();
return true;
@@ -6121,7 +5982,19 @@ export class InteractiveMode {
this.editor.handleInput(data);
}
+ // Pickers mount either as overlays (model/provider/MCP menu) or in place of
+ // the editor (thinking, settings, and scoped-model selectors); the tray stays
+ // hidden while either surface is up. Autocomplete keeps focus in the editor.
+ private isInlinePickerOpen(): boolean {
+ const editorAutocomplete =
+ this.editor instanceof CustomEditor && this.editor.focused && this.editor.isShowingAutocomplete();
+ if (this.ui.hasOverlay() && !editorAutocomplete) return true;
+ const editorChild = this.editorContainer.children[0];
+ return editorChild !== undefined && editorChild !== this.editor;
+ }
+
private getTrayOverrideLabel(): string | undefined {
+ if (this.isInlinePickerOpen()) return undefined;
if (this.isCtrlCExitHintVisible()) {
const clearKey = keyText("app.clear");
return clearKey ? `Press ${clearKey} again to exit` : "Press again to exit";
@@ -6134,61 +6007,64 @@ export class InteractiveMode {
}
private getTrayLocationLabel(): string | undefined {
- const modelLabel = this.getModelTrayLabel();
+ if (this.isInlinePickerOpen()) return undefined;
+ const sessionDepth = this.options.sessionDepth;
const hasChildren = this.options.sessionHasChildren === true || (this.subagentSnapshots?.size ?? 0) > 0;
- const depthLabel = formatAgentDepthLabel(this.options.sessionDepth, hasChildren);
- const shortcutsHint = this.getShortcutsTrayHint();
+ // Depth is subagent-session context: a root session (depth 0) never shows
+ // a depth label, even while its children run.
+ const depthLabel = sessionDepth ? formatAgentDepthLabel(sessionDepth, hasChildren) : undefined;
const agentsHint = this.getAgentsViewTrayHint();
- return [agentsHint, depthLabel, modelLabel, shortcutsHint]
- .filter((label): label is string => label !== undefined)
- .join(" ");
- }
-
- private getShortcutsTrayHint(): string | undefined {
- if (!this.isNewChat() || this.editor.getText().length > 0) {
- return undefined;
- }
- return keyText("app.shortcuts") ? keyHint("app.shortcuts", "for shortcuts") : "/hotkeys for shortcuts";
+ return [agentsHint, depthLabel].filter((label): label is string => label !== undefined).join(" ");
}
private isNewChat(): boolean {
return (this.connectionState?.messageCount ?? 0) === 0 && this.connectionState?.isStreaming !== true;
}
- private getModelTrayLabel(): string {
+ private getPromptContextLabel(maxWidth: number): string | undefined {
+ if (maxWidth < 1) return undefined;
+ return theme.fg(
+ "dim",
+ truncateToWidth(formatConversationDetailStatus(this.toolOutputExpanded, this.editDiffsExpanded), maxWidth, ""),
+ );
+ }
+
+ private getModelContextLabel(maxWidth = Number.MAX_SAFE_INTEGER): string | undefined {
+ if (maxWidth < 1) return undefined;
const model = this.getCurrentModel();
- if (!model) {
- return "—";
- }
- const parts = [model.name];
- if (model.reasoning) {
- const level = this.connectionState?.thinkingLevel ?? "off";
- if (level !== "off") {
- parts.push(level);
+ const parts: string[] = [];
+ if (model) {
+ const providerPrefix = `${model.provider}/`;
+ const modelId = model.id.startsWith(providerPrefix) ? model.id.slice(providerPrefix.length) : model.id;
+ const effort = model.reasoning ? this.connectionState?.thinkingLevel : undefined;
+ parts.push(effort ? `${modelId}:${effort.toLowerCase()}` : modelId);
+ if (this.connectionState?.serviceTier === "priority") {
+ parts.push("fast");
}
}
- if (this.connectionState?.serviceTier === "priority") {
- parts.push("fast");
+ const usage = this.getConnectionContextUsage();
+ if (usage && typeof usage.tokens === "number" && typeof usage.percent === "number") {
+ parts.push(`${formatTokenCount(usage.tokens)} (${Math.round(usage.percent)}%)`);
}
- return parts.join(" • ");
+ if (parts.length === 0) return undefined;
+ return theme.fg("dim", truncateToWidth(parts.join(" · "), maxWidth, ""));
}
private getAgentsViewTrayHint(): string | undefined {
if (!this.options.returnToAgentsView) {
return undefined;
}
- return keyHint("app.agents.back", "agents/resume");
+ return keyHint("app.agents.back", "manage");
}
private getTrayContextLabel(): string | undefined {
+ if (this.isInlinePickerOpen()) return undefined;
const goalLabel = this.getTrayGoalLabel();
const heartbeatLabel = this.getTrayHeartbeatLabel();
- const usage = this.getConnectionContextUsage();
- const contextLabel =
- usage && typeof usage.tokens === "number" && typeof usage.percent === "number"
- ? `${formatTokenCount(usage.tokens)} (${Math.round(usage.percent)}%)`
- : undefined;
- return [goalLabel, heartbeatLabel, contextLabel].filter((label) => label !== undefined).join(" · ") || undefined;
+ return (
+ [goalLabel, heartbeatLabel, this.getModelContextLabel()].filter((label) => label !== undefined).join(" · ") ||
+ undefined
+ );
}
private getTrayHeartbeatLabel(): string | undefined {
@@ -7306,11 +7182,11 @@ export class InteractiveMode {
}
private getPromptContextContainers(): Container[] {
- return [this.recapContainer, this.featureHintContainer, this.queuedMessagesContainer, this.sideQuestionContainer];
+ return [this.queuedMessagesContainer, this.sideQuestionContainer];
}
private getPromptDockComponents(): Component[] {
- return [this.editorContainer, this.subagentSummaryLine, this.footerSlot];
+ return [this.recapContainer, this.editorContainer, this.subagentSummaryLine, this.footerSlot];
}
/** Enter or leave fullscreen rendering without touching the persisted setting. */
@@ -7536,13 +7412,6 @@ export class InteractiveMode {
const hintText = theme.fg("dim", `╰─ ${dequeueHint} to browse and edit queued messages`);
this.queuedMessagesContainer.addChild(new TruncatedText(hintText, 1, 0));
}
- if (hasQueuedMessages && !this.featureHintSuppressedByQueue) {
- this.featureHintSuppressedByQueue = true;
- this.clearFeatureHintPresentation();
- } else if (!hasQueuedMessages && this.featureHintSuppressedByQueue) {
- this.featureHintSuppressedByQueue = false;
- this.resumeFeatureHintPresentation();
- }
}
private flushPendingBashComponents(): void {
@@ -10171,7 +10040,6 @@ ${interrupt ? `| \`${interrupt}\` | Interrupt current operation |\n` : ""}${shor
}
this.stopWorkingLoader();
this.discardRefineLoader();
- this.endFeatureHintRun();
this.stopWorkingPulse();
this.stopGoalTrayTimer();
this.closeHeartbeatManager();
diff --git a/packages/coding-agent/test/custom-editor.test.ts b/packages/coding-agent/test/custom-editor.test.ts
index 37ee3e034e..ba1ce8873f 100644
--- a/packages/coding-agent/test/custom-editor.test.ts
+++ b/packages/coding-agent/test/custom-editor.test.ts
@@ -1,9 +1,10 @@
import type { AutocompleteProvider, EditorTheme, OverlayHandle, TUI } from "@earendil-works/pi-tui";
import { CURSOR_MARKER, setKeybindings, visibleWidth } from "@earendil-works/pi-tui";
-import { beforeEach, describe, expect, it, vi } from "vitest";
+import stripAnsi from "strip-ansi";
+import { beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
import { KeybindingsManager } from "../src/core/keybindings.js";
import { CustomEditor } from "../src/modes/interactive/components/custom-editor.js";
-import { initTheme, type ThemeColor, theme } from "../src/modes/interactive/theme/theme.js";
+import { initTheme, preloadCodeHighlighter, type ThemeColor, theme } from "../src/modes/interactive/theme/theme.js";
const passthrough = (text: string) => text;
@@ -58,6 +59,10 @@ const autocompleteProvider: AutocompleteProvider = {
};
describe("CustomEditor", () => {
+ beforeAll(async () => {
+ await preloadCodeHighlighter();
+ });
+
beforeEach(() => {
setKeybindings(new KeybindingsManager());
vi.clearAllMocks();
@@ -266,6 +271,22 @@ describe("CustomEditor", () => {
expect(lines[1]).toContain("...");
});
+ it("updates placeholder and queue header alignment when editor padding changes", () => {
+ const editor = new CustomEditor(fakeTui, editorTheme, new KeybindingsManager(), {
+ placeholder: "type to start",
+ });
+ editor.getHeaderLine = () => "queued message";
+
+ for (const padding of [5, 1]) {
+ editor.setPaddingX(padding);
+ const lines = editor.render(40).map((line) => stripAnsi(line));
+
+ expect(lines[1]!.indexOf("queued message")).toBe(padding);
+ expect(lines[3]!.indexOf("type to start")).toBe(padding + 3);
+ expect(lines.every((line) => visibleWidth(line) === 40)).toBe(true);
+ }
+ });
+
it("keeps the surface background across truncation resets in the header line", () => {
const backgroundColor = (text: string) => `<bg>${text}</bg>`;
const editor = new CustomEditor(fakeTui, { ...editorTheme, backgroundColor }, new KeybindingsManager());
diff --git a/packages/coding-agent/test/interactive-mode-ctrl-c.test.ts b/packages/coding-agent/test/interactive-mode-ctrl-c.test.ts
index caa8a1a8e8..8829a7ec3a 100644
--- a/packages/coding-agent/test/interactive-mode-ctrl-c.test.ts
+++ b/packages/coding-agent/test/interactive-mode-ctrl-c.test.ts
@@ -36,7 +36,8 @@ type FakeInteractiveMode = {
abortBash: Mock;
};
subagentSummaryLine: { invalidate: Mock };
- ui: { requestRender: Mock; onDebug?: () => void };
+ editorContainer: { children: unknown[] };
+ ui: { requestRender: Mock; onDebug?: () => void; hasOverlay: () => boolean };
updatePendingMessagesDisplay: Mock;
showError: Mock;
showTreeSelector: Mock;
@@ -107,7 +108,8 @@ function createInteractiveFake(options: {
abortBash: vi.fn(),
},
subagentSummaryLine: { invalidate: vi.fn() },
- ui: { requestRender: vi.fn() },
+ editorContainer: { children: [editor] },
+ ui: { requestRender: vi.fn(), hasOverlay: () => false },
queueSelection: { isBrowsing: false, reset: () => "" },
updatePendingMessagesDisplay: vi.fn(),
showError: vi.fn(),
diff --git a/packages/coding-agent/test/interactive-mode-effort-command.test.ts b/packages/coding-agent/test/interactive-mode-effort-command.test.ts
index 380b075540..3be7204500 100644
--- a/packages/coding-agent/test/interactive-mode-effort-command.test.ts
+++ b/packages/coding-agent/test/interactive-mode-effort-command.test.ts
@@ -1,6 +1,7 @@
import type { ThinkingLevel } from "@earendil-works/pi-agent-core";
import type { Api, Model, ServiceTier } from "@earendil-works/pi-ai";
-import type { AutocompleteItem, Component } from "@earendil-works/pi-tui";
+import type { AutocompleteItem, AutocompleteProvider, Component } from "@earendil-works/pi-tui";
+import stripAnsi from "strip-ansi";
import { beforeAll, describe, expect, it, vi } from "vitest";
import { ThinkingSelectorComponent } from "../src/modes/interactive/components/thinking-selector.js";
import { InteractiveMode } from "../src/modes/interactive/interactive-mode.js";
@@ -48,12 +49,13 @@ type FastCommandContext = {
patchConnectionState: (patch: Record<string, unknown>) => void;
getCurrentModel: () => Model<Api> | undefined;
currentModelSupportsFastMode: () => boolean;
+ getConnectionContextUsage: () => undefined;
};
type FastInteractiveModePrototype = {
currentModelSupportsFastMode(this: FastCommandContext): boolean;
handleFastCommand(this: FastCommandContext): void;
- getModelTrayLabel(this: FastCommandContext): string;
+ getModelContextLabel(this: FastCommandContext, maxWidth: number): string;
};
const fastInteractiveModePrototype = InteractiveMode.prototype as unknown as FastInteractiveModePrototype;
@@ -86,6 +88,7 @@ function makeFastContext(model: Model<Api> = testModel("openai-codex", "gpt-5.5"
context.connectionState = { ...context.connectionState, ...patch } as FastCommandContext["connectionState"];
}),
getCurrentModel: () => model,
+ getConnectionContextUsage: () => undefined,
currentModelSupportsFastMode: () => fastInteractiveModePrototype.currentModelSupportsFastMode.call(context),
};
context.agentConnection = {
@@ -128,6 +131,39 @@ describe("InteractiveMode /effort", () => {
});
describe("argument autocomplete", () => {
+ it("completes built-in picker commands bare while retaining their optional argument suggestions", async () => {
+ const mode = Object.create(InteractiveMode.prototype) as InteractiveMode;
+ Object.assign(mode, {
+ currentModelSupportsFastMode: () => false,
+ getCachedModelCandidates: () => [],
+ getAvailableThinkingLevels: () => ["low", "high"],
+ getThinkingLevelCompletions: () => [{ value: "high", label: "high" }],
+ connectionCommands: [],
+ skillCommands: new Map(),
+ uiServices: { settingsManager: { getEnableSkillCommands: () => false } },
+ getCurrentCwd: () => process.cwd(),
+ fdPath: null,
+ });
+ const create = Reflect.get(InteractiveMode.prototype, "createBaseAutocompleteProvider") as (
+ this: InteractiveMode,
+ ) => AutocompleteProvider;
+ const provider = create.call(mode);
+ const options = { signal: new AbortController().signal };
+ for (const name of ["model", "effort"]) {
+ const text = `/${name}`;
+ const result = await provider.getSuggestions([text], 0, text.length, options);
+ const item = result!.items.find((candidate) => candidate.value === name)!;
+ expect(item.takesArgument).not.toBe(true);
+ expect(provider.applyCompletion([text], 0, text.length, item, result!.prefix)).toEqual({
+ lines: [text],
+ cursorLine: 0,
+ cursorCol: text.length,
+ });
+ }
+ const effort = await provider.getSuggestions(["/effort h"], 0, 9, options);
+ expect(effort?.items[0]?.value).toBe("high");
+ });
+
it("lists every supported level for an empty prefix and marks the current one", () => {
const context = makeContext();
@@ -407,11 +443,13 @@ describe("InteractiveMode /effort", () => {
);
});
- it("shows Fast mode beside the model and effort level", () => {
+ it("keeps Fast mode with the model ID and effort in the bottom tray", () => {
const context = makeFastContext();
context.connectionState = { sessionId: "session-1", serviceTier: "priority", thinkingLevel: "high" };
- expect(fastInteractiveModePrototype.getModelTrayLabel.call(context)).toBe("gpt-5.5 • high • fast");
+ expect(stripAnsi(fastInteractiveModePrototype.getModelContextLabel.call(context, 80))).toBe(
+ "gpt-5.5:high · fast",
+ );
});
});
});
diff --git a/packages/coding-agent/test/interactive-mode-feature-hints.test.ts b/packages/coding-agent/test/interactive-mode-feature-hints.test.ts
index 5be90902e9..653e151db4 100644
--- a/packages/coding-agent/test/interactive-mode-feature-hints.test.ts
+++ b/packages/coding-agent/test/interactive-mode-feature-hints.test.ts
@@ -1,8 +1,5 @@
-import { type Component, Container, visibleWidth } from "@earendil-works/pi-tui";
-import stripAnsi from "strip-ansi";
+import { type Component, Container } from "@earendil-works/pi-tui";
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
-import { FEATURE_HINT_ANIMATION_INTERVAL_MS } from "../src/modes/interactive/components/feature-hint.js";
-import { FEATURE_HINTS, FeatureHintDeck } from "../src/modes/interactive/feature-hints.js";
import { InteractiveMode } from "../src/modes/interactive/interactive-mode.js";
import { initTheme } from "../src/modes/interactive/theme/theme.js";
@@ -21,185 +18,46 @@ function callPrivate(mode: object, name: string): void {
}
function createMode() {
- const statusContainer = new Container();
- const featureHintContainer = new Container();
const loader = new FakeLoader();
- statusContainer.addChild(loader);
- const hint = { id: "test", text: "This is a deliberately long feature hint for narrow terminals." };
- const featureHintDeck = { next: vi.fn(() => hint) };
- const requestRender = vi.fn();
- const mode = {
- statusContainer,
- featureHintContainer,
- loadingAnimation: loader,
- workingVisible: true,
- connectionState: {
- isStreaming: true,
- sessionActions: { queuedCount: 0, steering: [], followUps: [] },
- },
- workingTimer: undefined,
- workingStartedAt: 0,
- featureHintDeck,
- currentFeatureHint: undefined,
- featureHintEligibleAt: 0,
- featureHintTimer: undefined,
- featureHintAnimationTimer: undefined,
- featureHintComponent: undefined,
- featureHintRunPending: false,
- compactionQueuedMessages: [],
- options: { returnToAgentsView: true },
- ui: { requestRender },
- };
- Object.setPrototypeOf(mode, InteractiveMode.prototype);
- return { mode, statusContainer, featureHintContainer, loader, featureHintDeck, requestRender };
+ const mode = Object.assign(Object.create(InteractiveMode.prototype), {
+ statusContainer: new Container(),
+ queuedMessagesContainer: new Container(),
+ sideQuestionContainer: new Container(),
+ createWorkingLoader: () => loader,
+ startWorkingTimer: vi.fn(),
+ ui: { requestRender: vi.fn() },
+ });
+ return { mode, loader };
}
-describe("feature hint deck", () => {
- it("shows every available hint before repeating and avoids a boundary repeat", () => {
- const deck = new FeatureHintDeck();
- const context = { getKeybinding: (action: string) => `Custom ${action}`, isResidentSession: true };
- const firstCycle = FEATURE_HINTS.map(() => deck.next(context));
-
- expect(firstCycle.every((hint) => hint !== undefined)).toBe(true);
- expect(new Set(firstCycle.map((hint) => hint?.id)).size).toBe(FEATURE_HINTS.length);
- expect(deck.next(context)?.id).not.toBe(firstCycle.at(-1)?.id);
- });
-
- it("uses configured shortcuts in keybinding-based hints", () => {
- const context = {
- getKeybinding: (action: string) => {
- if (action === "app.prompt.stash") return "Meta+S";
- if (action === "app.message.followUp") return "Meta+Enter";
- return "Meta+Left";
- },
- isResidentSession: true,
- };
- const textById = new Map(FEATURE_HINTS.map((hint) => [hint.id, hint.getText(context)]));
-
- expect(textById.get("prompt-stash")).toContain("Meta+S");
- expect(textById.get("follow-up")).toContain("Meta+Enter");
- expect(textById.get("agents-view")).toContain("Meta+Left");
- });
-
- it("hides resident-only hints in ephemeral sessions", () => {
- const context = { getKeybinding: () => "Left", isResidentSession: false };
- const textById = new Map(FEATURE_HINTS.map((hint) => [hint.id, hint.getText(context)]));
-
- expect(textById.get("agents-view")).toBeUndefined();
- expect(textById.get("background-running")).toBeUndefined();
- });
-});
-
-describe("InteractiveMode feature hints", () => {
- beforeAll(() => {
- initTheme("dark");
- });
-
- beforeEach(() => {
- vi.useFakeTimers();
- vi.setSystemTime(0);
- });
-
- afterEach(() => {
- vi.useRealTimers();
- });
-
- it("adds one animated truncated hint above the prompt after a sustained agent run", () => {
- const { mode, statusContainer, featureHintContainer, featureHintDeck, requestRender } = createMode();
-
- callPrivate(mode, "startFeatureHintPresentation");
- vi.advanceTimersByTime(4_999);
- expect(statusContainer.children).toHaveLength(1);
- expect(featureHintContainer.children).toHaveLength(0);
- expect(featureHintDeck.next).not.toHaveBeenCalled();
-
- vi.advanceTimersByTime(1);
- expect(statusContainer.children).toHaveLength(1);
- expect(featureHintContainer.children).toHaveLength(1);
- const lines = featureHintContainer.children[0]?.render(24) ?? [];
- expect(lines).toHaveLength(2);
- expect(stripAnsi(lines[0] ?? "")).toContain("Hint:");
- expect(lines[1]?.trim()).toBe("");
- expect(visibleWidth(lines[0] ?? "")).toBeLessThanOrEqual(24);
- expect(featureHintDeck.next).toHaveBeenCalledTimes(1);
- expect(requestRender).toHaveBeenCalledTimes(1);
-
- vi.advanceTimersByTime(FEATURE_HINT_ANIMATION_INTERVAL_MS);
- const animatedLines = featureHintContainer.children[0]?.render(24) ?? [];
- expect(stripAnsi(animatedLines[0] ?? "")).toBe(stripAnsi(lines[0] ?? ""));
- expect(animatedLines[0]).not.toBe(lines[0]);
- expect(requestRender).toHaveBeenCalledTimes(2);
- });
-
- it("cancels a pending hint when the loader stops", () => {
- const { mode, statusContainer, featureHintContainer, featureHintDeck, requestRender } = createMode();
-
- callPrivate(mode, "startFeatureHintPresentation");
- vi.advanceTimersByTime(2_000);
- callPrivate(mode, "stopWorkingLoader");
- vi.advanceTimersByTime(5_000);
-
- expect(statusContainer.children).toHaveLength(0);
- expect(featureHintContainer.children).toHaveLength(0);
- expect(featureHintDeck.next).not.toHaveBeenCalled();
- expect(requestRender).not.toHaveBeenCalled();
- });
-
- it("retains the hint and remaining delay when the loader is recreated", () => {
- const { mode, statusContainer, featureHintContainer, featureHintDeck } = createMode();
-
- callPrivate(mode, "startFeatureHintPresentation");
- vi.advanceTimersByTime(3_000);
+describe("InteractiveMode without feature-discovery tips", () => {
+ beforeAll(() => initTheme("dark"));
+ beforeEach(() => vi.useFakeTimers());
+ afterEach(() => vi.useRealTimers());
+
+ it("keeps sustained and restarted agent runs free of tip rows and tip timers", () => {
+ const { mode, loader } = createMode();
+ for (let run = 0; run < 3; run++) {
+ callPrivate(mode, "startWorkingLoader");
+ vi.advanceTimersByTime(60_000);
+ expect(mode.statusContainer.children).toEqual([loader]);
+ expect(mode.statusContainer.render(80).join("\n").trim()).toBe("loader");
+ expect(mode.queuedMessagesContainer.children).toHaveLength(0);
+ expect(mode.sideQuestionContainer.children).toHaveLength(0);
+ expect(vi.getTimerCount()).toBe(0);
+ }
callPrivate(mode, "stopWorkingLoader");
-
- const replacement = new FakeLoader();
- Reflect.set(mode, "loadingAnimation", replacement);
- statusContainer.addChild(replacement);
- callPrivate(mode, "startFeatureHintPresentation");
- vi.advanceTimersByTime(1_999);
- expect(statusContainer.children).toHaveLength(1);
- expect(featureHintContainer.children).toHaveLength(0);
- expect(featureHintDeck.next).not.toHaveBeenCalled();
-
- vi.advanceTimersByTime(1);
- expect(statusContainer.children).toHaveLength(1);
- expect(featureHintContainer.children).toHaveLength(1);
- expect(featureHintDeck.next).toHaveBeenCalledTimes(1);
-
- callPrivate(mode, "endFeatureHintRun");
- expect(statusContainer.children).toHaveLength(1);
- expect(featureHintContainer.children).toHaveLength(0);
- expect(Reflect.get(mode, "currentFeatureHint")).toBeUndefined();
+ expect(mode.statusContainer.children).toHaveLength(0);
+ expect(loader.stop).toHaveBeenCalled();
});
- it("keeps hints for steering and continuations, then restarts the delay for new runs", () => {
+ it("does not leave a delayed tip after a short run finishes", () => {
const { mode } = createMode();
- Reflect.set(mode, "currentFeatureHint", "Existing hint");
- Reflect.set(mode, "featureHintEligibleAt", 5_000);
-
- Reflect.get(InteractiveMode.prototype, "prepareFeatureHintRun").call(mode, {
- role: "user",
- content: [{ type: "text", text: "steer" }],
- timestamp: 0,
- });
- expect(Reflect.get(mode, "currentFeatureHint")).toBe("Existing hint");
-
- Reflect.set(mode, "featureHintRunPending", true);
- Reflect.get(InteractiveMode.prototype, "prepareFeatureHintRun").call(mode, {
- role: "assistant",
- content: [],
- });
- expect(Reflect.get(mode, "currentFeatureHint")).toBe("Existing hint");
- expect(Reflect.get(mode, "featureHintRunPending")).toBe(false);
-
- Reflect.set(mode, "featureHintRunPending", true);
- Reflect.get(InteractiveMode.prototype, "prepareFeatureHintRun").call(mode, {
- role: "user",
- content: [{ type: "text", text: "new run" }],
- timestamp: 0,
- });
- expect(Reflect.get(mode, "currentFeatureHint")).toBeUndefined();
- expect(Reflect.get(mode, "featureHintEligibleAt")).toBe(5_000);
- expect(Reflect.get(mode, "featureHintTimer")).toBeDefined();
+ callPrivate(mode, "startWorkingLoader");
+ vi.advanceTimersByTime(2_000);
+ callPrivate(mode, "stopWorkingLoader");
+ vi.advanceTimersByTime(60_000);
+ expect(mode.statusContainer.children).toHaveLength(0);
+ expect(vi.getTimerCount()).toBe(0);
});
});
diff --git a/packages/coding-agent/test/interactive-mode-prompt-stash.test.ts b/packages/coding-agent/test/interactive-mode-prompt-stash.test.ts
index eb7b746497..c2228c9725 100644
--- a/packages/coding-agent/test/interactive-mode-prompt-stash.test.ts
+++ b/packages/coding-agent/test/interactive-mode-prompt-stash.test.ts
@@ -1,4 +1,5 @@
import type { ImageContent } from "@earendil-works/pi-ai";
+import { Container } from "@earendil-works/pi-tui";
import { describe, expect, it, type Mock, vi } from "vitest";
import { KeybindingsManager } from "../src/core/keybindings.js";
import { InteractiveMode } from "../src/modes/interactive/interactive-mode.js";
@@ -73,7 +74,7 @@ type ResetHarness = PromptStashLiveMarkerHarness & {
activityTracker: { reset: Mock };
contextUsageTokenBaseline: number;
agentRunFileChanges: Map<string, unknown>;
- recapContainer: { clear: Mock };
+ recapContainer: Container;
ui: { requestRender: Mock };
ipythonToolComponents: Map<string, unknown>;
lateIpythonSentAgentMessages: Map<string, unknown>;
@@ -649,7 +650,7 @@ describe("InteractiveMode prompt stash", () => {
activityTracker: { reset: vi.fn() },
contextUsageTokenBaseline: 1,
agentRunFileChanges: new Map(),
- recapContainer: { clear: vi.fn() },
+ recapContainer: new Container(),
ui: { requestRender: vi.fn() },
ipythonToolComponents: new Map(),
lateIpythonSentAgentMessages: new Map(),
@@ -684,7 +685,7 @@ describe("InteractiveMode prompt stash", () => {
activityTracker: { reset: vi.fn() },
contextUsageTokenBaseline: 1,
agentRunFileChanges: new Map(),
- recapContainer: { clear: vi.fn() },
+ recapContainer: new Container(),
ui: { requestRender: vi.fn() },
ipythonToolComponents: new Map(),
lateIpythonSentAgentMessages: new Map(),
diff --git a/packages/coding-agent/test/interactive-mode-startup.test.ts b/packages/coding-agent/test/interactive-mode-startup.test.ts
index 35444ce746..6a080c6054 100644
--- a/packages/coding-agent/test/interactive-mode-startup.test.ts
+++ b/packages/coding-agent/test/interactive-mode-startup.test.ts
@@ -1,15 +1,24 @@
-import { Container, setKeybindings } from "@earendil-works/pi-tui";
+import {
+ type AutocompleteProvider,
+ type Component,
+ Container,
+ setKeybindings,
+ Text,
+ TUI,
+} from "@earendil-works/pi-tui";
import stripAnsi from "strip-ansi";
import { beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
+import { VirtualTerminal } from "../../tui/test/virtual-terminal.js";
import { KeybindingsManager } from "../src/core/keybindings.js";
-import {
- BrandSplashHeader,
- getRandomStartHint,
- InteractiveMode,
- START_HINTS,
-} from "../src/modes/interactive/interactive-mode.js";
+import { emptyUsage } from "../src/core/usage.js";
+import { AssistantMessageComponent } from "../src/modes/interactive/components/assistant-message.js";
+import { CustomEditor } from "../src/modes/interactive/components/custom-editor.js";
+import { RefinementOutcomeMessageComponent } from "../src/modes/interactive/components/refinement-outcome-message.js";
+import { SubagentSummaryLine } from "../src/modes/interactive/components/subagent-summary-line.js";
+import { ToolExecutionComponent } from "../src/modes/interactive/components/tool-execution.js";
+import { BrandSplashHeader, InteractiveMode } from "../src/modes/interactive/interactive-mode.js";
import type { PromptStashState } from "../src/modes/interactive/prompt-stash-state.js";
-import { getMarkdownTheme, initTheme } from "../src/modes/interactive/theme/theme.js";
+import { getEditorTheme, getMarkdownTheme, initTheme, theme } from "../src/modes/interactive/theme/theme.js";
describe("InteractiveMode startup hints", () => {
beforeAll(() => {
@@ -21,11 +30,16 @@ describe("InteractiveMode startup hints", () => {
});
function createMode(messageCount = 0, returnToAgentsView = false, getEditorText = () => "") {
+ const editor = { getText: getEditorText };
const mode = {
options: { returnToAgentsView },
- editor: { getText: getEditorText },
+ editor,
+ editorContainer: { children: [editor] as unknown[] },
+ ui: { hasOverlay: () => false },
+ heartbeatCatalog: [],
+ subagentSnapshots: new Map(),
connectionState: {
- model: { name: "test-model", reasoning: true },
+ model: { id: "test-model", name: "Test Model", provider: "test-provider", reasoning: true },
thinkingLevel: "high",
messageCount,
isStreaming: false,
@@ -43,7 +57,7 @@ describe("InteractiveMode startup hints", () => {
undefined,
{
topPadding: true,
- getStartHint: () => 'Try "refactor @<filepath>"',
+ getHideStartHint: () => true,
},
);
@@ -54,7 +68,8 @@ describe("InteractiveMode startup hints", () => {
expect(output).toContain("version v0.0.0");
expect(output).toContain("model test-model");
expect(output).toContain("cwd /tmp/project");
- expect(output).toContain('Try "refactor @<filepath>"');
+ expect(output).not.toContain("Try ");
+ expect(output).not.toContain("type to search sessions");
expect(output).not.toContain("input");
expect(output).not.toContain("files");
expect(output).not.toContain("help");
@@ -67,21 +82,302 @@ describe("InteractiveMode startup hints", () => {
expect(unpadded.render(120)[0]).not.toBe("");
});
- it("randomly selects from five concise filepath prompts", () => {
- expect(START_HINTS).toHaveLength(5);
- expect(new Set(START_HINTS).size).toBe(5);
+ it("keeps fresh-chat shortcut instructions out of the lower tray", () => {
+ const mode = createMode();
+ const label = Reflect.get(InteractiveMode.prototype, "getTrayLocationLabel").call(mode);
- for (const [index, hint] of START_HINTS.entries()) {
- expect(getRandomStartHint(() => index / START_HINTS.length)).toBe(hint);
- expect(hint).toMatch(/^Try ".*@<filepath>.*"$/);
- }
+ expect(stripAnsi(label)).toBe("");
});
- it("places the fresh-chat shortcut hint after the model and effort", () => {
+ it("shows the model ID and current effort in the lower tray and omits unsupported effort", () => {
const mode = createMode();
- const label = Reflect.get(InteractiveMode.prototype, "getTrayLocationLabel").call(mode);
+ const getLabel = (width: number) =>
+ Reflect.get(InteractiveMode.prototype, "getModelContextLabel").call(mode, width) as string | undefined;
+
+ expect(stripAnsi(getLabel(40)!)).toBe("test-model:high");
+ expect(stripAnsi(getLabel(6)!)).toBe("test-m");
+ expect(stripAnsi(getLabel(3)!)).toBe("tes");
+ expect(getLabel(0)).toBeUndefined();
+ mode.connectionState.thinkingLevel = "off";
+ expect(stripAnsi(getLabel(40)!)).toBe("test-model:off");
+ mode.connectionState.thinkingLevel = "xhigh";
+ mode.connectionState.isStreaming = true;
+ expect(stripAnsi(getLabel(40)!)).toBe("test-model:xhigh");
+ mode.connectionState.model.reasoning = false;
+ expect(stripAnsi(getLabel(40)!)).toBe("test-model");
+ });
+
+ it("shows context usage after model and effort below without duplicating it above", () => {
+ const mode = createMode(1);
+ mode.connectionState.model.id = "glm-5.3";
+ Object.assign(mode.connectionState, {
+ contextUsage: { contextWindow: 400_000, tokens: 175_000, percent: 43.75 },
+ });
+ const label = Reflect.get(InteractiveMode.prototype, "getModelContextLabel").call(mode, 120);
+
+ expect(stripAnsi(label)).toBe("glm-5.3:high · 175k (44%)");
+ expect(stripAnsi(Reflect.get(InteractiveMode.prototype, "getTrayContextLabel").call(mode))).toBe(
+ "glm-5.3:high · 175k (44%)",
+ );
+ expect(stripAnsi(Reflect.get(InteractiveMode.prototype, "getPromptContextLabel").call(mode, 120))).not.toContain(
+ "175k",
+ );
+ });
+
+ it("keeps available context usage visible when the model is unknown", () => {
+ const mode = createMode(1);
+ Reflect.deleteProperty(mode.connectionState, "model");
+ Object.assign(mode.connectionState, {
+ contextUsage: { contextWindow: 100_000, tokens: 12_000, percent: 12 },
+ });
+ const getLabel = () => Reflect.get(InteractiveMode.prototype, "getModelContextLabel").call(mode, 120);
+
+ expect(stripAnsi(getLabel())).toBe("12k (12%)");
+ Reflect.deleteProperty(mode.connectionState, "contextUsage");
+ expect(getLabel()).toBeUndefined();
+ });
+
+ it("refreshes context usage during streaming and omits unknown post-compaction counts", () => {
+ let outputTokens = 7_000;
+ const mode = Object.assign(createMode(1), {
+ recapContainer: new Container(),
+ agentRunFileChanges: new Map(),
+ activityTracker: { getStatus: () => ({ tokens: outputTokens }) },
+ contextUsageTokenBaseline: 5_000,
+ ui: { requestRender: vi.fn() },
+ });
+ Object.assign(mode.connectionState, {
+ contextUsage: { contextWindow: 100_000, tokens: 42_000, percent: 42 },
+ isStreaming: true,
+ });
+ Reflect.get(InteractiveMode.prototype, "renderRecap").call(mode);
+ const render = () => stripAnsi(Reflect.get(InteractiveMode.prototype, "getModelContextLabel").call(mode));
+
+ expect(render()).toContain("test-model:high · 44k (44%)");
+ outputTokens = 8_000;
+ expect(render()).toContain("test-model:high · 45k (45%)");
+ Object.assign(mode.connectionState, { contextUsage: { contextWindow: 100_000, tokens: null, percent: null } });
+ expect(render()).toContain("test-model:high");
+ expect(render()).not.toContain("%");
+ Object.assign(mode.connectionState, {
+ contextUsage: { contextWindow: 100_000, tokens: 0, percent: 0 },
+ isStreaming: false,
+ });
+ expect(render()).toContain("test-model:high · 0 (0%)");
+ });
+
+ it.each([
+ ["glm-5.3", "glm-5.3"],
+ ["glm-5.3-high", "glm-5.3-high"],
+ ["test-provider/glm-5.3", "glm-5.3"],
+ ["Qwen/Qwen3-Next-80B-A3B-Instruct", "Qwen/Qwen3-Next-80B-A3B-Instruct"],
+ ])("shows model ID %s without changing its spelling or identity", (id, expected) => {
+ const mode = createMode();
+ mode.connectionState.model.id = id;
+ const before = { ...mode.connectionState.model };
+
+ expect(stripAnsi(Reflect.get(InteractiveMode.prototype, "getModelContextLabel").call(mode, 120))).toBe(
+ `${expected}:high`,
+ );
+ expect(mode.connectionState.model).toEqual(before);
+ });
+
+ it("keeps fast mode separate and omits unavailable effort", () => {
+ const mode = createMode();
+ Object.assign(mode.connectionState, { serviceTier: "priority", thinkingLevel: undefined });
+ expect(stripAnsi(Reflect.get(InteractiveMode.prototype, "getModelContextLabel").call(mode))).toBe(
+ "test-model · fast",
+ );
+ });
+
+ it.each([
+ [false, false, "Collapsed mode (Ctrl+O to expand)"],
+ [false, true, "Details mode (Ctrl+O to expand)"],
+ [true, true, "Expanded mode (Ctrl+O to collapse)"],
+ ] as const)("shows a muted detail status above the prompt (%s, %s)", (allOutput, details, expected) => {
+ const mode = Object.assign(createMode(), { toolOutputExpanded: allOutput, editDiffsExpanded: details });
+ const getLabel = () => Reflect.get(InteractiveMode.prototype, "getPromptContextLabel").call(mode, 120);
+ expect(getLabel()).toBe(theme.fg("dim", expected));
+ expect(stripAnsi(Reflect.get(InteractiveMode.prototype, "getTrayContextLabel").call(mode))).toBe(
+ "test-model:high",
+ );
+ setKeybindings(new KeybindingsManager({ "app.tools.expand": "ctrl+e" }));
+ expect(stripAnsi(getLabel())).toBe(expected.replace("Ctrl+O", "Ctrl+E"));
+ setKeybindings(new KeybindingsManager({ "app.tools.expand": [] }));
+ expect(stripAnsi(getLabel())).toBe(expected.split(" (")[0]);
+ });
+
+ it("refreshes effort in the lower tray without rebuilding the recap", () => {
+ const mode = {
+ ...createMode(),
+ recapContainer: new Container(),
+ agentRunFileChanges: new Map(),
+ ui: { requestRender: vi.fn() },
+ };
+ Object.setPrototypeOf(mode, InteractiveMode.prototype);
+ Reflect.get(InteractiveMode.prototype, "renderRecap").call(mode);
+ const render = () => stripAnsi(Reflect.get(InteractiveMode.prototype, "getModelContextLabel").call(mode) ?? "");
+
+ expect(render()).toContain("test-model:high");
+ mode.connectionState.thinkingLevel = "low";
+ expect(render()).toContain("test-model:low");
+ mode.connectionState.model.reasoning = false;
+ expect(render()).toContain("test-model");
+ expect(render()).not.toContain("low");
+ mode.connectionState.model.reasoning = true;
+ expect(render()).toContain("test-model:low");
+ Reflect.deleteProperty(mode.connectionState, "model");
+ expect(render()).toBe("");
+ });
+
+ it.each([false, true])("keeps effort outside custom editors and preserves drafts and headers (%s)", (ownHeader) => {
+ const keybindings = new KeybindingsManager();
+ const ui = { terminal: { rows: 24 }, requestRender: vi.fn(), setFocus: vi.fn() } as unknown as TUI;
+ const defaultEditor = new CustomEditor(ui, getEditorTheme(), keybindings);
+ defaultEditor.setText("unfinished draft");
+ const mode = {
+ ...createMode(),
+ ui,
+ keybindings,
+ defaultEditor,
+ editor: defaultEditor,
+ editorContainer: new Container(),
+ recapContainer: new Container(),
+ agentRunFileChanges: new Map(),
+ sessionRecap: "Updated files",
+ pastedImages: new Map(),
+ queueSelection: { selected: undefined },
+ ctrlCExitHintExpiresAt: 0,
+ };
+ Object.setPrototypeOf(mode, InteractiveMode.prototype);
+ Reflect.get(InteractiveMode.prototype, "setupKeyHandlers").call(mode);
+ Reflect.get(InteractiveMode.prototype, "renderRecap").call(mode);
+ const replacement = new CustomEditor(ui, getEditorTheme(), keybindings);
+ if (ownHeader) replacement.getHeaderLine = () => "extension header";
+
+ Reflect.get(InteractiveMode.prototype, "setCustomEditorComponent").call(mode, () => replacement);
+
+ expect(replacement.getText()).toBe("unfinished draft");
+ expect(stripAnsi(replacement.render(80).join("\n"))).not.toContain("/effort");
+ if (ownHeader) expect(replacement.render(80)[1]).toContain("extension header");
+ const rows = mode.recapContainer.render(80);
+ expect(rows).toHaveLength(2);
+ expect(stripAnsi(rows[1]!)).toMatch(/^ Recap: Updated files\s+Collapsed mode \(Ctrl\+O to expand\) $/);
+ expect(rows[0]).toBe("");
+ expect(rows[1]).not.toMatch(/\x1b\[(?:4\d|10[0-7])(?:;[\d;]*)?m/);
+ const promptDock = new Container();
+ promptDock.addChild(mode.recapContainer);
+ promptDock.addChild(mode.editorContainer);
+ const dockRows = promptDock.render(80);
+ expect(dockRows[1]).toBe(rows[1]);
+ expect(dockRows[2]).toBe(replacement.render(80)[0]);
+ expect(dockRows[2]).toMatch(/\x1b\[48;/);
+ mode.connectionState.thinkingLevel = "low";
+ expect(stripAnsi(Reflect.get(InteractiveMode.prototype, "getModelContextLabel").call(mode))).toContain(
+ "test-model:low",
+ );
+ Reflect.get(InteractiveMode.prototype, "setCustomEditorComponent").call(mode, undefined);
+ expect(defaultEditor.getText()).toBe("unfinished draft");
+ expect(stripAnsi(defaultEditor.render(80).join("\n"))).not.toContain("/effort");
+ });
- expect(stripAnsi(label)).toBe("test-model • high ? for shortcuts");
+ it.each(
+ (["assistant", "tool", "refinement"] as const).flatMap((lastMessage) =>
+ [false, true].flatMap((withWidget) =>
+ [false, true].flatMap((withRecap) =>
+ [false, true].map((pickerOpen) => ({ lastMessage, withWidget, withRecap, pickerOpen })),
+ ),
+ ),
+ ),
+ )(
+ "uses one prompt separator after $lastMessage (widget=$withWidget, recap=$withRecap, picker=$pickerOpen)",
+ ({ lastMessage, withWidget, withRecap, pickerOpen }) => {
+ const width = 120;
+ const ui = { terminal: { rows: 24 }, requestRender: vi.fn(), hasOverlay: () => pickerOpen } as unknown as TUI;
+ const editor = new CustomEditor(ui, getEditorTheme(), new KeybindingsManager());
+ editor.setText("Draft prompt");
+ const activeInput = pickerOpen ? new Text("Choose a model", 1, 0) : editor;
+ const editorContainer = new Container();
+ editorContainer.addChild(activeInput);
+ let finalMessage: Component;
+ if (lastMessage === "assistant") {
+ finalMessage = new AssistantMessageComponent({
+ role: "assistant",
+ content: [{ type: "text", text: "Finished the response." }],
+ api: "openai-completions",
+ provider: "test",
+ model: "test-model",
+ usage: emptyUsage(),
+ stopReason: "stop",
+ timestamp: 0,
+ });
+ } else if (lastMessage === "tool") {
+ const tool = new ToolExecutionComponent("test-tool", "tool-1", {}, {}, undefined, ui, "/tmp");
+ tool.updateResult({ content: [{ type: "text", text: "Finished the tool." }], isError: false });
+ finalMessage = tool;
+ } else {
+ finalMessage = new RefinementOutcomeMessageComponent({
+ role: "custom",
+ customType: "refinement_outcome",
+ content: "Refinement complete",
+ display: true,
+ timestamp: 0,
+ details: { refinementId: "refine-1", summary: "Updated the harness", scope: "local", edits: [] },
+ });
+ }
+ const widget = new Text("Extension widget", 1, 0);
+ const mode = Object.assign(createMode(1, true), {
+ ui,
+ editor,
+ editorContainer,
+ widgetContainerAbove: new Container(),
+ widgetContainerBelow: new Container(),
+ extensionWidgetsAbove: new Map<string, Component>(withWidget ? [["test", widget]] : []),
+ extensionWidgetsBelow: new Map<string, Component>(),
+ queuedMessagesContainer: new Container(),
+ sideQuestionContainer: new Container(),
+ recapContainer: new Container(),
+ agentRunFileChanges: new Map(),
+ sessionRecap: withRecap ? "Completed the work" : undefined,
+ });
+ Reflect.get(InteractiveMode.prototype, "renderWidgets").call(mode);
+ Reflect.get(InteractiveMode.prototype, "renderRecap").call(mode);
+ const layout = new Container();
+ layout.addChild(finalMessage);
+ layout.addChild(mode.widgetContainerAbove);
+ for (const container of Reflect.get(InteractiveMode.prototype, "getPromptContextContainers").call(mode)) {
+ layout.addChild(container);
+ }
+ layout.addChild(mode.recapContainer);
+ layout.addChild(mode.editorContainer);
+ const recapRows = mode.recapContainer.render(width);
+ const precedingRows = [...finalMessage.render(width)];
+ if (withWidget) precedingRows.push("", ...widget.render(width));
+ expect(layout.render(width)).toEqual([...precedingRows, "", recapRows[1], ...activeInput.render(width)]);
+ expect(stripAnsi(recapRows[1]!)).toContain("Collapsed mode");
+ expect(stripAnsi(recapRows[1]!)).not.toContain("test-model");
+ expect(stripAnsi(recapRows[1]!)).toContain(withRecap ? "Recap: Completed the work" : "Collapsed mode");
+ if (!withRecap) expect(stripAnsi(recapRows[1]!)).not.toContain("Recap:");
+ expect(mode.widgetContainerBelow.render(width)).toEqual([]);
+ if (!withWidget) expect(mode.widgetContainerAbove.render(width)).toEqual([]);
+ if (withWidget) {
+ mode.extensionWidgetsAbove.clear();
+ Reflect.get(InteractiveMode.prototype, "renderWidgets").call(mode);
+ expect(layout.render(width)).toEqual([
+ ...finalMessage.render(width),
+ "",
+ recapRows[1],
+ ...activeInput.render(width),
+ ]);
+ }
+ },
+ );
+
+ it("uses the configured keybinding in the manage hint", () => {
+ setKeybindings(new KeybindingsManager({ "app.agents.back": "ctrl+g" }));
+ const label = Reflect.get(InteractiveMode.prototype, "getAgentsViewTrayHint").call(createMode(0, true));
+
+ expect(stripAnsi(label)).toBe("Ctrl+G manage");
});
it("keeps fresh-chat guidance hidden when a mid-turn snapshot still has no committed messages", () => {
@@ -228,39 +524,157 @@ describe("InteractiveMode startup hints", () => {
expect(shutdown).not.toHaveBeenCalled();
});
- it("keeps the lowercase agents hint while typing", () => {
+ it("keeps the manage hint while typing", () => {
let editorText = "";
const mode = createMode(0, true, () => editorText);
const getLabel = () => Reflect.get(InteractiveMode.prototype, "getTrayLocationLabel").call(mode);
- expect(stripAnsi(getLabel())).toBe("← agents/resume test-model • high ? for shortcuts");
+ expect(stripAnsi(getLabel())).toBe("← manage");
editorText = "draft prompt";
- expect(stripAnsi(getLabel())).toBe("← agents/resume test-model • high");
+ expect(stripAnsi(getLabel())).toBe("← manage");
});
- it("hides the fresh-chat shortcut hint while the prompt has text", () => {
+ it("keeps shortcut instructions out of the tray for blank and nonempty prompts", () => {
let editorText = "";
const mode = createMode(0, false, () => editorText);
const getLabel = () => Reflect.get(InteractiveMode.prototype, "getTrayLocationLabel").call(mode);
- expect(stripAnsi(getLabel())).toBe("test-model • high ? for shortcuts");
+ expect(stripAnsi(getLabel())).toBe("");
editorText = "draft prompt";
- expect(stripAnsi(getLabel())).toBe("test-model • high");
+ expect(stripAnsi(getLabel())).toBe("");
editorText = " ";
- expect(stripAnsi(getLabel())).toBe("test-model • high");
+ expect(stripAnsi(getLabel())).toBe("");
editorText = "";
- expect(stripAnsi(getLabel())).toBe("test-model • high ? for shortcuts");
+ expect(stripAnsi(getLabel())).toBe("");
});
it("hides the tray shortcut guidance for chats with history", () => {
const mode = createMode(1);
const label = Reflect.get(InteractiveMode.prototype, "getTrayLocationLabel").call(mode);
- expect(stripAnsi(label)).toBe("test-model • high");
+ expect(stripAnsi(label)).toBe("");
+ });
+
+ it("keeps the tray and subagents visible during slash autocomplete but hides them for a picker", async () => {
+ const ui = new TUI(new VirtualTerminal(100, 30));
+ vi.spyOn(ui, "requestRender").mockImplementation(() => {});
+ const editor = new CustomEditor(ui, getEditorTheme(), new KeybindingsManager());
+ const provider: AutocompleteProvider = {
+ getSuggestions: async (lines, line, col) => ({
+ prefix: lines[line]!.slice(0, col),
+ kind: "slash-command",
+ items: [
+ { value: "/model", label: "model" },
+ { value: "/mcp", label: "mcp" },
+ ],
+ }),
+ applyCompletion: (lines, cursorLine, _cursorCol, item) => ({
+ lines: lines.map((line, index) => (index === cursorLine ? item.value : line)),
+ cursorLine,
+ cursorCol: item.value.length,
+ }),
+ };
+ editor.setAutocompleteProvider(provider);
+ const editorContainer = new Container();
+ editorContainer.addChild(editor);
+ const mode = Object.assign(createMode(1, true), { ui, editor, editorContainer });
+ const call = (method: string) => Reflect.get(InteractiveMode.prototype, method).call(mode);
+ const summary = new SubagentSummaryLine(
+ () => call("getTrayLocationLabel"),
+ () => call("getTrayContextLabel"),
+ () => call("getTrayOverrideLabel"),
+ () => call("isInlinePickerOpen"),
+ );
+ summary.setSubagentCounts({ total: 1, running: 1, idle: 0, inactive: 0 });
+ summary.setOpenable(true);
+ const expectVisible = () => {
+ const output = stripAnsi(summary.render(100).join("\n"));
+ expect(output).toContain("manage");
+ expect(output).toContain("test-model:high");
+ expect(output).toContain("subagents");
+ expect(output).toContain("1 running");
+ };
+ ui.setFocus(editor);
+ expectVisible();
+ editor.handleInput("/");
+ await vi.waitFor(() => expect(editor.isShowingAutocomplete()).toBe(true));
+ expect(ui.hasOverlay()).toBe(true);
+ expectVisible();
+ editor.handleInput("m");
+ await vi.waitFor(() => expect(editor.isShowingAutocomplete()).toBe(true));
+ expect(editor.getText()).toBe("/m");
+ expectVisible();
+
+ // Opening a capturing picker must hide the tray even while autocomplete is retained underneath.
+ const picker = ui.showOverlay(new Text("Models / Providers / MCP", 0, 0));
+ expect(editor.isShowingAutocomplete()).toBe(true);
+ expect(editor.focused).toBe(false);
+ expect(summary.render(100)).toEqual([]);
+ picker.hide();
+ expect(editor.focused).toBe(true);
+ expectVisible();
+
+ editorContainer.clear();
+ editorContainer.addChild(new Text("Inline settings picker", 0, 0));
+ expect(summary.render(100)).toEqual([]);
+ editorContainer.clear();
+ editorContainer.addChild(editor);
+ expectVisible();
+ editor.handleInput("\x1b");
+ expect(editor.isShowingAutocomplete()).toBe(false);
+ expect(ui.hasOverlay()).toBe(false);
+ expectVisible();
+ });
+
+ it("hides the tray while an inline picker is open", () => {
+ const mode = createMode(0, true);
+ const locationLabel = () => Reflect.get(InteractiveMode.prototype, "getTrayLocationLabel").call(mode);
+ const contextLabel = () => Reflect.get(InteractiveMode.prototype, "getTrayContextLabel").call(mode);
+ const overrideLabel = () => Reflect.get(InteractiveMode.prototype, "getTrayOverrideLabel").call(mode);
+ Object.assign(mode.connectionState, {
+ goal: {
+ active: true,
+ status: "active",
+ objective: "finish the task",
+ tokensUsed: 0,
+ timeUsedSeconds: 65,
+ continuationsUsed: 1,
+ },
+ contextUsage: { contextWindow: 100_000, tokens: 75_000, percent: 75 },
+ });
+ Object.assign(mode, { ctrlCExitHintExpiresAt: Date.now() + 60_000 });
+
+ expect(stripAnsi(locationLabel())).toBe("← manage");
+ expect(stripAnsi(contextLabel())).toBe("Pursuing goal (1m 05s) · test-model:high · 75k (75%)");
+ expect(stripAnsi(overrideLabel())).toBe("Press Ctrl+C again to exit");
+
+ mode.ui.hasOverlay = () => true;
+ expect(locationLabel()).toBeUndefined();
+ expect(contextLabel()).toBeUndefined();
+ expect(overrideLabel()).toBeUndefined();
+
+ mode.ui.hasOverlay = () => false;
+ mode.editorContainer.children.length = 0;
+ mode.editorContainer.children.push({});
+ expect(locationLabel()).toBeUndefined();
+ expect(contextLabel()).toBeUndefined();
+ expect(overrideLabel()).toBeUndefined();
+ });
+
+ it("never shows a depth label for root sessions and keeps it for subagent sessions", () => {
+ const root = createMode();
+ Object.assign(root.options, { sessionDepth: 0, sessionHasChildren: true });
+ const subagent = createMode(1);
+ Object.assign(subagent.options, { sessionDepth: 1 });
+ const getLabel = (mode: ReturnType<typeof createMode>) =>
+ stripAnsi(Reflect.get(InteractiveMode.prototype, "getTrayLocationLabel").call(mode));
+
+ expect(getLabel(root)).toBe("");
+ expect(getLabel(subagent)).toBe("depth 1");
});
it("keeps the question-mark shortcut guide compact", () => {
diff --git a/packages/coding-agent/test/interactive-mode-status.test.ts b/packages/coding-agent/test/interactive-mode-status.test.ts
index 795af614c4..5db797ec29 100644
--- a/packages/coding-agent/test/interactive-mode-status.test.ts
+++ b/packages/coding-agent/test/interactive-mode-status.test.ts
@@ -14,6 +14,7 @@ import {
type TUI,
visibleWidth,
} from "@earendil-works/pi-tui";
+import stripAnsi from "strip-ansi";
import { beforeAll, describe, expect, test, vi } from "vitest";
import type { AgentSessionRuntime } from "../src/core/agent-session-runtime.js";
import { formatNoModelsAvailableMessage } from "../src/core/auth-guidance.js";
@@ -696,7 +697,6 @@ describe("InteractiveMode working timer", () => {
createWorkingLoader: ReturnType<typeof vi.fn>;
statusContainer: { addChild: ReturnType<typeof vi.fn> };
startWorkingTimer: ReturnType<typeof vi.fn>;
- startFeatureHintPresentation: ReturnType<typeof vi.fn>;
};
function createInitialTimerHarness(snapshot: AgentConnectionSnapshot, turnStartedAt = 1): InitialTimerHarness {
@@ -724,7 +724,6 @@ describe("InteractiveMode working timer", () => {
createWorkingLoader: vi.fn(() => ({})),
statusContainer: { addChild: vi.fn() },
startWorkingTimer: vi.fn(),
- startFeatureHintPresentation: vi.fn(),
});
}
@@ -1273,7 +1272,6 @@ describe("InteractiveMode pending bash components", () => {
queuedMessagesContainer: new Container(),
pendingBashComponents: [component],
getAllQueuedMessages: () => ({ steering: [], followUp: [] }),
- featureHintSuppressedByQueue: false,
} as unknown as InteractiveMode;
(
@@ -1301,8 +1299,6 @@ describe("InteractiveMode pending bash components", () => {
}),
isRecognizedSlashCommand: (name: string) => name === "compact",
getAppKeyDisplay: () => "Ctrl+Q",
- featureHintSuppressedByQueue: false,
- clearFeatureHintPresentation: vi.fn(),
} as unknown as InteractiveMode;
(
@@ -1388,11 +1384,9 @@ describe("InteractiveMode pending bash components", () => {
expect(loader.intervalId).not.toBeNull();
const editorStub = { clearHistory: vi.fn(), setText: vi.fn() };
- const endFeatureHintRun = vi.fn();
const queueSelection = new QueueSelection();
queueSelection.move({ steering: ["s1"], followUp: [] }, "draft", -1);
const fakeThis = {
- endFeatureHintRun,
queueSelection,
chatContainer: new Container(),
shortcutGuideContainer: new Container(),
@@ -1425,7 +1419,6 @@ describe("InteractiveMode pending bash components", () => {
).resetCurrentSessionRenderState.call(fakeThis);
expect(loader.intervalId).toBeNull();
- expect(endFeatureHintRun).toHaveBeenCalledOnce();
expect((fakeThis as unknown as { activeBashComponent: unknown }).activeBashComponent).toBeUndefined();
// Queue browsing is session-scoped: Enter in the next session must be a
// fresh prompt, and the previous session's stashed draft is discarded.
@@ -4315,6 +4308,8 @@ describe("InteractiveMode tray goal label", () => {
contextUsage: TrayUsage | undefined;
};
uiServices: { getContextUsage(): TrayUsage | undefined };
+ ui: { hasOverlay(): boolean };
+ editorContainer: { children: unknown[] };
getTrayContextLabel(): string | undefined;
};
const getTrayContextLabel = (InteractiveMode.prototype as unknown as TrayLabelHarness).getTrayContextLabel;
@@ -4355,11 +4350,13 @@ describe("InteractiveMode tray goal label", () => {
contextUsage: undefined,
};
fakeThis.uiServices = { getContextUsage: () => undefined };
+ fakeThis.ui = { hasOverlay: () => false };
+ fakeThis.editorContainer = { children: [] };
expect(getTrayContextLabel.call(fakeThis)).toBe("Pursuing goal (1m 05s)");
});
- test("combines active goals with token/context usage in one lower-tray label", () => {
+ test("shows context usage in the lower tray while preserving active goals", () => {
const fakeThis = Object.create(InteractiveMode.prototype) as TrayLabelHarness;
fakeThis.heartbeatCatalog = [];
fakeThis.subagentSnapshots = new Map<string, never>();
@@ -4377,11 +4374,13 @@ describe("InteractiveMode tray goal label", () => {
contextUsage: { contextWindow: 100_000, tokens: 75_000, percent: 75 },
};
fakeThis.uiServices = { getContextUsage: () => undefined };
+ fakeThis.ui = { hasOverlay: () => false };
+ fakeThis.editorContainer = { children: [] };
- expect(getTrayContextLabel.call(fakeThis)).toBe("Pursuing goal (1m 05s) · 75k (75%)");
+ expect(stripAnsi(getTrayContextLabel.call(fakeThis)!)).toBe("Pursuing goal (1m 05s) · 75k (75%)");
});
- test("combines active goals, active heartbeats, and context usage in one lower-tray label", () => {
+ test("combines active goals, heartbeats, and context usage below", () => {
const fakeThis = Object.create(InteractiveMode.prototype) as TrayLabelHarness;
fakeThis.heartbeatCatalog = [{ job: createHeartbeat("active") }];
fakeThis.subagentSnapshots = new Map<string, never>();
@@ -4400,8 +4399,10 @@ describe("InteractiveMode tray goal label", () => {
contextUsage: { contextWindow: 100_000, tokens: 75_000, percent: 75 },
};
fakeThis.uiServices = { getContextUsage: () => undefined };
+ fakeThis.ui = { hasOverlay: () => false };
+ fakeThis.editorContainer = { children: [] };
- expect(getTrayContextLabel.call(fakeThis)).toBe("Pursuing goal (1m 05s) · 1 heartbeat · 75k (75%)");
+ expect(stripAnsi(getTrayContextLabel.call(fakeThis)!)).toBe("Pursuing goal (1m 05s) · 1 heartbeat · 75k (75%)");
});
test("omits the usage segment when token count is unknown", () => {
@@ -4422,6 +4423,8 @@ describe("InteractiveMode tray goal label", () => {
contextUsage: { contextWindow: 100_000, tokens: null, percent: null },
};
fakeThis.uiServices = { getContextUsage: () => undefined };
+ fakeThis.ui = { hasOverlay: () => false };
+ fakeThis.editorContainer = { children: [] };
expect(getTrayContextLabel.call(fakeThis)).toBe("Pursuing goal (1m 05s)");
});
@@ -5544,7 +5547,6 @@ test("only the queued user /refine settlement stops its loader", async () => {
isInitialized: true,
footer: { invalidate: vi.fn() },
updateConnectionStateFromEvent: vi.fn(),
- prepareFeatureHintRun: vi.fn(),
activityTracker: { handleEvent: vi.fn(), reset: vi.fn() },
updateWorkingLoaderMessage: vi.fn(),
renderRecap: vi.fn(),
diff --git a/packages/coding-agent/test/prompt-context-line.test.ts b/packages/coding-agent/test/prompt-context-line.test.ts
new file mode 100644
index 0000000000..28073c414d
--- /dev/null
+++ b/packages/coding-agent/test/prompt-context-line.test.ts
@@ -0,0 +1,118 @@
+import { visibleWidth } from "@earendil-works/pi-tui";
+import stripAnsi from "strip-ansi";
+import { beforeAll, describe, expect, it } from "vitest";
+import { PromptContextLine } from "../src/modes/interactive/components/prompt-context-line.js";
+import { initTheme, preloadCodeHighlighter, theme } from "../src/modes/interactive/theme/theme.js";
+
+describe("PromptContextLine", () => {
+ beforeAll(async () => {
+ initTheme("dark");
+ await preloadCodeHighlighter();
+ });
+
+ it.each(["dark", "light"])(
+ "shares one plain row between recap and detail status with one blank line above the context row in the %s theme",
+ (name) => {
+ initTheme(name);
+ const line = new PromptContextLine(
+ () => "Updated the prompt layout",
+ () => theme.fg("dim", "Collapsed mode (Ctrl+O to expand)"),
+ );
+ const rows = line.render(80);
+
+ expect(rows).toHaveLength(2);
+ expect(stripAnsi(rows[1]!)).toMatch(
+ /^ Recap: Updated the prompt layout\s{2,}Collapsed mode \(Ctrl\+O to expand\) $/,
+ );
+ expect(rows[0]).toBe("");
+ expect(visibleWidth(rows[1]!)).toBe(80);
+ expect(rows[1]).not.toMatch(/\x1b\[(?:4\d|10[0-7])(?:;[\d;]*)?m/);
+ },
+ );
+
+ it("keeps detail status aligned right above the prompt", () => {
+ const line = new PromptContextLine(
+ () => undefined,
+ () => "Collapsed mode (Ctrl+O to expand)",
+ );
+
+ const rows = line.render(40);
+ expect(rows).toHaveLength(2);
+ expect(stripAnsi(rows[1]!)).toBe(`${"Collapsed mode (Ctrl+O to expand)".padStart(39)} `);
+ expect(rows[0]).toBe("");
+ });
+
+ it("uses the full row for recap when the status is unavailable", () => {
+ const line = new PromptContextLine(
+ () => "Updated files\n and checked the result",
+ () => undefined,
+ );
+
+ const rows = line.render(48);
+ expect(rows).toHaveLength(2);
+ expect(stripAnsi(rows[1]!).trim()).toBe("Recap: Updated files and checked the result");
+ expect(visibleWidth(rows[1]!)).toBe(48);
+ expect(rows[0]).toBe("");
+ });
+
+ it("keeps long Unicode recaps and detail status within narrow terminal widths", () => {
+ const line = new PromptContextLine(
+ () => "Updated 界面 files and checked the résumé with a long recap",
+ () => theme.fg("dim", "Details mode"),
+ );
+
+ for (const width of [1, 2, 3, 4, 8, 16, 24, 40, 80, 120]) {
+ const rows = line.render(width);
+ const plain = stripAnsi(rows[1]!);
+ expect(rows).toHaveLength(2);
+ expect(visibleWidth(rows[1]!)).toBe(width);
+ expect(plain).toContain("D");
+ expect(rows[0]).toBe("");
+ if (width >= 40) {
+ expect(plain).toMatch(/^ Recap: .+ {2,}Details mode $/);
+ }
+ }
+ });
+
+ it("fits detail status beside recap while preserving the recap and narrow widths", () => {
+ const line = new PromptContextLine(
+ () => "Updated the interface",
+ () => theme.fg("dim", "Expanded mode (Ctrl+O to collapse)"),
+ );
+ expect(stripAnsi(line.render(100)[1]!)).toMatch(
+ /^ Recap: Updated the interface\s{2,}Expanded mode \(Ctrl\+O to collapse\) $/,
+ );
+ for (const width of [1, 2, 3, 8, 24, 40, 80]) {
+ const rows = line.render(width);
+ expect(rows).toHaveLength(2);
+ expect(visibleWidth(rows[1]!)).toBe(width);
+ expect(rows[0]).toBe("");
+ }
+ });
+
+ it("reserves the full detail status before ellipsizing the recap", () => {
+ const metadata = "Expanded mode (Ctrl+O to collapse)";
+ const line = new PromptContextLine(
+ () => "Updated the interface and verified all of the layout changes",
+ (maxWidth) => {
+ expect(maxWidth).toBeGreaterThanOrEqual(visibleWidth(metadata));
+ return metadata;
+ },
+ );
+
+ const rows = line.render(56);
+ expect(rows[0]).toBe("");
+ expect(stripAnsi(rows[1]!)).toMatch(/^ Recap: .+… {2}Expanded mode \(Ctrl\+O to collapse\) $/);
+ expect(visibleWidth(rows[1]!)).toBe(56);
+ });
+
+ it("does not reserve a row when neither recap nor status is available", () => {
+ const line = new PromptContextLine(
+ () => " ",
+ () => undefined,
+ );
+
+ expect(line.render(80)).toEqual([]);
+ expect(line.render(0)).toEqual([]);
+ });
+});
diff --git a/packages/coding-agent/test/slash-commands.test.ts b/packages/coding-agent/test/slash-commands.test.ts
index b8cff0e741..16547a2ad2 100644
--- a/packages/coding-agent/test/slash-commands.test.ts
+++ b/packages/coding-agent/test/slash-commands.test.ts
@@ -74,7 +74,6 @@ describe("built-in slash commands", () => {
test("marks argument commands as taking a free-form argument", () => {
for (const [name, argumentHint] of [
- ["model", "[search]"],
["export", "[path]"],
["import", "<path.jsonl>"],
["name", "[name]"],
@@ -89,6 +88,7 @@ describe("built-in slash commands", () => {
});
expect(builtinSlashCommandTakesArgument("goal")).toBe(true);
expect(builtinSlashCommandTakesArgument("effort")).toBe(false);
+ expect(builtinSlashCommandTakesArgument("model")).toBe(false);
expect(builtinSlashCommandTakesArgument("thinking")).toBe(false);
expect(builtinSlashCommandTakesArgument("heartbeat")).toBe(true);
expect(builtinSlashCommandTakesArgument("mcp")).toBe(true);
diff --git a/packages/coding-agent/test/subagent-summary-line.test.ts b/packages/coding-agent/test/subagent-summary-line.test.ts
index 903de7fde4..c778b0a85e 100644
--- a/packages/coding-agent/test/subagent-summary-line.test.ts
+++ b/packages/coding-agent/test/subagent-summary-line.test.ts
@@ -41,6 +41,46 @@ describe("SubagentSummaryLine", () => {
expect(rendered[1]).toContain("● 1 running ◐ 1 idle ○ 0 inactive");
});
+ it("renders the subagents label without raw bold escapes", () => {
+ const line = new SubagentSummaryLine();
+ line.setSubagentCounts({ total: 1, running: 1, idle: 0, inactive: 0 });
+
+ const raw = line.render(120).join("\n");
+ expect(raw).toContain("subagents");
+ expect(raw).not.toContain("\x1b[1m");
+ });
+
+ it("hides the info line and the agents tile while a picker is open", () => {
+ let pickerOpen = false;
+ const line = new SubagentSummaryLine(
+ () => "test-model",
+ () => "75k (75%)",
+ undefined,
+ () => pickerOpen,
+ );
+ line.setSubagentCounts({ total: 2, running: 1, idle: 1, inactive: 0 });
+ line.setOpenable(true);
+
+ const closed = line.render(120).map(stripAnsi);
+ expect(closed).toHaveLength(4);
+ expect(closed[0]).toContain("test-model");
+ expect(closed[0]).toContain("75k (75%)");
+ expect(closed[1]).toContain("╭─ subagents ─");
+
+ expect(line.isSelectable()).toBe(true);
+ const onOpen = vi.fn();
+ line.onOpen = onOpen;
+ pickerOpen = true;
+ expect(line.render(120)).toEqual([]);
+ expect(line.isSelectable()).toBe(false);
+ line.handleInput("\r");
+ expect(onOpen).not.toHaveBeenCalled();
+
+ pickerOpen = false;
+ expect(line.render(120).map(stripAnsi)).toHaveLength(4);
+ expect(line.isSelectable()).toBe(true);
+ });
+
it("hints ↓ select when unfocused and Enter/→ open when focused", () => {
const line = new SubagentSummaryLine();
line.setSubagentCounts({ total: 1, running: 1, idle: 0, inactive: 0 });
@@ -54,6 +94,27 @@ describe("SubagentSummaryLine", () => {
expect(focused).not.toContain("↓ select");
});
+ it("does not transfer editor focus to the hidden summary while a picker is open", () => {
+ let pickerOpen = true;
+ const mode = Object.create(InteractiveMode.prototype) as InteractiveMode;
+ const setFocus = vi.fn();
+ const summaryLine = { isSelectable: () => true };
+ Object.assign(mode, {
+ isInlinePickerOpen: () => pickerOpen,
+ getTrayOverrideLabel: () => undefined,
+ subagentSummaryLine: summaryLine,
+ ui: { setFocus, requestRender: vi.fn() },
+ });
+ const focus = Reflect.get(InteractiveMode.prototype, "focusSubagentSummary") as (
+ this: InteractiveMode,
+ ) => boolean;
+ expect(focus.call(mode)).toBe(false);
+ expect(setFocus).not.toHaveBeenCalled();
+ pickerOpen = false;
+ expect(focus.call(mode)).toBe(true);
+ expect(setFocus).toHaveBeenCalledWith(summaryLine);
+ });
+
it("keeps the selection background across truncation resets when focused", () => {
const line = new SubagentSummaryLine();
line.setSubagentCounts({ total: 3, running: 1, idle: 1, inactive: 1 });
diff --git a/packages/coding-agent/test/suite/regressions/4533-preserve-recap.test.ts b/packages/coding-agent/test/suite/regressions/4533-preserve-recap.test.ts
index 4110fedae0..58f9a679ae 100644
--- a/packages/coding-agent/test/suite/regressions/4533-preserve-recap.test.ts
+++ b/packages/coding-agent/test/suite/regressions/4533-preserve-recap.test.ts
@@ -106,21 +106,25 @@ describe("ENG-4533 recap layout", () => {
expect(previous).toHaveLength(2);
expect(updated).toHaveLength(2);
- expect(stripAnsi(updated[0] ?? "")).toContain("Recap: Preparing the fix plan");
+ expect(stripAnsi(updated[1] ?? "")).toContain("Recap: Preparing the fix plan");
});
- it("does not reserve blank space before the first recap", () => {
+ it("shows the detail status before the first recap", () => {
const mode = createRenderMode();
- expect(render(mode)).toEqual([]);
+ expect(render(mode)).toHaveLength(2);
+ expect(stripAnsi(render(mode)[1] ?? "")).toContain("Collapsed mode");
});
it("keeps long recaps to one row on narrow terminals", () => {
const mode = createRenderMode("Reviewing the implementation and preparing a clean regression test");
+ Object.assign(mode, { getPromptContextLabel: () => undefined });
const lines = render(mode, 24);
expect(lines).toHaveLength(2);
- expect(visibleWidth(lines[0] ?? "")).toBe(24);
- expect(stripAnsi(lines[0] ?? "")).toContain("Recap:");
+ expect(visibleWidth(lines[1] ?? "")).toBe(24);
+ expect(stripAnsi(lines[1] ?? "")).toContain("Recap:");
+ expect(stripAnsi(lines[1] ?? "").trimEnd()).toMatch(/…$/);
+ expect(lines[0]).toBe("");
});
});
diff --git a/packages/coding-agent/test/suite/regressions/4741-hint-placement.test.ts b/packages/coding-agent/test/suite/regressions/4741-hint-placement.test.ts
index 6d19c16a66..3646326584 100644
--- a/packages/coding-agent/test/suite/regressions/4741-hint-placement.test.ts
+++ b/packages/coding-agent/test/suite/regressions/4741-hint-placement.test.ts
@@ -15,14 +15,12 @@ function callPrivate(mode: object, name: string, ...args: unknown[]): unknown {
return Reflect.get(InteractiveMode.prototype, name).call(mode, ...args);
}
-function createFeatureHintMode() {
+function createQueuedMessageMode() {
const loader = new FakeLoader();
const statusContainer = new Container();
statusContainer.addChild(loader);
- const featureHintContainer = new Container();
const mode = Object.assign(Object.create(InteractiveMode.prototype), {
statusContainer,
- featureHintContainer,
pendingMessagesContainer: new Container(),
pendingBashComponents: [],
queuedMessagesContainer: new Container(),
@@ -33,19 +31,11 @@ function createFeatureHintMode() {
isStreaming: true,
sessionActions: { queuedCount: 0, steering: [] as string[], followUps: [] as string[] },
},
- featureHintDeck: { next: vi.fn(() => ({ id: "test", text: "A useful feature hint." })) },
- currentFeatureHint: undefined,
- featureHintEligibleAt: 0,
- featureHintTimer: undefined,
- featureHintAnimationTimer: undefined,
- featureHintComponent: undefined,
- featureHintRunPending: false,
- featureHintSuppressedByQueue: false,
options: { returnToAgentsView: true },
getAppKeyDisplay: () => "Ctrl+Q",
ui: { requestRender: vi.fn() },
});
- return { mode, featureHintContainer };
+ return { mode };
}
describe("ENG-4741 hint placement", () => {
@@ -62,9 +52,8 @@ describe("ENG-4741 hint placement", () => {
vi.useRealTimers();
});
- it("orders hints below the recap and above queued messages and side questions", () => {
+ it("keeps queued messages and side questions above the prompt without a discovery-tip row", () => {
const recapContainer = new Container();
- const featureHintContainer = new Container();
const queuedMessagesContainer = new Container();
const sideQuestionContainer = new Container();
const editorContainer = new Container();
@@ -72,7 +61,6 @@ describe("ENG-4741 hint placement", () => {
const footerSlot = new Container();
const mode = Object.assign(Object.create(InteractiveMode.prototype), {
recapContainer,
- featureHintContainer,
queuedMessagesContainer,
sideQuestionContainer,
editorContainer,
@@ -80,16 +68,16 @@ describe("ENG-4741 hint placement", () => {
footerSlot,
});
- expect(callPrivate(mode, "getPromptContextContainers")).toEqual([
+ expect(callPrivate(mode, "getPromptContextContainers")).toEqual([queuedMessagesContainer, sideQuestionContainer]);
+ expect(callPrivate(mode, "getPromptDockComponents")).toEqual([
recapContainer,
- featureHintContainer,
- queuedMessagesContainer,
- sideQuestionContainer,
+ editorContainer,
+ subagentSummaryLine,
+ footerSlot,
]);
- expect(callPrivate(mode, "getPromptDockComponents")).toEqual([editorContainer, subagentSummaryLine, footerSlot]);
});
- it("keeps hints in the fullscreen transcript instead of the prompt dock", () => {
+ it("keeps queued messages in the fullscreen transcript and the prompt dock free of discovery tips", () => {
const previousIsTTY = Object.getOwnPropertyDescriptor(process.stdout, "isTTY");
Object.defineProperty(process.stdout, "isTTY", { configurable: true, value: true });
try {
@@ -97,7 +85,6 @@ describe("ENG-4741 hint placement", () => {
const mainViewContainer = new Container();
const widgetContainerAbove = new Container();
const recapContainer = new Container();
- const featureHintContainer = new Container();
const queuedMessagesContainer = new Container();
const sideQuestionContainer = new Container();
const widgetContainerBelow = new Container();
@@ -108,7 +95,6 @@ describe("ENG-4741 hint placement", () => {
mainViewContainer,
widgetContainerAbove,
recapContainer,
- featureHintContainer,
queuedMessagesContainer,
sideQuestionContainer,
widgetContainerBelow,
@@ -124,8 +110,6 @@ describe("ENG-4741 hint placement", () => {
headerContainer,
mainViewContainer,
widgetContainerAbove,
- recapContainer,
- featureHintContainer,
queuedMessagesContainer,
sideQuestionContainer,
widgetContainerBelow,
@@ -133,7 +117,6 @@ describe("ENG-4741 hint placement", () => {
dock: promptDock,
mouse: true,
});
- expect(promptDock.children).not.toContain(featureHintContainer);
} finally {
if (previousIsTTY) {
Object.defineProperty(process.stdout, "isTTY", previousIsTTY);
@@ -143,23 +126,17 @@ describe("ENG-4741 hint placement", () => {
}
});
- it("hides a visible hint while messages are queued and restores it when the queue clears", () => {
- const { mode, featureHintContainer } = createFeatureHintMode();
-
- callPrivate(mode, "startFeatureHintPresentation");
- vi.advanceTimersByTime(5_000);
- expect(featureHintContainer.children).toHaveLength(1);
-
+ it("shows queued messages without adding discovery tips when the queue clears", () => {
+ const { mode } = createQueuedMessageMode();
mode.connectionState.sessionActions.followUps = ["Continue after this turn"];
callPrivate(mode, "updatePendingMessagesDisplay");
- expect(featureHintContainer.children).toHaveLength(0);
+ expect(mode.queuedMessagesContainer.render(100).join("\n")).toContain("Continue after this turn");
mode.connectionState.sessionActions.followUps = [];
callPrivate(mode, "updatePendingMessagesDisplay");
- expect(featureHintContainer.children).toHaveLength(1);
-
- const restoredHint = featureHintContainer.children[0];
- callPrivate(mode, "updatePendingMessagesDisplay");
- expect(featureHintContainer.children).toEqual([restoredHint]);
+ vi.advanceTimersByTime(60_000);
+ expect(mode.queuedMessagesContainer.children).toHaveLength(0);
+ expect(mode.statusContainer.children).toHaveLength(1);
+ expect(vi.getTimerCount()).toBe(0);
});
});
diff --git a/packages/tui/.changes/ui-prompt-bar.md b/packages/tui/.changes/ui-prompt-bar.md
new file mode 100644
index 0000000000..d116d645ad
--- /dev/null
+++ b/packages/tui/.changes/ui-prompt-bar.md
@@ -0,0 +1,2 @@
+- Kept slash-command completion separate from execution so Tab and partial Enter complete without submitting.
+- Fixed the argument separator when completing extension commands with custom argument suggestions.
diff --git a/packages/tui/src/autocomplete.ts b/packages/tui/src/autocomplete.ts
index 25660b7ab4..9e84d1a4d3 100644
--- a/packages/tui/src/autocomplete.ts
+++ b/packages/tui/src/autocomplete.ts
@@ -238,6 +238,13 @@ export interface SlashCommand {
getArgumentCompletions?(argumentPrefix: string): Awaitable<AutocompleteItem[] | null>;
}
+function commandTakesArgument(command: SlashCommand | AutocompleteItem): boolean {
+ return (
+ command.takesArgument ??
+ ("getArgumentCompletions" in command && typeof command.getArgumentCompletions === "function")
+ );
+}
+
export interface AutocompleteSuggestions {
items: AutocompleteItem[];
prefix: string; // What we're matching against (e.g., "/" or "src/")
@@ -311,7 +318,7 @@ export class CombinedAutocompleteProvider implements AutocompleteProvider {
const aliases = "aliases" in cmd && cmd.aliases ? cmd.aliases : [];
const argumentHint = "argumentHint" in cmd && cmd.argumentHint ? cmd.argumentHint : undefined;
const sourceTag = "sourceTag" in cmd && cmd.sourceTag ? cmd.sourceTag : undefined;
- const takesArgument = "takesArgument" in cmd ? cmd.takesArgument === true : false;
+ const takesArgument = commandTakesArgument(cmd);
return {
name,
searchText: [name, ...aliases].join(" "),
@@ -393,13 +400,16 @@ export class CombinedAutocompleteProvider implements AutocompleteProvider {
isQuotedPrefix && hasTrailingQuoteInItem && hasLeadingQuoteAfterCursor ? afterCursor.slice(1) : afterCursor;
const slashContext = getSlashCommandContext(lines, cursorLine, cursorCol);
- const isSlashCommand =
- slashContext?.kind === "name" &&
- slashContext.prefix === prefix &&
- this.commands.some((command) => ("name" in command ? command.name : command.value) === item.value);
+ const command = this.commands.find(
+ (command) => ("name" in command ? command.name : command.value) === item.value,
+ );
+ const isSlashCommand = slashContext?.kind === "name" && slashContext.prefix === prefix && command !== undefined;
if (isSlashCommand) {
+ const takesArgument = commandTakesArgument(command);
const hasSeparatorAfterCursor = /^[ \t]/.test(adjustedAfterCursor);
- const separator = hasSeparatorAfterCursor ? "" : " ";
+ // Argument commands complete into the parameter position; commands without
+ // arguments complete bare so a following submit runs them as typed.
+ const separator = !takesArgument ? "" : hasSeparatorAfterCursor ? "" : " ";
const newLine = `${beforePrefix}/${item.value}${separator}${adjustedAfterCursor}`;
const newLines = [...lines];
newLines[cursorLine] = newLine;
@@ -407,7 +417,7 @@ export class CombinedAutocompleteProvider implements AutocompleteProvider {
return {
lines: newLines,
cursorLine,
- cursorCol: beforePrefix.length + item.value.length + 2,
+ cursorCol: beforePrefix.length + item.value.length + (takesArgument ? 2 : 1),
};
}
diff --git a/packages/tui/src/components/editor.ts b/packages/tui/src/components/editor.ts
index ad9fdc8daf..01910d7a68 100644
--- a/packages/tui/src/components/editor.ts
+++ b/packages/tui/src/components/editor.ts
@@ -753,14 +753,7 @@ export class Editor implements Component, Focusable {
if (kb.matches(data, "tui.select.confirm")) {
const selected = this.autocompleteList.getSelectedItem();
if (selected && this.autocompleteProvider) {
- const slashContext = this.getCurrentSlashCommandContext();
- const isSlashCommandCompletion =
- this.autocompleteKind === "slash-command" ||
- (this.autocompleteKind === undefined &&
- this.autocompleteState === "regular" &&
- this.autocompletePrefix.startsWith("/"));
- const shouldSubmitSlashCommand =
- isSlashCommandCompletion && slashContext?.kind === "name" && slashContext.isAtPromptStart;
+ const isTypedExactSlashCommand = this.isSlashNameCompletionAtPromptStart();
this.pushUndoSnapshot();
this.lastAction = null;
const result = this.autocompleteProvider.applyCompletion(
@@ -770,21 +763,20 @@ export class Editor implements Component, Focusable {
selected,
this.autocompletePrefix,
);
+ const completedExistingText =
+ result.lines.length === this.state.lines.length &&
+ result.lines.every((line, index) => line === this.state.lines[index]);
this.state.lines = result.lines;
this.state.cursorLine = result.cursorLine;
this.setCursorCol(result.cursorCol);
+ this.cancelAutocomplete();
- if (isSlashCommandCompletion) {
- this.cancelAutocomplete();
- if (!shouldSubmitSlashCommand || selected.takesArgument) {
- if (this.onChange) this.onChange(this.getText());
- return;
- }
- } else {
- this.cancelAutocomplete();
+ if (!isTypedExactSlashCommand || !completedExistingText) {
if (this.onChange) this.onChange(this.getText());
return;
}
+ // The typed command already matches the selection: fall through so
+ // Enter submits instead of swallowing the key on a no-op completion.
}
}
}
@@ -2140,6 +2132,17 @@ export class Editor implements Component, Focusable {
return getSlashCommandContext(this.state.lines, this.state.cursorLine, this.state.cursorCol);
}
+ /** True when the active autocomplete completes a slash command name at the prompt start. */
+ private isSlashNameCompletionAtPromptStart(): boolean {
+ const slashContext = this.getCurrentSlashCommandContext();
+ const isSlashCommandCompletion =
+ this.autocompleteKind === "slash-command" ||
+ (this.autocompleteKind === undefined &&
+ this.autocompleteState === "regular" &&
+ this.autocompletePrefix.startsWith("/"));
+ return isSlashCommandCompletion && slashContext?.kind === "name" && slashContext.isAtPromptStart;
+ }
+
/**
* Find the best autocomplete item index for the given prefix.
* Returns -1 if no match is found.
diff --git a/packages/tui/test/autocomplete-command-arguments.test.ts b/packages/tui/test/autocomplete-command-arguments.test.ts
new file mode 100644
index 0000000000..78db01478c
--- /dev/null
+++ b/packages/tui/test/autocomplete-command-arguments.test.ts
@@ -0,0 +1,54 @@
+import assert from "node:assert/strict";
+import { describe, it } from "node:test";
+import { CombinedAutocompleteProvider, type SlashCommand } from "../src/autocomplete.js";
+
+describe("slash command argument completion", () => {
+ it("enters the argument position for a custom completer without takesArgument metadata", async () => {
+ const prefixes: string[] = [];
+ const provider = new CombinedAutocompleteProvider(
+ [
+ {
+ name: "deploy",
+ getArgumentCompletions: (prefix) => {
+ prefixes.push(prefix);
+ return [{ value: "production", label: "production" }];
+ },
+ },
+ ],
+ process.cwd(),
+ );
+ const options = { signal: new AbortController().signal };
+ const suggestions = await provider.getSuggestions(["/dep"], 0, 4, options);
+ assert.ok(suggestions);
+ assert.equal(suggestions.items[0]?.takesArgument, true);
+ const completed = provider.applyCompletion(["/dep"], 0, 4, suggestions.items[0]!, suggestions.prefix);
+ assert.deepEqual(completed, { lines: ["/deploy "], cursorLine: 0, cursorCol: 8 });
+ const argumentsList = await provider.getSuggestions(["/deploy pro"], 0, 11, options);
+ assert.deepEqual(prefixes, ["pro"]);
+ assert.equal(argumentsList?.items[0]?.value, "production");
+ });
+
+ it("keeps an existing argument separator and places the cursor after it", () => {
+ const provider = new CombinedAutocompleteProvider(
+ [{ name: "deploy", getArgumentCompletions: () => null }],
+ process.cwd(),
+ );
+ assert.deepEqual(provider.applyCompletion(["/dep staging"], 0, 4, { value: "deploy", label: "deploy" }, "/dep"), {
+ lines: ["/deploy staging"],
+ cursorLine: 0,
+ cursorCol: 8,
+ });
+ });
+
+ it("preserves explicit argument declarations and bare no-argument commands", () => {
+ for (const [command, expected] of [
+ [{ name: "deploy", takesArgument: true }, "/deploy "],
+ [{ name: "deploy" }, "/deploy"],
+ [{ name: "deploy", takesArgument: false, getArgumentCompletions: () => null }, "/deploy"],
+ ] satisfies Array<[SlashCommand, string]>) {
+ const provider = new CombinedAutocompleteProvider([command], process.cwd());
+ const completed = provider.applyCompletion(["/dep"], 0, 4, { value: "deploy", label: "deploy" }, "/dep");
+ assert.deepEqual(completed, { lines: [expected], cursorLine: 0, cursorCol: expected.length });
+ }
+ });
+});
diff --git a/packages/tui/test/autocomplete.test.ts b/packages/tui/test/autocomplete.test.ts
index 5b2e8143cb..f64195476e 100644
--- a/packages/tui/test/autocomplete.test.ts
+++ b/packages/tui/test/autocomplete.test.ts
@@ -205,7 +205,31 @@ describe("CombinedAutocompleteProvider", () => {
assert.deepStrictEqual(applied, {
lines: ["Please use /help later"],
cursorLine: 0,
- cursorCol: "Please use /help ".length,
+ cursorCol: "Please use /help".length,
+ });
+ });
+
+ it("completes argument-taking commands into the parameter position and others bare", async () => {
+ const provider = new CombinedAutocompleteProvider(
+ [
+ { name: "model", description: "Select model" },
+ { name: "goal", description: "Set a goal", takesArgument: true },
+ ],
+ "/tmp",
+ );
+
+ const bare = provider.applyCompletion(["/mo"], 0, 3, { value: "model", label: "model" }, "/mo");
+ assert.deepStrictEqual(bare, {
+ lines: ["/model"],
+ cursorLine: 0,
+ cursorCol: "/model".length,
+ });
+
+ const spaced = provider.applyCompletion(["/go"], 0, 3, { value: "goal", label: "goal" }, "/go");
+ assert.deepStrictEqual(spaced, {
+ lines: ["/goal "],
+ cursorLine: 0,
+ cursorCol: "/goal ".length,
});
});
});
diff --git a/packages/tui/test/editor.test.ts b/packages/tui/test/editor.test.ts
index 14cad2c628..82a80007a2 100644
--- a/packages/tui/test/editor.test.ts
+++ b/packages/tui/test/editor.test.ts
@@ -2193,7 +2193,7 @@ describe("Editor component", () => {
assert.strictEqual(editor.isShowingAutocomplete(), true);
editor.handleInput("\r");
- assert.strictEqual(editor.getText(), "Please use /help ");
+ assert.strictEqual(editor.getText(), "Please use /help");
assert.deepStrictEqual(submitted, []);
assert.strictEqual(editor.isShowingAutocomplete(), false);
});
@@ -2212,11 +2212,11 @@ describe("Editor component", () => {
assert.strictEqual(editor.isShowingAutocomplete(), true);
editor.handleInput("\t");
- assert.strictEqual(editor.getText(), "First line\nThen /help ");
+ assert.strictEqual(editor.getText(), "First line\nThen /help");
assert.strictEqual(editor.isShowingAutocomplete(), false);
});
- it("preserves standalone slash command submission", async () => {
+ it("completes a standalone slash command with Enter and submits on the next Enter", async () => {
const editor = new Editor(createTestTUI(), defaultEditorTheme);
const submitted: string[] = [];
editor.onSubmit = (text) => submitted.push(text);
@@ -2230,10 +2230,149 @@ describe("Editor component", () => {
await flushAutocomplete();
editor.handleInput("\r");
+ assert.deepStrictEqual(submitted, []);
+ assert.strictEqual(editor.getText(), "/help");
+ assert.strictEqual(editor.isShowingAutocomplete(), false);
+
+ editor.handleInput("\r");
assert.deepStrictEqual(submitted, ["/help"]);
assert.strictEqual(editor.getText(), "");
});
+ it("completes a no-argument slash command with Tab without submitting", async () => {
+ const editor = new Editor(createTestTUI(), defaultEditorTheme);
+ const submitted: string[] = [];
+ editor.onSubmit = (text) => submitted.push(text);
+ editor.setAutocompleteProvider(
+ new CombinedAutocompleteProvider([{ name: "model", description: "Select model" }], process.cwd()),
+ );
+
+ editor.handleInput("/");
+ editor.handleInput("m");
+ editor.handleInput("o");
+ await flushAutocomplete();
+ assert.strictEqual(editor.isShowingAutocomplete(), true);
+
+ editor.handleInput("\t");
+ assert.strictEqual(editor.getText(), "/model");
+ assert.deepStrictEqual(submitted, []);
+ assert.strictEqual(editor.isShowingAutocomplete(), false);
+
+ editor.handleInput("\r");
+ assert.deepStrictEqual(submitted, ["/model"]);
+ assert.strictEqual(editor.getText(), "");
+ });
+
+ it("completes a no-argument slash command with Enter without submitting", async () => {
+ const editor = new Editor(createTestTUI(), defaultEditorTheme);
+ const submitted: string[] = [];
+ editor.onSubmit = (text) => submitted.push(text);
+ editor.setAutocompleteProvider(
+ new CombinedAutocompleteProvider([{ name: "model", description: "Select model" }], process.cwd()),
+ );
+
+ editor.handleInput("/");
+ editor.handleInput("m");
+ editor.handleInput("o");
+ await flushAutocomplete();
+ assert.strictEqual(editor.isShowingAutocomplete(), true);
+
+ editor.handleInput("\r");
+ assert.strictEqual(editor.getText(), "/model");
+ assert.deepStrictEqual(submitted, []);
+ assert.strictEqual(editor.isShowingAutocomplete(), false);
+
+ editor.handleInput("\r");
+ assert.deepStrictEqual(submitted, ["/model"]);
+ assert.strictEqual(editor.getText(), "");
+ });
+
+ it("completes an argument-taking command with Tab to the parameter position without submitting", async () => {
+ const editor = new Editor(createTestTUI(), defaultEditorTheme);
+ const submitted: string[] = [];
+ editor.onSubmit = (text) => submitted.push(text);
+ editor.setAutocompleteProvider(
+ new CombinedAutocompleteProvider(
+ [{ name: "goal", description: "Set a goal", takesArgument: true }],
+ process.cwd(),
+ ),
+ );
+
+ editor.handleInput("/");
+ editor.handleInput("g");
+ editor.handleInput("o");
+ await flushAutocomplete();
+ assert.strictEqual(editor.isShowingAutocomplete(), true);
+
+ editor.handleInput("\t");
+ assert.strictEqual(editor.getText(), "/goal ");
+ assert.deepStrictEqual(submitted, []);
+ assert.strictEqual(editor.isShowingAutocomplete(), false);
+ });
+
+ it("completes an argument-taking command with Enter to the parameter position without submitting", async () => {
+ const editor = new Editor(createTestTUI(), defaultEditorTheme);
+ const submitted: string[] = [];
+ editor.onSubmit = (text) => submitted.push(text);
+ editor.setAutocompleteProvider(
+ new CombinedAutocompleteProvider(
+ [{ name: "goal", description: "Set a goal", takesArgument: true }],
+ process.cwd(),
+ ),
+ );
+
+ editor.handleInput("/");
+ editor.handleInput("g");
+ editor.handleInput("o");
+ await flushAutocomplete();
+ assert.strictEqual(editor.isShowingAutocomplete(), true);
+
+ editor.handleInput("\r");
+ assert.strictEqual(editor.getText(), "/goal ");
+ assert.deepStrictEqual(submitted, []);
+ assert.strictEqual(editor.isShowingAutocomplete(), false);
+ });
+
+ it("cancels the slash command autocomplete with Escape without submitting", async () => {
+ const editor = new Editor(createTestTUI(), defaultEditorTheme);
+ const submitted: string[] = [];
+ editor.onSubmit = (text) => submitted.push(text);
+ editor.setAutocompleteProvider(
+ new CombinedAutocompleteProvider([{ name: "model", description: "Select model" }], process.cwd()),
+ );
+
+ editor.handleInput("/");
+ editor.handleInput("m");
+ editor.handleInput("o");
+ await flushAutocomplete();
+ assert.strictEqual(editor.isShowingAutocomplete(), true);
+
+ editor.handleInput("\x1b");
+ assert.strictEqual(editor.isShowingAutocomplete(), false);
+ assert.strictEqual(editor.getText(), "/mo");
+ assert.deepStrictEqual(submitted, []);
+ });
+
+ it("submits a fully typed no-argument command with Enter", async () => {
+ const editor = new Editor(createTestTUI(), defaultEditorTheme);
+ const submitted: string[] = [];
+ editor.onSubmit = (text) => submitted.push(text);
+ editor.setAutocompleteProvider(
+ new CombinedAutocompleteProvider([{ name: "model", description: "Select model" }], process.cwd()),
+ );
+
+ editor.handleInput("/");
+ for (const char of "model") {
+ editor.handleInput(char);
+ }
+ await flushAutocomplete();
+
+ editor.handleInput("\r");
+
+ assert.deepStrictEqual(submitted, ["/model"]);
+ assert.strictEqual(editor.getText(), "");
+ });
+
it("does not trigger slash command autocomplete inside URLs or paths", async () => {
const editor = new Editor(createTestTUI(), defaultEditorTheme);
editor.setAutocompleteProvider(
@@ -2561,7 +2700,7 @@ describe("Editor component", () => {
assert.strictEqual(editor.isShowingAutocomplete(), true);
editor.handleInput("\t");
- assert.strictEqual(editor.getText(), "/help ");
+ assert.strictEqual(editor.getText(), "/help");
assert.strictEqual(editor.isShowingAutocomplete(), false);
});
});