fix: preserve slash command text in editor history when plan/goal mode is already active

When /plan <text> or /goal set <text> 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
This commit is contained in:
Yahya Saqban
2026-05-22 23:39:02 +03:00
parent 3b072a10b9
commit ec5accff11
@@ -72,7 +72,12 @@ const BUILTIN_SLASH_COMMAND_REGISTRY: ReadonlyArray<SlashCommandSpec> = [
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<SlashCommandSpec> = [
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("");
},
},