Skip to content

test(agent): make a release/hold disagreement fail red instead of killing the vitest worker - #18989

Merged
DrJKL merged 9 commits into
fix/agent-consent-defer-first-run-screenfrom
gc-37/pin-hold-release-agreement
Sep 28, 2026
Merged

DrJKL merged 9 commits into
fix/agent-consent-defer-first-run-screenfrom
gc-37/pin-hold-release-agreement

Conversation

@christian-byrne

@christian-byrne christian-byrne commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

Problem

The release watcher must agree with screenHolder() about whether the consent offer is held. If release instead ignores the first-run holder, the offer is released and re-held in a microtask loop; without a bound, Vitest loses the worker rather than reporting an assertion.

Change

  • Wrap the mocked whenStartupDecided startup probe in a vi.fn with a 20-call circuit breaker. The mock owns and automatically resets its call history.
  • Use that bounded startup probe to let the existing exact consentStore.load assertion report a release/hold disagreement across the first-run screen, tours, their composition, and the sign-in dialog.
  • Keep the source comment scoped to those holder cases. Production code is unchanged.

Verification

At be2570918f, stacked on #18977 2361f7ad65:

  • pnpm test:unit src/extensions/core/agentPanel.test.ts --testTimeout=30000 — 74/74 passed.
  • Mutating screenIsClear from screenHolder() === null to screenBusyReason() === null, then running the same command, produces an ordinary red result: 4 failed / 70 passed; the first failure reports 21 consent loads instead of 1. The mutation was reverted and the passing command rerun.
  • The current effective diff against test(agent): pin the consent hold's reason precedence, and mark the one arrange production cannot produce #18977 changes only src/extensions/core/agentPanel.test.ts; production code is byte-identical to the base.

Full command/result note: #18989 (comment)

Merge order

This remains stacked directly after #18977. The updated #18977 head was merged into this branch before verification; do not merge this PR before #18977.

…ne arrange production cannot produce

An audit of every arrange in `agentPanel.test.ts` that writes
`gettingStartedVisible`, `firstRunHoldsScreen` or `activeTour` directly, after
two defects in a row hid behind a test that arranged state no production
ordering reaches.

One arrange is unreachable: `withholds a card whose Getting Started screen took
over while the offer was in flight`. `gettingStartedVisible` is set true only by
`showFirstRunScreen`, which runs once per page load from `handleStartupOutcome`
and always before it sets `startupDecided`; `tourHandoffs` only rises from a
template click on the rendered screen. Every automatic offer waits on
`whenStartupDecided()`, so the first-run hold can only fall while an offer is in
flight, never rise. The test stays — it is the only cover on `canShow` reading
`screenHolder()` rather than `screenBusyReason()` — renamed so it no longer
claims an ordering production produces, with the invariant it leans on written
down next to it.

One real gap: nothing pinned which reason wins when the first run and another
surface hold together. Swapping the precedence in `screenHolder` left all 70
tests green. The screen is built for a dialog over it (`FocusScope` traps focus
only while `!dialogOpen`), and the reported reason decides whose
`agent_consent_not_offered` denominator the user lands in, so it is behaviour:
first run wins while it holds the screen. Red on the swap, green restored.

No production change.
…ent fails red

The comment at agentPanel.ts:210-216 warns that release must agree with hold
about what "the screen" is. Making it disagree does not fail a test: the offer
releases, the next attempt re-holds it on the same tick, and the pair spins in
pure microtasks. That starves the macrotask queue, so `flush()` never resolves,
no expectation is evaluated, and the vitest worker dies of an OOM ~45 s in. CI
reports that as a dead runner, which gets retried, rather than as a red test,
which gets read.

Two test-only changes, no production change:

- the fixture's startup probe stops answering past 20 attempts (5x the most any
  passing test here needs, measured 4), so the cycle unwinds and every test in
  the file reaches its own assertions instead of the worker dying at the fifth;
