Skip to content

Commit d4d82c0

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 91bd295 + 09e4e5a commit d4d82c0

3 files changed

Lines changed: 16 additions & 0 deletions

File tree

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -758,6 +758,15 @@ function App(props: { onSnapshot?: () => Promise<string[]> }) {
758758
dialog.clear()
759759
},
760760
},
761+
{
762+
title: kv.get("clear_prompt_save_history", false) ? "Don't include cleared prompts in history" : "Include cleared prompts in history",
763+
value: "app.toggle.clear_prompt_history",
764+
category: "System",
765+
onSelect: (dialog) => {
766+
kv.set("clear_prompt_save_history", !kv.get("clear_prompt_save_history", false))
767+
dialog.clear()
768+
},
769+
},
761770
])
762771

763772
event.on(TuiEvent.CommandExecute.type, (evt) => {

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: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1082,6 +1082,12 @@ export function Prompt(props: PromptProps) {
10821082
// If no image, let the default paste behavior continue
10831083
}
10841084
if (keybind.match("input_clear", e) && store.prompt.input !== "") {
1085+
if (kv.get("clear_prompt_save_history", false)) {
1086+
history.append({
1087+
...store.prompt,
1088+
mode: store.mode,
1089+
})
1090+
}
10851091
input.clear()
10861092
input.extmarks.clear()
10871093
setStore("prompt", {

0 commit comments

Comments
 (0)