From 2e77c72d4a4e0d2da1141847acfc6f337cdf918f Mon Sep 17 00:00:00 2001 From: Justin Starner <9425563+jstarner@users.noreply.github.com> Date: Sun, 1 Nov 2026 10:12:38 -0500 Subject: [PATCH 1/3] fix(ios): keep a sheet's toolbar host off its own controls On iOS 26/27 UIKit hosts a sheet's bars in a Toolbar container at the sheet's frame. An undimmed sheet keeps the presenting screen in the capture, so the host also encloses that screen's bars and scroll view, and the own-presentation exemption failed: every control in the sheet was refused as covered. The host now covers the presentation beneath it but not its own. A host that encloses a presentation stacked over it still covers everything before it. --- .changeset/undimmed-sheet-toolbar-host.md | 5 + ...hot-occlusion-sibling-sized-chrome.test.ts | 146 +++++++++++++++++- .../capture-kit/src/snapshot-occlusion.ts | 117 ++++++++++++-- 3 files changed, 245 insertions(+), 23 deletions(-) create mode 100644 .changeset/undimmed-sheet-toolbar-host.md diff --git a/.changeset/undimmed-sheet-toolbar-host.md b/.changeset/undimmed-sheet-toolbar-host.md new file mode 100644 index 0000000000..7c9422b735 --- /dev/null +++ b/.changeset/undimmed-sheet-toolbar-host.md @@ -0,0 +1,5 @@ +--- +'agent-device': patch +--- + +Fix iOS 26/27 `press`, `click`, and `fill` refusing every control inside a sheet that keeps the screen beneath it in the capture (such as an undimmed sheet) as covered by the sheet's `Toolbar` host. The host now covers the screen beneath the sheet but not the sheet's own controls. A host that encloses a presentation stacked over it still covers everything before it. diff --git a/packages/capture-kit/src/snapshot-occlusion-sibling-sized-chrome.test.ts b/packages/capture-kit/src/snapshot-occlusion-sibling-sized-chrome.test.ts index 5e801a2550..e8606434d0 100644 --- a/packages/capture-kit/src/snapshot-occlusion-sibling-sized-chrome.test.ts +++ b/packages/capture-kit/src/snapshot-occlusion-sibling-sized-chrome.test.ts @@ -617,15 +617,149 @@ test('a toolbar host enclosing the bars of a presentation stacked over it keeps for (const label of COVER_CONTROLS) assert.ok(!covered.includes(label)); }); -test('a toolbar host enclosing the bars of a presentation beneath it keeps covering', () => { +test('a toolbar host enclosing the bars of a presentation beneath it covers that presentation, not its own', () => { // The capture without the cover: a sheet host enclosing Home's bar and list, which sit before Home's - // own host, covers Home. It covers the sheet too, failing closed; iOS publishes no presentation - // beneath a sheet, so this shape is not captured live. + // own host, covers Home, including the tab bar listed right after Home's host, but not the sheet. const rows = COVER_OVER_SHEET_ROWS.filter(([index]) => !COVER_ROW_INDEXES.has(index)); const covered = coveredLabels(capturedTree(rows)); - assert.ok(covered.includes('Edit')); - assert.ok(covered.includes('Open medium sheet')); + for (const label of ['Edit', 'Open medium sheet', 'Tab Bar', 'Home']) { + assert.ok(covered.includes(label), `${label} sits beneath the sheet`); + } + for (const label of ['Close', 'Primary action', 'Row 1', 'Bottom']) { + assert.ok(!covered.includes(label), `${label} is on the sheet`); + } +}); + +// `snapshot --json` of an undimmed `formSheet` over a tab screen on an iOS 27 simulator, trimmed. It +// keeps the screen and tab bar beneath it in the capture, and no sibling matches the host's frame. +const UNDIMMED_SHEET_ROWS: CapturedNode[] = [ + [0, undefined, 'Application', 'UIApplication', 'Agent Device Tester', [0, 0, 402, 874]], + [1, 0, 'ScrollView', 'RCTEnhancedScrollView', undefined, [18, 62, 366, 729]], + [18, 1, 'Button', 'RCTViewComponentView', 'Open undimmed sheet', [34.33, 515, 333.33, 44.67]], + [26, 0, 'TabBar', 'UITabBar', 'Tab Bar', [0, 791, 402, 83]], + [35, 26, 'Button', '_UITabButton', 'Settings', [286.81, 795, 90.19, 54]], + [37, 0, 'Toolbar', '_UIFloatingBarContainerView', 'Toolbar', [0, 0, 402, 874]], + [38, 0, 'NavigationBar', 'UINavigationBar', 'Undimmed sheet', [0, 78, 402, 54]], + [40, 0, 'Other', 'RCTScrollViewComponentView', undefined, [0, 62, 402, 723.33]], + [41, 40, 'ScrollView', 'RCTEnhancedScrollView', undefined, [0, 62, 402, 723.33]], + [44, 41, 'TextField', 'RCTUITextField', 'Sheet name', [20.33, 107.33, 361.33, 51.33]], + [47, 41, 'Button', 'RCTViewComponentView', 'Close undimmed sheet', [20, 209, 362, 44.67]], + [52, 0, 'Button', 'RCTViewComponentView', 'Continue', [20, 797.33, 362, 44.67]], + [53, 0, 'Toolbar', '_UIFloatingBarContainerView', 'Toolbar', [0, 62, 402, 812]], +]; + +const UNDIMMED_SHEET_CONTROLS = [ + 'Undimmed sheet', + 'Sheet name', + 'Close undimmed sheet', + 'Continue', +]; + +test('the captured iOS 27 undimmed sheet keeps its controls pressable and covers the screen beneath', () => { + const covered = coveredLabels(capturedTree(UNDIMMED_SHEET_ROWS)); + + for (const label of UNDIMMED_SHEET_CONTROLS) { + assert.ok(!covered.includes(label), `${label} is on the sheet`); + } + for (const label of ['Open undimmed sheet', 'Tab Bar', 'Settings']) { + assert.ok(covered.includes(label), `${label} sits beneath the sheet`); + } +}); + +test('a tab bar listed right after the presenting host stays beneath the undimmed sheet', () => { + // The SwiftUI capture order: the presenting screen's tab bar follows that screen's host instead of + // preceding it. It still belongs to the screen beneath, so the sheet's host keeps covering it. + const tabBarRows = UNDIMMED_SHEET_ROWS.filter(([index]) => index === 26 || index === 35); + const rows = UNDIMMED_SHEET_ROWS.filter(([index]) => index !== 26 && index !== 35); + rows.splice(rows.findIndex(([index]) => index === 37) + 1, 0, ...tabBarRows); + const covered = coveredLabels(capturedTree(rows)); + + for (const label of ['Tab Bar', 'Settings']) { + assert.ok(covered.includes(label), `${label} sits beneath the sheet`); + } + for (const label of UNDIMMED_SHEET_CONTROLS) { + assert.ok(!covered.includes(label), `${label} is on the sheet`); + } +}); + +test("a sheet control listed before the sheet's first bar stays pressable", () => { + // A grabber and a leading button sit between the presenting host and the sheet's navigation bar. + // They belong to the sheet, so only a tab bar there is read as the screen beneath. + const rows = [...UNDIMMED_SHEET_ROWS]; + rows.splice( + rows.findIndex(([index]) => index === 37) + 1, + 0, + [60, 0, 'Button', '_UIGrabber', 'Sheet Grabber', [153, 64, 96, 10]], + [61, 0, 'Button', 'RCTViewComponentView', 'Leading action', [300, 140, 80, 36]], + ); + const covered = coveredLabels(capturedTree(rows)); + + for (const label of ['Sheet Grabber', 'Leading action', ...UNDIMMED_SHEET_CONTROLS]) { + assert.ok(!covered.includes(label), `${label} is on the sheet`); + } +}); + +test('a lone screen keeps its tab bar uncovered by a host with no presentation before it', () => { + // With no previous toolbar host there is no screen beneath, so the tab bar is the screen's own. + const nodes = capturedTree([ + [0, undefined, 'Application', 'UIApplication', 'App', [0, 0, 402, 874]], + [1, 0, 'TabBar', 'UITabBar', 'Tab Bar', [0, 791, 402, 83]], + [2, 1, 'Button', '_UITabButton', 'Home', [25, 795, 98, 54]], + [3, 0, 'NavigationBar', 'UINavigationBar', 'Title', [0, 62, 402, 54]], + [4, 0, 'CollectionView', 'UICollectionView', undefined, [0, 116, 402, 675]], + [5, 4, 'Button', 'UIButton', 'Row', [16, 132, 370, 52]], + [6, 0, 'Toolbar', '_UIFloatingBarContainerView', 'Toolbar', [0, 62, 402, 812]], + ]); + + assert.deepEqual(coveredLabels(nodes), []); +}); + +test('a bottom host enclosing nothing but a tab bar keeps that tab bar pressable', () => { + // A host after a viewport-sized one that hosts only the tab bar: with no other region of its own, + // the tab bar is its own presentation's, as before. + const nodes = capturedTree([ + [0, undefined, 'Application', 'UIApplication', 'App', [0, 0, 402, 874]], + [1, 0, 'NavigationBar', 'UINavigationBar', 'Title', [0, 62, 402, 54]], + [2, 0, 'CollectionView', 'UICollectionView', undefined, [0, 116, 402, 675]], + [3, 2, 'Button', 'UIButton', 'Row', [16, 132, 370, 52]], + [4, 0, 'Toolbar', '_UIFloatingBarContainerView', 'Toolbar', [0, 0, 402, 874]], + [5, 0, 'TabBar', 'UITabBar', 'Tab Bar', [0, 791, 402, 83]], + [6, 5, 'Button', '_UITabButton', 'Home', [25, 795, 98, 54]], + [7, 0, 'Toolbar', '_UIFloatingBarContainerView', 'Toolbar', [0, 700, 402, 174]], + ]); + + assert.deepEqual(coveredLabels(nodes), []); +}); + +test('a barless undimmed sheet still covers the tab bar listed right after the presenting host', () => { + // The sheet keeps only its footer button: no bar or scroll view of its own. The presenting screen's + // scroll view is still enclosed, so the tab bar after the presenting host stays beneath the sheet. + const tabBarRows = UNDIMMED_SHEET_ROWS.filter(([index]) => index === 26 || index === 35); + const rows = UNDIMMED_SHEET_ROWS.filter( + ([index]) => ![26, 35, 38, 40, 41, 44, 47].includes(index), + ); + rows.splice(rows.findIndex(([index]) => index === 37) + 1, 0, ...tabBarRows); + const covered = coveredLabels(capturedTree(rows)); + + for (const label of ['Tab Bar', 'Settings', 'Open undimmed sheet']) { + assert.ok(covered.includes(label), `${label} sits beneath the sheet`); + } + assert.ok(!covered.includes('Continue'), 'Continue is on the sheet'); +}); + +test('an undimmed sheet host stops exempting its own controls once a presentation is stacked over it', () => { + // Non-vacuity for the stacked direction: a bar listed after the host, inside its frame, belongs to a + // presentation drawn over the sheet, so the host keeps covering the sheet as before. + const rows: CapturedNode[] = [ + ...UNDIMMED_SHEET_ROWS, + [54, 0, 'NavigationBar', 'UINavigationBar', 'Upper sheet', [0, 88, 402, 54]], + ]; + const covered = coveredLabels(capturedTree(rows)); + + for (const label of ['Sheet name', 'Close undimmed sheet', 'Continue']) { + assert.ok(covered.includes(label), `${label} sits beneath the upper presentation`); + } }); test.for([ @@ -674,7 +808,7 @@ test.for([ ] satisfies { name: string; rows: CapturedNode[] }[])( 'the captured iOS 27 $name publishes only the top sheet, and none of it is covered', ({ rows }) => { - // iOS drops the presentation beneath a sheet from the capture, so no lower control gets a ref. + // iOS drops the presentation beneath a SwiftUI sheet from the capture, so no lower control gets a ref. assert.deepEqual(coveredLabels(capturedTree(rows)), []); }, ); diff --git a/packages/capture-kit/src/snapshot-occlusion.ts b/packages/capture-kit/src/snapshot-occlusion.ts index cd0bdeca99..fa8b24c813 100644 --- a/packages/capture-kit/src/snapshot-occlusion.ts +++ b/packages/capture-kit/src/snapshot-occlusion.ts @@ -34,6 +34,7 @@ const VIEWPORT_CHROME_KIND_FRAGMENTS = ['tabbar', 'toolbar', 'navigationbar']; */ const VIEWPORT_CHROME_TOP_INSET_PT = 4; const TOOLBAR_HOST_KIND_FRAGMENTS = ['toolbar']; +const TAB_BAR_KIND_FRAGMENTS = ['tabbar']; const SCROLL_INDICATOR_KIND_FRAGMENTS = ['scrollbar', 'scrollindicator']; const SEMANTIC_TOUCH_KIND_FRAGMENTS = [ 'button', @@ -77,6 +78,7 @@ type OcclusionScan = { type NeighbourhoodIndex = { byIndex: Map; childrenByParent: Map; + toolbarHostReach: Map; }; function collectNeighbourhoodIndex(nodes: readonly RawSnapshotNode[]): NeighbourhoodIndex { @@ -89,7 +91,7 @@ function collectNeighbourhoodIndex(nodes: readonly RawSnapshotNode[]): Neighbour if (siblings) siblings.push(node); else childrenByParent.set(node.parentIndex, [node]); } - return { byIndex, childrenByParent }; + return { byIndex, childrenByParent, toolbarHostReach: new Map() }; } export type SnapshotOcclusionOptions = { @@ -295,6 +297,7 @@ function visibleCoverRect( if (areRelatedSnapshotNodes(target, candidate, scan.byIndex)) return null; const candidateRect = positiveRect(candidate.rect); if (!candidateRect || areRectsApproximatelyEqual(targetRect, candidateRect)) return null; + if (isInToolbarHostOwnPresentation(candidate, target, scan)) return null; if (findCoveringNode(scan, candidatePosition, candidate, options)) return null; return candidateRect; } @@ -349,7 +352,7 @@ function isOverlayLikeNode( * gate keeps a `dialog`/`sheet`/`alert` sized to the content around it covering. * * Accepted limit for stacked presentations: the interactive projection lists them as siblings of one - * root. iOS drops what sits beneath a sheet from the capture, but keeps what sits beneath a + * root. iOS drops what sits beneath a SwiftUI sheet from the capture, but keeps what sits beneath a * full-screen cover, and the cover's toolbar host is viewport-sized, so the full-viewport exemption * lets it through. Beneath a cover, only the cover's own bars and a lower presentation's * non-exempt toolbar host still cover. @@ -374,29 +377,109 @@ function isSiblingSizedChromeContainer( } /** - * SwiftUI toolbar hosts draw their descendants, not their enclosing frame. Exempt a host only - * when it encloses bars or scroll containers from its own presentation: the siblings after the - * previous toolbar and before this host. Enclosing another presentation's regions keeps it covering. + * Toolbar hosts draw their descendants, not their enclosing frame, so a host covers nothing of its + * own presentation: the bars and scroll containers after the previous toolbar and before this host. + * A host that also encloses the presentation beneath it, which an undimmed sheet keeps in the + * capture, covers that presentation; after a previous toolbar, enclosed tab bars listed first belong + * to it unless they are all the host encloses. Enclosing a presentation stacked over the host keeps + * it covering. */ -function isOwnPresentationToolbarHost( +type ToolbarHostReach = + | { kind: 'own-presentation' } + | { kind: 'over-beneath'; parentIndex: number; ownBranchIndexes: ReadonlySet }; + +function toolbarHostReach( node: RawSnapshotNode, neighbourhood: NeighbourhoodIndex, -): boolean { - if (!nodeKindIncludesAny(node, TOOLBAR_HOST_KIND_FRAGMENTS)) return false; - if (typeof node.parentIndex !== 'number') return false; +): ToolbarHostReach | null { + const cached = neighbourhood.toolbarHostReach.get(node.index); + if (cached !== undefined) return cached; + const reach = classifyToolbarHostReach(node, neighbourhood); + neighbourhood.toolbarHostReach.set(node.index, reach); + return reach; +} + +function classifyToolbarHostReach( + node: RawSnapshotNode, + neighbourhood: NeighbourhoodIndex, +): ToolbarHostReach | null { + if (!nodeKindIncludesAny(node, TOOLBAR_HOST_KIND_FRAGMENTS)) return null; + if (typeof node.parentIndex !== 'number') return null; const rect = positiveRect(node.rect); - if (!rect) return false; + if (!rect) return null; const siblings = neighbourhood.childrenByParent.get(node.parentIndex)!; const position = siblings.findIndex((sibling) => sibling.index === node.index); - const ownStart = ownPresentationStart(siblings, position); + const enclosedPositions = siblings.flatMap((sibling, siblingPosition) => + siblingPosition !== position && isEnclosedHostedRegion(rect, sibling) ? [siblingPosition] : [], + ); + if (enclosedPositions.some((siblingPosition) => siblingPosition > position)) return null; - let hasHostedRegion = false; - for (const [siblingPosition, sibling] of siblings.entries()) { - if (siblingPosition === position || !isEnclosedHostedRegion(rect, sibling)) continue; - if (siblingPosition < ownStart || siblingPosition > position) return false; - hasHostedRegion = true; + const previousHostEnd = ownPresentationStart(siblings, position); + const ownEnclosed = enclosedPositions.filter( + (siblingPosition) => siblingPosition >= previousHostEnd, + ); + const beneathTabBars = new Set(); + if (previousHostEnd > 0) { + for (const siblingPosition of ownEnclosed) { + if (!nodeKindIncludesAny(siblings[siblingPosition]!, TAB_BAR_KIND_FRAGMENTS)) break; + beneathTabBars.add(siblingPosition); + } + } + if ( + beneathTabBars.size === ownEnclosed.length && + enclosedPositions.length === ownEnclosed.length + ) { + beneathTabBars.clear(); + } + if (ownEnclosed.length === 0) return null; + if (enclosedPositions.length === ownEnclosed.length && beneathTabBars.size === 0) { + return { kind: 'own-presentation' }; + } + return { + kind: 'over-beneath', + parentIndex: node.parentIndex, + ownBranchIndexes: new Set( + siblings + .slice(previousHostEnd, position) + .filter((_, offset) => !beneathTabBars.has(previousHostEnd + offset)) + .map((sibling) => sibling.index), + ), + }; +} + +function isOwnPresentationToolbarHost( + node: RawSnapshotNode, + neighbourhood: NeighbourhoodIndex, +): boolean { + return toolbarHostReach(node, neighbourhood)?.kind === 'own-presentation'; +} + +function isInToolbarHostOwnPresentation( + host: RawSnapshotNode, + target: RawSnapshotNode, + scan: OcclusionScan, +): boolean { + const reach = toolbarHostReach(host, scan.neighbourhood); + if (reach?.kind !== 'over-beneath') return false; + const branch = branchUnderParent(target, reach.parentIndex, scan.byIndex); + return branch !== undefined && reach.ownBranchIndexes.has(branch.index); +} + +/** The target itself or its ancestor that is a direct child of `parentIndex`. */ +function branchUnderParent( + node: RawSnapshotNode, + parentIndex: number, + byIndex: Map, +): RawSnapshotNode | undefined { + let current: RawSnapshotNode | undefined = node; + const visited = new Set(); + while (current && !visited.has(current.index)) { + if (current.parentIndex === parentIndex) return current; + visited.add(current.index); + current = + typeof current.parentIndex === 'number' ? byIndex.get(current.parentIndex) : undefined; } - return hasHostedRegion; + return undefined; } function ownPresentationStart(siblings: readonly RawSnapshotNode[], position: number): number { From c6693c5e76e8fbd335196bdedc46b2815003397e Mon Sep 17 00:00:00 2001 From: Justin Starner <9425563+jstarner@users.noreply.github.com> Date: Sun, 1 Nov 2026 14:32:12 -0500 Subject: [PATCH 2/3] fix(ios): keep a barless sheet's controls pressable An undimmed sheet with no bar or scroll view still gets a Toolbar host at its frame. That host encloses only the screen beneath, so it was not recognised as the sheet's host and covered the sheet's own controls. Read it as covering the presentation beneath whenever it encloses any region before the previous host. --- .changeset/undimmed-sheet-toolbar-host.md | 2 +- ...hot-occlusion-sibling-sized-chrome.test.ts | 51 +++++++++++++++++++ .../capture-kit/src/snapshot-occlusion.ts | 15 +++--- 3 files changed, 60 insertions(+), 8 deletions(-) diff --git a/.changeset/undimmed-sheet-toolbar-host.md b/.changeset/undimmed-sheet-toolbar-host.md index 7c9422b735..e95b98278b 100644 --- a/.changeset/undimmed-sheet-toolbar-host.md +++ b/.changeset/undimmed-sheet-toolbar-host.md @@ -2,4 +2,4 @@ 'agent-device': patch --- -Fix iOS 26/27 `press`, `click`, and `fill` refusing every control inside a sheet that keeps the screen beneath it in the capture (such as an undimmed sheet) as covered by the sheet's `Toolbar` host. The host now covers the screen beneath the sheet but not the sheet's own controls. A host that encloses a presentation stacked over it still covers everything before it. +Fix iOS 26/27 `press`, `click`, and `fill` refusing every control inside a sheet that keeps the screen beneath it in the capture (such as an undimmed sheet) as covered by the sheet's `Toolbar` host, when that host encloses a bar or scroll view. The host now covers the screen beneath the sheet but not the sheet's own controls. A host that encloses a presentation stacked over it still covers everything before it. diff --git a/packages/capture-kit/src/snapshot-occlusion-sibling-sized-chrome.test.ts b/packages/capture-kit/src/snapshot-occlusion-sibling-sized-chrome.test.ts index e8606434d0..839136ea34 100644 --- a/packages/capture-kit/src/snapshot-occlusion-sibling-sized-chrome.test.ts +++ b/packages/capture-kit/src/snapshot-occlusion-sibling-sized-chrome.test.ts @@ -748,6 +748,57 @@ test('a barless undimmed sheet still covers the tab bar listed right after the p assert.ok(!covered.includes('Continue'), 'Continue is on the sheet'); }); +test('the captured iOS 27 undimmed sheet with no bar or scroll view keeps its controls pressable', () => { + // `snapshot --json` of the `UNDIMMED_SHEET_ROWS` sheet with its header hidden and a plain view for + // content. Its host encloses only the screen beneath, so nothing of the sheet's own marks it. + const covered = coveredLabels( + capturedTree([ + [0, undefined, 'Application', 'UIApplication', 'Agent Device Tester', [0, 0, 402, 874]], + [1, 0, 'ScrollView', 'RCTEnhancedScrollView', undefined, [18, 62, 366, 729]], + [ + 27, + 1, + 'Button', + 'RCTViewComponentView', + 'Open undimmed sheet', + [34.33, 655.33, 333.33, 44.67], + ], + [34, 0, 'TabBar', 'UITabBar', 'Tab Bar', [0, 791, 402, 83]], + [43, 34, 'Button', '_UITabButton', 'Settings', [286.81, 795, 90.19, 54]], + [45, 0, 'Toolbar', '_UIFloatingBarContainerView', 'Toolbar', [0, 0, 402, 874]], + [46, 0, 'Other', 'RCTViewComponentView', undefined, [0, 62, 402, 211.67]], + [47, 0, 'StaticText', 'RCTParagraphComponentView', 'Sheet name', [20, 82, 362, 17]], + [49, 0, 'TextField', 'RCTUITextField', 'Sheet name', [20.33, 107.33, 361.33, 51.33]], + [50, 0, 'StaticText', 'RCTParagraphComponentView', 'Not continued', [20, 175, 362, 18]], + [52, 0, 'Button', 'RCTViewComponentView', 'Close undimmed sheet', [20, 209, 362, 44.67]], + [53, 0, 'Button', 'RCTViewComponentView', 'Continue', [20, 285.67, 362, 44.67]], + [54, 0, 'Toolbar', '_UIFloatingBarContainerView', 'Toolbar', [0, 62, 402, 812]], + ]), + ); + + for (const label of ['Sheet name', 'Not continued', 'Close undimmed sheet', 'Continue']) { + assert.ok(!covered.includes(label), `${label} is on the sheet`); + } + for (const label of ['Open undimmed sheet', 'Tab Bar', 'Settings']) { + assert.ok(covered.includes(label), `${label} sits beneath the sheet`); + } +}); + +test('a bar-height toolbar after a host that encloses nothing keeps covering the field under it', () => { + // A toolbar enclosing no bar or scroll view gives no evidence that it is a host, so it is read as an + // opaque bar even with a previous host before it. + const nodes = capturedTree([ + [0, undefined, 'Application', 'UIApplication', 'App', [0, 0, 402, 874]], + [1, 0, 'ScrollView', 'UIScrollView', undefined, [0, 62, 402, 812]], + [2, 1, 'Button', 'UIButton', 'Row', [16, 132, 370, 52]], + [3, 0, 'Toolbar', '_UIFloatingBarContainerView', 'Toolbar', [0, 0, 402, 874]], + [4, 0, 'TextField', 'UITextField', 'Field under accessory', [16, 505, 370, 34]], + [5, 0, 'Toolbar', 'UIToolbar', 'Accessory', [0, 500, 402, 44]], + ]); + + assert.deepEqual(coveredLabels(nodes), ['Field under accessory']); +}); + test('an undimmed sheet host stops exempting its own controls once a presentation is stacked over it', () => { // Non-vacuity for the stacked direction: a bar listed after the host, inside its frame, belongs to a // presentation drawn over the sheet, so the host keeps covering the sheet as before. diff --git a/packages/capture-kit/src/snapshot-occlusion.ts b/packages/capture-kit/src/snapshot-occlusion.ts index fa8b24c813..5611a43dae 100644 --- a/packages/capture-kit/src/snapshot-occlusion.ts +++ b/packages/capture-kit/src/snapshot-occlusion.ts @@ -377,12 +377,13 @@ function isSiblingSizedChromeContainer( } /** - * Toolbar hosts draw their descendants, not their enclosing frame, so a host covers nothing of its - * own presentation: the bars and scroll containers after the previous toolbar and before this host. - * A host that also encloses the presentation beneath it, which an undimmed sheet keeps in the - * capture, covers that presentation; after a previous toolbar, enclosed tab bars listed first belong - * to it unless they are all the host encloses. Enclosing a presentation stacked over the host keeps - * it covering. + * Toolbar hosts draw their descendants, not their enclosing frame. A host that encloses bars or + * scroll containers of its own presentation, the siblings after the previous toolbar and before + * this host, covers nothing of it. A host that encloses the presentation beneath it, which an + * undimmed sheet keeps in the capture, covers only that presentation; after a previous toolbar, + * enclosed tab bars listed first belong to it unless they are all the host encloses. A host that + * encloses nothing, or a presentation stacked over it, keeps covering. Like the sibling-sized + * exemption, this cannot tell an opaque toolbar from a host. */ type ToolbarHostReach = | { kind: 'own-presentation' } @@ -412,6 +413,7 @@ function classifyToolbarHostReach( const enclosedPositions = siblings.flatMap((sibling, siblingPosition) => siblingPosition !== position && isEnclosedHostedRegion(rect, sibling) ? [siblingPosition] : [], ); + if (enclosedPositions.length === 0) return null; if (enclosedPositions.some((siblingPosition) => siblingPosition > position)) return null; const previousHostEnd = ownPresentationStart(siblings, position); @@ -431,7 +433,6 @@ function classifyToolbarHostReach( ) { beneathTabBars.clear(); } - if (ownEnclosed.length === 0) return null; if (enclosedPositions.length === ownEnclosed.length && beneathTabBars.size === 0) { return { kind: 'own-presentation' }; } From 67e7ca48075335aec947912c867be2a7d3268ec3 Mon Sep 17 00:00:00 2001 From: Justin Starner <9425563+jstarner@users.noreply.github.com> Date: Sun, 1 Nov 2026 14:50:42 -0500 Subject: [PATCH 3/3] fix(ios): read a leading tab bar as beneath only over a screen beneath A host whose own presentation lists its tab bar first, with nothing before the previous host enclosed, became over-beneath and covered that tab bar. Skip leading tab bars only when the host also encloses a region of the screen beneath, which also makes the all-tab-bars special case unnecessary. Move the doc comment onto the function it describes, and reword the changeset so it covers sheets without bars of their own. --- .changeset/undimmed-sheet-toolbar-host.md | 2 +- ...hot-occlusion-sibling-sized-chrome.test.ts | 17 +++++++++ .../capture-kit/src/snapshot-occlusion.ts | 36 +++++++------------ 3 files changed, 31 insertions(+), 24 deletions(-) diff --git a/.changeset/undimmed-sheet-toolbar-host.md b/.changeset/undimmed-sheet-toolbar-host.md index e95b98278b..fa2a795faf 100644 --- a/.changeset/undimmed-sheet-toolbar-host.md +++ b/.changeset/undimmed-sheet-toolbar-host.md @@ -2,4 +2,4 @@ 'agent-device': patch --- -Fix iOS 26/27 `press`, `click`, and `fill` refusing every control inside a sheet that keeps the screen beneath it in the capture (such as an undimmed sheet) as covered by the sheet's `Toolbar` host, when that host encloses a bar or scroll view. The host now covers the screen beneath the sheet but not the sheet's own controls. A host that encloses a presentation stacked over it still covers everything before it. +Fix iOS 26/27 `press`, `click`, and `fill` refusing every control inside a sheet that keeps the screen beneath it in the capture (such as an undimmed sheet), with or without bars or a scroll view of its own, as covered by the sheet's `Toolbar` host. The host now covers the screen beneath the sheet but not the sheet's own controls. A host that encloses no bar or scroll view, or a presentation stacked over it, still covers. diff --git a/packages/capture-kit/src/snapshot-occlusion-sibling-sized-chrome.test.ts b/packages/capture-kit/src/snapshot-occlusion-sibling-sized-chrome.test.ts index 839136ea34..28fc27a062 100644 --- a/packages/capture-kit/src/snapshot-occlusion-sibling-sized-chrome.test.ts +++ b/packages/capture-kit/src/snapshot-occlusion-sibling-sized-chrome.test.ts @@ -715,6 +715,23 @@ test('a lone screen keeps its tab bar uncovered by a host with no presentation b assert.deepEqual(coveredLabels(nodes), []); }); +test('a host listing its own tab bar first keeps it pressable when it encloses nothing beneath', () => { + // After a previous host, a tab bar listed first counts as the screen beneath only when the host also + // encloses a region before that previous host. + const nodes = capturedTree([ + [0, undefined, 'Application', 'UIApplication', 'App', [0, 0, 402, 874]], + [1, 0, 'Toolbar', '_UIFloatingBarContainerView', 'Toolbar', [0, 0, 402, 874]], + [2, 0, 'TabBar', 'UITabBar', 'Tab Bar', [0, 791, 402, 83]], + [3, 2, 'Button', '_UITabButton', 'Home', [25, 795, 98, 54]], + [4, 0, 'NavigationBar', 'UINavigationBar', 'Title', [0, 62, 402, 54]], + [5, 0, 'CollectionView', 'UICollectionView', undefined, [0, 116, 402, 675]], + [6, 5, 'Button', 'UIButton', 'Row', [16, 132, 370, 52]], + [7, 0, 'Toolbar', '_UIFloatingBarContainerView', 'Toolbar', [0, 62, 402, 812]], + ]); + + assert.deepEqual(coveredLabels(nodes), []); +}); + test('a bottom host enclosing nothing but a tab bar keeps that tab bar pressable', () => { // A host after a viewport-sized one that hosts only the tab bar: with no other region of its own, // the tab bar is its own presentation's, as before. diff --git a/packages/capture-kit/src/snapshot-occlusion.ts b/packages/capture-kit/src/snapshot-occlusion.ts index 5611a43dae..dec0c4f148 100644 --- a/packages/capture-kit/src/snapshot-occlusion.ts +++ b/packages/capture-kit/src/snapshot-occlusion.ts @@ -376,15 +376,6 @@ function isSiblingSizedChromeContainer( ); } -/** - * Toolbar hosts draw their descendants, not their enclosing frame. A host that encloses bars or - * scroll containers of its own presentation, the siblings after the previous toolbar and before - * this host, covers nothing of it. A host that encloses the presentation beneath it, which an - * undimmed sheet keeps in the capture, covers only that presentation; after a previous toolbar, - * enclosed tab bars listed first belong to it unless they are all the host encloses. A host that - * encloses nothing, or a presentation stacked over it, keeps covering. Like the sibling-sized - * exemption, this cannot tell an opaque toolbar from a host. - */ type ToolbarHostReach = | { kind: 'own-presentation' } | { kind: 'over-beneath'; parentIndex: number; ownBranchIndexes: ReadonlySet }; @@ -400,6 +391,15 @@ function toolbarHostReach( return reach; } +/** + * Toolbar hosts draw their descendants, not their enclosing frame. A host that encloses bars or + * scroll containers of its own presentation, the siblings after the previous toolbar and before + * this host, covers nothing of it. A host that encloses the presentation beneath it, which an + * undimmed sheet keeps in the capture, covers only that presentation, including enclosed tab bars + * listed first after the previous toolbar. A host that encloses nothing, or a presentation stacked + * over it, keeps covering. Like the sibling-sized exemption, this cannot tell an opaque toolbar + * from a host. + */ function classifyToolbarHostReach( node: RawSnapshotNode, neighbourhood: NeighbourhoodIndex, @@ -420,21 +420,11 @@ function classifyToolbarHostReach( const ownEnclosed = enclosedPositions.filter( (siblingPosition) => siblingPosition >= previousHostEnd, ); + if (ownEnclosed.length === enclosedPositions.length) return { kind: 'own-presentation' }; const beneathTabBars = new Set(); - if (previousHostEnd > 0) { - for (const siblingPosition of ownEnclosed) { - if (!nodeKindIncludesAny(siblings[siblingPosition]!, TAB_BAR_KIND_FRAGMENTS)) break; - beneathTabBars.add(siblingPosition); - } - } - if ( - beneathTabBars.size === ownEnclosed.length && - enclosedPositions.length === ownEnclosed.length - ) { - beneathTabBars.clear(); - } - if (enclosedPositions.length === ownEnclosed.length && beneathTabBars.size === 0) { - return { kind: 'own-presentation' }; + for (const siblingPosition of ownEnclosed) { + if (!nodeKindIncludesAny(siblings[siblingPosition]!, TAB_BAR_KIND_FRAGMENTS)) break; + beneathTabBars.add(siblingPosition); } return { kind: 'over-beneath',