Problem
Inside a team scope, the status bar, the assignments page and the triggers pane show the user's personal repos instead of the team's. Six components fetch /api/repos under six different SWR keys, and four of them never attach the x-mogplex-team-id header. The same page load also fires two to four duplicate uncached requests.
Where
Correct (sends the header):
hooks/use-repos.ts:10-24 (key ["/api/repos", activeTeamId], uses getActiveTeamRequestHeaders)
Wrong (no header):
components/status-bar.tsx:26 and :44
hooks/use-assignments.ts:19
components/panes/inline-trigger-form.tsx:30
components/panes/triggers-pane.tsx:33-36
Root cause: lib/client-fetch.ts:34 (fetchJsonArray) calls bare fetch with whatever init it is given, and these callers pass none. There is no global SWRConfig provider, so nothing dedupes across keys.
Fix
- Replace every direct
/api/repos fetch in the four wrong files with useRepos() from hooks/use-repos.ts. Delete the local fetchers.
- Grep for any other
"/api/repos" string in components/ and hooks/ and do the same (rg -n '"/api/repos' components hooks).
- Do not add a second hook. One key, one fetcher.
Exit criteria
Out of scope
Adding a global SWRConfig or a general team-aware fetch wrapper. Worth doing, but as its own change.
https://claude.ai/code/session_01SQ4nS96XYRztd5w9QkubPf
Problem
Inside a team scope, the status bar, the assignments page and the triggers pane show the user's personal repos instead of the team's. Six components fetch
/api/reposunder six different SWR keys, and four of them never attach thex-mogplex-team-idheader. The same page load also fires two to four duplicate uncached requests.Where
Correct (sends the header):
hooks/use-repos.ts:10-24(key["/api/repos", activeTeamId], usesgetActiveTeamRequestHeaders)Wrong (no header):
components/status-bar.tsx:26and:44hooks/use-assignments.ts:19components/panes/inline-trigger-form.tsx:30components/panes/triggers-pane.tsx:33-36Root cause:
lib/client-fetch.ts:34(fetchJsonArray) calls barefetchwith whateverinitit is given, and these callers pass none. There is no globalSWRConfigprovider, so nothing dedupes across keys.Fix
/api/reposfetch in the four wrong files withuseRepos()fromhooks/use-repos.ts. Delete the local fetchers."/api/repos"string incomponents/andhooks/and do the same (rg -n '"/api/repos' components hooks).Exit criteria
rg -n '"/api/repos' components hooks appreturns onlyhooks/use-repos.tsand any server-side callers.tests/unit/foruseAssignments(or the status bar) asserts the request includes thex-mogplex-team-idheader when a team is active. Must fail onmain./api/reposis requested once per page load.pnpm lint,pnpm typecheck,pnpm test:unitpass.Out of scope
Adding a global
SWRConfigor a general team-aware fetch wrapper. Worth doing, but as its own change.https://claude.ai/code/session_01SQ4nS96XYRztd5w9QkubPf