- three cases assert the held offer is not re-driven - one per holder
  `screenHolder` knows about, because each is the only case that fails when
  release forgets that holder.

Proof, on this branch: release on `screenBusyReason()` instead of
`screenIsClear` took the whole file from "worker exited unexpectedly, 4 of 71
reported, 44.7 s, 4.5 GB" to "6 failed | 68 passed, 15.3 s, 2.1 GB", with the
new case reporting `expected 21 to be less than or equal to 2`.
@coderabbitai

coderabbitai Bot commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository: Comfy-Org/ComfyUI_frontend/.coderabbit.yaml

Review profile: ASSERTIVE

Plan: Team

Run ID: c7398171-216d-40ef-9afe-26cddd02000a

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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

@github-actions

github-actions Bot commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

🎨 Storybook: ✅ Built — View Storybook

Details

⏰ Completed at: 09/28/2026, 01:35:49 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

📦 Bundle Size

⏳ Size data collection in progress…

🌾 Fallow: ✅ Passed

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.

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

Full docs: ADR-DEVEX-LINT-0015

@github-actions github-actions Bot added the risk:high PR risk grade (advisory shadow check; grader-owned) label 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                              @@
##           fix/agent-consent-defer-first-run-screen   #18989      +/-   ##
============================================================================
- Coverage                                     85.05%   85.02%   -0.04%     
============================================================================
  Files                                          2316     2317       +1     
  Lines                                        133714   133744      +30     
  Branches                                      34247    36174    +1927     
============================================================================
- Hits                                         113731   113710      -21     
- Misses                                        19665    19716      +51     
  Partials                                        318      318              
Flag Coverage Δ
unit 81.39% <ø> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.
see 35 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.

@DrJKL DrJKL added agent Comfy Agent product, integration, tests or product documentation agent-test-only Agent tests, fixtures and test support only; no production changes agent-test-unit Touches Agent-related unit/component tests or their support agent-ui Agent panel, composer, transcript or other user-interface components labels Sep 27, 2026
@DrJKL
DrJKL self-requested a review September 28, 2026 00:53

@DrJKL DrJKL 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.

Verdict: needs follow-up on duplicated regression coverage and unsupported proof claims

There are no P0 or P1 blockers. The inline comments cover two material findings and one minor test-fixture issue.

Finding without an anchorable line
  • [P3] Nit: The two commands in the PR description use npx vitest. Repository guidance requires the workspace package manager. Please use pnpm exec vitest so the command runs the locked Vitest version.
Existing findings confirmed or contested

No earlier human or automated review raised an actionable finding.

Unverified candidates
  1. [P2] The description gives exact mutation timing, memory, failure counts, probe provenance, and per-holder uniqueness results. My focused mutations confirmed the core behavior, but the supplied artifacts do not contain all of those measurements. Please link or attach the command and output for each mutation, or narrow the exact figures to what can be inspected.
  2. [P2] I confirmed 74 focused passes, focused ESLint, oxfmt, oxlint, and full typecheck. The broader 217-file run, pre-commit execution, and timeout measurements remain author-reported. Preserving those logs would make this section auditable.
  3. [P2] The stack composition claims for #18975 and #18976, including the consent_read_outcome attribution, have no supplied merge or test logs. Please link those runs or state that they are author-reported.
Checked and cleared
  • I rejected a candidate about a direct release-to-offer call bypassing the cap. That mutation changes the separate design invariant that automatic offers pass through whenStartupDecided; the PR's stated screenIsClear disagreement is bounded and fails as an ordinary assertion.
  • I found no new type assertion, suppression, any, raw error sink, class-array binding, dark: variant, PrimeVue use, or production behavior change.
  • Fallow reported no changed-file finding.
Coverage

Depth: standard. I ran correctness, maintainability, idiomaticity, tests, and documentation lanes over the full one-file diff. The standard specialist lenses ran inside those lanes. Playwright review was not applicable because no browser test changed. No ADR changed.

At 59525b6, the focused suite passed 74 tests. Focused ESLint, oxfmt, oxlint, full typecheck, and Fallow passed. A focused mutation with the new holder table deleted still failed the existing holder table at agentPanel.test.ts:425 with 21 consent loads instead of 2, which confirms the duplication finding.

Comment thread src/extensions/core/agentPanel.test.ts Resolved
Comment thread src/extensions/core/agentPanel.test.ts Resolved
Comment thread src/extensions/core/agentPanel.test.ts Resolved
@christian-byrne

Copy link
Copy Markdown
Contributor Author

Review-fix verification at df42c10f93 (stacked on #18977 2361f7ad65):

  • pnpm exec vitest run src/extensions/core/agentPanel.test.ts --testTimeout=30000 → 74/74 passed.
  • Mutation: changed screenIsClear from screenHolder() === null to screenBusyReason() === null, then ran the same command → ordinary Vitest red: 4 failed / 70 passed in 13.77 s; the first failure reports 21 consent loads instead of 1. The mutation was reverted and the 74/74 pass rerun.
  • Merge-commit pre-commit hooks ran oxfmt, type-aware oxlint, ESLint, and all workspace typechecks successfully.

The review fixes also replace manual module state with mock-owned vi.fn history and fold the disagreement assertion into the existing holder table. No production file differs from #18977.

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

@DrJKL DrJKL 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.

Verdict: ready to approve; one minor redundant assertion remains

The previous inline findings are addressed. M1's duplicate holder table is gone, M2 and D1's source comment is now scoped and stable, and I1's count is owned by the automatically reset startupProbe mock.

The prior evidence candidates are also settled. I independently reproduced D2's mutation at this head: the run completed with 4 failures and 70 passes, and the first failure reported 21 consent loads instead of 1. For D3, the focused suite passed 74 tests and ESLint, oxfmt, type-aware oxlint, and Fallow passed; the pre-commit/workspace-typecheck detail remains author-reported but is not a source finding. D4's stated base is an ancestor of this head and the effective diff is the stated test file. D5 is fixed because the current commands use pnpm exec.

T1 remains contested as outside this PR's invariant: bypassing whenStartupDecided would change the production release path rather than test the stated release/hold disagreement. The remaining P3 inline note only asks to remove an expectation that cannot report that disagreement before the exact load-count assertion fails.

Depth: standard. I re-ran the correctness, maintainability, idiomaticity, tests, and documentation lanes over the full effective diff. No P0–P2 finding remains.

Comment thread src/extensions/core/agentPanel.test.ts Resolved

@DrJKL DrJKL 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.

Verdict: ready to approve; one stale PR-description bullet remains

Commit be2570918f fixes my remaining test finding: the redundant probe-count expectation is gone, while startupProbe, its cap, and the exact load-count assertion remain. I repeated the release/hold mutation; Vitest reported the retained assertion at 21 loads instead of 1 rather than losing the worker. The focused suite passes all 74 tests, and the exact-head typecheck passes.

Finding without an anchorable line
  • [P3] Nit: Change bullet 2 still says this PR adds “the unique release-agreement assertion,” but the current diff adds no assertion to that table. The exact consentStore.load assertion already exists on the base, and the newly added direct probe assertion was removed in this commit. Please describe the current mechanism instead: the bounded startup probe lets the existing exact load-count assertion report the disagreement.
Prior findings
  • The redundant-assertion finding is fixed by this commit. The earlier table, comment-scope, mock-state, command, evidence, and stack-scope findings remain fixed or cleared.
  • I still reject the direct-offer bypass candidate as outside this PR's invariant because the production release path passes through whenStartupDecided.
Coverage

Depth: standard. I reran correctness, maintainability, idiomaticity, tests, and documentation lanes over the complete effective diff. The focused 74-test suite, ESLint, oxfmt, type-aware oxlint, Fallow, and workspace typecheck pass at be2570918f. The release/hold mutation fails normally at the retained exact load-count assertion. No P0–P2 finding remains.

DrJKL pushed a commit that referenced this pull request Sep 28, 2026
…ne arrange production cannot produce (#18977)

## Summary

Audits every `agentPanel.test.ts` arrangement that directly writes
`gettingStartedVisible`, `firstRunHoldsScreen`, or `activeTour`, after
two regressions hid behind impossible test state. Adds one reachable
reason-precedence regression. Test-only; no production change.

## Changes

- Classified 24 arrangements against production writers and orderings:
23 reachable; one impossible arrangement removed after review.
- Pins `first_run_screen` over `dialog_open` when both hold the
automatic consent offer. Reversing `screenHolder()` precedence makes
this test fail with `dialog_open`; restored production code passes.
- Keeps no test for the impossible mid-offer first-run transition.
`showFirstRunScreen` runs before `startupDecided`, and every automatic
offer waits for that decision, so the first-run hold cannot rise while
an offer is in flight.

<details>
<summary>Audited arrangement inventory and counting rule</summary>

Count one row per setup or transition sequence that directly writes one
or more audited refs; a row may write multiple refs. Dialog-only rows
are included where they compose with an audited ref or establish a
comparison reason.

1. beforeEach idle baseline - reachable
2. Getting Started screen up - reachable
3. coachmark tour active - reachable
4. screen and tour active - reachable
5. desktop sign-in dialog open - reachable
6. screen closes - reachable
7. screen closes into first-run tour - reachable
8. holding tour ends - reachable
9. startup decision remains pending after tour ends - reachable
10. tour ends while an offer remains in flight - reachable
11. tour starts while an offer is in flight - reachable
12. tour ends while consent cannot be read - reachable
13. first-run reason deduplication - reachable
14. tour reason deduplication - reachable
15. dialog reason deduplication - reachable
16. undecided-boot reason deduplication - reachable
17. in-flight tour plus workspace switch - reachable
18. second workspace repeats a tour reason - reachable
19. held offer emits no reason after consent resolves - reachable
20. tour ends while Getting Started remains up - reachable
21. tour ends while a dialog remains open - reachable
22. dialog opens while an offer is in flight - reachable
23. first-run hold rises while an offer is in flight - impossible;
removed
24. manual consent dialog per identity scope - reachable

</details>

## Verification

- `pnpm test:unit src/extensions/core/agentPanel.test.ts
--testTimeout=30000` - 74 passed.
- Precedence mutation `screenBusyReason() ?? (firstRunHoldsScreen ?
'first_run_screen' : null)` - focused regression fails with received
reason `dialog_open`.
- ESLint, oxfmt, and `git diff --check` pass for the changed file.
- CI was green on the rebased parent; fresh CI is running for the review
repair.

## Dependency

Stacked on #18966 because `firstRunHoldsScreen` is introduced there.
Required order remains #18966 -> #18977 -> #18989 -> #18975 -> #18978 ->
#18992.

---------

Co-authored-by: Amp <amp@ampcode.com>
Base automatically changed from gc-33/agentpanel-test-arrange-audit to fix/agent-consent-defer-first-run-screen September 28, 2026 16:29
@DrJKL
DrJKL merged commit 204483d into fix/agent-consent-defer-first-run-screen Sep 28, 2026
84 checks passed
@DrJKL
DrJKL deleted the gc-37/pin-hold-release-agreement branch September 28, 2026 16:30
christian-byrne added a commit that referenced this pull request Sep 28, 2026
…ne arrange production cannot produce (#18977)

## Summary

Audits every `agentPanel.test.ts` arrangement that directly writes
`gettingStartedVisible`, `firstRunHoldsScreen`, or `activeTour`, after
two regressions hid behind impossible test state. Adds one reachable
reason-precedence regression. Test-only; no production change.

## Changes

- Classified 24 arrangements against production writers and orderings:
23 reachable; one impossible arrangement removed after review.
- Pins `first_run_screen` over `dialog_open` when both hold the
automatic consent offer. Reversing `screenHolder()` precedence makes
this test fail with `dialog_open`; restored production code passes.
- Keeps no test for the impossible mid-offer first-run transition.
`showFirstRunScreen` runs before `startupDecided`, and every automatic
offer waits for that decision, so the first-run hold cannot rise while
an offer is in flight.

<details>
<summary>Audited arrangement inventory and counting rule</summary>

Count one row per setup or transition sequence that directly writes one
or more audited refs; a row may write multiple refs. Dialog-only rows
are included where they compose with an audited ref or establish a
comparison reason.

1. beforeEach idle baseline - reachable
2. Getting Started screen up - reachable
3. coachmark tour active - reachable
4. screen and tour active - reachable
5. desktop sign-in dialog open - reachable
6. screen closes - reachable
7. screen closes into first-run tour - reachable
8. holding tour ends - reachable
9. startup decision remains pending after tour ends - reachable
10. tour ends while an offer remains in flight - reachable
11. tour starts while an offer is in flight - reachable
12. tour ends while consent cannot be read - reachable
13. first-run reason deduplication - reachable
14. tour reason deduplication - reachable
15. dialog reason deduplication - reachable
16. undecided-boot reason deduplication - reachable
17. in-flight tour plus workspace switch - reachable
18. second workspace repeats a tour reason - reachable
19. held offer emits no reason after consent resolves - reachable
20. tour ends while Getting Started remains up - reachable
21. tour ends while a dialog remains open - reachable
22. dialog opens while an offer is in flight - reachable
23. first-run hold rises while an offer is in flight - impossible;
removed
24. manual consent dialog per identity scope - reachable

</details>

## Verification

- `pnpm test:unit src/extensions/core/agentPanel.test.ts
--testTimeout=30000` - 74 passed.
- Precedence mutation `screenBusyReason() ?? (firstRunHoldsScreen ?
'first_run_screen' : null)` - focused regression fails with received
reason `dialog_open`.
- ESLint, oxfmt, and `git diff --check` pass for the changed file.
- CI was green on the rebased parent; fresh CI is running for the review
repair.

## Dependency

Stacked on #18966 because `firstRunHoldsScreen` is introduced there.
Required order remains #18966 -> #18977 -> #18989 -> #18975 -> #18978 ->
#18992.

---------

Co-authored-by: Amp <amp@ampcode.com>
christian-byrne added a commit that referenced this pull request Sep 28, 2026
…ling the vitest worker (#18989)

## Problem

The release watcher must agree with `screenHolder()` about whether the
consent offer is held. If release instead ignores the first-run holder,
the offer is released and re-held in a microtask loop; without a bound,
Vitest loses the worker rather than reporting an assertion.

## Change

- Wrap the mocked `whenStartupDecided` startup probe in a `vi.fn` with a
20-call circuit breaker. The mock owns and automatically resets its call
history.
- Use that bounded startup probe to let the existing exact
`consentStore.load` assertion report a release/hold disagreement across
the first-run screen, tours, their composition, and the sign-in dialog.
- Keep the source comment scoped to those holder cases. Production code
is unchanged.

## Verification

At `be2570918f`, stacked on #18977 `2361f7ad65`:

- `pnpm test:unit src/extensions/core/agentPanel.test.ts
--testTimeout=30000` — 74/74 passed.
- Mutating `screenIsClear` from `screenHolder() === null` to
`screenBusyReason() === null`, then running the same command, produces
an ordinary red result: 4 failed / 70 passed; the first failure reports
21 consent loads instead of 1. The mutation was reverted and the passing
command rerun.
- The current effective diff against #18977 changes only
`src/extensions/core/agentPanel.test.ts`; production code is
byte-identical to the base.

Full command/result note:
#18989 (comment)

## Merge order

This remains stacked directly after #18977. The updated #18977 head was
merged into this branch before verification; do not merge this PR before
#18977.

---------

Co-authored-by: Amp <amp@ampcode.com>
christian-byrne added a commit to christian-byrne/ComfyUI_frontend that referenced this pull request Sep 29, 2026
… of dropping it (Comfy-Org#18966)

## Summary

Defers the automatic Agent consent offer while Getting Started owns the
screen, then re-offers it in the same session after that ownership ends.
The template path keeps first-run ownership across the dismissal-to-tour
preview gap, so the consent card cannot open underneath the tour.

The first-session entry-button/feature-flag timing question is separate
and is not changed here.

## Changes

- Arms the consent retry for `first_run_screen` instead of dropping that
offer.
- Uses live first-run screen ownership, including pending screen-to-tour
handoffs, when deciding whether consent can be shown.
- Cancels and releases an in-flight handoff when the authenticated
identity changes, preventing the previous account tour or hold from
crossing sessions.
- Removes the obsolete `firstRunTookScreen` latch.
- Keeps failed template loads on Getting Started and removes duplicate
no-tour coverage.

## Review focus

- `dismissIntoFirstRunTour` snapshots the owner, passes an
identity-change cancellation predicate to `beginTour`, and invalidates
pending holds at the auth boundary.
- Per-call symbols keep concurrent handoff ownership distinct, while
`authGeneration` separately invalidates stale continuations across
authenticated-session changes.
- Bare dismissal releases consent; template selection retains ownership
until the tour has either started, declined, or failed.

## Verification

At current head `e93ee8410e`, rebased directly on `main` at `4ff3690047`
(eleven-file base-to-head diff):

- `pnpm test:unit src/extensions/core/agentPanel.test.ts
src/renderer/extensions/firstRunTour/gettingStarted/GettingStartedScreen.test.ts
src/renderer/extensions/firstRunTour/gettingStarted/firstRunEntry.test.ts
src/renderer/extensions/firstRunTour/tour/useFirstRunTourController.test.ts
--testTimeout=30000` — 4 files, 226 tests passed.
- `bash scripts/test-browser-offline.sh --project=cloud
browser_tests/tests/agent/agentConsent.spec.ts -g 'defers the offer
until Getting Started releases the screen' --workers=1 --repeat-each=5`
— 5/5 passed in 43.2 seconds from a freshly restarted cloud-distribution
Vite process; the scenario-only 90-second budget covers both application
boots.
- ESLint, Oxlint, oxfmt, `git diff --check`, pre-push Knip, and
changed-line Fallow passed. Fallow excluded 17 inherited dependency
findings and reported two inherited styling advisories.

The branch retains the test-only changes from Comfy-Org#18977 and Comfy-Org#18989. Those
PRs were merged into this PR's branch (their GitHub base was
`fix/agent-consent-defer-first-run-screen`), not into `main`; dropping
them during reconciliation would lose their approved coverage. The
rebase preserves the eleven-file product/browser patch while removing
the stale `main` ancestry.

---------

Co-authored-by: Amp <amp@ampcode.com>
christian-byrne added a commit that referenced this pull request Sep 29, 2026
… of dropping it (#18966)

Defers the automatic Agent consent offer while Getting Started owns the
screen, then re-offers it in the same session after that ownership ends.
The template path keeps first-run ownership across the dismissal-to-tour
preview gap, so the consent card cannot open underneath the tour.

The first-session entry-button/feature-flag timing question is separate
and is not changed here.

- Arms the consent retry for `first_run_screen` instead of dropping that
offer.
- Uses live first-run screen ownership, including pending screen-to-tour
handoffs, when deciding whether consent can be shown.
- Cancels and releases an in-flight handoff when the authenticated
identity changes, preventing the previous account tour or hold from
crossing sessions.
- Removes the obsolete `firstRunTookScreen` latch.
- Keeps failed template loads on Getting Started and removes duplicate
no-tour coverage.

- `dismissIntoFirstRunTour` snapshots the owner, passes an
identity-change cancellation predicate to `beginTour`, and invalidates
pending holds at the auth boundary.
- Per-call symbols keep concurrent handoff ownership distinct, while
`authGeneration` separately invalidates stale continuations across
authenticated-session changes.
- Bare dismissal releases consent; template selection retains ownership
until the tour has either started, declined, or failed.

At current head `e93ee8410e`, rebased directly on `main` at `4ff3690047`
(eleven-file base-to-head diff):

- `pnpm test:unit src/extensions/core/agentPanel.test.ts
src/renderer/extensions/firstRunTour/gettingStarted/GettingStartedScreen.test.ts
src/renderer/extensions/firstRunTour/gettingStarted/firstRunEntry.test.ts
src/renderer/extensions/firstRunTour/tour/useFirstRunTourController.test.ts
--testTimeout=30000` — 4 files, 226 tests passed.
- `bash scripts/test-browser-offline.sh --project=cloud
browser_tests/tests/agent/agentConsent.spec.ts -g 'defers the offer
until Getting Started releases the screen' --workers=1 --repeat-each=5`
— 5/5 passed in 43.2 seconds from a freshly restarted cloud-distribution
Vite process; the scenario-only 90-second budget covers both application
boots.
- ESLint, Oxlint, oxfmt, `git diff --check`, pre-push Knip, and
changed-line Fallow passed. Fallow excluded 17 inherited dependency
findings and reported two inherited styling advisories.

The branch retains the test-only changes from #18977 and #18989. Those
PRs were merged into this PR's branch (their GitHub base was
`fix/agent-consent-defer-first-run-screen`), not into `main`; dropping
them during reconciliation would lose their approved coverage. The
rebase preserves the eleven-file product/browser patch while removing
the stale `main` ancestry.

---------

Co-authored-by: Amp <amp@ampcode.com>
christian-byrne added a commit that referenced this pull request Sep 29, 2026
… of dropping it (#18966)

Defers the automatic Agent consent offer while Getting Started owns the
screen, then re-offers it in the same session after that ownership ends.
The template path keeps first-run ownership across the dismissal-to-tour
preview gap, so the consent card cannot open underneath the tour.

The first-session entry-button/feature-flag timing question is separate
and is not changed here.

- Arms the consent retry for `first_run_screen` instead of dropping that
offer.
- Uses live first-run screen ownership, including pending screen-to-tour
handoffs, when deciding whether consent can be shown.
- Cancels and releases an in-flight handoff when the authenticated
identity changes, preventing the previous account tour or hold from
crossing sessions.
- Removes the obsolete `firstRunTookScreen` latch.
- Keeps failed template loads on Getting Started and removes duplicate
no-tour coverage.

- `dismissIntoFirstRunTour` snapshots the owner, passes an
identity-change cancellation predicate to `beginTour`, and invalidates
pending holds at the auth boundary.
- Per-call symbols keep concurrent handoff ownership distinct, while
`authGeneration` separately invalidates stale continuations across
authenticated-session changes.
- Bare dismissal releases consent; template selection retains ownership
until the tour has either started, declined, or failed.

At current head `e93ee8410e`, rebased directly on `main` at `4ff3690047`
(eleven-file base-to-head diff):

- `pnpm test:unit src/extensions/core/agentPanel.test.ts
src/renderer/extensions/firstRunTour/gettingStarted/GettingStartedScreen.test.ts
src/renderer/extensions/firstRunTour/gettingStarted/firstRunEntry.test.ts
src/renderer/extensions/firstRunTour/tour/useFirstRunTourController.test.ts
--testTimeout=30000` — 4 files, 226 tests passed.
- `bash scripts/test-browser-offline.sh --project=cloud
browser_tests/tests/agent/agentConsent.spec.ts -g 'defers the offer
until Getting Started releases the screen' --workers=1 --repeat-each=5`
— 5/5 passed in 43.2 seconds from a freshly restarted cloud-distribution
Vite process; the scenario-only 90-second budget covers both application
boots.
- ESLint, Oxlint, oxfmt, `git diff --check`, pre-push Knip, and
changed-line Fallow passed. Fallow excluded 17 inherited dependency
findings and reported two inherited styling advisories.

The branch retains the test-only changes from #18977 and #18989. Those
PRs were merged into this PR's branch (their GitHub base was
`fix/agent-consent-defer-first-run-screen`), not into `main`; dropping
them during reconciliation would lose their approved coverage. The
rebase preserves the eleven-file product/browser patch while removing
the stale `main` ancestry.

---------

Co-authored-by: Amp <amp@ampcode.com>
christian-byrne added a commit that referenced this pull request Sep 29, 2026
… of dropping it (#18966)

Defers the automatic Agent consent offer while Getting Started owns the
screen, then re-offers it in the same session after that ownership ends.
The template path keeps first-run ownership across the dismissal-to-tour
preview gap, so the consent card cannot open underneath the tour.

The first-session entry-button/feature-flag timing question is separate
and is not changed here.

- Arms the consent retry for `first_run_screen` instead of dropping that
offer.
- Uses live first-run screen ownership, including pending screen-to-tour
handoffs, when deciding whether consent can be shown.
- Cancels and releases an in-flight handoff when the authenticated
identity changes, preventing the previous account tour or hold from
crossing sessions.
- Removes the obsolete `firstRunTookScreen` latch.
- Keeps failed template loads on Getting Started and removes duplicate
no-tour coverage.

- `dismissIntoFirstRunTour` snapshots the owner, passes an
identity-change cancellation predicate to `beginTour`, and invalidates
pending holds at the auth boundary.
- Per-call symbols keep concurrent handoff ownership distinct, while
`authGeneration` separately invalidates stale continuations across
authenticated-session changes.
- Bare dismissal releases consent; template selection retains ownership
until the tour has either started, declined, or failed.

At current head `e93ee8410e`, rebased directly on `main` at `4ff3690047`
(eleven-file base-to-head diff):

- `pnpm test:unit src/extensions/core/agentPanel.test.ts
src/renderer/extensions/firstRunTour/gettingStarted/GettingStartedScreen.test.ts
src/renderer/extensions/firstRunTour/gettingStarted/firstRunEntry.test.ts
src/renderer/extensions/firstRunTour/tour/useFirstRunTourController.test.ts
--testTimeout=30000` — 4 files, 226 tests passed.
- `bash scripts/test-browser-offline.sh --project=cloud
browser_tests/tests/agent/agentConsent.spec.ts -g 'defers the offer
until Getting Started releases the screen' --workers=1 --repeat-each=5`
— 5/5 passed in 43.2 seconds from a freshly restarted cloud-distribution
Vite process; the scenario-only 90-second budget covers both application
boots.
- ESLint, Oxlint, oxfmt, `git diff --check`, pre-push Knip, and
changed-line Fallow passed. Fallow excluded 17 inherited dependency
findings and reported two inherited styling advisories.

The branch retains the test-only changes from #18977 and #18989. Those
PRs were merged into this PR's branch (their GitHub base was
`fix/agent-consent-defer-first-run-screen`), not into `main`; dropping
them during reconciliation would lose their approved coverage. The
rebase preserves the eleven-file product/browser patch while removing
the stale `main` ancestry.

---------

Co-authored-by: Amp <amp@ampcode.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent Comfy Agent product, integration, tests or product documentation agent-test-only Agent tests, fixtures and test support only; no production changes agent-test-unit Touches Agent-related unit/component tests or their support agent-ui Agent panel, composer, transcript or other user-interface components risk:medium PR risk grade (advisory shadow check; grader-owned)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants