Repository navigation
fix(agents): let an enrolled crewmate reach the crew roster - #15920
Conversation
Enrolling a template POSTs /api/agents -- the same crew registry write the
Crews tab's own create makes -- but the mutation invalidated only
['agent-templates']. The registry's own readers were left holding the
pre-write roster: the Crews tab beside this one on the same rail, and the
Crew Members roster that lives under the ['kirocrew-agents'] prefix.
Nothing else refreshes them while that cache entry is live. The dashboard's
QueryClient sets staleTime: Infinity ("queries never go stale on their own.
Freshness is driven exclusively by WebSocket push"), so a remount serves the
cached roster instead of asking again, and POST /api/agents pushes no refresh
frame -- the only push_refresh("agents") in the backend is the MCP capability
install. Opening Agent Capabilities on Crews, switching here, enrolling and
going back is inside that entry's gcTime, so the crewmate this tab has just
reported as enrolled is absent from the list it was added to.
The enroll now invalidates the registry prefix, which carries the members
roster with it, and ['kirocrewConfig'] alongside it -- the pairing #12740
established for a member write, because the same write lands in config.json
and its masked read ships the agent records.
The regression test mounts the Crews tab's own query beside the tab and runs
it under the production staleTime, because the suite's per-test QueryClient
uses the library default, where a remount would refetch and hide this.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Design Review (Fable 5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing to check. [DESIGN-REVIEWED] 2ffd45a Description read[DESCRIPTION-READ] 99e0a1d8706f4632dbf8a64866948f6dbf55ad7232c0d644c774e1b735007452 That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
GPT 5.6 Review — ✅ no blocking findingsGPT 5.6 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
UX Review (Fable 5) — ✅ PASSUX-level review of UX-Verdict: PASS Verify in the running app that switching back to the Crews tab shows the enrolled crewmate without a manual reload. [UX-REVIEWED] 2ffd45a Description read[DESCRIPTION-READ] cf57c263818860009e7316d4490907f88aa9d83372d851f9cd6fdaafeb81055b That sha256 names everything this verdict read: the PR description, plus the 3 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
First Principles Review (Fable 5) — 🟡 CONCERNSPremise-level review of First-Principles-Verdict: CONCERNS The PR's own rule — "a crew registry write has to name all three" keys — leaves one counted violator: MeetCrewmatesFlow invalidates the registry prefix but not Not justified as shipped
What this change shipsInventory (3 items) — 2 justifiedIntent: FIX — a crewmate enrolled from the Custom agents tab appears on the Crews tab and Crew Members roster immediately, instead of being absent from the list the enroll reported adding it to.
[FIRST-PRINCIPLES-REVIEWED] 2ffd45a Description read[DESCRIPTION-READ] d291d02e8b36aa579dd19c1b11331d7369eb2fbf61d3069c13472ba3bc19e7c1 That sha256 names the PR description this verdict read. Recompute it with |
Opus 5 Review — ✅ no blocking findingsReviewed Review detailsTwo newly added comments assert facts the repository contradicts; nothing blocks the merge. FINDING — website/src/pages/overview/AgentTemplatesTab.tsx:450 — the stated justification for the added invalidation, FINDING — website/src/test/AgentTemplatesTab.test.tsx:691 — [OPUS-REVIEWED] 2ffd45a Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
Replaces #12831 by @leonlaiyc (reopened in-repo so the fork-only CI gates can run). Original author's commit is carried verbatim; credit preserved via the commit author and
Co-Authored-By.Why no screenshot: This is a cache-invalidation behavior change in the enroll mutation's
onSuccess— it adds twoinvalidateQueriescalls. TheAgentTemplatesTabmarkup it touches is byte-identical before and after; a before/after of that tab would be the same pixels. The observable effect is that a different surface (the Crews tab / Crew Members roster) refreshes immediately instead of serving a stale cache entry — a freshness/timing behavior, not a visual delta — and it is proven by the added regression test rather than a static image.Problem / Motivation
Goal: an enrolled crewmate shows up on the Crews tab and the Crew Members roster right away, instead of being absent from the list the enroll just reported adding it to.
"Enroll as crewmate" on the Custom agents tab (formerly Agent templates) creates a crewmate, says so, and the crewmate is missing from the list it was added to.
The enroll POSTs
/api/agents— the same crew registry write the Crews tab's own create makes — but the mutation invalidated only['agent-templates']. The registry's own readers were left holding the pre-write roster: the Crews tab (this tab's sibling on the same rail,CapabilitiesPage) and the Crew Members roster under the same['kirocrew-agents']prefix (api/membersQuery.ts).Nothing else refreshes them while that cache entry is live. The dashboard's
QueryClientsetsstaleTime: Infinity("queries never go stale on their own. Freshness is driven exclusively by WebSocket push"), so a remount serves the cached roster, andPOST /api/agentspushes norefreshframe (the onlypush_refresh("agents")is the MCP capability install). Opening Agent Capabilities on Crews, switching here, enrolling and going back is inside that entry'sgcTime, so the just-enrolled crewmate is absent.Why it matters
The action reports success and the roster contradicts it on the next click, on the same page. The user's reasonable reading is that the enroll silently failed, and the obvious recovery — enroll again — hits
name_takenfrom the server for a crewmate the UI is refusing to show. There is no affordance on either tab that forces the refetch; a full reload is the only way out. The window is bounded by React Query'sgcTimeon['kirocrew-agents'], so it is a wrong state for exactly as long as the user is likely to still be looking.Not a goal
staleTime: Infinitypolicy. This is purely the client naming the keys its own write already invalidates for the Crews-tab create path.POST /api/agents; the fix is bounded to the enroll mutation'sonSuccess.What changed
The enroll now invalidates the registry prefix — which carries the members roster with it — and
['kirocrewConfig']alongside it, the pairing #12740 established for a member write (the same write lands inconfig.json, whose masked read ships the agent records):['kirocrew-agents']is invalidated as a prefix, which is how the members roster (['kirocrew-agents', 'members-roster']) comes along.['kirocrewConfig']is the pairing #12740 established for the same backend write.Tests
Added a regression test that mounts the Crews tab's own
['kirocrew-agents']query beside the tab under the productionstaleTime: Infinity(the suite's per-test client uses the library default, where a remount would refetch and hide the bug). It asserts the enrolled crewmate appears on the roster after enroll.Local run on this branch (rebased onto current
main):vitest run src/test/AgentTemplatesTab.test.tsx— 28/28 pass (incl. the new test)tsc --noEmit— cleaneslinton the two changed files — cleanPattern harvest
A client-side write that fans out to more than one read model must invalidate every key that reads it, not just the one the originating tab renders — especially under
staleTime: Infinity, where no background refetch will paper over a missed key. The members roster rides the['kirocrew-agents']prefix and['kirocrewConfig']carries the same records by design, so a crew registry write has to name all three.Rule candidate: When a React Query mutation writes a resource that several queries read (here a crew registry write read by
['agent-templates'], the['kirocrew-agents']prefix, and['kirocrewConfig']), invalidate every reader's key inonSuccess; understaleTime: Infinitya missed key leaves a stale UI with no self-correcting refetch.