Skip to content

test(desktop): cover composer mention catalog context guard - #4894

Merged
Astro-Han merged 1 commit into
apache:mainfrom
Totoro-qaq:test/composer-mentions-context-guard
Sep 6, 2026
Merged

test(desktop): cover composer mention catalog context guard#4894
Astro-Han merged 1 commit into
apache:mainfrom
Totoro-qaq:test/composer-mentions-context-guard

Conversation

@Totoro-qaq

Copy link
Copy Markdown
Contributor

Summary

Fixes #4892

Add three regression tests for ComposerMentionsProvider using the existing node:test + linkedom setup:

  • Observe the first committed context value after switching sessions, before passive effects can hide stale Skills or an unavailable verdict.
  • Cover switches from both populated and empty catalogs.
  • Keep settled Skills visible during a same-context refresh until its response resolves.

Production code, dependencies, compiler configuration, and test locations are unchanged.

Verification

  • npm --workspace @maka/desktop run build:main — passed.
  • New suite: node --test --test-concurrency=4 dist/main/__tests__/composer-mentions.test.js from apps/desktop — 3 passed; also passed in 20 consecutive fresh processes.
  • Existing agent-graph-panel and composer-directories suites — 23 passed.
  • Mutation checks, each rebuilt from source:
    • Invert the context comparison — all 3 tests fail.
    • Remove the render guard — both session-switch tests fail.
    • Clear Skills during same-context refresh — the refresh test fails.
    • Restore production code and rebuild — all 3 tests pass.
  • npm run lint, npm run format:check, npm run build, and npm run typecheck — passed.
  • npx knip --workspace apps/desktop and npx knip --workspace packages/ui — passed.
  • Desktop architecture checks — passed, including 101 checker tests.

Not run: full-repository npm test, Storybook browser smoke, or Electron GUI E2E.

AI use

  • No generative tool made a substantive contribution
  • Generative tooling made a substantive contribution

Tool(s) and scope:

  • OpenAI Codex: test implementation and local verification.
  • DeepSeek Harness (deepseek-v4-pro, reasoning effort max): independent read-only review and focused test execution.

Checklist

  • Tests cover the change and fail without it
  • Lint, format, typecheck and the affected suites pass locally

Does this PR entail a change in behavior?

  • Yes — described under Summary above
  • No

@github-actions github-actions Bot added the effort/M Under 500 readable lines label Sep 6, 2026
@Totoro-qaq

Copy link
Copy Markdown
Contributor Author

@Astro-Han CI is currently blocked at check:e2e-budget:

session-workbar.spec.ts: budget records 5 test(s), the file has 6

The same mismatch is present on current main. This PR only adds a node:test file and does not change the Electron E2E tier or its budget.

Could you take a look at the budget mismatch? I've kept that unrelated change out of this PR.

TYSM!

Failed check

@hqhq1025 hqhq1025 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed exact head c926fb260aee2914013965a239688618489df758. I found no P0-P3 issues in this test-only change.

The new apps/desktop/src/main/__tests__/composer-mentions.test.ts exercises the real ComposerMentionsProvider and reads the exposed catalog from a layout effect before the provider passive effect runs. It therefore pins the production timing contract: switching sessions immediately hides both populated and empty stale catalogs, while a same-context refresh retains settled skills. Independent mutation probes confirmed the tests fail if the context-key guard is inverted or if same-context refreshes clear the catalog.

Validation passed on the exact branch: clean install, build, Desktop typecheck, focused tests (26/26), full Desktop tests (2230/2230), renderer architecture (101/101), Biome/format, ASF headers, diff check, and the branch-local E2E budget. A clean synthetic merge with current main also built and passed focused tests (26/26), full Desktop tests (2289/2289), and architecture checks.

The required hosted test check is still red because the current merge tree contains an unrelated E2E budget mismatch in session-workbar.spec.ts (6 tests versus a budget of 5). The synthetic merge also exposes unrelated current-main Storybook type errors around WorkbarLayoutState.rightCollapsed. Neither path is touched by this PR, so I am not filing a PR finding for them, but the required gate is not green and this is not a merge approval.

Automated review notice: This comment was posted by an automated review agent operated by hqhq1025. It is not an independent human review and does not replace one.

Astro-Han added a commit that referenced this pull request Sep 6, 2026
…4895)

`check:e2e-budget` and the Storybook typecheck both failed on `main` after #4694 merged: that PR added a sixth test to `session-workbar.spec.ts` without updating `e2e-budget.json`, and replaced `WorkbarLayoutState.rightCollapsed` with `activeSessionId` + `collapsedBySession` while #4877 had just landed `stories/app-shell.stories.tsx` building the old shape. Its CI ran on a base that predated both, so neither showed until merge (reported on #4894).

The budget entry now records 6 tests and names the Electron-owned mechanism (per-Session collapse persisted across a renderer reload). The story builds the new layout state and reads the collapse bit through `isSessionWorkbarCollapsed`, as the controller does. No behavior change; no migration.

Refs #4694, #4761, #4877, #4894

Generated-by: Claude Code
Test the first committed catalog after a session switch, before passive
effects can reset stale state. Cover populated and empty catalogs, and
preserve settled skills during same-context refreshes.

Reuse the existing node:test and linkedom setup without production changes.

Fixes apache#4892

Generated-by: OpenAI Codex
@Totoro-qaq
Totoro-qaq force-pushed the test/composer-mentions-context-guard branch from c926fb2 to da01731 Compare September 6, 2026 07:00
@Totoro-qaq

Copy link
Copy Markdown
Contributor Author

@Astro-Han Thanks for fixing the main-branch blockers in #4895! I've rebased onto main, and CI now passes at da01731.

The patch is unchanged: one test file covering #4892, with no production changes. Could you take a look when you have a chance?

tysm!

@Astro-Han Astro-Han left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed at da01731 against main (90014db94), +195/−0, one test file, CI green.

This is the test #4892 asked for, in the tier it asked for: ComposerMentionsProvider mounted through the existing node:test + linkedom path under src/main/__tests__, observing the first committed context after a Session switch before passive effects can hide stale Skills, from both populated and empty catalogs, plus the same-context refresh keeping settled Skills visible. The mutation checks in the body (inverted comparison, removed guard, cleared Skills on refresh) are the three regressions the guard exists to catch, and each is caught by at least one test. No production code touched.

Thanks for the report on the budget breakage too; #4895 fixed it on main.

AI-assisted review: drafted with Maka; I read the three tests against composer-mentions.tsx myself.

@Astro-Han
Astro-Han merged commit 083027a into apache:main Sep 6, 2026
1 check passed
@Totoro-qaq
Totoro-qaq deleted the test/composer-mentions-context-guard branch September 6, 2026 08:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort/M Under 500 readable lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test(desktop): pin the composer mention catalog's context guard

3 participants