diff --git a/packages/opencode/src/cli/cmd/tui/app.tsx b/packages/opencode/src/cli/cmd/tui/app.tsx index e326a39b59..0b5ef2b005 100644 --- a/packages/opencode/src/cli/cmd/tui/app.tsx +++ b/packages/opencode/src/cli/cmd/tui/app.tsx @@ -794,6 +794,17 @@ function App(props: { onSnapshot?: () => Promise }) { dialog.clear() }, }, + { + name: "app.toggle.clear_prompt_history", + title: kv.get("clear_prompt_save_history", false) + ? "Don't include cleared prompts in history" + : "Include cleared prompts in history", + category: "System", + run: () => { + kv.set("clear_prompt_save_history", !kv.get("clear_prompt_save_history", false)) + dialog.clear() + }, + }, ].map((command) => ({ namespace: "palette", ...command, diff --git a/packages/opencode/src/cli/cmd/tui/component/prompt/history.tsx b/packages/opencode/src/cli/cmd/tui/component/prompt/history.tsx index 5b7be5d32b..da5318fd3b 100644 --- a/packages/opencode/src/cli/cmd/tui/component/prompt/history.tsx +++ b/packages/opencode/src/cli/cmd/tui/component/prompt/history.tsx @@ -87,6 +87,7 @@ export const { use: usePromptHistory, provider: PromptHistoryProvider } = create return store.history.at(store.index) }, append(item: PromptInfo) { + if (store.history.at(-1)?.input === item.input) return const entry = structuredClone(unwrap(item)) if (isDuplicateEntry(store.history.at(-1), entry)) { setStore("index", 0) diff --git a/packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx b/packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx index e4907dcc27..a83eeae184 100644 --- a/packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx +++ b/packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx @@ -1367,7 +1367,8 @@ export function Prompt(props: PromptProps) { } function clearPrompt() { - if (store.prompt.input.trim().length >= DRAFT_RETENTION_MIN_CHARS || store.prompt.parts.length > 0) { + const shouldSave = store.prompt.input.trim().length >= DRAFT_RETENTION_MIN_CHARS || store.prompt.parts.length > 0 + if (shouldSave || kv.get("clear_prompt_save_history", false)) { history.append({ ...store.prompt, mode: store.mode,