Skip to content

Commit 08d977f

Browse files
authored
fix(ios): keep list rows after a selectable text row in interactive snapshots (#2740)
* fix(ios): keep list rows after a selectable text row in interactive snapshots A UITextView is a UIScrollView and XCTest publishes its scroll indicator inside the text. The interactive presentation attributed that indicator to the nearest scroll-typed ancestor, the list around the text, and derived the list's viewport from it: one 22 px band at the text row. Every row after it was clipped away, so a Bluesky post thread whose root post is selectable text showed the root and none of its 58 replies while the full snapshot listed all of them. An indicator whose nearest scrolling ancestor is a TextView now belongs to that text view and derives no list viewport. Regression test built from the thread's runner tree; on the live screen the interactive snapshot goes from 20 to 67 nodes. * docs(ios): say plainly how a text view indicator clipped the list
1 parent 99c9b58 commit 08d977f

3 files changed

Lines changed: 103 additions & 4 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@
1313
`hingeAngleDegrees` and the previous reading, and says the hinge was observed half-open and did
1414
not settle rather than claiming it never got there. `fold-pose-unverified` still covers a budget
1515
that ends on another pose. Supersedes ADR 0025's budget-end exception (#2730).
16+
- Fixed (ios): an interactive snapshot of a list whose row holds selectable text (a `TextView`) no
17+
longer drops every row after that text. A UITextView is a scroll view too, and XCTest publishes
18+
its scroll indicator inside the text; the presentation read that indicator onto the list around
19+
it and clipped the list's viewport to one line, so a post thread whose root post is selectable
20+
text showed the root and none of its replies, while the full snapshot showed all of them. An
21+
indicator whose nearest scrolling ancestor is a text view now belongs to that text view and
22+
derives no list viewport.
1623
- Fixed (macos): `press` and `click` on the `frontmost-app`, `desktop`, and `menubar` surfaces post
1724
clicks the way a trackpad does. The helper posted the release in the same tick as the press, so
1825
AppKit dropped it and controls never activated; each press is now held (`--hold-ms`, 60 ms by

‎packages/capture-kit/src/ios-snapshot-engine/runner-presentation.test.ts‎

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,26 @@ test('runner presentation clips rows to a scroll viewport derived from its indic
3333
);
3434
});
3535

