fix: restore before-combine recall interception provisional binding

This commit is contained in:
Youzini-afk
2026-03-31 13:55:26 +08:00
parent 4925810064
commit 4c58121cce
2 changed files with 83 additions and 13 deletions

View File

@@ -4751,6 +4751,22 @@ function freezeGenerationRecallOptionsForTransaction(
).trim() || "normal";
const normalizedGenerationType = optionGenerationType;
const overrideUserMessage = normalizeRecallInputText(
recallOptions?.overrideUserMessage || recallOptions?.userMessage || "",
);
const source =
String(recallOptions?.overrideSource || recallOptions?.source || "").trim() ||
(normalizeGenerationRecallTransactionType(normalizedGenerationType) === "normal"
? "chat-tail-user"
: "chat-last-user");
const sourceLabel =
String(
recallOptions?.overrideSourceLabel ||
recallOptions?.sourceLabel ||
getRecallUserMessageSourceLabel(source),
).trim() || getRecallUserMessageSourceLabel(source);
let targetUserMessageIndex = Number.isFinite(recallOptions?.targetUserMessageIndex)
? Math.floor(Number(recallOptions.targetUserMessageIndex))
: resolveGenerationTargetUserMessageIndex(chat, {
@@ -4758,6 +4774,21 @@ function freezeGenerationRecallOptionsForTransaction(
});
if (!Number.isFinite(targetUserMessageIndex)) {
if (
normalizeGenerationRecallTransactionType(normalizedGenerationType) === "normal" &&
overrideUserMessage
) {
return {
generationType: normalizedGenerationType,
targetUserMessageIndex: null,
overrideUserMessage,
overrideSource: source,
overrideSourceLabel: sourceLabel,
includeSyntheticUserMessage: Boolean(
recallOptions?.includeSyntheticUserMessage,
),
};
}
return null;
}
targetUserMessageIndex = Math.floor(targetUserMessageIndex);
@@ -4777,18 +4808,6 @@ function freezeGenerationRecallOptionsForTransaction(
return null;
}
const source =
String(recallOptions?.overrideSource || recallOptions?.source || "").trim() ||
(normalizeGenerationRecallTransactionType(normalizedGenerationType) === "normal"
? "chat-tail-user"
: "chat-last-user");
const sourceLabel =
String(
recallOptions?.overrideSourceLabel ||
recallOptions?.sourceLabel ||
getRecallUserMessageSourceLabel(source),
).trim() || getRecallUserMessageSourceLabel(source);
return {
generationType: normalizedGenerationType,
targetUserMessageIndex,