AI-native design editor. Open-source Figma alternative.
feat(ai): offer the first-run welcome on the demo link (#1210)
Danila Poyarkov78355fd3890c
diff --git a/changes/1210/added.md b/changes/1210/added.mdnew file mode 100644index 000000000..efa2efc12--- /dev/null+++ b/changes/1210/added.md@@ -0,0 +1 @@+- A first visit to the `/demo` link offers the welcome and guided AI setup, as a first visit to the app does.diff --git a/src/app/ai/models/settings/onboarding/dialog.ts b/src/app/ai/models/settings/onboarding/dialog.tsindex f1e5b524f..6eb28247f 100644--- a/src/app/ai/models/settings/onboarding/dialog.ts+++ b/src/app/ai/models/settings/onboarding/dialog.ts@@ -10,9 +10,12 @@ export type AISetupEntry = 'welcome' | 'guided'export const aiSetupDialogOpen = ref(false)export const aiSetupEntry = ref<AISetupEntry>('guided')+/** The welcome points to the tour, except when it is offered over the tour itself. */+export const aiSetupOffersTour = ref(true)-export function openAISetup(entry: AISetupEntry = 'guided'): void {+export function openAISetup(entry: AISetupEntry = 'guided', offersTour = true): void {aiSetupEntry.value = entry+ aiSetupOffersTour.value = offersTouraiSetupDialogOpen.value = true}@@ -26,7 +29,7 @@ export function closeAISetup(): void {* Offers the welcome to a fresh install; anyone who already configured AI never sees it.* Returns whether the welcome opened.*/-export function offerAISetupOnFirstRun(): boolean {+export function offerAISetupOnFirstRun({ inTour }: { inTour: boolean }): boolean {// The native test binary starts every run with an empty data store.if (import.meta.env.MODE === 'native-test') return falseif (appPreferences.value.onboarding.aiSetup === 'done') return false@@ -34,6 +37,6 @@ export function offerAISetupOnFirstRun(): boolean {updateAISetupState('done')return false}- openAISetup('welcome')+ openAISetup('welcome', !inTour)return true}diff --git a/src/components/settings/ai-setup/AISetupDialog.vue b/src/components/settings/ai-setup/AISetupDialog.vueindex 8226a6f16..a44eea676 100644--- a/src/components/settings/ai-setup/AISetupDialog.vue+++ b/src/components/settings/ai-setup/AISetupDialog.vue@@ -2,6 +2,7 @@import {aiSetupDialogOpen,aiSetupEntry,+ aiSetupOffersTour,closeAISetup} from '@/app/ai/models/settings/onboarding/dialog'import { openTour } from '@/app/demo/document'@@ -37,6 +38,7 @@ function takeTour(): void {><AISetupFlow:entry="aiSetupEntry"+ :offers-tour="aiSetupOffersTour"@close="closeAISetup"@advanced="openAdvancedSettings"@tour="takeTour"diff --git a/src/components/settings/ai-setup/AISetupFlow.stories.ts b/src/components/settings/ai-setup/AISetupFlow.stories.tsindex bc5e5b11b..31cd92e0a 100644--- a/src/components/settings/ai-setup/AISetupFlow.stories.ts+++ b/src/components/settings/ai-setup/AISetupFlow.stories.ts@@ -13,6 +13,7 @@ import AISetupFlow from './AISetupFlow.vue'interface Args {entry: 'welcome' | 'guided'+ offersTour?: booleanagentsAvailable: boolean}@@ -79,6 +80,9 @@ async function next() {}export const Welcome: Story = { args: { entry: 'welcome' } }++/** Offered over the demo, which is the tour, so it does not point to it. */+export const WelcomeInTour: Story = { args: { entry: 'welcome', offersTour: false } }export const Goals: Story = {}export const AccessInBrowser: Story = {play: async () => {diff --git a/src/components/settings/ai-setup/AISetupFlow.vue b/src/components/settings/ai-setup/AISetupFlow.vueindex aab0efbe0..7a5d86149 100644--- a/src/components/settings/ai-setup/AISetupFlow.vue+++ b/src/components/settings/ai-setup/AISetupFlow.vue@@ -20,8 +20,13 @@ import AISetupConnection from './AISetupConnection.vue'import AISetupReview from './AISetupReview.vue'import AISetupRoles from './AISetupRoles.vue'-const { entry, agentsAvailable = IS_TAURI } = defineProps<{+const {+ entry,+ offersTour = true,+ agentsAvailable = IS_TAURI+} = defineProps<{entry: AISetupEntry+ offersTour?: booleanagentsAvailable?: boolean}>()const emit = defineEmits<{ close: []; advanced: []; tour: [] }>()@@ -107,7 +112,7 @@ async function finish(): Promise<void> {<h3 :class="styles.introHeading()">{{ ai.aiSetupWelcomeAITitle }}</h3><p :class="styles.introText()">{{ ai.aiSetupWelcomeAIDescription }}</p></section>- <section :class="styles.tour()" data-test-id="ai-setup-tour">+ <section v-if="offersTour" :class="styles.tour()" data-test-id="ai-setup-tour"><div><h3 :class="styles.introHeading()">{{ ai.aiSetupWelcomeTourTitle }}</h3><p :class="styles.introText()">{{ ai.aiSetupWelcomeTourDescription }}</p>diff --git a/src/views/WorkspaceView.vue b/src/views/WorkspaceView.vueindex 76db35300..e4008f560 100644--- a/src/views/WorkspaceView.vue+++ b/src/views/WorkspaceView.vue@@ -88,9 +88,10 @@ function openFirstTab(): Tab {}}+// A first visit to the demo link is a first run too; the welcome there skips the tour offer.const welcomeShown =- createdInitialTab && route.path === '/' && !appRuntimeConfig.test && !route.meta.demo- ? offerAISetupOnFirstRun()+ createdInitialTab && (route.path === '/' || route.meta.demo) && !appRuntimeConfig.test+ ? offerAISetupOnFirstRun({ inTour: route.meta.demo === true }): falseconst sharingStarted = startSharing()// One question per surface: a first run is asked about usage stats once the welcome closes.diff --git a/tests/e2e/settings/ai-setup-first-run.spec.ts b/tests/e2e/settings/ai-setup-first-run.spec.tsindex edd811fbc..5787921e6 100644--- a/tests/e2e/settings/ai-setup-first-run.spec.ts+++ b/tests/e2e/settings/ai-setup-first-run.spec.ts@@ -1,6 +1,7 @@import { expect, test } from '@playwright/test'import { CanvasHelper } from '#tests/helpers/canvas'+import { waitForDemo } from '#tests/helpers/demo'// `?test` suppresses the first-run offer, so these load the app as a person would, with none// of the stored preferences the other browser tests start from.@@ -20,6 +21,16 @@ test('a fresh install offers guided AI setup once and remembers skipping it', asawait expect(setup).toHaveCount(0)})+test('a first visit to the demo offers the welcome without pointing to the tour', async ({+ page+}) => {+ await page.goto('/demo')+ await waitForDemo(page)+ const setup = page.getByTestId('ai-setup-dialog')+ await expect(setup.getByRole('heading', { name: 'Welcome to OpenPencil' })).toBeVisible()+ await expect(setup.getByTestId('ai-setup-tour')).toHaveCount(0)+})+const CONFIGURED_MODEL_SETTINGS = {version: 1,connections: [