36+
test('a text view scroll indicator inside a list does not clip the list to that text', () => {
37+
const request = createIosSnapshotRequest({ interactiveOnly: true });
38+
const result = presentIosSnapshot(runnerInput(request, threadNodes()), request);
39+
const labels = result.nodes.map((node) => node.label);
40+
41+
assert.deepEqual(result.nodes.find((node) => node.type === 'ScrollView')?.rect, {
42+
x: 0,
43+
y: 110,
44+
width: 402,
45+
height: 702,
46+
});
47+
assert.ok(labels.includes('Reply (58 replies)'));
48+
assert.ok(labels.includes('Reply 37'));
49+
assert.ok(labels.includes('Like (0 likes)'));
50+
assert.equal(
51+
labels.some((label) => label === 'Vertical scroll bar, 1 page'),
52+
false,
53+
);
54+
});
55+
3656
function runnerInput(request: IosSnapshotRequest, nodes: RawSnapshotNode[]): IosSnapshotInput {
3757
return {
3858
stage: 'presented',
@@ -114,6 +134,53 @@ function runnerNodes(): RawSnapshotNode[] {
114134
];
115135
}
116136

137+
/**
138+
* A post thread as XCTest reports it: the list's own indicator is its child, while the root post's
139+
* selectable text is a `TextView` (a UIScrollView underneath) carrying an indicator of its own.
140+
*/
141+
function threadNodes(): RawSnapshotNode[] {
142+
const rowRect = { x: 16, y: 180, width: 370, height: 22 };
143+
return [
144+
runnerNode(0, 'Application', 'Blue Sky', viewport),
145+
runnerNode(
146+
1,
147+
'ScrollView',
148+
'Vertical scroll bar, 5 pages',
149+
{ x: 0, y: 110, width: 402, height: 764 },
150+
0,
151+
1,
152+
),
153+
runnerNode(2, 'Other', 'Bob', { x: 0, y: 110, width: 402, height: 764 }, 1, 2),
154+
runnerNode(3, 'Other', 'Thread root', rowRect, 2, 3),
155+
runnerNode(4, 'TextView', 'Thread root', rowRect, 3, 4),
156+
{
157+
...runnerNode(
158+
5,
159+
'Other',
160+
'Vertical scroll bar, 1 page',
161+
{ x: 353, y: 180, width: 30, height: 22 },
162+
4,
163+
5,
164+
),
165+
value: '0%',
166+
},
167+
runnerNode(6, 'Button', 'Reply (58 replies)', { x: 9, y: 232, width: 54, height: 32 }, 2, 3),
168+
runnerNode(7, 'Link', 'Reply 37', { x: 16, y: 274, width: 370, height: 165 }, 2, 3),
169+
runnerNode(8, 'Button', 'Like (0 likes)', { x: 209, y: 412, width: 28, height: 28 }, 7, 4),
170+
{
171+
...runnerNode(
172+
9,
173+
'Other',
174+
'Vertical scroll bar, 5 pages',
175+
{ x: 369, y: 110, width: 30, height: 702 },
176+
1,
177+
2,
178+
),
179+
value: '0%',
180+
},
181+
];
182+
}
183+
117184
function runnerNode(
118185
index: number,
119186
type: string,

‎packages/capture-kit/src/ios-snapshot-engine/scroll.ts‎

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ import {
44
inferVerticalScrollIndicatorDirections,
55
isSystemScrollIndicatorLabel,
66
} from '@agent-device/kernel/scroll-indicator';
7+
import { normalizeType } from '@agent-device/contracts/snapshot';
78
import {
8-
findNearestScrollableContainer,
9+
findNearestAncestor,
910
isScrollableSnapshotType,
1011
mergeReplacement,
1112
updateReplacement,
@@ -45,9 +46,7 @@ function collectIosScrollIndicatorNodePresentation(
4546
): void {
4647
const suppressed = !isScrollableSnapshotType(node.type) || context.isSuppressed(node);
4748
const directions = inferVerticalScrollIndicatorDirections(node.label?.trim() ?? '', node.value);
48-
const container = directions
49-
? findNearestScrollableContainer(node, byIndex, { includeSelf: true })
50-
: undefined;
49+
const container = directions ? findScrollIndicatorContainer(node, byIndex) : undefined;
5150
if (suppressed) context.suppressNode(node, container ? [container] : []);
5251
if (
5352
container &&
@@ -58,6 +57,32 @@ function collectIosScrollIndicatorNodePresentation(
5857
}
5958
}
6059

60+
/**
61+
* The scroll container an indicator reports on. XCTest publishes a UIScrollView's indicators as
62+
* children of that view, so the nearest scroll-typed ancestor is normally the owner. A UITextView
63+
* is a UIScrollView too but publishes as `TextView`, and its indicators sit inside the text. When
64+
* such an indicator was treated as the surrounding list's, the list's viewport shrank to that one
65+
* line of text and every row after it was clipped away (a post thread whose root post is
66+
* selectable text lost all of its replies). An indicator whose nearest scrolling ancestor is a
67+
* text view belongs to that text view, which derives no viewport, so it resolves no container.
68+
*/
69+
function findScrollIndicatorContainer(
70+
node: RawSnapshotNode,
71+
byIndex: ReadonlyMap<number, RawSnapshotNode>,
72+
): RawSnapshotNode | null {
73+
if (isScrollableSnapshotType(node.type)) return node;
74+
const host = findNearestAncestor(
75+
node,
76+
byIndex,
77+
(ancestor) => isScrollableSnapshotType(ancestor.type) || isTextViewType(ancestor.type),
78+
);
79+
return host && isScrollableSnapshotType(host.type) ? host : null;
80+
}
81+
82+
function isTextViewType(type: string | undefined): boolean {
83+
return normalizeType(type ?? '') === 'textview';
84+
}
85+
6186
function clipDescendantsToDerivedScrollViewports(
6287
nodes: RawSnapshotNode[],
6388
context: SnapshotTreeRuleContext,

0 commit comments

Comments
 (0)