Skip to content

Commit 73cf060

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 2719063 + 97a9457 commit 73cf060

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
@@ -788,6 +788,15 @@ function App(props: { onSnapshot?: () => Promise<string[]> }) {
788788
dialog.clear()
789789
},
790790
},
791+
{
792+
title: kv.get("clear_prompt_save_history", false) ? "Don't include cleared prompts in history" : "Include cleared prompts in history",
793+
value: "app.toggle.clear_prompt_history",
794+
category: "System",
795+
onSelect: (dialog) => {
796+
kv.set("clear_prompt_save_history", !kv.get("clear_prompt_save_history", false))
797+
dialog.clear()
798+
},
799+
},
791800
])
792801

793802
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
@@ -938,6 +938,12 @@ export function Prompt(props: PromptProps) {
938938
// If no image, let the default paste behavior continue
939939
}
940940
if (keybind.match("input_clear", e) && store.prompt.input !== "") {
941+
if (kv.get("clear_prompt_save_history", false)) {
942+
history.append({
943+
...store.prompt,
944+
mode: store.mode,
945+
})
946+
}
941947
input.clear()
942948
input.extmarks.clear()
943949
setStore("prompt", {

0 commit comments

Comments
 (0)