Skip to content

test(first-run-tour): end the tour in the order finish() writes it - #19003

Open
christian-byrne wants to merge 2 commits into
mainfrom
gc-38/first-run-tour-controller-ending-order
Open

christian-byrne wants to merge 2 commits into
mainfrom
gc-38/first-run-tour-controller-ending-order

Conversation

@christian-byrne

Copy link
Copy Markdown
Contributor

Test-only. No production file is touched; git diff on src/ outside the one test file is empty.

What this fixes

useFirstRunTourController.test.ts's endTour helper wrote lastEnding before clearing activeTour. finish() in onboardingTourStore.ts does the opposite:

if (!dispatch({ type: 'ended', run })) return   // → IDLE, so activeTour and step fall here
if (ending.tour) lastEnding.value = …           // only then

The controller's teardown watcher fires on activeTour === 'firstRun' going false and reads engine.lastEnding in the callback. With the ending written first, the test cannot tell a watcher that reads it after the flush from one that reads it during. Measured, not argued: adding { flush: 'sync' } to that watcher — which in production would read lastEnding one statement before finish() writes it — leaves all 62 tests green. With the writes in production order the same change fails exactly one test, congratulates a tour the user walked to the end, which is the test that would be wrong in production.

And five teardowns that arranged a state production cannot reach

Five tests cleared activeTour on its own, leaving lastEnding null after a step had already been shown. There is no production path to that pair:

  • ended is dispatched only from finish(), which always records an ending when a tour was active;
  • resolvedEmpty is the one other transition to IDLE (tourState.ts:98) and it is refused unless state.phase === 'resolving', i.e. before any step exists.

They now end through endTour(COMPLETED). The genuinely ending-less end keeps its cover in congratulates nobody when the tour never appeared, which models it the way begin() produces it — request, resolve nothing, return to idle inside startTour.

The effect on coverage is visible: making the watcher bail on a null ending (if (!ending) return) failed 5 tests before, of which only that one arranged a reachable state; after, it fails exactly that 1. Forgetting the outcome instead (tourWasCompleted = ending !== null) still fails the same 4 congratulates nobody for a tour … cases, before and after — the value of the read was already covered, only its timing was not.

Checks

check result
npx vitest run --testTimeout=30000 src/renderer/extensions/firstRunTour/tour/useFirstRunTourController.test.ts 62 passed (62 before)
npx vitest run --testTimeout=30000 src/renderer/extensions/firstRunTour/ src/extensions/core/agentPanel.test.ts src/components/graph/GraphCanvas.test.ts src/views/GraphView.test.ts 14 files, 373 passed — unchanged
NODE_OPTIONS=--max-old-space-size=8192 npx vue-tsc --noEmit exit 0
oxfmt --check / eslint / oxlint --type-aware clean (round-tripped: an injected no-unnecessary-type-conversion is reported, so the clean result is a real one)
pre-commit hooks ran (lint-staged + typecheck:app)

--testTimeout=30000 on every figure, so machine load under concurrent work cannot be mistaken for a test result.

Base and merge order

Based on main, deliberately. useFirstRunTourController.{ts,test.ts} are byte-identical at main and at #18966's head, so this needs no position in the consent stack. #18986 is the only open PR that touches this test file, and all seven of its hunks are in the starting describe (its beginTour return-type change); this touches endTour and the nudge / run outcome describes, so the two do not overlap.

No test was added, removed or weakened; no production behaviour changed.

`endTour` set `lastEnding` before clearing `activeTour`. `finish()` does the
opposite: `dispatch({ type: 'ended' })` returns the state machine to `IDLE`,
and only then is `lastEnding` assigned. Under the arranged order anything
watching the tour end reads the ending a flush early and still looks correct —
making the watcher `flush: 'sync'` leaves all 62 tests green. With the writes
in production order the same change fails exactly one test,
`congratulates a tour the user walked to the end`.

