From 665c547ee370be198c6739743333009066193e98 Mon Sep 17 00:00:00 2001 From: Youzini-afk <13153778771cx@gmail.com> Date: Mon, 6 Apr 2026 19:37:27 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20Recall=20Card=20=E8=B0=83=E8=AF=95?= =?UTF-8?q?=E5=9F=8B=E7=82=B9=E5=8F=97=E9=9D=A2=E6=9D=BF=E3=80=8C=E5=90=AF?= =?UTF-8?q?=E7=94=A8=E8=B0=83=E8=AF=95=E6=97=A5=E5=BF=97=E3=80=8D=E6=8E=A7?= =?UTF-8?q?=E5=88=B6=EF=BC=9B=E6=8E=A7=E5=88=B6=E5=8F=B0=E8=8A=82=E6=B5=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Made-with: Cursor --- index.js | 41 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 36 insertions(+), 5 deletions(-) diff --git a/index.js b/index.js index 2690127..589cd5d 100644 --- a/index.js +++ b/index.js @@ -75,6 +75,7 @@ import { import { debugDebug, debugLog, + isDebugLoggingEnabled, } from "./debug-logging.js"; import { extractMemories, @@ -588,18 +589,19 @@ const PERSISTED_RECALL_UI_REFRESH_RETRY_DELAYS_MS = [ const BME_DEBUG_RECALL_CARD_UI = "ST-BME|DBG|recall-card-ui"; const BME_DEBUG_RECALL_CARD_UI_INGEST = "http://127.0.0.1:7433/ingest/799bfe5d-077f-41ac-bcda-da9f93fe5a85"; +const BME_DEBUG_RECALL_CARD_UI_CONSOLE_THROTTLE_MS = 2500; +let bmeRecallCardUiConsolePending = 0; +let bmeRecallCardUiConsoleLastFlush = 0; function bmePostRecallCardUiDebug(partial) { + if (!isDebugLoggingEnabled(getSettings())) { + return; + } const payload = { bmeDbgTag: BME_DEBUG_RECALL_CARD_UI, sessionId: "b6ba57", ...partial, timestamp: Date.now(), }; - try { - if (typeof console?.info === "function") { - console.info(BME_DEBUG_RECALL_CARD_UI, payload.message, payload); - } - } catch (_) {} fetch(BME_DEBUG_RECALL_CARD_UI_INGEST, { method: "POST", headers: { @@ -608,6 +610,35 @@ function bmePostRecallCardUiDebug(partial) { }, body: JSON.stringify(payload), }).catch(() => {}); + + try { + if (typeof console?.info !== "function") return; + const verbose = + typeof globalThis !== "undefined" && + globalThis.__ST_BME_RECALL_CARD_UI_VERBOSE_CONSOLE === true; + if (verbose) { + console.info(BME_DEBUG_RECALL_CARD_UI, payload.message, payload); + return; + } + bmeRecallCardUiConsolePending += 1; + const now = Date.now(); + if ( + now - bmeRecallCardUiConsoleLastFlush < + BME_DEBUG_RECALL_CARD_UI_CONSOLE_THROTTLE_MS + ) { + return; + } + const batched = bmeRecallCardUiConsolePending; + bmeRecallCardUiConsolePending = 0; + bmeRecallCardUiConsoleLastFlush = now; + console.info( + BME_DEBUG_RECALL_CARD_UI, + partial.message, + partial.location, + partial.data, + batched > 1 ? `(×${batched})` : "", + ); + } catch (_) {} } const PERSISTED_RECALL_UI_DIAGNOSTIC_THROTTLE_MS = 1500; const persistedRecallUiDiagnosticTimestamps = new Map();