дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-12-06 01:57:13 +02:00
fix(workbench): stop conversations and output panes at the last line (#8263)
A strong downward trackpad gesture could pull the last reply above the composer and leave a blank strip. Vertical overscroll is now bounded in conversations, consoles and log viewers; scrolling toward the end releases the temporary space that holds a reader's place after a resize or fold; and a large pixel delta in a nested tool output stops at that output's edge.
Цей коміт міститься в:
1 джерело
775a5e04d0
коміт
cfbc0e3ed3
8 files changed
+91
-5
No files matched your search
@@ -83,6 +83,24 @@ test("keeps the conversation position on double-click", async ({ page }) => {
|
||||
await expect.poll(() => stream.evaluate((el, top) => Math.abs(el.scrollTop - top), before)).toBeLessThanOrEqual(1);
|
||||
});
|
||||
|
||||
test("returns to the reply when scrolling down after the conversation viewport grows", async ({ page }) => {
|
||||
const stream = await openHistory(page);
|
||||
const bottomGap = () =>
|
||||
stream.evaluate((el) => el.getBoundingClientRect().bottom - el.lastElementChild!.getBoundingClientRect().bottom);
|
||||
// A macOS trackpad can also scroll past this boundary during a fling.
|
||||
await expect(stream).toHaveCSS("overscroll-behavior-y", "none");
|
||||
const initialGap = await bottomGap();
|
||||
await stream.hover();
|
||||
await page.mouse.wheel(0, -8);
|
||||
await expect.poll(bottomGap).toBeLessThan(initialGap - 5);
|
||||
|
||||
const size = page.viewportSize()!;
|
||||
await page.setViewportSize({ ...size, height: size.height + 40 });
|
||||
await expect.poll(bottomGap).toBeGreaterThan(initialGap + 25);
|
||||
await page.mouse.wheel(0, 80);
|
||||
await expect.poll(async () => Math.abs((await bottomGap()) - initialGap)).toBeLessThanOrEqual(1);
|
||||
});
|
||||
|
||||
for (const placement of ["editor", "toolWindow"] as const) {
|
||||
test(`lets small upward wheel steps leave the end while replies stream in the ${placement}`, async ({ page }) => {
|
||||
// Streams into an 80-turn conversation for several seconds: close to 30 s on CI runners.
|
||||
|
||||
@@ -63,6 +63,7 @@ for (const kind of ["run", "debug", "services-run", "services-debug", "stacktrac
|
||||
const host = page.locator("#console-alignment-host");
|
||||
const log = host.getByRole("log");
|
||||
await expect(log).toBeVisible();
|
||||
await expect(log).toHaveCSS("overscroll-behavior-y", "none");
|
||||
await log.focus();
|
||||
await page.keyboard.press("Meta+f");
|
||||
const search = host.getByRole("search", { name: "Find in console" });
|
||||
|
||||
@@ -261,6 +261,7 @@
|
||||
min-width: 0;
|
||||
overflow-y: auto;
|
||||
overflow-x: hidden;
|
||||
overscroll-behavior-y: none;
|
||||
overflow-anchor: none;
|
||||
padding: var(--space-3);
|
||||
display: flex;
|
||||
|
||||
@@ -535,6 +535,23 @@ export function Stream({
|
||||
shownRow.current = null;
|
||||
holdShownRow();
|
||||
}, [holdShownRow]);
|
||||
const scrollTowardEnd = useCallback(
|
||||
(target: EventTarget | null) => {
|
||||
scrollingUp.current = false;
|
||||
const el = ref.current;
|
||||
if (!el || !slack.current || scrollOwner(target, el) !== el) return;
|
||||
// The spacer holds the reader at the scroll limit after a fold or resize. A downward
|
||||
// gesture there may never fire a scroll event, so release it on input.
|
||||
shownRow.current = null;
|
||||
setSlack(0);
|
||||
if (el.scrollHeight - el.clientHeight - el.scrollTop < 1) {
|
||||
position.current = { top: el.scrollTop, stick: true };
|
||||
positions.set(key, position.current);
|
||||
}
|
||||
updateJumpVisibility(el);
|
||||
},
|
||||
[key, positions, setSlack, updateJumpVisibility],
|
||||
);
|
||||
/** A diagram that drew after the last streamed chunk grows the conversation: keep following. */
|
||||
const onDiagramDrawn = useCallback(() => {
|
||||
const el = ref.current;
|
||||
@@ -680,15 +697,20 @@ export function Stream({
|
||||
if (owner !== el) {
|
||||
const room = e.deltaY < 0 ? owner.scrollTop : owner.scrollHeight - owner.clientHeight - owner.scrollTop;
|
||||
if (room <= 1) e.preventDefault();
|
||||
else if (e.deltaMode === WheelEvent.DOM_DELTA_PIXEL && Math.abs(e.deltaY) > room) {
|
||||
// A single trackpad delta can cross the edge before the next wheel event.
|
||||
e.preventDefault();
|
||||
owner.scrollTop += Math.sign(e.deltaY) * room;
|
||||
}
|
||||
return;
|
||||
}
|
||||
markUserScroll();
|
||||
if (e.deltaY < 0) stopFollowing(e.target);
|
||||
else if (e.deltaY > 0) scrollingUp.current = false;
|
||||
else if (e.deltaY > 0) scrollTowardEnd(owner);
|
||||
};
|
||||
el.addEventListener("wheel", onWheel, { passive: false });
|
||||
return () => el.removeEventListener("wheel", onWheel);
|
||||
}, [markUserScroll, stopFollowing]);
|
||||
}, [markUserScroll, scrollTowardEnd, stopFollowing]);
|
||||
/**
|
||||
* The reader opened or closed a section: put its header back where it was, in the run or
|
||||
* output that scrolls it and then in the conversation. Following stops when that leaves any
|
||||
@@ -849,7 +871,7 @@ export function Stream({
|
||||
markUserScroll();
|
||||
const y = e.touches.length === 1 ? e.touches[0]!.clientY : null;
|
||||
if (y !== null && touchY.current !== null && y > touchY.current) stopFollowing(e.target);
|
||||
else if (y !== null && touchY.current !== null && y < touchY.current) scrollingUp.current = false;
|
||||
else if (y !== null && touchY.current !== null && y < touchY.current) scrollTowardEnd(e.target);
|
||||
touchY.current = y;
|
||||
}}
|
||||
onKeyDown={(e) => {
|
||||
@@ -861,9 +883,9 @@ export function Stream({
|
||||
e.key === "ArrowDown" ||
|
||||
e.key === "PageDown" ||
|
||||
e.key === "End" ||
|
||||
(e.key === " " && !e.shiftKey)
|
||||
(e.key === " " && !e.shiftKey && !isInteractiveTarget(e.target))
|
||||
)
|
||||
scrollingUp.current = false;
|
||||
scrollTowardEnd(e.target);
|
||||
}}
|
||||
onPointerDown={(e) => {
|
||||
if (isInteractiveTarget(e.target)) return;
|
||||
|
||||
@@ -935,6 +935,36 @@ describe("scrolling", () => {
|
||||
expect(el.scrollTop).toBe(1000);
|
||||
});
|
||||
|
||||
it.each(["wheel", "touch", "End"])("clears fold space when scrolling down again with %s", async (method) => {
|
||||
backend.entries.set("A", [
|
||||
{ type: "thought", text: "Weighing it" },
|
||||
{ type: "agent", text: "Answer A" },
|
||||
]);
|
||||
useAgents.setState({ entries: new Map(backend.entries) });
|
||||
render(<SessionEditor input={input("A")} />);
|
||||
await screen.findByText("Answer A");
|
||||
const { el, summary, slack } = foldingStream(60);
|
||||
summary.getBoundingClientRect = () => ({ top: 900 - el.scrollTop }) as DOMRect;
|
||||
fireEvent.click(summary);
|
||||
el.scrollTop = 660;
|
||||
fireEvent.scroll(el);
|
||||
fireEvent.click(summary);
|
||||
expect(slack()).toBe(60);
|
||||
// Space on the fold header activates it; only scroll input should release the spacer.
|
||||
fireEvent.keyDown(summary, { key: " " });
|
||||
expect(slack()).toBe(60);
|
||||
|
||||
if (method === "wheel") fireEvent.wheel(el, { deltaY: 12 });
|
||||
else if (method === "touch") {
|
||||
fireEvent.touchStart(el, { touches: [{ clientY: 100 }] });
|
||||
fireEvent.touchMove(el, { touches: [{ clientY: 88 }] });
|
||||
} else fireEvent.keyDown(el, { key: "End" });
|
||||
|
||||
expect(slack()).toBe(0);
|
||||
expect(el.scrollTop).toBe(el.scrollHeight - el.clientHeight);
|
||||
expect(useAgents.getState().scrollPositions.get("A")?.stick).toBe(true);
|
||||
});
|
||||
|
||||
it("scrolls the innermost container under the wheel and never hands it to the conversation", () => {
|
||||
const transcript: AgentEntry[] = [tool("live", { status: "running", output: "Tool output" })];
|
||||
useAgents.setState({ entries: new Map([["A", transcript]]) });
|
||||
@@ -957,6 +987,11 @@ describe("scrolling", () => {
|
||||
output.scrollTop = 100;
|
||||
expect(fireEvent.wheel(output, { deltaY: -4 })).toBe(true);
|
||||
expect(screen.queryByRole("button", { name: "Jump to Latest" })).toBeNull();
|
||||
// A large pixel delta stops at the output boundary in either direction.
|
||||
expect(fireEvent.wheel(output, { deltaY: 150 })).toBe(false);
|
||||
expect(output.scrollTop).toBe(200);
|
||||
expect(fireEvent.wheel(output, { deltaY: -250 })).toBe(false);
|
||||
expect(output.scrollTop).toBe(0);
|
||||
// A gesture that started in the conversation stays there when the output slides under it.
|
||||
now = 2000;
|
||||
expect(fireEvent.wheel(el, { deltaY: -4 })).toBe(true);
|
||||
|
||||
@@ -226,6 +226,7 @@
|
||||
color: var(--fg-strong);
|
||||
}
|
||||
.log {
|
||||
overscroll-behavior-y: none;
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
margin: 0;
|
||||
|
||||
@@ -74,6 +74,11 @@ body {
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
/* Output panes follow their last line. Keep macOS elastic offsets out of that position. */
|
||||
[role="log"] {
|
||||
overscroll-behavior-y: none;
|
||||
}
|
||||
|
||||
[data-scrollbar-drag-surface] {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
|
||||
@@ -23,6 +23,9 @@
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
}
|
||||
.output :global(.cm-scroller) {
|
||||
overscroll-behavior-y: none;
|
||||
}
|
||||
.log {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
|
||||
Reference in new issue
Заблокувати користувача