Genie React

Playwright MCP sees the screen. It can't see why React re-rendered

Ticking one checkbox re-rendered all 100 table rows. The driver's checkbox state, console and network log read the same before and after the fix. Genie named the prop and exited 1, then 0.

A browser driver such as Playwright MCP tells your coding agent what the page shows. It does not tell the agent which components React rendered or why. In a test app in this repo, ticking one checkbox re-rendered all 100 rows of a table, and the driver's view of the page read the same before and after the fix.

This article runs that bug through a driver alone, then adds Genie. I used agent-browser as the driver for most runs. Playwright MCP fills the same role, and I ran it once on the same click to compare. The raw evidence has every command and its full output.

The symptom

apps/realworld-legacy is Acme Tracker, a React 18 app with Redux and PureComponent class rows. Its issues page shows 100 issues. The seeded bug report says "Ticking one checkbox in the issue table lags. It looks like every row on the page redraws."

What the driver gives your agent

Click the checkbox for CORE-40, the fourth row, then ask the driver what happened. The output of all five commands, in order:

agent-browser --session art-m3 click '.issue-row:nth-child(4) input[type=checkbox]'
agent-browser --session art-m3 is checked '.issue-row:nth-child(4) input[type=checkbox]'
agent-browser --session art-m3 console
agent-browser --session art-m3 errors
agent-browser --session art-m3 network requests
✓ Done
true
[73908.1140] GET http://127.0.0.1:5223/api/notifications (Fetch) 200
[73908.1141] GET http://127.0.0.1:5223/api/notifications (Fetch) 200

The box is checked. The console and error log are empty, because I cleared them right before the click. The only requests were two notification polls the app runs on a timer. The screenshot shows CORE-40 highlighted and "3240 issues, 1 selected" in the toolbar. As far as the screen goes, the click worked.

Playwright MCP 0.0.86 reported the same thing. I drove it over stdio from a scratch client, which prints the >>> line, and took a snapshot of the clicked row:

>>> tools/call browser_snapshot {"target":".issue-row:nth-child(4)"}
### Page
- Page URL: http://127.0.0.1:5223/issues
- Page Title: Acme Tracker
- Console: 0 errors, 4 warnings
### Snapshot
- row [ref=f1e145]:
  - cell [ref=f1e146]:
    - checkbox "Select CORE-40" [checked] [active] [ref=f1e147]
  - cell "CORE-40" [ref=f1e148]

I trimmed the snapshot to its first two cells. browser_network_requests listed the page-load requests and the same two notification polls. browser_console_messages returned five messages: one webpack info line, two React Router future-flag warnings, and two warnings from react-redux. This is the first line of one:

[WARNING] Selector unknown returned a different result when called with the same parameters. This can lead to unnecessary rerenders.

That warning is a real lead. It does not name a selector or a component, though. All four warnings were already logged before the click, since the page reported Console: 0 errors, 4 warnings both before and after it. Nothing in the console points at the rows.

Then I applied the fix and ran the agent-browser commands again. The output matched: true, an empty console, and two notification polls. The driver cannot tell the broken build from the fixed one.

What Genie adds

Genie reads React from inside the page. I re-ran these Genie steps on Genie 1.1.0. Open a render window, click, and count the rows that rendered:

npx genie-react call react_clear_renders '{"component":["IssueRow","IssueTable"],"budget":{"adaptive":false,"fiberLimit":20000,"operationLimit":2000000,"timeLimitMs":500,"targetOperationReserve":100000,"targetTimeReserveMs":100}}' --session upd-g
agent-browser --session upd-g click '.issue-row:nth-child(4) input[type=checkbox]'
npx genie-react call react_quiesce '{"idleMs":500,"timeoutMs":10000}' --session upd-g
npx genie-react call react_component_cohort '{"component":"IssueRow","limit":1}' --session upd-g
status: updated
matched: 100
mountedUpdated: 100
mountedIdle: 0
mountedUnknown: 0

One click, 100 row renders. I raised the render budget for this read. With the default budget, which scaled to 750 fibers and 36 ms on this page, the same read covered 34 rows and reported the other 66 as mountedUnknown. Genie marks that gap instead of counting the missing rows as idle. The coverage also says which budget to use next (trimmed):

  budgetAdvice:
    exhaustedLimits: [targetOperationReserve]
    suggestedBudget: {fiberLimit:750,operationLimit:90000,timeLimitMs:36,targetOperationReserve:12000,targetTimeReserveMs:12}

I cleared again with that budget and repeated the click, and the read covered all 100 rows. Genie 1.0.2 reported the same gap without budgetAdvice.

Now ask why:

npx genie-react call react_render_causes '{"component":"IssueRow","limit":2}' --session upd-g

