Stop issue page jumps during live run updates

This commit is contained in:
Dotta committed 2026-04-14 11:46:39 -05:00
1 parent 318045eb74
commit 15a24aeb2c
3 files changed
+56 -7

No files matched your search

+53 -1
View File
@@ -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(
<MemoryRouter>
<IssueChatThread
comments={[]}
linkedRuns={[]}
timelineEvents={[]}
liveRuns={[]}
onAdd={async () => {}}
enableLiveTranscriptPolling={false}
/>
</MemoryRouter>,
);
});
act(() => {
root.render(
<MemoryRouter>
<IssueChatThread
comments={[]}
linkedRuns={[]}
timelineEvents={[]}
liveRuns={[{
id: "run-1",
issueId: "issue-1",
status: "running",
invocationSource: "comment",
triggerDetail: null,
startedAt: "2026-04-06T12:00:00.000Z",
finishedAt: null,
createdAt: "2026-04-06T12:00:00.000Z",
agentId: "agent-1",
agentName: "Agent 1",
adapterType: "codex_local",
}]}
onAdd={async () => {}}
enableLiveTranscriptPolling={false}
/>
</MemoryRouter>,
);
});
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);
+2 -2
View File
@@ -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();
});
+1 -4
View File
@@ -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(