From ec5accff11b63ee130d9b640d31b8a429da585be Mon Sep 17 00:00:00 2001 From: Yahya Saqban Date: Fri, 22 May 2026 23:39:02 +0300 Subject: [PATCH] fix: preserve slash command text in editor history when plan/goal mode is already active MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When /plan or /goal set is typed while plan/goal mode is already active, the handler shows a warning and clears the editor, but the typed text was silently discarded — the user could not recover it with Up Arrow. Fix: save the text to editor history before clearing, so it remains recoverable via input history. Fixes #1287 --- .../src/slash-commands/builtin-registry.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/packages/coding-agent/src/slash-commands/builtin-registry.ts b/packages/coding-agent/src/slash-commands/builtin-registry.ts index 62d827fb1..1f9e4c9df 100644 --- a/packages/coding-agent/src/slash-commands/builtin-registry.ts +++ b/packages/coding-agent/src/slash-commands/builtin-registry.ts @@ -72,7 +72,12 @@ const BUILTIN_SLASH_COMMAND_REGISTRY: ReadonlyArray = [ inlineHint: "[prompt]", allowArgs: true, handleTui: async (command, runtime) => { + const hadArgs = !!command.args; await runtime.ctx.handlePlanModeCommand(command.args || undefined); + if (hadArgs && runtime.ctx.planModeEnabled) { + // plan was already active — preserve the typed command in input history + runtime.ctx.editor.addToHistory(command.text); + } runtime.ctx.editor.setText(""); }, }, @@ -90,7 +95,12 @@ const BUILTIN_SLASH_COMMAND_REGISTRY: ReadonlyArray = [ inlineHint: "[objective]", allowArgs: true, handleTui: async (command, runtime) => { + const hadArgs = !!command.args; await runtime.ctx.handleGoalModeCommand(command.args || undefined); + if (hadArgs && runtime.ctx.goalModeEnabled) { + // goal was already active — preserve the typed command in input history + runtime.ctx.editor.addToHistory(command.text); + } runtime.ctx.editor.setText(""); }, },