Skip to content

Commit 4fd693f

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 465c83c + 4e8020b commit 4fd693f

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
@@ -779,6 +779,15 @@ function App(props: { onSnapshot?: () => Promise<string[]> }) {
779779
dialog.clear()
780780
},
781781
},
782+
{
783+
title: kv.get("clear_prompt_save_history", false) ? "Don't include cleared prompts in history" : "Include cleared prompts in history",
784+
value: "app.toggle.clear_prompt_history",
785+
category: "System",
786+
onSelect: (dialog) => {
787+
kv.set("clear_prompt_save_history", !kv.get("clear_prompt_save_history", false))
788+
dialog.clear()
789+
},
790+
},
782791
])
783792

784793
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
@@ -1261,6 +1261,12 @@ export function Prompt(props: PromptProps) {
12611261
// If no image, let the default paste behavior continue
12621262
}
12631263
if (keybind.match("input_clear", e) && store.prompt.input !== "") {
1264+
if (kv.get("clear_prompt_save_history", false)) {
1265+
history.append({
1266+
...store.prompt,
1267+
mode: store.mode,
1268+
})
1269+
}
12641270
input.clear()
12651271
input.extmarks.clear()
12661272
setStore("prompt", {

0 commit comments

Comments
 (0)