fix(history): bulk delete + clear-all now persist to SQLite
The Phase 9 bulk-delete path passed UUID strings to deleteFromHistory(index),
which expected an integer; JS coerced the string to NaN and splice(NaN, 1)
collapsed to splice(0, 1), so bulk-delete silently removed the first N visible
rows instead of the selected ones, then fired delete_transcript against the
wrong IDs.
Clear-all called saveHistory(), which was a no-op stub left over from the
same incomplete-refactor pattern that produced the manualTags persistence bug
fixed in 7eb52d9. The in-memory array was emptied, but SQLite still held
every transcript, so they reappeared on next loadHistory().
- Add deleteFromHistoryById(id) next to the index-keyed deleteFromHistory.
- bulkDelete now calls deleteFromHistoryById.
- clearAll now awaits an explicit per-id delete loop and surfaces a toast on
partial failure.
- Remove the saveHistory() stub and its sole caller's import.
https://claude.ai/code/session_0189xUb6ie6t9qHkzatGZ9Rb
This commit is contained in:
@@ -223,8 +223,6 @@ if (typeof window !== "undefined" && hasTauriRuntime()) {
|
||||
loadHistory().catch(() => {});
|
||||
}
|
||||
|
||||
export function saveHistory() {}
|
||||
|
||||
export async function addToHistory(entry: TranscriptWriteEntry) {
|
||||
const normalised = normaliseTranscriptEntry(entry);
|
||||
history.unshift(normalised);
|
||||
@@ -323,6 +321,12 @@ export function deleteFromHistory(index: number) {
|
||||
.catch((err) => console.warn("deleteFromHistory: SQLite delete failed", err));
|
||||
}
|
||||
|
||||
export function deleteFromHistoryById(id: string) {
|
||||
const idx = history.findIndex((entry) => String(entry.id) === String(id));
|
||||
if (idx === -1) return;
|
||||
deleteFromHistory(idx);
|
||||
}
|
||||
|
||||
export const tasks = $state<TaskEntry[]>([]);
|
||||
|
||||
function mapTaskRow(row: TaskDto): TaskEntry {
|
||||
|
||||
Reference in New Issue
Block a user