Your lightweight open-source personal agent.
Python agent-frameworkai-agentai-agentschatbotchatopsdiscord-botllm-agentsllmslocal-llmmcpmodel-context-protocolmulti-agentopenai-compatibleopenclawpersonal-ai-assistantpythonself-hostedtelegram-bot-ai-assistantwebuiworkflow-automation
fix(webui): apply latest offscreen visibility notification (NAN-333)
chengyongru872a83340da2
diff --git a/webui/src/components/thread/ThreadMessages.tsx b/webui/src/components/thread/ThreadMessages.tsxindex 54fab66d0..edc127c2c 100644--- a/webui/src/components/thread/ThreadMessages.tsx+++ b/webui/src/components/thread/ThreadMessages.tsx@@ -612,7 +612,8 @@ const ThreadDisplayUnit = memo(function ThreadDisplayUnit({useEffect(() => {const element = elementRef.current;if (!element || !deferOffscreenRender || interacted || typeof IntersectionObserver === "undefined") return;- const observer = new IntersectionObserver(([entry]) => {+ const observer = new IntersectionObserver((entries) => {+ const entry = entries[entries.length - 1];if (!entry) return;if (!entry.isIntersecting) {const height = element.getBoundingClientRect().height;diff --git a/webui/src/tests/thread-messages.test.tsx b/webui/src/tests/thread-messages.test.tsxindex 6f24f6f7c..9eccbae9a 100644--- a/webui/src/tests/thread-messages.test.tsx+++ b/webui/src/tests/thread-messages.test.tsx@@ -226,7 +226,7 @@ describe("ThreadMessages", () => {expect(screen.getByText("latest answer").closest(".thread-render-unit")).toBeNull();});- it("recycles offscreen historical content while preserving its measured space", () => {+ it("recycles historical content using the latest intersection in each batch", () => {let notify: (entries: Array<{ isIntersecting: boolean }>) => void = () => {};vi.stubGlobal("IntersectionObserver", class {constructor(callback: typeof notify) { notify = callback; }@@ -243,8 +243,15 @@ describe("ThreadMessages", () => {act(() => notify([{ isIntersecting: false }]));expect(unit.style.height).toBe("240px");expect(unit.childElementCount).toBe(0);+ act(() => notify([{ isIntersecting: false }, { isIntersecting: true }]));+ expect(screen.getByText("historical answer")).toBeVisible();+ expect(unit.style.height).toBe("");+ act(() => notify([{ isIntersecting: true }, { isIntersecting: false }]));+ expect(unit.style.height).toBe("240px");+ expect(unit.childElementCount).toBe(0);act(() => notify([{ isIntersecting: true }]));expect(screen.getByText("historical answer")).toBeVisible();+ expect(unit.style.height).toBe("");expect(view.container).toHaveTextContent("old question");});