From 15a24aeb2c2c6efef8ebea758bfdfab822d8531d Mon Sep 17 00:00:00 2001 From: Dotta Date: Mon, 13 Apr 2026 11:04:53 -0500 Subject: [PATCH] Stop issue page jumps during live run updates --- ui/src/components/IssueChatThread.test.tsx | 54 +++++++++++++++++++++- ui/src/lib/issue-chat-scroll.test.ts | 4 +- ui/src/lib/issue-chat-scroll.ts | 5 +- 3 files changed, 56 insertions(+), 7 deletions(-) diff --git a/ui/src/components/IssueChatThread.test.tsx b/ui/src/components/IssueChatThread.test.tsx index 890a9405170..dbddfacb3da 100644 --- a/ui/src/components/IssueChatThread.test.tsx +++ b/ui/src/components/IssueChatThread.test.tsx @@ -518,7 +518,59 @@ describe("IssueChatThread", () => { }); }); - it("requests composer viewport restoration when live messages arrive while the composer is visible", () => { + it("does not restore the composer viewport for passive live updates by default", () => { + const root = createRoot(container); + + act(() => { + root.render( + + {}} + enableLiveTranscriptPolling={false} + /> + , + ); + }); + + act(() => { + root.render( + + {}} + enableLiveTranscriptPolling={false} + /> + , + ); + }); + + expect(restoreComposerViewportSnapshotMock).not.toHaveBeenCalled(); + + act(() => { + root.unmount(); + }); + }); + + it("requests composer viewport restoration when live messages arrive during active composer interaction", () => { const root = createRoot(container); const scrollByMock = vi.spyOn(window, "scrollBy").mockImplementation(() => {}); shouldPreserveComposerViewportMock.mockReturnValue(true); diff --git a/ui/src/lib/issue-chat-scroll.test.ts b/ui/src/lib/issue-chat-scroll.test.ts index 3621aaec754..491369ad59b 100644 --- a/ui/src/lib/issue-chat-scroll.test.ts +++ b/ui/src/lib/issue-chat-scroll.test.ts @@ -72,12 +72,12 @@ describe("issue-chat-scroll", () => { mainContent.remove(); }); - it("preserves the composer viewport when the composer is visible", () => { + it("does not preserve the composer viewport just because the composer is visible", () => { const composer = document.createElement("div"); document.body.appendChild(composer); mockTop(composer, 540); - expect(shouldPreserveComposerViewport(composer)).toBe(true); + expect(shouldPreserveComposerViewport(composer)).toBe(false); composer.remove(); }); diff --git a/ui/src/lib/issue-chat-scroll.ts b/ui/src/lib/issue-chat-scroll.ts index 1e7e5da135a..b70f3d925e2 100644 --- a/ui/src/lib/issue-chat-scroll.ts +++ b/ui/src/lib/issue-chat-scroll.ts @@ -46,10 +46,7 @@ export function shouldPreserveComposerViewport( if (activeElement instanceof Node && composerElement.contains(activeElement)) { return true; } - - const viewportHeight = doc.defaultView?.innerHeight ?? window.innerHeight; - const rect = composerElement.getBoundingClientRect(); - return rect.bottom > 0 && rect.top < viewportHeight; + return false; } export function restoreComposerViewportSnapshot(