Files
nanobot/webui/browser/thread-autoscroll.spec.ts
chengyongru 394a78e82d fix(sessions): preserve cross-session input ownership and history (#6613)
* fix(webui): reconcile cross-session history by message ID

* fix(sessions): preserve target authority and input ownership

Resolve cross-session follow-ups through the target route, carry stable input IDs through admission and recovery, and associate live and replayed answers with the inputs actually consumed.

Keep ordinary input scope isolation and omit historical anomaly repair. Resolves NAN-430.

* fix(sessions): complete input identity integration across boundaries

Carry input identity explicitly in projected input events, keep runner annotations out of public history, and reuse the canonical WebUI session parser during recovery.

Type validated recovery metadata and align existing channel and subagent regressions with explicit response ownership. All nine failed compatibility cases and adjacent recovery coverage pass in a focused 58-test run.

* fix(sessions): unify input recording and block remote commands

* fix(webui): keep input ownership checks page-bounded

Look up referenced inputs through the existing identity index before invoking transcript backfill. Complete pages no longer scan the full prompt history, including answers whose inputs live on earlier pages.

Cover cold-cache pagination and cross-turn ownership in existing regressions. Focused pagination, replay and follow-up recovery checks: 88 passed.

* fix(webui): preserve response ownership during history replay

* fix: resolve strict typing in response replay

* fix: preserve continuation ownership during recovery

* test: diagnose stuck gateway asyncio shutdown

* test: retain gateway thread stack diagnostics

* test(webui): stabilize native autoscroll browser setup
2026-11-11 10:46:44 +08:00

42 lines
2.2 KiB
TypeScript

import { expect, test } from "@playwright/test";
test.use({ launchOptions: {
executablePath: process.env.PLAYWRIGHT_CHROMIUM_EXECUTABLE_PATH,
args: ["--enable-blink-features=MiddleClickAutoscroll"],
} });
test("lets native autoscroll leave the live tail and reverse after returning", async ({ page }) => {
// A real scrolling control catches browser configurations without native autoscroll.
await page.setContent('<div id="control" style="height:600px;overflow:auto"><div style="height:5000px">Autoscroll control</div></div>');
await page.locator("#control").click({ button: "middle", position: { x: 200, y: 200 } });
await page.mouse.move(200, 300);
await expect.poll(() => page.locator("#control").evaluate((node) => node.scrollTop)).toBeGreaterThan(100);
await page.keyboard.press("Escape");
await page.addInitScript(() => localStorage.setItem("nanobot.locale", "en"));
await page.goto("/browser/fixture.html?case=history-boundary&local=1");
const body = page.getByTestId("thread-message-region");
// The plain-text fallback is replaced when the lazy Markdown renderer loads.
const tail = body.locator(".markdown-content").getByText("Cached message 279", { exact: true });
await expect(tail).toBeVisible();
const distanceFromBottom = () => body.evaluate((node) => node.scrollHeight - node.clientHeight - node.scrollTop);
expect(await body.evaluate((node) => node.scrollHeight - node.clientHeight)).toBeGreaterThan(1_000);
await expect.poll(distanceFromBottom).toBeLessThan(1);
await tail.click({ button: "middle" });
const bounds = await tail.boundingBox();
expect(bounds).not.toBeNull();
const x = bounds!.x + bounds!.width / 2;
const y = bounds!.y + bounds!.height / 2;
await page.mouse.move(x, y - 100);
await expect.poll(distanceFromBottom).toBeGreaterThan(150);
await page.mouse.move(x, y + 100);
await expect.poll(distanceFromBottom).toBeLessThan(1);
await page.mouse.move(x, y - 100);
await expect.poll(distanceFromBottom).toBeGreaterThan(150);
await page.keyboard.press("Escape");
await expect(page.getByRole("button", { name: "Scroll to bottom" })).toBeVisible();
await page.getByRole("button", { name: "Scroll to bottom" }).click();
await expect.poll(distanceFromBottom).toBeLessThan(1);
});