Five teardowns also cleared `activeTour` on its own, leaving `lastEnding` null
after a step had been shown. No production path reaches that: `ended` is only
dispatched from `finish()`, which always records an ending, and `resolvedEmpty`
— the one ending-less return to `IDLE` — can only fire while the tour is still
resolving. They now end through `endTour(COMPLETED)`. The ending-less end keeps
its cover in `congratulates nobody when the tour never appeared`, which models
it the way `begin()` produces it.

No test added, removed or weakened; 62 passed before and after.
@christian-byrne
christian-byrne requested a review from a team September 26, 2026 13:21
@github-actions

github-actions Bot commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

🔬 E2E Coverage: ⚠️ Coverage collection failed — check the CI workflow logs

🎨 Storybook: ✅ Built — View Storybook

Details

⏰ Completed at: 11/10/2026, 10:24:22 PM UTC

Links

🧩 Custom Nodes Ecosystem Matrix: 🟡 Withheld — could not measure

Executes the frontend JS of every registry pack that ships any, against this change, in both renderers. The eight ecosystem-matrix shard checks are a harness self-test; the pack verdict is matrix-verdict.

This candidate changes nothing the matrix measures, so every expensive stage was skipped.

Reproduce locally
# build one shard's fixture, then run it
python3 scripts/registry-census/build_matrix.py --shard 1/4
MATRIX_RENDERER=vue MATRIX_VUE=1 \
  npx vitest run --config vitest.matrix.config.mts

Full docs: scripts/registry-census/README.md

🌾 Fallow: ✅ Passed

Findings and check details

Fallow audits the diff for duplication, complexity and dead code. It gates on new findings only, so when the audit completes, a red is something this PR introduced or moved — never inherited backlog. A red can also mean the audit itself did not finish; the details below say which happened.

No new findings in the changed files.

Full docs: ADR-DEVEX-LINT-0015

Reproduce locally
# the base the gate compared against
npx fallow audit --root . --quiet --format json \
  --changed-since eaa5f001207633183f92c347fb31c7fba50ba86d

🏛️ Architecture: 🟡 Withheld — could not measure

Reproduce locally
pnpm architecture:check

Full docs: Frontend domain catalog

@coderabbitai

coderabbitai Bot commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The first-run tour test helper now clears activeTour and step before setting lastEnding. Several tests now end tours through endTour(COMPLETED).

Changes: First-run tour tests

Layer / File(s) Summary
Tour ending helper and test calls
src/renderer/extensions/firstRunTour/tour/useFirstRunTourController.test.ts
The helper clears activeTour and step before setting lastEnding. Several tests use endTour(COMPLETED) to end tours.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Change: Other

Possibly related PRs

  • Comfy-Org/ComfyUI_frontend#20411: Both PRs address first-run post-tour nudge behavior. This PR updates tests for ending tours; the related PR changes when and where the nudge appears.

Suggested reviewers: drjkl

Merge Risk: Minimal · up to 3561e

This change only adjusts test setup to match the order in which the production code ends a tour. It does not change runtime behavior, and no merge-blocking risk remains.

Important

Pre-merge checks failed

Please resolve all errors before merging. Addressing warnings is optional.

Failed Failed checks: 1 inconclusive

Check name Status Explanation Resolution
Website End-To-End Regression Coverage Inconclusive The commit subjects are available, but the authoritative changed-file list is not available in the permitted review context. The PR description does not rule out changes outside src/. Provide the changed-file list for the PR relative to its base.
Passed Passed checks: 6 passed

Check name Status Explanation
Title check Passed The title clearly identifies the test change: ending the tour in the same order as finish() writes its state.
Description check Passed The description explains the problem and resulting test behavior, and provides verification commands with results. It covers the template’s summary and verification requirements, despite using differe…
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.
End-To-End Regression Coverage For Fixes Passed The PR title and commit subjects do not use bug-fix language. The end-to-end regression test requirement does not apply.
Adr Compliance For Entity/Litegraph Changes Passed The reported changed file is a first-run tour test. It is not under the specified paths or related to graph entities, so this check does not apply.
Full details: Description check

Explanation

The description explains the problem and resulting test behavior, and provides verification commands with results. It covers the template’s summary and verification requirements, despite using different section headings.

Finishing Touches

