chore: 移除 Recall Card 本地 ingest 端口调试埋点

Made-with: Cursor
This commit is contained in:
Youzini-afk
2026-04-06 19:46:22 +08:00
parent f42295fe80
commit a0c706e410

View File

@@ -75,7 +75,6 @@ import {
import {
debugDebug,
debugLog,
isDebugLoggingEnabled,
} from "./debug-logging.js";
import {
extractMemories,
@@ -585,61 +584,6 @@ const PERSISTED_RECALL_UI_REFRESH_RETRY_DELAYS_MS = [
3000,
4200,
];
/** Ingest / NDJSON搜索此固定串可只看 Recall Card UI 调试行 */
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(),
};
fetch(BME_DEBUG_RECALL_CARD_UI_INGEST, {
method: "POST",
headers: {
"Content-Type": "application/json",
"X-Debug-Session-Id": "b6ba57",
},
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();
const persistedRecallPersistDiagnosticTimestamps = new Map();
@@ -1847,9 +1791,6 @@ function ensurePersistedRecallRecordForGeneration({
},
);
// #region agent log
{bmePostRecallCardUiDebug({location:'index.js:ensurePersistedRecallRecordForGeneration',message:`${BME_DEBUG_RECALL_CARD_UI} target resolved`,data:{targetUserMessageIndex,chatLen:chat.length,isUser:chat[targetUserMessageIndex]?.is_user,generationType,hookName:String(hookName||''),injectionTextLen:injectionText?.length||0}});}
// #endregion
if (
!Number.isFinite(targetUserMessageIndex) ||
!chat[targetUserMessageIndex]?.is_user
@@ -2606,9 +2547,6 @@ function refreshPersistedRecallMessageUi() {
skippedNonUserIndices: [],
};
// #region agent log
{const _latestUserIdx=chat.reduce((a,m,i)=>m?.is_user?i:a,-1);const _domKeys=[...messageElementMap.keys()];const _hasRecord=_latestUserIdx>=0&&!!readPersistedRecallFromUserMessage(chat,_latestUserIdx);const _hasDom=_latestUserIdx>=0&&messageElementMap.has(_latestUserIdx);bmePostRecallCardUiDebug({location:'index.js:refreshPersistedRecallMessageUi:loop-start',message:`${BME_DEBUG_RECALL_CARD_UI} refresh loop entry`,data:{chatLen:chat.length,domElementCount:_domKeys.length,domKeys:_domKeys.slice(-6),latestUserIdx:_latestUserIdx,hasRecordForLatest:_hasRecord,hasDomForLatest:_hasDom}});}
// #endregion
for (let messageIndex = 0; messageIndex < chat.length; messageIndex++) {
const message = chat[messageIndex];
const messageElement = messageElementMap.get(messageIndex) || null;
@@ -2640,9 +2578,6 @@ function refreshPersistedRecallMessageUi() {
}
const record = readPersistedRecallFromUserMessage(chat, messageIndex);
// #region agent log
if(message?.is_user){const _isLatestUser=messageIndex===chat.reduce((a,m,i)=>m?.is_user?i:a,-1);if(_isLatestUser){bmePostRecallCardUiDebug({location:'index.js:refreshPersistedRecallMessageUi:latest-user-check',message:`${BME_DEBUG_RECALL_CARD_UI} latest user msg detail`,data:{messageIndex,hasRecord:!!record?.injectionText,hasDom:!!messageElement,hasExistingCard:!!existingCard,domMesid:messageElement?.getAttribute?.('mesid'),domDataMesid:messageElement?.getAttribute?.('data-mesid'),domClasses:messageElement?.className?.slice(0,80)||''}});}}
// #endregion
if (!record?.injectionText) {
if (messageElement) {
restoreRecallCardUserInputDisplay(messageElement);
@@ -2710,9 +2645,6 @@ function refreshPersistedRecallMessageUi() {
recallCardUserInputDisplayMode,
);
summary.renderedCount += 1;
// #region agent log
{const _isLatestUser2=messageIndex===chat.reduce((a,m,i)=>m?.is_user?i:a,-1);if(_isLatestUser2){bmePostRecallCardUiDebug({location:'index.js:refreshPersistedRecallMessageUi:card-mounted',message:`${BME_DEBUG_RECALL_CARD_UI} card mounted for latest user`,data:{messageIndex,hadExistingCard:!!currentCard,cardInDom:!!messageElement.querySelector('.bme-recall-card')}});}}
// #endregion
}
summary.status = summarizePersistedRecallRefreshStatus(summary);
@@ -2729,9 +2661,6 @@ function refreshPersistedRecallMessageUi() {
`rendered:${summary.renderedCount}`,
);
}
// #region agent log
bmePostRecallCardUiDebug({location:'index.js:refreshPersistedRecallMessageUi:summary',message:`${BME_DEBUG_RECALL_CARD_UI} refresh complete`,data:{status:summary.status,renderedCount:summary.renderedCount,persistedRecordCount:summary.persistedRecordCount,waitingDom:summary.waitingMessageIndices,anchorFail:summary.anchorFailureIndices}});
// #endregion
return summary;
}
@@ -2823,9 +2752,6 @@ function armPersistedRecallMessageUiObserver(sessionId, runAttempt) {
}
function schedulePersistedRecallMessageUiRefresh(delayMs = 0) {
// #region agent log
{const _prevSession=persistedRecallUiRefreshSession;const _caller=new Error().stack?.split('\n')?.[2]?.trim()?.slice(0,120)||'';bmePostRecallCardUiDebug({location:'index.js:schedulePersistedRecallMessageUiRefresh',message:`${BME_DEBUG_RECALL_CARD_UI} schedule refresh called`,data:{delayMs,prevSession:_prevSession,nextSession:_prevSession+1,caller:_caller}});}
// #endregion
clearTimeout(persistedRecallUiRefreshTimer);
clearPersistedRecallMessageUiObserver();