Merge branch 'main' into dev

This commit is contained in:
Youzini-afk
2026-04-11 21:13:50 +08:00
2 changed files with 75 additions and 0 deletions

View File

@@ -358,6 +358,11 @@ export function onMessageDeletedController(
}
export function onMessageEditedController(runtime, messageId, meta = null) {
if (runtime.isMvuExtraAnalysisGuardActive?.()) {
console.debug?.("[ST-BME] skip: mvu-extra-analysis hook=MESSAGE_EDITED");
runtime.refreshPersistedRecallMessageUi?.();
return;
}
runtime.invalidateRecallAfterHistoryMutation("消息已编辑");
runtime.scheduleHistoryMutationRecheck("message-edited", messageId, meta);
runtime.refreshPersistedRecallMessageUi?.();
@@ -414,6 +419,13 @@ export async function onGenerationAfterCommandsController(
return;
}
if (runtime.isMvuExtraAnalysisGuardActive?.()) {
console.debug?.(
"[ST-BME] skip: mvu-extra-analysis hook=GENERATION_AFTER_COMMANDS",
);
return;
}
const generationType = String(type || "normal").trim() || "normal";
const frozenInputSnapshot =
generationType === "normal"
@@ -547,6 +559,16 @@ export async function onBeforeCombinePromptsController(
};
}
if (runtime.isMvuExtraAnalysisGuardActive?.()) {
console.debug?.(
"[ST-BME] skip: mvu-extra-analysis hook=GENERATE_BEFORE_COMBINE_PROMPTS",
);
return {
skipped: true,
reason: "mvu-extra-analysis",
};
}
const frozenInputSnapshot =
runtime.consumeHostGenerationInputSnapshot?.() ||
runtime.getPendingHostGenerationInputSnapshot?.() ||

View File

@@ -764,6 +764,7 @@ let pendingAutoExtraction = {
let isHostGenerationRunning = false;
let lastHostGenerationEndedAt = 0;
let skipBeforeCombineRecallUntil = 0;
let mvuExtraAnalysisGuardUntil = 0;
let lastPreGenerationRecallKey = "";
let lastPreGenerationRecallAt = 0;
const generationRecallTransactions = new Map();
@@ -789,6 +790,7 @@ const persistedRecallPersistDiagnosticTimestamps = new Map();
const GENERATION_RECALL_TRANSACTION_TTL_MS = 15000;
const PLANNER_RECALL_HANDOFF_TTL_MS = GENERATION_RECALL_TRANSACTION_TTL_MS;
const GENERATION_RECALL_HOOK_BRIDGE_MS = 1200;
const MVU_EXTRA_ANALYSIS_GUARD_TTL_MS = 2500;
const stageNoticeHandles = {
extraction: null,
vector: null,
@@ -6688,6 +6690,54 @@ function consumeDryRunPromptPreview(now = Date.now()) {
return true;
}
function readMvuExtraAnalysisFlag() {
try {
const sameFrameMvu = globalThis?.window?.Mvu;
if (typeof sameFrameMvu?.isDuringExtraAnalysis === "function") {
return Boolean(sameFrameMvu.isDuringExtraAnalysis());
}
} catch {}
try {
const parentMvu = globalThis?.window?.parent?.Mvu;
if (typeof parentMvu?.isDuringExtraAnalysis === "function") {
return Boolean(parentMvu.isDuringExtraAnalysis());
}
} catch {}
try {
const getActivePinia =
globalThis?.window?.getActivePinia ??
globalThis?.window?.parent?.getActivePinia;
if (typeof getActivePinia === "function") {
const pinia = getActivePinia();
return Boolean(
pinia?.state?.value?.["MVU变量框架"]?.runtimes?.is_during_extra_analysis,
);
}
} catch {}
return false;
}
function isMvuExtraAnalysisGuardActive(now = Date.now()) {
if (readMvuExtraAnalysisFlag()) {
mvuExtraAnalysisGuardUntil = Math.max(
mvuExtraAnalysisGuardUntil,
now + MVU_EXTRA_ANALYSIS_GUARD_TTL_MS,
);
}
if (mvuExtraAnalysisGuardUntil <= now) {
if (mvuExtraAnalysisGuardUntil !== 0) {
mvuExtraAnalysisGuardUntil = 0;
}
return false;
}
return true;
}
function isGraphEffectivelyEmpty(graph) {
if (!graph || typeof graph !== "object") {
return true;
@@ -12642,6 +12692,7 @@ function onMessageEdited(messageId, meta = null) {
const result = onMessageEditedController(
{
invalidateRecallAfterHistoryMutation,
isMvuExtraAnalysisGuardActive,
refreshPersistedRecallMessageUi: schedulePersistedRecallMessageUiRefresh,
scheduleHistoryMutationRecheck,
},
@@ -12739,6 +12790,7 @@ async function onGenerationAfterCommands(type, params = {}, dryRun = false) {
getContext,
getGenerationRecallHookStateFromResult,
getGenerationRecallTransactionResult,
isMvuExtraAnalysisGuardActive,
markGenerationRecallTransactionHookState,
resolveGenerationRecallDeliveryMode,
runRecall,
@@ -12763,6 +12815,7 @@ async function onBeforeCombinePrompts(promptData = null) {
getContext,
getGenerationRecallHookStateFromResult,
getGenerationRecallTransactionResult,
isMvuExtraAnalysisGuardActive,
markGenerationRecallTransactionHookState,
resolveGenerationRecallDeliveryMode,
runRecall,