Merge upstream/main: resolve format-only conflicts

Adopt upstream multi-line formatting for chat-history.js and
tests/chat-history.mjs. Also brings in upstream .gitignore,
settleExtractionStatusAfterHistoryRecovery null-safety fix,
and getSmartTriggerDecision index-aware extraction filtering.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Hao19911125
2026-04-03 15:10:21 +08:00
6 changed files with 64 additions and 741 deletions

View File

@@ -4412,22 +4412,6 @@ function notifyExtractionIssue(message, title = "ST-BME 提取提示") {
toastr.warning(message, title, { timeOut: 4500 });
}
function settleExtractionStatusAfterHistoryRecovery(
text = "提取完成",
meta = "",
level = "success",
) {
const currentText = String(lastExtractionStatus?.text || "");
const currentLevel = String(lastExtractionStatus?.level || "");
if (currentText !== "AI 生成中" && currentLevel !== "running") {
return;
}
setLastExtractionStatus(text, meta, level, {
syncRuntime: true,
toastKind: "",
});
}
async function fetchLocalWithTimeout(
url,
options = {},
@@ -5668,8 +5652,12 @@ const DEFAULT_TRIGGER_KEYWORDS = [
export function getSmartTriggerDecision(chat, lastProcessed, settings) {
const pendingMessages = chat
.slice(Math.max(0, (lastProcessed ?? -1) + 1))
.filter((msg) => !isSystemMessageForExtraction(msg))
.map((msg) => ({
.map((msg, offset) => ({
msg,
index: Math.max(0, (lastProcessed ?? -1) + 1) + offset,
}))
.filter(({ msg, index }) => !isSystemMessageForExtraction(msg, { index, chat }))
.map(({ msg }) => ({
role: msg.is_user ? "user" : "assistant",
content: msg.mes || "",
}))
@@ -7936,6 +7924,30 @@ async function recoverHistoryIfNeeded(trigger = "history-recovery") {
}
}
function settleExtractionStatusAfterHistoryRecovery(
text = "提取完成",
meta = "",
level = "success",
) {
const statusSnapshot =
typeof lastExtractionStatus === "object" && lastExtractionStatus
? lastExtractionStatus
: null;
if (!statusSnapshot || typeof setLastExtractionStatus !== "function") {
return;
}
const currentText = String(statusSnapshot.text || "");
const currentLevel = String(statusSnapshot.level || "");
if (currentText !== "AI 生成中" && currentLevel !== "running") {
return;
}
setLastExtractionStatus(text, meta, level, {
syncRuntime: true,
toastKind: "",
});
}
/**
* 提取管线:处理未提取的对话楼层
*/