From eeacf592dd399d0df2da268e1aee0751ec2d647f Mon Sep 17 00:00:00 2001 From: thePR0M3TH3AN <53631862+PR0M3TH3AN@users.noreply.github.com> Date: Sat, 20 Jun 2026 18:27:42 -0400 Subject: [PATCH] chore(watch-history): instrument defaultRemoveHandler (the real delete path) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- js/historyView.js | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/js/historyView.js b/js/historyView.js index 79840982..444f7ff4 100644 --- a/js/historyView.js +++ b/js/historyView.js @@ -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); }