Repository navigation
perf(desktop): bound rendering within oversized turns #4259
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
M4n5ter
merged 34 commits into
apache:main
from
liugddx:fix/oversized-turn-render-bounds
Sep 6, 2026
Merged
Changes from 5 commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
73bb817
perf(desktop): bound rendering within oversized turns
liugddx d393e70
fix(ui): release live tail before geometry changes
liugddx c0f6631
test(desktop): enforce oversized turn performance gate
liugddx 895cb38
fix(ui): release live tail for focus navigation
liugddx d12b061
fix(ui): preserve live tail for visible focus
liugddx 3d26257
test(desktop): target visible focus growth race
liugddx af3cebf
fix(ui): classify focus before browser reveal
liugddx 24a2094
test(desktop): assert focused card position
liugddx efe3acb
perf(desktop): give tall transcript blocks a realistic intrinsic-size…
liugddx 4fc19d6
fix(ui): address oversized-turn review feedback
liugddx 51d17cf
Merge remote-tracking branch 'upstream/main' into review/pr4259-fixes
liugddx ffc698b
test(desktop): tolerate transient fixture cleanup locks
liugddx 214c442
fix(desktop): reach the production PageUp path, drop dead scroll indi…
liugddx 615bcce
test(desktop): pin the visible-Tab keep-tail contract under pending g…
liugddx 267ebd8
fix(ui): keep scroll authority test doubles compatible
liugddx 5f70b2c
test(desktop): focus real controls in oversized turn regression
liugddx 1d4c637
test(desktop): wait for tool group geometry to settle
liugddx 0fa6a8d
test(desktop): target visible controls in expanded tool card
liugddx 49f8d5c
test(desktop): choose actually visible transcript control
liugddx 496f201
fix(ui): release the transcript pin from position, drop input enumera…
liugddx c3ad913
fix(ui): release the transcript pin on upward reader motion, not dist…
liugddx e0a9665
Merge remote-tracking branch 'upstream/main' into HEAD
liugddx c033dbb
fix(ui): let the transcript pin own overflow anchoring for #4269
liugddx 8f4842f
Merge remote-tracking branch 'upstream/main' into HEAD
liugddx ba8f91b
fix(ui): keep tail-follow from asking for earlier history
liugddx 54fa258
Merge upstream/main: adopt its landed #4269 scroll fix, keep only #42…
liugddx b0e8d81
test(desktop): address containment review — anchoring CSS, reasoning,…
liugddx 81ff492
test(desktop): measure the cold-scroll anchor in viewport space
liugddx bfee6e1
test(desktop): step the cold-scroll story instantly, log per-step geo…
liugddx 53a50a4
test(desktop): hold the cold-scroll gate at the measured branch baseline
liugddx 75ec355
test(desktop): give each story reasoning run a unique accessible name
liugddx bd8e029
fix(desktop): estimate collapsed disclosures at their collapsed height
liugddx 834bd88
Merge upstream/main: follow #4825 below Electron, keep containment + …
liugddx 7ddb4ec
Merge remote-tracking branch 'upstream/main' into HEAD
liugddx File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,255 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
|
|
||
| import { expect, test } from './fixtures'; | ||
|
|
||
| const SEGMENT = [ | ||
| '.maka-assistant-answer-content > .maka-chat-message-bubble-assistant', | ||
| '.maka-assistant-answer-content > .maka-processing-sequence', | ||
| '.maka-processing-sequence > *', | ||
| ].join(','); | ||
| const SCROLLER = '[data-chat-scroll-container="true"]'; | ||
|
|
||
| async function waitForPaintedFrames(page: import('@playwright/test').Page, frames = 4) { | ||
| await page.evaluate(async (count) => { | ||
| for (let frame = 0; frame < count; frame += 1) { | ||
| await new Promise<void>((resolve) => requestAnimationFrame(() => resolve())); | ||
| } | ||
| }, frames); | ||
| } | ||
|
|
||
| test('an oversized single Turn skips offscreen timeline blocks', async ({ | ||
| oversizedTurnWindow: page, | ||
| }) => { | ||
| await page.setViewportSize({ width: 900, height: 700 }); | ||
| const segments = page.locator(SEGMENT); | ||
| await expect(segments).not.toHaveCount(0); | ||
| expect(await segments.count()).toBeGreaterThan(80); | ||
|
|
||
| const state = await segments.evaluateAll((elements) => { | ||
| const rows = elements as HTMLElement[]; | ||
| return { | ||
| automatic: rows.filter((element) => | ||
| getComputedStyle(element).contentVisibility === 'auto').length, | ||
| skipped: rows.filter((element) => | ||
| !element.checkVisibility({ contentVisibilityAuto: true })).length, | ||
| }; | ||
| }); | ||
| expect(state.automatic).toBe(await segments.count()); | ||
| expect(state.skipped).toBeGreaterThan(0); | ||
|
|
||
| const first = segments.first(); | ||
| await first.evaluate((element) => element.scrollIntoView({ block: 'center' })); | ||
| await page.evaluate(() => new Promise<void>((resolve) => | ||
| requestAnimationFrame(() => requestAnimationFrame(() => resolve())), | ||
| )); | ||
| expect(await first.evaluate((element) => | ||
| element.checkVisibility({ contentVisibilityAuto: true }), | ||
| )).toBe(true); | ||
| }); | ||
|
|
||
| test('upward scrolling releases the live tail while skipped geometry materializes', async ({ | ||
| oversizedTurnWindow: page, | ||
| }) => { | ||
| await page.setViewportSize({ width: 900, height: 700 }); | ||
| const root = page.locator(SCROLLER); | ||
| await root.evaluate((element) => { | ||
| element.scrollTop = element.scrollHeight; | ||
| }); | ||
| await waitForPaintedFrames(page); | ||
|
|
||
| const atTail = await root.evaluate((element) => | ||
| element.scrollHeight - element.scrollTop - element.clientHeight, | ||
| ); | ||
| expect(atTail).toBeLessThanOrEqual(4); | ||
|
|
||
| // Force the ordering from the field report: the wheel begins materializing | ||
| // an intrinsic-size block before Chromium delivers the resulting scroll. | ||
| // Appending below the reader is deterministic synthetic growth; approaching | ||
| // the skipped timeline blocks above adds the real content-visibility change. | ||
| await root.evaluate((element) => { | ||
| const list = element.querySelector('.maka-chat-message-list'); | ||
| if (!list) throw new Error('the transcript content box is missing'); | ||
| element.addEventListener('wheel', () => { | ||
| const growth = document.createElement('div'); | ||
| growth.dataset.oversizedTurnGrowth = 'true'; | ||
| growth.style.height = '600px'; | ||
| list.append(growth); | ||
| }, { capture: true, once: true }); | ||
| }); | ||
|
|
||
| await root.hover(); | ||
| await page.mouse.wheel(0, -500); | ||
| await waitForPaintedFrames(page, 6); | ||
|
|
||
| const released = await root.evaluate((element) => ({ | ||
| distance: element.scrollHeight - element.scrollTop - element.clientHeight, | ||
| top: element.scrollTop, | ||
| })); | ||
| expect(released.distance).toBeGreaterThan(100); | ||
|
|
||
| // A later delivery must preserve the released position too. Without the | ||
| // release, the scroll authority writes the latest tail on this resize. | ||
| await root.evaluate((element) => { | ||
| const growth = element.querySelector<HTMLElement>('[data-oversized-turn-growth]'); | ||
| if (!growth) throw new Error('the synthetic growth box is missing'); | ||
| growth.style.height = '900px'; | ||
| }); | ||
| await waitForPaintedFrames(page); | ||
|
|
||
| const afterGrowth = await root.evaluate((element) => ({ | ||
| distance: element.scrollHeight - element.scrollTop - element.clientHeight, | ||
| top: element.scrollTop, | ||
| })); | ||
| expect(afterGrowth.distance).toBeGreaterThan(released.distance); | ||
| expect(Math.abs(afterGrowth.top - released.top)).toBeLessThanOrEqual(4); | ||
| }); | ||
|
|
||
| test('keyboard focus into a skipped card releases the live tail', async ({ | ||
| oversizedTurnWindow: page, | ||
| }) => { | ||
| await page.setViewportSize({ width: 900, height: 700 }); | ||
| const root = page.locator(SCROLLER); | ||
| await root.evaluate((element) => { | ||
| element.scrollTop = element.scrollHeight; | ||
| }); | ||
| await waitForPaintedFrames(page); | ||
|
|
||
| const boundary = await root.evaluate((element, segmentSelector) => { | ||
| // Use the actual sequential focus order inside the transcript. The | ||
| // containment boundary is the tool-card row around Astryx's native button, | ||
| // so visibility must be asked of that row rather than its focused child. | ||
| const headers = [...element.querySelectorAll<HTMLElement>('[role="button"][tabindex="0"]')] | ||
| .map((header) => ({ header, row: header.closest<HTMLElement>(segmentSelector) })) | ||
| .filter((entry): entry is { header: HTMLElement; row: HTMLElement } => | ||
| entry.row != null, | ||
| ); | ||
| for (let index = 1; index < headers.length; index += 1) { | ||
| const previous = headers[index - 1]!; | ||
| const anchor = headers[index]!; | ||
| if ( | ||
| !previous.row.checkVisibility({ contentVisibilityAuto: true }) | ||
| && anchor.row.checkVisibility({ contentVisibilityAuto: true }) | ||
| ) { | ||
| previous.header.dataset.focusBoundaryTarget = 'true'; | ||
| anchor.header.dataset.focusBoundaryAnchor = 'true'; | ||
| anchor.header.focus({ preventScroll: true }); | ||
| return { found: true, headerCount: headers.length }; | ||
| } | ||
| } | ||
| return { found: false, headerCount: headers.length }; | ||
| }, SEGMENT); | ||
| expect(boundary.headerCount).toBeGreaterThan(5); | ||
| expect(boundary.found).toBe(true); | ||
|
|
||
| // This is the normal sequential-navigation path, not a synthetic focus | ||
| // event. Shift+Tab enters the immediately preceding skipped activity card. | ||
| await page.keyboard.press('Shift+Tab'); | ||
| await waitForPaintedFrames(page, 6); | ||
|
|
||
| const focused = await root.evaluate((element) => { | ||
| const active = document.activeElement as HTMLElement | null; | ||
| const rootRect = element.getBoundingClientRect(); | ||
| const activeRect = active?.getBoundingClientRect(); | ||
| return { | ||
| target: active?.dataset.focusBoundaryTarget === 'true', | ||
| distance: element.scrollHeight - element.scrollTop - element.clientHeight, | ||
| top: element.scrollTop, | ||
| activeTop: activeRect?.top ?? Number.NaN, | ||
| withinViewport: activeRect != null | ||
| && activeRect.bottom > rootRect.top | ||
| && activeRect.top < rootRect.bottom, | ||
| }; | ||
| }); | ||
| expect(focused.target).toBe(true); | ||
| expect(focused.distance).toBeGreaterThan(100); | ||
| expect(focused.withinViewport).toBe(true); | ||
|
|
||
| // A later content delivery resizes the observed transcript box. It must not | ||
| // re-pin and move the focused card out from under keyboard/AT navigation. | ||
| await root.evaluate((element) => { | ||
| const list = element.querySelector('.maka-chat-message-list'); | ||
| if (!list) throw new Error('the transcript content box is missing'); | ||
| const growth = document.createElement('div'); | ||
| growth.style.height = '600px'; | ||
| list.append(growth); | ||
| }); | ||
| await waitForPaintedFrames(page); | ||
|
|
||
| const afterGrowth = await root.evaluate((element) => { | ||
| const active = document.activeElement as HTMLElement | null; | ||
| return { | ||
| target: active?.dataset.focusBoundaryTarget === 'true', | ||
| distance: element.scrollHeight - element.scrollTop - element.clientHeight, | ||
| top: element.scrollTop, | ||
| activeTop: active?.getBoundingClientRect().top ?? Number.NaN, | ||
| }; | ||
| }); | ||
| expect(afterGrowth.target).toBe(true); | ||
| expect(afterGrowth.distance).toBeGreaterThan(focused.distance); | ||
| expect(Math.abs(afterGrowth.top - focused.top)).toBeLessThanOrEqual(4); | ||
| expect(Math.abs(afterGrowth.activeTop - focused.activeTop)).toBeLessThanOrEqual(4); | ||
| }); | ||
|
|
||
| test('visible transcript focus during pending growth keeps the live tail', async ({ | ||
| oversizedTurnWindow: page, | ||
| }) => { | ||
| await page.setViewportSize({ width: 900, height: 700 }); | ||
| const root = page.locator(SCROLLER); | ||
| await root.evaluate((element) => { | ||
| element.scrollTop = element.scrollHeight; | ||
| }); | ||
| await waitForPaintedFrames(page); | ||
|
|
||
| await root.evaluate((element) => { | ||
| const list = element.querySelector('.maka-chat-message-list'); | ||
| if (!list) throw new Error('the transcript content box is missing'); | ||
| const rootRect = element.getBoundingClientRect(); | ||
| const control = [...list.querySelectorAll<HTMLElement>('[role="button"][tabindex="0"]')] | ||
| .reverse() | ||
| .find((candidate) => { | ||
| const rect = candidate.getBoundingClientRect(); | ||
| return rect.bottom > rootRect.top && rect.top < rootRect.bottom; | ||
| }); | ||
| if (!control) throw new Error('no visible transcript control is available'); | ||
|
|
||
| // Keep both mutations and focus in one task. ResizeObserver is therefore | ||
| // still pending when the visible control receives focus, which is the race | ||
| // where root distance must not be mistaken for reader movement. | ||
| const firstGrowth = document.createElement('div'); | ||
| firstGrowth.dataset.pendingFocusGrowth = 'true'; | ||
| firstGrowth.style.height = '600px'; | ||
| list.append(firstGrowth); | ||
| control.focus(); | ||
| const secondGrowth = document.createElement('div'); | ||
| secondGrowth.dataset.followUpFocusGrowth = 'true'; | ||
| secondGrowth.style.height = '300px'; | ||
| list.append(secondGrowth); | ||
| }); | ||
| await waitForPaintedFrames(page, 6); | ||
|
|
||
| const result = await root.evaluate((element) => ({ | ||
| distance: element.scrollHeight - element.scrollTop - element.clientHeight, | ||
| activeInTranscript: Boolean( | ||
| document.activeElement?.closest('.maka-chat-message-list'), | ||
| ), | ||
| })); | ||
| expect(result.activeInTranscript).toBe(true); | ||
| expect(result.distance).toBeLessThanOrEqual(4); | ||
| }); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.