fix(webui): update usage and tool progress during active turns (#6553)

* fix(webui): stream model status and usage during active turns

* fix(webui): keep live rounds and active-run status consistent

* fix(webui): reuse existing run indicators without extra status text

* fix(webui): preserve live activity and batch durable delivery

Cancel and drain sibling tools when progress notifications fail, retain balanced checkpoints, and keep model telemetry separate from answer provenance.

Group-commit already queued activity at the channel delivery boundary while preserving FIFO, generation ownership, per-envelope admission, and commit-before-fanout semantics. Isolate invalid members without dropping valid neighboring events.

Retain tool detail lazy grouping and cover scheduling, cancellation, persistence, encoding failures, and projection regressions.

* test(webui): separate standard-library imports in batch regression

* test: tighten live execution checks and clarify contracts

* refactor: remove redundant live execution comments

* refactor: settle tool results through one output path
This commit is contained in:
chengyongru authored and GitHub committed 2026-11-04 16:27:24 +08:00
1 parent 006a535537
commit 8ff04aad2b
52 files changed
+2065 -211

No files matched your search

+47 -9
View File
@@ -714,7 +714,10 @@ for (const elapsedMs of [0, 80]) test(`fast responses reclaim completed slots an
expect(nextHeld.anchorTop - atNewHead.anchorTop).toBeCloseTo(48, 0);
await completePrepend(history, body, "Question 16", "Question 28", nextHeld.anchorTop);
await expect(body.locator(".thread-history-slot")).toHaveCount(0);
expect(history.reads).toEqual(["?limit=120&before=40", "?limit=120&before=28"]);
expect(history.reads).toEqual([
"?limit=120&before=40&include_model_requests=1",
"?limit=120&before=28&include_model_requests=1",
]);
});
test("ordinary middle reading never reveals an exhausted overlay, even when the complete beginning is cached", async ({ page }) => {
@@ -920,7 +923,12 @@ test("navigation-window loading and errors remain visible and retry uses the nav
expect(Math.abs(navigationSpacing.boundaryGap! - navigationSpacing.referenceGap!)).toBeLessThan(1);
await positionAtTop(body);
await expect(page.locator('.thread-history-status[data-state="loading"]')).toHaveCount(0);
expect(history.reads).toEqual(["?limit=24&after=38", "?limit=24&after=50", "?limit=24&before=38", "?limit=24&before=38"]);
expect(history.reads).toEqual([
"?limit=24&after=38&include_model_requests=1",
"?limit=24&after=50&include_model_requests=1",
"?limit=24&before=38&include_model_requests=1",
"?limit=24&before=38&include_model_requests=1",
]);
});
async function jumpViaRail(page: Page, index: number) {
@@ -963,7 +971,10 @@ test("failed Blocks animate without visible error text; pulling retries once and
await expect.poll(() => displacement(body)).toBe(0);
expect((await historyGeometry(body, "Question 40")).slotBeforeKey).toBe("u40");
await expectCoordinates(body, "Question 40", held);
expect(history.reads).toEqual(["?limit=120&before=40", "?limit=120&before=40"]);
expect(history.reads).toEqual([
"?limit=120&before=40&include_model_requests=1",
"?limit=120&before=40&include_model_requests=1",
]);
history.complete();
await expect(body.getByText("Question 28", { exact: true })).toBeAttached();
@@ -1003,7 +1014,11 @@ test("cross-path unloaded rail jump has visible navigation feedback outside a sc
await retry.click();
await expect.poll(() => history.reads.length).toBe(3);
await expect(page.locator('.thread-history-status[data-state="loading"]')).toBeInViewport();
expect(history.reads).toEqual(["?limit=120&before=40", "?limit=24&after=10", "?limit=24&after=10"]);
expect(history.reads).toEqual([
"?limit=120&before=40&include_model_requests=1",
"?limit=24&after=10&include_model_requests=1",
"?limit=24&after=10&include_model_requests=1",
]);
history.complete();
await expect(body.getByText("Question 10", { exact: true })).toBeInViewport();
await expect(page.locator('.thread-history-status[data-state="loading"]')).toHaveCount(0);
@@ -1044,7 +1059,12 @@ test("cross-path newer has visible navigation feedback and forward input retries
await page.mouse.wheel(0, 120);
await expect.poll(() => history.reads.length).toBe(4);
await expect(page.locator('.thread-history-status[data-state="loading"]')).toBeInViewport();
expect(history.reads).toEqual(["?limit=24&after=10", "?limit=24&before=10", "?limit=24&after=22", "?limit=24&after=22"]);
expect(history.reads).toEqual([
"?limit=24&after=10&include_model_requests=1",
"?limit=24&before=10&include_model_requests=1",
"?limit=24&after=22&include_model_requests=1",
"?limit=24&after=22&include_model_requests=1",
]);
history.complete();
await expect(body.getByText("Question 33", { exact: true })).toBeAttached();
await expect(page.locator('.thread-history-status[data-state="loading"]')).toHaveCount(0);
@@ -1088,7 +1108,10 @@ test("cross-path older errors never float after latest or a loaded rail jump, bu
expect(history.reads).toHaveLength(initialReads + 1);
await retry.click();
await expect.poll(() => history.reads.length).toBe(initialReads + 2);
expect(history.reads.slice(initialReads)).toEqual(["?limit=120&before=40", "?limit=120&before=40"]);
expect(history.reads.slice(initialReads)).toEqual([
"?limit=120&before=40&include_model_requests=1",
"?limit=120&before=40&include_model_requests=1",
]);
history.complete();
await expect(body.getByText("Question 28", { exact: true })).toBeAttached();
await expect(body.locator(".thread-history-slot")).toHaveCount(0);
@@ -1178,7 +1201,11 @@ test("bounded navigation retains three pages and reclaims each completed wheel o
await expect(slot).toHaveCount(0);
await expectAnchorCoordinate(body, "Question 26", secondHeld.anchorTop);
expect((await historyGeometry(body, "Question 26")).slotBeforeKey).toBeNull();
expect(history.reads).toEqual(["?limit=24&after=38", "?limit=24&before=38", "?limit=24&before=26"]);
expect(history.reads).toEqual([
"?limit=24&after=38&include_model_requests=1",
"?limit=24&before=38&include_model_requests=1",
"?limit=24&before=26&include_model_requests=1",
]);
const atNewHead = await approachNextHead("Question 14");
expect(atNewHead.firstKey).toBe("u14");
@@ -1201,7 +1228,12 @@ test("bounded navigation retains three pages and reclaims each completed wheel o
await expect(body.locator('[data-thread-display-unit^="u"]')).toHaveCount(36);
await expect(header).toHaveCount(0);
await expect(page.getByText("No earlier messages", { exact: true })).toHaveCount(0);
expect(history.reads).toEqual(["?limit=24&after=38", "?limit=24&before=38", "?limit=24&before=26", "?limit=24&before=14"]);
expect(history.reads).toEqual([
"?limit=24&after=38&include_model_requests=1",
"?limit=24&before=38&include_model_requests=1",
"?limit=24&before=26&include_model_requests=1",
"?limit=24&before=14&include_model_requests=1",
]);
const atKeyboardHead = await approachNextHead("Question 2");
expect(atKeyboardHead.firstKey).toBe("u2");
@@ -1228,7 +1260,13 @@ test("bounded navigation retains three pages and reclaims each completed wheel o
await expect(body.getByText("Question 25", { exact: true })).toBeAttached();
await expect(body.getByText("Question 26", { exact: true })).toHaveCount(0);
await expect(body.locator('[data-thread-display-unit^="u"]')).toHaveCount(26);
expect(history.reads).toEqual(["?limit=24&after=38", "?limit=24&before=38", "?limit=24&before=26", "?limit=24&before=14", "?limit=24&before=2"]);
expect(history.reads).toEqual([
"?limit=24&after=38&include_model_requests=1",
"?limit=24&before=38&include_model_requests=1",
"?limit=24&before=26&include_model_requests=1",
"?limit=24&before=14&include_model_requests=1",
"?limit=24&before=2&include_model_requests=1",
]);
});