Skip to content

test(coach): guard the run-end snapshot → curPw seam (v0.2.6) - #20

Merged
ChrisBeWithYou merged 1 commit into
mainfrom
test/coach-snapshot-seam
Jul 16, 2026
Merged

ChrisBeWithYou merged 1 commit into
mainfrom
test/coach-snapshot-seam

Conversation

@ChrisBeWithYou

@ChrisBeWithYou ChrisBeWithYou commented Jul 16, 2026 •

Copy link
Copy Markdown
Collaborator

Why

The v0.2.5 coach bug (_lastEndedSession snapshot dropped pathway_id/practice_type → "Practice next" re-prescribed the just-run rung) shipped green because smoke-coach-rx only exercised the pure coachRxFor with a hand-built ctx (explicit curPw) — it never covered the snapshot construction that broke. This closes that gap.

What

A new smoke section drives a real >2s pathway run (select rung → Play → Stop) and asserts against the actual seam:

  • _lastEndedSession carries mode==='pathway', pathway_id (=== the run's rung), and a truthy practice_type;
  • the real buildCoachRx, fed that snapshot + a finger fault, does not re-prescribe the just-run rung and falls to its sibling (fs_spider_adjacent).

Exposes buildCoachRx + lastEndedSession on the existing window.__virtuosoCoach debug hook (test-only surface, inert for users — no behavior change).

Proof the guard bites

Re-dropping pathway_id from the snapshot turns the new asserts red — the behavioral one re-prescribes chromatic_warmup (the exact bug) — and green once restored:

[FAIL] snapshot carries pathway_id (the dropped field)  pathway_id=undefined
[FAIL] coach does NOT re-prescribe the just-run rung (curPw honored)  → chromatic_warmup
[FAIL] a finger fault on chromatic_warmup falls to its sibling  → chromatic_warmup (want fs_spider_adjacent)

Full suite green with the fix in place. node --check clean.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Improved pathway practice coaching to preserve session details and provide more relevant follow-up pathway recommendations.
  • Bug Fixes
    • Prevented recently completed pathways from being immediately recommended again when a related finger issue is detected.
  • Chores
    • Updated the plugin to version 0.2.6.

Closes the test gap that let the v0.2.5 coach bug ship green: smoke-coach-rx
only exercised the PURE coachRxFor with a hand-built ctx (explicit curPw), so
it never covered the _lastEndedSession snapshot construction that dropped
pathway_id/practice_type.

New smoke section drives a REAL >2s pathway run (select rung → Play → Stop),
then asserts against the actual seam:
  - _lastEndedSession carries mode==='pathway', pathway_id (=== the run's rung),
    and a truthy practice_type;
  - the REAL buildCoachRx, fed that snapshot + a finger fault, does NOT
    re-prescribe the just-run rung and falls to its sibling (fs_spider_adjacent).

Verified the guard bites: re-dropping pathway_id from the snapshot turns the
new asserts red (behavioral one re-prescribes chromatic_warmup, the exact bug),
green once restored.

Exposes buildCoachRx + lastEndedSession on the existing window.__virtuosoCoach
debug hook (inert for users; test-only surface). No user-facing behavior change.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MS2YFb6UUSwJVV6CmEa25i
@coderabbitai

coderabbitai Bot commented Jul 16, 2026 •

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The plugin version is updated to 0.2.6, the coach debug hook exposes the latest ended session, and a smoke test validates pathway session snapshots and follow-up prescription selection.

Changes

Coach prescription regression

Layer / File(s) Summary
Ended-session debug contract
plugin.json, screen.js
The plugin version changes to 0.2.6, and window.__virtuosoCoach exposes lastEndedSession().
Pathway prescription regression
.claude/skills/run-virtuoso/smoke-coach-rx.mjs
The smoke test runs a real pathway session, verifies mode, pathway_id, and practice_type, and checks that buildCoachRx selects the expected sibling pathway without repeating the completed pathway.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise and accurately highlights the main change: guarding the run-end snapshot to curPw seam in coach smoke tests.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch test/coach-snapshot-seam

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ast-grep (0.44.1)
screen.js

ast-grep timed out on this file


Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.claude/skills/run-virtuoso/smoke-coach-rx.mjs:
- Around line 160-164: Guard the stop sequence after the `#virtuoso-play` startup
in the smoke test using the started result. Only wait for the duration gate and
click `#virtuoso-stop` when startup succeeds; otherwise fail fast with a focused
startup failure while preserving the existing ok assertion.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 8c4c43ef-a130-44d7-acd9-e977dea04525

📥 Commits

Reviewing files that changed from the base of the PR and between e3a3870 and be51e10.

📒 Files selected for processing (3)
  • .claude/skills/run-virtuoso/smoke-coach-rx.mjs
  • plugin.json
  • screen.js

Comment on lines +160 to +164
await page.click("#virtuoso-play");
const started = await page.waitForSelector("#virtuoso-stop:not([disabled])", { timeout: 8000 }).then(() => true).catch(() => false);
ok(started, "real pathway run started (stop button armed)");
await page.waitForTimeout(4200); // clear the 2s duration gate even with a count-in
await page.click("#virtuoso-stop");

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

Guard the stop sequence when startup fails.

ok(started, ...) records the failure, but execution still clicks Stop. If startup times out, that action can fail separately and obscure the actual root cause. Guard the wait/stop sequence with started or fail fast with a focused startup error.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.claude/skills/run-virtuoso/smoke-coach-rx.mjs around lines 160 - 164, Guard
the stop sequence after the `#virtuoso-play` startup in the smoke test using the
started result. Only wait for the duration gate and click `#virtuoso-stop` when
startup succeeds; otherwise fail fast with a focused startup failure while
preserving the existing ok assertion.

@ChrisBeWithYou
ChrisBeWithYou merged commit 8436194 into main Jul 16, 2026
3 checks passed
@ChrisBeWithYou
ChrisBeWithYou deleted the test/coach-snapshot-seam branch July 16, 2026 14:26
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.

1 participant