A self-improving RLM agent for coding workflows and long-running autonomous tasks.
Rust
rewire shortcut flow (#362)
ktdcc3c258521a
diff --git a/packages/coding-agent/CHANGELOG.md b/packages/coding-agent/CHANGELOG.mdindex fda914b581..71e29dc58b 100644--- a/packages/coding-agent/CHANGELOG.md+++ b/packages/coding-agent/CHANGELOG.md@@ -2,11 +2,12 @@## [Unreleased]-<<<<<<< fix-agent-session-splash-alignment+- Changed Escape to interrupt active work with a visible abort notice, double Escape to open the session tree from an empty prompt or clear an idle draft, and `?` to show shortcuts ([ENG-4489](https://linear.app/primeintellect/issue/ENG-4489/rewire-prime-agent-shortcuts-to-match-claude-code-flow)).+- Changed new-chat guidance to show concise shell, command, file, and shortcut hints, with Agents View first and `? for shortcuts` after the model and effort ([ENG-4489](https://linear.app/primeintellect/issue/ENG-4489/rewire-prime-agent-shortcuts-to-match-claude-code-flow)).+- Changed `?` shortcut help to appear as a temporary compact panel below the transcript, while `/hotkeys` shows the full reference without Ctrl+Z ([ENG-4489](https://linear.app/primeintellect/issue/ENG-4489/rewire-prime-agent-shortcuts-to-match-claude-code-flow)).+- Fixed Escape repeats around autocomplete, queued draft restoration, whitespace-only drafts, and active background work ([ENG-4489](https://linear.app/primeintellect/issue/ENG-4489/rewire-prime-agent-shortcuts-to-match-claude-code-flow)).- Fixed the agents-view splash shifting when opening an agent session ([ENG-4517](https://linear.app/primeintellect/issue/ENG-4517)).-=======- Changed `/model` to sort featured flagship models above a provider's long tail (with a numeric-aware alphabetical tiebreak), so the full Prime Inference catalog doesn't flood the picker.->>>>>>> main- Changed automatic harness refinement to be enabled by default while keeping `autoRefine.enabled: false` as the opt-out.- Fixed non-numeric `autoRefine.turnInterval` and `autoRefine.cooldownMs` settings falling back to defaults instead of silently enabling a noisy auto-refine loop.- Fixed all session-resume entry points to share a searchable full-screen picker, stream results while loading, and support renaming ([ENG-4513](https://linear.app/primeintellect/issue/ENG-4513/resume-in-agents-view-is-broken)).diff --git a/packages/coding-agent/src/core/keybindings.ts b/packages/coding-agent/src/core/keybindings.tsindex c011beb773..99d35c552a 100644--- a/packages/coding-agent/src/core/keybindings.ts+++ b/packages/coding-agent/src/core/keybindings.ts@@ -14,6 +14,7 @@ export interface AppKeybindings {"app.interrupt": true;"app.clear": true;"app.input.clear": true;+ "app.shortcuts": true;"app.exit": true;"app.suspend": true;"app.model.select": true;@@ -72,7 +73,8 @@ export const KEYBINDINGS = {...TUI_KEYBINDINGS,"app.interrupt": { defaultKeys: [], description: "Interrupt current operation" },"app.clear": { defaultKeys: "ctrl+c", description: "Interrupt current operation, then exit" },- "app.input.clear": { defaultKeys: "escape", description: "Clear input" },+ "app.input.clear": { defaultKeys: "escape", description: "Interrupt response or clear prompt" },+ "app.shortcuts": { defaultKeys: "?", description: "Show keyboard shortcuts" },"app.exit": { defaultKeys: "ctrl+d", description: "Exit when editor is empty" },"app.suspend": {defaultKeys: process.platform === "win32" ? [] : "ctrl+z",diff --git a/packages/coding-agent/src/modes/interactive/components/assistant-message.ts b/packages/coding-agent/src/modes/interactive/components/assistant-message.tsindex 6ca79716ee..e8cd22cd0c 100644--- a/packages/coding-agent/src/modes/interactive/components/assistant-message.ts+++ b/packages/coding-agent/src/modes/interactive/components/assistant-message.ts@@ -250,23 +250,19 @@ export class AssistantMessageComponent extends Container {}}- // Check if aborted - show after partial content- // But only if there are no tool calls (tool execution components will show the error)const hasToolCalls = message.content.some((c) => c.type === "toolCall");this.hasToolCalls = hasToolCalls;- if (!hasToolCalls) {- if (message.stopReason === "aborted") {- const abortMessage =- message.errorMessage && message.errorMessage !== "Request was aborted"- ? message.errorMessage- : "Operation aborted";- this.contentContainer.addChild(new Spacer(1));- this.contentContainer.addChild(this.createErrorComponent(abortMessage));- } else if (message.stopReason === "error") {- const errorMsg = message.errorMessage || "Unknown error";- this.contentContainer.addChild(new Spacer(1));- this.contentContainer.addChild(this.createErrorComponent(errorMsg, "Error"));- }+ if (message.stopReason === "aborted") {+ const abortMessage =+ message.errorMessage && message.errorMessage !== "Request was aborted"+ ? message.errorMessage+ : "Operation aborted";+ this.contentContainer.addChild(new Spacer(1));+ this.contentContainer.addChild(this.createErrorComponent(abortMessage));+ } else if (!hasToolCalls && message.stopReason === "error") {+ const errorMsg = message.errorMessage || "Unknown error";+ this.contentContainer.addChild(new Spacer(1));+ this.contentContainer.addChild(this.createErrorComponent(errorMsg, "Error"));}}diff --git a/packages/coding-agent/src/modes/interactive/components/custom-editor.ts b/packages/coding-agent/src/modes/interactive/components/custom-editor.tsindex 1cbfed4f3d..bd64b5cf19 100644--- a/packages/coding-agent/src/modes/interactive/components/custom-editor.ts+++ b/packages/coding-agent/src/modes/interactive/components/custom-editor.ts@@ -149,6 +149,14 @@ export class CustomEditor extends Editor {return;}+ const repeatedClearInput = this.splitRepeatedKeybinding(data, "app.input.clear");+ if (repeatedClearInput) {+ for (const input of repeatedClearInput) {+ this.handleInput(input);+ }+ return;+ }+// Check for paste image keybindingif (this.keybindings.matches(data, "app.clipboard.pasteImage")) {this.onPasteImage?.();@@ -161,17 +169,20 @@ export class CustomEditor extends Editor {return;}- // Clear input - only if autocomplete is NOT active+ // Clear inputif (this.keybindings.matches(data, "app.input.clear")) {- if (!this.isShowingAutocomplete()) {- // Use dynamic onEscape if set, otherwise registered handler- const handler = this.onEscape ?? this.actionHandlers.get("app.input.clear");- if (handler) {- handler();- return;- }+ const hadAutocomplete = this.isShowingAutocomplete();+ if (hadAutocomplete) {+ this.cancelAutocomplete();+ }+ const handler = this.onEscape ?? this.actionHandlers.get("app.input.clear");+ if (handler) {+ handler();+ return;+ }+ if (hadAutocomplete) {+ return;}- // Let parent handle escape for autocomplete cancellationsuper.handleInput(data);return;}@@ -188,7 +199,12 @@ export class CustomEditor extends Editor {// Check all other app actionsfor (const [action, handler] of this.actionHandlers) {- if (action !== "app.input.clear" && action !== "app.exit" && this.keybindings.matches(data, action)) {+ if (+ action !== "app.input.clear" &&+ action !== "app.exit" &&+ (action !== "app.shortcuts" || this.getText().length === 0) &&+ this.keybindings.matches(data, action)+ ) {if ((action === "app.clear" || action === "app.interrupt") && this.isShowingAutocomplete()) {this.cancelAutocomplete();}@@ -211,6 +227,29 @@ export class CustomEditor extends Editor {super.handleInput(data);}+ private splitRepeatedKeybinding(data: string, keybinding: AppKeybinding): string[] | undefined {+ const inputs: string[] = [];+ let offset = 0;++ while (offset < data.length) {+ let match: string | undefined;+ for (let end = offset + 1; end <= data.length; end++) {+ const candidate = data.slice(offset, end);+ if (this.keybindings.matches(candidate, keybinding)) {+ match = candidate;+ offset = end;+ break;+ }+ }+ if (!match) {+ return undefined;+ }+ inputs.push(match);+ }++ return inputs.length > 1 ? inputs : undefined;+ }+private getEffectivePaddingX(width: number): number {const maxPadding = Math.max(0, Math.floor((width - 1) / 2));const configuredPaddingX = Math.min(this.configuredPaddingX, maxPadding);diff --git a/packages/coding-agent/src/modes/interactive/interactive-mode.ts b/packages/coding-agent/src/modes/interactive/interactive-mode.tsindex b9350f04b9..302f6e98ae 100644--- a/packages/coding-agent/src/modes/interactive/interactive-mode.ts+++ b/packages/coding-agent/src/modes/interactive/interactive-mode.ts@@ -300,6 +300,7 @@ export interface BrandSplashHeaderOptions {logo?: string;getExtraMetadata?: () => readonly BrandSplashMetadataLine[];getHideStartHint?: () => boolean;+ getStartHint?: () => string;}export class BrandSplashHeader implements Component {@@ -337,13 +338,14 @@ export class BrandSplashHeader implements Component {};const extraMetadata = this.options.getExtraMetadata?.() ?? [];const hideStartHint = this.options.getHideStartHint?.() ?? false;+ const startHint = this.options.getStartHint?.() ?? "type to start";const metaLines = showMeta? [labelled("version", `v${this.version}`),labelled("model", this.getModelId() ?? "—"),labelled("cwd", formatSplashCwd(this.getCwd())),...extraMetadata.map((line) => labelled(line.label, line.value)),- ...(hideStartHint ? [] : ["", theme.fg("dim", "type to start")]),+ ...(hideStartHint ? [] : ["", theme.fg("dim", startHint)]),]: [];const metaStart = Math.max(0, Math.floor((this.logoRaw.length - metaLines.length) / 2));@@ -572,6 +574,7 @@ export type InteractiveModeRunResult = "agents_view";export class InteractiveMode {private static readonly EXIT_HINT_DURATION_MS = 2000;+ private static readonly ESCAPE_REPEAT_WINDOW_MS = 500;private uiServices: InteractiveModeUiServices;private agentConnection: AgentConnection;@@ -579,6 +582,7 @@ export class InteractiveMode {private bindLocalSessionExtensions: boolean;private ui: TUI;private chatContainer: Container;+ private shortcutGuideContainer: Container;private pendingMessagesContainer: Container;private statusContainer: Container;private queuedMessagesContainer: Container;@@ -622,6 +626,10 @@ export class InteractiveMode {private ctrlCExitHintExpiresAt = 0;private ctrlCExitHintTimer: ReturnType<typeof setTimeout> | undefined = undefined;+ private escapeRepeatAction: "tree" | "clear" | undefined;+ private escapeRepeatExpiresAt = 0;+ private escapeRepeatTimer: ReturnType<typeof setTimeout> | undefined = undefined;+ private isRestoringQueuedEditorText = false;private anthropicSubscriptionWarningShown = false;// Status line tracking (for mutating immediately-sequential status updates)@@ -684,8 +692,7 @@ export class InteractiveMode {private connectionState: AgentConnectionState | undefined;private connectionResourceSnapshot: AgentConnectionResourceSnapshot | undefined;private initialConnectionSnapshotConsumed = false;- // Whether the session already had messages when first rendered (i.e. a resumed session).- private sessionHadInitialMessages = false;+ private sessionHasMessages = false;// Registry of images pasted this session, keyed by the `[image #N]` marker// shown to the user. Insertion-ordered; the bytes persist (bounded by@@ -778,6 +785,7 @@ export class InteractiveMode {};this.headerContainer = new Container();this.chatContainer = new Container();+ this.shortcutGuideContainer = new Container();this.pendingMessagesContainer = new Container();this.statusContainer = new Container();this.queuedMessagesContainer = new Container();@@ -804,7 +812,7 @@ export class InteractiveMode {paddingX: editorPaddingX,autocompleteMaxVisible,isArgumentCommand: builtinSlashCommandTakesArgument,- placeholder: "Type a message, / for commands",+ placeholder: 'Try "refactor @<filepath>"',placeholderColor: (text) => theme.fg("dim", text),});this.editor = this.defaultEditor;@@ -1055,7 +1063,11 @@ export class InteractiveMode {() => this.getCurrentModelId(),() => this.getCurrentCwd(),verboseInstructions,- { getHideStartHint: () => this.childAgentPanelMode !== undefined },+ {+ getExtraMetadata: () => this.getStartupMetadata(),+ getHideStartHint: () => this.childAgentPanelMode !== undefined || !this.isNewChat(),+ getStartHint: () => 'Try "refactor @<filepath>"',+ },);this.headerContainer.addChild(this.builtInHeader);this.headerContainer.addChild(new Spacer(1));@@ -1224,7 +1236,7 @@ export class InteractiveMode {// The agents view owns these for daemon sessions. When there is no agents view,// show them once at the top of a fresh session, but never append them under a// restored conversation where they read as disconnected clutter.- if (!ownsGlobalStartupNotices || this.sessionHadInitialMessages) {+ if (!ownsGlobalStartupNotices || this.sessionHasMessages) {return;}@@ -2311,6 +2323,10 @@ export class InteractiveMode {return this.connectionState?.isBashRunning ?? false;}+ private hasInterruptibleWork(): boolean {+ return this.isAgentStreaming() || this.isAgentCompacting() || this.isBashRunning() || this.getRetryAttempt() > 0;+ }+private getRetryAttempt(): number {return this.connectionState?.retryAttempt ?? 0;}@@ -2385,6 +2401,7 @@ export class InteractiveMode {private resetCurrentSessionRenderState(options?: { clearPromptStash?: boolean }): void {this.chatContainer.clear();+ this.shortcutGuideContainer.clear();this.pendingMessagesContainer.clear();this.queuedMessagesContainer.clear();this.compactionQueuedMessages = [];@@ -3464,12 +3481,13 @@ export class InteractiveMode {// Set up handlers on defaultEditor - they use this.editor for text access// so they work correctly regardless of which editor is activethis.defaultEditor.onEscape = () => {- this.clearInputBar();+ this.handleEscape();};// Register app action handlersthis.defaultEditor.onAction("app.clear", () => this.handleCtrlC());this.defaultEditor.onAction("app.interrupt", () => this.handleInterruptKey());+ this.defaultEditor.onAction("app.shortcuts", () => this.showShortcutGuide());this.defaultEditor.onCtrlD = () => this.handleCtrlD();this.defaultEditor.onAction("app.suspend", () => this.handleCtrlZ());@@ -3507,6 +3525,9 @@ export class InteractiveMode {this.defaultEditor.onMoveBelowPrompt = () => this.focusChildAgentSummary();this.defaultEditor.onChange = (text: string) => {+ if (this.escapeRepeatAction && !this.isRestoringQueuedEditorText) {+ this.clearEscapeRepeat();+ }if (text.length > 0) {this.clearCtrlCExitHint();}@@ -3660,6 +3681,7 @@ export class InteractiveMode {this.defaultEditor.onSubmit = async (text: string) => {text = text.trim();if (!text) return;+ this.clearShortcutGuide();const promptStashToRestore = this.promptStash;let restorePromptStashAfterSubmit = true;@@ -4164,6 +4186,8 @@ export class InteractiveMode {// reset with it. (agent_start on auto-retry does not reset the tracker.)if (event.type === "message_start" && event.message.role === "user") {this.contextUsageTokenBaseline = 0;+ this.setSessionHasMessages(true);+ this.clearShortcutGuide();}this.activityTracker.handleEvent(event);this.updateWorkingLoaderMessage();@@ -4728,6 +4752,7 @@ export class InteractiveMode {private restoreMainAgentView(): void {this.mainViewContainer.clear();this.mainViewContainer.addChild(this.chatContainer);+ this.mainViewContainer.addChild(this.shortcutGuideContainer);this.mainViewContainer.addChild(this.pendingMessagesContainer);// Subagent tree sits directly above the loader, mirroring Claude's layout.this.mainViewContainer.addChild(this.subagentTree);@@ -4808,8 +4833,46 @@ export class InteractiveMode {}private getTrayLocationLabel(): string | undefined {+ const modelLabel = this.getModelTrayLabel();+ const shortcutsHint = this.getShortcutsTrayHint();const agentsHint = this.getAgentsViewTrayHint();- return [agentsHint, this.getModelTrayLabel()].filter((label): label is string => label !== undefined).join(" ");+ return [agentsHint, modelLabel, shortcutsHint].filter((label): label is string => label !== undefined).join(" ");+ }++ private getStartupMetadata(): BrandSplashMetadataLine[] {+ if (this.childAgentPanelMode || !this.isNewChat()) {+ return [];+ }+ return [+ { label: "input", value: "! shell · / commands" },+ { label: "files", value: "@ file paths" },+ { label: "help", value: this.getShortcutHelpHint() },+ ];+ }++ private getShortcutsTrayHint(): string | undefined {+ if (!this.isNewChat()) {+ return undefined;+ }+ return keyText("app.shortcuts") ? keyHint("app.shortcuts", "for shortcuts") : "/hotkeys for shortcuts";+ }++ private getShortcutHelpHint(): string {+ const shortcuts = keyText("app.shortcuts");+ return shortcuts ? `${shortcuts} for shortcuts` : "/hotkeys for shortcuts";+ }++ private isNewChat(): boolean {+ return !this.sessionHasMessages;+ }++ private setSessionHasMessages(hasMessages: boolean): void {+ if (this.sessionHasMessages === hasMessages) {+ return;+ }+ this.sessionHasMessages = hasMessages;+ this.builtInHeader?.invalidate();+ this.childAgentSummary.invalidate();}private getModelTrayLabel(): string {@@ -4831,7 +4894,7 @@ export class InteractiveMode {if (this.editor.getText().trim()) {return undefined;}- return keyHint("app.agents.back", "manage sessions");+ return keyHint("app.agents.back", "agents view");}private getTrayContextLabel(): string | undefined {@@ -5446,10 +5509,10 @@ export class InteractiveMode {const snapshot = await this.agentConnection.getInitialSnapshot();this.initialConnectionSnapshotConsumed = true;context = this.getSessionContextFromConnectionSnapshot(snapshot);- this.sessionHadInitialMessages = context.messages.length > 0;state = snapshot.state;this.seedChildAgentInspector(snapshot.children);}+ this.setSessionHasMessages(context.messages.length > 0);this.applyConnectionStateSnapshot(state);await this.renderSessionContext(context, {updateFooter: true,@@ -5498,7 +5561,53 @@ export class InteractiveMode {// Key handlers// =========================================================================+ private handleEscape(): void {+ this.clearCtrlCExitHint();+ const action = this.takeEscapeRepeatAction();+ if (action === "tree") {+ void this.showTreeSelector();+ return;+ }+ if (action === "clear") {+ this.clearInputBar();+ return;+ }++ this.armEscapeRepeat(this.hasInterruptibleWork() || this.editor.getText().length === 0 ? "tree" : "clear");+ this.interruptOrClearInput();+ }++ private armEscapeRepeat(action: "tree" | "clear"): void {+ this.clearEscapeRepeat();+ this.escapeRepeatAction = action;+ this.escapeRepeatExpiresAt = Date.now() + InteractiveMode.ESCAPE_REPEAT_WINDOW_MS;+ this.escapeRepeatTimer = setTimeout(() => {+ this.clearEscapeRepeat();+ }, InteractiveMode.ESCAPE_REPEAT_WINDOW_MS);+ this.escapeRepeatTimer.unref?.();+ }++ private takeEscapeRepeatAction(): "tree" | "clear" | undefined {+ if (!this.escapeRepeatAction || this.escapeRepeatExpiresAt <= Date.now()) {+ this.clearEscapeRepeat();+ return undefined;+ }+ const action = this.escapeRepeatAction;+ this.clearEscapeRepeat();+ return action;+ }++ private clearEscapeRepeat(): void {+ if (this.escapeRepeatTimer) {+ clearTimeout(this.escapeRepeatTimer);+ this.escapeRepeatTimer = undefined;+ }+ this.escapeRepeatAction = undefined;+ this.escapeRepeatExpiresAt = 0;+ }+private handleCtrlC(): void {+ this.clearEscapeRepeat();if (this.isCtrlCExitHintVisible()) {void this.shutdown();return;@@ -5507,6 +5616,7 @@ export class InteractiveMode {}private handleInterruptKey(): void {+ this.clearEscapeRepeat();this.interruptOrClearInput();this.showCtrlCExitHint();}@@ -5959,6 +6069,7 @@ export class InteractiveMode {}private clearInputBar(): void {+ this.clearEscapeRepeat();this.clearCtrlCExitHint({ render: false });this.editor.setText("");this.ui.requestRender();@@ -6076,7 +6187,12 @@ export class InteractiveMode {const combinedText = [queuedText, currentText].filter((t) => t.trim()).join("\n\n");// The image registry persists, so the restored `[image #N]` markers resolve// on resubmit without any re-registration here.- this.editor.setText(combinedText);+ this.isRestoringQueuedEditorText = true;+ try {+ this.editor.setText(combinedText);+ } finally {+ this.isRestoringQueuedEditorText = false;+ }this.updatePendingMessagesDisplay();return allQueued.length;}@@ -8078,8 +8194,35 @@ export class InteractiveMode {return this.capitalizeKey(keyText(action));}- private handleHotkeysCommand(): void {- // Navigation keybindings+ private getShortcutGuide(): string {+ const tab = this.getEditorKeyDisplay("tui.input.tab");+ const newLine = this.getEditorKeyDisplay("tui.input.newLine");+ const clearInput = this.getAppKeyDisplay("app.input.clear");+ const shortcutsKey = this.getAppKeyDisplay("app.shortcuts");+ const selectModel = this.getAppKeyDisplay("app.model.select");+ const expandTools = this.getAppKeyDisplay("app.tools.expand");+ const toggleThinking = this.getAppKeyDisplay("app.thinking.toggle");+ const externalEditor = this.getAppKeyDisplay("app.editor.external");+ const promptStash = this.getAppKeyDisplay("app.prompt.stash");+ const pasteImage = this.getAppKeyDisplay("app.clipboard.pasteImage");++ return `+**Prompt**+\`!\` shell mode · \`/\` commands · \`@\` file paths+\`${tab}\` complete paths · \`${newLine}\` new line+\`${clearInput}\` interrupt · press twice to rewind or clear the prompt++**Controls**+\`${selectModel}\` select model · \`/effort\` set reasoning · \`${expandTools}\` tool output+\`${toggleThinking}\` thinking blocks · \`${promptStash}\` stash prompt · \`${externalEditor}\` edit in \`$EDITOR\`+\`${pasteImage}\` paste image++**Help**+${shortcutsKey ? `\`${shortcutsKey}\` quick shortcuts · ` : ""}\`/hotkeys\` full reference+`;+ }++ private getHotkeysGuide(): string {const cursorUp = this.getEditorKeyDisplay("tui.editor.cursorUp");const cursorDown = this.getEditorKeyDisplay("tui.editor.cursorDown");const cursorLeft = this.getEditorKeyDisplay("tui.editor.cursorLeft");@@ -8092,8 +8235,6 @@ export class InteractiveMode {const jumpBackward = this.getEditorKeyDisplay("tui.editor.jumpBackward");const pageUp = this.getEditorKeyDisplay("tui.editor.pageUp");const pageDown = this.getEditorKeyDisplay("tui.editor.pageDown");-- // Editing keybindingsconst submit = this.getEditorKeyDisplay("tui.input.submit");const newLine = this.getEditorKeyDisplay("tui.input.newLine");const deleteWordBackward = this.getEditorKeyDisplay("tui.editor.deleteWordBackward");@@ -8104,13 +8245,11 @@ export class InteractiveMode {const yankPop = this.getEditorKeyDisplay("tui.editor.yankPop");const undo = this.getEditorKeyDisplay("tui.editor.undo");const tab = this.getEditorKeyDisplay("tui.input.tab");-- // App keybindingsconst clear = this.getAppKeyDisplay("app.clear");const clearInput = this.getAppKeyDisplay("app.input.clear");const interrupt = this.getAppKeyDisplay("app.interrupt");+ const shortcutsKey = this.getAppKeyDisplay("app.shortcuts");const exit = this.getAppKeyDisplay("app.exit");- const suspend = this.getAppKeyDisplay("app.suspend");const selectModel = this.getAppKeyDisplay("app.model.select");const expandTools = this.getAppKeyDisplay("app.tools.expand");const toggleThinking = this.getAppKeyDisplay("app.thinking.toggle");@@ -8120,8 +8259,6 @@ export class InteractiveMode {const followUp = this.getAppKeyDisplay("app.message.followUp");const dequeue = this.getAppKeyDisplay("app.message.dequeue");const pasteImage = this.getAppKeyDisplay("app.clipboard.pasteImage");-- // Fullscreen viewport keybindingsconst viewportPageUp = this.getEditorKeyDisplay("tui.viewport.pageUp");const viewportPageDown = this.getEditorKeyDisplay("tui.viewport.pageDown");const viewportTop = this.getEditorKeyDisplay("tui.viewport.top");@@ -8158,8 +8295,7 @@ export class InteractiveMode {| \`${tab}\` | Path completion / accept autocomplete || \`${clearInput}\` | Clear input / cancel autocomplete || \`${clear}\` | Interrupt current operation (first) / exit (second) |-${interrupt ? `| \`${interrupt}\` | Interrupt current operation |\n` : ""}| \`${exit}\` | Exit (when editor is empty) |-| \`${suspend}\` | Suspend to background |+${interrupt ? `| \`${interrupt}\` | Interrupt current operation |\n` : ""}${shortcutsKey ? `| \`${shortcutsKey}\` | Show quick shortcuts |\n` : ""}| \`${exit}\` | Exit (when editor is empty) || \`${selectModel}\` | Open model selector || \`${expandTools}\` | Toggle tool output expansion || \`${toggleThinking}\` | Toggle thinking block visibility |@@ -8180,7 +8316,6 @@ ${interrupt ? `| \`${interrupt}\` | Interrupt current operation |\n` : ""}| \`${| mouse wheel | Scroll transcript |`;- // Add extension-registered shortcutsconst shortcuts = this.bindLocalSessionExtensions? this.getLocalSessionHost().getExtensionRunner().getShortcuts(this.keybindings.getEffectiveConfig()): undefined;@@ -8192,17 +8327,35 @@ ${interrupt ? `| \`${interrupt}\` | Interrupt current operation |\n` : ""}| \`${`;for (const [key, shortcut] of shortcuts) {const description = shortcut.description ?? shortcut.extensionPath;- const keyDisplay = formatKeyText(key);- hotkeys += `| \`${keyDisplay}\` | ${description} |\n`;+ hotkeys += `| \`${formatKeyText(key)}\` | ${description} |\n`;}}- this.chatContainer.addChild(new Spacer(1));- this.chatContainer.addChild(new DynamicBorder());- this.chatContainer.addChild(new Text(theme.bold(theme.fg("accent", "Keyboard Shortcuts")), 1, 0));+ return hotkeys;+ }++ private showShortcutGuide(): void {+ const hotkeys = this.getShortcutGuide();++ this.shortcutGuideContainer.clear();+ this.shortcutGuideContainer.addChild(new Spacer(1));+ this.shortcutGuideContainer.addChild(new Markdown(hotkeys.trim(), 1, 1, this.getMarkdownThemeWithSettings()));+ this.ui.requestRender();+ }++ private handleHotkeysCommand(): void {+ const hotkeys = this.getHotkeysGuide();+this.chatContainer.addChild(new Spacer(1));this.chatContainer.addChild(new Markdown(hotkeys.trim(), 1, 1, this.getMarkdownThemeWithSettings()));- this.chatContainer.addChild(new DynamicBorder());+ this.ui.requestRender();+ }++ private clearShortcutGuide(): void {+ if (this.shortcutGuideContainer.children.length === 0) {+ return;+ }+ this.shortcutGuideContainer.clear();this.ui.requestRender();}@@ -8372,6 +8525,7 @@ ${interrupt ? `| \`${interrupt}\` | Interrupt current operation |\n` : ""}| \`${stop(options: { preserveAltScreen?: boolean } = {}): void {this.unregisterSignalHandlers();this.clearCtrlCExitHint({ render: false });+ this.clearEscapeRepeat();if (this.settingsManager.getShowTerminalProgress()) {this.ui.terminal.setProgress(false);}diff --git a/packages/coding-agent/test/assistant-message.test.ts b/packages/coding-agent/test/assistant-message.test.tsindex 3cbee0d607..a18ebcc9d7 100644--- a/packages/coding-agent/test/assistant-message.test.ts+++ b/packages/coding-agent/test/assistant-message.test.ts@@ -56,6 +56,21 @@ describe("AssistantMessageComponent", () => {expect(rendered.includes(OSC133_ZONE_FINAL)).toBe(false);});+ test("renders an abort status for messages with tool calls", () => {+ initTheme("dark");++ const message = {+ ...createAssistantMessage([+ { type: "toolCall" as const, id: "tool-1", name: "ipython", arguments: { code: "while True: pass" } },+ ]),+ stopReason: "aborted" as const,+ errorMessage: "Operation aborted",+ };+ const rendered = stripAnsi(new AssistantMessageComponent(message).render(80).join("\n"));++ expect(rendered).toContain("Operation aborted");+ });+test("honors initial expansion for multiline assistant errors", () => {initTheme("dark");diff --git a/packages/coding-agent/test/custom-editor.test.ts b/packages/coding-agent/test/custom-editor.test.tsindex 21250fee38..413660bb9b 100644--- a/packages/coding-agent/test/custom-editor.test.ts+++ b/packages/coding-agent/test/custom-editor.test.ts@@ -68,6 +68,75 @@ describe("CustomEditor", () => {expect(editor.getText()).toBe("/");});+ it("routes Escape through its handler while dismissing autocomplete", async () => {+ const editor = new CustomEditor(fakeTui, editorTheme, new KeybindingsManager());+ const handler = vi.fn();++ editor.setAutocompleteProvider(autocompleteProvider);+ editor.onEscape = handler;+ editor.handleInput("/");+ await vi.waitFor(() => expect(editor.isShowingAutocomplete()).toBe(true));++ editor.handleInput("\x1b");++ expect(editor.isShowingAutocomplete()).toBe(false);+ expect(handler).toHaveBeenCalledTimes(1);+ });++ it("handles the question-mark shortcut as an app action", () => {+ const editor = new CustomEditor(fakeTui, editorTheme, new KeybindingsManager());+ const handler = vi.fn();++ editor.onAction("app.shortcuts", handler);+ editor.handleInput("?");++ expect(handler).toHaveBeenCalledTimes(1);+ expect(editor.getText()).toBe("");+ });++ it("keeps question marks in a nonempty prompt", () => {+ const editor = new CustomEditor(fakeTui, editorTheme, new KeybindingsManager());+ const handler = vi.fn();+ editor.onAction("app.shortcuts", handler);+ editor.setText("Can this contain");++ editor.handleInput("?");++ expect(handler).not.toHaveBeenCalled();+ expect(editor.getText()).toBe("Can this contain?");+ });++ it("splits terminal-batched repeats for the configured clear-input binding", () => {+ const editor = new CustomEditor(fakeTui, editorTheme, new KeybindingsManager());+ const handler = vi.fn();+ editor.onEscape = handler;++ editor.handleInput("\x1b\x1b");++ expect(handler).toHaveBeenCalledTimes(2);+ });++ it("splits arbitrary terminal-batched clear-input repeats", () => {+ const editor = new CustomEditor(fakeTui, editorTheme, new KeybindingsManager());+ const handler = vi.fn();+ editor.onEscape = handler;++ editor.handleInput("\x1b\x1b\x1b");++ expect(handler).toHaveBeenCalledTimes(3);+ });++ it("uses custom clear-input bindings when splitting batched repeats", () => {+ const keybindings = new KeybindingsManager({ "app.input.clear": "ctrl+x" });+ const editor = new CustomEditor(fakeTui, editorTheme, keybindings);+ const handler = vi.fn();+ editor.onEscape = handler;++ editor.handleInput("\x18\x18");++ expect(handler).toHaveBeenCalledTimes(2);+ });+it("renders a header line and blank spacer inside the top of the editor box", () => {const editor = new CustomEditor(fakeTui, editorTheme, new KeybindingsManager());const withoutHeader = editor.render(40);diff --git a/packages/coding-agent/test/interactive-mode-ctrl-c.test.ts b/packages/coding-agent/test/interactive-mode-ctrl-c.test.tsindex da3653eea3..89ee712303 100644--- a/packages/coding-agent/test/interactive-mode-ctrl-c.test.ts+++ b/packages/coding-agent/test/interactive-mode-ctrl-c.test.ts@@ -13,6 +13,9 @@ type FakeEditor = {type FakeInteractiveMode = {ctrlCExitHintExpiresAt: number;ctrlCExitHintTimer: ReturnType<typeof setTimeout> | undefined;+ escapeRepeatAction: "tree" | "clear" | undefined;+ escapeRepeatExpiresAt: number;+ escapeRepeatTimer: ReturnType<typeof setTimeout> | undefined;isShuttingDown: boolean;editor: FakeEditor;connectionState: {@@ -36,6 +39,7 @@ type FakeInteractiveMode = {ui: { requestRender: Mock; onDebug?: () => void };restoreQueuedMessagesToEditor: Mock;updatePendingMessagesDisplay: Mock;+ showTreeSelector: Mock;shutdown: Mock;updateEditorBorderColor: Mock;defaultEditor?: {@@ -48,6 +52,7 @@ type FakeInteractiveMode = {};keybindings?: KeybindingsManager;handleDebugCommand?: Mock;+ showShortcutGuide?: Mock;};function createEditor(text = ""): FakeEditor {@@ -77,6 +82,9 @@ function createInteractiveFake(options: {const fake: FakeInteractiveMode = {ctrlCExitHintExpiresAt: 0,ctrlCExitHintTimer: undefined,+ escapeRepeatAction: undefined,+ escapeRepeatExpiresAt: 0,+ escapeRepeatTimer: undefined,isShuttingDown: false,editor,connectionState: {@@ -100,14 +108,16 @@ function createInteractiveFake(options: {ui: { requestRender: vi.fn() },restoreQueuedMessagesToEditor: vi.fn().mockResolvedValue(0),updatePendingMessagesDisplay: vi.fn(),+ showTreeSelector: vi.fn(),shutdown: vi.fn().mockResolvedValue(undefined),updateEditorBorderColor: vi.fn(),+ showShortcutGuide: vi.fn(),};Object.setPrototypeOf(fake, InteractiveMode.prototype);return fake;}-describe("InteractiveMode Ctrl+C flow", () => {+describe("InteractiveMode interrupt shortcuts", () => {beforeEach(() => {setKeybindings(new KeybindingsManager());vi.useFakeTimers();@@ -194,7 +204,7 @@ describe("InteractiveMode Ctrl+C flow", () => {expect(mode.shutdown).not.toHaveBeenCalled();});- it("makes Escape clear input without aborting the agent", () => {+ it("cancels the tree repeat when typing after interrupting streaming", () => {const actionHandlers = new Map<string, () => void>();const mode = createInteractiveFake({ editorText: "draft", streaming: true });const defaultEditor: NonNullable<FakeInteractiveMode["defaultEditor"]> = {@@ -210,13 +220,156 @@ describe("InteractiveMode Ctrl+C flow", () => {Reflect.get(InteractiveMode.prototype, "setupKeyHandlers").call(mode);expect(defaultEditor.onEscape).toBeDefined();+ defaultEditor.onEscape?.();+ expect(mode.restoreQueuedMessagesToEditor).toHaveBeenCalledWith({ abort: true });+ expect(mode.editor.getText()).toBe("draft");+ mode.editor.setText("queued draft");+ defaultEditor.onChange?.("queued draft");++ defaultEditor.onEscape?.();++ expect(mode.showTreeSelector).not.toHaveBeenCalled();+ expect(mode.shutdown).not.toHaveBeenCalled();+ });++ it("preserves the tree repeat while restoring queued messages", async () => {+ const mode = createInteractiveFake({});+ const defaultEditor: NonNullable<FakeInteractiveMode["defaultEditor"]> = {+ onAction: vi.fn(),+ };+ Object.assign(mode, {+ defaultEditor,+ keybindings: new KeybindingsManager(),+ handleDebugCommand: vi.fn(),+ });+ Reflect.get(InteractiveMode.prototype, "setupKeyHandlers").call(mode);+ const setText = mode.editor.setText.bind(mode.editor);+ mode.editor.setText = (text) => {+ setText(text);+ defaultEditor.onChange?.(text);+ };+ mode.escapeRepeatAction = "tree";+ mode.escapeRepeatExpiresAt = Date.now() + 500;+ mode.agentConnection.abortAndClearQueue.mockResolvedValue({ steering: ["queued"], followUp: [] });++ const restoreQueuedMessagesToEditor = Reflect.get(InteractiveMode.prototype, "restoreQueuedMessagesToEditor");+ await restoreQueuedMessagesToEditor.call(mode, { abort: true });++ expect(mode.escapeRepeatAction).toBe("tree");+ });++ it("clears an idle draft on double Escape", () => {+ const actionHandlers = new Map<string, () => void>();+ const mode = createInteractiveFake({ editorText: "draft" });+ const defaultEditor: NonNullable<FakeInteractiveMode["defaultEditor"]> = {+ onAction: vi.fn((action: string, handler: () => void) => {+ actionHandlers.set(action, handler);+ }),+ };+ Object.assign(mode, {+ defaultEditor,+ keybindings: new KeybindingsManager(),+ handleDebugCommand: vi.fn(),+ });++ Reflect.get(InteractiveMode.prototype, "setupKeyHandlers").call(mode);+ defaultEditor.onEscape?.();+ expect(mode.editor.getText()).toBe("draft");+defaultEditor.onEscape?.();expect(mode.editor.getText()).toBe("");- expect(mode.agentConnection.abortRetry).not.toHaveBeenCalled();- expect(mode.agentConnection.abortCompaction).not.toHaveBeenCalled();- expect(mode.agentConnection.abortBranchSummary).not.toHaveBeenCalled();- expect(mode.agentConnection.abortBash).not.toHaveBeenCalled();expect(mode.restoreQueuedMessagesToEditor).not.toHaveBeenCalled();});++ it("opens the tree on double Escape with an empty idle prompt", () => {+ const mode = createInteractiveFake({});+ const handleEscape = Reflect.get(InteractiveMode.prototype, "handleEscape");++ handleEscape.call(mode);+ handleEscape.call(mode);++ expect(mode.showTreeSelector).toHaveBeenCalledTimes(1);+ expect(mode.editor.getText()).toBe("");+ });++ it("clears a whitespace draft on double Escape", () => {+ const mode = createInteractiveFake({ editorText: " " });+ const handleEscape = Reflect.get(InteractiveMode.prototype, "handleEscape");++ handleEscape.call(mode);+ handleEscape.call(mode);++ expect(mode.showTreeSelector).not.toHaveBeenCalled();+ expect(mode.editor.getText()).toBe("");+ });++ for (const [label, options] of [+ ["a retry", { retryAttempt: 1 }],+ ["compaction", { compacting: true }],+ ["a bash command", { bashRunning: true }],+ ] as const) {+ it(`opens the tree after cancelling ${label} without clearing the draft`, () => {+ const mode = createInteractiveFake({ editorText: "draft", ...options });+ const handleEscape = Reflect.get(InteractiveMode.prototype, "handleEscape");++ handleEscape.call(mode);+ handleEscape.call(mode);++ expect(mode.showTreeSelector).toHaveBeenCalledTimes(1);+ expect(mode.editor.getText()).toBe("draft");+ });+ }++ it("clears the Escape repeat before a separate interrupt", () => {+ const mode = createInteractiveFake({});+ mode.escapeRepeatAction = "tree";+ mode.escapeRepeatExpiresAt = Date.now() + 500;++ Reflect.get(InteractiveMode.prototype, "handleInterruptKey").call(mode);++ expect(mode.escapeRepeatAction).toBeUndefined();+ });++ it("expires the Escape repeat window", async () => {+ const actionHandlers = new Map<string, () => void>();+ const mode = createInteractiveFake({ editorText: "draft" });+ const defaultEditor: NonNullable<FakeInteractiveMode["defaultEditor"]> = {+ onAction: vi.fn((action: string, handler: () => void) => {+ actionHandlers.set(action, handler);+ }),+ };+ Object.assign(mode, {+ defaultEditor,+ keybindings: new KeybindingsManager(),+ handleDebugCommand: vi.fn(),+ });++ Reflect.get(InteractiveMode.prototype, "setupKeyHandlers").call(mode);+ defaultEditor.onEscape?.();+ await vi.advanceTimersByTimeAsync(500);+ defaultEditor.onEscape?.();++ expect(mode.editor.getText()).toBe("draft");+ });++ it("opens keyboard shortcuts from the configured app action", () => {+ const actionHandlers = new Map<string, () => void>();+ const mode = createInteractiveFake({});+ const defaultEditor: NonNullable<FakeInteractiveMode["defaultEditor"]> = {+ onAction: vi.fn((action: string, handler: () => void) => {+ actionHandlers.set(action, handler);+ }),+ };+ Object.assign(mode, {+ defaultEditor,+ keybindings: new KeybindingsManager(),+ handleDebugCommand: vi.fn(),+ });++ Reflect.get(InteractiveMode.prototype, "setupKeyHandlers").call(mode);+ actionHandlers.get("app.shortcuts")?.();++ expect(mode.showShortcutGuide).toHaveBeenCalledTimes(1);+ });});diff --git a/packages/coding-agent/test/interactive-mode-prompt-stash.test.ts b/packages/coding-agent/test/interactive-mode-prompt-stash.test.tsindex aa8fd52dd7..5672581910 100644--- a/packages/coding-agent/test/interactive-mode-prompt-stash.test.ts+++ b/packages/coding-agent/test/interactive-mode-prompt-stash.test.ts@@ -34,6 +34,7 @@ type PromptStashHarness = {promptStash?: PromptStash;editor: FakeEditor;showStatus: Mock;+ clearShortcutGuide: Mock;};type PromptStashLiveMarkerHarness = PromptStashHarness & {@@ -43,6 +44,7 @@ type PromptStashLiveMarkerHarness = PromptStashHarness & {type ResetHarness = PromptStashLiveMarkerHarness & {chatContainer: { clear: Mock };+ shortcutGuideContainer: { clear: Mock };pendingMessagesContainer: { clear: Mock };queuedMessagesContainer: { clear: Mock };defaultEditor: FakeEditor;@@ -126,6 +128,7 @@ function createPromptStashHarness(pasteSnapshot: options.pasteSnapshot,}),showStatus: vi.fn(),+ clearShortcutGuide: vi.fn(),};Object.setPrototypeOf(harness, InteractiveMode.prototype);return harness;@@ -330,6 +333,7 @@ describe("InteractiveMode prompt stash", () => {compactionQueuedMessages: [],connectionQueue: { steering: ["old [image #2]"], followUp: [] },chatContainer: { clear: vi.fn() },+ shortcutGuideContainer: { clear: vi.fn() },pendingMessagesContainer: { clear: vi.fn() },queuedMessagesContainer: { clear: vi.fn() },pastedImages: new Map<number, unknown>([@@ -363,6 +367,7 @@ describe("InteractiveMode prompt stash", () => {compactionQueuedMessages: [],connectionQueue: { steering: [], followUp: [] },chatContainer: { clear: vi.fn() },+ shortcutGuideContainer: { clear: vi.fn() },pendingMessagesContainer: { clear: vi.fn() },queuedMessagesContainer: { clear: vi.fn() },pastedImages: new Map<number, unknown>([[1, {}]]),diff --git a/packages/coding-agent/test/interactive-mode-startup.test.ts b/packages/coding-agent/test/interactive-mode-startup.test.tsnew file mode 100644index 0000000000..d64f67c29d--- /dev/null+++ b/packages/coding-agent/test/interactive-mode-startup.test.ts@@ -0,0 +1,136 @@+import { Container, setKeybindings } from "@earendil-works/pi-tui";+import stripAnsi from "strip-ansi";+import { beforeAll, beforeEach, describe, expect, it, vi } from "vitest";+import { KeybindingsManager } from "../src/core/keybindings.js";+import { BrandSplashHeader, InteractiveMode } from "../src/modes/interactive/interactive-mode.js";+import { getMarkdownTheme, initTheme } from "../src/modes/interactive/theme/theme.js";++describe("InteractiveMode startup hints", () => {+ beforeAll(() => {+ initTheme("dark");+ });++ beforeEach(() => {+ setKeybindings(new KeybindingsManager());+ });++ function createMode(sessionHasMessages = false, returnToAgentsView = false) {+ const mode = {+ childAgentPanelMode: undefined,+ sessionHasMessages,+ options: { returnToAgentsView },+ editor: { getText: () => "" },+ connectionState: {+ model: { name: "test-model", reasoning: true },+ thinkingLevel: "high",+ },+ };+ Object.setPrototypeOf(mode, InteractiveMode.prototype);+ return mode;+ }++ it("renders compact new-chat guidance and the configured shortcut hint", () => {+ const mode = createMode();+ const metadata = Reflect.get(InteractiveMode.prototype, "getStartupMetadata").call(mode);+ const header = new BrandSplashHeader(+ "0.0.0",+ () => "test-model",+ () => "/tmp/project",+ undefined,+ {+ getExtraMetadata: () => metadata,+ getStartHint: () => 'Try "refactor @<filepath>"',+ },+ );++ const output = stripAnsi(header.render(120).join("\n"));++ expect(output).toContain("! shell · / commands");+ expect(output).toContain("@ file paths");+ expect(output).toContain("? for shortcuts");+ expect(output).toContain('Try "refactor @<filepath>"');+ });++ it("places the fresh-chat shortcut hint after the model and effort", () => {+ const mode = createMode();+ const label = Reflect.get(InteractiveMode.prototype, "getTrayLocationLabel").call(mode);++ expect(stripAnsi(label)).toBe("test-model • high ? for shortcuts");+ });++ it("places the Agents View hint before the model and fresh-chat help", () => {+ const mode = createMode(false, true);+ const label = Reflect.get(InteractiveMode.prototype, "getTrayLocationLabel").call(mode);++ expect(stripAnsi(label)).toBe("← agents view test-model • high ? for shortcuts");+ });++ it("hides startup shortcut guidance for chats with history", () => {+ const mode = createMode(true);+ const metadata = Reflect.get(InteractiveMode.prototype, "getStartupMetadata").call(mode);+ const label = Reflect.get(InteractiveMode.prototype, "getTrayLocationLabel").call(mode);++ expect(metadata).toEqual([]);+ expect(stripAnsi(label)).toBe("test-model • high");+ });++ it("keeps the question-mark shortcut guide compact", () => {+ const guide = Reflect.get(InteractiveMode.prototype, "getShortcutGuide").call(createMode());++ expect(guide).toContain("`!` shell mode · `/` commands · `@` file paths");+ expect(guide).toContain("stash prompt");+ expect(guide).toContain("`/hotkeys` full reference");+ expect(guide).not.toContain("Ctrl+Z");+ expect(guide).not.toContain("suspend");+ expect(guide).not.toContain("**Navigation**");+ expect(guide).not.toContain("**Extensions**");+ });++ it("renders question-mark shortcut help ephemerally without appending to chat history", () => {+ const shortcutGuideContainer = new Container();+ const chatContainer = new Container();+ const mode = Object.assign(createMode(), {+ shortcutGuideContainer,+ chatContainer,+ ui: { requestRender: vi.fn() },+ getMarkdownThemeWithSettings: () => getMarkdownTheme(),+ });++ Reflect.get(InteractiveMode.prototype, "showShortcutGuide").call(mode);+ Reflect.get(InteractiveMode.prototype, "showShortcutGuide").call(mode);++ expect(chatContainer.children).toHaveLength(0);+ expect(shortcutGuideContainer.children).toHaveLength(2);++ Reflect.get(InteractiveMode.prototype, "clearShortcutGuide").call(mode);++ expect(shortcutGuideContainer.children).toHaveLength(0);+ });++ it("keeps /hotkeys comprehensive without Ctrl+Z", () => {+ const guide = Reflect.get(InteractiveMode.prototype, "getHotkeysGuide").call(createMode());++ expect(guide).toContain("**Navigation**");+ expect(guide).toContain("**Editing**");+ expect(guide).toContain("**Fullscreen mode (`/fullscreen`)**");+ expect(guide).toContain("Queue follow-up message");+ expect(guide).not.toContain("Ctrl+Z");+ expect(guide).not.toContain("Suspend to background");+ });++ it("renders /hotkeys in chat history instead of the temporary guide", () => {+ const shortcutGuideContainer = new Container();+ const chatContainer = new Container();+ const mode = Object.assign(createMode(), {+ shortcutGuideContainer,+ chatContainer,+ ui: { requestRender: vi.fn() },+ getMarkdownThemeWithSettings: () => getMarkdownTheme(),+ });++ Reflect.get(InteractiveMode.prototype, "handleHotkeysCommand").call(mode);++ expect(chatContainer.children).toHaveLength(2);+ expect(shortcutGuideContainer.children).toHaveLength(0);+ });+});diff --git a/packages/coding-agent/test/interactive-mode-status.test.ts b/packages/coding-agent/test/interactive-mode-status.test.tsindex 116ff24eb3..e0197c6f6f 100644--- a/packages/coding-agent/test/interactive-mode-status.test.ts+++ b/packages/coding-agent/test/interactive-mode-status.test.ts@@ -302,6 +302,7 @@ describe("InteractiveMode.renderSessionContext", () => {type SubmitHandlerHarness = {defaultEditor: { onSubmit?: (text: string) => Promise<void> };editor: { setText: (text: string) => void; addToHistory?: (text: string) => void };+ clearShortcutGuide: () => void;showWarning: (message: string) => void;showError: (message: string) => void;isBashRunning: () => boolean;@@ -317,6 +318,7 @@ function createSubmitHandlerHarness(overrides: Partial<SubmitHandlerHarness> = {const fakeThis: SubmitHandlerHarness = {defaultEditor: {},editor: { setText: vi.fn(), addToHistory: vi.fn() },+ clearShortcutGuide: vi.fn(),showWarning: vi.fn(),showError: vi.fn(),isBashRunning: () => false,@@ -531,6 +533,7 @@ describe("InteractiveMode pending bash components", () => {const editorStub = { clearHistory: vi.fn(), setText: vi.fn() };const fakeThis = {chatContainer: new Container(),+ shortcutGuideContainer: new Container(),pendingMessagesContainer: new Container(),queuedMessagesContainer: new Container(),compactionQueuedMessages: [],@@ -688,27 +691,23 @@ describe("InteractiveMode key handlers", () => {onPasteImage?: () => void;onAction(action: string, handler: () => void): void;};- editor: { setText: ReturnType<typeof vi.fn> };ui: { onDebug?: () => void; requestRender: ReturnType<typeof vi.fn> };- clearCtrlCExitHint(options?: { render?: boolean }): void;+ handleEscape(): void;setupKeyHandlers(): void;};- test("escape clears the input bar without aborting streaming", () => {+ test("routes Escape through the repeat handler", () => {const fakeThis = Object.create(InteractiveMode.prototype) as KeyHandlerHarness;fakeThis.defaultEditor = {onAction: vi.fn(),};- fakeThis.editor = { setText: vi.fn() };fakeThis.ui = { requestRender: vi.fn() };- fakeThis.clearCtrlCExitHint = vi.fn();+ fakeThis.handleEscape = vi.fn();fakeThis.setupKeyHandlers();fakeThis.defaultEditor.onEscape?.();- expect(fakeThis.clearCtrlCExitHint).toHaveBeenCalledWith({ render: false });- expect(fakeThis.editor.setText).toHaveBeenCalledWith("");- expect(fakeThis.ui.requestRender).toHaveBeenCalledTimes(1);+ expect(fakeThis.handleEscape).toHaveBeenCalledTimes(1);});});