Generate docstrings

  • Commit to this branch
  • Create a new PR
Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 2843755 and 3561e02.

Files selected for processing: 1

  • src/renderer/extensions/firstRunTour/tour/useFirstRunTourController.test.ts
Files with no reviewable changes: 1

  • src/renderer/extensions/firstRunTour/tour/useFirstRunTourController.test.ts

Included review availability: This review used your included allowance. 7 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 8 reviews per hour.

coderabbitai[bot]
coderabbitai Bot previously approved these changes Sep 26, 2026
@codecov

codecov Bot commented Sep 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

@@            Coverage Diff             @@
##             main   #19003      +/-   ##
==========================================
+ Coverage   84.04%   84.94%   +0.90%     
==========================================
  Files        3158     2309     -849     
  Lines      154414   133073   -21341     
  Branches    41918    35968    -5950     
==========================================
- Hits       129772   113040   -16732     
+ Misses      23037    19715    -3322     
+ Partials     1605      318    -1287     
Flag Coverage Δ
billing-web-unit ?
unit 81.10% <ø> (-0.01%) ⬇️
website-unit ?

Flags with carried forward coverage won't be shown. Click here to find out more.
see 850 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions github-actions Bot added the risk:medium PR risk grade (advisory shadow check; grader-owned) label Sep 26, 2026
MaanilVerma
MaanilVerma previously approved these changes Oct 2, 2026

@MaanilVerma MaanilVerma left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Re-ran both mutations from the description on this branch with main merged in. Adding { flush: 'sync' } to the teardown watcher passes all 69 tests with main's version of this file and fails exactly congratulates a tour the user walked to the end with yours. The null-ending bail goes from 5 failures to 1. (The description says 62; main has added tests since, and the claim still holds.)

Check Result
sync-flush watcher caught pass (0 to 1)
null-ending bail pass (5 to 1)
five teardowns were unreachable pass, read against tourState.ts
lint and format pass
helper JSDoc nitpick, inline A below

question: #19013 rewrites this same endTour helper and these five call sites, and its version still writes lastEnding before tourIsOver(). Whichever of the two lands second will conflict here. Could the second one keep this order, and maybe the five teardowns as endTour(COMPLETED)? Otherwise the sync-flush mutation goes back to green with no test noticing.

Approving. The JSDoc nitpick is optional.

Comment on lines +99 to +105
/**
* The engine ending the tour and recording how, in the order `finish()` writes
* them: `dispatch({ type: 'ended' })` returns the state machine to `IDLE` — so
* `activeTour` and `step` fall together — and only then is `lastEnding`
* assigned. Writing the ending first would leave anything watching the tour end
* free to read it a flush early and still look correct.
*/

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

A

nitpick (non-blocking): this JSDoc narrates finish()'s internals (dispatch({ type: 'ended' }), IDLE), and that will drift the next time the store changes. The one thing a reader needs is that the order is load-bearing. Could we cut it to something like /** Ends the tour the way \finish()` does: state first, then `lastEnding`. */`?

Removed unnecessary comments from endTour function.
@DrJKL
DrJKL dismissed stale reviews from MaanilVerma and coderabbitai[bot] via 3561e02 November 10, 2026 22:22
@DrJKL
DrJKL enabled auto-merge November 10, 2026 22:22
@datadog-official

datadog-official Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

Pipelines

❌ Errors

Your PR has failed checks. Please review the issues below and take necessary action before merging.

🚦 5 Pipeline jobs failed

CI: Tests E2E | e2e-status

View in Datadog · View in GitHub Actions

CI: Tests E2E | lint-and-format

View in Datadog · View in GitHub Actions

CI: Tests E2E | lint-pr / lint

View in Datadog · View in GitHub Actions

View all 5 failed jobs.

Useful? React with 👍 / 👎

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 3561e02 | Docs | View more details | Give us feedback!

@github-actions github-actions Bot added risk:high PR risk grade (advisory shadow check; grader-owned) and removed risk:medium PR risk grade (advisory shadow check; grader-owned) labels Nov 10, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk:high PR risk grade (advisory shadow check; grader-owned)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants