Skip to content

fix(react-native): detect the collapsed LogBox banner's count badge - #4890

Merged
thymikee merged 5 commits into
mainfrom
t3/fix-logbox-count-badge
Nov 21, 2026
Merged

thymikee merged 5 commits into
mainfrom
t3/fix-logbox-count-badge

Conversation

@thymikee

@thymikee thymikee commented Nov 21, 2026 •

Copy link
Copy Markdown
Member

Summary

A collapsed LogBox banner is detected only while it holds one log entry. From two entries up, LogBox's badge renders the entry count instead of ! (LogBoxNotificationCountBadge), so the banner's label reads 20, Failed to fetch, and no collapsed-warning pattern matched it. react-native dismiss-overlay then reported No React Native overlay detected and snapshot -i carried no overlay hint (#4787).

Detection now accepts the <count>, <message> form only where LogBox floats its banner: banner-sized, and both side gaps equal to its fixed 10 dp inset, read in the capture's own units. Android publishes physical pixels, so the snapshot state carries the helper's density beside the viewport. Rows that merely open with a number (2, Morning, a flush footer, a 16 pt inset card) stay undetected. The rule sits in the contracts label check, so detection, the dismiss target and iOS wrapper suppression change together. No new flags.

Before / after

$ pnpm exec vitest run --project unit-core \
    packages/capture-kit/src/react-native-overlay.test.ts \
    packages/capture-kit/src/ios-snapshot-engine/noise-overlay.test.ts \
    packages/daemon/src/execution/handlers/__tests__/react-native.test.ts
base 55be96bb: 5 failed | 30 passed   (count banner detected: false)
head e4e058e9: 35 passed             (close-collapsed-banner, verified: true)

Validation

Tested at e4e058e9 on origin/main. The count-banner tests fail at base for the intended reason and pass at head. Live on two simulators, iPhone 17 Pro and iPad Pro 13-inch, both capture the count banner, publish the hint and verify the dismiss; rebuilt at base on the same iPad session, the same capture answers No React Native overlay detected. Excerpts in the evidence comment. Android is unverified on device and rests on fixtures. pnpm lint, pnpm typecheck and pnpm format pass.

Fixes #4787

🤖 Generated with Claude Code

From two entries up, LogBox's badge renders the entry count instead of `!`
(LogBoxNotificationCountBadge), so the collapsed banner's joined label reads
`20, Failed to fetch`. No collapsed-warning pattern accepted that shape, so
dismiss-overlay reported `No React Native overlay detected`, snapshot carried
no overlay hint, and a press on a control under the banner opened the inspector.

Detect the `<count>, <message>` form only where LogBox places its banner: the
node is banner-sized, spans nearly the capture's own box, and hangs off that
box's bottom edge. Ordinary rows that open with a number (a list row, a tab, a
price) keep their meaning, and a capture that publishes no box keeps the
label-only rule. The rule lives in the contracts label check, so the snapshot
detector, the dismiss target, and the iOS full-screen wrapper suppression
change together.
@github-actions

github-actions Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Size Report

Metric Base Current Diff
Installed (including dependencies) 6.48 MB 6.48 MB +1.5 kB
Package (unpacked) 6.48 MB 6.48 MB +1.5 kB
Package (download) 1.97 MB 1.97 MB +499 B

Startup median (7 runs, lower is better):

Scenario Base Current Diff
CLI --version 17.7 ms 17.8 ms +0.1 ms
CLI --help 37.3 ms 36.3 ms -0.9 ms

@apex-sentinel-staging

This comment has been minimized.

@apex-sentinel-staging apex-sentinel-staging Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apex Sentinel: 1 new finding on 4f1294e. The verdict and the full list are in the summary comment.

…anner

The placement rule asked only that a count banner be wide and sit near the bottom
edge, so a full-width row flush with that edge ("2, Continue shopping") read as a
LogBox banner and its close point got tapped.

LogBox floats its banner with left: 10, right: 10 and bottom: 20 inside its own
container, so the banner keeps a visible gap on all three sides and no gap larger
than LogBox's own. The rule now measures those gaps against the capture's box and
rejects a row pinned to a side or the bottom edge, which is app chrome: a tab bar,
a footer, or a bottom-sheet row.
@apex-sentinel-staging

This comment has been minimized.

@thymikee

Copy link
Copy Markdown
Member Author

The collapsed-banner count badge is still missed on iPad and tablet-width surfaces at 6fcf103, and the change has no live device run yet.

isWithinSurfaceBand requires each side gap to be at least 1% of the surface width (react-native-overlay.ts:175). LogBox floats its banner with a fixed 10-unit side gap. On any surface wider than 1000 dp/pt the real banner fails that floor. Examples are a 13" iPad Pro portrait window (1032pt, floor 10.32), every iPad in landscape, and an Android tablet or unfolded foldable in landscape (10/1280 is 0.78%). The iOS wrapper suppression uses the same band, so it misses there too. On these surfaces react-native dismiss-overlay still reports no overlay, snapshot -i prints no hint, and a press under the banner still opens the inspector. That is the #4787 failure. The rule should be that a visible gap means strictly more than flush. A flush row has gap 0, so an absolute floor of 1 unit in the capture's own units, or a ratio floor of 10/2560 or lower, keeps every flush case rejected. Please add an iPad-sized fixture (1032x1376, banner x 10, width 1012) to the count-banner tests.

This change decides which tap react-native dismiss-overlay sends and whether snapshot carries the overlay hint, so it is device-facing, and the PR body says no device run was done (react-native.ts:78). Correctness depends on real-tree geometry that the fixtures only assume: the Android banner rect against the helper's display-sized viewport, the iOS rect including the bottom safe-area inset against the app-window viewport, and the joined <count>, <message> label landing on the banner node itself. Before merge, one live run is required on an iOS simulator (and an Android emulator if available) using examples/test-app with two or more console.error entries so the badge shows a count. Please record the tested SHA, snapshot --json with the banner node's label and rect plus the published viewport, snapshot -i output showing the 'React Native warning/error overlay detected' hint, and react-native dismiss-overlay --json returning overlayAction close-collapsed-banner with verified: true.

Not blocking, and these can be taken or left: the 15% upper band (react-native-overlay.ts:36) admits ordinary inset cards, for example a 370x72 card labeled '3, New messages' at x 16 above an 83pt tab bar on a 402x874 capture, so requiring small, roughly equal side gaps (about 3% of width or less) plus a negative fixture would tighten it; the max(COLLAPSED_BANNER_MAX_BOTTOM_MARGIN, 15% of height) clause at line 164 can never reject anything because the band already caps the bottom gap at 15%, and its comment describes a widening the code does not do; and in capture-kit react-native-overlay.ts:243 nodeLabelFacts returns a boolean so nodeHasMatchingLabel would read better, and the coordinate fallback could test membership in collapsedCountBadgeNodes instead of carrying surface on the facts.

The earlier inline thread about a full-width bottom row is fixed at this head, so it can be resolved: #4890 (comment).

The only checks not passing are two cancelled 'Body rules' runs, which a newer body edit supersedes, and the diff touches no workflow or body-check script, so the cancellation looks unrelated to the code. Not verified here: tests were not run locally, no device tree was inspected, the claim that the badge id is unreachable in both trees, and the Android app-window size against the display under a non-edge-to-edge navigation bar.

No conflicts. Before merge, the side-gap floor must pass LogBox's 10-unit gap on surfaces wider than 1000 units, and the live count-banner run above must show the snapshot hint and dismiss-overlay closing the banner with verified: true.

The side-gap floor asked for 1% of the surface width, so a real banner failed it
once the surface passed 1000 units: a 13" iPad Pro portrait window, every iPad in
landscape, an unfolded foldable. LogBox's gap is a fixed 10 units, so the floor is
now one unit and the cap is LogBox's own gap, widened by ratio only for
device-pixel captures.

The bottom band already capped the gap, so the clause above it could not reject
anything and is gone. A count banner now also reaches the coordinate fallback
through the nodes already proven to be banners, so the facts no longer carry a
surface, and nodeHasMatchingLabel says what it answers.
@apex-sentinel-staging

This comment has been minimized.

@apex-sentinel-staging apex-sentinel-staging Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apex Sentinel: 1 new finding on a0cfc96. The verdict and the full list are in the summary comment.

The count-badge banner was accepted by a side band widened with a surface ratio,
which also accepted an ordinary inset card on a wide surface. Match LogBox's
fixed 10 dp inset instead, translated with the capture's own rect units: the
Android helper publishes physical pixels, so the state now carries the helper's
density beside the viewport.
@thymikee

Copy link
Copy Markdown
Member Author

Live device evidence

Tested SHA e4e058e925d4052f51c46961602d14bcbf56b8e2 (agent-device built from this worktree, isolated --state-dir). Fixture: examples/test-app route that raises two console.error entries, so LogBox collapses with the badge showing the count. Its own labels avoid overlay vocabulary, so the capture's evidence is the banner alone.

iPhone 17 Pro (iOS 27.0)

snapshot --json — banner label carries the count, and the capture's published viewport:

viewport: {"width": 402, "height": 874}
overlay hint: true
{"index": 4, "ref": "e5", "type": "Other", "label": "2, Failed to fetch shipping options",
 "rect": {"x": 10, "y": 787.6666870415211, "width": 382, "height": 48}, "hittable": true}

snapshot -i carries the hint on the interactive tree too:

@e4 [other] "2, Failed to fetch shipping options"
Warning: Hint: React Native warning/error overlay detected. It overlays part of the app and
should be handled before interacting. Run: agent-device react-native dismiss-overlay

react-native dismiss-overlay --json:

{ "x": 369, "y": 813, "message": "React Native overlay dismiss action sent and verified gone",
  "action": "dismiss-overlay", "overlayAction": "close-collapsed-banner",
  "ref": "e8", "label": "2, Failed to fetch shipping options", "dismissed": true, "verified": true }

iPad Pro 13-inch (M5) (iOS 27.0) — the tablet-width case

The banner's 10-unit side gap is under 1% of a 1032-unit-wide surface, which is the geometry the earlier ratio band got wrong.

snapshot --json:

viewport: {"width": 1032, "height": 1376}
overlay hint: true
{"index": 4, "ref": "e5", "type": "Other", "label": "2, Failed to fetch shipping options",
 "rect": {"x": 10, "y": 1298.5, "width": 1012, "height": 48}, "hittable": true}

react-native dismiss-overlay --json:

{ "x": 999, "y": 1324, "message": "React Native overlay dismiss action sent and verified gone",
  "action": "dismiss-overlay", "overlayAction": "close-collapsed-banner",
  "ref": "e5", "label": "2, Failed to fetch shipping options", "dismissed": true, "verified": true }

Same iPad, same fixture, origin/main binaries

Rebuilt the CLI at origin/main and re-ran the same session, so the difference is only the fix:

snapshot --json  ->  viewport {"width": 1032, "height": 1376}
                    overlay hint: false        (no warning at all)
                    banner node present: label "2, Failed to fetch shipping options",
                                          rect x 10, y 1298.5, w 1012, h 48
react-native dismiss-overlay --json  ->  { "message": "No React Native overlay detected",
    "overlayAction": null, "ref": null, "dismissed": false }

That is #4787 reproduced and then closed on the same device.

One run on the iPad first reported overlayAction: "close" with verified: false: that session's tree still held the dev-build's own launcher sheet (Close at y 576, Reload), so the command aimed at that surface instead of the banner. Dismissing it and re-running picked the banner and verified. Worth knowing that a co-present dev launcher competes for the dismiss target on iPad; nothing in this PR changes that path.

Not covered

Android is unverified — no emulator was run for this evidence. The device-pixel path is covered by unit fixtures only: LogBox's 10 dp inset read as 10 x the capture's density, and the negative case where the capture published no density.

@apex-sentinel-staging

Copy link
Copy Markdown

Apex Sentinel · ✅ Approve · review of e4e058e

Since the review of a0cfc96: 0 new · 0 still open · 1 no longer raised (1 marked fixed)

No open findings.

Reviewed with this repository's own Sentinel configuration (55be96bb6018).

💬 Talking to Sentinel

In a finding's thread, reply with:

Command What it does
@apex-sentinel-staging note <context> Adds context; Sentinel re-checks the cited code
@apex-sentinel-staging pivot <why> Says the finding is wrong; Sentinel re-checks the cited code
@apex-sentinel-staging like Marks the finding as useful
@apex-sentinel-staging dislike <why> Marks it as not useful, so it is not raised again

On this conversation, comment @apex-sentinel-staging review to run a full review once again.

@thymikee

Copy link
Copy Markdown
Member Author

This PR is ready at e4e058e. The two high-priority findings from the earlier review (#4890 (comment)) are fixed. The flush full-width row now fails the 10 dp check, and the fixed 10 dp ±1 side gap replaces the width-ratio band, with negative tests for both. All 21 checks pass at this commit. Not blocking, and fine to take or leave: add one buildSnapshotState test that feeds an android-helper capture with pixelDensity: 2.625 and expects rectUnitsPerDp 2.625, because deleting the spread at https://github.com/callstack/agent-device/blob/e4e058e/packages/capture-kit/src/snapshot-state.ts#L156 keeps every test green while Android detection stops; and consider a follow-up issue for Android landscape with a side navigation bar or a display cutout, where the window is narrower than the display and one side gap can exceed 10 dp (https://github.com/callstack/agent-device/blob/e4e058e/packages/contracts/src/react-native-overlay.ts#L197). Not verified here: Android behavior on a live device, since the density lift, the display-sized viewport and the joined count-and-message label rest on fixtures only. Tests were also not run locally, and whether the helper's display metrics are the real app-usable ones was not checked. The earlier threads #4890 (comment) and #4890 (comment) no longer apply, because both are fixed at this commit, so they can be resolved.

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Nov 21, 2026
@thymikee
thymikee merged commit fc705c1 into main Nov 21, 2026
21 checks passed
@thymikee
thymikee deleted the t3/fix-logbox-count-badge branch November 21, 2026 14:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-human Valid work that needs human implementation, judgment, or maintainer merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

React Native overlay: collapsed LogBox banner with a count badge (2+ entries) is not detected

1 participant