Skip to content

host tests: wait for new-room skills to load before simulating bot message#4941

Open
habdelra wants to merge 1 commit into
mainfrom
worktree-commands-test-flake-fix
Open

host tests: wait for new-room skills to load before simulating bot message#4941
habdelra wants to merge 1 commit into
mainfrom
worktree-commands-test-flake-fix

Conversation

@habdelra
Copy link
Copy Markdown
Contributor

Summary

Two acceptance tests in commands-test.gts intermittently failed on CI (shard 17 of the host test suite):

  • ShowCard command added from a skill, can be automatically executed when agentId matches — timed out waiting for apply-state="applied"
  • command request with arguments that do not match the json schema gets an "invalid" result — warning text was No command for the name "show-card_566f" was found instead of the expected JSON-schema validation message

Root cause

Both tests click [data-test-create-room-btn] and then immediately simulateRemoteMessage with a command request for show-card_566f, which is a function on the env skill that the new room auto-attaches.

The new room's processRoomTask is still mid-loadSkills when the simulated bot event lands; message-builder walks builderContext.skills and calls store.get<Skill>(skill.cardId), but the env skill is not in the store yet, so the request never resolves to a codeRef and command-service falls into the "No command for the name X was found" branch instead of executing or running the JSON-schema validator.

Fix

  • New helper waitForNewRoomSkillsLoaded(roomId): polls until the room's enabledSkillCards is populated and roomResource.commands.length > 0 (commands is computed from the loaded skill instances in the store, so a non-empty list proves loadSkills finished and the skill's @field commands field is materialised). On timeout it throws with a JSON diagnostic snapshot of skillsConfig + the room resource's view, so a future flake reports enough state to distinguish "no skill loaded" from "skill loaded but commands missing".
  • Used in the two failing tests and the third sister test (is not automatically executed when agentId does not match), which has the same setup and was passing by luck.
  • Inline diagnostic logging in the two failing tests around the assertions that have been flaking, so we capture rendered apply states, warnings, and room/skill state if either still misses after the fix.

Test plan

  • CI passes shard 17 of host tests
  • Run the three affected tests locally a few times to confirm no flake
  • If a CI failure recurs, the diagnostic logs in the test/helper attribute it cleanly

🤖 Generated with Claude Code

…ssage

Two acceptance tests in commands-test.gts intermittently failed on CI
(shard 17 of the host test suite):

  - "ShowCard command added from a skill, can be automatically executed
    when agentId matches" — timed out waiting for apply-state="applied"
  - "command request with arguments that do not match the json schema
    gets an 'invalid' result" — warning text was 'No command for the
    name "show-card_566f" was found' instead of the expected JSON-schema
    validation message

Both tests click [data-test-create-room-btn] and then immediately
simulateRemoteMessage with a command request for show-card_566f, which
is a function on the env skill that the new room auto-attaches. The new
room's processRoomTask is still mid-loadSkills when the simulated bot
event lands; message-builder walks builderContext.skills and calls
store.get<Skill>(skill.cardId), but the env skill isn't in the store
yet, so the request never resolves to a codeRef and command-service
falls into the "No command for the name X was found" branch instead
of executing or running the JSON-schema validator.

Add waitForNewRoomSkillsLoaded(roomId): polls until the room's
enabledSkillCards is populated *and* roomResource.commands.length > 0
(commands is computed from the loaded skill instances in the store, so
a non-empty list proves loadSkills finished and the skill's @field
commands field is materialised). On timeout it throws with a JSON
diagnostic snapshot of skillsConfig + the room resource's view, so a
future flake reports enough state to distinguish "no skill loaded" from
"skill loaded but commands missing".

Use the new helper in the two failing tests and in the third sister
test ('is not automatically executed when agentId does not match'),
which has the same setup and was passing by luck. Also add inline
diagnostic logging in the two failing tests around the assertions that
have been flaking so we capture rendered apply states, warnings, and
room/skill state if either still misses after the fix.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 22, 2026

Preview deployments

Host Test Results

    1 files      1 suites   1h 49m 0s ⏱️
2 724 tests 2 709 ✅ 15 💤 0 ❌
2 743 runs  2 728 ✅ 15 💤 0 ❌

Results for commit 00a61ed.

Realm Server Test Results

    1 files      1 suites   10m 5s ⏱️
1 482 tests 1 482 ✅ 0 💤 0 ❌
1 573 runs  1 573 ✅ 0 💤 0 ❌

Results for commit 00a61ed.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Reduces CI flakiness in host acceptance tests by ensuring a newly created AI assistant room has finished loading its default skills (and derived commands) before simulateRemoteMessage dispatches command requests that depend on those skills being present in the store.

Changes:

  • Added waitForNewRoomSkillsLoaded(roomId) test helper that waits until the room’s enabled skills are present and the room resource exposes non-empty commands, with enriched timeout diagnostics.
  • Updated three acceptance tests to await skill/command readiness before simulating show-card_566f command requests.
  • Added targeted console diagnostics on the previously-flaking assertions to improve future failure triage.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
packages/host/tests/helpers/index.gts Adds a polling helper that waits for new-room skill loading to complete and enriches failures with diagnostic state.
packages/host/tests/acceptance/commands-test.gts Uses the new helper to remove the skill-load race before simulating bot command requests; adds diagnostic logging around flaky assertions.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@habdelra habdelra requested a review from a team May 22, 2026 21:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants