From b5fcf1f17b88191c6f22fe9bcec45a80f0e56f97 Mon Sep 17 00:00:00 2001 From: YuanShiJiLoong <2450829984@qq.com> Date: Thu, 26 Feb 2026 01:59:49 +0900 Subject: [PATCH] fix: AI reference tab includes all selected chapters regardless of position --- app/lib/context-engine.js | 7 ++----- app/page.js | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/app/lib/context-engine.js b/app/lib/context-engine.js index fab7c2c..aaa61d9 100644 --- a/app/lib/context-engine.js +++ b/app/lib/context-engine.js @@ -611,12 +611,9 @@ function buildPreviousContext(chapters, currentIndex) { }).join('\n\n'); } -// 按 selectedIds 过滤的前文上下文 +// 按 selectedIds 过滤的章节上下文(包含用户手动勾选的所有章节,不限前后) function buildPreviousContextFiltered(chapters, currentIndex, selectedIds) { - if (currentIndex <= 0) return ''; - - const prevChapters = chapters.slice(0, currentIndex); - const selected = prevChapters.filter(ch => selectedIds.has(`chapter-${ch.id}`)); + const selected = chapters.filter((ch, i) => i !== currentIndex && selectedIds.has(`chapter-${ch.id}`)); if (selected.length === 0) return ''; return selected.map((ch) => { diff --git a/app/page.js b/app/page.js index ddc2527..f4f1f0a 100644 --- a/app/page.js +++ b/app/page.js @@ -161,7 +161,7 @@ export default function Home() { }; loadContext(); - }, [activeChapterId, settingsVersion, chatHistory.length]); + }, [activeChapterId, settingsVersion, chatHistory.length, chapters.length]); // 定时自动存档 (每 15 分钟) useEffect(() => {