Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import path from "path"
import { Global } from "@/global"
import { Filesystem } from "@/util"
import { Filesystem, Log } from "@/util"
import { onMount } from "solid-js"
import { createStore } from "solid-js/store"
import { createSimpleContext } from "../../context/helper"
Expand Down Expand Up @@ -54,7 +54,7 @@ export const { use: useFrecency, provider: FrecencyProvider } = createSimpleCont

if (sorted.length > 0) {
const content = sorted.map((entry) => JSON.stringify(entry)).join("\n") + "\n"
writeFile(frecencyPath, content).catch(() => {})
writeFile(frecencyPath, content).catch((e) => Log.Default.debug("frecency write failed", { error: String(e) }))
}
})

Expand All @@ -77,7 +77,7 @@ export const { use: useFrecency, provider: FrecencyProvider } = createSimpleCont
.slice(0, MAX_FRECENCY_ENTRIES)
setStore("data", Object.fromEntries(sorted))
const content = sorted.map(([path, entry]) => JSON.stringify({ path, ...entry })).join("\n") + "\n"
writeFile(frecencyPath, content).catch(() => {})
writeFile(frecencyPath, content).catch((e) => Log.Default.debug("frecency trim failed", { error: String(e) }))
}
}

Expand Down
12 changes: 6 additions & 6 deletions packages/opencode/src/cli/cmd/tui/component/prompt/stash.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import path from "path"
import { Global } from "@/global"
import { Filesystem } from "@/util"
import { Filesystem, Log } from "@/util"
import { onMount } from "solid-js"
import { createStore, produce, unwrap } from "solid-js/store"
import { createSimpleContext } from "../../context/helper"
Expand Down Expand Up @@ -39,7 +39,7 @@ export const { use: usePromptStash, provider: PromptStashProvider } = createSimp
// Rewrite file with only valid entries to self-heal corruption
if (lines.length > 0) {
const content = lines.map((line) => JSON.stringify(line)).join("\n") + "\n"
writeFile(stashPath, content).catch(() => {})
writeFile(stashPath, content).catch((e) => Log.Default.debug("stash file write failed", { error: String(e) }))
}
})

Expand All @@ -66,11 +66,11 @@ export const { use: usePromptStash, provider: PromptStashProvider } = createSimp

if (trimmed) {
const content = store.entries.map((line) => JSON.stringify(line)).join("\n") + "\n"
writeFile(stashPath, content).catch(() => {})
writeFile(stashPath, content).catch((e) => Log.Default.debug("stash file write failed", { error: String(e) }))
return
}

appendFile(stashPath, JSON.stringify(stash) + "\n").catch(() => {})
appendFile(stashPath, JSON.stringify(stash) + "\n").catch((e) => Log.Default.debug("stash file write failed", { error: String(e) }))
},
pop() {
if (store.entries.length === 0) return undefined
Expand All @@ -82,7 +82,7 @@ export const { use: usePromptStash, provider: PromptStashProvider } = createSimp
)
const content =
store.entries.length > 0 ? store.entries.map((line) => JSON.stringify(line)).join("\n") + "\n" : ""
writeFile(stashPath, content).catch(() => {})
writeFile(stashPath, content).catch((e) => Log.Default.debug("stash file write failed", { error: String(e) }))
return entry
},
remove(index: number) {
Expand All @@ -94,7 +94,7 @@ export const { use: usePromptStash, provider: PromptStashProvider } = createSimp
)
const content =
store.entries.length > 0 ? store.entries.map((line) => JSON.stringify(line)).join("\n") + "\n" : ""
writeFile(stashPath, content).catch(() => {})
writeFile(stashPath, content).catch((e) => Log.Default.debug("stash file write failed", { error: String(e) }))
},
}
},
Expand Down