From 28268389e049f021ccd37873d874c00ba0c54a6a Mon Sep 17 00:00:00 2001 From: Christian Byrne Date: Sat, 26 Sep 2026 22:29:53 -0700 Subject: [PATCH] fix(agent): show onboarding after first scoped consent (#19061) - Preserve legacy device-wide onboarding migration for scopes that already accepted consent. - Do not consume that legacy flag for a new scope before its first consent; clicking Start now shows the scoped coach once. - Cover both new-consent and already-consented migration paths. Linear: PM-1301, PM-1308 Replaces the repro-only #18094 with the confirmed fix. - `pnpm exec vitest run src/workbench/extensions/agent/AgentPanelRoot.test.ts` (309 passed) - Full `pnpm typecheck:app` via pre-commit - ESLint, oxlint, stylelint, and oxfmt via pre-commit Justification: narrow state-migration fix with focused regression coverage; requested as part of the PM-1308 thread takeover. --- .../extensions/agent/AgentPanelRoot.test.ts | 25 +++++++++++++++++++ .../extensions/agent/AgentPanelRoot.vue | 5 +++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/workbench/extensions/agent/AgentPanelRoot.test.ts b/src/workbench/extensions/agent/AgentPanelRoot.test.ts index fe7c0aba59c..3088d55b0b1 100644 --- a/src/workbench/extensions/agent/AgentPanelRoot.test.ts +++ b/src/workbench/extensions/agent/AgentPanelRoot.test.ts @@ -522,6 +522,31 @@ describe('AgentPanelRoot onboarding', () => { localStorage.removeItem(SCOPED_KEY) }) + it('shows the scoped coach after first consent despite a legacy seen flag', async () => { + localStorage.setItem('Comfy.AgentPanel.onboarded', 'true') + const consentStore = useAgentConsentStore() + Object.assign(consentStore, { accepted: false }) + + render(AgentPanelRoot, { global: { plugins: [i18n] } }) + expect(localStorage.getItem(SCOPED_KEY)).toBeNull() + + Object.assign(consentStore, { accepted: true }) + + expect( + await screen.findByRole('dialog', { name: 'Meet your Comfy Agent' }) + ).toBeInTheDocument() + expect(localStorage.getItem(SCOPED_KEY)).not.toBe('true') + }) + + it('still carries the legacy seen flag for an already-consented scope', () => { + localStorage.setItem('Comfy.AgentPanel.onboarded', 'true') + + render(AgentPanelRoot, { global: { plugins: [i18n] } }) + + expect(localStorage.getItem(SCOPED_KEY)).toBe('true') + expect(localStorage.getItem('Comfy.AgentPanel.onboarded')).toBeNull() + }) + it('defers the tour in App Mode without completing it or blocking the composer', async () => { canvasStore.linearMode = true render(AgentPanelRoot, { global: { plugins: [i18n] } }) diff --git a/src/workbench/extensions/agent/AgentPanelRoot.vue b/src/workbench/extensions/agent/AgentPanelRoot.vue index 159e576c541..4af5896475a 100644 --- a/src/workbench/extensions/agent/AgentPanelRoot.vue +++ b/src/workbench/extensions/agent/AgentPanelRoot.vue @@ -279,7 +279,10 @@ const onboardingKey = computed(() => watch( onboardingKey, (key) => { - if (key) adoptSharedOnboardingFlag(key) + // Only carry the pre-consent, device-wide flag into a scope that had + // already accepted consent when it loaded. A newly consenting scope has + // not seen this scoped tour yet and should receive it once. + if (key && consentAccepted.value) adoptSharedOnboardingFlag(key) }, { immediate: true } )