Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

Add composable in-app feature tours (#6951)

Jacob Beckerman1bd061ac1cf1
diff --git a/.claude/skills/add-tour/SKILL.md b/.claude/skills/add-tour/SKILL.md
new file mode 100644
index 0000000000..ebf8f292a4
--- /dev/null
+++ b/.claude/skills/add-tour/SKILL.md
@@ -0,0 +1,160 @@
+---
+name: add-tour
+description: Add or change an in-app feature tour (a view's guided flyover) in the web app. Use when adding a tour to a view, adding or editing tour steps, pointing a step at a new control, or when a step's target needs something opened first.
+---
+
+# Add or change an in-app tour
+
+Frontend only. Two layers:
+
+| Layer | Where | What |
+|---|---|---|
+| Primitive | `apps/web/src/components/ui/components/Tour/` | `Tour.*` parts, `defineTourTargets`, `tourTarget`. Generic; no app knowledge. |
+| App | `apps/web/src/features/tours/` | `ViewTour` (desktop gate, per-user dismissal, connector/video CTAs), `defineViewTour`. |
+| Per view | `apps/web/src/features/<view>/tour.ts` | The view's targets and its tour definition. |
+
+Read an existing `tour.ts` first. `channels-view/tour.ts` and
+`agents-view/tour.ts` show entries; `calendar-view/tour.ts` shows the sidebar
+toggle entry.
+
+## 1. Declare targets
+
+In the view's `tour.ts`:
+
+```ts
+export const REPORTS_TOUR = defineTourTargets('reports', ['filters', 'chart']);
+```
+
+- Ids are `namespace.name`. Use the view's name as the namespace.
+- Targets are view-scoped: they resolve only inside the tour's split. Pass
+ `{ scope: 'app' }` only for shared chrome outside any split (see
+ `command/sidebar/tour.ts`).
+- Reuse shared targets before adding new ones:
+ - `VIEW_SHELL_TOUR` (`@app/components/view-shell/tour`): `aside`, `main`, `topBar`, `sidebarToggle`. Every `ViewShell` registers these.
+ - `SOUP_TOUR` (`features/next-soup/tour.ts`): `list`.
+ - `CHANNEL_TOUR` (`features/channel/tour.ts`): `messages`, `composer`, `call`.
+ - `APP_TOUR` (`features/command/sidebar/tour.ts`): `createMenu`.
+
+Never target with selectors, `data-*` attributes, or `aria-label` lookups. If
+the control you want isn't registered, register it (step 2).
+
+## 2. Attach targets
+
+```tsx
+<div ref={tourTarget(REPORTS_TOUR.filters)}>…</div>
+```
+
+- The element must have a box. `display: contents` wrappers never resolve;
+ attach to a real element.
+- **Never write a conditional `ref`** like
+ `ref={cond ? tourTarget(X) : undefined}`. The Solid compiler silently drops
+ it, and the target never registers. Create the ref in the component body
+ and decide inside a callback:
+ `const target = tourTarget(X);` then `ref={(el) => { if (cond) target(el); }}`.
+- If the element already has a ref, call both:
+ `ref={(el) => { existing(el); target(el); }}` with
+ `const target = tourTarget(...)` created in the component body, or use
+ `mergeRefs` from `@solid-primitives/refs`.
+- For a component that doesn't forward `ref`, add a `ref` prop that it passes
+ to its root (see `SidebarCreateButton`).
+- A lower-level feature may import targets from the view that owns the tour
+ (for example, `features/calendar` imports `CALENDAR_TOUR`).
+
+## 3. Define the tour
+
+```ts
+export const reportsTour = defineViewTour({
+ id: 'reports', // dismissal key: never reuse or rename casually
+ title: 'Reports',
+ connector: { kind: 'mcp', label: 'Linear', tools: ['Linear'] }, // optional
+ video: { youtubeId: '…', title: '…', duration: '1:23' }, // optional
+ steps: [
+ { target: REPORTS_TOUR.filters, title: '…', description: '…' },
+ { target: [REPORTS_TOUR.chart, VIEW_SHELL_TOUR.main], title: '…', description: '…' },
+ ],
+});
+```
+
+- `target` may be a list; the first shown one wins. Use this for features
+ that aren't always rendered (behind a flag, a connection, or data such as
+ "more than one calendar"): list the real control first and the nearest
+ always-present surface after it, and set `missingHint`. The hint shows
+ whenever the step falls back.
+- Before relying on a target, check every branch that renders it: touch
+ vs desktop headers, preview vs workspace, empty states. Register the same
+ target in each branch that shows the control.
+- A step without `target` floats in the split.
+- `missingHint` explains how to reach or enable the feature when the step
+ floats or falls back.
+- `placement` (a floating-ui `Placement`) overrides the default `right-start`.
+
+## 4. Never navigate for the user: use an entry
+
+If a step's target is behind something (a collapsed sidebar, another page, an
+unopened item), don't open it from the tour. Give the step an `entry`:
+
+```ts
+{
+ target: REPORTS_TOUR.chart,
+ entry: VIEW_SHELL_TOUR.sidebarToggle,
+ entryLabel: 'Open the sidebar to continue the tour',
+ title: '…',
+ description: '…',
+}
+```
+
+While the target is missing and the entry is shown, the card hides, a beacon
+marks the entry, and a small card beside it shows `entryLabel` with Skip. The beacon stays until the target appears, however the user gets there. Register the entry control as a target like any other.
+
+- Keep `entryLabel` short and imperative: "Open a channel or DM to continue".
+- **Chain entries** when the entry itself can be hidden. The first shown one
+ wins, so list the real control first and the sidebar toggle last:
+ `entry: [CHANNELS_TOUR.conversation, VIEW_SHELL_TOUR.sidebarToggle]`. With
+ the sidebar collapsed the beacon marks the toggle; once it opens, the beacon
+ moves to the row.
+- `ViewTour` appends `VIEW_SHELL_TOUR.sidebarToggle` to every step that has
+ a target, so a step whose target is in a collapsed sidebar always marks the
+ toggle. You still need it explicitly only as the last link of a chain you
+ write yourself.
+- A view that collapses its sidebar itself instead of through `ViewShell`
+ (like Customers' `NavigationToggle`) must register its own expand control
+ as `VIEW_SHELL_TOUR.sidebarToggle`, or those steps will float.
+- Point entries at a specific control, not a large container. When many
+ elements share a target (every conversation row), the top-most one on
+ screen is used.
+
+## 5. Mount it
+
+Mount once, inside the view's split (usually in `ViewShell.Main` or next to the
+list):
+
+```tsx
+<ViewTour tour={reportsTour} />
+<ViewTour tour={tasksTour} actions={<ImportLinearAction />} /> // extra CTAs
+```
+
+- For `SoupView`-based routes, pass it through the slot:
+ `<SoupView … tour={<ViewTour tour={callsTour} />} />`.
+- Don't put it inside a `<Show>` branch that remounts on navigation, or the
+ tour restarts at step 1.
+- Don't gate it on desktop or on a flag yourself; `ViewTour` already checks
+ both. All tours sit behind the `enableInAppTours` flag
+ (`enable-in-app-tours` in PostHog). To see tours on the local dev server,
+ start it with `VITE_ENABLE_IN_APP_TOURS=true`.
+- Don't pass step callbacks that change pages or open panels.
+
+## 6. Test and document
+
+- Unit behavior of the primitive lives in `Tour/Tour.test.tsx` and app behavior
+ in `features/tours/ViewTour.test.tsx`; add cases there when you change them.
+- The primitive's gallery page is `Tour/Tour.docs.tsx`.
+- Progress is saved per user in local storage under `macro:tour:<id>`
+ (`completed`, `dismissed`, or the active step). Changing a tour's steps
+ doesn't reset it for users who finished it; bump the `id` only if everyone
+ must see the new version.
+- Check it in a browser with `VITE_ENABLE_IN_APP_TOURS=true`: on localhost
+ the tour reopens on every mount. Walk
+ every step, including one that waits on an entry, once with the sidebar
+ open and once collapsed.
+- Update `docs/AGENT_GUIDE/view-tours.md` when a view gains a tour or its steps
+ change.
diff --git a/apps/web/AGENTS.md b/apps/web/AGENTS.md
index 8a67155dbc..68dbd1b35b 100644
--- a/apps/web/AGENTS.md
+++ b/apps/web/AGENTS.md
@@ -66,6 +66,7 @@ Then trigger the interaction and read `window.__inst.log`. `'1,2,3' → '' → '
- Shared server-state queries and mutations live in `src/lib/queries`; keep
feature-specific query orchestration with its owning feature.
- When adding or changing a feature flag, follow the `define-feature-flag` skill.
+- When adding or changing a view's feature tour, follow the `add-tour` skill.
### SolidJs
- Avoid createEffect. Legitimate uses: syncing with external/imperative systems (DOM APIs, third-party libs). If you're using it to derive state or trigger updates, use a derived signal or wrap the setter instead.
diff --git a/apps/web/src/components/ui/components/Tour/Tour.docs.tsx b/apps/web/src/components/ui/components/Tour/Tour.docs.tsx
new file mode 100644
index 0000000000..abfcd4b35f
--- /dev/null
+++ b/apps/web/src/components/ui/components/Tour/Tour.docs.tsx
@@ -0,0 +1,192 @@
+import { defineDoc } from '@app/features/ui-gallery/types';
+import { createSignal, Show } from 'solid-js';
+import { Button } from '../Button';
+import { defineTourTargets, Tour, type TourStep, tourTarget } from '.';
+
+const DEMO = defineTourTargets('tour-demo', [
+ 'search',
+ 'create',
+ 'toggle',
+ 'hidden',
+]);
+
+function CardPopover() {
+ return (
+ <Tour.Popover class="w-72 rounded-2xl border border-edge bg-dialog p-4 text-ink shadow-lg">
+ <Card />
+ </Tour.Popover>
+ );
+}
+
+function Card() {
+ return (
+ <>
+ <div class="mb-3 flex items-center gap-1 text-ink-muted">
+ <Tour.Progress class="mr-auto text-xs" />
+ <Tour.Previous />
+ <Tour.Next />
+ <Tour.Close />
+ </div>
+ <Tour.Title class="text-base font-medium" />
+ <Tour.Description class="mt-1 text-sm text-ink-muted" />
+ </>
+ );
+}
+
+// #region demo:popover
+const POPOVER_STEPS: TourStep[] = [
+ {
+ target: DEMO.search,
+ title: 'Search anything',
+ description: 'Steps point at a target registered with `tourTarget`.',
+ },
+ {
+ target: DEMO.create,
+ placement: 'bottom-start',
+ title: 'Create something',
+ description: 'Each step can prefer its own placement.',
+ },
+ {
+ title: 'No target',
+ description: 'A step without a target floats in the boundary.',
+ },
+];
+
+function PopoverDemo() {
+ const [open, setOpen] = createSignal(false);
+ return (
+ <div class="flex items-center gap-2">
+ <Button variant="outline" onClick={() => setOpen(true)}>
+ Start tour
+ </Button>
+ <Button variant="ghost" ref={tourTarget(DEMO.search)}>
+ Search
+ </Button>
+ <Button variant="ghost" ref={tourTarget(DEMO.create)}>
+ Create
+ </Button>
+ <Show when={open()}>
+ <Tour.Root steps={POPOVER_STEPS} onDismiss={() => setOpen(false)}>
+ <Tour.Highlight />
+ <CardPopover />
+ </Tour.Root>
+ </Show>
+ </div>
+ );
+}
+// #endregion
+
+// #region demo:entry
+const ENTRY_STEPS: TourStep[] = [
+ {
+ target: DEMO.toggle,
+ title: 'Hidden settings',
+ description: 'The next step points at something that is not shown yet.',
+ },
+ {
+ target: DEMO.hidden,
+ entry: DEMO.toggle,
+ entryLabel: 'Show settings to continue the tour',
+ title: 'Found it',
+ description:
+ 'While the target is missing the card hides and a beacon marks the entry until the target appears.',
+ },
+];
+
+function EntryDemo() {
+ const [open, setOpen] = createSignal(false);
+ const [shown, setShown] = createSignal(false);
+ return (
+ <div class="flex items-center gap-2">
+ <Button variant="outline" onClick={() => setOpen(true)}>
+ Start tour
+ </Button>
+ <Button
+ variant="ghost"
+ ref={tourTarget(DEMO.toggle)}
+ onClick={() => setShown((value) => !value)}
+ >
+ {shown() ? 'Hide settings' : 'Show settings'}
+ </Button>
+ <Show when={shown()}>
+ <span ref={tourTarget(DEMO.hidden)} class="text-sm text-ink-muted">
+ Settings
+ </span>
+ </Show>
+ <Show when={open()}>
+ <Tour.Root steps={ENTRY_STEPS} onDismiss={() => setOpen(false)}>
+ <Tour.Highlight />
+ <Tour.Beacon />
+ <Tour.Hint class="w-56 rounded-xl border border-edge bg-dialog p-3 text-sm text-ink shadow-lg">
+ <p>Show settings to continue.</p>
+ <div class="mt-2">
+ <Tour.Next variant="outline" size="sm">
+ Skip
+ </Tour.Next>
+ </div>
+ </Tour.Hint>
+ <CardPopover />
+ </Tour.Root>
+ </Show>
+ </div>
+ );
+}
+// #endregion
+
+// #region demo:panel
+function PanelDemo() {
+ return (
+ <Tour.Root steps={POPOVER_STEPS}>
+ <Tour.Panel class="w-80 rounded-xl border border-edge-muted p-4">
+ <Card />
+ </Tour.Panel>
+ </Tour.Root>
+ );
+}
+// #endregion
+
+export default defineDoc({
+ name: 'Tour',
+ category: 'Overlays',
+ description:
+ 'Composable product tours. Features declare named targets with `defineTourTargets` and attach them with `tourTarget`; a tour lists steps that point at them.',
+ status: 'beta',
+ exports: ['Tour', 'defineTourTargets', 'tourTarget', 'useTour'],
+ import:
+ "import { defineTourTargets, Tour, tourTarget } from '@ui/components/Tour';",
+ guidelines: {
+ do: [
+ 'Declare targets with `defineTourTargets` and attach them with `ref={tourTarget(...)}`.',
+ 'Give a step an `entry` when its target must be opened first; the beacon marks the way.',
+ "Use `scope: 'app'` only for shared chrome outside any split.",
+ ],
+ dont: [
+ 'Do not target elements with selectors or data attributes.',
+ 'Do not navigate, open panels, or change pages from a tour step.',
+ 'Do not attach a target to a `display: contents` element; it has no box to point at.',
+ ],
+ },
+ demos: [
+ {
+ id: 'popover',
+ title: 'Popover',
+ description:
+ '`Tour.Popover` floats next to the target and stays in the boundary. `Tour.Highlight` outlines the target.',
+ render: PopoverDemo,
+ },
+ {
+ id: 'entry',
+ title: 'Entry beacon',
+ description:
+ 'Give a step an `entry` when its target needs to be opened first. The tour never navigates for the user; it marks the way.',
+ render: EntryDemo,
+ },
+ {
+ id: 'panel',
+ title: 'Inline panel',
+ description:
+ '`Tour.Panel` renders the same parts in normal flow, for docked or embedded tours.',
+ render: PanelDemo,
+ },
+ ],
+});
diff --git a/apps/web/src/components/ui/components/Tour/Tour.test.tsx b/apps/web/src/components/ui/components/Tour/Tour.test.tsx
new file mode 100644
index 0000000000..b999ff88d1
--- /dev/null
+++ b/apps/web/src/components/ui/components/Tour/Tour.test.tsx
@@ -0,0 +1,388 @@
+import { cleanup, fireEvent, render, screen } from '@solidjs/testing-library';
+import { createSignal, Show } from 'solid-js';
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
+
+/** Targets resolve again once refs are inserted; let that settle. */
+const settle = () => Promise.resolve();
+
+import {
+ defineTourTargets,
+ resolveTourTarget,
+ Tour,
+ type TourStep,
+ tourTarget,
+ useTour,
+} from '.';
+
+const T = defineTourTargets('test', [
+ 'first',
+ 'second',
+ 'entry',
+ 'hidden',
+ 'toggle',
+ 'row',
+]);
+const APP = defineTourTargets('test-app', ['menu'], { scope: 'app' });
+
+// jsdom has no layout; give every element a box so it counts as shown.
+beforeEach(() => {
+ vi.spyOn(HTMLElement.prototype, 'getBoundingClientRect').mockReturnValue(
+ new DOMRect(10, 10, 100, 20)
+ );
+});
+afterEach(() => {
+ cleanup();
+ vi.restoreAllMocks();
+});
+
+function Card() {
+ return (
+ <>
+ <Tour.Title />
+ <Tour.Description />
+ <Tour.Progress />
+ <Tour.Previous />
+ <Tour.Next doneLabel="Done" />
+ <Tour.Close />
+ </>
+ );
+}
+
+let tour!: ReturnType<typeof useTour>;
+function Probe() {
+ tour = useTour();
+ return null;
+}
+
+const status = () =>
+ document.querySelector('[data-tour-popover]')?.getAttribute('data-status');
+
+describe('defineTourTargets', () => {
+ it('namespaces ids and records scope', () => {
+ expect(T.first.id).toBe('test.first');
+ expect(T.first.scope).toBe('view');
+ expect(APP.menu.scope).toBe('app');
+ });
+});
+
+describe('resolveTourTarget', () => {
+ it('prefers earlier targets and keeps view targets inside the boundary', () => {
+ const [inside, setInside] = createSignal(true);
+ let boundary!: HTMLDivElement;
+ render(() => (
+ <>
+ <div ref={boundary}>
+ <Show when={inside()}>
+ <span data-testid="inside" ref={tourTarget(T.second)} />
+ </Show>
+ </div>
+ <span data-testid="outside" ref={tourTarget(T.first)} />
+ <span data-testid="menu" ref={tourTarget(APP.menu)} />
+ </>
+ ));
+ expect(resolveTourTarget([T.first, T.second], boundary)).toBe(
+ screen.getByTestId('inside')
+ );
+ expect(resolveTourTarget([T.first], undefined)).toBe(
+ screen.getByTestId('outside')
+ );
+ expect(resolveTourTarget([APP.menu], boundary)).toBe(
+ screen.getByTestId('menu')
+ );
+ setInside(false);
+ expect(resolveTourTarget([T.second], boundary)).toBeUndefined();
+ });
+
+ it('skips targets inside inert or hidden subtrees', () => {
+ render(() => (
+ <div inert>
+ <span ref={tourTarget(T.hidden)} />
+ </div>
+ ));
+ expect(resolveTourTarget([T.hidden], undefined)).toBeUndefined();
+ });
+});
+
+describe('Tour', () => {
+ const steps: TourStep[] = [
+ { target: T.first, title: 'First', description: 'One' },
+ { target: T.second, title: 'Second', description: 'Two' },
+ ];
+
+ it('steps through and completes on the last step', async () => {
+ const onComplete = vi.fn();
+ render(() => (
+ <>
+ <span ref={tourTarget(T.first)} />
+ <span ref={tourTarget(T.second)} />
+ <Tour.Root steps={steps} onComplete={onComplete}>
+ <Tour.Popover>
+ <Card />
+ </Tour.Popover>
+ </Tour.Root>
+ </>
+ ));
+ await settle();
+ const dialog = screen.getByRole('dialog', { name: 'First' });
+ expect(dialog.textContent).toContain('1 / 2');
+ expect(status()).toBe('anchored');
+ fireEvent.click(screen.getByRole('button', { name: 'Next step' }));
+ expect(screen.getByRole('dialog', { name: 'Second' })).toBeTruthy();
+ fireEvent.click(screen.getByRole('button', { name: 'Previous step' }));
+ expect(screen.getByRole('dialog', { name: 'First' })).toBeTruthy();
+ fireEvent.click(screen.getByRole('button', { name: 'Next step' }));
+ fireEvent.click(screen.getByRole('button', { name: 'Done' }));
+ expect(onComplete).toHaveBeenCalledOnce();
+ });
+
+ it('dismisses from the close button and Escape', () => {
+ const onDismiss = vi.fn();
+ render(() => (
+ <Tour.Root steps={steps} onDismiss={onDismiss}>
+ <Tour.Popover>
+ <Card />
+ </Tour.Popover>
+ </Tour.Root>
+ ));
+ fireEvent.click(screen.getByRole('button', { name: 'Dismiss tour' }));
+ fireEvent.keyDown(screen.getByRole('dialog'), { key: 'Escape' });
+ expect(onDismiss).toHaveBeenCalledTimes(2);
+ });
+
+ it('floats when the target is missing and there is no entry', () => {
+ render(() => (
+ <Tour.Root steps={steps}>
+ <Tour.Popover>
+ <Card />
+ </Tour.Popover>
+ </Tour.Root>
+ ));
+ expect(status()).toBe('floating');
+ });
+
+ it('waits on the entry instead of navigating, and resumes when the target appears', async () => {
+ const [shown, setShown] = createSignal(false);
+ const waiting: TourStep[] = [
+ {
+ target: T.hidden,
+ entry: T.entry,
+ entryLabel: 'Open settings to continue',
+ title: 'Hidden',
+ description: 'Behind the entry',
+ },
+ ];
+ render(() => (
+ <>
+ <button type="button" ref={tourTarget(T.entry)}>
+ Settings
+ </button>
+ <Show when={shown()}>
+ <span ref={tourTarget(T.hidden)} />
+ </Show>
+ <Tour.Root steps={waiting}>
+ <Tour.Beacon />
+ <Tour.Popover>
+ <Card />
+ </Tour.Popover>
+ </Tour.Root>
+ </>
+ ));
+ await settle();
+ expect(screen.queryByRole('dialog')).toBeNull();
+ expect(document.querySelector('[data-tour-beacon]')).toBeTruthy();
+ expect(screen.getByRole('status').textContent).toBe(
+ 'Open settings to continue'
+ );
+
+ // Pressing alone doesn't clear the beacon; only the target appearing does.
+ fireEvent.pointerDown(screen.getByRole('button', { name: 'Settings' }));
+ expect(document.querySelector('[data-tour-beacon]')).toBeTruthy();
+ expect(screen.queryByRole('dialog')).toBeNull();
+
+ setShown(true);
+ await settle();
+ expect(status()).toBe('anchored');
+
+ // Leaving again brings the beacon back.
+ setShown(false);
+ await settle();
+ expect(document.querySelector('[data-tour-beacon]')).toBeTruthy();
+ });
+
+ it('falls back through entries and says what to press', async () => {
+ const [expanded, setExpanded] = createSignal(false);
+ const onComplete = vi.fn();
+ render(() => (
+ <>
+ <button type="button" ref={tourTarget(T.toggle)}>
+ Show sidebar
+ </button>
+ <Show when={expanded()}>
+ <button type="button" ref={tourTarget(T.entry)}>
+ Settings
+ </button>
+ </Show>
+ <Tour.Root
+ steps={[
+ {
+ target: T.hidden,
+ entry: [T.entry, T.toggle],
+ entryLabel: 'Open settings to continue',
+ title: 'Hidden',
+ description: 'Behind two steps',
+ },
+ ]}
+ onComplete={onComplete}
+ >
+ <Tour.Beacon />
+ <Tour.Hint>
+ <span>Open settings to continue</span>
+ <Tour.Next>Skip</Tour.Next>
+ </Tour.Hint>
+ </Tour.Root>
+ </>
+ ));
+ await settle();
+ const hint = () => document.querySelector('[data-tour-hint]');
+ expect(hint()?.textContent).toContain('Open settings to continue');
+
+ // The sidebar opening swaps the beacon to the real entry.
+ setExpanded(true);
+ await settle();
+ expect(hint()).toBeTruthy();
+
+ fireEvent.click(screen.getByRole('button', { name: 'Skip' }));
+ expect(onComplete).toHaveBeenCalledOnce();
+ });
+
+ it('moves the beacon along the chain when an entry is pressed', async () => {
+ const [expanded, setExpanded] = createSignal(false);
+ render(() => (
+ <>
+ <Show when={!expanded()}>
+ <button
+ type="button"
+ ref={tourTarget(T.toggle)}
+ onClick={() => setExpanded(true)}
+ >
+ Show sidebar
+ </button>
+ </Show>
+ <Show when={expanded()}>
+ <button type="button" data-testid="row" ref={tourTarget(T.row)}>
+ Row
+ </button>
+ </Show>
+ <Tour.Root
+ steps={[
+ {
+ target: T.hidden,
+ entry: [T.row, T.toggle],
+ title: 'Inside',
+ description: 'Behind the row',
+ },
+ ]}
+ >
+ <Probe />
+ </Tour.Root>
+ </>
+ ));
+ await settle();
+ expect(tour.status()).toBe('waiting');
+ expect(tour.entry()?.textContent).toBe('Show sidebar');
+
+ const toggle = screen.getByRole('button', { name: 'Show sidebar' });
+ fireEvent.pointerDown(toggle);
+ fireEvent.click(toggle);
+ await settle();
+ expect(tour.status()).toBe('waiting');
+ expect(tour.entry()).toBe(screen.getByTestId('row'));
+ });
+
+ it('falls back to the root entry for steps with a target', async () => {
+ render(() => (
+ <>
+ <button type="button" ref={tourTarget(T.toggle)}>
+ Show sidebar
+ </button>
+ <Tour.Root
+ fallbackEntry={T.toggle}
+ steps={[
+ { target: T.hidden, title: 'Tucked away', description: '' },
+ { title: 'No target', description: '' },
+ ]}
+ >
+ <Probe />
+ </Tour.Root>
+ </>
+ ));
+ await settle();
+ expect(tour.status()).toBe('waiting');
+ tour.next();
+ expect(tour.status()).toBe('floating');
+ });
+
+ it('points at the top-most element when several share a target', () => {
+ const tops = new Map<string, number>([
+ ['low', 200],
+ ['high', 40],
+ ]);
+ vi.spyOn(HTMLElement.prototype, 'getBoundingClientRect').mockImplementation(
+ function (this: HTMLElement) {
+ return new DOMRect(
+ 0,
+ tops.get(this.dataset.testid ?? '') ?? 0,
+ 100,
+ 20
+ );
+ }
+ );
+ render(() => (
+ <>
+ <span data-testid="low" ref={tourTarget(T.row)} />
+ <span data-testid="high" ref={tourTarget(T.row)} />
+ </>
+ ));
+ expect(resolveTourTarget([T.row], undefined)).toBe(
+ screen.getByTestId('high')
+ );
+ });
+
+ it('reports when a step is anchored to a fallback target', async () => {
+ let tour!: ReturnType<typeof useTour>;
+ function Probe() {
+ tour = useTour();
+ return null;
+ }
+ render(() => (
+ <>
+ <span ref={tourTarget(T.second)} />
+ <Tour.Root
+ steps={[
+ {
+ target: [T.first, T.second],
+ title: 'Fallback',
+ description: 'Primary missing',
+ },
+ ]}
+ >
+ <Probe />
+ </Tour.Root>
+ </>
+ ));
+ await settle();
+ expect(tour.status()).toBe('anchored');
+ expect(tour.isFallback()).toBe(true);
+ });
+
+ it('renders the same parts inline with Tour.Panel', () => {
+ render(() => (
+ <Tour.Root steps={steps}>
+ <Tour.Panel>
+ <Card />
+ </Tour.Panel>
+ </Tour.Root>
+ ));
+ expect(screen.getByRole('region', { name: 'First' })).toBeTruthy();
+ });
+});
diff --git a/apps/web/src/components/ui/components/Tour/Tour.tsx b/apps/web/src/components/ui/components/Tour/Tour.tsx
new file mode 100644
index 0000000000..00edd35b63
--- /dev/null
+++ b/apps/web/src/components/ui/components/Tour/Tour.tsx
@@ -0,0 +1,662 @@
+import {
+ autoUpdate,
+ computePosition,
+ flip,
+ hide,
+ offset,
+ type Placement,
+ shift,
+ size,
+ type VirtualElement,
+} from '@floating-ui/dom';
+import CaretLeftIcon from '@phosphor/caret-left.svg';
+import CaretRightIcon from '@phosphor/caret-right.svg';
+import XIcon from '@phosphor/x.svg';
+import {
+ type Accessor,
+ createContext,
+ createEffect,
+ createMemo,
+ createSignal,
+ createUniqueId,
+ type JSX,
+ on,
+ onCleanup,
+ type ParentProps,
+ Show,
+ splitProps,
+ useContext,
+} from 'solid-js';
+import { Portal } from 'solid-js/web';
+import { cn } from '../../utils/classname';
+import { Button, type ButtonProps } from '../Button';
+import { matchTourTarget, resolveTourTarget, type TourTarget } from './targets';
+
+type Targets = TourTarget | readonly TourTarget[];
+
+/** One stop in a tour. Extend it with app-specific fields through `Tour.Root`'s generic. */
+export type TourStep = {
+ title: string;
+ description: string;
+ /** Where the step points, in preference order. Omit for a free-floating step. */
+ target?: Targets;
+ /**
+ * A control that reveals `target` when the target isn't on screen, such as
+ * a nav item or a sidebar toggle. While the target is missing, the step
+ * waits: the card hides and `Tour.Beacon` marks the entry instead, until
+ * the target appears.
+ */
+ entry?: Targets;
+ /** Accessible description of what the entry beacon leads to. */
+ entryLabel?: string;
+ /** Preferred card placement when the step is anchored. */
+ placement?: Placement;
+};
+
+/**
+ * - `anchored`: the target is on screen.
+ * - `waiting`: the target is missing but its entry is on screen.
+ * - `floating`: nothing to point at; the card floats in the boundary.
+ */
+export type TourStatus = 'anchored' | 'waiting' | 'floating';
+
+export type TourContextValue<Step extends TourStep = TourStep> = {
+ steps: Accessor<readonly Step[]>;
+ index: Accessor<number>;
+ current: Accessor<Step>;
+ isFirst: Accessor<boolean>;
+ isLast: Accessor<boolean>;
+ goTo: (index: number) => void;
+ next: () => void;
+ previous: () => void;
+ dismiss: () => void;
+ complete: () => void;
+ status: Accessor<TourStatus>;
+ /** The element the current step points at, when anchored. */
+ target: Accessor<HTMLElement | undefined>;
+ /**
+ * Whether the step is anchored to one of its later targets because the
+ * first isn't shown, e.g. a feature that isn't set up yet.
+ */
+ isFallback: Accessor<boolean>;
+ /** The entry the current step is waiting on, when waiting. */
+ entry: Accessor<HTMLElement | undefined>;
+ boundary: Accessor<HTMLElement | undefined>;
+ titleId: string;
+};
+
+const TourContext = createContext<TourContextValue>();
+
+export function useTour<Step extends TourStep = TourStep>() {
+ const context = useContext(TourContext);
+ if (!context) throw new Error('Tour parts must be used within Tour.Root');
+ return context as unknown as TourContextValue<Step>;
+}
+
+const toList = (targets: Targets | undefined): readonly TourTarget[] =>
+ targets === undefined
+ ? []
+ : Array.isArray(targets)
+ ? targets
+ : [targets as TourTarget];
+
+export type TourRootProps<Step extends TourStep> = ParentProps<{
+ steps: readonly Step[];
+ /** Controlled step index. Pair with `onStepChange`. */
+ step?: number;
+ onStepChange?: (index: number) => void;
+ /** Close button and Escape. */
+ onDismiss?: () => void;
+ /** `Tour.Next` on the last step. Defaults to `onDismiss`. */
+ onComplete?: () => void;
+ /**
+ * The region the tour belongs to, found from the root's position in the
+ * DOM. View-scoped targets resolve only inside it and floating parts stay
+ * within it. Defaults to the viewport.
+ */
+ boundary?: (root: HTMLElement) => HTMLElement | null | undefined;
+ /**
+ * Entries tried after a step's own, for every step that has a target. Use
+ * for controls that reveal most hidden targets, such as a sidebar toggle,
+ * so a step never floats unattached while its target is tucked away.
+ */
+ fallbackEntry?: Targets;
+}>;
+
+/** Owns step state and target resolution. Renders nothing visible itself. */
+function TourRoot<Step extends TourStep>(props: TourRootProps<Step>) {
+ const [ownIndex, setOwnIndex] = createSignal(0);
+ const [root, setRoot] = createSignal<HTMLElement>();
+ const titleId = createUniqueId();
+
+ const steps = () => props.steps;
+ const index = () =>
+ Math.min(Math.max(props.step ?? ownIndex(), 0), props.steps.length - 1);
+ const current = () => props.steps[index()];
+ const boundary = createMemo(() => {
+ const element = root();
+ return element ? (props.boundary?.(element) ?? undefined) : undefined;
+ });
+
+ const match = createMemo(() =>
+ matchTourTarget(toList(current().target), boundary())
+ );
+ const target = () => match()?.element;
+ const isFallback = () => {
+ const matched = match()?.target;
+ return !!matched && matched !== toList(current().target)[0];
+ };
+
+ const entries = () => {
+ const step = current();
+ if (step.target === undefined) return toList(step.entry);
+ return [...toList(step.entry), ...toList(props.fallbackEntry)];
+ };
+ const entry = createMemo(() =>
+ target() ? undefined : resolveTourTarget(entries(), boundary())
+ );
+
+ // The beacon stays on the entry until the target appears; pressing a
+ // sidebar toggle hands off to the next entry in the chain as it appears.
+ const status = (): TourStatus =>
+ target() ? 'anchored' : entry() ? 'waiting' : 'floating';
+
+ const goTo = (next: number) => {
+ const clamped = Math.min(Math.max(next, 0), props.steps.length - 1);
+ if (props.step === undefined) setOwnIndex(clamped);
+ props.onStepChange?.(clamped);
+ };
+ const dismiss = () => props.onDismiss?.();
+ const complete = () => (props.onComplete ?? props.onDismiss)?.();
+
+ const value: TourContextValue<Step> = {
+ steps,
+ index,
+ current,
+ isFirst: () => index() === 0,
+ isLast: () => index() === props.steps.length - 1,
+ goTo,
+ next: () =>
+ index() === props.steps.length - 1 ? complete() : goTo(index() + 1),
+ previous: () => goTo(index() - 1),
+ dismiss,
+ complete,
+ status,
+ target,
+ isFallback,
+ entry,
+ boundary,
+ titleId,
+ };
+
+ return (
+ <TourContext.Provider value={value as unknown as TourContextValue}>
+ <span ref={setRoot} hidden data-tour-root />
+ <Show when={props.steps.length > 0}>{props.children}</Show>
+ </TourContext.Provider>
+ );
+}
+
+const EDGE = 16;
+
+/** Keeps `element` positioned against `reference` until cleanup. */
+function follow(
+ reference: Element | VirtualElement,
+ element: HTMLElement,
+ update: () => void
+) {
+ const stop = autoUpdate(reference, element, update);
+ onCleanup(stop);
+}
+
+/** A virtual point near the boundary's top-right, where unanchored cards rest. */
+function restingPoint(boundary: HTMLElement | undefined): VirtualElement {
+ return {
+ contextElement: boundary,
+ getBoundingClientRect() {
+ const rect = boundary?.getBoundingClientRect() ?? {
+ top: 0,
+ right: window.innerWidth,
+ };
+ const x = rect.right - EDGE;
+ const y = rect.top + 72;
+ return {
+ x,
+ y,
+ left: x,
+ top: y,
+ right: x,
+ bottom: y,
+ width: 0,
+ height: 0,
+ };
+ },
+ };
+}
+
+export type TourPopoverProps = ParentProps<{
+ class?: string;
+ /** Overrides the step's placement. */
+ placement?: Placement;
+ /** Gap between the target and the card. */
+ gutter?: number;
+}>;
+
+/**
+ * The step content as a floating, non-modal card next to the target, kept
+ * inside the boundary. Hidden while the step waits on or reveals its entry.
+ *
+ * `data-placed` appears once the card is positioned (animate its entrance
+ * from there) and `data-settled` a frame later (animate moves between steps
+ * only then).
+ */
+function TourPopover(props: TourPopoverProps) {
+ const tour = useTour();
+ // Each appearance mounts a fresh card, so it rises where it belongs
+ // instead of resuming from wherever it last was.
+ return (
+ <Show when={tour.status() === 'anchored' || tour.status() === 'floating'}>
+ <PopoverCard {...props} />
+ </Show>
+ );
+}
+
+function PopoverCard(props: TourPopoverProps) {
+ const tour = useTour();
+ const [card, setCard] = createSignal<HTMLElement>();
+ const [position, setPosition] = createSignal({
+ x: 0,
+ y: 0,
+ maxWidth: 0,
+ maxHeight: 0,
+ placed: false,
+ hidden: false,
+ });
+ // Position changes animate only once the card has appeared in place, so
+ // it rises where it belongs instead of gliding in from the corner.
+ const [settled, setSettled] = createSignal(false);
+ createEffect(
+ on(
+ () => position().placed,
+ (placed) => {
+ if (!placed) return;
+ const frame = requestAnimationFrame(() => setSettled(true));
+ onCleanup(() => cancelAnimationFrame(frame));
+ }
+ )
+ );
+
+ createEffect(() => {
+ const element = card();
+ const status = tour.status();
+ if (!element || (status !== 'anchored' && status !== 'floating')) return;
+ const target = tour.target();
+ const boundary = tour.boundary();
+ // App-scoped targets live outside the split, so bound by the viewport.
+ const inBoundary = !target || !boundary || boundary.contains(target);
+ const clip = inBoundary && boundary ? boundary : 'clippingAncestors';
+ const placement = target
+ ? (props.placement ?? tour.current().placement ?? 'right-start')
+ : 'bottom-end';
+ const reference = target ?? restingPoint(boundary);
+ follow(reference, element, () => {
+ void computePosition(reference, element, {
+ strategy: 'fixed',
+ placement,
+ middleware: [
+ offset(target ? (props.gutter ?? EDGE) : 0),
+ flip({
+ boundary: clip,
+ padding: EDGE,
+ fallbackPlacements: ['left-start', 'bottom-start', 'top-start'],
+ }),
+ shift({ boundary: clip, padding: EDGE, crossAxis: true }),
+ size({
+ boundary: clip,
+ padding: EDGE,
+ apply: ({ availableWidth, availableHeight }) => {
+ setPosition((p) => ({
+ ...p,
+ maxWidth: availableWidth,
+ maxHeight: availableHeight,
+ }));
+ },
+ }),
+ // Only an anchored card follows its target out of view.
+ ...(target ? [hide({ boundary: clip })] : []),
+ ],
+ }).then(({ x, y, middlewareData }) =>
+ setPosition((p) => ({
+ ...p,
+ x,
+ y,
+ placed: true,
+ hidden: !!middlewareData.hide?.referenceHidden,
+ }))
+ );
+ });
+ });
+
+ return (
+ <Portal>
+ <section
+ ref={setCard}
+ role="dialog"
+ aria-modal="false"
+ aria-labelledby={tour.titleId}
+ data-tour-popover
+ data-status={tour.status()}
+ data-placed={position().placed ? '' : undefined}
+ data-settled={settled() ? '' : undefined}
+ class={cn('fixed left-0 top-0 z-[70]', props.class)}
+ style={{
+ transform: `translate3d(${position().x}px, ${position().y}px, 0)`,
+ // Transparent until first placed, so it never flashes at 0,0.
+ opacity: position().placed ? undefined : 0,
+ visibility: position().hidden ? 'hidden' : 'visible',
+ 'max-width': position().maxWidth
+ ? `${position().maxWidth}px`
+ : undefined,
+ 'max-height': position().maxHeight
+ ? `${position().maxHeight}px`
+ : undefined,
+ }}
+ onKeyDown={(event) => {
+ if (event.key !== 'Escape') return;
+ event.stopPropagation();
+ tour.dismiss();
+ }}
+ >
+ {props.children}
+ </section>
+ </Portal>
+ );
+}
+
+/** The step content inline, in normal flow. Use for docked or embedded tours. */
+function TourPanel(props: ParentProps<{ class?: string }>) {
+ const tour = useTour();
+ return (
+ <section
+ aria-labelledby={tour.titleId}
+ data-tour-panel
+ data-status={tour.status()}
+ class={props.class}
+ >
+ {props.children}
+ </section>
+ );
+}
+
+/** Tracks `element`'s rect, clipped to `bounds`, while mounted. */
+function createTrackedRect(
+ element: Accessor<HTMLElement | undefined>,
+ overlay: Accessor<HTMLElement | undefined>,
+ bounds: Accessor<HTMLElement | undefined>
+) {
+ const [rect, setRect] = createSignal<DOMRect>();
+ createEffect(() => {
+ const source = element();
+ const layer = overlay();
+ if (!source || !layer) {
+ setRect(undefined);
+ return;
+ }
+ follow(source, layer, () => {
+ const box = source.getBoundingClientRect();
+ const limit = bounds()?.contains(source)
+ ? bounds()!.getBoundingClientRect()
+ : new DOMRect(0, 0, window.innerWidth, window.innerHeight);
+ const left = Math.max(box.left, limit.left);
+ const top = Math.max(box.top, limit.top);
+ const right = Math.min(box.right, limit.right);
+ const bottom = Math.min(box.bottom, limit.bottom);
+ setRect(
+ right > left && bottom > top
+ ? new DOMRect(left, top, right - left, bottom - top)
+ : undefined
+ );
+ });
+ });
+ return rect;
+}
+
+/** An outline around the current target. Renders nothing unless anchored. */
+function TourHighlight(props: { class?: string; inset?: number }) {
+ const tour = useTour();
+ const [ring, setRing] = createSignal<HTMLElement>();
+ const rect = createTrackedRect(tour.target, ring, tour.boundary);
+ const inset = () => props.inset ?? 4;
+ return (
+ <Show when={tour.status() === 'anchored'}>
+ <Portal>
+ <div
+ ref={setRing}
+ aria-hidden="true"
+ data-tour-highlight
+ class={cn(
+ 'pointer-events-none fixed z-[69] rounded-[10px] border border-accent',
+ props.class
+ )}
+ style={{
+ visibility: rect() ? 'visible' : 'hidden',
+ left: `${(rect()?.left ?? 0) - inset()}px`,
+ top: `${(rect()?.top ?? 0) - inset()}px`,
+ width: `${(rect()?.width ?? 0) + inset() * 2}px`,
+ height: `${(rect()?.height ?? 0) + inset() * 2}px`,
+ }}
+ />
+ </Portal>
+ </Show>
+ );
+}
+
+/**
+ * A pulsing ring and dot on the entry the current step is waiting on. It
+ * doesn't intercept input; it stays until the target appears.
+ */
+function TourBeacon(props: { class?: string; inset?: number }) {
+ const tour = useTour();
+ const [frame, setFrame] = createSignal<HTMLElement>();
+ const rect = createTrackedRect(tour.entry, frame, tour.boundary);
+ const inset = () => props.inset ?? 3;
+ return (
+ <Show when={tour.status() === 'waiting'}>
+ <Portal>
+ {/* A pulsing ring around the whole entry, with a dot on its corner,
+ so even a small icon button reads as "press this". */}
+ <span
+ ref={setFrame}
+ aria-hidden="true"
+ data-tour-beacon
+ class={cn(
+ 'pointer-events-none fixed z-[70] rounded-[10px] border-2 border-accent',
+ props.class
+ )}
+ style={{
+ visibility: rect() ? 'visible' : 'hidden',
+ left: `${(rect()?.left ?? 0) - inset()}px`,
+ top: `${(rect()?.top ?? 0) - inset()}px`,
+ width: `${(rect()?.width ?? 0) + inset() * 2}px`,
+ height: `${(rect()?.height ?? 0) + inset() * 2}px`,
+ }}
+ >
+ <span class="absolute inset-[-2px] animate-ping rounded-[10px] border-2 border-accent opacity-50" />
+ <span class="absolute -top-1.5 -right-1.5 size-3">
+ <span class="absolute inset-0 animate-ping rounded-full bg-accent opacity-60" />
+ <span class="absolute inset-0 rounded-full border-2 border-dialog bg-accent" />
+ </span>
+ </span>
+ <span role="status" class="sr-only">
+ {tour.current().entryLabel ??
+ `Tour continues: ${tour.current().title}`}
+ </span>
+ </Portal>
+ </Show>
+ );
+}
+
+export type TourHintProps = ParentProps<{
+ class?: string;
+ placement?: Placement;
+}>;
+
+/**
+ * A small floating note beside the entry while the step waits, saying what
+ * to press. Unlike the card it doesn't cover the entry, so it can carry
+ * controls such as skip or dismiss.
+ */
+function TourHint(props: TourHintProps) {
+ const tour = useTour();
+ const [hint, setHint] = createSignal<HTMLElement>();
+ const [position, setPosition] = createSignal<{ x: number; y: number }>();
+ createEffect(() => {
+ const element = hint();
+ const entry = tour.entry();
+ if (!element || !entry) return;
+ follow(entry, element, () => {
+ void computePosition(entry, element, {
+ strategy: 'fixed',
+ placement: props.placement ?? 'right',
+ middleware: [
+ offset(12),
+ flip({ padding: EDGE, fallbackPlacements: ['bottom', 'top'] }),
+ shift({ padding: EDGE }),
+ ],
+ }).then(({ x, y }) => setPosition({ x, y }));
+ });
+ });
+ return (
+ <Show when={tour.status() === 'waiting'}>
+ <Portal>
+ <div
+ ref={setHint}
+ data-tour-hint
+ data-placed={position() ? '' : undefined}
+ class={cn('fixed left-0 top-0 z-[70]', props.class)}
+ style={{
+ transform: `translate3d(${position()?.x ?? 0}px, ${position()?.y ?? 0}px, 0)`,
+ opacity: position() ? undefined : 0,
+ }}
+ >
+ {props.children}
+ </div>
+ </Portal>
+ </Show>
+ );
+}
+
+function TourTitle(props: { class?: string; children?: JSX.Element }) {
+ const tour = useTour();
+ return (
+ <h2 id={tour.titleId} class={props.class}>
+ {props.children ?? tour.current().title}
+ </h2>
+ );
+}
+
+function TourDescription(props: { class?: string; children?: JSX.Element }) {
+ const tour = useTour();
+ return (
+ <p class={props.class}>{props.children ?? tour.current().description}</p>
+ );
+}
+
+/** "2 / 5", announced when the step changes. */
+function TourProgress(props: { class?: string }) {
+ const tour = useTour();
+ return (
+ <span aria-live="polite" class={cn('tabular-nums', props.class)}>
+ {tour.index() + 1} / {tour.steps().length}
+ </span>
+ );
+}
+
+type TourButtonProps = Omit<ButtonProps, 'onClick'>;
+
+function TourPrevious(props: TourButtonProps) {
+ const tour = useTour();
+ const [local, others] = splitProps(props, ['children']);
+ return (
+ <Button
+ size="icon-sm"
+ label="Previous step"
+ disabled={tour.isFirst()}
+ {...others}
+ onClick={tour.previous}
+ >
+ {local.children ?? <CaretLeftIcon />}
+ </Button>
+ );
+}
+
+/** Advances, or completes the tour on the last step. */
+function TourNext(props: TourButtonProps & { doneLabel?: JSX.Element }) {
+ const tour = useTour();
+ const [local, others] = splitProps(props, ['children', 'doneLabel']);
+ // Text children name the button; only the icon form needs a label.
+ const iconOnly = () =>
+ local.children === undefined && !(tour.isLast() && local.doneLabel);
+ return (
+ <Button
+ size="icon-sm"
+ label={iconOnly() ? 'Next step' : undefined}
+ {...others}
+ onClick={tour.next}
+ >
+ <Show
+ when={tour.isLast() && local.doneLabel}
+ fallback={local.children ?? <CaretRightIcon />}
+ >
+ {local.doneLabel}
+ </Show>
+ </Button>
+ );
+}
+
+function TourClose(props: TourButtonProps) {
+ const tour = useTour();
+ const [local, others] = splitProps(props, ['children']);
+ // Text children name the button; only the icon form needs a label.
+ return (
+ <Button
+ size="icon-sm"
+ label={local.children === undefined ? 'Dismiss tour' : undefined}
+ {...others}
+ onClick={tour.dismiss}
+ >
+ {local.children ?? <XIcon />}
+ </Button>
+ );
+}
+
+/**
+ * Composable product tours. `Root` owns the steps; pick a form for the
+ * content (`Popover` floating by the target, or `Panel` inline) and add
+ * `Highlight` for the target, and `Beacon` and `Hint` for a waiting entry.
+ *
+ * @example
+ * <Tour.Root steps={steps} onDismiss={dismiss}>
+ * <Tour.Highlight />
+ * <Tour.Beacon />
+ * <Tour.Popover class="w-80 rounded-2xl border border-edge bg-dialog p-5">
+ * <Tour.Title />
+ * <Tour.Description />
+ * <Tour.Previous /> <Tour.Progress /> <Tour.Next doneLabel="Done" />
+ * </Tour.Popover>
+ * </Tour.Root>
+ */
+export const Tour = {
+ Root: TourRoot,
+ Popover: TourPopover,
+ Panel: TourPanel,
+ Highlight: TourHighlight,
+ Beacon: TourBeacon,
+ Hint: TourHint,
+ Title: TourTitle,
+ Description: TourDescription,
+ Progress: TourProgress,
+ Previous: TourPrevious,
+ Next: TourNext,
+ Close: TourClose,
+};
diff --git a/apps/web/src/components/ui/components/Tour/index.ts b/apps/web/src/components/ui/components/Tour/index.ts
new file mode 100644
index 0000000000..25d12cddc6
--- /dev/null
+++ b/apps/web/src/components/ui/components/Tour/index.ts
@@ -0,0 +1,18 @@
+export {
+ Tour,
+ type TourContextValue,
+ type TourHintProps,
+ type TourPopoverProps,
+ type TourRootProps,
+ type TourStatus,
+ type TourStep,
+ useTour,
+} from './Tour';
+export {
+ defineTourTargets,
+ matchTourTarget,
+ resolveTourTarget,
+ type TourTarget,
+ type TourTargetScope,
+ tourTarget,
+} from './targets';
diff --git a/apps/web/src/components/ui/components/Tour/targets.ts b/apps/web/src/components/ui/components/Tour/targets.ts
new file mode 100644
index 0000000000..aeb073fe92
--- /dev/null
+++ b/apps/web/src/components/ui/components/Tour/targets.ts
@@ -0,0 +1,138 @@
+import { createSignal, onCleanup } from 'solid-js';
+
+/**
+ * Where a target may be found. `view` targets resolve only inside the tour's
+ * boundary (its split pane), so two splits showing the same view never
+ * highlight each other's controls. `app` targets are shared chrome, such as
+ * the sidebar create menu, and resolve anywhere.
+ */
+export type TourTargetScope = 'view' | 'app';
+
+declare const tourTargetBrand: unique symbol;
+
+/**
+ * A named element a tour step can point at. Only `defineTourTargets` creates
+ * these, so every target has a `namespace.name` id and a declared scope.
+ */
+export type TourTarget = {
+ readonly id: `${string}.${string}`;
+ readonly scope: TourTargetScope;
+ readonly [tourTargetBrand]: true;
+};
+
+/**
+ * Declares the targets a feature exposes to tours.
+ *
+ * @example
+ * export const CALENDAR_TOUR = defineTourTargets('calendar', ['period', 'grid']);
+ * <div ref={tourTarget(CALENDAR_TOUR.period)} />
+ */
+export function defineTourTargets<const Name extends string>(
+ namespace: string,
+ names: readonly Name[],
+ options: { scope?: TourTargetScope } = {}
+): { readonly [K in Name]: TourTarget } {
+ const scope = options.scope ?? 'view';
+ return Object.fromEntries(
+ names.map((name) => [
+ name,
+ { id: `${namespace}.${name}`, scope } as unknown as TourTarget,
+ ])
+ ) as { readonly [K in Name]: TourTarget };
+}
+
+const elements = new Map<string, Set<HTMLElement>>();
+const [version, setVersion] = createSignal(0);
+const bump = () => setVersion((value) => value + 1);
+
+// Targets appear and disappear through layout too (a sidebar expanding from
+// zero width), so size changes of registered elements re-resolve. Only
+// registered elements are observed.
+let sizes: ResizeObserver | undefined;
+const observeSize = (element: HTMLElement) => {
+ if (typeof ResizeObserver === 'undefined') return;
+ sizes ??= new ResizeObserver(bump);
+ sizes.observe(element);
+};
+
+function register(target: TourTarget, element: HTMLElement) {
+ let set = elements.get(target.id);
+ if (!set) {
+ set = new Set();
+ elements.set(target.id, set);
+ }
+ set.add(element);
+ observeSize(element);
+ bump();
+ // Refs run before the element is inserted; resolve again once it is.
+ queueMicrotask(bump);
+ return () => {
+ set.delete(element);
+ if (!set.size) elements.delete(target.id);
+ sizes?.unobserve(element);
+ bump();
+ };
+}
+
+/**
+ * A ref that registers the element as `target` for as long as the owning
+ * component is mounted. Call it in JSX: `ref={tourTarget(TARGETS.name)}`.
+ *
+ * Don't pass a conditional expression as the ref
+ * (`ref={cond ? tourTarget(X) : undefined}`): the Solid compiler drops it.
+ * Create the ref in the component body and branch inside a callback.
+ */
+export function tourTarget(target: TourTarget) {
+ let unregister: (() => void) | undefined;
+ onCleanup(() => unregister?.());
+ return (element: HTMLElement) => {
+ unregister?.();
+ unregister = register(target, element);
+ };
+}
+
+const isShown = (element: HTMLElement) => {
+ if (!element.isConnected) return false;
+ const rect = element.getBoundingClientRect();
+ if (!rect.width || !rect.height) return false;
+ return !element.closest('[hidden], [inert], [aria-hidden="true"]');
+};
+
+/**
+ * The element for the first of `targets` that has one shown (inside
+ * `boundary` for view-scoped targets); the top-most when several share it. Reruns in a tracked scope when
+ * a target registers, unregisters, or resizes.
+ */
+export function resolveTourTarget(
+ targets: readonly TourTarget[],
+ boundary: HTMLElement | undefined
+): HTMLElement | undefined {
+ return matchTourTarget(targets, boundary)?.element;
+}
+
+/** Like `resolveTourTarget`, but also says which of `targets` matched. */
+export function matchTourTarget(
+ targets: readonly TourTarget[],
+ boundary: HTMLElement | undefined
+): { target: TourTarget; element: HTMLElement } | undefined {
+ version();
+ for (const target of targets) {
+ // Several elements can share a target (every row of a list); point at
+ // the top-most one on screen so the choice is stable and predictable.
+ let best: { element: HTMLElement; rect: DOMRect } | undefined;
+ for (const element of elements.get(target.id) ?? []) {
+ if (!isShown(element)) continue;
+ if (target.scope === 'view' && boundary && !boundary.contains(element))
+ continue;
+ const rect = element.getBoundingClientRect();
+ if (
+ !best ||
+ rect.top < best.rect.top ||
+ (rect.top === best.rect.top && rect.left < best.rect.left)
+ )
+ best = { element, rect };
+ }
+ if (best) return { target, element: best.element };
+ }
+ return undefined;
+}
diff --git a/apps/web/src/components/view-shell/SidebarCreateButton.tsx b/apps/web/src/components/view-shell/SidebarCreateButton.tsx
index 9942473625..ee250cb841 100644
--- a/apps/web/src/components/view-shell/SidebarCreateButton.tsx
+++ b/apps/web/src/components/view-shell/SidebarCreateButton.tsx
@@ -33,9 +33,11 @@ export function SidebarCreateHeader(props: {
export function SidebarCreateButton(props: {
label: string;
onCreate: () => void;
+ ref?: (element: HTMLElement) => void;
}) {
return (
<ViewSidebar.Action
+ ref={props.ref}
{...pressHandlers((event) => {
event.preventDefault();
props.onCreate();
diff --git a/apps/web/src/components/view-shell/ViewShell.tsx b/apps/web/src/components/view-shell/ViewShell.tsx
index 3b9efcd26e..9f5ccb4367 100644
--- a/apps/web/src/components/view-shell/ViewShell.tsx
+++ b/apps/web/src/components/view-shell/ViewShell.tsx
@@ -12,9 +12,11 @@ import { TOKENS } from '@core/hotkey/tokens';
import ListIcon from '@phosphor/list.svg';
import SidebarIcon from '@phosphor/sidebar-simple.svg';
import { createWritableMemo } from '@solid-primitives/memo';
+import { mergeRefs } from '@solid-primitives/refs';
import { createElementSize } from '@solid-primitives/resize-observer';
import { Button, cn } from '@ui';
import { CollapseTransition } from '@ui/components/CollapseTransition';
+import { tourTarget } from '@ui/components/Tour';
import {
type Accessor,
batch,
@@ -32,6 +34,7 @@ import {
useContext,
} from 'solid-js';
import { createSidebarMotion } from './create-sidebar-motion';
+import { VIEW_SHELL_TOUR } from './tour';
import {
type AsideLayout,
type AsideMode,
@@ -377,6 +380,7 @@ function Aside(props: ViewShellAsideProps) {
'onWidthChangeEnd',
]);
const ws = useViewShellInternal();
+ const asideTarget = tourTarget(VIEW_SHELL_TOUR.aside);
const [resizedWidth, setResizedWidth] = createSignal<{
configuredWidth: number;
width: number;
@@ -460,6 +464,7 @@ function Aside(props: ViewShellAsideProps) {
>
<div
{...rest}
+ ref={asideTarget}
class={cn('size-full min-h-0 min-w-0', local.class)}
data-view-shell-aside=""
inert={ws.aside.isCollapsed()}
@@ -496,7 +501,10 @@ function Aside(props: ViewShellAsideProps) {
'relative h-full max-w-full bg-panel shadow-menu',
local.class
)}
- ref={overlayAside}
+ ref={(element) => {
+ overlayAside = element;
+ asideTarget(element);
+ }}
style={{ width: `${overlayWidth()}px` }}
data-view-shell-aside=""
>
@@ -526,6 +534,9 @@ export function ViewSidebarCloseButton(
/** Safe outside a shell so block preview headers can share this control. */
export function ViewSidebarToggle(props: { action: 'collapse' | 'expand' }) {
const ws = useContext(ViewShellContext);
+ // A conditional expression as `ref` is dropped by the Solid compiler, so
+ // only the expand toggle registers, from inside the callback.
+ const toggleTarget = tourTarget(VIEW_SHELL_TOUR.sidebarToggle);
const visible = () =>
ws?.aside.canCollapse() &&
(props.action === 'expand'
@@ -548,6 +559,9 @@ export function ViewSidebarToggle(props: { action: 'collapse' | 'expand' }) {
}
hotkey={TOKENS.workspace.toggleNavigation}
aria-expanded={props.action !== 'expand'}
+ ref={(element) => {
+ if (props.action === 'expand') toggleTarget(element);
+ }}
data-view-sidebar-toggle={props.action}
onClick={(event) => {
const shell = event.currentTarget.closest('[data-view-shell]');
@@ -591,7 +605,7 @@ export function ViewNavigationControls() {
}
function Main(props: JSX.HTMLAttributes<HTMLElement>) {
- const [local, rest] = splitProps(props, ['children', 'class']);
+ const [local, rest] = splitProps(props, ['children', 'class', 'ref']);
const ws = useViewShellInternal();
const layout = ws.main.layout;
const target = () => {
@@ -612,6 +626,7 @@ function Main(props: JSX.HTMLAttributes<HTMLElement>) {
>
<main
{...rest}
+ ref={mergeRefs(local.ref, tourTarget(VIEW_SHELL_TOUR.main))}
class={cn('flex size-full min-h-0 min-w-0 flex-col', local.class)}
data-view-shell-main=""
>
@@ -622,10 +637,11 @@ function Main(props: JSX.HTMLAttributes<HTMLElement>) {
}
function TopBar(props: JSX.HTMLAttributes<HTMLDivElement>) {
- const [local, rest] = splitProps(props, ['children', 'class']);
+ const [local, rest] = splitProps(props, ['children', 'class', 'ref']);
return (
<div
{...rest}
+ ref={mergeRefs(local.ref, tourTarget(VIEW_SHELL_TOUR.topBar))}
class={cn(
'flex h-12 min-w-0 shrink-0 items-center gap-1 px-2 py-3 not-touch:pl-[13px] touch:hidden',
local.class
diff --git a/apps/web/src/components/view-shell/index.ts b/apps/web/src/components/view-shell/index.ts
index 06905503fb..121f8e955a 100644
--- a/apps/web/src/components/view-shell/index.ts
+++ b/apps/web/src/components/view-shell/index.ts
@@ -19,6 +19,7 @@ export {
} from './ListDropdowns';
export { MobileFilterDrawer } from './MobileFilterDrawer';
export { SearchBar, type SearchBarProps } from './SearchBar';
+export { VIEW_SHELL_TOUR } from './tour';
export {
type UseViewControlHotkeysOptions,
useViewControlHotkeys,
diff --git a/apps/web/src/components/view-shell/tour.ts b/apps/web/src/components/view-shell/tour.ts
new file mode 100644
index 0000000000..c8a7b39b5a
--- /dev/null
+++ b/apps/web/src/components/view-shell/tour.ts
@@ -0,0 +1,14 @@
+import { defineTourTargets } from '@ui/components/Tour';
+
+/**
+ * Parts every view shell registers for tours. They resolve per split, so a
+ * step can point at "this view's sidebar" without the view tagging it.
+ * `sidebarToggle` is the expand control shown while the sidebar is collapsed,
+ * the natural entry for a step whose target lives in the sidebar.
+ */
+export const VIEW_SHELL_TOUR = defineTourTargets('view-shell', [
+ 'aside',
+ 'main',
+ 'topBar',
+ 'sidebarToggle',
+]);
diff --git a/apps/web/src/features/agents-view/components/AgentsSidebar.tsx b/apps/web/src/features/agents-view/components/AgentsSidebar.tsx
index ef74fd800a..2767f2e17b 100644
--- a/apps/web/src/features/agents-view/components/AgentsSidebar.tsx
+++ b/apps/web/src/features/agents-view/components/AgentsSidebar.tsx
@@ -27,6 +27,7 @@ import AgentIcon from '@phosphor/sparkle.svg';
import TrayIcon from '@phosphor/tray.svg';
import { Key } from '@solid-primitives/keyed';
import { cn } from '@ui';
+import { tourTarget } from '@ui/components/Tour';
import { createSignal, type JSX, Show } from 'solid-js';
import { compactAge } from '../core/format-age';
import type { AgentsMode } from '../core/mode';
@@ -35,6 +36,7 @@ import {
type AgentConversationEntity,
conversationTimestamp,
} from '../core/recent-conversations';
+import { AGENTS_TOUR } from '../tour';
import { AgentSessionListItem } from '../views/AgentSessionListItem';
import { AgentSessionListSkeleton } from './AgentSessionListSkeleton';
@@ -227,6 +229,7 @@ export function AgentsSidebar(props: AgentsSidebarProps) {
<SidebarCreateButton
label="New conversation"
onCreate={props.onNewConversation}
+ ref={tourTarget(AGENTS_TOUR.newChat)}
/>
</ViewSidebar.Primary>
@@ -235,6 +238,7 @@ export function AgentsSidebar(props: AgentsSidebarProps) {
<ViewSidebar.Item
active={props.activePage === 'agents'}
onClick={() => props.onOpenPage('agents')}
+ ref={tourTarget(AGENTS_TOUR.rosterNav)}
>
<ViewSidebar.Icon>
<AgentIcon />
diff --git a/apps/web/src/features/agents-view/tour.ts b/apps/web/src/features/agents-view/tour.ts
new file mode 100644
index 0000000000..5a3b7dd539
--- /dev/null
+++ b/apps/web/src/features/agents-view/tour.ts
@@ -0,0 +1,60 @@
+import { VIEW_SHELL_TOUR } from '@app/components/view-shell/tour';
+import { APP_TOUR } from '@app/features/command/sidebar/tour';
+import { defineViewTour } from '@app/features/tours/core/view-tour';
+import { defineTourTargets } from '@ui/components/Tour';
+
+export const AGENTS_TOUR = defineTourTargets('agents', [
+ 'newChat',
+ 'rosterNav',
+ 'picker',
+ 'composer',
+ 'agentsTab',
+ 'runtimesTab',
+]);
+
+const openRoster = {
+ entry: [AGENTS_TOUR.rosterNav, VIEW_SHELL_TOUR.sidebarToggle],
+ entryLabel: 'Open Agents to continue',
+};
+
+export const agentsTour = defineViewTour({
+ id: 'agents',
+ title: 'Agents',
+ steps: [
+ {
+ target: AGENTS_TOUR.picker,
+ entry: [AGENTS_TOUR.newChat, VIEW_SHELL_TOUR.sidebarToggle],
+ entryLabel: 'Start a new conversation to continue',
+ title: 'Choose your agent and model',
+ description:
+ 'Open this picker to choose a chat or coding agent. Models are listed here too; each agent’s submenu lets you choose a model for that conversation.',
+ },
+ {
+ target: AGENTS_TOUR.agentsTab,
+ ...openRoster,
+ title: 'Chat agents work with your context',
+ description:
+ 'Chat agents use instructions and connected tools to research, write, and work with your documents and conversations. Your team and private agents live here.',
+ },
+ {
+ target: AGENTS_TOUR.runtimesTab,
+ ...openRoster,
+ title: 'Coding agents work on code',
+ description:
+ 'Coding agents run through a coding runtime, such as Cursor or a paired machine. Choose a coding agent when you need repository work rather than a regular chat.',
+ },
+ {
+ target: AGENTS_TOUR.agentsTab,
+ ...openRoster,
+ title: 'Share agents with your team',
+ description:
+ 'Team agents are available to teammates; private agents belong to you. When creating or editing an agent, choose Team or Private alongside its instructions and tools.',
+ },
+ {
+ target: APP_TOUR.createMenu,
+ title: 'Put recurring work on a schedule',
+ description:
+ 'Use Create → Automation to give an agent instructions and a schedule—for example, a weekly summary or daily triage. Review the automation’s runs and pause it when you need to.',
+ },
+ ],
+});
diff --git a/apps/web/src/features/agents-view/views/AgentPicker.tsx b/apps/web/src/features/agents-view/views/AgentPicker.tsx
index 4b98310b04..55ce0f6710 100644
--- a/apps/web/src/features/agents-view/views/AgentPicker.tsx
+++ b/apps/web/src/features/agents-view/views/AgentPicker.tsx
@@ -8,6 +8,7 @@ import CheckIcon from '@phosphor/check.svg';
import CodeIcon from '@phosphor/code.svg';
import PlusIcon from '@phosphor/plus.svg';
import { Dropdown } from '@ui';
+import { tourTarget } from '@ui/components/Tour';
import { createSignal, For, Show } from 'solid-js';
import { AgentModelMenuItem } from '../../block-agent/component/AgentModelMenuItem';
import type {
@@ -21,6 +22,7 @@ import {
rosterForAgentPicker,
} from '../core/roster';
import { createComposerModels } from '../queries/composer-models';
+import { AGENTS_TOUR } from '../tour';
/** Agent selection with a per-message model catalog in each submenu. */
export function AgentPicker(props: {
@@ -75,6 +77,7 @@ export function AgentPicker(props: {
<Dropdown.Trigger
variant="ghost"
aria-label="Agent"
+ ref={tourTarget(AGENTS_TOUR.picker)}
title={
rawModel()
? label()
diff --git a/apps/web/src/features/agents-view/views/AgentsView.tsx b/apps/web/src/features/agents-view/views/AgentsView.tsx
index 4ec78a09c1..de6f15b286 100644
--- a/apps/web/src/features/agents-view/views/AgentsView.tsx
+++ b/apps/web/src/features/agents-view/views/AgentsView.tsx
@@ -4,6 +4,7 @@ import { QUERY_FILTERS_BASE } from '@app/features/next-soup/filters/query-filter
import { AgentSettings } from '@app/features/settings/AgentSettings';
import { McpConnections } from '@app/features/settings/McpConnections';
import { withEntityNotifications } from '@app/features/soup/entity-notifications';
+import { ViewTour } from '@app/features/tours/ViewTour';
import {
useGlobalBlockOrchestrator,
useGlobalNotificationSource,
@@ -49,6 +50,7 @@ import {
import { kindForBot } from '../core/roster';
import { type AgentsRoute, agentsRouteId } from '../core/route';
import { createAgentRosterSource } from '../queries/agent-roster-source';
+import { agentsTour } from '../tour';
import { NewChatPage, type StartConversation } from './NewChatPage';
type SelectedConversation = {
@@ -292,6 +294,7 @@ function AgentsWorkspace(props: { initialRoute?: AgentsRoute }) {
</ViewShell.Aside>
<ViewShell.Main class="overflow-hidden">
+ <ViewTour tour={agentsTour} />
<main class="main">
<Show
when={selected()?.conversation}
diff --git a/apps/web/src/features/agents-view/views/NewChatPage.tsx b/apps/web/src/features/agents-view/views/NewChatPage.tsx
index 802c553487..87040c4af9 100644
--- a/apps/web/src/features/agents-view/views/NewChatPage.tsx
+++ b/apps/web/src/features/agents-view/views/NewChatPage.tsx
@@ -10,6 +10,7 @@ import { useUserId } from '@core/context/user';
import { uploadFile } from '@core/util/upload';
import { useAgentCapabilitiesQuery } from '@queries/agents/capabilities';
import type { PromptAttachment } from '@service-agent-harness/generated/schemas';
+import { tourTarget } from '@ui/components/Tour';
import { createMemo, createSignal } from 'solid-js';
import {
type EffortChoice,
@@ -29,6 +30,7 @@ import { createRecentRepositories } from '../primitives/recent-repositories';
import { createComposerModels } from '../queries/composer-models';
import { createReachableRepositories } from '../queries/reachable-repositories';
import { createRepositoryBranches } from '../queries/repository-branches';
+import { AGENTS_TOUR } from '../tour';
import { AgentPicker } from './AgentPicker';
import { RepositoryPicker } from './RepositoryPicker';
@@ -255,7 +257,7 @@ export function NewChatPage(props: {
return (
<section class="page newchat" data-active aria-label="New conversation">
- <div class="col">
+ <div ref={tourTarget(AGENTS_TOUR.composer)} class="col">
<div class="greeting">
<h2>
{coding() ? 'What should we build?' : 'What should we work on?'}
diff --git a/apps/web/src/features/calendar-view/components/CalendarSidebar.tsx b/apps/web/src/features/calendar-view/components/CalendarSidebar.tsx
index 33b7a9d213..bf7222580d 100644
--- a/apps/web/src/features/calendar-view/components/CalendarSidebar.tsx
+++ b/apps/web/src/features/calendar-view/components/CalendarSidebar.tsx
@@ -22,6 +22,7 @@ import CaretDownIcon from '@phosphor/caret-down.svg';
import PlusIcon from '@phosphor/plus.svg';
import CloseIcon from '@phosphor/x.svg';
import { cn, Calendar as MiniCalendar, ToggleSwitch } from '@ui';
+import { tourTarget } from '@ui/components/Tour';
import { format } from 'date-fns';
import {
createEffect,
@@ -34,6 +35,7 @@ import {
Switch,
} from 'solid-js';
import { CalendarCallSidebar } from '../calendar-call-sidebar';
+import { CALENDAR_TOUR } from '../tour';
import {
CalendarCreateCallItem,
CalendarCreateEventItem,
@@ -92,7 +94,7 @@ function UpcomingEventsSection() {
return (
<CollapsibleSection.Root open={open()} onOpenChange={setOpen}>
- <CollapsibleSection.Header>
+ <CollapsibleSection.Header ref={tourTarget(CALENDAR_TOUR.upcoming)}>
<CollapsibleSection.Trigger class="min-w-0 flex-1">
<span class="min-w-0 truncate">Upcoming events</span>
<CollapsibleSection.Indicator />
diff --git a/apps/web/src/features/calendar-view/components/Header.tsx b/apps/web/src/features/calendar-view/components/Header.tsx
index 72a588d105..b44fb70871 100644
--- a/apps/web/src/features/calendar-view/components/Header.tsx
+++ b/apps/web/src/features/calendar-view/components/Header.tsx
@@ -29,6 +29,7 @@ import PlusIcon from '@phosphor/plus.svg';
import { createElementSize } from '@solid-primitives/resize-observer';
import { Button, cn } from '@ui';
import { usePager } from '@ui/components/Pager';
+import { tourTarget } from '@ui/components/Tour';
import {
createMemo,
createSignal,
@@ -37,6 +38,7 @@ import {
Show,
Switch,
} from 'solid-js';
+import { CALENDAR_TOUR } from '../tour';
import {
CalendarCreateCallItem,
CalendarCreateEventItem,
@@ -251,6 +253,7 @@ export function Header(props: { presentation: 'workspace' | 'preview' }) {
size="icon-sm"
class="shrink-0"
label="Show calendar navigation"
+ ref={tourTarget(CALENDAR_TOUR.sidebarToggle)}
aria-expanded={shell?.aside.isOverlay() ?? false}
onClick={() => shell?.aside.expand()}
>
@@ -274,7 +277,10 @@ export function Header(props: { presentation: 'workspace' | 'preview' }) {
<SplitHeaderRight>
<HeaderIsland class="px-1">
- <div class="flex items-center gap-1">
+ <div
+ ref={tourTarget(CALENDAR_TOUR.period)}
+ class="flex items-center gap-1"
+ >
<Show when={!isMobile()}>
<PeriodSelector isNarrow={isNarrow()} />
<div class="flex shrink-0 items-center gap-1">
@@ -359,6 +365,7 @@ export function Header(props: { presentation: 'workspace' | 'preview' }) {
isCompactHeader() ? 'basis-full' : 'ml-4'
)}
data-calendar-period-controls=""
+ ref={tourTarget(CALENDAR_TOUR.period)}
onClick={() => setSearchExpanded(false)}
>
<Show when={showHeaderCreate()}>
diff --git a/apps/web/src/features/calendar-view/components/Workspace.tsx b/apps/web/src/features/calendar-view/components/Workspace.tsx
index 5a0d6645a1..7d6e908d01 100644
--- a/apps/web/src/features/calendar-view/components/Workspace.tsx
+++ b/apps/web/src/features/calendar-view/components/Workspace.tsx
@@ -6,6 +6,7 @@ import {
} from '@app/features/calendar/components/CalendarPagerContext';
import { useCalendarView } from '@app/features/calendar/components/CalendarViewContext';
import { RangeUnavailableBanner } from '@app/features/calendar/components/RangeUnavailableBanner';
+import { ViewTour } from '@app/features/tours/ViewTour';
import { createSizeBreakpoints } from '@app/util/create-size-breakpoints';
import {
useSplitDisplayName,
@@ -16,6 +17,7 @@ import { isMobile } from '@core/mobile/isMobile';
import { createElementSize } from '@solid-primitives/resize-observer';
import { Layer } from '@ui';
import { Pager, PagerSwipeGestures } from '@ui/components/Pager';
+import { tourTarget } from '@ui/components/Tour';
import {
createEffect,
createSignal,
@@ -27,6 +29,7 @@ import {
Suspense,
Switch,
} from 'solid-js';
+import { CALENDAR_TOUR, calendarTour } from '../tour';
import { CalendarSidebar } from './CalendarSidebar';
import { Header } from './Header';
import { Page } from './Page';
@@ -117,7 +120,10 @@ function CalendarPages() {
function CalendarPageContent() {
return (
- <div class="calendar-view-content flex min-w-0 min-h-0 flex-1 flex-col">
+ <div
+ ref={tourTarget(CALENDAR_TOUR.grid)}
+ class="calendar-view-content flex min-w-0 min-h-0 flex-1 flex-col"
+ >
<CalendarPages />
</div>
);
@@ -164,6 +170,7 @@ function WorkspaceContent() {
</Show>
<ViewShell.Main>
<Header presentation="workspace" />
+ <ViewTour tour={calendarTour} />
<ViewShell.Content class="flex min-h-0 flex-1">
<CalendarPageContent />
</ViewShell.Content>
diff --git a/apps/web/src/features/calendar-view/tour.ts b/apps/web/src/features/calendar-view/tour.ts
new file mode 100644
index 0000000000..0e53565542
--- /dev/null
+++ b/apps/web/src/features/calendar-view/tour.ts
@@ -0,0 +1,60 @@
+import { VIEW_SHELL_TOUR } from '@app/components/view-shell/tour';
+import { defineViewTour } from '@app/features/tours/core/view-tour';
+import { defineTourTargets } from '@ui/components/Tour';
+
+export const CALENDAR_TOUR = defineTourTargets('calendar', [
+ 'sources',
+ 'availability',
+ 'upcoming',
+ 'period',
+ 'grid',
+ 'sidebarToggle',
+]);
+
+/**
+ * Touch and preview headers have their own sidebar toggle; the desktop
+ * workspace uses the shell's.
+ */
+const openSidebar = {
+ entry: [CALENDAR_TOUR.sidebarToggle, VIEW_SHELL_TOUR.sidebarToggle],
+ entryLabel: 'Show the calendar sidebar to continue',
+};
+
+export const calendarTour = defineViewTour({
+ id: 'calendar',
+ title: 'Calendar',
+ connector: { kind: 'email', label: 'Google' },
+ steps: [
+ {
+ // The Calendars list only appears with more than one calendar.
+ target: [CALENDAR_TOUR.sources, VIEW_SHELL_TOUR.aside],
+ ...openSidebar,
+ missingHint:
+ 'Connect another Google account to choose which calendars to show here.',
+ title: 'All your calendars, one schedule',
+ description:
+ 'Connect multiple Google accounts and see work, personal, and shared calendars together. Expand an account here to toggle individual calendars.',
+ },
+ {
+ // Copy availability needs a connected Google calendar.
+ target: [CALENDAR_TOUR.availability, CALENDAR_TOUR.upcoming],
+ ...openSidebar,
+ missingHint: 'Connect a Google calendar to copy your availability.',
+ title: 'Copy your availability',
+ description:
+ 'Choose a date range to copy your open times, then paste them into a message or email. Busy events across your connected calendars are taken into account.',
+ },
+ {
+ target: CALENDAR_TOUR.period,
+ title: 'Choose how you see your week',
+ description:
+ 'Switch between day, week, and month. Move through dates without losing your connected calendars.',
+ },
+ {
+ target: CALENDAR_TOUR.grid,
+ title: 'Keep the conversation with the event',
+ description:
+ 'Open an event to see its participants and meeting details. Join the call from the event when it is time.',
+ },
+ ],
+});
diff --git a/apps/web/src/features/calendar/availability/CopyAvailabilityButton.tsx b/apps/web/src/features/calendar/availability/CopyAvailabilityButton.tsx
index c5abeb9f34..a717688cc9 100644
--- a/apps/web/src/features/calendar/availability/CopyAvailabilityButton.tsx
+++ b/apps/web/src/features/calendar/availability/CopyAvailabilityButton.tsx
@@ -1,5 +1,7 @@
+import { CALENDAR_TOUR } from '@app/features/calendar-view/tour';
import CalendarCheckIcon from '@phosphor/calendar-check.svg';
import { Button, type ButtonSize, useImperativeDialog } from '@ui';
+import { tourTarget } from '@ui/components/Tour';
import { Show } from 'solid-js';
import { useCalendarConnectedInboxes } from '../hooks/use-calendar-connected-inboxes';
import { CopyAvailabilityDialog } from './CopyAvailabilityDialog';
@@ -18,6 +20,7 @@ export function CopyAvailabilityButton(props: {
return (
<Show when={connectedInboxes().length > 0}>
<Button
+ ref={tourTarget(CALENDAR_TOUR.availability)}
variant="ghost"
size={props.size ?? 'icon-sm'}
class={props.class}
diff --git a/apps/web/src/features/calendar/components/SourceControls.tsx b/apps/web/src/features/calendar/components/SourceControls.tsx
index eb7a18d31a..2200dec272 100644
--- a/apps/web/src/features/calendar/components/SourceControls.tsx
+++ b/apps/web/src/features/calendar/components/SourceControls.tsx
@@ -1,8 +1,10 @@
import { ViewSidebar } from '@app/components/view-shell';
+import { CALENDAR_TOUR } from '@app/features/calendar-view/tour';
import CaretDownIcon from '@phosphor/caret-down.svg';
import RssIcon from '@phosphor/rss.svg';
import WarningIcon from '@phosphor/warning.svg';
import { Checkbox } from '@ui';
+import { tourTarget } from '@ui/components/Tour';
import { createSignal, For, Show } from 'solid-js';
import type { CalendarSource } from '../types';
import { groupCalendarSourcesByAccount } from '../utils/calendar-source-groups';
@@ -35,7 +37,10 @@ export function SourceControls(props: SourceControlsProps) {
});
return (
- <ul class="flex min-w-0 flex-col gap-(--sidebar-row-gap)">
+ <ul
+ ref={tourTarget(CALENDAR_TOUR.sources)}
+ class="flex min-w-0 flex-col gap-(--sidebar-row-gap)"
+ >
<For each={groups()}>
{(group) => {
const visibleCount = () =>
diff --git a/apps/web/src/features/channel/Call/ChannelCallButton.tsx b/apps/web/src/features/channel/Call/ChannelCallButton.tsx
index 1bd7e7c19d..fb5151576b 100644
--- a/apps/web/src/features/channel/Call/ChannelCallButton.tsx
+++ b/apps/web/src/features/channel/Call/ChannelCallButton.tsx
@@ -7,7 +7,9 @@ import PhoneIcon from '@phosphor/phone-call.svg';
import { useActiveCallQuery } from '@queries/call/call';
import { ChannelTypeEnum } from '@service-storage/client';
import { Button, cn, confirmDialog } from '@ui';
+import { tourTarget } from '@ui/components/Tour';
import { getOwner, Show } from 'solid-js';
+import { CHANNEL_TOUR } from '../tour';
import { getCallJoinTab, getCallLeaveTab } from './call-tabs';
import { useCall } from './use-call';
@@ -100,6 +102,7 @@ export function ChannelCallButton(props: { channelId: string }) {
return (
<Show when={!call.isInThisChannel()}>
<Button
+ ref={tourTarget(CHANNEL_TOUR.call)}
onClick={handleClick}
tooltip={tooltip()}
variant={variant()}
diff --git a/apps/web/src/features/channel/Channel/Channel.tsx b/apps/web/src/features/channel/Channel/Channel.tsx
index 0e86768a56..87fcd65ccc 100644
--- a/apps/web/src/features/channel/Channel/Channel.tsx
+++ b/apps/web/src/features/channel/Channel/Channel.tsx
@@ -72,6 +72,7 @@ import {
import { usePostTypingUpdateMutation } from '@queries/messages/typing';
import { ChannelTypeEnum } from '@service-storage/client';
import { useBeforeLeave } from '@solidjs/router';
+import { tourTarget } from '@ui/components/Tour';
import {
createEffect,
createMemo,
@@ -92,6 +93,7 @@ import { ChannelInputContainer } from '../Input/ChannelInputContainer';
import { hasSendableInputContent } from '../Input/utils/sendable-content';
import { ChannelThread } from '../Thread';
import { buildReplyTargetValue } from '../Thread/utils/message-actions';
+import { CHANNEL_TOUR } from '../tour';
import { isUnifiedInputMode } from '../unified-input-mode';
import { ActiveCallMessage } from './ActiveCallMessage';
import { ChannelDropZone } from './ChannelDropZone';
@@ -201,6 +203,8 @@ export function Channel(props: ChannelProps) {
isReady: () => !!threadListNavigation(),
});
+ const messagesTarget = tourTarget(CHANNEL_TOUR.messages);
+ const composerTarget = tourTarget(CHANNEL_TOUR.composer);
const [channelInputSnapshot, setChannelInputSnapshot] =
createSignal<InputSnapshot>();
const [channelInputHandle, setChannelInputHandle] =
@@ -700,6 +704,7 @@ export function Channel(props: ChannelProps) {
class="ph-no-capture relative flex-1 min-h-0 outline-none flex flex-col"
ref={(element) => {
attachMessageListRef(element);
+ messagesTarget(element);
}}
tabIndex={-1}
data-channel-message-list
@@ -904,6 +909,7 @@ export function Channel(props: ChannelProps) {
<ChannelInputContainer
ref={(el) => {
attachInputRef(el);
+ composerTarget(el);
}}
>
<Switch>
diff --git a/apps/web/src/features/channel/tour.ts b/apps/web/src/features/channel/tour.ts
new file mode 100644
index 0000000000..b6934fd279
--- /dev/null
+++ b/apps/web/src/features/channel/tour.ts
@@ -0,0 +1,8 @@
+import { defineTourTargets } from '@ui/components/Tour';
+
+/** Parts of an open conversation that tours can point at. */
+export const CHANNEL_TOUR = defineTourTargets('channel', [
+ 'messages',
+ 'composer',
+ 'call',
+]);
diff --git a/apps/web/src/features/channels-view/channels-view.test.tsx b/apps/web/src/features/channels-view/channels-view.test.tsx
index b3831f8fe0..50062e5fe9 100644
--- a/apps/web/src/features/channels-view/channels-view.test.tsx
+++ b/apps/web/src/features/channels-view/channels-view.test.tsx
@@ -51,6 +51,7 @@ vi.mock('@app/lib/split-router', () => ({
),
},
}));
+vi.mock('@app/features/tours/ViewTour', () => ({ ViewTour: () => null }));
vi.mock('@app/components/view-shell', () => ({
ViewShell: {
Root: mocks.pass,
diff --git a/apps/web/src/features/channels-view/channels-view.tsx b/apps/web/src/features/channels-view/channels-view.tsx
index d49835f2be..1a158c9b62 100644
--- a/apps/web/src/features/channels-view/channels-view.tsx
+++ b/apps/web/src/features/channels-view/channels-view.tsx
@@ -4,6 +4,7 @@ import { useMobileSearchText } from '@app/features/command/mobile/use-mobile-sea
import { markChannelNotificationsSeenOnOpen } from '@app/features/next-soup/utils';
import { MaybeSoupEntityActionDrawerManager } from '@app/features/soup';
import { withEntityNotifications } from '@app/features/soup/entity-notifications';
+import { ViewTour } from '@app/features/tours/ViewTour';
import { SplitRouter } from '@app/lib/split-router';
import { DebugSuspense } from '@channel/DebugSuspense';
import { useGlobalNotificationSource } from '@components/app/GlobalAppState';
@@ -34,6 +35,7 @@ import {
} from './queries';
import { createChannelDetailSource } from './queries/channel-detail-source';
import { createChannelSearchSource } from './queries/channel-search-source';
+import { channelsTour } from './tour';
const ChannelSourcesContext =
createContext<ReturnType<typeof useChannelsSources>>();
@@ -146,6 +148,7 @@ function ChannelsViewRoot() {
</DebugSuspense>
</ViewShell.Aside>
<ViewShell.Main class="overflow-hidden">
+ <ViewTour tour={channelsTour} />
<ChannelSourcesContext.Provider value={sources}>
<DebugSuspense name="ChannelsView.outlet">
<SplitRouter.Outlet
diff --git a/apps/web/src/features/channels-view/components/rail/ExpandedChannelsRail.tsx b/apps/web/src/features/channels-view/components/rail/ExpandedChannelsRail.tsx
index e0f1678b89..2e53d05240 100644
--- a/apps/web/src/features/channels-view/components/rail/ExpandedChannelsRail.tsx
+++ b/apps/web/src/features/channels-view/components/rail/ExpandedChannelsRail.tsx
@@ -21,6 +21,7 @@ import {
useDragDropContext,
} from '@thisbeyond/solid-dnd';
import { cn, Dropdown, EmptyStatePanel, Hotkey, Tabs, Tooltip } from '@ui';
+import { tourTarget } from '@ui/components/Tour';
import {
type Accessor,
createSignal,
@@ -33,6 +34,7 @@ import {
import { Virtualizer, type VirtualizerHandle } from 'virtua/solid';
import { canLabelChannel } from '../../core/channel-label-eligibility';
import { ChannelsLiveCallsSidebar } from '../../live-calls-sidebar';
+import { CHANNELS_TOUR } from '../../tour';
import type { ChannelListSort, ChannelsGroup } from '../../types';
import { channelMentionsUser, formatDetailedTimestamp } from '../../utils';
import { ChannelsEmptyState } from '../ChannelsEmptyState';
@@ -323,6 +325,7 @@ function ChannelOption(props: {
>
<ViewSidebar.Item
as="div"
+ ref={tourTarget(CHANNELS_TOUR.conversation)}
id={item().domId}
role="treeitem"
tabIndex={-1}
@@ -710,6 +713,9 @@ function ChannelHeadingDropTarget(props: { element: HTMLElement }) {
}
function ExpandedGroupSection(props: { config: GroupConfig }) {
+ // A conditional expression as `ref` is dropped by the Solid compiler, so
+ // the target is chosen inside the callback.
+ const createTarget = tourTarget(CHANNELS_TOUR.create);
const rail = useChannelsRail();
const [scrollRoot, setScrollRoot] = createSignal<HTMLDivElement>();
const [headerElement, setHeaderElement] = createSignal<HTMLElement>();
@@ -774,7 +780,13 @@ function ExpandedGroupSection(props: { config: GroupConfig }) {
</span>
</Show>
</button>
- <div data-section-action="" class="flex items-center gap-0.5">
+ <div
+ ref={(element) => {
+ if (props.config.group === 'channels') createTarget(element);
+ }}
+ data-section-action=""
+ class="flex items-center gap-0.5"
+ >
<ChannelSortDropdown
group={props.config.group}
label={props.config.label}
@@ -1015,6 +1027,7 @@ function ExpandedRecents() {
}
export function ExpandedChannelsRail(props: { search: ChannelRailSearch }) {
+ const listTarget = tourTarget(CHANNELS_TOUR.list);
const rail = useChannelsRail();
const activeDescendant = () => {
const rowId = rail.list.focus.key();
@@ -1027,7 +1040,10 @@ export function ExpandedChannelsRail(props: { search: ChannelRailSearch }) {
<ChannelsLiveCallsSidebar />
<div class="flex min-h-0 flex-1 flex-col">
<div
- ref={rail.registerRootRef}
+ ref={(element) => {
+ rail.registerRootRef(element);
+ listTarget(element);
+ }}
role="tree"
tabIndex={-1}
aria-activedescendant={activeDescendant()}
diff --git a/apps/web/src/features/channels-view/tour.ts b/apps/web/src/features/channels-view/tour.ts
new file mode 100644
index 0000000000..6ef776fef1
--- /dev/null
+++ b/apps/web/src/features/channels-view/tour.ts
@@ -0,0 +1,67 @@
+import { VIEW_SHELL_TOUR } from '@app/components/view-shell/tour';
+import { CHANNEL_TOUR } from '@app/features/channel/tour';
+import { defineViewTour } from '@app/features/tours/core/view-tour';
+import { defineTourTargets } from '@ui/components/Tour';
+
+export const CHANNELS_TOUR = defineTourTargets('channels', [
+ 'list',
+ 'create',
+ 'conversation',
+]);
+
+/** Steps inside a conversation wait on a row in the rail, or on the toggle
+ * that shows the rail when the sidebar is collapsed. */
+const openConversation = {
+ entry: [CHANNELS_TOUR.conversation, VIEW_SHELL_TOUR.sidebarToggle],
+ entryLabel: 'Open a channel or DM to continue',
+ missingHint: 'Select a channel or DM to see this feature highlighted.',
+};
+
+export const channelsTour = defineViewTour({
+ id: 'channels',
+ title: 'Channels',
+ video: {
+ youtubeId: '1gDOXUxHo0U',
+ title: 'What Macro learned from Slack/Superhuman',
+ duration: '5:56',
+ },
+ steps: [
+ {
+ target: CHANNELS_TOUR.list,
+ entry: VIEW_SHELL_TOUR.sidebarToggle,
+ entryLabel: 'Show the channel list to continue',
+ title: 'Channels and DMs, together',
+ description:
+ 'Organize work in shared channels, and use DMs for smaller conversations. All and Recent help you return to the right discussion.',
+ },
+ {
+ target: CHANNELS_TOUR.create,
+ entry: VIEW_SHELL_TOUR.sidebarToggle,
+ entryLabel: 'Show the channel list to continue',
+ title: 'Bring your team into the room',
+ description:
+ 'Use the + beside Channels to create a shared space, or the + beside DMs to start a direct message. Choose the people who need the context.',
+ },
+ {
+ target: CHANNEL_TOUR.messages,
+ ...openConversation,
+ title: 'Follow a thread, keep the context',
+ description:
+ 'Open a conversation, then reply to a message in a thread. The discussion stays attached to the original message instead of getting lost in the channel.',
+ },
+ {
+ target: CHANNEL_TOUR.composer,
+ ...openConversation,
+ title: 'Bring agents and work into chat',
+ description:
+ 'Type @ to mention a teammate or agent, or link a document, task, or call. Everyone in the conversation can follow the shared context they have access to.',
+ },
+ {
+ target: CHANNEL_TOUR.call,
+ ...openConversation,
+ title: 'Go from messages to a call',
+ description:
+ 'Use the phone button to start or join a call in this conversation. The call stays connected to the channel so the team can return to its context.',
+ },
+ ],
+});
diff --git a/apps/web/src/features/command/sidebar/sidebar-create-menu.tsx b/apps/web/src/features/command/sidebar/sidebar-create-menu.tsx
index 7b70b26c0d..9f2ced7ae9 100644
--- a/apps/web/src/features/command/sidebar/sidebar-create-menu.tsx
+++ b/apps/web/src/features/command/sidebar/sidebar-create-menu.tsx
@@ -8,6 +8,7 @@ import { activateClosestDOMScope } from '@core/hotkey/utils';
import CreateIcon from '@phosphor/note-pencil.svg';
import PlusIcon from '@phosphor/plus.svg';
import { Button, Dropdown, Hotkey, NavRow } from '@ui';
+import { tourTarget } from '@ui/components/Tour';
import {
createSignal,
For,
@@ -16,6 +17,7 @@ import {
type ValidComponent,
} from 'solid-js';
import { Dynamic } from 'solid-js/web';
+import { APP_TOUR } from './tour';
export type SidebarCreateMenuProps = {
/** Only read by the built-in `row` variant, for its tooltip. */
@@ -91,6 +93,7 @@ export const SidebarCreateMenu = (props: SidebarCreateMenuProps) => {
return true;
});
+ const createMenuTarget = tourTarget(APP_TOUR.createMenu);
return (
<Dropdown
open={open()}
@@ -105,6 +108,7 @@ export const SidebarCreateMenu = (props: SidebarCreateMenuProps) => {
when={props.variant === 'icon'}
fallback={
<Dropdown.Trigger
+ ref={createMenuTarget}
as={NavRow}
class="center h-8 bg-ink/4 text-[13px]"
fullWidth
@@ -135,6 +139,7 @@ export const SidebarCreateMenu = (props: SidebarCreateMenuProps) => {
}
>
<Dropdown.Trigger
+ ref={createMenuTarget}
as={Button}
variant="outline"
size="icon-sm"
@@ -154,6 +159,7 @@ export const SidebarCreateMenu = (props: SidebarCreateMenuProps) => {
>
{(trigger) => (
<Dropdown.Trigger
+ ref={createMenuTarget}
as={trigger()}
// `Dropdown.Trigger` hardcodes `variant`/`size` for its default
// `as={Button}` and spreads props after them, so both leak into a
diff --git a/apps/web/src/features/command/sidebar/tour.ts b/apps/web/src/features/command/sidebar/tour.ts
new file mode 100644
index 0000000000..c9ae912f94
--- /dev/null
+++ b/apps/web/src/features/command/sidebar/tour.ts
@@ -0,0 +1,6 @@
+import { defineTourTargets } from '@ui/components/Tour';
+
+/** App chrome that tours in any view can point at. */
+export const APP_TOUR = defineTourTargets('app', ['createMenu'], {
+ scope: 'app',
+});
diff --git a/apps/web/src/features/companies/components/CrmSidebar.tsx b/apps/web/src/features/companies/components/CrmSidebar.tsx
index 850826a2a4..d8e8fdcff5 100644
--- a/apps/web/src/features/companies/components/CrmSidebar.tsx
+++ b/apps/web/src/features/companies/components/CrmSidebar.tsx
@@ -9,8 +9,10 @@ import SidebarIcon from '@phosphor/sidebar-simple.svg';
import StackIcon from '@phosphor/stack.svg';
import ImportIcon from '@phosphor/upload-simple.svg';
import { Button, Tooltip } from '@ui';
+import { tourTarget } from '@ui/components/Tour';
import { createSignal, For, Show } from 'solid-js';
import { CRM_VIEWS } from '../core/crm-navigation';
+import { COMPANIES_TOUR } from '../tour';
export function CrmSidebar(props: {
active: string;
@@ -52,7 +54,7 @@ export function CrmSidebar(props: {
}
/>
<ViewSidebar.Content>
- <div class="px-1.5">
+ <div ref={tourTarget(COMPANIES_TOUR.layout)} class="px-1.5">
<TabsInset
aria-label="Company layout"
fullWidth
@@ -74,7 +76,10 @@ export function CrmSidebar(props: {
<CollapsibleSection.Indicator />
</CollapsibleSection.Trigger>
<CollapsibleSection.Content>
- <ViewSidebar.Nav aria-label="Company views">
+ <ViewSidebar.Nav
+ aria-label="Company views"
+ ref={tourTarget(COMPANIES_TOUR.views)}
+ >
<For each={CRM_VIEWS}>
{(view) => (
<Tooltip label={view.description} placement="right">
diff --git a/apps/web/src/features/companies/route.tsx b/apps/web/src/features/companies/route.tsx
index 5126211628..c18f201aca 100644
--- a/apps/web/src/features/companies/route.tsx
+++ b/apps/web/src/features/companies/route.tsx
@@ -1,3 +1,4 @@
+import { ViewTour } from '@app/features/tours/ViewTour';
import { defineRoute } from '@app/lib/split-router';
import {
CRM_VIEW_URL_PARAM,
@@ -11,6 +12,7 @@ import {
import { enableCrm, isFeatureEnabled } from '@core/constant/featureFlags';
import { lazy } from 'solid-js';
import { getViewPreset } from '../next-soup/sidebar/soup-filter-presets';
+import { companiesTour } from './tour';
const SoupView = lazy(async () => ({
default: (await import('../next-soup/soup-view/soup-view')).SoupView,
@@ -31,6 +33,7 @@ export const CompaniesRouteView = withAuth(() => {
initialClientFilters={preset?.clientFilters}
initialGroupBy={preset?.groupBy}
initialCrmView={crmView ? decodeCrmViewParam(crmView) : undefined}
+ tour={<ViewTour tour={companiesTour} />}
/>
);
});
diff --git a/apps/web/src/features/companies/tour.ts b/apps/web/src/features/companies/tour.ts
new file mode 100644
index 0000000000..ac40ed51d9
--- /dev/null
+++ b/apps/web/src/features/companies/tour.ts
@@ -0,0 +1,47 @@
+import { VIEW_SHELL_TOUR } from '@app/components/view-shell/tour';
+import { defineViewTour } from '@app/features/tours/core/view-tour';
+import { defineTourTargets } from '@ui/components/Tour';
+
+export const COMPANIES_TOUR = defineTourTargets('companies', [
+ 'layout',
+ 'views',
+]);
+
+export const companiesTour = defineViewTour({
+ id: 'companies',
+ title: 'Customers',
+ connector: {
+ kind: 'mcp',
+ label: 'HubSpot or Attio',
+ tools: ['HubSpot', 'Attio'],
+ },
+ video: {
+ youtubeId: '5d2K_NYs50k',
+ title: 'Teams and CRM in Macro',
+ duration: '2:33',
+ },
+ steps: [
+ {
+ target: COMPANIES_TOUR.layout,
+ entry: VIEW_SHELL_TOUR.sidebarToggle,
+ entryLabel: 'Show the Customers sidebar to continue',
+ title: 'Your pipeline, as a board or list',
+ description:
+ 'Switch to Board to see companies by stage, or List to scan their details in rows. Both show the same customer relationships—choose the view that fits your work.',
+ },
+ {
+ target: VIEW_SHELL_TOUR.main,
+ title: 'See the whole relationship',
+ description:
+ 'Open a company to view its contacts and details. Update properties as the relationship develops.',
+ },
+ {
+ target: COMPANIES_TOUR.views,
+ entry: VIEW_SHELL_TOUR.sidebarToggle,
+ entryLabel: 'Show the Customers sidebar to continue',
+ title: 'Make your pipeline useful',
+ description:
+ 'Use filters and saved views to focus on the right companies. Switch to the board to see work by stage.',
+ },
+ ],
+});
diff --git a/apps/web/src/features/companies/views/CrmWorkspace.tsx b/apps/web/src/features/companies/views/CrmWorkspace.tsx
index ebdc0e7cfe..e5ba691ea3 100644
--- a/apps/web/src/features/companies/views/CrmWorkspace.tsx
+++ b/apps/web/src/features/companies/views/CrmWorkspace.tsx
@@ -4,6 +4,7 @@ import {
useViewShell,
ViewShell,
} from '@app/components/view-shell';
+import { VIEW_SHELL_TOUR } from '@app/components/view-shell/tour';
import { NO_ASSIGNEE } from '@app/features/next-soup/filters/configs';
import { NIL_UUID } from '@app/features/next-soup/filters/filter-store';
import { getViewPreset } from '@app/features/next-soup/sidebar/soup-filter-presets';
@@ -32,6 +33,7 @@ import { useCrmLists } from '@queries/crm/lists';
import { useQuickAccessCrmCompaniesQuery } from '@queries/soup/quick-access-crm-companies';
import { useCurrentTeamQuery } from '@queries/team/teams';
import { Button, Dropdown, Tooltip } from '@ui';
+import { tourTarget } from '@ui/components/Tour';
import { createSignal, type JSX, onMount, Show, Suspense } from 'solid-js';
import { openCreateCompanyModal } from '../CreateCompanyModal';
import { CrmListDialog } from '../components/CrmListDialog';
@@ -52,6 +54,8 @@ function NavigationToggle(props: {
}) {
const shell = useViewShell();
const [open, setOpen] = createSignal(false);
+ // CRM collapses its own sidebar, so its toggle stands in for the shell's.
+ const toggleTarget = tourTarget(VIEW_SHELL_TOUR.sidebarToggle);
return (
<Show when={shell.aside.isCollapsed()}>
<Show
@@ -62,6 +66,7 @@ function NavigationToggle(props: {
variant="ghost"
size="icon-sm"
label="Expand CRM sidebar"
+ ref={toggleTarget}
onClick={props.onExpand}
>
<ListIcon class="size-4" />
@@ -77,6 +82,7 @@ function NavigationToggle(props: {
depth={isTouchDevice() ? 3 : undefined}
class="touch:island touch:pointer-events-auto touch:size-10 touch:shrink-0 touch:bg-chrome"
aria-label="Show CRM navigation"
+ ref={toggleTarget}
>
<ListIcon class="size-4 touch:size-6" />
</Dropdown.Trigger>
diff --git a/apps/web/src/features/drive-view/drive-view.tsx b/apps/web/src/features/drive-view/drive-view.tsx
index 7b9458c338..e394f9c43a 100644
--- a/apps/web/src/features/drive-view/drive-view.tsx
+++ b/apps/web/src/features/drive-view/drive-view.tsx
@@ -5,6 +5,7 @@ import {
type FacetSelection,
useSoupListNavigationHotkeys,
} from '@app/features/soup';
+import { ViewTour } from '@app/features/tours/ViewTour';
import { useGlobalNotificationSource } from '@components/app/GlobalAppState';
import {
useSplitPanelOrThrow,
@@ -34,6 +35,7 @@ import {
import { createDriveState } from './primitives/drive-state';
import { createDriveDataSource } from './queries/drive-data-source';
import { createDriveSidebarSource } from './queries/drive-sidebar-source';
+import { documentsTour } from './tour';
import { DriveLoading, DriveWorkspace } from './views/drive-workspace';
export type DriveViewProps = { initialFacets?: FacetSelection };
@@ -161,7 +163,7 @@ function DriveComposition(props: { route: DriveRouteState }) {
actions,
}}
>
- <DriveWorkspace />
+ <DriveWorkspace tour={<ViewTour tour={documentsTour} />} />
</DriveProvider>
);
}
diff --git a/apps/web/src/features/drive-view/tour.ts b/apps/web/src/features/drive-view/tour.ts
new file mode 100644
index 0000000000..50db495cb2
--- /dev/null
+++ b/apps/web/src/features/drive-view/tour.ts
@@ -0,0 +1,31 @@
+import { VIEW_SHELL_TOUR } from '@app/components/view-shell/tour';
+import { defineViewTour } from '@app/features/tours/core/view-tour';
+
+export const documentsTour = defineViewTour({
+ id: 'documents',
+ title: 'Documents',
+ connector: { kind: 'mcp', label: 'Notion', tools: ['Notion'] },
+ video: { youtubeId: 'V8wE8Hq5_qw', title: 'Macro Docs', duration: '1:09' },
+ steps: [
+ {
+ target: VIEW_SHELL_TOUR.aside,
+ entry: VIEW_SHELL_TOUR.sidebarToggle,
+ entryLabel: 'Show the Documents sidebar to continue',
+ title: 'A place for your ideas',
+ description:
+ 'Create a document or bring your existing files into Macro. Search and filter to find them again.',
+ },
+ {
+ target: VIEW_SHELL_TOUR.main,
+ title: 'Connect the context',
+ description:
+ 'In a document, type @ to mention people or link related work.',
+ },
+ {
+ target: VIEW_SHELL_TOUR.topBar,
+ title: 'Think together',
+ description:
+ 'Share a document and use comments to keep feedback close to the work.',
+ },
+ ],
+});
diff --git a/apps/web/src/features/drive-view/views/drive-workspace.tsx b/apps/web/src/features/drive-view/views/drive-workspace.tsx
index 3da3e5d469..8db6a1a82d 100644
--- a/apps/web/src/features/drive-view/views/drive-workspace.tsx
+++ b/apps/web/src/features/drive-view/views/drive-workspace.tsx
@@ -3,7 +3,7 @@ import { SplitRouter } from '@app/split-router';
import { useSplitPanelOrThrow } from '@components/app/split-layout/layoutUtils';
import { SplitPanel } from '@components/app/split-panel';
import SpinnerIcon from '@phosphor/spinner.svg';
-import { createMemo, Show, Suspense } from 'solid-js';
+import { createMemo, type JSX, Show, Suspense } from 'solid-js';
import { DriveFileDropzone } from '../components/drive-file-dropzone';
import { useDriveView } from '../context/drive-context';
import { driveLocationBreadcrumbs } from '../core/breadcrumbs';
@@ -22,7 +22,7 @@ export function DriveLoading() {
);
}
-export function DriveWorkspace() {
+export function DriveWorkspace(props: { tour?: JSX.Element }) {
const { state, sidebar, actions } = useDriveView();
const breadcrumbs = createMemo(() =>
@@ -67,6 +67,7 @@ export function DriveWorkspace() {
fallback={
<>
<DriveHeader />
+ {props.tour}
<ViewShell.Content>
<Suspense fallback={<DriveLoading />}>
<DriveFileDropzone onDrop={actions.dropFiles}>
diff --git a/apps/web/src/features/email-view/components/EmailHeader.tsx b/apps/web/src/features/email-view/components/EmailHeader.tsx
index 4ac368292f..9572f6fc44 100644
--- a/apps/web/src/features/email-view/components/EmailHeader.tsx
+++ b/apps/web/src/features/email-view/components/EmailHeader.tsx
@@ -7,10 +7,12 @@ import {
import { SidebarCreateButton } from '@app/components/view-shell/SidebarCreateButton';
import { useSplitLayout } from '@components/app/split-layout/layout';
import { useSplitPanelOrThrow } from '@components/app/split-layout/layoutUtils';
+import { tourTarget } from '@ui/components/Tour';
import { createSignal, Show } from 'solid-js';
import { composeEmail } from '../compose-email';
import { EMAIL_TABS } from '../constants';
import { useEmailView } from '../email-view-context';
+import { EMAIL_TOUR } from '../tour';
import { EmailControls } from './EmailControls';
import { EmailInboxFilter, EmailInboxMenu } from './EmailInboxSelector';
@@ -63,6 +65,7 @@ export function EmailHeader(props: EmailHeaderProps) {
const { state, setState } = useEmailView();
const [filterOpen, setFilterOpen] = createSignal(false);
let searchInput: HTMLInputElement | undefined;
+ const searchTarget = tourTarget(EMAIL_TOUR.search);
const selectedTabLabel = () =>
EMAIL_TABS.find((tab) => tab.id === state.tab)?.label ?? 'Email';
@@ -110,7 +113,10 @@ export function EmailHeader(props: EmailHeaderProps) {
<Show when={state.tab !== 'scheduled'}>
<div class="flex min-w-0 items-center justify-between gap-3">
<SearchBar
- ref={(element) => (searchInput = element)}
+ ref={(element) => {
+ searchInput = element;
+ searchTarget(element);
+ }}
label="Search email"
value={state.search}
hotkey="cmd+f"
diff --git a/apps/web/src/features/email-view/components/EmailList.tsx b/apps/web/src/features/email-view/components/EmailList.tsx
index 03dc368d32..8b02f5d542 100644
--- a/apps/web/src/features/email-view/components/EmailList.tsx
+++ b/apps/web/src/features/email-view/components/EmailList.tsx
@@ -30,6 +30,7 @@ import CheckIcon from '@phosphor/check.svg';
import SpinnerIcon from '@phosphor/spinner.svg';
import { createElementSize } from '@solid-primitives/resize-observer';
import { Button, cn } from '@ui';
+import { tourTarget } from '@ui/components/Tour';
import {
createEffect,
createMemo,
@@ -57,6 +58,7 @@ import {
} from '../persistence';
import { createEmailRowActionState } from '../primitives/row-action-state';
import type { EmailDataSourceItem } from '../queries/use-email-query';
+import { EMAIL_TOUR } from '../tour';
import { useEmailListHotkeys } from '../use-email-list-hotkeys';
import { EmailDateGroupHeader } from './EmailDateGroupHeader';
import { EmailEmptyState } from './EmailEmptyState';
@@ -413,11 +415,13 @@ export function EmailList(props: EmailListProps) {
}
}
+ const listTarget = tourTarget(EMAIL_TOUR.list);
return (
<MaybeSoupEntityActionDrawerManager>
<div
ref={(element: HTMLDivElement) => {
setGrid(element);
+ listTarget(element);
props.ref?.(element);
}}
role="grid"
diff --git a/apps/web/src/features/email-view/components/EmailSidebar.tsx b/apps/web/src/features/email-view/components/EmailSidebar.tsx
index 9501891380..f55ef7546a 100644
--- a/apps/web/src/features/email-view/components/EmailSidebar.tsx
+++ b/apps/web/src/features/email-view/components/EmailSidebar.tsx
@@ -14,11 +14,13 @@ import SignalIcon from '@phosphor/wave-sine.svg';
import NoiseIcon from '@phosphor/waveform.svg';
import { SidebarTagsSection } from '@property/tags/SidebarTagsSection';
import { pressHandlers } from '@ui';
+import { tourTarget } from '@ui/components/Tour';
import { type Component, For, Show } from 'solid-js';
import { Dynamic } from 'solid-js/web';
import { composeEmail } from '../compose-email';
import { EMAIL_TAB_IDS, EMAIL_TABS, type EmailTabItem } from '../constants';
import { useEmailView } from '../email-view-context';
+import { EMAIL_TOUR } from '../tour';
import type { EmailTab } from '../types';
import { EmailInboxList } from './EmailInboxSelector';
@@ -56,7 +58,15 @@ function Tab(props: { item: EmailTabItem; onNavigate?: () => void }) {
export function EmailNavigation(props: { onNavigate?: () => void }) {
return (
<ViewSidebar.Nav aria-label="Email tabs">
- <For each={EMAIL_TABS}>
+ <div
+ ref={tourTarget(EMAIL_TOUR.signalNoise)}
+ class="flex flex-col gap-(--sidebar-row-gap)"
+ >
+ <For each={EMAIL_TABS.slice(0, 2)}>
+ {(item) => <Tab item={item} onNavigate={props.onNavigate} />}
+ </For>
+ </div>
+ <For each={EMAIL_TABS.slice(2)}>
{(item) => <Tab item={item} onNavigate={props.onNavigate} />}
</For>
</ViewSidebar.Nav>
@@ -103,12 +113,14 @@ export function EmailSidebar() {
<EmailNavigation />
- <SidebarTagsSection
- activeIds={state.facets.tags ?? []}
- onActiveIdsChange={showTags}
- open={isSidebarSectionOpen('tags')}
- onOpenChange={(open) => setSidebarSectionOpen('tags', open)}
- />
+ <div ref={tourTarget(EMAIL_TOUR.tags)}>
+ <SidebarTagsSection
+ activeIds={state.facets.tags ?? []}
+ onActiveIdsChange={showTags}
+ open={isSidebarSectionOpen('tags')}
+ onOpenChange={(open) => setSidebarSectionOpen('tags', open)}
+ />
+ </div>
</ViewSidebar.Content>
</ViewSidebar.Root>
);
diff --git a/apps/web/src/features/email-view/email-view.tsx b/apps/web/src/features/email-view/email-view.tsx
index c9eadb2588..1f4a081909 100644
--- a/apps/web/src/features/email-view/email-view.tsx
+++ b/apps/web/src/features/email-view/email-view.tsx
@@ -1,4 +1,5 @@
import { ViewBreadcrumbs, ViewShell } from '@app/components/view-shell';
+import { ViewTour } from '@app/features/tours/ViewTour';
import { SplitRouter } from '@app/lib/split-router';
import { type PillTabItem, PillTabs } from '@components/app/mobile/PillTabs';
import { SplitHeaderLeft } from '@components/app/split-layout/components/SplitHeader';
@@ -25,6 +26,7 @@ import { EmailList } from './components/EmailList';
import { EmailSidebar } from './components/EmailSidebar';
import { EMAIL_TABS } from './constants';
import { EmailViewProvider, useEmailView } from './email-view-context';
+import { emailTour } from './tour';
import type { EmailTab, EmailViewStateOptions } from './types';
export type EmailViewProps = {
@@ -69,6 +71,7 @@ function EmailDesktopLayout(
<ViewShell.Header>
<EmailHeader onSearchEscape={props.onSearchEscape} />
</ViewShell.Header>
+ <ViewTour tour={emailTour} />
<ViewShell.Content>{props.children}</ViewShell.Content>
</>
);
diff --git a/apps/web/src/features/email-view/tour.ts b/apps/web/src/features/email-view/tour.ts
new file mode 100644
index 0000000000..ee98304ba7
--- /dev/null
+++ b/apps/web/src/features/email-view/tour.ts
@@ -0,0 +1,41 @@
+import { VIEW_SHELL_TOUR } from '@app/components/view-shell/tour';
+import { defineViewTour } from '@app/features/tours/core/view-tour';
+import { defineTourTargets } from '@ui/components/Tour';
+
+export const EMAIL_TOUR = defineTourTargets('email', [
+ 'signalNoise',
+ 'tags',
+ 'list',
+ 'search',
+]);
+
+export const emailTour = defineViewTour({
+ id: 'mail',
+ title: 'Email',
+ connector: { kind: 'email', label: 'Google' },
+ video: { youtubeId: 'tnsxkywzTvY', title: 'Macro Mail', duration: '1:24' },
+ steps: [
+ {
+ target: EMAIL_TOUR.signalNoise,
+ entry: VIEW_SHELL_TOUR.sidebarToggle,
+ entryLabel: 'Show the email sidebar to continue',
+ title: 'Find the signal in your inbox',
+ description:
+ 'Signal keeps important conversations in focus. Noise gives lower-priority mail its own space, so you can catch up when it suits you.',
+ },
+ {
+ target: EMAIL_TOUR.tags,
+ entry: VIEW_SHELL_TOUR.sidebarToggle,
+ entryLabel: 'Show the email sidebar to continue',
+ title: 'Organize email your way',
+ description:
+ 'Create tags for projects, customers, or anything you track. Apply them manually, ask an agent to tag matching email, or set up an automation to keep it organized. Choose a tag here to see its messages.',
+ },
+ {
+ target: [EMAIL_TOUR.list, EMAIL_TOUR.search],
+ title: 'Move faster with shortcuts',
+ description:
+ 'Select messages and press ⌘K (Ctrl+K on Windows) to see available actions and their shortcuts. Use ⌘F / Ctrl+F to search email, and Escape to clear your selection.',
+ },
+ ],
+});
diff --git a/apps/web/src/features/home/components/HomeFilters.tsx b/apps/web/src/features/home/components/HomeFilters.tsx
index 93f19b511f..9b23f41a7f 100644
--- a/apps/web/src/features/home/components/HomeFilters.tsx
+++ b/apps/web/src/features/home/components/HomeFilters.tsx
@@ -10,10 +10,12 @@ import { Accordion } from '@kobalte/core/accordion';
import BellSimpleIcon from '@phosphor/bell-simple.svg';
import FilterIcon from '@phosphor/funnel-simple.svg';
import { Dropdown } from '@ui';
+import { tourTarget } from '@ui/components/Tour';
import { createMemo, createSignal, For, type JSX, Show } from 'solid-js';
import { selectedHomeTypes, setHomeTypeSelected } from '../core/type-selection';
import { HOME_TYPE_FILTER_GROUPS } from '../home-facets';
import { useHomeView } from '../home-view-context';
+import { HOME_TOUR } from '../tour';
const FILTER_ICONS = new Map<string, () => JSX.Element>([
[
@@ -228,6 +230,7 @@ export function HomeFilterDropdown() {
label="Filter Home"
customTrigger={
<Dropdown.Trigger
+ ref={tourTarget(HOME_TOUR.filter)}
variant="ghost"
size="sm"
square
diff --git a/apps/web/src/features/home/components/HomeListLayout.tsx b/apps/web/src/features/home/components/HomeListLayout.tsx
index d2707aa5f1..fba961a4a0 100644
--- a/apps/web/src/features/home/components/HomeListLayout.tsx
+++ b/apps/web/src/features/home/components/HomeListLayout.tsx
@@ -1,7 +1,9 @@
import { SidebarCreateHeader } from '@app/components/view-shell/SidebarCreateButton';
import { MobileTopEdgeFade } from '@components/app/mobile/MobileEdgeFade';
import { isTouchDevice } from '@core/mobile/isTouchDevice';
+import { tourTarget } from '@ui/components/Tour';
import { type JSX, type ParentProps, Show } from 'solid-js';
+import { HOME_TOUR } from '../tour';
import { HomeFilterDropdown } from './HomeFilters';
function MobileHomeHeader(props: ParentProps) {
@@ -20,6 +22,7 @@ export function HomeListLayout(
) {
return (
<div
+ ref={tourTarget(HOME_TOUR.list)}
class="relative flex size-full min-h-0 min-w-0 flex-col"
style={{
'--mobile-content-inset-top': 'calc(var(--safe-top, 0px) + 3.75rem)',
diff --git a/apps/web/src/features/home/home-view.tsx b/apps/web/src/features/home/home-view.tsx
index 4b1478eaf0..789c114c6f 100644
--- a/apps/web/src/features/home/home-view.tsx
+++ b/apps/web/src/features/home/home-view.tsx
@@ -1,6 +1,7 @@
import { useViewShell, ViewShell } from '@app/components/view-shell';
import { calendarSearch } from '@app/features/calendar-view/calendar-url';
import { CalendarView } from '@app/features/calendar-view/calendar-view';
+import { ViewTour } from '@app/features/tours/ViewTour';
import { createSearchParams, SplitRouter } from '@app/lib/split-router';
import { DebugSuspense } from '@channel/DebugSuspense';
import { useGlobalBlockOrchestrator } from '@components/app/GlobalAppState';
@@ -20,6 +21,7 @@ import { HomeReturnBreadcrumb } from './components/HomeReturnBreadcrumb';
import { HomeTabs } from './components/HomeTabs';
import { HomeViewProvider, useHomeView } from './home-view-context';
import { homeCalendarRoute } from './route';
+import { homeTour } from './tour';
import type { HomeViewStateOptions } from './types';
export type HomeViewProps = {
@@ -60,6 +62,7 @@ function HomeListPane(props: {
showContent();
}}
>
+ <ViewTour tour={homeTour} />
<DebugSuspense name="HomeView.list" fallback={<HomeFallback />}>
<HomeList
hasPreview={props.hasPreview}
diff --git a/apps/web/src/features/home/tour.ts b/apps/web/src/features/home/tour.ts
new file mode 100644
index 0000000000..e162d9f5a1
--- /dev/null
+++ b/apps/web/src/features/home/tour.ts
@@ -0,0 +1,39 @@
+import { VIEW_SHELL_TOUR } from '@app/components/view-shell/tour';
+import { defineViewTour } from '@app/features/tours/core/view-tour';
+import { defineTourTargets } from '@ui/components/Tour';
+
+export const HOME_TOUR = defineTourTargets('home', ['list', 'filter']);
+
+export const homeTour = defineViewTour({
+ id: 'home',
+ title: 'Home',
+ video: {
+ youtubeId: 'Fn5hdzXsQQ8',
+ title: 'Macro Product Demo',
+ duration: '4:45',
+ },
+ steps: [
+ {
+ target: HOME_TOUR.list,
+ entry: VIEW_SHELL_TOUR.sidebarToggle,
+ entryLabel: 'Show your Home list to continue',
+ title: 'See your work together',
+ description:
+ 'Home brings docs, DMs, emails, tasks, files, agents, and group chats into one place.',
+ },
+ {
+ target: HOME_TOUR.filter,
+ entry: VIEW_SHELL_TOUR.sidebarToggle,
+ entryLabel: 'Show your Home list to continue',
+ title: 'Open the context',
+ description:
+ 'Select an item to preview it beside your list. Use the filter to narrow what you see.',
+ },
+ {
+ target: VIEW_SHELL_TOUR.main,
+ title: 'Start something new',
+ description:
+ 'Choose New chat to work with an agent, or use Create in the sidebar to start a document, task, or conversation.',
+ },
+ ],
+});
diff --git a/apps/web/src/features/next-soup/route.tsx b/apps/web/src/features/next-soup/route.tsx
index 18ecb696a4..88a2265ffa 100644
--- a/apps/web/src/features/next-soup/route.tsx
+++ b/apps/web/src/features/next-soup/route.tsx
@@ -1,3 +1,4 @@
+import { ViewTour } from '@app/features/tours/ViewTour';
import { usePosthog } from '@app/lib/analytics/posthog';
import { defineRoute } from '@app/lib/split-router';
import { useSplitPanelOrThrow } from '@components/app/split-layout/layoutUtils';
@@ -11,6 +12,7 @@ import { lazy, Show } from 'solid-js';
import type { SetPredicatesInput } from './filters/filter-store/predicates-store';
import type { Query } from './filters/filter-store/types';
import { getViewPreset } from './sidebar/soup-filter-presets';
+import { callsTour, foldersTour } from './tour';
import { useRecentViewFlag } from './use-recent-view-flag';
const SoupView = lazy(async () => ({
@@ -57,6 +59,7 @@ export const CallsRouteView = withAuth(() => {
initialFilters={preset?.filters}
initialClientFilters={preset?.clientFilters}
initialGroupBy={preset?.groupBy}
+ tour={<ViewTour tour={callsTour} />}
/>
);
});
@@ -74,6 +77,7 @@ export const FoldersRouteView = withAuth(() => {
initialFilters={preset?.filters}
initialClientFilters={preset?.clientFilters}
initialGroupBy={preset?.groupBy}
+ tour={<ViewTour tour={foldersTour} />}
/>
);
});
diff --git a/apps/web/src/features/next-soup/soup-view/soup-view.tsx b/apps/web/src/features/next-soup/soup-view/soup-view.tsx
index 18f98dfce2..95fa292046 100644
--- a/apps/web/src/features/next-soup/soup-view/soup-view.tsx
+++ b/apps/web/src/features/next-soup/soup-view/soup-view.tsx
@@ -109,6 +109,7 @@ import Spinner from '@phosphor/spinner.svg';
import { createElementSize } from '@solid-primitives/resize-observer';
import { debounce } from '@solid-primitives/scheduled';
import { Button, cn, Layer, Tooltip } from '@ui';
+import { tourTarget } from '@ui/components/Tour';
import {
type Accessor,
batch,
@@ -127,6 +128,7 @@ import {
import { Dynamic } from 'solid-js/web';
import { Virtualizer, type VirtualizerHandle } from 'virtua/solid';
import type { CacheSnapshot } from 'virtua/unstable_core';
+import { SOUP_TOUR } from '../tour';
import { SearchAskAiButton } from './search-ask-ai-button';
import { SoupEntitySelectionToolbar } from './soup-entity-selection-toolbar';
import { useSoupNavigationHotkeys } from './use-soup-navigation-hotkeys';
@@ -275,6 +277,8 @@ interface SoupViewProps {
* When set, its pieces win over persisted/preset state during init.
*/
initialCrmView?: CrmViewConfig;
+ /** The view's tour, e.g. `<ViewTour tour={callsTour} />`. */
+ tour?: JSX.Element;
}
export const SoupView = (props: SoupViewProps) => {
@@ -639,6 +643,7 @@ export const SoupView = (props: SoupViewProps) => {
</div>
<SoupFiltersBar variant={props.filterBarVariant} />
</Show>
+ {props.tour}
<Show when={soupView.source.cachedMail?.()}>
<p role="status" class="px-4 py-1 text-xs text-ink-muted">
Showing cached mail. Only synchronized messages are available.
@@ -1225,6 +1230,7 @@ const SoupViewListContent = (props: SoupViewListProps) => {
};
const featuredCount = createMemo(() => featuredIds().length);
+ const listTarget = tourTarget(SOUP_TOUR.list);
return (
<MaybeSoupEntityActionDrawerManager>
@@ -1232,6 +1238,7 @@ const SoupViewListContent = (props: SoupViewListProps) => {
class="size-full"
ref={(el) => {
setSoupViewRef(el);
+ listTarget(el);
attachHotkeys(el);
}}
tabIndex={-1}
diff --git a/apps/web/src/features/next-soup/tour.ts b/apps/web/src/features/next-soup/tour.ts
new file mode 100644
index 0000000000..47633a0129
--- /dev/null
+++ b/apps/web/src/features/next-soup/tour.ts
@@ -0,0 +1,59 @@
+import { VIEW_SHELL_TOUR } from '@app/components/view-shell/tour';
+import { defineViewTour } from '@app/features/tours/core/view-tour';
+import { defineTourTargets } from '@ui/components/Tour';
+
+/** Parts of the shared list view that tours can point at. */
+export const SOUP_TOUR = defineTourTargets('soup', ['list']);
+
+export const callsTour = defineViewTour({
+ id: 'calls',
+ title: 'Calls',
+ video: { youtubeId: 'MMG00RA7kU0', title: 'Macro Calls', duration: '1:15' },
+ steps: [
+ {
+ target: SOUP_TOUR.list,
+ title: 'Pick up the conversation',
+ description:
+ 'Find your recent calls here, alongside the work they relate to.',
+ },
+ {
+ target: VIEW_SHELL_TOUR.main,
+ title: 'Revisit the details',
+ description:
+ 'Open a call to review its available transcript and catch up on what was discussed.',
+ },
+ {
+ target: VIEW_SHELL_TOUR.aside,
+ entry: VIEW_SHELL_TOUR.sidebarToggle,
+ entryLabel: 'Show the sidebar to continue',
+ title: 'Keep momentum',
+ description:
+ 'Bring decisions back into your documents, tasks, and team conversations.',
+ },
+ ],
+});
+
+export const foldersTour = defineViewTour({
+ id: 'folders',
+ title: 'Folders',
+ steps: [
+ {
+ target: [VIEW_SHELL_TOUR.aside, SOUP_TOUR.list],
+ title: 'Give a project a home',
+ description:
+ 'Group related work in a folder so it’s easy to find and return to.',
+ },
+ {
+ target: VIEW_SHELL_TOUR.main,
+ title: 'Bring the pieces together',
+ description:
+ 'Move items into folders and open them without losing the surrounding context.',
+ },
+ {
+ target: VIEW_SHELL_TOUR.topBar,
+ title: 'Find what you need',
+ description:
+ 'Use search and filters to narrow down the items in your workspace.',
+ },
+ ],
+});
diff --git a/apps/web/src/features/settings/components/agent-management-navigation.tsx b/apps/web/src/features/settings/components/agent-management-navigation.tsx
index a9f6ec59f6..3420a3db5d 100644
--- a/apps/web/src/features/settings/components/agent-management-navigation.tsx
+++ b/apps/web/src/features/settings/components/agent-management-navigation.tsx
@@ -1,5 +1,7 @@
+import { AGENTS_TOUR } from '@app/features/agents-view/tour';
import HardDrivesIcon from '@phosphor/hard-drives.svg';
import SparkleIcon from '@phosphor/sparkle.svg';
+import { tourTarget } from '@ui/components/Tour';
export type AgentManagementSection = 'agents' | 'runtimes';
@@ -8,6 +10,8 @@ export function AgentManagementNavigation(props: {
section: AgentManagementSection;
onChange: (section: AgentManagementSection) => void;
}) {
+ const agentsTab = tourTarget(AGENTS_TOUR.agentsTab);
+ const runtimesTab = tourTarget(AGENTS_TOUR.runtimesTab);
return (
<nav
aria-label="Agent management"
@@ -15,6 +19,7 @@ export function AgentManagementNavigation(props: {
>
<button
type="button"
+ ref={agentsTab}
aria-current={props.section === 'agents' ? 'page' : undefined}
onClick={() => props.onChange('agents')}
class="flex items-center gap-2 border-b-2 border-transparent px-4 py-3 text-sm text-ink-muted aria-[current=page]:border-accent aria-[current=page]:text-ink hover:text-ink focus-visible:outline-accent"
@@ -23,6 +28,7 @@ export function AgentManagementNavigation(props: {
</button>
<button
type="button"
+ ref={runtimesTab}
aria-current={props.section === 'runtimes' ? 'page' : undefined}
onClick={() => props.onChange('runtimes')}
class="flex items-center gap-2 border-b-2 border-transparent px-4 py-3 text-sm text-ink-muted aria-[current=page]:border-accent aria-[current=page]:text-ink hover:text-ink focus-visible:outline-accent"
diff --git a/apps/web/src/features/setup/core/connectedTools.ts b/apps/web/src/features/setup/core/connectedTools.ts
new file mode 100644
index 0000000000..aded45e804
--- /dev/null
+++ b/apps/web/src/features/setup/core/connectedTools.ts
@@ -0,0 +1,25 @@
+type PipedreamConnection = { server_name: string };
+type NativeServer = { server_name: string; authenticated: boolean };
+
+/**
+ * Whether the named MCP tool is connected. Mirrors the backend's
+ * stack-selection rule (`mcp_select`): a user with any Pipedream connectors is
+ * served those, so native rows stop counting.
+ */
+export function isMcpToolConnected(
+ name: string,
+ sources: {
+ pipedream: readonly PipedreamConnection[];
+ native: readonly NativeServer[];
+ }
+) {
+ const wanted = name.toLowerCase();
+ if (sources.pipedream.length > 0)
+ return sources.pipedream.some(
+ (connection) => connection.server_name.toLowerCase() === wanted
+ );
+ return sources.native.some(
+ (server) =>
+ server.authenticated && server.server_name.toLowerCase() === wanted
+ );
+}
diff --git a/apps/web/src/features/setup/flow/OnboardingFlow.tsx b/apps/web/src/features/setup/flow/OnboardingFlow.tsx
index 0b0413a0cd..624f464ca1 100644
--- a/apps/web/src/features/setup/flow/OnboardingFlow.tsx
+++ b/apps/web/src/features/setup/flow/OnboardingFlow.tsx
@@ -27,6 +27,7 @@ import {
Show,
Suspense,
} from 'solid-js';
+import { isMcpToolConnected } from '../core/connectedTools';
import type { ModuleLogo, ModuleState } from '../Module';
import { MODULE_LOGOS } from '../moduleLogos';
import { BrandHandoff, type BrandHandoffSource } from './BrandHandoff';
@@ -289,20 +290,11 @@ function FlowContent() {
// Live connection state, derived from the flow's queries (no standing
// bookkeeping): whether an MCP server authenticated, and which tools the
// user connected. Drives the hero-module states and the build phrases.
- // Mirrors the backend's stack-selection rule (`mcp_select`): a user with
- // any Pipedream connectors is served those, so native rows stop counting.
- const serverAuthed = (name: string) => {
- const pipedream = pipedreamQuery.data ?? [];
- if (pipedream.length > 0) {
- return pipedream.some(
- (connection) =>
- connection.server_name.toLowerCase() === name.toLowerCase()
- );
- }
- return (serversQuery.data ?? []).some(
- (server) => server.server_name === name && server.authenticated
- );
- };
+ const serverAuthed = (name: string) =>
+ isMcpToolConnected(name, {
+ pipedream: pipedreamQuery.data ?? [],
+ native: serversQuery.data ?? [],
+ });
const connectedTools = (): ConnectedTools => ({
google: (linksQuery.data?.links.length ?? 0) > 0,
linear: serverAuthed('Linear'),
diff --git a/apps/web/src/features/tasks-view/components/TasksSidebar.tsx b/apps/web/src/features/tasks-view/components/TasksSidebar.tsx
index 12b4eb58af..91dac8403d 100644
--- a/apps/web/src/features/tasks-view/components/TasksSidebar.tsx
+++ b/apps/web/src/features/tasks-view/components/TasksSidebar.tsx
@@ -25,9 +25,11 @@ import StackIcon from '@phosphor/stack.svg';
import { SidebarTagsSection } from '@property/tags/SidebarTagsSection';
import { useFavoritesData } from '@queries/favorites/favorites';
import type { Favorite } from '@service-storage/generated/schemas/favorite';
+import { tourTarget } from '@ui/components/Tour';
import { createMemo, For, Show } from 'solid-js';
import { Dynamic } from 'solid-js/web';
import { useTasksView } from '../tasks-view-context';
+import { TASKS_TOUR } from '../tour';
import type { TasksTab } from '../types';
const TASK_NAV_ITEMS = [
@@ -212,12 +214,16 @@ export function TasksSidebar() {
open={isSidebarSectionOpen('favorites')}
onOpenChange={(open) => setSidebarSectionOpen('favorites', open)}
/>
- <SidebarTagsSection
- activeIds={state.facets.tags ?? []}
- onActiveIdsChange={(ids) => setFacets({ ...state.facets, tags: ids })}
- open={isSidebarSectionOpen('tags')}
- onOpenChange={(open) => setSidebarSectionOpen('tags', open)}
- />
+ <div ref={tourTarget(TASKS_TOUR.tags)}>
+ <SidebarTagsSection
+ activeIds={state.facets.tags ?? []}
+ onActiveIdsChange={(ids) =>
+ setFacets({ ...state.facets, tags: ids })
+ }
+ open={isSidebarSectionOpen('tags')}
+ onOpenChange={(open) => setSidebarSectionOpen('tags', open)}
+ />
+ </div>
</ViewSidebar.Content>
</ViewSidebar.Root>
);
diff --git a/apps/web/src/features/tasks-view/tasks-view.tsx b/apps/web/src/features/tasks-view/tasks-view.tsx
index a65b93168f..d0e90bb3e2 100644
--- a/apps/web/src/features/tasks-view/tasks-view.tsx
+++ b/apps/web/src/features/tasks-view/tasks-view.tsx
@@ -1,6 +1,7 @@
import { ViewBreadcrumbs, ViewShell } from '@app/components/view-shell';
import { openProject } from '@app/features/projects/open-project';
import { ProjectsTab } from '@app/features/projects/projects';
+import { ViewTour, ViewTourAction } from '@app/features/tours/ViewTour';
import { SplitRouter, useNavigate, useParams } from '@app/lib/split-router';
import { useSplitLayout } from '@components/app/split-layout/layout';
import { useSplitPanelOrThrow } from '@components/app/split-layout/layoutUtils';
@@ -24,6 +25,7 @@ import { TasksSidebar } from './components/TasksSidebar';
import { TaskList } from './components/task-list/TaskList';
import { projectDetailRoute } from './route';
import { TasksViewProvider, useTasksView } from './tasks-view-context';
+import { tasksTour } from './tour';
import type { TasksViewStateOptions } from './types';
export type TasksViewProps = {
@@ -76,6 +78,18 @@ function TasksViewBreadcrumbs(props: ParentProps) {
);
}
+/** The tasks tour's shortcut for bringing existing issues over. */
+function ImportLinearAction() {
+ const { openWithSplit } = useSplitLayout();
+ return (
+ <ViewTourAction
+ onClick={() => openWithSplit({ type: 'component', id: 'import-linear' })}
+ >
+ Import from Linear
+ </ViewTourAction>
+ );
+}
+
function TasksViewRoot() {
const panel = useSplitPanelOrThrow();
const { state, projectsEnabled } = useTasksView();
@@ -91,6 +105,7 @@ function TasksViewRoot() {
<ViewShell.Header>
<TasksHeader onSearchEscape={() => listElement()?.focus()} />
</ViewShell.Header>
+ <ViewTour tour={tasksTour} actions={<ImportLinearAction />} />
<ViewShell.Content>
<Suspense fallback={<TasksListFallback />}>
<TaskList ref={setListElement} />
diff --git a/apps/web/src/features/tasks-view/tour.ts b/apps/web/src/features/tasks-view/tour.ts
new file mode 100644
index 0000000000..bf114d96ed
--- /dev/null
+++ b/apps/web/src/features/tasks-view/tour.ts
@@ -0,0 +1,36 @@
+import { VIEW_SHELL_TOUR } from '@app/components/view-shell/tour';
+import { defineViewTour } from '@app/features/tours/core/view-tour';
+import { defineTourTargets } from '@ui/components/Tour';
+
+export const TASKS_TOUR = defineTourTargets('tasks', ['tags']);
+
+export const tasksTour = defineViewTour({
+ id: 'tasks',
+ title: 'Tasks',
+ connector: { kind: 'mcp', label: 'Linear', tools: ['Linear'] },
+ video: { youtubeId: 'gxJquVXRX5A', title: 'Macro Tasks', duration: '1:35' },
+ steps: [
+ {
+ target: VIEW_SHELL_TOUR.aside,
+ entry: VIEW_SHELL_TOUR.sidebarToggle,
+ entryLabel: 'Show the task sidebar to continue',
+ title: 'Turn plans into progress',
+ description:
+ 'Create a task with a clear next step, or connect Linear to bring your issues into Macro.',
+ },
+ {
+ target: VIEW_SHELL_TOUR.main,
+ title: 'Give work an owner',
+ description:
+ 'Open a task to set its assignee, due date, and status. Add context so the next step is clear.',
+ },
+ {
+ target: TASKS_TOUR.tags,
+ entry: VIEW_SHELL_TOUR.sidebarToggle,
+ entryLabel: 'Show the task sidebar to continue',
+ title: 'Keep tasks organized with tags',
+ description:
+ 'Tag tasks by project, team, or type of work. Create and manage tags here, then select a tag to narrow your task list to what matters now.',
+ },
+ ],
+});
diff --git a/apps/web/src/features/tours/ViewTour.test.tsx b/apps/web/src/features/tours/ViewTour.test.tsx
new file mode 100644
index 0000000000..726f8b5b7b
--- /dev/null
+++ b/apps/web/src/features/tours/ViewTour.test.tsx
@@ -0,0 +1,249 @@
+import { cleanup, fireEvent, render, screen } from '@solidjs/testing-library';
+import { defineTourTargets, tourTarget } from '@ui/components/Tour';
+import { createSignal } from 'solid-js';
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
+import { defineViewTour } from './core/view-tour';
+import { ViewTour, ViewTourAction } from './ViewTour';
+
+const wiring = vi.hoisted(() => ({
+ userId: 'tour-user',
+ settings: vi.fn(),
+ links: [] as unknown[],
+ native: [] as { server_name: string; authenticated: boolean }[],
+ pipedream: [] as { server_name: string }[],
+ queries: vi.fn(),
+}));
+
+const [desktop, setDesktop] = createSignal(true);
+vi.mock('@solid-primitives/media', () => ({ createMediaQuery: () => desktop }));
+const [flagOn, setFlagOn] = createSignal(true);
+vi.mock('@app/lib/analytics/posthog', () => ({
+ useFeatureFlag: () => () => ({ enabled: flagOn() }),
+}));
+vi.mock('@core/context/user', () => ({ useUserId: () => () => wiring.userId }));
+vi.mock('@core/constant/SettingsState', () => ({
+ useSettingsState: () => ({ openSettingsInSplit: wiring.settings }),
+}));
+vi.mock('@queries/email/link', () => ({
+ useEmailLinksQuery: () => {
+ wiring.queries('email');
+ return { isSuccess: true, data: { links: wiring.links } };
+ },
+}));
+vi.mock('@queries/mcp-servers', () => ({
+ useMcpServersQuery: () => {
+ wiring.queries('native');
+ return { isSuccess: true, data: wiring.native };
+ },
+}));
+vi.mock('@queries/pipedream-connectors', () => ({
+ usePipedreamConnectionsQuery: () => {
+ wiring.queries('pipedream');
+ return { isSuccess: true, data: wiring.pipedream };
+ },
+}));
+
+const steps = [
+ { title: 'First step', description: 'One' },
+ { title: 'Second step', description: 'Two' },
+];
+const plain = defineViewTour({ id: 'plain', title: 'Plain', steps });
+const withVideo = defineViewTour({
+ id: 'video',
+ title: 'Video',
+ video: { youtubeId: 'abc', title: 'Demo video', duration: '1:00' },
+ steps,
+});
+const linear = defineViewTour({
+ id: 'linear',
+ title: 'Linear',
+ connector: { kind: 'mcp', label: 'Linear', tools: ['Linear'] },
+ steps,
+});
+const key = (id: string) => `macro:tour:${id}:tour-user`;
+const saved = (id: string) =>
+ JSON.parse(localStorage.getItem(key(id)) ?? 'null');
+
+beforeEach(() => {
+ vi.stubEnv('DEV', false);
+ setDesktop(true);
+ setFlagOn(true);
+ localStorage.clear();
+ wiring.userId = 'tour-user';
+ wiring.links = [];
+ wiring.native = [];
+ wiring.pipedream = [];
+ vi.clearAllMocks();
+});
+afterEach(() => {
+ cleanup();
+ vi.unstubAllEnvs();
+ vi.unstubAllGlobals();
+});
+
+describe('ViewTour', () => {
+ it('renders nothing while the in-app tours flag is off', () => {
+ setFlagOn(false);
+ render(() => <ViewTour tour={withVideo} />);
+ expect(screen.queryByRole('dialog')).toBeNull();
+ setFlagOn(true);
+ expect(screen.getByRole('dialog')).toBeTruthy();
+ });
+
+ it('saves a dismissal per user and stays hidden afterwards', () => {
+ const view = render(() => <ViewTour tour={plain} />);
+ fireEvent.click(screen.getByRole('button', { name: 'Dismiss' }));
+ expect(screen.queryByRole('dialog')).toBeNull();
+ expect(saved('plain')).toEqual({ status: 'dismissed' });
+ view.unmount();
+ render(() => <ViewTour tour={plain} />);
+ expect(screen.queryByRole('dialog')).toBeNull();
+ });
+
+ it('completes and saves from the last step', () => {
+ render(() => <ViewTour tour={plain} />);
+ fireEvent.click(screen.getByRole('button', { name: 'Next' }));
+ expect(screen.getByRole('dialog', { name: 'Second step' })).toBeTruthy();
+ fireEvent.click(screen.getByRole('button', { name: 'Got it' }));
+ expect(saved('plain')).toEqual({ status: 'completed' });
+ });
+
+ it('resumes an unfinished tour at the last step reached', () => {
+ const view = render(() => <ViewTour tour={plain} />);
+ fireEvent.click(screen.getByRole('button', { name: 'Next' }));
+ expect(saved('plain')).toEqual({ status: 'active', step: 1 });
+ view.unmount();
+ render(() => <ViewTour tour={plain} />);
+ expect(screen.getByRole('dialog', { name: 'Second step' })).toBeTruthy();
+ });
+
+ it('starts fresh when saved progress is unreadable', () => {
+ localStorage.setItem(key('plain'), 'hidden');
+ render(() => <ViewTour tour={plain} />);
+ expect(screen.getByRole('dialog', { name: 'First step' })).toBeTruthy();
+ });
+
+ it('reopens on localhost without touching saved dismissals', () => {
+ vi.stubEnv('DEV', true);
+ vi.stubGlobal('location', { hostname: 'localhost' });
+ localStorage.setItem(key('plain'), JSON.stringify({ status: 'dismissed' }));
+ render(() => <ViewTour tour={plain} />);
+ expect(screen.getByRole('dialog')).toBeTruthy();
+ fireEvent.click(screen.getByRole('button', { name: 'Dismiss' }));
+ expect(saved('plain')).toEqual({ status: 'dismissed' });
+ });
+
+ it('unmounts off desktop without saving a dismissal', () => {
+ render(() => <ViewTour tour={withVideo} />);
+ fireEvent.click(screen.getByRole('button', { name: 'Watch Demo video' }));
+ expect(document.querySelector('iframe')).toBeTruthy();
+ setDesktop(false);
+ expect(screen.queryByRole('dialog')).toBeNull();
+ expect(document.querySelector('iframe')).toBeNull();
+ expect(localStorage.getItem(key('video'))).toBeNull();
+ setDesktop(true);
+ expect(screen.getByRole('dialog')).toBeTruthy();
+ });
+
+ it('closes the video from the × above it, with no YouTube link', () => {
+ render(() => <ViewTour tour={withVideo} />);
+ fireEvent.click(screen.getByRole('button', { name: 'Watch Demo video' }));
+ expect(document.querySelector('iframe')).toBeTruthy();
+ expect(screen.queryByRole('link', { name: /YouTube/ })).toBeNull();
+ fireEvent.click(screen.getByRole('button', { name: 'Close video' }));
+ expect(document.querySelector('iframe')).toBeNull();
+ });
+
+ it('runs connection queries only for tours with a connector', () => {
+ render(() => <ViewTour tour={plain} />);
+ expect(wiring.queries).not.toHaveBeenCalled();
+ });
+
+ it('offers the connector until it is linked, using the onboarding rule', () => {
+ const view = render(() => <ViewTour tour={linear} />);
+ fireEvent.click(screen.getByRole('button', { name: 'Connect Linear' }));
+ expect(wiring.settings).toHaveBeenCalledWith('Connected');
+ view.unmount();
+
+ // Pipedream connections win over native rows, as the backend serves them.
+ wiring.native = [{ server_name: 'Linear', authenticated: true }];
+ wiring.pipedream = [{ server_name: 'notion' }];
+ const second = render(() => <ViewTour tour={linear} />);
+ expect(screen.getByRole('button', { name: 'Connect Linear' })).toBeTruthy();
+ second.unmount();
+
+ wiring.pipedream = [{ server_name: 'linear' }];
+ render(() => <ViewTour tour={linear} />);
+ expect(screen.queryByRole('button', { name: 'Connect Linear' })).toBeNull();
+ });
+
+ it('renders extra actions', () => {
+ const onClick = vi.fn();
+ render(() => (
+ <ViewTour
+ tour={plain}
+ actions={<ViewTourAction onClick={onClick}>Import</ViewTourAction>}
+ />
+ ));
+ fireEvent.click(screen.getByRole('button', { name: 'Import' }));
+ expect(onClick).toHaveBeenCalledOnce();
+ });
+});
+
+describe('ViewTour waiting hint', () => {
+ const T = defineTourTargets('hint-test', ['entry', 'a', 'b', 'c']);
+ const waiting = defineViewTour({
+ id: 'waiting',
+ title: 'Waiting',
+ steps: [
+ {
+ target: T.a,
+ entry: T.entry,
+ entryLabel: 'Open the thing to continue',
+ title: 'A',
+ description: 'a',
+ },
+ {
+ target: T.b,
+ entry: T.entry,
+ entryLabel: 'Open the thing to continue',
+ title: 'B',
+ description: 'b',
+ },
+ {
+ target: T.c,
+ entry: T.entry,
+ entryLabel: 'Open the thing to continue',
+ title: 'C',
+ description: 'c',
+ },
+ { title: 'After', description: 'done waiting' },
+ ],
+ });
+
+ beforeEach(() => {
+ vi.spyOn(HTMLElement.prototype, 'getBoundingClientRect').mockReturnValue(
+ new DOMRect(10, 10, 100, 20)
+ );
+ });
+ afterEach(() => vi.restoreAllMocks());
+
+ it('shows the action to take, with Skip to move on', async () => {
+ render(() => (
+ <>
+ <button type="button" ref={tourTarget(T.entry)}>
+ Thing
+ </button>
+ <ViewTour tour={waiting} />
+ </>
+ ));
+ await Promise.resolve();
+ const hint = () => document.querySelector('[data-tour-hint]');
+ expect(hint()?.textContent).toContain('Open the thing to continue');
+ expect(hint()?.textContent).toContain('1 / 4');
+ expect(screen.queryByRole('button', { name: 'Dismiss' })).toBeNull();
+
+ fireEvent.click(screen.getByRole('button', { name: 'Skip' }));
+ expect(hint()?.textContent).toContain('2 / 4');
+ });
+});
diff --git a/apps/web/src/features/tours/ViewTour.tsx b/apps/web/src/features/tours/ViewTour.tsx
new file mode 100644
index 0000000000..8060f60696
--- /dev/null
+++ b/apps/web/src/features/tours/ViewTour.tsx
@@ -0,0 +1,270 @@
+import { VIEW_SHELL_TOUR } from '@app/components/view-shell/tour';
+import { isMcpToolConnected } from '@app/features/setup/core/connectedTools';
+import { useFeatureFlag } from '@app/lib/analytics/posthog';
+import { enableInAppTours } from '@core/constant/featureFlags';
+import { useSettingsState } from '@core/constant/SettingsState';
+import { useUserId } from '@core/context/user';
+import { createUserScopedStorage } from '@core/util/userScopedStorage';
+import { useEmailLinksQuery } from '@queries/email/link';
+import { useMcpServersQuery } from '@queries/mcp-servers';
+import { usePipedreamConnectionsQuery } from '@queries/pipedream-connectors';
+import { createMediaQuery } from '@solid-primitives/media';
+import { Button } from '@ui';
+import { Tour, useTour } from '@ui/components/Tour';
+import { createSignal, type JSX, Match, Show, Switch } from 'solid-js';
+import { ViewTourVideo } from './components/ViewTourVideo';
+import type {
+ ViewTourConnector,
+ ViewTour as ViewTourDefinition,
+ ViewTourStep,
+} from './core/view-tour';
+import './view-tour.css';
+
+/** Tours are a desktop affordance: wide viewports with a fine pointer. */
+const DESKTOP_QUERY = '(min-width: 768px) and (pointer: fine)';
+
+export type ViewTourProps = {
+ tour: ViewTourDefinition;
+ /** Extra calls to action shown under the step, e.g. an import shortcut. */
+ actions?: JSX.Element;
+};
+
+/**
+ * A view's automatic tour. Mount it once inside the view; it stays within
+ * the view's split, and its progress is saved per user on this browser.
+ */
+export function ViewTour(props: ViewTourProps) {
+ const userId = useUserId();
+ const desktop = createMediaQuery(DESKTOP_QUERY);
+ const flag = useFeatureFlag(enableInAppTours);
+ return (
+ <Show when={flag().enabled && desktop() && userId()} keyed>
+ {(id) => <DismissibleTour {...props} userId={id} />}
+ </Show>
+ );
+}
+
+const isLocalTesting = () =>
+ import.meta.env.DEV &&
+ ['localhost', '127.0.0.1', '[::1]'].includes(window.location.hostname);
+
+/**
+ * Saved per user and tour on this browser: finished or dismissed tours stay
+ * hidden, and an unfinished tour resumes at the step the user last reached.
+ */
+type TourProgress =
+ | { status: 'completed' | 'dismissed' }
+ | { status: 'active'; step: number };
+
+function readProgress(raw: string | null): TourProgress | undefined {
+ if (!raw) return undefined;
+ try {
+ const value = JSON.parse(raw) as Partial<TourProgress & { step: unknown }>;
+ if (value.status === 'completed' || value.status === 'dismissed')
+ return { status: value.status };
+ if (value.status === 'active' && typeof value.step === 'number')
+ return { status: 'active', step: value.step };
+ } catch {
+ // Unreadable progress starts the tour fresh.
+ }
+ return undefined;
+}
+
+function DismissibleTour(props: ViewTourProps & { userId: string }) {
+ const storage = createUserScopedStorage(`macro:tour:${props.tour.id}`);
+ // Localhost reopens tours from the start on every mount so they can be
+ // iterated on, and leaves saved progress alone.
+ const localTesting = isLocalTesting();
+ const saved = localTesting
+ ? undefined
+ : readProgress(storage.read(props.userId));
+ const [closed, setClosed] = createSignal(
+ saved?.status === 'completed' || saved?.status === 'dismissed'
+ );
+ const [step, setStep] = createSignal(
+ saved?.status === 'active'
+ ? Math.min(saved.step, props.tour.steps.length - 1)
+ : 0
+ );
+ const save = (progress: TourProgress) => {
+ if (!localTesting) storage.write(props.userId, JSON.stringify(progress));
+ };
+ const changeStep = (next: number) => {
+ setStep(next);
+ save({ status: 'active', step: next });
+ };
+ const close = (status: 'completed' | 'dismissed') => {
+ setClosed(true);
+ save({ status });
+ };
+
+ return (
+ <Show when={!closed()}>
+ <Tour.Root
+ steps={props.tour.steps}
+ step={step()}
+ onStepChange={changeStep}
+ onDismiss={() => close('dismissed')}
+ onComplete={() => close('completed')}
+ boundary={(root) => root.closest<HTMLElement>('[data-split-id]')}
+ // Most hidden targets live in the view's collapsed sidebar.
+ fallbackEntry={VIEW_SHELL_TOUR.sidebarToggle}
+ >
+ <Tour.Highlight class="view-tour-highlight" />
+ <Tour.Beacon />
+ <Tour.Hint class="view-tour-hint w-64 rounded-xl border border-edge bg-dialog p-3 text-ink">
+ <ViewTourHint tour={props.tour} />
+ </Tour.Hint>
+ <Tour.Popover class="view-tour-card w-80 overflow-y-auto rounded-2xl border border-edge bg-dialog p-5 text-ink">
+ <ViewTourCard tour={props.tour} actions={props.actions} />
+ </Tour.Popover>
+ </Tour.Root>
+ </Show>
+ );
+}
+
+/** What to do to continue, shown beside the beacon while a step waits. */
+function ViewTourHint(props: { tour: ViewTourDefinition }) {
+ const tour = useTour<ViewTourStep>();
+ return (
+ <>
+ <div class="flex items-center gap-2 text-xs text-ink-muted">
+ <p class="mr-auto font-medium">{props.tour.title}</p>
+ <Tour.Progress />
+ </div>
+ <p class="mt-1.5 text-sm leading-5">
+ {tour.current().entryLabel ?? `Continue with ${props.tour.title}`}
+ </p>
+ <div class="mt-3">
+ <Tour.Next variant="outline" size="md" doneLabel="Done">
+ Skip
+ </Tour.Next>
+ </div>
+ </>
+ );
+}
+
+function ViewTourCard(props: ViewTourProps) {
+ const tour = useTour<ViewTourStep>();
+ // Explain how to reach the feature when the tour can't point at it, or
+ // points at a stand-in because it isn't set up yet.
+ const missingHint = () =>
+ (tour.status() === 'floating' && tour.current().target) || tour.isFallback()
+ ? tour.current().missingHint
+ : undefined;
+
+ return (
+ <>
+ <div class="mb-5 flex items-center gap-1 text-ink-muted">
+ <p class="mr-auto text-xs font-medium">{props.tour.title}</p>
+ <Tour.Previous />
+ <Tour.Progress class="min-w-10 text-center text-xs" />
+ <Tour.Next disabled={tour.isLast()} />
+ </div>
+ <div aria-live="polite">
+ <Tour.Title class="text-lg font-medium tracking-tight" />
+ <Tour.Description class="mt-2 text-sm leading-6 text-ink-muted" />
+ </div>
+ <Show when={missingHint()}>
+ {(hint) => (
+ <p class="mt-3 text-xs leading-5 text-ink-extra-muted">{hint()}</p>
+ )}
+ </Show>
+ <div class="mt-4 flex flex-wrap gap-2 empty:hidden">
+ <Show when={props.tour.connector}>
+ {(connector) => <ConnectAction connector={connector()} />}
+ </Show>
+ {props.actions}
+ </div>
+ <div class="mt-5 flex items-center justify-end gap-2">
+ <Tour.Close variant="ghost" size="md">
+ Dismiss
+ </Tour.Close>
+ <Tour.Next variant="cta" size="md" doneLabel="Got it">
+ Next
+ </Tour.Next>
+ </div>
+ <Show when={props.tour.video} keyed>
+ {(video) => <ViewTourVideo video={video} />}
+ </Show>
+ </>
+ );
+}
+
+/** Offers the connector until it's linked. Queries run only when mounted. */
+function ConnectAction(props: { connector: ViewTourConnector }) {
+ const { openSettingsInSplit } = useSettingsState();
+ return (
+ <Switch>
+ <Match when={props.connector.kind === 'email'}>
+ <EmailConnectAction
+ label={props.connector.label}
+ onConnect={() => openSettingsInSplit('Email')}
+ />
+ </Match>
+ <Match when={props.connector.kind === 'mcp' && props.connector}>
+ {(connector) => (
+ <McpConnectAction
+ label={connector().label}
+ tools={connector().kind === 'mcp' ? connector().tools : []}
+ onConnect={() => openSettingsInSplit('Connected')}
+ />
+ )}
+ </Match>
+ </Switch>
+ );
+}
+
+function EmailConnectAction(props: { label: string; onConnect: () => void }) {
+ const links = useEmailLinksQuery();
+ // Unknown counts as connected so the button never flashes in.
+ const connected = () =>
+ !links.isSuccess || (links.data?.links.length ?? 0) > 0;
+ return (
+ <Show when={!connected()}>
+ <ConnectButton label={props.label} onClick={props.onConnect} />
+ </Show>
+ );
+}
+
+function McpConnectAction(props: {
+ label: string;
+ tools: readonly string[];
+ onConnect: () => void;
+}) {
+ const native = useMcpServersQuery({ neverSuspend: true });
+ const pipedream = usePipedreamConnectionsQuery({ neverSuspend: true });
+ const connected = () => {
+ if (!native.isSuccess || !pipedream.isSuccess) return true;
+ const sources = {
+ native: native.data ?? [],
+ pipedream: pipedream.data ?? [],
+ };
+ return props.tools.some((tool) => isMcpToolConnected(tool, sources));
+ };
+ return (
+ <Show when={!connected()}>
+ <ConnectButton label={props.label} onClick={props.onConnect} />
+ </Show>
+ );
+}
+
+function ConnectButton(props: { label: string; onClick: () => void }) {
+ return (
+ <Button variant="outline" size="sm" onClick={props.onClick}>
+ Connect {props.label}
+ </Button>
+ );
+}
+
+/** A call to action for `ViewTour`'s `actions` slot. */
+export function ViewTourAction(props: {
+ onClick: () => void;
+ children: JSX.Element;
+}) {
+ return (
+ <Button variant="outline" size="sm" onClick={props.onClick}>
+ {props.children}
+ </Button>
+ );
+}
diff --git a/apps/web/src/features/tours/components/ViewTourVideo.tsx b/apps/web/src/features/tours/components/ViewTourVideo.tsx
new file mode 100644
index 0000000000..204ea7ccbb
--- /dev/null
+++ b/apps/web/src/features/tours/components/ViewTourVideo.tsx
@@ -0,0 +1,55 @@
+import PlayIcon from '@phosphor/play.svg';
+import XIcon from '@phosphor/x.svg';
+import { Button } from '@ui';
+import { createSignal, Show } from 'solid-js';
+import type { ViewTourVideo as Video } from '../core/view-tour';
+
+/** Load the third-party player only after an explicit play action. */
+export function ViewTourVideo(props: { video: Video }) {
+ const [playing, setPlaying] = createSignal(false);
+ return (
+ <div class="mt-4 border-t border-edge-muted pt-3">
+ <Show
+ when={playing()}
+ fallback={
+ <button
+ type="button"
+ onClick={() => setPlaying(true)}
+ class="flex w-full items-center gap-3 rounded-lg p-2 text-left hover:bg-hover"
+ aria-label={`Watch ${props.video.title}`}
+ >
+ <PlayIcon class="size-4 shrink-0" />
+ <span class="min-w-0 flex-1">
+ <span class="block text-xs text-ink">{props.video.title}</span>
+ <span class="mt-0.5 block text-xs text-ink-muted">
+ Watch video · {props.video.duration}
+ </span>
+ </span>
+ </button>
+ }
+ >
+ <div class="mb-2 flex items-center justify-between gap-2">
+ <span class="min-w-0 truncate text-xs text-ink">
+ {props.video.title}
+ </span>
+ <Button
+ variant="ghost"
+ size="icon-sm"
+ label="Close video"
+ onClick={() => setPlaying(false)}
+ >
+ <XIcon />
+ </Button>
+ </div>
+ <iframe
+ class="aspect-video w-full rounded-lg border-0 bg-surface"
+ src={`https://www.youtube-nocookie.com/embed/${props.video.youtubeId}?autoplay=1&rel=0`}
+ title={props.video.title}
+ allow="autoplay; encrypted-media; picture-in-picture; fullscreen"
+ allowfullscreen
+ referrerpolicy="strict-origin-when-cross-origin"
+ />
+ </Show>
+ </div>
+ );
+}
diff --git a/apps/web/src/features/tours/core/view-tour.ts b/apps/web/src/features/tours/core/view-tour.ts
new file mode 100644
index 0000000000..fefd72a984
--- /dev/null
+++ b/apps/web/src/features/tours/core/view-tour.ts
@@ -0,0 +1,29 @@
+import type { TourStep } from '@ui/components/Tour';
+
+export type ViewTourVideo = {
+ youtubeId: string;
+ title: string;
+ duration: string;
+};
+
+/** What the tour offers to connect when the view's data source isn't linked yet. */
+export type ViewTourConnector =
+ | { kind: 'email'; label: string }
+ | { kind: 'mcp'; label: string; tools: readonly string[] };
+
+export type ViewTourStep = TourStep & {
+ /** Shown when the step has a target but nothing to point at and no entry. */
+ missingHint?: string;
+};
+
+export type ViewTour = {
+ /** Stable id; dismissal is saved per user under it. */
+ id: string;
+ title: string;
+ connector?: ViewTourConnector;
+ video?: ViewTourVideo;
+ steps: readonly ViewTourStep[];
+};
+
+/** Identity helper so tour definitions are checked against `ViewTour`. */
+export const defineViewTour = (tour: ViewTour) => tour;
diff --git a/apps/web/src/features/tours/view-tour.css b/apps/web/src/features/tours/view-tour.css
new file mode 100644
index 0000000000..f493cf30e9
--- /dev/null
+++ b/apps/web/src/features/tours/view-tour.css
@@ -0,0 +1,30 @@
+/* One quiet edge and a diffuse shadow keep the card lifted without a lip. */
+.view-tour-card,
+.view-tour-hint {
+ box-shadow: 0 18px 48px rgb(0 0 0 / 35%);
+}
+html[data-theme-light='true'] :is(.view-tour-card, .view-tour-hint) {
+ box-shadow: 0 12px 36px rgb(0 0 0 / 10%);
+}
+/* Appear in place: fade and rise at the first position, never glide in. */
+:is(.view-tour-card, .view-tour-hint)[data-placed] {
+ animation: view-tour-rise 220ms cubic-bezier(.2,.8,.2,1) both;
+}
+/* Later moves between steps glide. */
+.view-tour-card[data-settled] {
+ transition: transform 180ms cubic-bezier(.2,.8,.2,1);
+}
+@keyframes view-tour-rise {
+ from {
+ opacity: 0;
+ translate: 0 8px;
+ }
+}
+.view-tour-highlight {
+ border-color: color-mix(in srgb, var(--color-accent) 70%, var(--color-ink));
+ box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-accent) 12%, transparent);
+}
+@media (prefers-reduced-motion: reduce) {
+ :is(.view-tour-card, .view-tour-hint)[data-placed] { animation: none; }
+ .view-tour-card[data-settled] { transition: none; }
+}
diff --git a/apps/web/src/lib/core/constant/featureFlags.ts b/apps/web/src/lib/core/constant/featureFlags.ts
index 3c3bd6905b..4c47f0f32c 100644
--- a/apps/web/src/lib/core/constant/featureFlags.ts
+++ b/apps/web/src/lib/core/constant/featureFlags.ts
@@ -725,3 +725,13 @@ export const enableUnifiedDocumentDiscussions = defineFlag({
env: 'ENABLE_UNIFIED_DOCUMENT_DISCUSSIONS',
default: onInDev,
});
+
+/**
+ * Automatic in-app feature tours on desktop views (`features/tours`). Follows
+ * PostHog everywhere, including the local dev server; set
+ * VITE_ENABLE_IN_APP_TOURS=true to turn tours on locally.
+ */
+export const enableInAppTours = defineFlag({
+ key: 'enable-in-app-tours',
+ env: 'ENABLE_IN_APP_TOURS',
+});
diff --git a/docs/AGENT_GUIDE/README.md b/docs/AGENT_GUIDE/README.md
index efce1fd6c4..85d889c0a3 100644
--- a/docs/AGENT_GUIDE/README.md
+++ b/docs/AGENT_GUIDE/README.md
@@ -13,6 +13,7 @@ verified live against a local stack (`just run_local`).
| [../CLAUDE_CLOUD_DEMO.md](../CLAUDE_CLOUD_DEMO.md) | Claude in Harness settings, encrypted saved connection, Open in Claude, and cloud-side transcript polling |
| [channels.md](channels.md) | Channels: create, invite, message, participants, bots |
| [tasks.md](tasks.md) | Task list and creation dialog |
+| [view-tours.md](view-tours.md) | Desktop feature flyovers, dismissal, targeting, and embedded videos |
| [reminders.md](reminders.md) | Creating and editing reminders, scheduling controls, and safe failure verification |
| [surfaces.md](surfaces.md) | Every other surface: inbox, email, search, files, calendar, calls, customers, activity, settings |
| [browser-technique.md](browser-technique.md) | Generic chrome-devtools MCP lessons learned on this app |
diff --git a/docs/AGENT_GUIDE/view-tours.md b/docs/AGENT_GUIDE/view-tours.md
new file mode 100644
index 0000000000..2222f1b1f6
--- /dev/null
+++ b/docs/AGENT_GUIDE/view-tours.md
@@ -0,0 +1,61 @@
+# In-app feature tours
+
+Tours are behind the `enable-in-app-tours` PostHog flag, including on the
+local dev server; set `VITE_ENABLE_IN_APP_TOURS=true` to turn them on locally. With it on, desktop views show a
+floating feature tour until it is dismissed: Home, Email,
+Documents, Tasks, Channels, Calendar, Customers, Agents, Calls, and Folders. Tours
+are not mounted on narrow screens or primary touch devices, including their videos
+and highlights.
+
+## What you see
+
+- A card sits beside the current feature, preferably to its right, and a thin
+ outline highlights the feature. The card stays inside the viewport and the
+ view's split. It doesn't take focus or block the rest of the UI; clicking
+ outside keeps it open.
+- The header shows the feature name and Back / `n / total` / Next. The footer
+ has a ghost Dismiss button beside the primary button, which reads Next, then
+ Got it on the last step.
+- A step with nothing to point at floats at the top right of the split. When a
+ feature isn't set up (for example, no connected calendar, or only one
+ calendar), the step points at the nearest real surface instead and adds a
+ short hint on how to enable it.
+- The card fades and rises in place when it first appears; it glides only
+ when moving between steps.
+- **Beacons.** A tour never navigates or opens things for you. When a step's
+ feature is behind something (a collapsed sidebar, another page, an unopened
+ conversation), the card hides and a pulsing dot marks the control that
+ reveals it: the sidebar toggle, the Agents nav item, New conversation, or the
+ top conversation row. A small card beside it says what to do ("Open a
+ channel or DM to continue"), with Skip below to move on. If that control is itself in a collapsed
+ sidebar, the dot marks the sidebar toggle first, then moves once the
+ sidebar opens. The dot stays until the feature itself is on screen, however
+ you get there; then the card appears at it. Leaving again brings the dot back.
+
+## Per view
+
+- **Agents:** agent and model picker (beacon on New conversation), then the
+ agents and Runtimes tabs (beacon on Agents), then Create for automations.
+- **Channels:** channels and DMs, creation, then threads, @mentions, and calls,
+ which wait on the channel list until a conversation is open. No Slack action.
+- **Email:** Signal/Noise, tags, then keyboard shortcuts.
+- **Customers:** Board/List, relationship details, then company views.
+- **Calendar:** calendar sources and copy availability (beacon on the sidebar
+ toggle while the sidebar is collapsed), calendar periods, then event details.
+- **Tasks:** also offers Import from Linear, which opens the CSV importer.
+
+Connection suggestions open Email or Connected settings. Home, Email, Documents,
+Tasks, Channels, Customers, and Calls include a video from Macro's YouTube
+channel; no player loads until Watch is clicked. The player has an × above it
+to close the video, and dismissing the tour removes it.
+
+## Progress
+
+Progress is saved per user and view in this browser's local storage, not on
+the server. Got it on the last step (or skipping past it) saves the tour as
+completed; Dismiss, or Escape while focus is inside the card, saves it as
+dismissed.
+Either keeps it hidden. An unfinished tour resumes at the step last reached.
+Other views keep their own tours. On localhost, 127.0.0.1, and IPv6 loopback
+in development, tours start from the first step on every mount and saved
+progress is left alone.