Skip to content

Commit 78d7fd0

Browse files
committed
fix(capture-kit): require React Native evidence for generic severity labels
Any node labelled "Error: ..." or "Warning: ..." counted as a collapsed LogBox banner, so app form errors appended the dismiss-overlay hint to every snapshot. A label with only the generic severity prefix now needs a stack frame or known overlay text on screen. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016qAu53rMak1bXMuR5U2gF4
1 parent 5dc12db commit 78d7fd0

3 files changed

Lines changed: 58 additions & 2 deletions

File tree

‎packages/capture-kit/src/react-native-overlay.test.ts‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,3 +103,33 @@ describe('React Native collapsed warning dismissal', () => {
103103
);
104104
});
105105
});
106+
107+
describe('React Native overlay evidence', () => {
108+
test('app text with a generic severity prefix is not an overlay', () => {
109+
const nodes = [
110+
node({
111+
index: 0,
112+
ref: 'e1',
113+
type: 'StaticText',
114+
label: 'Error: invalid email',
115+
rect: { x: 16, y: 300, width: 300, height: 44 },
116+
}),
117+
node({ index: 1, ref: 'e2', type: 'Button', label: 'Close', hittable: true }),
118+
];
119+
expect(analyzeReactNativeOverlay(nodes).detected).toBe(false);
120+
expect(formatReactNativeOverlayWarning(nodes)).toBe(undefined);
121+
});
122+
123+
test('a generic severity banner counts once a React Native stack frame is on screen', () => {
124+
const nodes = [
125+
node({ index: 0, ref: 'e1', label: 'Warning: state update on unmounted component' }),
126+
node({ index: 1, ref: 'e2', label: 'App.tsx:42:7', rect: collapsedBannerRect }),
127+
];
128+
expect(analyzeReactNativeOverlay(nodes).detected).toBe(true);
129+
});
130+
131+
test('a collapsed LogBox summary banner is an overlay by itself', () => {
132+
const nodes = [node({ index: 0, ref: 'e1', label: '!, Warning: x', rect: collapsedBannerRect })];
133+
expect(analyzeReactNativeOverlay(nodes).detected).toBe(true);
134+
});
135+
});

‎packages/capture-kit/src/react-native-overlay.ts‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
import { rectArea } from '@agent-device/kernel/rect';
88
import {
99
isReactNativeCollapsedWarningBanner,
10+
isReactNativeCollapsedWarningEvidenceLabel,
1011
isReactNativeCollapsedWarningLabel,
1112
isReactNativeOverlayDismissLabel,
1213
isReactNativeOverlayMinimizeLabel,
@@ -94,6 +95,10 @@ function collectReactNativeOverlayFacts(nodes: SnapshotNode[]): ReactNativeOverl
9495
hasOverlayControl,
9596
hasControllessRedBoxText,
9697
collapsedNodes,
98+
collapsedEvidenceNodes: collectOverlayNodes(
99+
collapsedNodes,
100+
isReactNativeCollapsedWarningEvidenceLabel,
101+
),
97102
openDebuggerWarningNodes,
98103
}),
99104
};
@@ -150,10 +155,14 @@ function isReactNativeOverlayDetected(params: {
150155
hasOverlayControl: boolean;
151156
hasControllessRedBoxText: boolean;
152157
collapsedNodes: SnapshotNode[];
158+
collapsedEvidenceNodes: SnapshotNode[];
153159
openDebuggerWarningNodes: SnapshotNode[];
154160
}): boolean {
161+
const hasOverlayContext =
162+
params.hasReactNativeStackFrame || hasKnownReactNativeOverlayText(params.text);
155163
return (
156-
params.collapsedNodes.length > 0 ||
164+
params.collapsedEvidenceNodes.length > 0 ||
165+
(params.collapsedNodes.length > 0 && hasOverlayContext) ||
157166
params.openDebuggerWarningNodes.length > 0 ||
158167
params.hasControllessRedBoxText ||
159168
(params.hasOverlayControl &&

‎packages/contracts/src/react-native-overlay.ts‎

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@ export type ReactNativeOverlayNode = Pick<
55
'index' | 'type' | 'role' | 'subrole' | 'label' | 'value' | 'identifier' | 'rect' | 'hittable'
66
>;
77

8+
/** App text such as "Error: invalid email" also starts this way, so it is not overlay evidence alone. */
9+
const GENERIC_SEVERITY_PREFIX_PATTERN = /^(warn|warning|error):\s+/;
810
const COLLAPSED_WARNING_PREFIX_PATTERNS = [
911
/^!,\s+/,
10-
/^(warn|warning|error):\s+/,
12+
GENERIC_SEVERITY_PREFIX_PATTERN,
1113
/\b(?:possible\s+)?unhandled (?:promise )?rejection\b/,
1214
] as const;
1315
const COLLAPSED_WARNING_TEXT_MARKERS = [
@@ -48,6 +50,21 @@ export function isReactNativeCollapsedWarningLabel(rawLabel: string | undefined)
4850
);
4951
}
5052

53+
/**
54+
* A collapsed-warning label that names React Native by itself: every collapsed match except one
55+
* that only carries the generic `warn:`/`warning:`/`error:` prefix.
56+
*/
57+
export function isReactNativeCollapsedWarningEvidenceLabel(rawLabel: string | undefined): boolean {
58+
const label = rawLabel?.trim().toLowerCase();
59+
if (!label || !isReactNativeCollapsedWarningLabel(label)) return false;
60+
return (
61+
COLLAPSED_WARNING_TEXT_MARKERS.some((marker) => label.includes(marker)) ||
62+
COLLAPSED_WARNING_PREFIX_PATTERNS.some(
63+
(pattern) => pattern !== GENERIC_SEVERITY_PREFIX_PATTERN && pattern.test(label),
64+
)
65+
);
66+
}
67+
5168
export function isReactNativeOverlayDismissLabel(label: string): boolean {
5269
return /^dismiss(?:\s*\([^)]*\))?$/i.test(label);
5370
}

0 commit comments

Comments
 (0)