Genie React

The mutation succeeded and the list didn't update. One query key was off by one letter

A task form said Saved while the list kept two rows. Genie showed the invalidation matched 0 queries because the key said task, not tasks.

The list didn't update because the mutation invalidated ['task', 'list'] and the list reads ['tasks', 'list']. Genie's query_invalidations showed the call matched 0 cached queries and named ["tasks","list"] as the near miss. genie-react verify failed with exit code 1 before the one-line fix and passed with exit code 0 after it.

Every command and output below comes from one run of Genie 1.1.0 on 2026-11-19 against the tasks screen of the eval fixture in this repo (evals/fixture-app). Outputs are trimmed to the lines that matter. The raw evidence has every command in order with untrimmed output.

The form says Saved and the list keeps two rows

The Tasks screen has a title field, an Add task button and a list. Open it and connect Genie:

agent-browser --session upd-f open "http://localhost:5242/?screen=tasks"
npx genie-react status --session upd-f --wait 15000

status reports ready: true for the tab. Add a task the way a user would:

agent-browser --session upd-f fill 'input[aria-label="New task title"]' 'Archive Q3 invoices'
agent-browser --session upd-f click 'button[type=submit]'
agent-browser --session upd-f wait --text Saved
agent-browser --session upd-f get text 'ul[aria-label="Tasks"]'
Saved
Renew TLS certificate
Rotate API keys

The form says Saved. The list still shows the two seed tasks.

Turn the symptom into a failing check

Before you read any code, write down what a working fix must make true. Adding a task must re-render TaskList, the component that reads the list query. AddTaskForm must render too, which proves the click reached the app:

npx genie-react verify begin --session upd-f --name 'add a task' \
  --claim 'render TaskList min 1' --claim 'render AddTaskForm min 1' --claim 'boundaries clean'

Then fill the field, click Add task, wait for Saved, and end the window with the ID that begin printed:

npx genie-react verify end vfy_1cacbcc2-a427-4360-9fa9-93b1fd4f8a00 --session upd-f
fail vfy_1cacbcc2-a427-4360-9fa9-93b1fd4f8a00 "add a task"  3 commits, quiet after 625 ms (react, query, network)
  1 fail render TaskList min 1  {renders:0,mounts:0,updates:0,remounts:0,semantics:exact,instances:1,activeInstances:1}
  2 pass render AddTaskForm min 1  {renders:3,mounts:0,updates:3,remounts:0,semantics:exact,instances:1,activeInstances:1}
  3 pass boundaries clean  {caughtDuringWindow:0,caughtAtEnd:0}

The command exits with code 1. AddTaskForm rendered 3 times, so the interaction landed. TaskList rendered 0 times, so no new data reached it.

Ask Query what the invalidation hit

query_invalidations lists the app's recent invalidateQueries, refetchQueries, resetQueries and removeQueries calls. Each entry has the filter the app passed and the cached queries it matched:

npx genie-react call query_invalidations --session upd-f '{}'
calls[1]:
  - {sequence:1,method:invalidateQueries,timestamp:1795078912160,byGenie:false,filters:{queryKey:[task,list],exact:false,type:null,refetchType:null,predicate:false},matchedCount:0,matched:[],nearMisses:["[\"tasks\",\"list\"]"],stack:[…,"at Object.onSuccess (http://localhost:5242/src/screens/tasks/taskQueries.ts:17:32)",…]}

The app did call invalidateQueries, from onSuccess at taskQueries.ts:17. Its filter was [task,list] and it matched 0 queries. Genie runs TanStack Query's own matching with the same filter, so 0 means the call reached nothing in the cache.

nearMisses names the cached key the filter almost matched, ["tasks","list"]. Its first segment differs from the filter's by one letter. Genie 1.0.2 listed only keys that share the first segment, so this field stayed empty there.

Now read the list query itself:

npx genie-react call query_get --session upd-f '{"queryKey":["tasks","list"]}'
queryHash: "[\"tasks\",\"list\"]"
status: success
isInvalidated: false
dataUpdateCount: 1
fetchCount: 1
data: [{id:1,title:"Renew TLS certificate"},{id:2,title:"Rotate API keys"}]

