test(desktop): pin the composer mention catalog's context guard #4892
Description
composer-mentions.tsx:132 derives what the composer shows while a Skill catalog is reloading:
const liveCatalog = catalog.contextKey === contextKey
? catalog
: { contextKey, loading: true, settled: undefined, skills: EMPTY_SKILLS };The cached catalog is keyed on contextKey — session id, model, collaboration mode, permission mode, new-task target — and when the context has moved on, the provider must publish a loading placeholder rather than the previous context's Skills. Otherwise a session switch briefly offers the Skills of the session you just left, and mentionSkillsUnavailable reports the old verdict.
Nothing currently fails if that ternary is inverted. The only coverage near it is a Storybook story (ContextSwitchStartsWithALoadingCatalog), which drives the whole composer through a real browser to observe an aria-busy attribute — it does not pin this derivation, and it is the more expensive of the two places this could live.
What to do
Write a unit test for it in the seam this file already sits in. No new tooling is needed:
tsconfig.main.jsoncompiles whatever the main graph imports, so renderer modules reachable from a test are emitted toapps/desktop/dist/renderer/.composer-mentions.jsis already there.apps/desktop/src/main/__tests__/holds ~146 tests that import renderer modules this way, and 18 of them render React components withlinkedom+createRootundernode --test.agent-graph-panel.test.tsandcomposer-model-picker-recovery.test.tsx(inpackages/ui) are both good models.
Suggested shape: mount ComposerMentionsProvider with a sessionId, let its catalog settle, switch sessionId, and assert that the value published through useComposerMentionsContext reports mentionSkillsLoading: true and empty mentionSkills before the new load resolves — while a same-context refresh keeps the Skills already on screen (that second half is the #2667 regression the surrounding comment describes, and it is worth pinning in the same test file).
Acceptance
Invert the ternary at composer-mentions.tsx:132 and the new test must fail. Restore it and it must pass. Run it with:
npm --workspace @maka/desktop run build:main
cd apps/desktop && node --test --test-concurrency=4 "dist/main/__tests__/<name>.test.js"Notes
Do not add a test runner. Vitest, jsdom, and a second tsc target were all considered and are unnecessary — this file is already reachable from node --test today.
The directory name is misleading: renderer unit tests live under src/main/__tests__ because that is the tsc project that emits them. Relocating them is a separate change with its own constraints (check-stale-dist maps src/renderer to dist-renderer, and check:architecture enumerates the renderer tree), so please do not do it here.
Activity
[-]test(desktop): give the renderer a per-file unit seam[/-][+]test(desktop): pin the composer mention catalog's context guard[/+]Astro-Han commentedon Sep 6, 2026
Correction to the original description: this issue first claimed
apps/desktophad no per-file unit seam for renderer code and asked for one to be built. That was wrong. The seam exists and is in heavy use —tsconfig.main.jsonemits every renderer module the main test graph reaches intodist/renderer/(105 of them today), andcomposer-mentions.jsis already among them. The issue has been rewritten to the actual gap, which is one missing test.Totoro-qaq commentedon Sep 6, 2026
take
test(desktop): cover composer mention catalog context guard
test(desktop): cover composer mention catalog context guard (#4894)