chore(watch-history): instrument defaultRemoveHandler (the real delete path)

Diagnostics revealed the delete does NOT go through watchHistoryController
(app.watchHistoryController is undefined — it lives on modalCoordinator, not the
app root), so the renderer's `remove` handler always falls through to the
uninstrumented defaultRemoveHandler. That's why no [watch-history:remove] logs
appeared even though a refresh fired. Instrument defaultRemoveHandler to log the
published (reduced) item count + snapshot/list-update results, so we can confirm
whether the publish reduces correctly and isolate the read/cache layer.

Flag-gated; no behavior change.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
This commit is contained in:
thePR0M3TH3ANandClaude Opus 4.8 committed 2026-06-20 18:27:42 -04:00
1 parent 4a2ba2cc2f
commit eeacf592dd
1 file changed
+20 -2
+20 -2
View File
@@ -327,20 +327,38 @@ async function defaultRemoveHandler({
})
.filter(Boolean)
: [];
logWatchHistoryDebug("watch-history:remove", "info", "defaultRemoveHandler", {
actor,
sanitizedCount: sanitized.length,
values: sanitized.map((p) => p?.value).slice(0, 20),
hasSnapshot: typeof snapshot === "function",
});
if (typeof snapshot === "function") {
// Removal replaces the list — without this the snapshot would merge the
// removed item back from cache and the deletion would have no effect.
await snapshot(sanitized, { actor, reason, replace: true });
const snapResult = await snapshot(sanitized, { actor, reason, replace: true });
logWatchHistoryDebug("watch-history:remove", "info", "defaultRemoveHandler snapshot", {
ok: snapResult?.ok,
empty: snapResult?.empty,
skipped: snapResult?.skipped,
});
}
try {
if (typeof updateWatchHistoryList === "function") {
await updateWatchHistoryList(sanitized, {
const updateResult = await updateWatchHistoryList(sanitized, {
actorPubkey: actor,
replace: true,
source: reason
});
logWatchHistoryDebug("watch-history:remove", "info", "defaultRemoveHandler list update", {
ok: updateResult?.ok,
finalItemCount: updateResult?.items?.length,
});
}
} catch (error) {
logWatchHistoryDebug("watch-history:remove", "warn", "defaultRemoveHandler failed", {
error: error?.message || String(error),
});
if (isDevEnv) {
userLogger.warn("[historyView] Failed to update watch history list:", error);
}