Skip to content

Commit 1ebf158

Browse files
Apply PR #11710: feat: Add the ability to include cleared prompts in the history, toggled by a KV-persisted command palette item (resolves #11489)
2 parents 2d15d89 + 571ae48 commit 1ebf158

3 files changed

Lines changed: 14 additions & 1 deletion

File tree

packages/opencode/src/cli/cmd/tui/app.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -929,6 +929,17 @@ function App(props: { onSnapshot?: () => Promise<string[]> }) {
929929
dialog.clear()
930930
},
931931
},
932+
{
933+
name: "app.toggle.clear_prompt_history",
934+
title: kv.get("clear_prompt_save_history", false)
935+
? "Don't include cleared prompts in history"
936+
: "Include cleared prompts in history",
937+
category: "System",
938+
run: () => {
939+
kv.set("clear_prompt_save_history", !kv.get("clear_prompt_save_history", false))
940+
dialog.clear()
941+
},
942+
},
932943
].map((command) => ({
933944
namespace: "palette",
934945
...command,

packages/opencode/src/cli/cmd/tui/component/prompt/history.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ export const { use: usePromptHistory, provider: PromptHistoryProvider } = create
8787
return store.history.at(store.index)
8888
},
8989
append(item: PromptInfo) {
90+
if (store.history.at(-1)?.input === item.input) return
9091
const entry = structuredClone(unwrap(item))
9192
if (isDuplicateEntry(store.history.at(-1), entry)) {
9293
setStore("index", 0)

packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1372,7 +1372,8 @@ export function Prompt(props: PromptProps) {
13721372
}
13731373

13741374
function clearPrompt() {
1375-
if (store.prompt.input.trim().length >= DRAFT_RETENTION_MIN_CHARS || store.prompt.parts.length > 0) {
1375+
const shouldSave = store.prompt.input.trim().length >= DRAFT_RETENTION_MIN_CHARS || store.prompt.parts.length > 0
1376+
if (shouldSave || kv.get("clear_prompt_save_history", false)) {
13761377
history.append({
13771378
...store.prompt,
13781379
mode: store.mode,

0 commit comments

Comments
 (0)