Skip to content

Commit 9c8d351

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 ce19c05 + 97a9457 commit 9c8d351

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
@@ -804,6 +804,15 @@ function App(props: { onSnapshot?: () => Promise<string[]> }) {
804804
dialog.clear()
805805
},
806806
},
807+
{
808+
title: kv.get("clear_prompt_save_history", false) ? "Don't include cleared prompts in history" : "Include cleared prompts in history",
809+
value: "app.toggle.clear_prompt_history",
810+
category: "System",
811+
onSelect: (dialog) => {
812+
kv.set("clear_prompt_save_history", !kv.get("clear_prompt_save_history", false))
813+
dialog.clear()
814+
},
815+
},
807816
])
808817

809818
sdk.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
@@ -936,6 +936,12 @@ export function Prompt(props: PromptProps) {
936936
// If no image, let the default paste behavior continue
937937
}
938938
if (keybind.match("input_clear", e) && store.prompt.input !== "") {
939+
if (kv.get("clear_prompt_save_history", false)) {
940+
history.append({
941+
...store.prompt,
942+
mode: store.mode,
943+
})
944+
}
939945
input.clear()
940946
input.extmarks.clear()
941947
setStore("prompt", {

0 commit comments

Comments
 (0)