Skip to content

Commit f0d4c1e

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 66d409d + 571ae48 commit f0d4c1e

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
@@ -794,6 +794,17 @@ function App(props: { onSnapshot?: () => Promise<string[]> }) {
794794
dialog.clear()
795795
},
796796
},
797+
{
798+
name: "app.toggle.clear_prompt_history",
799+
title: kv.get("clear_prompt_save_history", false)
800+
? "Don't include cleared prompts in history"
801+
: "Include cleared prompts in history",
802+
category: "System",
803+
run: () => {
804+
kv.set("clear_prompt_save_history", !kv.get("clear_prompt_save_history", false))
805+
dialog.clear()
806+
},
807+
},
797808
].map((command) => ({
798809
namespace: "palette",
799810
...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
@@ -1367,7 +1367,8 @@ export function Prompt(props: PromptProps) {
13671367
}
13681368

13691369
function clearPrompt() {
1370-
if (store.prompt.input.trim().length >= DRAFT_RETENTION_MIN_CHARS || store.prompt.parts.length > 0) {
1370+
const shouldSave = store.prompt.input.trim().length >= DRAFT_RETENTION_MIN_CHARS || store.prompt.parts.length > 0
1371+
if (shouldSave || kv.get("clear_prompt_save_history", false)) {
13711372
history.append({
13721373
...store.prompt,
13731374
mode: store.mode,

0 commit comments

Comments
 (0)