Skip to content

Commit 337021e

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 4814ab3 + a9b2743 commit 337021e

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
@@ -938,6 +938,17 @@ function App(props: { onSnapshot?: () => Promise<string[]> }) {
938938
dialog.clear()
939939
},
940940
},
941+
{
942+
name: "app.toggle.clear_prompt_history",
943+
title: kv.get("clear_prompt_save_history", false)
944+
? "Don't include cleared prompts in history"
945+
: "Include cleared prompts in history",
946+
category: "System",
947+
run: () => {
948+
kv.set("clear_prompt_save_history", !kv.get("clear_prompt_save_history", false))
949+
dialog.clear()
950+
},
951+
},
941952
].map((command) => ({
942953
namespace: "palette",
943954
...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
@@ -1280,7 +1280,8 @@ export function Prompt(props: PromptProps) {
12801280
}
12811281

12821282
function clearPrompt() {
1283-
if (store.prompt.input.trim().length >= DRAFT_RETENTION_MIN_CHARS || store.prompt.parts.length > 0) {
1283+
const shouldSave = store.prompt.input.trim().length >= DRAFT_RETENTION_MIN_CHARS || store.prompt.parts.length > 0
1284+
if (shouldSave || kv.get("clear_prompt_save_history", false)) {
12841285
history.append({
12851286
...store.prompt,
12861287
mode: store.mode,

0 commit comments

Comments
 (0)