Skip to content

Commit b4c4c9c

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 3e8abac + 731c1e5 commit b4c4c9c

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
@@ -731,6 +731,15 @@ function App(props: { onSnapshot?: () => Promise<string[]> }) {
731731
dialog.clear()
732732
},
733733
},
734+
{
735+
title: kv.get("clear_prompt_save_history", false) ? "Don't include cleared prompts in history" : "Include cleared prompts in history",
736+
value: "app.toggle.clear_prompt_history",
737+
category: "System",
738+
onSelect: (dialog) => {
739+
kv.set("clear_prompt_save_history", !kv.get("clear_prompt_save_history", false))
740+
dialog.clear()
741+
},
742+
},
734743
])
735744

736745
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
@@ -1023,6 +1023,12 @@ export function Prompt(props: PromptProps) {
10231023
// If no image, let the default paste behavior continue
10241024
}
10251025
if (keybind.match("input_clear", e) && store.prompt.input !== "") {
1026+
if (kv.get("clear_prompt_save_history", false)) {
1027+
history.append({
1028+
...store.prompt,
1029+
mode: store.mode,
1030+
})
1031+
}
10261032
input.clear()
10271033
input.extmarks.clear()
10281034
setStore("prompt", {

0 commit comments

Comments
 (0)