The list's key is [tasks,list], the near miss. It was never marked invalid, it fetched once, and it still holds two tasks. The cause is one letter, task against tasks.

The mutation did save

The form said Saved, but that only proves the mutation function resolved. Refetch the list by hand to see what the server has:

npx genie-react call query_refetch --session upd-f '{"queryKey":["tasks","list"]}'
agent-browser --session upd-f get text 'ul[aria-label="Tasks"]'
ok: true
matched: 1
Renew TLS certificate
Rotate API keys
Archive Q3 invoices

The task exists on the server. Only the cache was stale, because nothing told it to refetch.

This is why the form looked right. AddTaskForm shows Saved when addTask.isSuccess is true. That flag belongs to the mutation. It turns true when mutationFn resolves, whatever onSuccess does to the cache afterwards. A success message and a stale list can sit on the same screen, and both report what really happened.

The cause and the fix

taskQueries.ts already defines a key factory, and useTasks builds its key from it:

export const taskKeys = {
  all: ['tasks'] as const,
  list: () => [...taskKeys.all, 'list'] as const,
}

useAddTask typed its key by hand instead. TanStack Query matches invalidateQueries filters by key prefix. ['tasks'] would have matched the list. ['task', 'list'] matches no key that starts with tasks. The fix uses the factory, so both sides read the same key:

   return useMutation({
     mutationFn: api.addTask,
-    onSuccess: () => queryClient.invalidateQueries({ queryKey: ['task', 'list'] }),
+    onSuccess: () => queryClient.invalidateQueries({ queryKey: taskKeys.list() }),
   })

The proof

Reload the tab, run the same verify begin with the same three claims, and add the same task:

pass vfy_65b7ac47-c406-48ae-b984-e383f63deaa6 "add a task"  3 commits, quiet after 621 ms (react, query, network)
  1 pass render TaskList min 1  {renders:1,mounts:0,updates:1,remounts:0,semantics:exact,instances:1,activeInstances:1}
  2 pass render AddTaskForm min 1  {renders:3,mounts:0,updates:3,remounts:0,semantics:exact,instances:1,activeInstances:1}
  3 pass boundaries clean  {caughtDuringWindow:0,caughtAtEnd:0}
attempt 2 for these claims on this tab; previous fail vfy_1cacbcc2-a427-4360-9fa9-93b1fd4f8a00; document reloaded since

The command exits with code 0. The last line links this pass to the earlier failure. Genie does not check the screen, so read it with the driver, then read the evidence again:

Renew TLS certificate
Rotate API keys
Archive Q3 invoices
calls[1]:
  - {sequence:1,method:invalidateQueries,…,filters:{queryKey:[tasks,list],exact:false,…},matchedCount:1,matched:[{queryHash:"[\"tasks\",\"list\"]",queryKey:[tasks,list],isActive:true,observerCount:1}],…}

query_get on the list now reports dataUpdateCount:2 and fetchCount:2, with three tasks in data.

Catch the next one in one call

You do not need to know which mutation is wrong to start. After any "saved but not shown" report, run query_invalidations once. Each matchedCount: 0 row is a call that refreshed nothing. Its nearMisses names the key it was probably meant for, and its stack names the file and line that made it. Here that was ["tasks","list"] and taskQueries.ts:17, the onSuccess handler, which is where the fix went.

To keep it fixed, build every key in invalidateQueries, useQuery and setQueryData from the same factory, as taskKeys.list() does. A typo inside the factory changes the read and the invalidation together, so the two still match.

Where this approach falls short

  • nearMisses lists cached keys where one segment differs by a plural ending or a small typo, then keys that share the filter's first segment. A key that differs in more than that may not appear. Run query_list and compare the keys yourself when nearMisses is empty.
  • query_invalidations records the four filter calls only. A mutation that writes with setQueryData does not appear there. Read the target query with query_get instead.
  • verify decides render, effect and boundary claims, and it printed ui-outcome-not-observed on both runs. A TaskList render proves new data arrived, not that the row is visible. Confirm the screen with the driver, as above.
  • matchedCount counts the queries in the cache at the moment of the call. If the list query did not exist yet, 0 is the correct answer and not a bug.

For more on following Query data to the screen, see Query and Router. For claim syntax and exit codes, see Verify a fix.

On this page