Trimmed to one event, with the path shortened:

  IssueRow #2868266403964 {…,key:iss-1754,necessity:unknown,necessityReason:callbacks-changed,inputEvidence:changed,source:{location:…/src/features/issues/issue-table.tsx:48:15,role:element-callsite,ownership:app}}
    ← props exact onToggle

Each row rendered because its onToggle prop changed, and Genie saw that directly (exact). The source points at line 48 of issue-table.tsx, where the table creates each row.

The cause

IssueTable passes every row a new arrow function on each render:

<IssueRow
  key={issue.id}
  issue={issue}
  selected={selectedIds.includes(issue.id)}
  onToggle={() => this.props.selectionToggled(issue.id)}
  onOpen={this.openIssue}
/>

IssueRow is a PureComponent, which skips a render only when every prop is shallowly equal. A new function is never equal to the old one. So when the selection changes and the table renders, all 100 rows render with it.

The fix

Pass the stable bound action and let the row supply its own ID:

--- a/apps/realworld-legacy/src/features/issues/issue-table.tsx
-                onToggle={() => this.props.selectionToggled(issue.id)}
+                onToggle={this.props.selectionToggled}
--- a/apps/realworld-legacy/src/features/issues/issue-row.tsx
-  onToggle: () => void
+  onToggle: (id: string) => void
-            onChange={onToggle}
+            onChange={() => onToggle(issue.id)}

The proof

verify turns "fixed" into an exit code. The claims say every row render must come from the selected prop, and the table must still render, so a click that missed the app fails:

npx genie-react verify begin --session upd-g --name 'select one row' \
  --budget '{"adaptive":false,"fiberLimit":20000,"operationLimit":2000000,"timeLimitMs":500,"targetOperationReserve":100000,"targetTimeReserveMs":100}' \
  --claim 'render IssueRow only props.selected' --claim 'render IssueTable min 1' --claim 'boundaries clean'
agent-browser --session upd-g click '.issue-row:nth-child(4) input[type=checkbox]'
npx genie-react verify end <id> --session upd-g; echo "exit code: $?"

Before the fix, trimmed to the verdict and claim lines:

fail vfy_dd9856b5-1dc3-4224-8498-c7095869bfe2 "select one row"  3 commits, quiet after 958 ms (react)
  1 fail render IssueRow only props.selected  {renders:100,events:100,violatingEvents:100,causes:[props.onToggle,props.selected]}
  2 pass render IssueTable min 1  {renders:1,mounts:0,updates:1,remounts:0,semantics:exact,instances:1,activeInstances:1}
  3 pass boundaries clean  {caughtDuringWindow:0,caughtAtEnd:0}
exit code: 1

After the fix:

pass vfy_31125f33-e12a-4234-98d1-28782d185a13 "select one row"  3 commits, quiet after 949 ms (react)
  1 pass render IssueRow only props.selected  {renders:1,events:1,violatingEvents:0,causes:[props.selected]}
  2 pass render IssueTable min 1  {renders:1,mounts:0,updates:1,remounts:0,semantics:exact,instances:1,activeInstances:1}
  3 pass boundaries clean  {caughtDuringWindow:0,caughtAtEnd:0}
exit code: 0

The cohort agreed: 1 row updated and 99 stayed idle. The driver still confirms the part Genie does not check. After the fix, is checked printed true, so the click still selects the row.

What the driver does better

Genie does not click, type, or look at the page. Your agent needs a driver for all of that, and every run above used one.

Playwright MCP covers ground Genie does not. Per its README, its default tools navigate, click, fill forms, handle dialogs, and read the accessibility tree. Opt-in capabilities add request mocking (--caps=network), cookies and storage (--caps=storage), and tracing and video (--caps=devtools). It works on any site, built with any framework, in production. Genie needs a development build of React 18 or newer with Genie installed.

A driver can also measure cost. agent-browser profiler recorded a Chrome CPU profile of the click. Summed by function, it put 11.07 ms of self time in RelativeTime, the date cell inside each row, and 0.15 ms in IssueRow's own render. A profile is the better tool when you need to know which function burns CPU. It does not say which prop change made the rows render, and it mixes in other work. With the fix applied, the same summary still showed 5.92 ms in RelativeTime.

browser_evaluate runs any JavaScript in the page, so an agent could try to hook React itself. None of Playwright MCP's tools reads React state for the agent, and its README does not mention React.

When this approach does not fit

  • The bug is on screen: wrong text, a missing button, a broken layout. A driver snapshot or screenshot is enough.
  • The app is not React, or you only have a production build.
  • You need CPU time per function across all JavaScript. Record a profile with your driver.

For render bugs that leave the screen correct, pair the driver with Genie. See Debug renders and effects for the render tools and Verify a fix for the claim forms. Is it the network or React? uses the same app to split one click into request time and render time.

On this page