Skip to content

Module 03 / Lesson 03

Find the exact element with React Grab and check five UI states

Module 03 · Real-World ContextStep 03 of 03

Move beyond generic "AI slop" by enforcing real design tokens, accessible motion, and surgical component targeting.

A stressed user opens your status page on a mobile phone under bright sunlight to see if their service is down. If the AI generated low-contrast grey text, erratic animations, and overlapping badges, the user cannot find the answer. When you tell the AI "make the badge look better", it often rewires the wrong component and breaks the entire screen.

Narrated lesson · 1:28
Read the narration transcript

Which Degraded badge did we mean?

See that degraded badge on the Event Delivery card? On a phone it squeezes the service name. So I ask the agent to fix the badge.

It changes the incident summary instead. Both places use the same status wording. From the prompt alone, the agent had to guess what I was looking at.

Copy the source context for the exact element

In a local development build, hover over the actual badge. React Grab can copy the element and component context using Command C or Control C. There’s an official setup guide linked below.

Read the copied context. A shared badge may appear in the stack, but the parent card owns this layout. Tell the agent to update the service card and preserve the incident summary.

Check the before-and-after layout

On a narrow screen, put Degraded below the service name. I review the diff first. This change moves the layout. The word Degraded and the data behind it are unchanged.

Now widen the preview. The badge moves onto the same row. Test a longer service name, and open the incident summary to make sure the intended restriction held.

Check the states around the change

Look beyond the sunny screenshot. Check an empty list, loading, a visible error, a long label at phone width, and a pending save. The layout should remain understandable as data changes.

Keep inspection tools in development. Run the production build and confirm it works without the inspection helper. Then use the comparison below and gather evidence from both widths.

The everyday problem

The degraded badge beside Event Delivery is squeezed on a phone. “Move the badge to the right” sounds precise when you are looking at the screen. The status app also has a degraded badge in the recent incident summary, and your agent edits that one. Now the wrong file is in the diff and you still have the original problem.

Point at what you can see: the badge in the service status card. Name what should happen after the fix. A narrow card should stack the badge under the title. A wide card should keep the existing row. This turns a visually obvious request into a concrete change with two checks.

Why the agent got it wrong

A rendered page and a codebase give you different kinds of context. As a person you see which element sits next to the service title. The agent may have the repo and a screenshot, but the same wording can appear in several files. It has to guess which component owns what you meant unless you show it a source location or a uniquely identifying element.

A class or string search can help once you know the target. Look for matching labels, then narrow by the parent component and the page route. Sending only a label is risky when the label is shared by design. In the status app, the sidebar and the service list use the same status vocabulary.

The tool and technique

React Grab can copy source context from the hovered element in a development build. Follow its project setup documentation if you choose to use it. Hover the badge, copy with the documented shortcut, and inspect the selected component and source locations before putting them in the request. The output is a starting point. It can include a shared primitive, so check which parent owns the layout.

If your environment doesn’t support React Grab, use React DevTools or inspect the element and find the matching page and component through search. Either way give the agent the same three things: the exact element, the behavior at each size, and what must stay unchanged.

Copy the exact element and check five UI states

React Grab helps you point at the cramped Degraded badge in the development preview and copy its source context. Paste the result alongside the intended behavior. Widen the review to five states the agent may have missed in a mockup.

npx grab@latest init

Example selection: Degraded in ServiceStatus
at src/components/service-status.tsx:42:14
Stack the badge below the name at phone width. Keep the desktop row.
Check: empty list, loading layout, long name, save error, pending submit.
Load the React Grab script only when process.env.NODE_ENV === "development".

Open both widths and confirm the agent changed the service row you selected. Inspect the production build for the absence of React Grab or source-selection assets. A server-side duplicate guard may still be needed when a pending button alone cannot stop retries.

On screen in the status app

Compare the before-and-after layout below. The initial request names only a badge. The revised request points to the Event Delivery card, states the desired layout at two widths, and protects the incident summary. The shown utility classes are an example for a viewport-based breakpoint. A reusable card that lives in narrow desktop containers may need a container-based breakpoint instead.

Run the demonstration at both widths. On the phone, the title and badge should have separate lines. On desktop, the badge should stay alongside the title. Pass a long service name through the same card. Look at the proposed edit and confirm it changes layout without touching the data it displays.

src/components/service-status.tsx

Before

<header className="flex items-center justify-between gap-3">
  <h3>{name}</h3>
  <StatusBadge state={state} />
</header>

After

<header className="flex flex-col items-start gap-2 sm:flex-row sm:items-center sm:justify-between">
  <h3 className="min-w-0 break-words">{name}</h3>
  <StatusBadge state={state} />
</header>

What to watch for

Keep development inspection tooling behind the framework’s development-only configuration. Source locations shouldn’t be part of the visitor-facing build. A copied element can also include real page content, so review it before sending it to a hosted agent. Use a local fixture with synthetic values in the lesson.

This fix only covers one component and a known responsive behavior. Existing loading, empty, error, and pending states still deserve review when the same component shows them. One screenshot can demonstrate a good layout, but an actual comparison across states catches regressions it can’t show.

How you know it worked

Open both widths, choose After, and confirm the badge is below the title in the narrow card and beside it in the wide card. Open the incident summary and check it still renders the same way. Then skim the diff. If the agent changed data or introduced a new badge, ask why before you approve the patch.

Capture one screenshot from each width and name the untouched screen in your pull request. When using the idea on your own repo, remove identifiers or customer data from the example you share. The principle carries to forms, navigation, and tables wherever the same wording appears more than once.

For a reusable card, test the same long name when the status list has an adjacent sidebar. That can create a narrow container on a wide monitor. Watch whether the fixed layout still matches the requirement before deciding if the viewport breakpoint is enough.

Watch the short visual recap

Find the right badge. See the degraded badge on the Event Delivery card? On a phone, it squeezes the service name into two lines. I told the agent to fix the badge. It changed the incident summary instead. Both screens use the same status wording.

Give the agent a precise target. Here’s where React Grab helps. In a local development build, point at the badge and copy its source context. The selection tells the agent which component to inspect. Now write the change in plain English. On narrow screens, place the badge below the title. Keep the desktop row and leave the incident summary alone.

Check the diff and both widths. Read the proposed diff before you call it done. This patch changes the heading layout. The wording and status data stay the same. Check the narrow view, then widen the card. The badge moves below the title on the phone and returns to the same row on desktop.

Take the habit to your own work. Give the agent three things. The exact element, the behavior you want, and a check that would catch the wrong edit. Use the practice below to compare both widths and decide what evidence belongs in the pull request.

Check the patch at both widths

Switch between the two layouts. Check where the Degraded badge sits relative to the service name.

Service status
Event DeliveryDegraded

Webhook delivery is delayed.

The title and badge share one row.

References