Skip to content

Commit f6aeace

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 b2baddc + 4e8020b commit f6aeace

3 files changed

Lines changed: 17 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
@@ -770,6 +770,17 @@ function App(props: { onSnapshot?: () => Promise<string[]> }) {
770770
dialog.clear()
771771
},
772772
},
773+
{
774+
name: "app.toggle.clear_prompt_history",
775+
title: kv.get("clear_prompt_save_history", false)
776+
? "Don't include cleared prompts in history"
777+
: "Include cleared prompts in history",
778+
category: "System",
779+
run: () => {
780+
kv.set("clear_prompt_save_history", !kv.get("clear_prompt_save_history", false))
781+
dialog.clear()
782+
},
783+
},
773784
].map((command) => ({
774785
namespace: "palette",
775786
...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
@@ -82,6 +82,7 @@ export const { use: usePromptHistory, provider: PromptHistoryProvider } = create
8282
return store.history.at(store.index)
8383
},
8484
append(item: PromptInfo) {
85+
if (store.history.at(-1)?.input === item.input) return
8586
const entry = structuredClone(unwrap(item))
8687
let trimmed = false
8788
setStore(

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1360,7 +1360,11 @@ export function Prompt(props: PromptProps) {
13601360
}
13611361

13621362
function clearPrompt() {
1363-
if (store.prompt.input.trim().length >= DRAFT_RETENTION_MIN_CHARS || store.prompt.parts.length > 0) {
1363+
if (
1364+
kv.get("clear_prompt_save_history", false) ||
1365+
store.prompt.input.trim().length >= DRAFT_RETENTION_MIN_CHARS ||
1366+
store.prompt.parts.length > 0
1367+
) {
13641368
history.append({
13651369
...store.prompt,
13661370
mode: store.mode,

0 commit comments

Comments
 (0)