From 98cb41054ba78c37d7de5e8798fed4c9586374a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pierzcha=C5=82a?= Date: Wed, 11 Nov 2026 08:27:04 +0100 Subject: [PATCH 1/5] fix(capture): exempt floating chrome above bottom tabs --- ...hot-occlusion-sibling-sized-chrome.test.ts | 59 +++++++++++++++++++ .../capture-kit/src/snapshot-occlusion.ts | 37 +++++++++++- 2 files changed, 93 insertions(+), 3 deletions(-) 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 28fc27a062..b80f65f484 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 @@ -925,3 +925,62 @@ test('a control the exempt toolbar host really hosts still covers the row it ove assert.deepEqual(coveredLabels(nodes), ['Barless row 12']); }); + +function projectedTabsTree(): RawSnapshotNode[] { + return capturedTree([ + [0, undefined, 'Application', '', undefined, [0, 0, 402, 874]], + [1, 0, 'StaticText', '', 'Home', [177, 71, 47, 20]], + [2, 0, 'StaticText', '', 'home-tab-content', [173, 422, 55, 24]], + [3, 0, 'StaticText', '', 'Go to the Actions tab', [53, 454, 297, 16]], + [4, 0, 'Toolbar', '', 'Toolbar', [0, 0, 402, 791]], + [5, 0, 'Button', '', 'Home, tab, 1 of 3', [0, 791, 134, 49]], + [6, 0, 'Button', '', 'Feed, tab, 2 of 3', [134, 791, 134, 49]], + [7, 0, 'Button', '', 'Actions, tab, 3 of 3', [268, 791, 134, 49]], + [8, 0, 'Toolbar', '', 'Toolbar', [0, 0, 402, 874]], + ]); +} + +test('projected tab content remains uncovered above the adjoining bottom tab buttons (#4365)', () => { + const annotated = annotateCoveredSnapshotNodes(projectedTabsTree()); + for (const index of [1, 2, 3, 5, 6, 7]) { + assert.equal( + annotated.find((candidate) => candidate.index === index)?.interactionBlocked, + undefined, + ); + } +}); + +test('a real toolbar over content remains covering despite an adjoining control (#4365)', () => { + const nodes = projectedTabsTree(); + nodes[4]!.rect = { x: 0, y: 0, width: 402, height: 300 }; + nodes[5]!.rect = { x: 0, y: 300, width: 134, height: 49 }; + assert.equal(annotateCoveredSnapshotNodes(nodes)[1]?.interactionBlocked, 'covered'); +}); + +test('a control hosted by the projected floating container still covers content (#4365)', () => { + const nodes = projectedTabsTree(); + nodes.splice( + 5, + 0, + node({ + index: 9, + parentIndex: 4, + depth: 2, + type: 'Toolbar', + label: 'Action', + rect: { x: 160, y: 60, width: 100, height: 50 }, + hittable: true, + }), + ); + assert.equal( + annotateCoveredSnapshotNodes(nodes).find((candidate) => candidate.index === 1) + ?.interactionBlocked, + 'covered', + ); +}); + +test('a sheet with the same footprint and adjoining tab buttons still covers content (#4365)', () => { + const nodes = projectedTabsTree(); + nodes[4]!.type = 'Sheet'; + assert.equal(annotateCoveredSnapshotNodes(nodes)[1]?.interactionBlocked, 'covered'); +}); diff --git a/packages/capture-kit/src/snapshot-occlusion.ts b/packages/capture-kit/src/snapshot-occlusion.ts index 7d9aef1526..fcba952f3f 100644 --- a/packages/capture-kit/src/snapshot-occlusion.ts +++ b/packages/capture-kit/src/snapshot-occlusion.ts @@ -334,7 +334,7 @@ function isOverlayLikeNode( ): boolean { if (!positiveRect(node.rect)) return false; if (isViewportRootNode(node)) return false; - if (isFullViewportChromeContainer(node, neighbourhood.byIndex)) return false; + if (isFullViewportChromeContainer(node, neighbourhood)) return false; if (isSiblingSizedChromeContainer(node, neighbourhood)) return false; if (isOwnPresentationToolbarHost(node, neighbourhood)) return false; // This is a presentation-order heuristic: only known floating UI chrome should cover @@ -501,18 +501,23 @@ function isEnclosedHostedRegion(rect: Rect, node: RawSnapshotNode): boolean { function isFullViewportChromeContainer( node: RawSnapshotNode, - byIndex: Map, + neighbourhood: NeighbourhoodIndex, ): boolean { if (!nodeKindIncludesAny(node, VIEWPORT_CHROME_KIND_FRAGMENTS)) return false; const rect = positiveRect(node.rect); if (!rect) return false; + const byIndex = neighbourhood.byIndex; let current = typeof node.parentIndex === 'number' ? byIndex.get(node.parentIndex) : undefined; const visited = new Set(); while (current && !visited.has(current.index)) { if (isViewportRootNode(current)) { const viewportRect = positiveRect(current.rect); - return Boolean(viewportRect && isViewportFootprint(rect, viewportRect)); + return Boolean( + viewportRect && + (isViewportFootprint(rect, viewportRect) || + isViewportAboveBottomBar(node, rect, viewportRect, neighbourhood)), + ); } visited.add(current.index); current = @@ -521,6 +526,32 @@ function isFullViewportChromeContainer( return false; } +function isViewportAboveBottomBar( + node: RawSnapshotNode, + rect: Rect, + viewport: Rect, + neighbourhood: NeighbourhoodIndex, +): boolean { + const bottom = rect.y + rect.height; + if (bottom <= viewport.y + viewport.height / 2 || bottom >= viewport.y + viewport.height) + return false; + if (!isViewportFootprint(rect, { ...viewport, height: bottom - viewport.y })) return false; + const siblings = neighbourhood.childrenByParent.get(node.parentIndex ?? -1) ?? []; + return siblings.some((sibling) => { + if (!nodeKindIncludesAny(sibling, ['button', 'tabitem', 'tabbar'])) return false; + const bar = positiveRect(sibling.rect); + if (!bar) return false; + return ( + Math.abs(bar.y - bottom) <= 0.5 && + bar.x >= viewport.x && + bar.x + bar.width <= viewport.x + viewport.width && + bar.height <= viewport.height / 4 && + bar.y + bar.height >= viewport.y + viewport.height * 0.9 && + bar.y + bar.height <= viewport.y + viewport.height + 0.5 + ); + }); +} + function isAdditionalOverlayRootNode( node: RawSnapshotNode, byIndex: Map, From 0f4f2ad1a944c65dbfe4cc2ff76ef08caa52b177 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pierzcha=C5=82a?= Date: Wed, 11 Nov 2026 08:42:36 +0100 Subject: [PATCH 2/5] fix(capture): require a complete bottom tab row --- ...hot-occlusion-sibling-sized-chrome.test.ts | 8 ++++++ .../capture-kit/src/snapshot-occlusion.ts | 26 ++++++++++++++----- 2 files changed, 28 insertions(+), 6 deletions(-) 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 b80f65f484..b42f47cb66 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 @@ -984,3 +984,11 @@ test('a sheet with the same footprint and adjoining tab buttons still covers con nodes[4]!.type = 'Sheet'; assert.equal(annotateCoveredSnapshotNodes(nodes)[1]?.interactionBlocked, 'covered'); }); + +test('a single bottom CTA does not exempt a covering toolbar (#4365)', () => { + const nodes = projectedTabsTree(); + nodes.splice(6, 2); + nodes[5]!.label = 'Continue'; + nodes[5]!.rect = { x: 0, y: 791, width: 402, height: 49 }; + assert.equal(annotateCoveredSnapshotNodes(nodes)[1]?.interactionBlocked, 'covered'); +}); diff --git a/packages/capture-kit/src/snapshot-occlusion.ts b/packages/capture-kit/src/snapshot-occlusion.ts index fcba952f3f..72703b7307 100644 --- a/packages/capture-kit/src/snapshot-occlusion.ts +++ b/packages/capture-kit/src/snapshot-occlusion.ts @@ -537,19 +537,33 @@ function isViewportAboveBottomBar( return false; if (!isViewportFootprint(rect, { ...viewport, height: bottom - viewport.y })) return false; const siblings = neighbourhood.childrenByParent.get(node.parentIndex ?? -1) ?? []; - return siblings.some((sibling) => { - if (!nodeKindIncludesAny(sibling, ['button', 'tabitem', 'tabbar'])) return false; + const buttons = siblings.flatMap((sibling) => { + if (!nodeKindIncludesAny(sibling, ['button'])) return []; const bar = positiveRect(sibling.rect); - if (!bar) return false; - return ( - Math.abs(bar.y - bottom) <= 0.5 && + if (!bar) return []; + return Math.abs(bar.y - bottom) <= 0.5 && bar.x >= viewport.x && bar.x + bar.width <= viewport.x + viewport.width && bar.height <= viewport.height / 4 && bar.y + bar.height >= viewport.y + viewport.height * 0.9 && bar.y + bar.height <= viewport.y + viewport.height + 0.5 - ); + ? [bar] + : []; }); + buttons.sort((a, b) => a.x - b.x); + if (buttons.length < 2 || Math.abs(buttons[0]!.x - viewport.x) > 0.5) return false; + let edge = viewport.x; + const first = buttons[0]!; + for (const button of buttons) { + if ( + Math.abs(button.x - edge) > 0.5 || + Math.abs(button.y - first.y) > 0.5 || + Math.abs(button.height - first.height) > 0.5 + ) + return false; + edge = button.x + button.width; + } + return Math.abs(edge - (viewport.x + viewport.width)) <= 0.5; } function isAdditionalOverlayRootNode( From 30e391521ef016549d3d076380a4cd80aa62d064 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pierzcha=C5=82a?= Date: Wed, 11 Nov 2026 08:50:38 +0100 Subject: [PATCH 3/5] fix(capture): recognize tiled tab items --- ...apshot-occlusion-sibling-sized-chrome.test.ts | 16 ++++++++++------ packages/capture-kit/src/snapshot-occlusion.ts | 2 +- 2 files changed, 11 insertions(+), 7 deletions(-) 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 b42f47cb66..974ad3da1b 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 @@ -941,12 +941,16 @@ function projectedTabsTree(): RawSnapshotNode[] { } test('projected tab content remains uncovered above the adjoining bottom tab buttons (#4365)', () => { - const annotated = annotateCoveredSnapshotNodes(projectedTabsTree()); - for (const index of [1, 2, 3, 5, 6, 7]) { - assert.equal( - annotated.find((candidate) => candidate.index === index)?.interactionBlocked, - undefined, - ); + for (const type of ['Button', 'TabItem']) { + const nodes = projectedTabsTree(); + for (const index of [5, 6, 7]) nodes[index]!.type = type; + const annotated = annotateCoveredSnapshotNodes(nodes); + for (const index of [1, 2, 3, 5, 6, 7]) { + assert.equal( + annotated.find((candidate) => candidate.index === index)?.interactionBlocked, + undefined, + ); + } } }); diff --git a/packages/capture-kit/src/snapshot-occlusion.ts b/packages/capture-kit/src/snapshot-occlusion.ts index 72703b7307..037d22af62 100644 --- a/packages/capture-kit/src/snapshot-occlusion.ts +++ b/packages/capture-kit/src/snapshot-occlusion.ts @@ -538,7 +538,7 @@ function isViewportAboveBottomBar( if (!isViewportFootprint(rect, { ...viewport, height: bottom - viewport.y })) return false; const siblings = neighbourhood.childrenByParent.get(node.parentIndex ?? -1) ?? []; const buttons = siblings.flatMap((sibling) => { - if (!nodeKindIncludesAny(sibling, ['button'])) return []; + if (!nodeKindIncludesAny(sibling, ['button', 'tabitem'])) return []; const bar = positiveRect(sibling.rect); if (!bar) return []; return Math.abs(bar.y - bottom) <= 0.5 && From 96a677586108cce34e9644ae15dbfab20db2b7ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pierzcha=C5=82a?= Date: Wed, 11 Nov 2026 08:53:07 +0100 Subject: [PATCH 4/5] fix(capture): restrict bottom row exemption to floating hosts --- ...hot-occlusion-sibling-sized-chrome.test.ts | 28 ++++++++----------- .../capture-kit/src/snapshot-occlusion.ts | 5 +++- 2 files changed, 16 insertions(+), 17 deletions(-) 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 974ad3da1b..e5c501e7ad 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 @@ -3,21 +3,6 @@ import { test } from 'vitest'; import type { RawSnapshotNode, Rect } from '@agent-device/kernel/snapshot'; import { annotateCoveredSnapshotNodes } from './snapshot-occlusion.ts'; -// The sibling-sized-chrome family of `snapshot-occlusion.test.ts`: every test here drives the rule -// through `annotateCoveredSnapshotNodes`, which owns it as a private classification step. The rule -// stays inside that module because the eager-closure gate (#1739, ADR-0019) forbids a new module in -// the closure of a published entry surface, and `snapshot-occlusion.ts` is one. -// -// #2996: on iOS 26/27 UIKit hosts a bottom tab bar in a `_UIFloatingBarContainerView` (published as -// `type: 'Toolbar'`) that is a SIBLING of the tab screen's content branch under the same layout -// container, sized to that branch's frame. The reporter's capture shows `0,0,402,791` beside a -// `0,0,402,791` content branch with the 83pt tab bar at y=791 outside both; the two "live shape" -// tests carry trees captured on an iPhone 18 Pro (iOS 27.0). The container reports `hittable: true` -// and passes touches through, so `press`/`fill` refused every element above the tab bar while a -// coordinate press at the same point worked. The existing `isFullViewportChromeContainer` exemption -// compares the candidate against the viewport root, and such a container deliberately stops short -// of it, so the sibling-level rule owns this case. - type NodeSpec = { index: number; parentIndex?: number; @@ -932,7 +917,7 @@ function projectedTabsTree(): RawSnapshotNode[] { [1, 0, 'StaticText', '', 'Home', [177, 71, 47, 20]], [2, 0, 'StaticText', '', 'home-tab-content', [173, 422, 55, 24]], [3, 0, 'StaticText', '', 'Go to the Actions tab', [53, 454, 297, 16]], - [4, 0, 'Toolbar', '', 'Toolbar', [0, 0, 402, 791]], + [4, 0, 'Toolbar', '_UIFloatingBarContainerView', 'Toolbar', [0, 0, 402, 791]], [5, 0, 'Button', '', 'Home, tab, 1 of 3', [0, 791, 134, 49]], [6, 0, 'Button', '', 'Feed, tab, 2 of 3', [134, 791, 134, 49]], [7, 0, 'Button', '', 'Actions, tab, 3 of 3', [268, 791, 134, 49]], @@ -996,3 +981,14 @@ test('a single bottom CTA does not exempt a covering toolbar (#4365)', () => { nodes[5]!.rect = { x: 0, y: 791, width: 402, height: 49 }; assert.equal(annotateCoveredSnapshotNodes(nodes)[1]?.interactionBlocked, 'covered'); }); + +test('an ordinary toolbar above a two-button action row still covers content (#4365)', () => { + const nodes = projectedTabsTree(); + nodes[4]!.role = ''; + nodes.splice(7, 1); + nodes[5]!.rect = { x: 0, y: 791, width: 201, height: 49 }; + nodes[6]!.rect = { x: 201, y: 791, width: 201, height: 49 }; + nodes[5]!.label = 'Cancel'; + nodes[6]!.label = 'Confirm'; + assert.equal(annotateCoveredSnapshotNodes(nodes)[1]?.interactionBlocked, 'covered'); +}); diff --git a/packages/capture-kit/src/snapshot-occlusion.ts b/packages/capture-kit/src/snapshot-occlusion.ts index 037d22af62..264de4b0b1 100644 --- a/packages/capture-kit/src/snapshot-occlusion.ts +++ b/packages/capture-kit/src/snapshot-occlusion.ts @@ -526,17 +526,20 @@ function isFullViewportChromeContainer( return false; } +// The floating host can end at a complete bottom tab row after projection removes its content sibling. function isViewportAboveBottomBar( node: RawSnapshotNode, rect: Rect, viewport: Rect, neighbourhood: NeighbourhoodIndex, ): boolean { + if (node.role !== '_UIFloatingBarContainerView' || typeof node.parentIndex !== 'number') + return false; const bottom = rect.y + rect.height; if (bottom <= viewport.y + viewport.height / 2 || bottom >= viewport.y + viewport.height) return false; if (!isViewportFootprint(rect, { ...viewport, height: bottom - viewport.y })) return false; - const siblings = neighbourhood.childrenByParent.get(node.parentIndex ?? -1) ?? []; + const siblings = neighbourhood.childrenByParent.get(node.parentIndex) ?? []; const buttons = siblings.flatMap((sibling) => { if (!nodeKindIncludesAny(sibling, ['button', 'tabitem'])) return []; const bar = positiveRect(sibling.rect); From db450150326d79b5b7c97eeeb9d4297f2329ef83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pierzcha=C5=82a?= Date: Wed, 11 Nov 2026 10:48:49 +0100 Subject: [PATCH 5/5] test(capture): preserve live bottom tabs projection --- ...napshot-occlusion-bottom-tabs.fixture.json | 158 ++++++++++++++++++ ...hot-occlusion-sibling-sized-chrome.test.ts | 56 +++---- .../capture-kit/src/snapshot-occlusion.ts | 6 +- 3 files changed, 183 insertions(+), 37 deletions(-) create mode 100644 packages/capture-kit/src/snapshot-occlusion-bottom-tabs.fixture.json diff --git a/packages/capture-kit/src/snapshot-occlusion-bottom-tabs.fixture.json b/packages/capture-kit/src/snapshot-occlusion-bottom-tabs.fixture.json new file mode 100644 index 0000000000..e28a6aca9f --- /dev/null +++ b/packages/capture-kit/src/snapshot-occlusion-bottom-tabs.fixture.json @@ -0,0 +1,158 @@ +[ + { + "index": 0, + "type": "Application", + "role": "UIApplication", + "label": "e2e Benchmark", + "rect": { + "x": 0, + "y": 0, + "width": 402, + "height": 874 + }, + "enabled": true, + "depth": 0, + "hittable": false + }, + { + "index": 1, + "parentIndex": 0, + "type": "StaticText", + "role": "RCTParagraphComponentView", + "subrole": "UIView", + "label": "Home", + "rect": { + "x": 177.3333282470703, + "y": 71, + "width": 47.333343505859375, + "height": 20.333335876464844 + }, + "enabled": true, + "depth": 1, + "hittable": true + }, + { + "index": 2, + "parentIndex": 0, + "type": "StaticText", + "role": "RCTParagraphComponentView", + "subrole": "UIView", + "label": "Home", + "identifier": "home-tab-content", + "rect": { + "x": 173.3333282470703, + "y": 422.00000762939453, + "width": 55, + "height": 24 + }, + "enabled": true, + "depth": 1, + "hittable": true + }, + { + "index": 3, + "parentIndex": 0, + "type": "StaticText", + "role": "RCTParagraphComponentView", + "subrole": "UIView", + "label": "Go to the Actions tab and press the button there.", + "rect": { + "x": 52.66666793823242, + "y": 454.00000762939453, + "width": 296.66668701171875, + "height": 15.666656494140625 + }, + "enabled": true, + "depth": 1, + "hittable": true + }, + { + "index": 4, + "parentIndex": 0, + "type": "Toolbar", + "role": "_UIFloatingBarContainerView", + "label": "Toolbar", + "identifier": "Toolbar", + "rect": { + "x": 0, + "y": 0, + "width": 402, + "height": 791 + }, + "enabled": true, + "depth": 1, + "hittable": true + }, + { + "index": 5, + "parentIndex": 0, + "type": "Button", + "role": "RCTViewComponentView", + "subrole": "UIView", + "label": "Home, tab, 1 of 3", + "identifier": "tab-home", + "rect": { + "x": 0, + "y": 791.3333333432674, + "width": 134, + "height": 48.66668701171875 + }, + "enabled": true, + "selected": true, + "depth": 1, + "hittable": true + }, + { + "index": 6, + "parentIndex": 0, + "type": "Button", + "role": "RCTViewComponentView", + "subrole": "UIView", + "label": "Feed, tab, 2 of 3", + "identifier": "tab-feed", + "rect": { + "x": 134, + "y": 791.3333333432674, + "width": 134, + "height": 48.66668701171875 + }, + "enabled": true, + "depth": 1, + "hittable": true + }, + { + "index": 7, + "parentIndex": 0, + "type": "Button", + "role": "RCTViewComponentView", + "subrole": "UIView", + "label": "Actions, tab, 3 of 3", + "identifier": "tab-actions", + "rect": { + "x": 268, + "y": 791.3333333432674, + "width": 134, + "height": 48.66668701171875 + }, + "enabled": true, + "depth": 1, + "hittable": true + }, + { + "index": 8, + "parentIndex": 0, + "type": "Toolbar", + "role": "_UIFloatingBarContainerView", + "label": "Toolbar", + "identifier": "Toolbar", + "rect": { + "x": 0, + "y": 0, + "width": 402, + "height": 874 + }, + "enabled": true, + "depth": 1, + "hittable": true + } +] 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 e5c501e7ad..e0bb8aa030 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 @@ -1,8 +1,24 @@ import assert from 'node:assert/strict'; +import { readFileSync } from 'node:fs'; import { test } from 'vitest'; import type { RawSnapshotNode, Rect } from '@agent-device/kernel/snapshot'; import { annotateCoveredSnapshotNodes } from './snapshot-occlusion.ts'; +// The sibling-sized-chrome family of `snapshot-occlusion.test.ts`: every test here drives the rule +// through `annotateCoveredSnapshotNodes`, which owns it as a private classification step. The rule +// stays inside that module because the eager-closure gate (#1739, ADR-0019) forbids a new module in +// the closure of a published entry surface, and `snapshot-occlusion.ts` is one. +// +// #2996: on iOS 26/27 UIKit hosts a bottom tab bar in a `_UIFloatingBarContainerView` (published as +// `type: 'Toolbar'`) that is a SIBLING of the tab screen's content branch under the same layout +// container, sized to that branch's frame. The reporter's capture shows `0,0,402,791` beside a +// `0,0,402,791` content branch with the 83pt tab bar at y=791 outside both; the two "live shape" +// tests carry trees captured on an iPhone 18 Pro (iOS 27.0). The container reports `hittable: true` +// and passes touches through, so `press`/`fill` refused every element above the tab bar while a +// coordinate press at the same point worked. The existing `isFullViewportChromeContainer` exemption +// compares the candidate against the viewport root, and such a container deliberately stops short +// of it, so the sibling-level rule owns this case. + type NodeSpec = { index: number; parentIndex?: number; @@ -119,10 +135,6 @@ function targetVerdict(nodes: RawSnapshotNode[]): RawSnapshotNode | undefined { } test("a chrome container sized to its content sibling branch does not cover that branch's targets (#2996)", () => { - // The reporter's capture: the container is 791pt tall, matching the content branch beside it and - // stopping 83pt short of the 874pt viewport the existing exemption keys on. The four publications - // of the chrome kind are pinned by the table below, so this pins the geometry and the target's own - // readback. const annotated = targetVerdict( chromeHostTree({ branchRect: BRANCH, chromeRole: '_UIFloatingBarContainerView' }), ); @@ -132,9 +144,6 @@ test("a chrome container sized to its content sibling branch does not cover that }); test('a control the exempt container really hosts still covers what it overlaps (#2996)', () => { - // The exemption excuses the container's OWN box, not its subtree: a hosted strip with its own - // smaller rect is unrelated to the target and differs from the branch frame, so it keeps covering - // the content beneath it — the fix cannot trade false refusals for missed real occlusion. const nodes = chromeHostTree({ targetRect: { x: 151, y: 700, width: 100, height: 32 }, chromeRole: '_UIFloatingBarContainerView', @@ -156,9 +165,6 @@ test('a control the exempt container really hosts still covers what it overlaps }); test('a chrome candidate whose frame differs from the content branch beside it still covers (#2996 non-vacuity)', () => { - // Isolates frame-EQUALITY from mere overlap: the container stops 60pt short of the branch, so it - // matches neither the branch nor the viewport, and its box is real covering evidence over the - // target in the region they share. const nodes = chromeHostTree({ branchRect: BRANCH, chromeRect: { x: 0, y: 0, width: 402, height: 731 }, @@ -169,9 +175,6 @@ test('a chrome candidate whose frame differs from the content branch beside it s }); test('a chrome candidate taller than the content branch beside it still covers, so equality is not overlap (#2996 containment)', () => { - // The mirror must be the SAME frame, not merely containing it. The container reaches 91pt below - // the branch while stopping short of the viewport, so it paints over the branch's lower edge and - // keeps covering the target inside that edge. const nodes = chromeHostTree({ branchRect: { x: 0, y: 0, width: 402, height: 700 }, chromeRect: BRANCH, @@ -183,8 +186,6 @@ test('a chrome candidate taller than the content branch beside it still covers, }); test('a full-screen dialog sized to the content branch beside it still covers, because only chrome kinds are exempt (#2996 kind gate)', () => { - // A `Dialog` sibling that fills the branch is a real modal presentation over that branch. Reading - // the exemption from geometry alone would let it through, so it stays kind-gated. const nodes = chromeHostTree({ chromeType: 'Dialog', chromeRole: 'UIAlertControllerView', @@ -195,9 +196,6 @@ test('a full-screen dialog sized to the content branch beside it still covers, b }); test('a chrome candidate in another window keeps covering content sized like its own frame (#2996 sibling scope)', () => { - // The exemption compares a candidate against the siblings listed under ITS OWN parent. This - // container's only sibling is its own full-window host, so nothing matches and it keeps covering - // — a same-size rect elsewhere in the tree cannot excuse it. const nodes: RawSnapshotNode[] = [ node({ index: 0, depth: 0, type: 'Application', role: 'UIApplication', rect: VIEWPORT }), node({ @@ -912,17 +910,9 @@ test('a control the exempt toolbar host really hosts still covers the row it ove }); function projectedTabsTree(): RawSnapshotNode[] { - return capturedTree([ - [0, undefined, 'Application', '', undefined, [0, 0, 402, 874]], - [1, 0, 'StaticText', '', 'Home', [177, 71, 47, 20]], - [2, 0, 'StaticText', '', 'home-tab-content', [173, 422, 55, 24]], - [3, 0, 'StaticText', '', 'Go to the Actions tab', [53, 454, 297, 16]], - [4, 0, 'Toolbar', '_UIFloatingBarContainerView', 'Toolbar', [0, 0, 402, 791]], - [5, 0, 'Button', '', 'Home, tab, 1 of 3', [0, 791, 134, 49]], - [6, 0, 'Button', '', 'Feed, tab, 2 of 3', [134, 791, 134, 49]], - [7, 0, 'Button', '', 'Actions, tab, 3 of 3', [268, 791, 134, 49]], - [8, 0, 'Toolbar', '', 'Toolbar', [0, 0, 402, 874]], - ]); + return JSON.parse( + readFileSync(new URL('./snapshot-occlusion-bottom-tabs.fixture.json', import.meta.url), 'utf8'), + ) as RawSnapshotNode[]; } test('projected tab content remains uncovered above the adjoining bottom tab buttons (#4365)', () => { @@ -961,11 +951,9 @@ test('a control hosted by the projected floating container still covers content hittable: true, }), ); - assert.equal( - annotateCoveredSnapshotNodes(nodes).find((candidate) => candidate.index === 1) - ?.interactionBlocked, - 'covered', - ); + const target = annotateCoveredSnapshotNodes(nodes).find((candidate) => candidate.index === 1); + assert.equal(target?.interactionBlocked, 'covered'); + assert.equal(target?.coveredBy?.label, 'Action'); }); test('a sheet with the same footprint and adjoining tab buttons still covers content (#4365)', () => { diff --git a/packages/capture-kit/src/snapshot-occlusion.ts b/packages/capture-kit/src/snapshot-occlusion.ts index 264de4b0b1..8ee5f86b00 100644 --- a/packages/capture-kit/src/snapshot-occlusion.ts +++ b/packages/capture-kit/src/snapshot-occlusion.ts @@ -26,6 +26,7 @@ const OVERLAY_KIND_FRAGMENTS = [ 'menu', ]; const VIEWPORT_CHROME_KIND_FRAGMENTS = ['tabbar', 'toolbar', 'navigationbar']; +const FLOATING_BAR_CONTAINER_ROLE = '_UIFloatingBarContainerView'; /** * How far below the viewport top a full-viewport chrome container may start, before the 0.5pt rect * tolerance. On iOS 27 an app that draws a 2pt bar at the top gets a `_UIFloatingBarContainerView` @@ -533,11 +534,10 @@ function isViewportAboveBottomBar( viewport: Rect, neighbourhood: NeighbourhoodIndex, ): boolean { - if (node.role !== '_UIFloatingBarContainerView' || typeof node.parentIndex !== 'number') + if (node.role !== FLOATING_BAR_CONTAINER_ROLE || typeof node.parentIndex !== 'number') return false; const bottom = rect.y + rect.height; - if (bottom <= viewport.y + viewport.height / 2 || bottom >= viewport.y + viewport.height) - return false; + if (bottom >= viewport.y + viewport.height) return false; if (!isViewportFootprint(rect, { ...viewport, height: bottom - viewport.y })) return false; const siblings = neighbourhood.childrenByParent.get(node.parentIndex) ?? []; const buttons = siblings.flatMap((sibling) => {