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.

Refactor settings navigation, calendar connections, and booking links (#7484)

Jacob Beckermand9abbd796347
diff --git a/apps/web/src/components/app/Layout.tsx b/apps/web/src/components/app/Layout.tsx
index 760e047740..bb2401207c 100644
--- a/apps/web/src/components/app/Layout.tsx
+++ b/apps/web/src/components/app/Layout.tsx
@@ -63,7 +63,6 @@ import {
useNavigate,
} from '@solidjs/router';
import { cn, ImperativeDialogHost } from '@ui';
-import { ScreencastHotkeys } from '@ui/components/ScreencastHotkeys';
import {
createEffect,
createMemo,
@@ -319,7 +318,6 @@ function LayoutInner(props: RouteSectionProps) {
</Show>
</Suspense>
<DevStatusBar />
- <ScreencastHotkeys />
</div>
);
}
diff --git a/apps/web/src/components/ui/components/ScreencastHotkeys.tsx b/apps/web/src/components/ui/components/ScreencastHotkeys.tsx
deleted file mode 100644
index 7e7cfa2ccb..0000000000
--- a/apps/web/src/components/ui/components/ScreencastHotkeys.tsx
+++ /dev/null
@@ -1,84 +0,0 @@
-import { useSubscribeToKeypress } from '@app/signal/hotkeyRoot';
-import { makePersisted } from '@solid-primitives/storage';
-import { createSignal, For, Show } from 'solid-js';
-import { Portal } from 'solid-js/web';
-import { Hotkey } from './Hotkey';
-
-export const [enableScreencastHotkeys, setEnableScreencastHotkeys] =
- makePersisted(createSignal(false), { name: 'enableHotkeyScreencast' });
-
-type ScreencastEntry = {
- id: number;
- shortcut: string;
- label?: string;
- count: number;
- timeout: number;
-};
-
-let entryId = 0;
-const ENTRY_TTL = 3000;
-
-export function ScreencastHotkeys() {
- const [entries, setEntries] = createSignal<ScreencastEntry[]>([]);
-
- useSubscribeToKeypress((ctx) => {
- if (ctx.eventType !== 'keydown' || !ctx.isNonModifierKeypress) return;
- if (!ctx.commandCaptured && !ctx.pressedKeys.has('cmd')) return;
- const cmd = ctx.commandCaptured;
- const shortcut = cmd?.hotkeys?.[0] ?? ctx.pressedKeysString;
- const label = cmd
- ? typeof cmd.description === 'function'
- ? cmd.description()
- : cmd.description
- : undefined;
-
- setEntries((prev) => {
- const last = prev[prev.length - 1];
- if (last && last.shortcut === shortcut) {
- window.clearTimeout(last.timeout);
- const updated = {
- ...last,
- count: last.count + 1,
- timeout: window.setTimeout(() => {
- setEntries((p) => p.filter((e) => e.id !== last.id));
- }, ENTRY_TTL),
- };
- return [...prev.slice(0, -1), updated];
- }
- const id = entryId++;
- const timeout = window.setTimeout(() => {
- setEntries((p) => p.filter((e) => e.id !== id));
- }, ENTRY_TTL);
- const next = [...prev, { id, shortcut, label, count: 1, timeout }];
- if (next.length > 5) {
- const oldest = next[0];
-
- window.clearTimeout(oldest.timeout);
- return next.slice(-5);
- }
- return next;
- });
- });
-
- return (
- <Show when={enableScreencastHotkeys() && entries().length > 0}>
- <Portal>
- <div class="fixed right-3 top-3 z-2147483647 flex flex-col-reverse gap-1 pointer-events-none text-xs">
- <For each={entries()}>
- {(entry) => (
- <div class="flex items-center gap-2 bg-surface p-1 border border-edge rounded-md">
- <Hotkey shortcut={entry.shortcut} theme="accent" />
- <Show when={entry.count > 1}>
- <span class="text-xs font-medium text-accent">
- x{entry.count}
- </span>
- </Show>
- <span class="text-xs text-ink-muted">{entry.label}</span>
- </div>
- )}
- </For>
- </div>
- </Portal>
- </Show>
- );
-}
diff --git a/apps/web/src/features/calendar/calendar-settings.tsx b/apps/web/src/features/calendar/calendar-settings.tsx
new file mode 100644
index 0000000000..14760ccdcf
--- /dev/null
+++ b/apps/web/src/features/calendar/calendar-settings.tsx
@@ -0,0 +1,138 @@
+import { useFeatureFlag } from '@app/lib/analytics/posthog';
+import { toast } from '@core/component/Toast/Toast';
+import { enableMultiInbox } from '@core/constant/featureFlags';
+import { useUserId } from '@core/context/user';
+import { useAddInboxFlow } from '@core/email-link';
+import { useEmailLinksQuery } from '@queries/email/link';
+import { createSignal, Suspense } from 'solid-js';
+import { SettingsPage } from '../settings/primitives';
+import {
+ type ConnectedCalendarAccount,
+ ConnectedCalendars,
+} from './components/connected-calendars';
+import {
+ TurnOffCalendarDialog,
+ type TurnOffCalendarTarget,
+} from './components/TurnOffCalendarDialog';
+import { useCalendarSources } from './hooks/use-calendar-sources';
+import { groupCalendarSourcesByAccount } from './utils/calendar-source-groups';
+import { useCalendarPreferences } from './utils/preferences';
+
+function CalendarSettingsContent() {
+ const links = useEmailLinksQuery();
+ const { sources, calendarsQuery } = useCalendarSources();
+ const userId = useUserId();
+ const multiInbox = useFeatureFlag(enableMultiInbox);
+ const startAddInbox = useAddInboxFlow();
+ const [preferences, setPreferences] = useCalendarPreferences();
+ const [connecting, setConnecting] = createSignal(false);
+ const [disconnect, setDisconnect] =
+ createSignal<TurnOffCalendarTarget | null>(null);
+ const accounts = (): ConnectedCalendarAccount[] => {
+ const groups = groupCalendarSourcesByAccount(
+ sources().filter((s) => s.emailLinkId)
+ );
+ const owned = (links.isSuccess ? (links.data?.links ?? []) : []).filter(
+ (l) => l.macro_id === userId()
+ );
+ return [
+ ...owned.map((link) => ({
+ id: link.id,
+ email: link.email_address,
+ calendars: groups.find((g) => g.key === link.id)?.calendars ?? [],
+ defaultColor: calendarsQuery.isSuccess
+ ? (calendarsQuery.data?.find(
+ (c) => c.emailLinkId === link.id && c.isPrimary
+ )?.color ?? undefined)
+ : undefined,
+ needsPermission: link.needs_calendar_permission,
+ canManage: true,
+ })),
+ ...groups
+ .filter((g) => !owned.some((l) => l.id === g.key))
+ .map((g) => ({
+ id: g.key,
+ email: g.emailAddress,
+ calendars: g.calendars,
+ needsPermission: false,
+ canManage: false,
+ })),
+ ];
+ };
+ const connect = async (scopes: 'calendar' | 'gmail_and_calendar') => {
+ if (connecting()) return;
+ setConnecting(true);
+ try {
+ await startAddInbox({ scopes });
+ } catch {
+ toast.failure('Could not connect your calendar. Please try again.');
+ } finally {
+ setConnecting(false);
+ }
+ };
+ return (
+ <>
+ <ConnectedCalendars
+ accounts={accounts()}
+ loading={links.isPending || calendarsQuery.isPending}
+ error={links.isError || calendarsQuery.isError}
+ connecting={connecting()}
+ canConnect={
+ links.isSuccess &&
+ (!accounts().some((a) => a.canManage) || multiInbox().enabled)
+ }
+ onRetry={() => {
+ void links.refetch();
+ void calendarsQuery.refetch();
+ }}
+ onConnect={() => void connect('gmail_and_calendar')}
+ onEnable={() => void connect('calendar')}
+ onDisconnect={(account) =>
+ setDisconnect({ linkId: account.id, emailAddress: account.email })
+ }
+ isVisible={(id) => !preferences.hiddenSourceIds.includes(id)}
+ onVisibilityChange={(ids, visible) => {
+ const hidden = new Set(preferences.hiddenSourceIds);
+ for (const id of ids) {
+ if (visible) hidden.delete(id);
+ else hidden.add(id);
+ }
+ setPreferences('hiddenSourceIds', [...hidden]);
+ }}
+ accountColor={(id) => preferences.accountColors[id]}
+ sourceColor={(id) => preferences.sourceColors[id]}
+ onAccountColor={(id, color) =>
+ setPreferences('accountColors', id, color)
+ }
+ onSourceColor={(id, color) => setPreferences('sourceColors', id, color)}
+ />
+ <TurnOffCalendarDialog
+ target={disconnect()}
+ onClose={() => setDisconnect(null)}
+ />
+ </>
+ );
+}
+
+export function CalendarConnectionSettings() {
+ return (
+ <Suspense
+ fallback={
+ <p class="px-6 text-sm text-ink-muted">Loading calendar connections…</p>
+ }
+ >
+ <CalendarSettingsContent />
+ </Suspense>
+ );
+}
+
+export function CalendarSettings() {
+ return (
+ <SettingsPage
+ title="Calendar"
+ description="Manage your connected accounts, calendar visibility, and colors."
+ >
+ <CalendarConnectionSettings />
+ </SettingsPage>
+ );
+}
diff --git a/apps/web/src/features/calendar/components/calendar-color-picker.test.tsx b/apps/web/src/features/calendar/components/calendar-color-picker.test.tsx
new file mode 100644
index 0000000000..cbaf4d5d5d
--- /dev/null
+++ b/apps/web/src/features/calendar/components/calendar-color-picker.test.tsx
@@ -0,0 +1,51 @@
+import { cleanup, fireEvent, render, screen } from '@solidjs/testing-library';
+import { createSignal } from 'solid-js';
+import { afterEach, expect, it } from 'vitest';
+import { CalendarColorPicker } from './calendar-color-picker';
+
+afterEach(cleanup);
+
+it('previews swatches, validates hex input, and preserves the selected hue through black', async () => {
+ let saved: string | undefined;
+ render(() => {
+ const [color, setColor] = createSignal('#0000ff');
+ return (
+ <CalendarColorPicker
+ label="Work color"
+ color={color()}
+ overridden={true}
+ onChange={(value) => {
+ saved = value;
+ setColor(value ?? '#0000ff');
+ }}
+ />
+ );
+ });
+ fireEvent.click(screen.getByRole('button', { name: 'Work color' }));
+ const input = await screen.findByRole('textbox', { name: 'Hex color' });
+ fireEvent.click(screen.getByRole('button', { name: 'Sage' }));
+ expect(saved).toBe('#8bbf96');
+ fireEvent.input(input, { target: { value: 'nope' } });
+ fireEvent.keyDown(input, { key: 'Enter' });
+ expect(input.getAttribute('aria-invalid')).toBe('true');
+ expect(saved).toBe('#8bbf96');
+
+ fireEvent.input(input, { target: { value: '#00f' } });
+ fireEvent.keyDown(input, { key: 'Enter' });
+ expect(saved).toBe('#0000ff');
+ fireEvent.input(input, { target: { value: '#000' } });
+ fireEvent.keyDown(input, { key: 'Enter' });
+ const field = screen.getByRole('slider', {
+ name: 'Saturation and brightness',
+ });
+ for (let i = 0; i < 10; i++) {
+ fireEvent.keyDown(field, { key: 'ArrowUp', shiftKey: true });
+ fireEvent.keyDown(field, { key: 'ArrowRight', shiftKey: true });
+ }
+ expect(saved).toBe('#0000ff');
+ expect(input.getAttribute('aria-invalid')).toBe('false');
+ const hue = screen.getByRole('slider', { name: 'Hue' });
+ fireEvent.focus(hue);
+ fireEvent.keyDown(hue, { key: 'Home' });
+ expect(saved).toBe('#ff0000');
+});
diff --git a/apps/web/src/features/calendar/components/calendar-color-picker.tsx b/apps/web/src/features/calendar/components/calendar-color-picker.tsx
new file mode 100644
index 0000000000..da54de43b9
--- /dev/null
+++ b/apps/web/src/features/calendar/components/calendar-color-picker.tsx
@@ -0,0 +1,308 @@
+import { Popover } from '@kobalte/core/popover';
+import { Slider } from '@kobalte/core/slider';
+import ResetIcon from '@phosphor/arrow-counter-clockwise.svg';
+import CheckIcon from '@phosphor/check.svg';
+import CloseIcon from '@phosphor/x.svg';
+import { createSignal, For } from 'solid-js';
+import {
+ type CalendarColor,
+ calendarColorHex,
+ normalizeCalendarHex,
+ parseCalendarColor,
+} from '../core/calendar-color';
+
+const SWATCHES = [
+ { name: 'Rose', color: '#ed6a86' },
+ { name: 'Tangerine', color: '#f49259' },
+ { name: 'Honey', color: '#edc35a' },
+ { name: 'Sage', color: '#8bbf96' },
+ { name: 'Seafoam', color: '#57b6b0' },
+ { name: 'Sky', color: '#75b7e5' },
+ { name: 'Blue', color: '#5c8aee' },
+ { name: 'Iris', color: '#9382e8' },
+ { name: 'Orchid', color: '#c48dd5' },
+ { name: 'Blush', color: '#dba3b3' },
+ { name: 'Clay', color: '#b39583' },
+ { name: 'Slate', color: '#8d9aa9' },
+];
+
+export function CalendarColorPicker(props: {
+ label: string;
+ color: string;
+ overridden: boolean;
+ onChange: (color: string | undefined) => void;
+}) {
+ const [open, setOpen] = createSignal(false);
+ const [color, setColor] = createSignal<CalendarColor>({
+ hue: 210,
+ saturation: 0.6,
+ brightness: 0.9,
+ });
+ const [draft, setDraft] = createSignal<string>();
+ const [invalid, setInvalid] = createSignal(false);
+ let swatch!: HTMLSpanElement;
+ let dragging: number | undefined;
+ const hex = () => calendarColorHex(color());
+ const hueColor = () => `hsl(${color().hue} 100% 50%)`;
+ const change = (next: CalendarColor) => {
+ setColor(next);
+ setDraft(undefined);
+ setInvalid(false);
+ props.onChange(calendarColorHex(next));
+ };
+ const changeHex = (value: string) => {
+ const next = parseCalendarColor(value);
+ // Keep the chosen hue when the color field reaches gray, white, or black.
+ if (next.saturation === 0) next.hue = color().hue;
+ change(next);
+ };
+ const commitHex = () => {
+ const value = draft();
+ if (value === undefined) return;
+ const normalized = normalizeCalendarHex(value);
+ if (!normalized) {
+ setInvalid(true);
+ return;
+ }
+ changeHex(normalized);
+ };
+ const atPointer = (
+ event: PointerEvent & { currentTarget: HTMLDivElement }
+ ) => {
+ const rect = event.currentTarget.getBoundingClientRect();
+ if (!rect.width || !rect.height) return;
+ change({
+ ...color(),
+ saturation: Math.max(
+ 0,
+ Math.min(1, (event.clientX - rect.left) / rect.width)
+ ),
+ brightness:
+ 1 - Math.max(0, Math.min(1, (event.clientY - rect.top) / rect.height)),
+ });
+ };
+ return (
+ <Popover
+ placement="bottom-end"
+ gutter={10}
+ open={open()}
+ onOpenChange={(value) => {
+ if (value) {
+ setColor(
+ parseCalendarColor(
+ normalizeCalendarHex(props.color) ??
+ getComputedStyle(swatch).backgroundColor
+ )
+ );
+ setDraft(undefined);
+ setInvalid(false);
+ }
+ setOpen(value);
+ }}
+ >
+ <Popover.Trigger
+ aria-label={props.label}
+ title={props.label}
+ class="flex size-8 shrink-0 items-center justify-center rounded-full outline-none hover:bg-ink/5 focus-visible:ring-2 focus-visible:ring-accent data-expanded:bg-ink/5"
+ >
+ <span
+ ref={swatch}
+ class="size-5 rounded-full border border-ink/10 transition-transform hover:scale-110"
+ style={{ 'background-color': props.color }}
+ />
+ </Popover.Trigger>
+ <Popover.Portal>
+ <Popover.Content class="z-action-menu w-72 max-h-[calc(100dvh-2rem)] max-w-[calc(100vw-1.5rem)] overflow-y-auto rounded-2xl border border-edge-muted bg-menu p-3 text-ink shadow-menu outline-none menu-open-animation">
+ <div class="mb-3 flex items-start justify-between gap-2 px-1">
+ <div class="min-w-0">
+ <Popover.Title class="text-sm font-medium">
+ Calendar color
+ </Popover.Title>
+ <Popover.Description
+ class="mt-0.5 truncate text-xs text-ink-muted"
+ title={props.label}
+ >
+ {props.label}
+ </Popover.Description>
+ </div>
+ <Popover.CloseButton
+ aria-label="Close color picker"
+ class="flex size-6 shrink-0 items-center justify-center rounded-full text-ink-muted hover:bg-hover focus-visible:outline-2 focus-visible:outline-accent"
+ >
+ <CloseIcon class="size-3.5" />
+ </Popover.CloseButton>
+ </div>
+ <div
+ role="slider"
+ tabIndex={0}
+ aria-label="Saturation and brightness"
+ aria-valuemin={0}
+ aria-valuemax={100}
+ aria-valuenow={Math.round(color().saturation * 100)}
+ aria-valuetext={`${Math.round(color().saturation * 100)}% saturation, ${Math.round(color().brightness * 100)}% brightness`}
+ class="relative h-44 w-full touch-none rounded-xl outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 ring-offset-menu"
+ style={{
+ background: `linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, transparent), ${hueColor()}`,
+ }}
+ onPointerDown={(event) => {
+ if (event.button !== 0) return;
+ event.preventDefault();
+ event.currentTarget.focus({ preventScroll: true });
+ event.currentTarget.setPointerCapture(event.pointerId);
+ dragging = event.pointerId;
+ atPointer(event);
+ }}
+ onPointerMove={(event) => {
+ if (dragging === event.pointerId) atPointer(event);
+ }}
+ onPointerUp={(event) => {
+ if (dragging !== event.pointerId) return;
+ atPointer(event);
+ dragging = undefined;
+ event.currentTarget.releasePointerCapture(event.pointerId);
+ }}
+ onPointerCancel={() => {
+ dragging = undefined;
+ }}
+ onLostPointerCapture={() => {
+ dragging = undefined;
+ }}
+ onKeyDown={(event) => {
+ const step = event.shiftKey ? 0.1 : 0.01;
+ const next = { ...color() };
+ switch (event.key) {
+ case 'ArrowLeft':
+ next.saturation = Math.max(0, next.saturation - step);
+ break;
+ case 'ArrowRight':
+ next.saturation = Math.min(1, next.saturation + step);
+ break;
+ case 'ArrowUp':
+ next.brightness = Math.min(1, next.brightness + step);
+ break;
+ case 'ArrowDown':
+ next.brightness = Math.max(0, next.brightness - step);
+ break;
+ default:
+ return;
+ }
+ event.preventDefault();
+ change(next);
+ }}
+ >
+ <span
+ class="pointer-events-none absolute size-4 -translate-x-1/2 -translate-y-1/2 rounded-full border-2 shadow-md"
+ style={{
+ left: `${color().saturation * 100}%`,
+ top: `${(1 - color().brightness) * 100}%`,
+ 'background-color': hex(),
+ 'border-color': '#fff',
+ 'box-shadow': '0 0 0 1px #0003, 0 2px 5px #0004',
+ }}
+ />
+ </div>
+ <Slider
+ minValue={0}
+ maxValue={360}
+ step={1}
+ value={[color().hue]}
+ aria-label="Hue"
+ onChange={([hue]) => change({ ...color(), hue: hue ?? 0 })}
+ class="my-4 flex h-5 touch-none items-center px-1.5"
+ >
+ <Slider.Track
+ class="relative h-2.5 w-full rounded-full"
+ style={{
+ background:
+ 'linear-gradient(to right, #f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00)',
+ }}
+ >
+ <Slider.Thumb
+ aria-label="Hue"
+ class="top-1/2 size-4 -translate-y-1/2 rounded-full border-2 outline-none focus-visible:ring-2 focus-visible:ring-accent"
+ style={{
+ 'background-color': hueColor(),
+ 'border-color': '#fff',
+ 'box-shadow': '0 1px 4px #0006',
+ }}
+ >
+ <Slider.Input />
+ </Slider.Thumb>
+ </Slider.Track>
+ </Slider>
+ <div class="flex items-center gap-3 rounded-lg border border-edge-muted px-3 py-2 focus-within:border-accent">
+ <span
+ class="size-5 shrink-0 rounded-md border border-ink/10"
+ style={{ 'background-color': hex() }}
+ />
+ <span class="text-xs text-ink-muted">HEX</span>
+ <input
+ aria-label="Hex color"
+ aria-invalid={invalid()}
+ class="min-w-0 flex-1 bg-transparent text-right font-mono text-sm uppercase outline-none aria-invalid:text-failure"
+ value={draft() ?? hex()}
+ spellcheck={false}
+ maxLength={7}
+ onInput={(event) => {
+ setDraft(event.currentTarget.value);
+ setInvalid(false);
+ }}
+ onBlur={commitHex}
+ onKeyDown={(event) => {
+ if (event.key === 'Enter') {
+ event.preventDefault();
+ commitHex();
+ }
+ }}
+ />
+ </div>
+ <div
+ class="mt-4 grid grid-cols-6 gap-2"
+ aria-label="Suggested colors"
+ >
+ <For each={SWATCHES}>
+ {(item) => (
+ <button
+ type="button"
+ aria-label={item.name}
+ title={item.name}
+ aria-pressed={hex().toLowerCase() === item.color}
+ onClick={() => changeHex(item.color)}
+ class="flex size-8 items-center justify-center justify-self-center rounded-full border border-ink/10 outline-none transition-transform hover:scale-110 focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 ring-offset-menu aria-pressed:ring-2 aria-pressed:ring-ink/40 aria-pressed:ring-offset-2"
+ >
+ <span
+ class="flex size-full items-center justify-center rounded-full"
+ style={{ 'background-color': item.color }}
+ >
+ <CheckIcon
+ class="size-4"
+ style={{
+ color: '#111',
+ visibility:
+ hex().toLowerCase() === item.color
+ ? 'visible'
+ : 'hidden',
+ }}
+ />
+ </span>
+ </button>
+ )}
+ </For>
+ </div>
+ <button
+ type="button"
+ disabled={!props.overridden}
+ aria-label={`Reset ${props.label}`}
+ onClick={() => {
+ props.onChange(undefined);
+ setOpen(false);
+ }}
+ class="mt-4 flex w-full items-center justify-center gap-1.5 rounded-lg py-2 text-xs text-ink-muted hover:bg-hover disabled:opacity-40 focus-visible:outline-2 focus-visible:outline-accent"
+ >
+ <ResetIcon class="size-3.5" /> Reset to default
+ </button>
+ </Popover.Content>
+ </Popover.Portal>
+ </Popover>
+ );
+}
diff --git a/apps/web/src/features/calendar/components/connected-calendars.test.tsx b/apps/web/src/features/calendar/components/connected-calendars.test.tsx
new file mode 100644
index 0000000000..f45564eedd
--- /dev/null
+++ b/apps/web/src/features/calendar/components/connected-calendars.test.tsx
@@ -0,0 +1,106 @@
+import { cleanup, fireEvent, render, screen } from '@solidjs/testing-library';
+import { createSignal } from 'solid-js';
+import { afterEach, expect, it, vi } from 'vitest';
+import { ConnectedCalendars } from './connected-calendars';
+
+afterEach(cleanup);
+
+it('shows partial account visibility and toggles every calendar in the account', () => {
+ const [hidden, setHidden] = createSignal(['holidays']);
+ const ui = render(() => (
+ <ConnectedCalendars
+ accounts={[
+ {
+ id: 'work',
+ email: '[email protected]',
+ canManage: true,
+ needsPermission: false,
+ calendars: [
+ { id: 'primary', name: 'Work', color: '#123456' },
+ { id: 'holidays', name: 'Holidays', color: '#654321' },
+ ],
+ },
+ ]}
+ loading={false}
+ error={false}
+ connecting={false}
+ canConnect={true}
+ onRetry={() => {}}
+ onConnect={() => {}}
+ onEnable={() => {}}
+ onDisconnect={() => {}}
+ isVisible={(id) => !hidden().includes(id)}
+ onVisibilityChange={(ids, visible) =>
+ setHidden((current) =>
+ visible
+ ? current.filter((id) => !ids.includes(id))
+ : [...new Set([...current, ...ids])]
+ )
+ }
+ accountColor={() => undefined}
+ sourceColor={() => undefined}
+ onAccountColor={() => {}}
+ onSourceColor={() => {}}
+ />
+ ));
+ const account = ui.getByRole('checkbox', {
+ }) as HTMLInputElement;
+ expect(account.indeterminate).toBe(true);
+ fireEvent.click(account);
+ expect(hidden()).toEqual([]);
+ fireEvent.click(account);
+ expect(hidden()).toEqual(['primary', 'holidays']);
+ fireEvent.click(ui.getByRole('checkbox', { name: 'Holidays' }));
+ expect(hidden()).toEqual(['primary']);
+ expect(account.indeterminate).toBe(true);
+});
+
+it('keeps the color control mounted across updates and supports resetting the override', async () => {
+ const [color, setColor] = createSignal<string>();
+ const connect = vi.fn();
+ const ui = render(() => (
+ <ConnectedCalendars
+ accounts={[
+ {
+ id: 'work',
+ email: '[email protected]',
+ canManage: true,
+ needsPermission: false,
+ calendars: [
+ { id: 'primary', name: 'Work', color: color() ?? '#123456' },
+ ],
+ },
+ ]}
+ loading={false}
+ error={false}
+ connecting={false}
+ canConnect={true}
+ onRetry={() => {}}
+ onConnect={connect}
+ onEnable={() => {}}
+ onDisconnect={() => {}}
+ isVisible={() => true}
+ onVisibilityChange={() => {}}
+ accountColor={() => undefined}
+ sourceColor={() => color()}
+ onAccountColor={() => {}}
+ onSourceColor={(_, next) => setColor(next)}
+ />
+ ));
+ const picker = ui.getByLabelText('Color for Work ([email protected])');
+ fireEvent.click(picker);
+ const hex = await screen.findByRole('textbox', { name: 'Hex color' });
+ fireEvent.input(hex, { target: { value: '#ff0000' } });
+ fireEvent.keyDown(hex, { key: 'Enter' });
+ expect(color()).toBe('#ff0000');
+ expect(ui.getByLabelText('Color for Work ([email protected])')).toBe(picker);
+ fireEvent.click(
+ screen.getByRole('button', {
+ name: 'Reset Color for Work ([email protected])',
+ })
+ );
+ expect(color()).toBeUndefined();
+ fireEvent.click(ui.getByRole('button', { name: 'Connect account' }));
+ expect(connect).toHaveBeenCalledOnce();
+});
diff --git a/apps/web/src/features/calendar/components/connected-calendars.tsx b/apps/web/src/features/calendar/components/connected-calendars.tsx
new file mode 100644
index 0000000000..355571b06c
--- /dev/null
+++ b/apps/web/src/features/calendar/components/connected-calendars.tsx
@@ -0,0 +1,198 @@
+import {
+ SettingsButton as Button,
+ SettingsCard,
+ SettingsRow,
+ SettingsSection,
+} from '@app/features/settings/primitives';
+import PlusIcon from '@phosphor/plus.svg';
+import { Checkbox } from '@ui';
+import { Index, Show } from 'solid-js';
+import type { CalendarSource } from '../types';
+import { CalendarColorPicker } from './calendar-color-picker';
+
+export interface ConnectedCalendarAccount {
+ id: string;
+ email: string;
+ calendars: CalendarSource[];
+ needsPermission: boolean;
+ canManage: boolean;
+ defaultColor?: string;
+}
+
+export function ConnectedCalendars(props: {
+ accounts: ConnectedCalendarAccount[];
+ loading: boolean;
+ error: boolean;
+ connecting: boolean;
+ canConnect: boolean;
+ onRetry: () => void;
+ onConnect: () => void;
+ onEnable: () => void;
+ onDisconnect: (account: ConnectedCalendarAccount) => void;
+ isVisible: (id: string) => boolean;
+ onVisibilityChange: (ids: string[], visible: boolean) => void;
+ accountColor: (id: string) => string | undefined;
+ sourceColor: (id: string) => string | undefined;
+ onAccountColor: (id: string, color: string | undefined) => void;
+ onSourceColor: (id: string, color: string | undefined) => void;
+}) {
+ return (
+ <SettingsSection
+ title="Connected calendars"
+ description="Connect your accounts and choose which calendars appear in Macro."
+ >
+ <SettingsCard>
+ <SettingsRow
+ label="Google Calendar"
+ description="Keep work and personal calendars together."
+ >
+ <Show when={props.canConnect}>
+ <Button
+ size="sm"
+ variant="outline"
+ disabled={props.connecting}
+ onClick={props.onConnect}
+ >
+ <PlusIcon class="size-4" />
+ {props.connecting ? 'Connecting…' : 'Connect account'}
+ </Button>
+ </Show>
+ </SettingsRow>
+ <Show when={props.loading}>
+ <p role="status" class="px-6 py-4 text-sm text-ink-muted">
+ Loading calendars…
+ </p>
+ </Show>
+ <Show when={props.error}>
+ <div
+ role="alert"
+ class="flex items-center justify-between gap-3 px-6 py-4 text-sm text-ink-muted"
+ >
+ Could not load calendars.
+ <Button size="sm" variant="outline" onClick={props.onRetry}>
+ Retry
+ </Button>
+ </div>
+ </Show>
+ <Index each={props.accounts}>
+ {(account) => {
+ const visibleCount = () =>
+ account().calendars.filter((c) => props.isVisible(c.id)).length;
+ const primary = () =>
+ account().calendars.find((c) => c.isPrimary) ??
+ account().calendars[0];
+ return (
+ <div class="px-6 py-4">
+ <div class="flex flex-wrap items-center gap-3">
+ <Checkbox
+ class="flex min-w-0 flex-1 items-center gap-3"
+ checked={
+ account().calendars.length > 0 &&
+ visibleCount() === account().calendars.length
+ }
+ indeterminate={
+ visibleCount() > 0 &&
+ visibleCount() < account().calendars.length
+ }
+ disabled={!account().calendars.length}
+ onChange={(visible) =>
+ props.onVisibilityChange(
+ account().calendars.map((c) => c.id),
+ visible
+ )
+ }
+ >
+ <Checkbox.Control />
+ <Checkbox.Label class="min-w-0 break-all text-sm font-medium">
+ {account().email}
+ </Checkbox.Label>
+ </Checkbox>
+ <Show when={account().calendars.length}>
+ <CalendarColorPicker
+ label={`Default color for ${account().email}`}
+ color={
+ props.accountColor(account().id) ??
+ account().defaultColor ??
+ primary()?.color ??
+ 'var(--color-accent)'
+ }
+ overridden={!!props.accountColor(account().id)}
+ onChange={(color) =>
+ props.onAccountColor(account().id, color)
+ }
+ />
+ </Show>
+ <Show when={account().canManage}>
+ <Button
+ size="sm"
+ variant="ghost"
+ disabled={props.connecting}
+ onClick={() =>
+ account().needsPermission
+ ? props.onEnable()
+ : props.onDisconnect(account())
+ }
+ >
+ {account().needsPermission
+ ? 'Connect calendar'
+ : 'Disconnect'}
+ </Button>
+ </Show>
+ </div>
+ <Show when={!account().calendars.length}>
+ <p class="mt-2 pl-7 text-xs text-ink-muted">
+ {account().needsPermission
+ ? 'Connect to give Macro access to this calendar.'
+ : 'Your calendars will appear here after syncing.'}
+ </p>
+ </Show>
+ <div class="mt-2 flex flex-col gap-1 pl-7">
+ <Index each={account().calendars}>
+ {(calendar) => (
+ <div class="flex items-center gap-3 py-2">
+ <Checkbox
+ class="flex min-w-0 flex-1 items-center gap-3"
+ checked={props.isVisible(calendar().id)}
+ onChange={(visible) =>
+ props.onVisibilityChange([calendar().id], visible)
+ }
+ >
+ <Checkbox.Control />
+ <Checkbox.Label class="min-w-0 text-sm text-ink-muted">
+ <span class="break-words">{calendar().name}</span>
+ <Show when={calendar().isPrimary}>
+ <span class="ml-2 text-xs text-ink-extra-muted">
+ Primary
+ </span>
+ </Show>
+ <Show when={calendar().syncError}>
+ <span class="block text-xs text-failure">
+ Sync failed: {calendar().syncError}
+ </span>
+ </Show>
+ </Checkbox.Label>
+ </Checkbox>
+ <CalendarColorPicker
+ label={`Color for ${calendar().name} (${account().email})`}
+ color={calendar().color}
+ overridden={!!props.sourceColor(calendar().id)}
+ onChange={(color) =>
+ props.onSourceColor(calendar().id, color)
+ }
+ />
+ </div>
+ )}
+ </Index>
+ </div>
+ </div>
+ );
+ }}
+ </Index>
+ </SettingsCard>
+ <p class="px-6 text-xs text-ink-extra-muted">
+ Visibility and colors are saved in this browser. Hiding a calendar does
+ not disconnect it or change your booking availability.
+ </p>
+ </SettingsSection>
+ );
+}
diff --git a/apps/web/src/features/calendar/core/calendar-color.test.ts b/apps/web/src/features/calendar/core/calendar-color.test.ts
new file mode 100644
index 0000000000..7200014fab
--- /dev/null
+++ b/apps/web/src/features/calendar/core/calendar-color.test.ts
@@ -0,0 +1,33 @@
+import { expect, it } from 'vitest';
+import {
+ calendarColorHex,
+ normalizeCalendarHex,
+ parseCalendarColor,
+} from './calendar-color';
+
+it.each([
+ '#ff0000',
+ '#00ff00',
+ '#0000ff',
+ '#000000',
+ '#ffffff',
+ '#888888',
+ '#edc35a',
+ '#123456',
+])('preserves %s when opening and saving the picker', (hex) => {
+ expect(calendarColorHex(parseCalendarColor(hex))).toBe(hex);
+});
+
+it('accepts shorthand and pasted hex values but rejects invalid or transparent colors', () => {
+ expect(normalizeCalendarHex(' #AbC ')).toBe('#aabbcc');
+ expect(normalizeCalendarHex('F49259')).toBe('#f49259');
+ for (const value of ['invalid', '#12345', '#12345678', '', 'rgb(1,2,3)']) {
+ expect(normalizeCalendarHex(value)).toBeUndefined();
+ }
+});
+
+it('resolves the computed RGB color used by inherited calendar colors', () => {
+ expect(calendarColorHex(parseCalendarColor('rgb(117, 183, 229)'))).toBe(
+ '#75b7e5'
+ );
+});
diff --git a/apps/web/src/features/calendar/core/calendar-color.ts b/apps/web/src/features/calendar/core/calendar-color.ts
new file mode 100644
index 0000000000..995a84deb7
--- /dev/null
+++ b/apps/web/src/features/calendar/core/calendar-color.ts
@@ -0,0 +1,36 @@
+import Color from 'colorjs.io';
+
+export type CalendarColor = {
+ hue: number;
+ saturation: number;
+ brightness: number;
+};
+
+/** The picker uses HSV so the field maps directly to saturation and brightness. */
+export function parseCalendarColor(value: string): CalendarColor {
+ const [h, s, l] = new Color(value).to('hsl').coords;
+ const lightness = l / 100;
+ const brightness = lightness + (s / 100) * Math.min(lightness, 1 - lightness);
+ return {
+ hue: Number.isFinite(h) ? h : 0,
+ saturation: brightness === 0 ? 0 : 2 * (1 - lightness / brightness),
+ brightness,
+ };
+}
+
+export function calendarColorHex(color: CalendarColor): string {
+ const lightness = color.brightness * (1 - color.saturation / 2);
+ const saturation =
+ lightness === 0 || lightness === 1
+ ? 0
+ : (color.brightness - lightness) / Math.min(lightness, 1 - lightness);
+ return new Color('hsl', [color.hue, saturation * 100, lightness * 100])
+ .to('srgb')
+ .toString({ format: 'hex', collapse: false });
+}
+
+export function normalizeCalendarHex(value: string): string | undefined {
+ const hex = value.trim().replace(/^#/, '');
+ if (!/^(?:[\da-f]{3}|[\da-f]{6})$/i.test(hex)) return;
+ return `#${hex.length === 3 ? [...hex].map((c) => c + c).join('') : hex}`.toLowerCase();
+}
diff --git a/apps/web/src/features/calendar/hooks/use-calendar-sources.ts b/apps/web/src/features/calendar/hooks/use-calendar-sources.ts
index 4dab363465..f57fe33da7 100644
--- a/apps/web/src/features/calendar/hooks/use-calendar-sources.ts
+++ b/apps/web/src/features/calendar/hooks/use-calendar-sources.ts
@@ -2,9 +2,11 @@ import { useVisibleCalendarsQuery } from '@queries/calendar/calendars';
import { createMemo } from 'solid-js';
import type { CalendarSource } from '../types';
import { DEFAULT_CALENDAR_SOURCE } from '../types';
+import { useCalendarPreferences } from '../utils/preferences';
/** Query-backed calendar sources with presentation colors, grouped by account. */
export function useCalendarSources() {
+ const [preferences] = useCalendarPreferences();
const calendarsQuery = useVisibleCalendarsQuery();
const sources = createMemo<CalendarSource[]>(() => {
const calendars = calendarsQuery.isSuccess
@@ -17,7 +19,13 @@ export function useCalendarSources() {
return calendars.map((calendar) => ({
id: calendar.id,
name: calendar.name,
- color: calendar.color ?? DEFAULT_CALENDAR_SOURCE.color,
+ color:
+ preferences.sourceColors[calendar.id] ??
+ preferences.accountColors[
+ calendar.emailLinkId ?? calendar.emailAddress ?? calendar.id
+ ] ??
+ calendar.color ??
+ DEFAULT_CALENDAR_SOURCE.color,
emailAddress: calendar.emailAddress,
emailLinkId: calendar.emailLinkId,
isPrimary: calendar.isPrimary,
diff --git a/apps/web/src/features/calendar/utils/preferences.ts b/apps/web/src/features/calendar/utils/preferences.ts
index 686a5f45ce..6f7551e034 100644
--- a/apps/web/src/features/calendar/utils/preferences.ts
+++ b/apps/web/src/features/calendar/utils/preferences.ts
@@ -15,6 +15,8 @@ import { getDefaultCalendarTimeFormat } from './time-format';
interface CalendarPreferences {
periodView: CalendarPeriodView;
hiddenSourceIds: string[];
+ sourceColors: Record<string, string | undefined>;
+ accountColors: Record<string, string | undefined>;
showWeekends: boolean;
weekStartsOn: CalendarWeekStart;
timeFormat: CalendarTimeFormat;
@@ -25,6 +27,8 @@ export const useCalendarPreferences = createSharedRoot(() => {
const defaultPreferences: CalendarPreferences = {
periodView: getPreferredCalendarPeriodView(),
hiddenSourceIds: [],
+ sourceColors: {},
+ accountColors: {},
showWeekends: true,
weekStartsOn: 0,
timeFormat: getDefaultCalendarTimeFormat(),
diff --git a/apps/web/src/features/channel/Bots/BotCreatePage.tsx b/apps/web/src/features/channel/Bots/BotCreatePage.tsx
index 450e42fca0..0330f127b6 100644
--- a/apps/web/src/features/channel/Bots/BotCreatePage.tsx
+++ b/apps/web/src/features/channel/Bots/BotCreatePage.tsx
@@ -172,7 +172,7 @@ export function BotCreate(props: { channelId?: string; onBack: () => void }) {
};
return (
- <div class="size-full overflow-y-auto bg-surface text-ink">
+ <div class="size-full overflow-y-auto bg-[color-mix(in_srgb,var(--color-panel)_99%,var(--color-ink))] text-ink">
{/* Mobile chrome insets live inside the scroll content so the page is
full-frame, matching SettingsPage (this create view only renders
inside the settings panel). */}
diff --git a/apps/web/src/features/channel/Bots/BotDetailPage.tsx b/apps/web/src/features/channel/Bots/BotDetailPage.tsx
index e48e83c43c..3284559bce 100644
--- a/apps/web/src/features/channel/Bots/BotDetailPage.tsx
+++ b/apps/web/src/features/channel/Bots/BotDetailPage.tsx
@@ -189,7 +189,7 @@ export function BotDetail(props: { botId: string; onBack: () => void }) {
return (
<>
- <div class="size-full overflow-y-auto bg-surface text-ink">
+ <div class="size-full overflow-y-auto bg-[color-mix(in_srgb,var(--color-panel)_99%,var(--color-ink))] text-ink">
{/* Mobile chrome insets live inside the scroll content so the page is
full-frame, matching SettingsPage (this detail view only renders
inside the settings panel). */}
diff --git a/apps/web/src/features/channel/Bots/BotFormSection.tsx b/apps/web/src/features/channel/Bots/BotFormSection.tsx
index fb34968591..50445fd80c 100644
--- a/apps/web/src/features/channel/Bots/BotFormSection.tsx
+++ b/apps/web/src/features/channel/Bots/BotFormSection.tsx
@@ -1,5 +1,5 @@
-import { Surface } from '@ui';
import type { JSX } from 'solid-js';
+import { SettingsSection } from '../../settings/primitives';
export function BotFormSection(props: {
title: string;
@@ -9,17 +9,13 @@ export function BotFormSection(props: {
children: JSX.Element;
}) {
return (
- <section class={props.class}>
- <div class="mb-2 flex items-end justify-between gap-3 px-1">
- <div>
- <h2 class="text-sm font-semibold">{props.title}</h2>
- <p class="mt-0.5 text-xs text-ink-muted">{props.description}</p>
- </div>
- {props.action}
- </div>
- <Surface depth={2} class="rounded-xl border border-ink/[0.06] p-4">
- {props.children}
- </Surface>
- </section>
+ <SettingsSection
+ title={props.title}
+ description={props.description}
+ actions={props.action}
+ class={props.class}
+ >
+ <div class="pt-2">{props.children}</div>
+ </SettingsSection>
);
}
diff --git a/apps/web/src/features/scheduling/browser-test/calendars.tsx b/apps/web/src/features/scheduling/browser-test/calendars.tsx
new file mode 100644
index 0000000000..a0e6c7cc97
--- /dev/null
+++ b/apps/web/src/features/scheduling/browser-test/calendars.tsx
@@ -0,0 +1,97 @@
+import {
+ type ConnectedCalendarAccount,
+ ConnectedCalendars,
+} from '../../calendar/components/connected-calendars';
+import { useCalendarPreferences } from '../../calendar/utils/preferences';
+
+/** Exercises the production controls and persisted preferences without OAuth or real accounts. */
+export function FixtureCalendars(props: { notify: (message: string) => void }) {
+ const [preferences, setPreferences] = useCalendarPreferences();
+ const accounts: ConnectedCalendarAccount[] = [
+ {
+ id: 'fixture-pending',
+ email: '[email protected]',
+ needsPermission: true,
+ canManage: true,
+ calendars: [],
+ },
+ {
+ id: 'fixture-work',
+ email: '[email protected]',
+ needsPermission: false,
+ canManage: true,
+ calendars: [
+ {
+ id: 'fixture-work-primary',
+ name: 'Work',
+ color: '#4285f4',
+ isPrimary: true,
+ emailLinkId: 'fixture-work',
+ },
+ {
+ id: 'fixture-team',
+ name: 'Team events',
+ color: '#33b679',
+ emailLinkId: 'fixture-work',
+ },
+ ],
+ },
+ {
+ id: 'fixture-personal',
+ email: '[email protected]',
+ needsPermission: false,
+ canManage: true,
+ calendars: [
+ {
+ id: 'fixture-personal-primary',
+ name: 'Personal',
+ color: '#8e24aa',
+ isPrimary: true,
+ emailLinkId: 'fixture-personal',
+ },
+ {
+ id: 'fixture-holidays',
+ name: 'Holidays',
+ color: '#f6bf26',
+ emailLinkId: 'fixture-personal',
+ },
+ ],
+ },
+ ];
+ return (
+ <ConnectedCalendars
+ accounts={accounts.map((account) => ({
+ ...account,
+ defaultColor: account.calendars[0]?.color,
+ calendars: account.calendars.map((calendar) => ({
+ ...calendar,
+ color:
+ preferences.sourceColors[calendar.id] ??
+ preferences.accountColors[account.id] ??
+ calendar.color,
+ })),
+ }))}
+ loading={false}
+ error={false}
+ connecting={false}
+ canConnect={true}
+ onConnect={() => props.notify('Connect account selected (preview only)')}
+ onEnable={() => props.notify('Connect calendar selected (preview only)')}
+ onDisconnect={() => props.notify('Disconnect selected (preview only)')}
+ onRetry={() => {}}
+ isVisible={(id) => !preferences.hiddenSourceIds.includes(id)}
+ onVisibilityChange={(ids, visible) => {
+ const hidden = new Set(preferences.hiddenSourceIds);
+ for (const id of ids) {
+ if (visible) hidden.delete(id);
+ else hidden.add(id);
+ }
+ setPreferences('hiddenSourceIds', [...hidden]);
+ }}
+ sourceColor={(id) => preferences.sourceColors[id]}
+ accountColor={(id) => preferences.accountColors[id]}
+ onSourceColor={(id, color) => setPreferences('sourceColors', id, color)}
+ onAccountColor={(id, color) => setPreferences('accountColors', id, color)}
+ />
+ );
+}
diff --git a/apps/web/src/features/scheduling/browser-test/fixture.tsx b/apps/web/src/features/scheduling/browser-test/fixture.tsx
index 901aa5e3e2..6fcd3e64a1 100644
--- a/apps/web/src/features/scheduling/browser-test/fixture.tsx
+++ b/apps/web/src/features/scheduling/browser-test/fixture.tsx
@@ -2,11 +2,22 @@ import { macroDarkTheme } from '../../theme/themes/macro-dark';
import { macroLightTheme } from '../../theme/themes/macro-light';
import { themeCssVars } from '../../theme/utils/themeColorTokens';
import { BookingReceiptView } from '../views/booking-receipt-view';
+import { FixtureCalendars } from './calendars';
import '@fontsource-variable/inter';
import '../../../index.css';
-import { createSignal, onCleanup, onMount, Show } from 'solid-js';
+import { ViewShell } from '@app/components/view-shell';
+import type { SettingsTab } from '@core/constant/SettingsState';
+import { SETTINGS_TAB_GROUPS } from '@core/constant/settingsTabsConfig';
+import { createMemo, createSignal, onCleanup, onMount, Show } from 'solid-js';
import { createStore } from 'solid-js/store';
import { render } from 'solid-js/web';
+import { SettingsSearchTarget } from '../../settings/components/settings-search-target';
+import { SettingsSidebar } from '../../settings/components/settings-sidebar';
+import {
+ type SettingsSearchResult,
+ searchSettings,
+} from '../../settings/core/settings-search';
+import { SettingsPage } from '../../settings/primitives';
import {
type SchedulingCapabilities,
SchedulingProvider,
@@ -23,6 +34,20 @@ import { PublicBookingView } from '../views/public-booking-view';
import { SchedulingSettingsView } from '../views/settings-view';
function Fixture() {
+ const [settingsTab, setSettingsTab] =
+ createSignal<SettingsTab>('Booking links');
+ const [settingsSearch, setSettingsSearch] = createSignal('');
+ const [selectedResult, setSelectedResult] =
+ createSignal<SettingsSearchResult>();
+ const settingsGroups = SETTINGS_TAB_GROUPS.map((group) => ({
+ ...group,
+ items: group.items.filter(
+ (item) => item.tab === 'Calendar' || item.tab === 'Booking links'
+ ),
+ })).filter((group) => group.items.length > 0);
+ const settingsResults = createMemo(() =>
+ searchSettings(settingsGroups, settingsSearch())
+ );
const [loseNextResponse, setLoseNextResponse] = createSignal(false);
const receipts = new Map<string, BookingReceipt>();
const [narrow, setNarrow] = createSignal(false);
@@ -176,17 +201,16 @@ function Fixture() {
window.addEventListener('hashchange', followPreview);
onCleanup(() => window.removeEventListener('hashchange', followPreview));
});
- let selectedScope = () => 'me';
+ const [readOnlyTeam, setReadOnlyTeam] = createSignal(false);
const capabilities: SchedulingCapabilities = {
userId: () => 'macro|[email protected]',
scopes: () => [
{ id: 'me', name: 'Personal', canEdit: true },
- { id: 'team', teamId: 'team', name: 'Design team', canEdit: true },
{
- id: 'readonly',
+ id: 'team',
teamId: 'team',
- name: 'Team member (read only)',
- canEdit: false,
+ name: 'Design team',
+ canEdit: !readOnlyTeam(),
},
],
members: () => [
@@ -216,28 +240,21 @@ function Fixture() {
setScreen('receipt');
}
},
- openConnections: () => setNotice('Calendar connection shortcut selected'),
openTeamSettings: () => setNotice('Macro team settings shortcut selected'),
createSource: (scope, range) => {
- selectedScope = () => (scope().id === 'readonly' ? 'team' : scope().id);
return {
- profile: () =>
- profiles()[scope().id === 'readonly' ? 'team' : scope().id],
+ profile: () => profiles()[scope().id],
bookings: () =>
bookings().filter(
(b) =>
- b.profileId ===
- profiles()[scope().id === 'readonly' ? 'team' : scope().id]
- .id &&
+ b.profileId === profiles()[scope().id].id &&
b.startsAt >= range().from &&
b.startsAt < range().to
),
loadInsights: async (from, to) =>
bookings().filter(
(b) =>
- b.profileId ===
- profiles()[scope().id === 'readonly' ? 'team' : scope().id]
- .id &&
+ b.profileId === profiles()[scope().id].id &&
b.startsAt >= from &&
b.startsAt < to
),
@@ -300,13 +317,15 @@ function Fixture() {
<button
type="button"
onClick={() => {
- setActive(selectedScope());
setSlug(undefined);
setScreen('public');
}}
>
Public booking page
</button>
+ <button type="button" onClick={() => setReadOnlyTeam(!readOnlyTeam())}>
+ {readOnlyTeam() ? 'Enable team editing' : 'Read-only team'}
+ </button>
<button type="button" onClick={() => applyTheme(!dark())}>
{dark() ? 'Light preview' : 'Dark preview'}
</button>
@@ -326,7 +345,43 @@ function Fixture() {
>
<Show when={screen() === 'settings'}>
<SchedulingProvider value={capabilities}>
- <SchedulingSettingsView />
+ <ViewShell.Root asidePreferenceKey="scheduling-preview" resizable>
+ <ViewShell.Aside>
+ <SettingsSidebar
+ groups={settingsGroups}
+ results={settingsResults()}
+ selectedResultId={selectedResult()?.id}
+ searchQuery={settingsSearch()}
+ onSearchQueryChange={setSettingsSearch}
+ isItemActive={(tab) => settingsTab() === tab}
+ onSelect={(tab) => {
+ setSettingsTab(tab);
+ setSelectedResult(undefined);
+ }}
+ onSelectResult={(result) => {
+ setSettingsTab(result.tab);
+ setSelectedResult({ ...result });
+ }}
+ onLogout={() => setNotice('Preview only')}
+ />
+ </ViewShell.Aside>
+ <ViewShell.Main>
+ <ViewShell.TopBar />
+ <SettingsSearchTarget result={selectedResult()}>
+ <Show
+ when={settingsTab() === 'Calendar'}
+ fallback={<SchedulingSettingsView />}
+ >
+ <SettingsPage
+ title="Calendar"
+ description="Manage your connected accounts, calendar visibility, and colors."
+ >
+ <FixtureCalendars notify={setNotice} />
+ </SettingsPage>
+ </Show>
+ </SettingsSearchTarget>
+ </ViewShell.Main>
+ </ViewShell.Root>
</SchedulingProvider>
</Show>
<Show when={screen() === 'public'}>
diff --git a/apps/web/src/features/scheduling/calendar-actions.tsx b/apps/web/src/features/scheduling/calendar-actions.tsx
index 5cbd40c014..0991f101c6 100644
--- a/apps/web/src/features/scheduling/calendar-actions.tsx
+++ b/apps/web/src/features/scheduling/calendar-actions.tsx
@@ -22,7 +22,7 @@ function Actions() {
const copy = async () => {
const profile = source.isSuccess ? source.data : undefined;
if (!profile?.revision || !profile.eventTypes.some((e) => e.enabled)) {
- settings.openSettings('Calendar');
+ settings.openSettings('Booking links');
return;
}
if (
@@ -48,8 +48,8 @@ function Actions() {
<Button
variant="ghost"
size="icon-sm"
- label="Open calendar scheduling settings"
- onClick={() => settings.openSettings('Calendar')}
+ label="Open booking link settings"
+ onClick={() => settings.openSettings('Booking links')}
>
<GearIcon class="size-3.5" />
</Button>
diff --git a/apps/web/src/features/scheduling/components/availability-panel.tsx b/apps/web/src/features/scheduling/components/availability-panel.tsx
index df00e893d1..ec0a3f6247 100644
--- a/apps/web/src/features/scheduling/components/availability-panel.tsx
+++ b/apps/web/src/features/scheduling/components/availability-panel.tsx
@@ -1,12 +1,19 @@
+import { SettingsCard } from '@app/features/settings/primitives';
import Clock from '@phosphor/clock.svg';
import Globe from '@phosphor/globe.svg';
import { Button } from '@ui';
import { createSignal, For, Show } from 'solid-js';
-import type { AvailabilitySchedule, SchedulingProfile } from '../core/types';
+import type {
+ AvailabilitySchedule,
+ SchedulingProfile,
+ SchedulingScope,
+} from '../core/types';
import { WEEKDAYS } from '../core/types';
+import { OwnerBadge } from './owner-badge';
export function AvailabilityPanel(props: {
profile: SchedulingProfile;
+ owner?: SchedulingScope;
canEdit: boolean;
saving: boolean;
onEdit: (schedule: AvailabilitySchedule) => void;
@@ -19,12 +26,15 @@ export function AvailabilityPanel(props: {
const usedBy = (id: string) =>
props.profile.eventTypes.filter((e) => e.scheduleId === id);
return (
- <div class="overflow-hidden rounded-xl border border-edge-muted bg-panel">
+ <SettingsCard>
<For
each={props.profile.schedules}
fallback={
- <div class="flex flex-col items-center gap-3 px-6 py-16 text-center">
+ <div class="flex flex-col items-center gap-3 px-6 py-8 text-center">
<Clock class="size-7 text-ink-muted" />
+ <Show when={props.owner}>
+ {(owner) => <OwnerBadge scope={owner()} />}
+ </Show>
<h2 class="font-semibold">Set your working hours</h2>
<p class="text-sm text-ink-muted">
Create a schedule to start accepting bookings.
@@ -33,7 +43,7 @@ export function AvailabilityPanel(props: {
}
>
{(schedule) => (
- <article class="border-b border-edge-muted px-6 py-5 last:border-b-0">
+ <article class="px-6 py-4">
<div class="flex flex-wrap items-start justify-between gap-5">
<button
type="button"
@@ -41,8 +51,11 @@ export function AvailabilityPanel(props: {
disabled={!props.canEdit}
onClick={() => props.onEdit(schedule)}
>
- <div class="flex items-center gap-3">
+ <div class="flex flex-wrap items-center gap-3">
<h2 class="font-semibold">{schedule.name}</h2>
+ <Show when={props.owner}>
+ {(owner) => <OwnerBadge scope={owner()} />}
+ </Show>
<Show when={defaultId() === schedule.id}>
<span class="rounded-md bg-active px-2 py-0.5 text-xs text-ink-muted">
Default
@@ -121,6 +134,6 @@ export function AvailabilityPanel(props: {
</article>
)}
</For>
- </div>
+ </SettingsCard>
);
}
diff --git a/apps/web/src/features/scheduling/components/event-editor.tsx b/apps/web/src/features/scheduling/components/event-editor.tsx
index e592771882..7aa303fd8c 100644
--- a/apps/web/src/features/scheduling/components/event-editor.tsx
+++ b/apps/web/src/features/scheduling/components/event-editor.tsx
@@ -1,12 +1,7 @@
-import ArrowLeft from '@phosphor/arrow-left.svg';
-import CalendarIcon from '@phosphor/calendar-blank.svg';
-import CheckCircle from '@phosphor/check-circle.svg';
-import ClockIcon from '@phosphor/clock.svg';
-import GearIcon from '@phosphor/gear.svg';
-import Sliders from '@phosphor/sliders-horizontal.svg';
-import TextAlignLeft from '@phosphor/text-align-left.svg';
-import UsersIcon from '@phosphor/users.svg';
-import VideoCamera from '@phosphor/video-camera.svg';
+import {
+ SettingsCard,
+ SettingsSection,
+} from '@app/features/settings/primitives';
import { Button } from '@ui';
import { createSignal, For, Index, Show } from 'solid-js';
import { unwrap } from 'solid-js/store';
@@ -31,7 +26,6 @@ export function EventEditor(props: {
onCancel: () => void;
}) {
const [draft, setDraft] = createSignal(structuredClone(unwrap(props.event)));
- const [section, setSection] = createSignal('Basics');
const [error, setError] = createSignal('');
const update = <K extends keyof EventType>(key: K, value: EventType[K]) =>
setDraft((d) => ({ ...d, [key]: value }));
@@ -43,7 +37,6 @@ export function EventEditor(props: {
return;
}
if (props.team && missingHosts().length) {
- setSection('Hosts');
setError(
'Remove former team members from the selected hosts before saving.'
);
@@ -60,256 +53,176 @@ export function EventEditor(props: {
draft().hosts.filter(
(id) => !props.members.some((member) => member.id === id)
);
- const sections = () => [
- {
- label: 'Setup',
- items: [
- {
- name: 'Basics',
- icon: GearIcon,
- description: 'Set the details people see on your booking page.',
- },
- {
- name: 'Availability',
- icon: CalendarIcon,
- description: 'Choose when people can book this event.',
- },
- ...(props.team
- ? [
- {
- name: 'Hosts',
- icon: UsersIcon,
- description: 'Choose the people who will host this event.',
- },
- ]
- : []),
- ],
- },
- {
- label: 'Booking experience',
- items: [
- {
- name: 'Booking form',
- icon: TextAlignLeft,
- description: 'Collect the information you need before a meeting.',
- },
- {
- name: 'Confirmation',
- icon: CheckCircle,
- description: 'Choose how new bookings are accepted.',
- },
- ],
- },
- {
- label: 'Policies',
- items: [
- {
- name: 'Limits & buffers',
- icon: Sliders,
- description: 'Protect your time with notice, limits, and breaks.',
- },
- ],
- },
- ];
- const currentSection = () =>
- sections()
- .flatMap((group) => group.items)
- .find((item) => item.name === section());
return (
<form onSubmit={(e) => void save(e)} class="@container min-w-0">
- <div class="grid min-w-0 gap-6 @min-[760px]:grid-cols-[180px_minmax(0,1fr)] @min-[1100px]:gap-10">
- <aside class="min-w-0">
- <Button variant="ghost" class="mb-5 -ml-2" onClick={props.onCancel}>
- <ArrowLeft class="size-4" />
- Event types
+ <div class="flex min-w-0 flex-col gap-5">
+ <Button variant="ghost" class="self-start" onClick={props.onCancel}>
+ Cancel editing
+ </Button>
+ <header class="mb-7 flex items-start justify-between gap-4">
+ <div class="min-w-0">
+ <h3 class="break-words text-base font-semibold">
+ {draft().title || 'New event type'}
+ </h3>
+ <p class="mt-1 text-sm text-ink-muted">
+ {draft().slug
+ ? `/${draft().slug}`
+ : 'Create a reusable booking link.'}
+ </p>
+ </div>
+ <Button type="submit" variant="strong" disabled={props.saving}>
+ {props.saving ? 'Saving…' : 'Save changes'}
</Button>
- <nav
- aria-label="Event settings"
- class="flex gap-5 overflow-x-auto pb-2 @min-[760px]:flex-col @min-[760px]:gap-6"
+ </header>
+ <div class="flex min-w-0 flex-col gap-7">
+ <Show when={error()}>
+ <p role="alert" class="text-sm text-failure">
+ {error()}
+ </p>
+ </Show>
+ <SettingsSection
+ title="Basics"
+ description="Details guests see when booking."
>
- <For each={sections()}>
- {(group) => (
- <div class="shrink-0">
- <h2 class="mb-2 px-3 text-xs font-medium text-ink-muted">
- {group.label}
- </h2>
- <div class="flex gap-1 @min-[760px]:flex-col">
- <For each={group.items}>
- {(item) => (
- <button
- type="button"
- aria-current={
- section() === item.name ? 'page' : undefined
- }
- onClick={() => setSection(item.name)}
- class="flex w-full items-center gap-2 rounded-lg px-3 py-2 text-left text-sm whitespace-nowrap text-ink-muted hover:bg-hover aria-[current=page]:bg-surface-2 aria-[current=page]:text-ink aria-[current=page]:font-medium focus-visible:outline-2 focus-visible:outline-ink"
- >
- <item.icon class="size-4" />
- {item.name}
- </button>
- )}
- </For>
- </div>
- </div>
- )}
- </For>
- </nav>
- </aside>
- <div class="min-w-0">
- <header class="mb-7 flex items-start justify-between gap-4">
- <div class="min-w-0">
- <h1 class="break-words text-2xl font-semibold tracking-tight">
- {draft().title || 'New event type'}
- </h1>
- <p class="mt-1 text-sm text-ink-muted">
- {draft().slug
- ? `/${draft().slug}`
- : 'Create a reusable booking link.'}
- </p>
- </div>
- <Button type="submit" variant="strong" disabled={props.saving}>
- {props.saving ? 'Saving…' : 'Save changes'}
- </Button>
- </header>
- <div class="grid min-w-0 items-start gap-6 @min-[1100px]:grid-cols-[minmax(0,1fr)_240px]">
- <section class="min-w-0 overflow-hidden rounded-xl border border-edge-muted bg-panel">
- <div class="border-b border-edge-muted bg-surface-1 px-6 py-5">
- <h2 class="font-semibold">{section()}</h2>
- <p class="mt-1 text-sm text-ink-muted">
- {currentSection()?.description}
- </p>
- </div>
+ <SettingsCard>
<div class="flex flex-col gap-5 p-6">
- <Show when={error()}>
- <p role="alert" class="text-sm text-failure">
- {error()}
- </p>
- </Show>
- <Show when={section() === 'Basics'}>
- <Field label="Title">
- <TextInput
- required
- value={draft().title}
- placeholder="30 minute meeting"
- onInput={(e) => {
- const title = e.currentTarget.value;
- setDraft((d) => ({
- ...d,
- title,
- slug:
- d.slug === slugify(d.title)
- ? slugify(title)
- : d.slug,
- }));
- }}
- />
- </Field>
- <Field
- label="Link"
- hint="A short, memorable name for your booking link."
- >
- <TextInput
- required
- value={draft().slug}
- onInput={(e) => update('slug', e.currentTarget.value)}
- />
- </Field>
- <Field label="Description">
- <TextArea
- value={draft().description}
- placeholder="What should people know before booking?"
- onInput={(e) =>
- update('description', e.currentTarget.value)
- }
- />
- </Field>
- <Field label="Duration (minutes)" class="max-w-56">
- <TextInput
- type="number"
- min="5"
- max="480"
- required
- value={draft().durationMinutes}
- onInput={(e) =>
- update('durationMinutes', e.currentTarget.valueAsNumber)
- }
- />
- </Field>
- <CheckField
- checked={draft().googleMeet}
- onChange={(v) => update('googleMeet', v)}
- label="Create a Google Meet link"
+ <Field label="Title">
+ <TextInput
+ required
+ value={draft().title}
+ placeholder="30 minute meeting"
+ onInput={(e) => {
+ const title = e.currentTarget.value;
+ setDraft((d) => ({
+ ...d,
+ title,
+ slug:
+ d.slug === slugify(d.title) ? slugify(title) : d.slug,
+ }));
+ }}
/>
- <Field
- label={
- draft().googleMeet
- ? 'Additional location details'
- : 'Location or meeting URL'
+ </Field>
+ <Field
+ label="Link"
+ hint="A short, memorable name for your booking link."
+ >
+ <TextInput
+ required
+ value={draft().slug}
+ onInput={(e) => update('slug', e.currentTarget.value)}
+ />
+ </Field>
+ <Field label="Description">
+ <TextArea
+ value={draft().description}
+ placeholder="What should people know before booking?"
+ onInput={(e) =>
+ update('description', e.currentTarget.value)
}
- >
- <TextInput
- value={draft().location}
- placeholder="Office address, phone number, or meeting URL"
- onInput={(e) => update('location', e.currentTarget.value)}
- />
- </Field>
- <CheckField
- checked={draft().enabled}
- onChange={(v) => update('enabled', v)}
- label="Accept bookings"
/>
- </Show>
- <Show when={section() === 'Availability'}>
- <Field label="Availability schedule">
- <SelectInput
- label="Availability schedule"
- value={draft().scheduleId}
- options={props.schedules.map((s) => ({
- value: s.id,
- label: s.name,
- }))}
- onChange={(value) => update('scheduleId', value)}
- />
- </Field>
- <Show
- when={props.schedules.find(
- (s) => s.id === draft().scheduleId
- )}
- >
- {(schedule) => (
- <div class="overflow-hidden rounded-lg border border-edge-muted">
- <div class="border-b border-edge-muted bg-surface-2 px-4 py-3 text-sm font-medium">
- Weekly hours{' '}
- <span class="ml-2 font-normal text-ink-muted">
- {schedule().timeZone.replaceAll('_', ' ')}
- </span>
- </div>
- <dl class="divide-y divide-edge-muted">
- <For each={schedule().weekly}>
- {(day) => (
- <div class="flex flex-wrap justify-between gap-2 px-4 py-3 text-sm">
- <dt>{WEEKDAYS[day.day]}</dt>
- <dd class="text-ink-muted">
- {day.windows.length
- ? day.windows
- .map((w) => `${w.start} – ${w.end}`)
- .join(', ')
- : 'Unavailable'}
- </dd>
- </div>
- )}
- </For>
- </dl>
+ </Field>
+ <Field label="Duration (minutes)" class="max-w-56">
+ <TextInput
+ type="number"
+ min="5"
+ max="480"
+ required
+ value={draft().durationMinutes}
+ onInput={(e) =>
+ update('durationMinutes', e.currentTarget.valueAsNumber)
+ }
+ />
+ </Field>
+ <CheckField
+ checked={draft().googleMeet}
+ onChange={(v) => update('googleMeet', v)}
+ label="Create a Google Meet link"
+ />
+ <Field
+ label={
+ draft().googleMeet
+ ? 'Additional location details'
+ : 'Location or meeting URL'
+ }
+ >
+ <TextInput
+ value={draft().location}
+ placeholder="Office address, phone number, or meeting URL"
+ onInput={(e) => update('location', e.currentTarget.value)}
+ />
+ </Field>
+ <CheckField
+ checked={draft().enabled}
+ onChange={(v) => update('enabled', v)}
+ label="Accept bookings"
+ />
+ </div>
+ </SettingsCard>
+ </SettingsSection>
+ <SettingsSection
+ title="Availability"
+ description="Choose when this link accepts bookings."
+ >
+ <SettingsCard>
+ <div class="flex flex-col gap-5 p-6">
+ <Field label="Availability schedule">
+ <SelectInput
+ label="Availability schedule"
+ value={draft().scheduleId}
+ options={props.schedules.map((s) => ({
+ value: s.id,
+ label: s.name,
+ }))}
+ onChange={(value) => update('scheduleId', value)}
+ />
+ </Field>
+ <Show
+ when={props.schedules.find(
+ (s) => s.id === draft().scheduleId
+ )}
+ >
+ {(schedule) => (
+ <div class="overflow-hidden rounded-lg border border-edge-muted">
+ <div class="border-b border-edge-muted bg-surface-2 px-4 py-3 text-sm font-medium">
+ Weekly hours{' '}
+ <span class="ml-2 font-normal text-ink-muted">
+ {schedule().timeZone.replaceAll('_', ' ')}
+ </span>
</div>
- )}
- </Show>
- <p class="text-sm text-ink-muted">
- Busy events on each host’s connected calendar are excluded
- automatically. Manage weekly hours and date overrides in
- Availability.
- </p>
+ <dl class="divide-y divide-edge-muted">
+ <For each={schedule().weekly}>
+ {(day) => (
+ <div class="flex flex-wrap justify-between gap-2 px-4 py-3 text-sm">
+ <dt>{WEEKDAYS[day.day]}</dt>
+ <dd class="text-ink-muted">
+ {day.windows.length
+ ? day.windows
+ .map((w) => `${w.start} – ${w.end}`)
+ .join(', ')
+ : 'Unavailable'}
+ </dd>
+ </div>
+ )}
+ </For>
+ </dl>
+ </div>
+ )}
</Show>
- <Show when={section() === 'Hosts' && props.team}>
+ <p class="text-sm text-ink-muted">
+ Busy events on each host’s connected calendar are excluded
+ automatically. Manage weekly hours and date overrides in
+ Availability.
+ </p>
+ </div>
+ </SettingsCard>
+ </SettingsSection>
+ <Show when={props.team}>
+ <SettingsSection
+ title="Hosts"
+ description="Select the people who will host this event."
+ >
+ <SettingsCard>
+ <div class="flex flex-col gap-5 p-6">
<Field label="Scheduling type">
<SelectInput
label="Scheduling type"
@@ -384,221 +297,199 @@ export function EventEditor(props: {
connected calendar. Round robin assigns the available host
with the fewest bookings.
</p>
- </Show>
- <Show when={section() === 'Limits & buffers'}>
- <div class="grid grid-cols-1 gap-5 @min-[900px]:grid-cols-2">
- <For
- each={[
- {
- key: 'beforeMinutes' as const,
- label: 'Buffer before (minutes)',
- max: 10080,
- min: 0,
- },
- {
- key: 'afterMinutes' as const,
- label: 'Buffer after (minutes)',
- max: 10080,
- min: 0,
- },
- {
- key: 'noticeMinutes' as const,
- label: 'Minimum notice (minutes)',
- max: 10080,
- min: 0,
- },
- {
- key: 'horizonDays' as const,
- label: 'Booking window (days)',
- max: 365,
- min: 1,
- },
- {
- key: 'intervalMinutes' as const,
- label: 'Time-slot interval (minutes)',
- max: 480,
- min: 5,
- },
- ]}
- >
- {(field) => (
- <Field label={field.label}>
- <TextInput
- type="number"
- min={field.min}
- max={field.max}
- required
- value={draft()[field.key]}
- onInput={(e) =>
- update(field.key, e.currentTarget.valueAsNumber)
- }
- />
- </Field>
- )}
- </For>
- <Field
- label="Maximum bookings per day"
- hint="Leave blank for no limit."
- >
- <TextInput
- type="number"
- min="1"
- max="100"
- value={draft().dailyLimit ?? ''}
- onInput={(e) =>
- update(
- 'dailyLimit',
- e.currentTarget.value === ''
- ? null
- : e.currentTarget.valueAsNumber
- )
- }
- />
- </Field>
- </div>
- </Show>
- <Show when={section() === 'Booking form'}>
- <p class="text-sm text-ink-muted">
- Name and email are always required. Add questions to prepare
- for the meeting.
- </p>
- <Index each={draft().questions}>
- {(q) => (
- <div class="flex flex-col gap-3 rounded-lg border border-edge-muted p-4">
- <Field label="Question">
- <TextInput
- value={q().label}
- onInput={(e) =>
- update(
- 'questions',
- draft().questions.map((item) =>
- item.id === q().id
- ? { ...item, label: e.currentTarget.value }
- : item
- )
+ </div>
+ </SettingsCard>
+ </SettingsSection>
+ </Show>
+ <SettingsSection
+ title="Limits & buffers"
+ description="Leave time between meetings and control how far ahead guests book."
+ >
+ <SettingsCard>
+ <div class="flex flex-col gap-5 p-6">
+ <div class="grid grid-cols-1 gap-5 @min-[900px]:grid-cols-2">
+ <For
+ each={[
+ {
+ key: 'beforeMinutes' as const,
+ label: 'Buffer before (minutes)',
+ max: 10080,
+ min: 0,
+ },
+ {
+ key: 'afterMinutes' as const,
+ label: 'Buffer after (minutes)',
+ max: 10080,
+ min: 0,
+ },
+ {
+ key: 'noticeMinutes' as const,
+ label: 'Minimum notice (minutes)',
+ max: 10080,
+ min: 0,
+ },
+ {
+ key: 'horizonDays' as const,
+ label: 'Booking window (days)',
+ max: 365,
+ min: 1,
+ },
+ {
+ key: 'intervalMinutes' as const,
+ label: 'Time-slot interval (minutes)',
+ max: 480,
+ min: 5,
+ },
+ ]}
+ >
+ {(field) => (
+ <Field label={field.label}>
+ <TextInput
+ type="number"
+ min={field.min}
+ max={field.max}
+ required
+ value={draft()[field.key]}
+ onInput={(e) =>
+ update(field.key, e.currentTarget.valueAsNumber)
+ }
+ />
+ </Field>
+ )}
+ </For>
+ <Field
+ label="Maximum bookings per day"
+ hint="Leave blank for no limit."
+ >
+ <TextInput
+ type="number"
+ min="1"
+ max="100"
+ value={draft().dailyLimit ?? ''}
+ onInput={(e) =>
+ update(
+ 'dailyLimit',
+ e.currentTarget.value === ''
+ ? null
+ : e.currentTarget.valueAsNumber
+ )
+ }
+ />
+ </Field>
+ </div>
+ </div>
+ </SettingsCard>
+ </SettingsSection>
+ <SettingsSection
+ title="Booking form"
+ description="Collect information before the meeting."
+ >
+ <SettingsCard>
+ <div class="flex flex-col gap-5 p-6">
+ <p class="text-sm text-ink-muted">
+ Name and email are always required. Add questions to prepare
+ for the meeting.
+ </p>
+ <Index each={draft().questions}>
+ {(q) => (
+ <div class="flex flex-col gap-3 rounded-lg border border-edge-muted p-4">
+ <Field label="Question">
+ <TextInput
+ value={q().label}
+ onInput={(e) =>
+ update(
+ 'questions',
+ draft().questions.map((item) =>
+ item.id === q().id
+ ? { ...item, label: e.currentTarget.value }
+ : item
)
- }
- />
- </Field>
- <div class="flex items-center justify-between">
- <CheckField
- checked={q().required}
- label="Required"
- onChange={(required) =>
- update(
- 'questions',
- draft().questions.map((item) =>
- item.id === q().id
- ? { ...item, required }
- : item
- )
+ )
+ }
+ />
+ </Field>
+ <div class="flex items-center justify-between">
+ <CheckField
+ checked={q().required}
+ label="Required"
+ onChange={(required) =>
+ update(
+ 'questions',
+ draft().questions.map((item) =>
+ item.id === q().id
+ ? { ...item, required }
+ : item
)
- }
- />
- <Button
- variant="ghost"
- onClick={() =>
- update(
- 'questions',
- draft().questions.filter(
- (item) => item.id !== q().id
- )
+ )
+ }
+ />
+ <Button
+ variant="ghost"
+ onClick={() =>
+ update(
+ 'questions',
+ draft().questions.filter(
+ (item) => item.id !== q().id
)
- }
- >
- Remove
- </Button>
- </div>
+ )
+ }
+ >
+ Remove
+ </Button>
</div>
- )}
- </Index>
- <Button
- variant="outline"
- onClick={() =>
- update('questions', [
- ...draft().questions,
- { id: crypto.randomUUID(), label: '', required: false },
- ])
- }
- >
- Add a question
- </Button>
- </Show>
- <Show when={section() === 'Confirmation'}>
- <div class="rounded-lg border border-edge-muted p-4">
- <p class="font-medium">Automatic confirmation</p>
- <p class="mt-2 text-sm text-ink-muted">
- Guests receive a calendar invitation as soon as they book
- an available time.
- </p>
- <Show when={draft().requiresConfirmation}>
- <Button
- variant="outline"
- onClick={() => update('requiresConfirmation', false)}
- >
- Enable automatic confirmation
- </Button>
- <p class="mt-2 text-sm text-ink-muted">
- This link is paused until automatic confirmation is
- enabled.
- </p>
- </Show>
- </div>
- </Show>
+ </div>
+ )}
+ </Index>
+ <Button
+ variant="outline"
+ onClick={() =>
+ update('questions', [
+ ...draft().questions,
+ { id: crypto.randomUUID(), label: '', required: false },
+ ])
+ }
+ >
+ Add a question
+ </Button>
</div>
- </section>
- <aside class="hidden min-w-0 @min-[1100px]:block">
- <p class="mb-3 text-xs font-medium text-ink-muted">
- Booking preview
- </p>
- <div class="space-y-5 rounded-xl border border-edge-muted bg-panel p-5">
- <div>
- <h3 class="break-words text-lg font-semibold">
- {draft().title || 'New event type'}
- </h3>
- <Show when={draft().description}>
- <p class="mt-3 whitespace-pre-wrap break-words text-sm text-ink-muted">
- {draft().description}
- </p>
- </Show>
- </div>
- <div class="space-y-3 text-sm text-ink-muted">
- <p class="flex items-center gap-2">
- <ClockIcon class="size-4" />
- {draft().durationMinutes || 0} minutes
+ </SettingsCard>
+ </SettingsSection>
+ <SettingsSection
+ title="Confirmation"
+ description="Choose how bookings are confirmed."
+ >
+ <SettingsCard>
+ <div class="flex flex-col gap-5 p-6">
+ <div class="rounded-lg border border-edge-muted p-4">
+ <p class="font-medium">Automatic confirmation</p>
+ <p class="mt-2 text-sm text-ink-muted">
+ Guests receive a calendar invitation as soon as they book an
+ available time.
</p>
- <Show when={draft().googleMeet}>
- <p class="flex items-center gap-2">
- <VideoCamera class="size-4" />
- Google Meet
- </p>
- </Show>
- <Show when={draft().location}>
- <p class="break-words">{draft().location}</p>
- </Show>
- <Show when={props.team}>
- <p class="flex items-center gap-2">
- <UsersIcon class="size-4" />
- {draft().mode === 'roundRobin'
- ? 'Round robin'
- : 'Collective'}
- </p>
- </Show>
<Show when={draft().requiresConfirmation}>
- <p class="flex items-center gap-2">
- <CheckCircle class="size-4" />
- Confirmation required
+ <Button
+ variant="outline"
+ onClick={() => update('requiresConfirmation', false)}
+ >
+ Enable automatic confirmation
+ </Button>
+ <p class="mt-2 text-sm text-ink-muted">
+ This link is paused until automatic confirmation is
+ enabled.
</p>
</Show>
</div>
- <div class="border-t border-edge-muted pt-4 text-xs text-ink-muted">
- {draft().enabled
- ? 'Accepting bookings'
- : 'Booking link is paused'}
- </div>
</div>
- </aside>
- </div>
+ </SettingsCard>
+ </SettingsSection>
+ </div>
+ <div class="flex justify-end gap-2">
+ <Button variant="ghost" onClick={props.onCancel}>
+ Cancel
+ </Button>
+ <Button type="submit" variant="strong" disabled={props.saving}>
+ {props.saving ? 'Saving…' : 'Save changes'}
+ </Button>
</div>
</div>
</form>
diff --git a/apps/web/src/features/scheduling/components/event-types-panel.tsx b/apps/web/src/features/scheduling/components/event-types-panel.tsx
index d510ae93ff..05e40ce5a9 100644
--- a/apps/web/src/features/scheduling/components/event-types-panel.tsx
+++ b/apps/web/src/features/scheduling/components/event-types-panel.tsx
@@ -1,3 +1,4 @@
+import { SettingsCard } from '@app/features/settings/primitives';
import { DropdownMenu } from '@kobalte/core/dropdown-menu';
import External from '@phosphor/arrow-square-out.svg';
import Clock from '@phosphor/clock.svg';
@@ -6,11 +7,14 @@ import Dots from '@phosphor/dots-three.svg';
import Link from '@phosphor/link.svg';
import { Button, ToggleSwitch } from '@ui';
import { createSignal, For, Show } from 'solid-js';
-import type { EventType } from '../core/types';
+import type { EventType, SchedulingScope } from '../core/types';
import { TextInput } from './fields';
+import { OwnerBadge } from './owner-badge';
export function EventTypesPanel(props: {
events: EventType[];
+ owner?: SchedulingScope;
+ search?: string;
canEdit: boolean;
saving: boolean;
onEdit: (event: EventType) => void;
@@ -20,28 +24,33 @@ export function EventTypesPanel(props: {
onCopy: (event: EventType) => void;
link: (event: EventType) => string;
}) {
- const [search, setSearch] = createSignal('');
+ const [localSearch, setSearch] = createSignal('');
+ const search = () => (props.search ?? localSearch()).trim();
const [removing, setRemoving] = createSignal<string>();
const filtered = () =>
props.events.filter((e) =>
- `${e.title} ${e.slug}`.toLowerCase().includes(search().toLowerCase())
+ `${e.title} ${e.slug} ${props.owner?.name ?? ''} ${props.owner?.teamId ? 'team' : 'personal'}`
+ .toLowerCase()
+ .includes(search().toLowerCase())
);
return (
<div class="flex flex-col gap-5">
- <div class="max-w-sm">
- <TextInput
- type="search"
- aria-label="Search event types"
- placeholder="Search event types…"
- value={search()}
- onInput={(e) => setSearch(e.currentTarget.value)}
- />
- </div>
- <div class="overflow-hidden rounded-xl border border-edge-muted bg-panel">
+ <Show when={props.search === undefined}>
+ <div class="max-w-sm">
+ <TextInput
+ type="search"
+ aria-label="Search event types"
+ placeholder="Search event types…"
+ value={search()}
+ onInput={(e) => setSearch(e.currentTarget.value)}
+ />
+ </div>
+ </Show>
+ <SettingsCard>
<For
each={filtered()}
fallback={
- <div class="flex flex-col items-center gap-3 px-6 py-16 text-center">
+ <div class="flex flex-col items-center gap-3 px-6 py-8 text-center">
<Link class="size-7 text-ink-muted" />
<h2 class="font-semibold">
{search()
@@ -57,19 +66,24 @@ export function EventTypesPanel(props: {
}
>
{(event) => (
- <article class="border-b border-edge-muted px-5 py-5 last:border-b-0">
+ <article class="px-6 py-4">
<div class="flex flex-wrap items-center gap-x-6 gap-y-4">
<div class="min-w-48 flex-1">
- <button
- type="button"
- disabled={!props.canEdit}
- onClick={() => props.onEdit(event)}
- class="max-w-full text-left"
- >
- <h2 class="truncate text-base font-semibold">
- {event.title}
- </h2>
- </button>
+ <div class="flex flex-wrap items-center gap-2">
+ <button
+ type="button"
+ disabled={!props.canEdit}
+ onClick={() => props.onEdit(event)}
+ class="max-w-full text-left"
+ >
+ <h2 class="truncate text-sm font-medium">
+ {event.title}
+ </h2>
+ </button>
+ <Show when={props.owner}>
+ {(owner) => <OwnerBadge scope={owner()} />}
+ </Show>
+ </div>
<p class="mt-1 truncate text-xs text-ink-muted">
/{event.slug}
</p>
@@ -187,7 +201,7 @@ export function EventTypesPanel(props: {
</article>
)}
</For>
- </div>
+ </SettingsCard>
</div>
);
}
diff --git a/apps/web/src/features/scheduling/components/owner-badge.tsx b/apps/web/src/features/scheduling/components/owner-badge.tsx
new file mode 100644
index 0000000000..bbc4c00f6e
--- /dev/null
+++ b/apps/web/src/features/scheduling/components/owner-badge.tsx
@@ -0,0 +1,23 @@
+import User from '@phosphor/user.svg';
+import Users from '@phosphor/users.svg';
+import { Show } from 'solid-js';
+import type { SchedulingScope } from '../core/types';
+
+export function OwnerBadge(props: { scope: SchedulingScope }) {
+ return (
+ <span
+ class="inline-flex max-w-full items-center gap-1.5 rounded-md bg-ink/5 px-2 py-1 text-xs font-normal text-ink-muted"
+ title={props.scope.teamId ? `Team · ${props.scope.name}` : 'Personal'}
+ >
+ <Show
+ when={props.scope.teamId}
+ fallback={<User class="size-3 shrink-0" />}
+ >
+ <Users class="size-3 shrink-0" />
+ </Show>
+ <span class="truncate">
+ {props.scope.teamId ? `Team · ${props.scope.name}` : 'Personal'}
+ </span>
+ </span>
+ );
+}
diff --git a/apps/web/src/features/scheduling/components/scheduling-workspace.tsx b/apps/web/src/features/scheduling/components/scheduling-workspace.tsx
deleted file mode 100644
index e7a741929e..0000000000
--- a/apps/web/src/features/scheduling/components/scheduling-workspace.tsx
+++ /dev/null
@@ -1,160 +0,0 @@
-import { SettingsSheetContext } from '@app/features/settings/primitives';
-import External from '@phosphor/arrow-square-out.svg';
-import Calendar from '@phosphor/calendar-blank.svg';
-import Chart from '@phosphor/chart-line.svg';
-import Clock from '@phosphor/clock.svg';
-import Copy from '@phosphor/copy.svg';
-import Gear from '@phosphor/gear-six.svg';
-import Link from '@phosphor/link.svg';
-import Plugs from '@phosphor/plugs-connected.svg';
-import Users from '@phosphor/users.svg';
-import { cn } from '@ui';
-import { createEffect, For, type JSX, on, Show, useContext } from 'solid-js';
-
-export const schedulingPages = [
- {
- name: 'Event types',
- description:
- 'Configure different events for people to book on your calendar.',
- icon: Link,
- },
- {
- name: 'Bookings',
- description: 'See upcoming and past events booked through your links.',
- icon: Calendar,
- },
- {
- name: 'Availability',
- description: 'Set the times you are available for meetings.',
- icon: Clock,
- },
- {
- name: 'Teams',
- description: 'Schedule together with your Macro team.',
- icon: Users,
- },
- {
- name: 'Insights',
- description: 'View booking insights across your events.',
- icon: Chart,
- },
- {
- name: 'Booking page',
- description: 'Make your public booking page feel like you.',
- icon: Gear,
- },
-];
-
-export function SchedulingWorkspace(props: {
- page: string;
- onNavigate: (page: string) => void;
- title?: string;
- description?: string;
- actions?: JSX.Element;
- children: JSX.Element;
- publicLink?: string;
- onCopy: () => void;
- onConnections: () => void;
- editor?: boolean;
-}) {
- const inSheet = useContext(SettingsSheetContext);
- let scrollBody: HTMLElement | undefined;
- createEffect(
- on([() => props.page, () => props.editor, () => props.title], () =>
- scrollBody?.scrollTo({ top: 0 })
- )
- );
- return (
- <div class="@container/workspace h-full min-h-0 bg-page text-ink select-children">
- <div class="flex h-full min-h-0 flex-col @min-[900px]/workspace:flex-row">
- <Show when={!props.editor}>
- <aside class="flex shrink-0 flex-col gap-5 px-3 py-4 @min-[900px]/workspace:w-52 @min-[900px]/workspace:py-7">
- <div class="hidden items-center gap-2 px-3 @min-[900px]/workspace:flex">
- <Calendar class="size-5" />
- <span class="text-lg font-semibold tracking-tight">
- Scheduling
- </span>
- </div>
- <nav
- aria-label="Scheduling"
- class="flex gap-1 overflow-x-auto @min-[900px]/workspace:flex-col"
- >
- <For each={schedulingPages}>
- {(item) => (
- <button
- type="button"
- aria-current={props.page === item.name ? 'page' : undefined}
- onClick={() => props.onNavigate(item.name)}
- class={cn(
- 'flex shrink-0 items-center gap-3 rounded-lg px-3 py-2.5 text-left text-sm transition-colors hover:bg-hover',
- props.page === item.name
- ? 'bg-active font-medium text-ink'
- : 'text-ink-muted'
- )}
- >
- <item.icon class="size-[18px] shrink-0" />
- {item.name}
- </button>
- )}
- </For>
- </nav>
- <div class="mt-auto hidden flex-col gap-1 @min-[900px]/workspace:flex">
- <Show when={props.publicLink}>
- <a
- class="flex items-center gap-3 rounded-lg px-3 py-2 text-sm text-ink-muted hover:bg-hover"
- href={props.publicLink}
- target="_blank"
- rel="noopener noreferrer"
- >
- <External class="size-[18px]" />
- View public page
- </a>
- </Show>
- <button
- type="button"
- disabled={!props.publicLink}
- onClick={props.onCopy}
- class="flex items-center gap-3 rounded-lg px-3 py-2 text-left text-sm text-ink-muted hover:bg-hover disabled:opacity-40"
- >
- <Copy class="size-[18px]" />
- Copy public page link
- </button>
- <button
- type="button"
- onClick={props.onConnections}
- class="flex items-center gap-3 rounded-lg px-3 py-2 text-left text-sm text-ink-muted hover:bg-hover"
- >
- <Plugs class="size-[18px]" />
- Connected calendars
- </button>
- </div>
- </aside>
- </Show>
- <main
- ref={scrollBody}
- data-drawer-scroll-body={inSheet ? true : undefined}
- class="min-h-0 min-w-0 flex-1 overflow-y-auto rounded-t-2xl border border-edge-muted bg-panel [scrollbar-gutter:stable] [overflow-anchor:none] @min-[900px]/workspace:my-2 @min-[900px]/workspace:mr-2 @min-[900px]/workspace:rounded-2xl"
- >
- <div class="@container mx-auto flex w-full max-w-[1600px] flex-col gap-7 px-5 py-7 @min-[700px]/workspace:px-8 @min-[1200px]/workspace:px-10 @min-[1200px]/workspace:py-9">
- <Show when={props.title}>
- <header class="flex flex-wrap items-start justify-between gap-4">
- <div>
- <h1 class="text-xl font-semibold tracking-tight">
- {props.title}
- </h1>
- <Show when={props.description}>
- <p class="mt-1 text-sm text-ink-muted">
- {props.description}
- </p>
- </Show>
- </div>
- {props.actions}
- </header>
- </Show>
- {props.children}
- </div>
- </main>
- </div>
- </div>
- );
-}
diff --git a/apps/web/src/features/scheduling/context/scheduling-context.tsx b/apps/web/src/features/scheduling/context/scheduling-context.tsx
index c63005c789..a46771b54f 100644
--- a/apps/web/src/features/scheduling/context/scheduling-context.tsx
+++ b/apps/web/src/features/scheduling/context/scheduling-context.tsx
@@ -35,7 +35,6 @@ export type SchedulingCapabilities = {
) => SchedulingSource;
copyLink: (profile: SchedulingProfile, slug?: string) => Promise<void>;
link: (profile: SchedulingProfile, slug?: string) => string;
- openConnections: () => void;
openTeamSettings: () => void;
manageBooking: (id: string) => Promise<void>;
};
diff --git a/apps/web/src/features/scheduling/primitives/create-scheduling-owner.ts b/apps/web/src/features/scheduling/primitives/create-scheduling-owner.ts
new file mode 100644
index 0000000000..d328037b0b
--- /dev/null
+++ b/apps/web/src/features/scheduling/primitives/create-scheduling-owner.ts
@@ -0,0 +1,147 @@
+import { type Accessor, createSignal } from 'solid-js';
+import { unwrap } from 'solid-js/store';
+import type { SchedulingCapabilities } from '../context/scheduling-context';
+import {
+ type AvailabilitySchedule,
+ type EventType,
+ newEventType,
+ newSchedule,
+ type SchedulingProfile,
+ type SchedulingScope,
+} from '../core/types';
+
+export function createSchedulingOwner(
+ capabilities: Pick<SchedulingCapabilities, 'createSource' | 'userId'>,
+ scope: Accessor<SchedulingScope>,
+ range: Accessor<{ from: string; to: string }>
+) {
+ const source = capabilities.createSource(scope, range);
+ const [event, setEvent] = createSignal<EventType>();
+ const [schedule, setSchedule] = createSignal<AvailabilitySchedule>();
+ const [error, setError] = createSignal('');
+ const [creating, setCreating] = createSignal(false);
+ const [busyBooking, setBusyBooking] = createSignal('');
+ const [profileDraft, setProfileDraft] = createSignal<{
+ name: string;
+ description: string;
+ }>();
+ let eventOpener: HTMLElement | undefined;
+ let scheduleOpener: HTMLElement | undefined;
+ const focusedElement = () =>
+ document.activeElement instanceof HTMLElement
+ ? document.activeElement
+ : undefined;
+ const restoreFocus = (opener?: HTMLElement) =>
+ queueMicrotask(() => {
+ if (opener?.isConnected) opener.focus({ preventScroll: true });
+ });
+ const editEvent = (next: EventType) => {
+ eventOpener = focusedElement();
+ setEvent(next);
+ };
+ const editSchedule = (next: AvailabilitySchedule) => {
+ scheduleOpener = focusedElement();
+ setSchedule(next);
+ };
+ const closeEventEditor = () => {
+ setEvent(undefined);
+ restoreFocus(eventOpener);
+ };
+ const closeScheduleEditor = () => {
+ setSchedule(undefined);
+ restoreFocus(scheduleOpener);
+ };
+ const save = async (next: SchedulingProfile) => {
+ if (!scope().canEdit)
+ throw new Error('Only owners and admins can edit team scheduling.');
+ setError('');
+ await source.save(next);
+ };
+ const action = async (fn: () => Promise<void>) => {
+ setError('');
+ try {
+ await fn();
+ } catch (e) {
+ setError(e instanceof Error ? e.message : 'Could not save your changes.');
+ }
+ };
+ const bookingAction = async (id: string, fn: () => Promise<void>) => {
+ setBusyBooking(id);
+ await action(fn);
+ setBusyBooking('');
+ };
+ const createEvent = async (opener?: HTMLElement) => {
+ if (!scope().canEdit || creating() || source.saving()) return;
+ let profile = source.profile();
+ if (!profile) return;
+ eventOpener = opener ?? focusedElement();
+ setCreating(true);
+ try {
+ if (!profile.schedules.length) {
+ const next = newSchedule(
+ Intl.DateTimeFormat().resolvedOptions().timeZone
+ );
+ await save({
+ ...profile,
+ schedules: [next],
+ defaultScheduleId: next.id,
+ });
+ profile = source.profile();
+ if (!profile) return;
+ }
+ setEvent(
+ newEventType(
+ profile.defaultScheduleId ?? profile.schedules[0].id,
+ [capabilities.userId()],
+ !!scope().teamId
+ )
+ );
+ } finally {
+ setCreating(false);
+ }
+ };
+ const createSchedule = (opener?: HTMLElement) => {
+ if (scope().canEdit && !source.saving()) {
+ editSchedule(
+ newSchedule(Intl.DateTimeFormat().resolvedOptions().timeZone)
+ );
+ scheduleOpener = opener ?? scheduleOpener;
+ }
+ };
+ const duplicate = (item: EventType) => {
+ const existing = source.profile()?.eventTypes ?? [];
+ let slug = `${item.slug}-copy`;
+ let suffix = 2;
+ while (existing.some((e) => e.slug === slug))
+ slug = `${item.slug}-copy-${suffix++}`;
+ editEvent({
+ ...structuredClone(unwrap(item)),
+ id: crypto.randomUUID(),
+ title: `${item.title} (copy)`,
+ slug,
+ enabled: false,
+ });
+ };
+ return {
+ scope,
+ source,
+ event,
+ schedule,
+ error,
+ creating,
+ busyBooking,
+ profileDraft,
+ setProfileDraft,
+ save,
+ action,
+ bookingAction,
+ editEvent,
+ editSchedule,
+ closeEventEditor,
+ closeScheduleEditor,
+ createEvent,
+ createSchedule,
+ duplicate,
+ };
+}
+export type SchedulingOwner = ReturnType<typeof createSchedulingOwner>;
diff --git a/apps/web/src/features/scheduling/scheduling.tsx b/apps/web/src/features/scheduling/scheduling.tsx
index 7f4710f996..c0847b9562 100644
--- a/apps/web/src/features/scheduling/scheduling.tsx
+++ b/apps/web/src/features/scheduling/scheduling.tsx
@@ -67,7 +67,6 @@ function SchedulingSettingsContent() {
userId: () => user.userId() ?? '',
createSource: createSchedulingSource,
link: schedulingLink,
- openConnections: () => settings.openSettings('Connected'),
openTeamSettings: () => settings.openSettings('Team'),
copyLink: async (profile, slug) => {
if (
@@ -87,7 +86,7 @@ function SchedulingSettingsContent() {
export function SchedulingSettings() {
return (
<Suspense
- fallback={<p class="p-8 text-ink-muted">Loading calendar settings…</p>}
+ fallback={<p class="p-8 text-ink-muted">Loading booking links…</p>}
>
<SchedulingSettingsContent />
</Suspense>
diff --git a/apps/web/src/features/scheduling/views/owner-settings-section.tsx b/apps/web/src/features/scheduling/views/owner-settings-section.tsx
new file mode 100644
index 0000000000..7ba40e6ed1
--- /dev/null
+++ b/apps/web/src/features/scheduling/views/owner-settings-section.tsx
@@ -0,0 +1,360 @@
+import { SettingsButton as Button } from '@app/features/settings/primitives';
+import Copy from '@phosphor/copy.svg';
+import { Match, Show, Switch } from 'solid-js';
+import { AvailabilityPanel } from '../components/availability-panel';
+import { BookingsPanel } from '../components/bookings-panel';
+import { EventEditor } from '../components/event-editor';
+import { EventTypesPanel } from '../components/event-types-panel';
+import { Field, TextArea, TextInput } from '../components/fields';
+import { OwnerBadge } from '../components/owner-badge';
+import { ScheduleEditor } from '../components/schedule-editor';
+import { useScheduling } from '../context/scheduling-context';
+import type { SchedulingOwner } from '../primitives/create-scheduling-owner';
+import { InsightsView } from './insights-view';
+
+export function OwnerSettingsSection(props: {
+ kind: 'links' | 'availability' | 'page' | 'bookings' | 'insights';
+ owner: SchedulingOwner;
+ search?: string;
+}) {
+ const capabilities = useScheduling();
+ const owner = props.owner;
+ const {
+ scope,
+ source,
+ event,
+ schedule,
+ profileDraft,
+ setProfileDraft,
+ save,
+ action,
+ busyBooking,
+ bookingAction,
+ closeEventEditor,
+ closeScheduleEditor,
+ duplicate,
+ } = owner;
+ return (
+ <Show when={source.profile()}>
+ {(p) => (
+ <Switch>
+ <Match when={props.kind === 'links'}>
+ <div
+ class="min-w-0"
+ role="group"
+ aria-label={`${scope().name} ${props.kind === 'page' ? 'booking page' : props.kind}`}
+ >
+ <Show when={event()}>
+ <div class="mb-4">
+ <OwnerBadge scope={scope()} />
+ </div>
+ </Show>
+ <Show
+ when={!event()}
+ fallback={
+ <Show when={event()} keyed>
+ {(value) => (
+ <EventEditor
+ event={value}
+ events={p().eventTypes}
+ schedules={p().schedules}
+ members={capabilities.members()}
+ team={!!scope().teamId}
+ saving={source.saving()}
+ onCancel={closeEventEditor}
+ onSave={async (next) => {
+ const exists = p().eventTypes.some(
+ (e) => e.id === next.id
+ );
+ await save({
+ ...p(),
+ eventTypes: exists
+ ? p().eventTypes.map((e) =>
+ e.id === next.id ? next : e
+ )
+ : [...p().eventTypes, next],
+ });
+ if (event()?.id === next.id) closeEventEditor();
+ }}
+ />
+ )}
+ </Show>
+ }
+ >
+ <EventTypesPanel
+ owner={scope()}
+ search={props.search ?? ''}
+ events={p().eventTypes}
+ canEdit={scope().canEdit}
+ saving={source.saving()}
+ onEdit={owner.editEvent}
+ onDuplicate={duplicate}
+ link={(item) => capabilities.link(p(), item.slug)}
+ onCopy={(item) =>
+ void action(() => capabilities.copyLink(p(), item.slug))
+ }
+ onToggle={(item, enabled) =>
+ void action(() =>
+ save({
+ ...p(),
+ eventTypes: p().eventTypes.map((e) =>
+ e.id === item.id ? { ...e, enabled } : e
+ ),
+ })
+ )
+ }
+ onDelete={(item) =>
+ void action(() =>
+ save({
+ ...p(),
+ eventTypes: p().eventTypes.filter(
+ (e) => e.id !== item.id
+ ),
+ })
+ )
+ }
+ />
+ </Show>
+ </div>
+ </Match>
+ <Match when={props.kind === 'availability'}>
+ <div
+ class="min-w-0"
+ role="group"
+ aria-label={`${scope().name} ${props.kind === 'page' ? 'booking page' : props.kind}`}
+ >
+ <Show when={schedule()}>
+ <div class="mb-4">
+ <OwnerBadge scope={scope()} />
+ </div>
+ </Show>
+ <Show
+ when={!schedule()}
+ fallback={
+ <Show when={schedule()} keyed>
+ {(value) => (
+ <ScheduleEditor
+ schedule={value}
+ saving={source.saving()}
+ onCancel={closeScheduleEditor}
+ onSave={async (next) => {
+ const exists = p().schedules.some(
+ (s) => s.id === next.id
+ );
+ await save({
+ ...p(),
+ defaultScheduleId:
+ p().defaultScheduleId ??
+ p().schedules[0]?.id ??
+ next.id,
+ schedules: exists
+ ? p().schedules.map((s) =>
+ s.id === next.id ? next : s
+ )
+ : [...p().schedules, next],
+ });
+ if (schedule()?.id === next.id) closeScheduleEditor();
+ }}
+ />
+ )}
+ </Show>
+ }
+ >
+ <AvailabilityPanel
+ owner={scope()}
+ profile={p()}
+ canEdit={scope().canEdit}
+ saving={source.saving()}
+ onEdit={owner.editSchedule}
+ onDefault={(s) =>
+ void action(() => save({ ...p(), defaultScheduleId: s.id }))
+ }
+ onDelete={(s) =>
+ void action(async () => {
+ if (p().eventTypes.some((e) => e.scheduleId === s.id))
+ throw new Error(
+ 'Move event types to another schedule first.'
+ );
+ const schedules = p().schedules.filter(
+ (x) => x.id !== s.id
+ );
+ await save({
+ ...p(),
+ schedules,
+ defaultScheduleId:
+ p().defaultScheduleId === s.id
+ ? (schedules[0]?.id ?? null)
+ : p().defaultScheduleId,
+ });
+ })
+ }
+ />
+ </Show>
+ </div>
+ </Match>
+ <Match when={props.kind === 'page'}>
+ <div
+ class="min-w-0"
+ role="group"
+ aria-label={`${scope().name} ${props.kind === 'page' ? 'booking page' : props.kind}`}
+ >
+ <div class="mb-4 flex flex-wrap items-center justify-between gap-3">
+ <OwnerBadge scope={scope()} />
+ <div class="flex items-center gap-3">
+ <Show when={p().revision > 0}>
+ <a
+ class="text-sm text-ink-muted underline underline-offset-4"
+ href={capabilities.link(p())}
+ target="_blank"
+ rel="noopener noreferrer"
+ >
+ Preview page
+ </a>
+ </Show>
+ <Button
+ variant="outline"
+ size="sm"
+ disabled={!p().revision}
+ onClick={() =>
+ void action(() => capabilities.copyLink(p()))
+ }
+ >
+ <Copy class="size-4" />
+ Copy page link
+ </Button>
+ </div>
+ </div>
+ <div class="flex flex-col gap-4">
+ <div class="flex flex-col gap-6 rounded-xl border border-edge-muted p-6">
+ <Field label="Display name">
+ <TextInput
+ disabled={!scope().canEdit}
+ value={profileDraft()?.name ?? p().name}
+ onInput={(e) =>
+ setProfileDraft({
+ name: e.currentTarget.value,
+ description:
+ profileDraft()?.description ?? p().description,
+ })
+ }
+ />
+ </Field>
+ <Field label="Introduction">
+ <TextArea
+ disabled={!scope().canEdit}
+ value={profileDraft()?.description ?? p().description}
+ onInput={(e) =>
+ setProfileDraft({
+ name: profileDraft()?.name ?? p().name,
+ description: e.currentTarget.value,
+ })
+ }
+ />
+ </Field>
+ <Button
+ class="self-start"
+ variant="strong"
+ disabled={
+ !scope().canEdit || !profileDraft() || source.saving()
+ }
+ onClick={() =>
+ void action(async () => {
+ await save({ ...p(), ...profileDraft() });
+ setProfileDraft(undefined);
+ })
+ }
+ >
+ Save booking page
+ </Button>
+ </div>
+ <aside class="rounded-xl border border-edge-muted p-6">
+ <p class="text-xs font-medium uppercase tracking-wide text-ink-muted">
+ Preview
+ </p>
+ <span class="mt-6 flex size-12 items-center justify-center rounded-full bg-active text-lg font-semibold">
+ {(profileDraft()?.name ?? p().name).slice(0, 1)}
+ </span>
+ <h2 class="mt-4 font-semibold">
+ {profileDraft()?.name ?? p().name}
+ </h2>
+ <p class="mt-2 whitespace-pre-wrap text-sm text-ink-muted">
+ {profileDraft()?.description ?? p().description}
+ </p>
+ <Show when={p().revision > 0}>
+ <a
+ class="mt-6 inline-block text-sm underline underline-offset-4"
+ href={capabilities.link(p())}
+ target="_blank"
+ rel="noopener noreferrer"
+ >
+ View public page ↗
+ </a>
+ </Show>
+ </aside>
+ </div>
+ </div>
+ </Match>
+ <Match when={props.kind === 'bookings'}>
+ <div
+ class="min-w-0"
+ role="group"
+ aria-label={`${scope().name} ${props.kind === 'page' ? 'booking page' : props.kind}`}
+ >
+ <div class="mb-4">
+ <OwnerBadge scope={scope()} />
+ </div>
+ <BookingsPanel
+ bookings={source.bookings()}
+ events={p().eventTypes}
+ members={capabilities.members()}
+ currentUserId={capabilities.userId()}
+ canEdit={scope().canEdit}
+ busyId={busyBooking()}
+ onApprove={(id) =>
+ void bookingAction(id, () => source.approve(id))
+ }
+ onCancel={(id) =>
+ void bookingAction(id, () => source.cancel(id))
+ }
+ onManage={(id) =>
+ void bookingAction(id, () => capabilities.manageBooking(id))
+ }
+ onAttendance={(id, attendance) =>
+ void bookingAction(id, () =>
+ source.setAttendance(id, attendance)
+ )
+ }
+ />
+ </div>
+ </Match>
+ <Match when={props.kind === 'insights'}>
+ <div
+ class="min-w-0"
+ role="group"
+ aria-label={`${scope().name} ${props.kind === 'page' ? 'booking page' : props.kind}`}
+ >
+ <div class="mb-4">
+ <OwnerBadge scope={scope()} />
+ </div>
+ <Show when={scope().id} keyed>
+ {(_scopeId) => (
+ <InsightsView
+ source={source}
+ events={p().eventTypes}
+ members={capabilities.members()}
+ timeZone={
+ p().schedules.find((s) => s.id === p().defaultScheduleId)
+ ?.timeZone ??
+ p().schedules[0]?.timeZone ??
+ Intl.DateTimeFormat().resolvedOptions().timeZone
+ }
+ />
+ )}
+ </Show>
+ </div>
+ </Match>
+ </Switch>
+ )}
+ </Show>
+ );
+}
diff --git a/apps/web/src/features/scheduling/views/settings-view.test.tsx b/apps/web/src/features/scheduling/views/settings-view.test.tsx
new file mode 100644
index 0000000000..075b6e4c3d
--- /dev/null
+++ b/apps/web/src/features/scheduling/views/settings-view.test.tsx
@@ -0,0 +1,207 @@
+import {
+ cleanup,
+ fireEvent,
+ render,
+ screen,
+ waitFor,
+ within,
+} from '@solidjs/testing-library';
+import { createSignal } from 'solid-js';
+import { afterEach, beforeEach, expect, it, vi } from 'vitest';
+import {
+ type SchedulingCapabilities,
+ SchedulingProvider,
+ type SchedulingSource,
+} from '../context/scheduling-context';
+import {
+ newEventType,
+ newSchedule,
+ type SchedulingProfile,
+} from '../core/types';
+import { SchedulingSettingsView } from './settings-view';
+
+vi.mock('./insights-view', () => ({ InsightsView: () => <div>Insights</div> }));
+vi.mock('../components/event-editor', () => ({
+ EventEditor: (props: {
+ event: SchedulingProfile['eventTypes'][number];
+ onSave: (event: SchedulingProfile['eventTypes'][number]) => Promise<void>;
+ onCancel: () => void;
+ }) => (
+ <div>
+ <button
+ onClick={() =>
+ void props.onSave({
+ ...props.event,
+ title: `${props.event.title} edited`,
+ })
+ }
+ >
+ Save test event
+ </button>
+ <button onClick={props.onCancel}>Cancel test event</button>
+ </div>
+ ),
+}));
+
+beforeEach(() => {
+ vi.spyOn(window, 'scrollTo').mockImplementation(() => {});
+});
+afterEach(() => {
+ cleanup();
+ vi.restoreAllMocks();
+});
+
+function fixture(teamEditable = true) {
+ const sources = new Map<string, SchedulingSource>();
+ const saves = vi.fn();
+ const createSource: SchedulingCapabilities['createSource'] = (scope) => {
+ const schedule = { ...newSchedule('UTC'), id: 'same-schedule-id' };
+ // Identical IDs ensure actions are routed by owner, not accidental ID matching.
+ const event = {
+ ...newEventType(schedule.id, ['user'], !!scope().teamId),
+ id: 'same-event-id',
+ enabled: true,
+ title: scope().teamId ? 'Team planning' : 'Personal catch-up',
+ slug: 'meeting',
+ };
+ const [profile, setProfile] = createSignal<SchedulingProfile>({
+ id: scope().id,
+ name: scope().name,
+ description: '',
+ schedules: [schedule],
+ defaultScheduleId: schedule.id,
+ eventTypes: [event],
+ revision: 1,
+ });
+ const source: SchedulingSource = {
+ profile,
+ bookings: () => [],
+ loading: () => false,
+ error: () => undefined,
+ saving: () => false,
+ save: async (next) => {
+ saves(scope().id, next);
+ setProfile(next);
+ },
+ approve: async () => {},
+ cancel: async () => {},
+ loadInsights: async () => [],
+ setAttendance: async () => {},
+ reload: () => {},
+ };
+ sources.set(scope().id, source);
+ return source;
+ };
+ render(() => (
+ <SchedulingProvider
+ value={{
+ scopes: () => [
+ { id: 'personal', name: 'Personal', canEdit: true },
+ { id: 'team', name: 'Design', teamId: 'team', canEdit: teamEditable },
+ ],
+ members: () => [],
+ userId: () => 'user',
+ createSource,
+ copyLink: async () => {},
+ link: (p, slug) => `/book/${p.id}/${slug ?? ''}`,
+ openTeamSettings: () => {},
+ manageBooking: async () => {},
+ }}
+ >
+ <SchedulingSettingsView />
+ </SchedulingProvider>
+ ));
+ return { sources, saves };
+}
+
+it('shows both owners and keeps link actions and editing within their owner', async () => {
+ const { sources, saves } = fixture();
+ expect(screen.queryByLabelText('Calendar owner')).toBeNull();
+ const team = screen
+ .getByRole('button', { name: 'Team planning' })
+ .closest('article')!;
+ const personal = screen
+ .getByRole('button', { name: 'Personal catch-up' })
+ .closest('article')!;
+ expect(within(team).getByText('Team · Design')).toBeTruthy();
+ expect(within(personal).getByText('Personal', { exact: true })).toBeTruthy();
+ expect(within(team).getByRole('link').getAttribute('href')).toBe(
+ '/book/team/meeting'
+ );
+ expect(within(personal).getByRole('link').getAttribute('href')).toBe(
+ '/book/personal/meeting'
+ );
+
+ fireEvent.click(within(team).getByRole('switch'));
+ await waitFor(() => expect(saves).toHaveBeenCalledOnce());
+ expect(sources.get('team')!.profile()!.eventTypes[0].enabled).toBe(false);
+ expect(sources.get('personal')!.profile()!.eventTypes[0].enabled).toBe(true);
+
+ const personalPageName = screen.getAllByRole('textbox', {
+ name: 'Display name',
+ })[0];
+ fireEvent.input(personalPageName, { target: { value: 'Personal draft' } });
+ fireEvent.click(screen.getByRole('button', { name: 'Team planning' }));
+ fireEvent.click(screen.getByRole('button', { name: 'Save test event' }));
+ await screen.findByRole('button', {
+ name: 'Team planning edited',
+ });
+ expect(sources.get('personal')!.profile()!.eventTypes[0].title).toBe(
+ 'Personal catch-up'
+ );
+ expect((personalPageName as HTMLInputElement).value).toBe('Personal draft');
+ expect(
+ screen.getByRole('button', { name: 'Personal catch-up' })
+ ).toBeTruthy();
+});
+
+it('searches all owners without switching other sections and preserves read-only team access', () => {
+ fixture(false);
+ const team = screen
+ .getByRole('button', { name: 'Team planning' })
+ .closest('article')!;
+ expect(within(team).getByRole('switch').hasAttribute('disabled')).toBe(true);
+ expect(
+ within(team).queryByRole('button', { name: 'Options for Team planning' })
+ ).toBeNull();
+ fireEvent.input(
+ screen.getByRole('searchbox', { name: 'Search booking links' }),
+ { target: { value: 'Design' } }
+ );
+ expect(
+ screen.queryByRole('button', { name: 'Personal catch-up' })
+ ).toBeNull();
+ expect(screen.getByRole('button', { name: 'Team planning' })).toBeTruthy();
+ expect(screen.getAllByRole('textbox', { name: 'Display name' })).toHaveLength(
+ 2
+ );
+ fireEvent.click(screen.getByRole('button', { name: 'New booking link' }));
+ expect(screen.getByRole('button', { name: 'Save test event' })).toBeTruthy();
+ expect(screen.getByRole('button', { name: 'Team planning' })).toBeTruthy();
+});
+
+it('creates a link for the chosen owner without replacing other owners or their drafts', async () => {
+ const { sources } = fixture();
+ const personalPageName = screen.getAllByRole('textbox', {
+ name: 'Display name',
+ })[0];
+ fireEvent.input(personalPageName, { target: { value: 'Keep this draft' } });
+ fireEvent.keyDown(screen.getByRole('button', { name: 'New booking link' }), {
+ key: 'Enter',
+ });
+ const teamOption = await screen.findByRole('menuitem', {
+ name: 'Team · Design',
+ });
+ teamOption.focus();
+ fireEvent.keyDown(teamOption, { key: 'Enter' });
+ await screen.findByRole('button', { name: 'Save test event' });
+ expect(
+ screen.getByRole('button', { name: 'Personal catch-up' })
+ ).toBeTruthy();
+ fireEvent.click(screen.getByRole('button', { name: 'Save test event' }));
+ await waitFor(() =>
+ expect(sources.get('team')!.profile()!.eventTypes).toHaveLength(2)
+ );
+ expect(sources.get('personal')!.profile()!.eventTypes).toHaveLength(1);
+ expect((personalPageName as HTMLInputElement).value).toBe('Keep this draft');
+});
diff --git a/apps/web/src/features/scheduling/views/settings-view.tsx b/apps/web/src/features/scheduling/views/settings-view.tsx
index 4a44c66f0c..f1c66fa520 100644
--- a/apps/web/src/features/scheduling/views/settings-view.tsx
+++ b/apps/web/src/features/scheduling/views/settings-view.tsx
@@ -1,197 +1,263 @@
-import Copy from '@phosphor/copy.svg';
-import Plus from '@phosphor/plus.svg';
-import Users from '@phosphor/users.svg';
-import { Button } from '@ui';
-import { createSignal, For, Show } from 'solid-js';
-import { unwrap } from 'solid-js/store';
-import { AvailabilityPanel } from '../components/availability-panel';
-import { BookingsPanel } from '../components/bookings-panel';
-import { EventEditor } from '../components/event-editor';
-import { EventTypesPanel } from '../components/event-types-panel';
-import { Field, SelectInput, TextArea, TextInput } from '../components/fields';
-import { ScheduleEditor } from '../components/schedule-editor';
import {
- SchedulingWorkspace,
- schedulingPages,
-} from '../components/scheduling-workspace';
+ SettingsButton as Button,
+ SettingsCard,
+ SettingsPage,
+ SettingsRow,
+ SettingsSection,
+} from '@app/features/settings/primitives';
+import { DropdownMenu } from '@kobalte/core/dropdown-menu';
+import Plus from '@phosphor/plus.svg';
+import { createMemo, createSignal, For, mapArray, Show } from 'solid-js';
+import { Field, TextInput } from '../components/fields';
+import { OwnerBadge } from '../components/owner-badge';
import { useScheduling } from '../context/scheduling-context';
import { reportDate, shiftReportDate } from '../core/insights';
import {
- type AvailabilitySchedule,
- type EventType,
- newEventType,
- newSchedule,
- type SchedulingProfile,
-} from '../core/types';
-import { InsightsView } from './insights-view';
+ createSchedulingOwner,
+ type SchedulingOwner,
+} from '../primitives/create-scheduling-owner';
+import { OwnerSettingsSection } from './owner-settings-section';
+
+function CreateAction(props: {
+ owners: SchedulingOwner[];
+ kind: 'event' | 'schedule';
+}) {
+ let trigger: HTMLButtonElement | undefined;
+ const label = () =>
+ props.kind === 'event' ? 'New booking link' : 'New schedule';
+ const editable = () => props.owners.filter((owner) => owner.scope().canEdit);
+ const disabled = (owner: SchedulingOwner) =>
+ !owner.source.profile() ||
+ owner.source.saving() ||
+ owner.creating() ||
+ !!(props.kind === 'event' ? owner.event() : owner.schedule());
+ const create = (owner: SchedulingOwner) => {
+ if (props.kind === 'event')
+ void owner.action(() => owner.createEvent(trigger));
+ else owner.createSchedule(trigger);
+ };
+ return (
+ <Show when={editable().length > 0}>
+ <Show
+ when={editable().length > 1}
+ fallback={
+ <Button
+ ref={trigger}
+ variant="outline"
+ size="sm"
+ disabled={!editable()[0] || disabled(editable()[0])}
+ onClick={() => create(editable()[0])}
+ >
+ <Plus class="size-4" />
+ {label()}
+ </Button>
+ }
+ >
+ <DropdownMenu>
+ <DropdownMenu.Trigger
+ as={Button}
+ ref={trigger}
+ variant="outline"
+ size="sm"
+ >
+ <Plus class="size-4" />
+ {label()}
+ </DropdownMenu.Trigger>
+ <DropdownMenu.Portal>
+ <DropdownMenu.Content class="z-action-menu min-w-48 rounded-xl border border-edge-muted bg-menu p-1 text-sm shadow-lg">
+ <div class="px-3 py-2 text-xs text-ink-muted">Create for</div>
+ <For each={editable()}>
+ {(owner) => (
+ <DropdownMenu.Item
+ disabled={disabled(owner)}
+ class="rounded-lg px-3 py-2 outline-none data-highlighted:bg-hover data-disabled:opacity-40"
+ onSelect={() => create(owner)}
+ >
+ <OwnerBadge scope={owner.scope()} />
+ </DropdownMenu.Item>
+ )}
+ </For>
+ </DropdownMenu.Content>
+ </DropdownMenu.Portal>
+ </DropdownMenu>
+ </Show>
+ </Show>
+ );
+}
export function SchedulingSettingsView() {
const capabilities = useScheduling();
- const [scopeId, setScopeId] = createSignal(
- capabilities.scopes()[0]?.id ?? 'me'
- );
- const scope = () =>
- capabilities.scopes().find((s) => s.id === scopeId()) ??
- capabilities.scopes()[0];
const browserZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
const today = reportDate(new Date(), browserZone);
const [bookingFrom, setBookingFrom] = createSignal(
shiftReportDate(today, -30)
);
const [bookingTo, setBookingTo] = createSignal(shiftReportDate(today, 30));
- const source = capabilities.createSource(scope, () => ({
- from: new Date(`${bookingFrom()}T00:00:00`).toISOString(),
- to: new Date(`${shiftReportDate(bookingTo(), 1)}T00:00:00`).toISOString(),
- }));
- const [page, setPage] = createSignal('Event types');
- const [event, setEvent] = createSignal<EventType>();
- const [schedule, setSchedule] = createSignal<AvailabilitySchedule>();
- const [error, setError] = createSignal('');
- const [busyBooking, setBusyBooking] = createSignal('');
- const [profileDraft, setProfileDraft] = createSignal<{
- name: string;
- description: string;
- }>();
- const profile = source.profile;
- const editing = () => !!event() || !!schedule();
- const pageInfo = () => schedulingPages.find((p) => p.name === page());
- const navigate = (name: string) => {
- setPage(name);
- setEvent(undefined);
- setSchedule(undefined);
- setError('');
- };
- const changeScope = (id: string) => {
- setScopeId(id);
- setEvent(undefined);
- setSchedule(undefined);
- setProfileDraft(undefined);
- setError('');
- };
- const save = async (next: SchedulingProfile) => {
- setError('');
- await source.save(next);
- };
- const action = async (fn: () => Promise<void>) => {
- setError('');
- try {
- await fn();
- } catch (e) {
- setError(e instanceof Error ? e.message : 'Could not save your changes.');
- }
- };
- const bookingAction = async (id: string, fn: () => Promise<void>) => {
- setBusyBooking(id);
- await action(fn);
- setBusyBooking('');
- };
- const createEvent = async () => {
- let p = profile();
- if (!p) return;
- if (!p.schedules.length) {
- const s = newSchedule(Intl.DateTimeFormat().resolvedOptions().timeZone);
- await save({ ...p, schedules: [s], defaultScheduleId: s.id });
- p = profile();
- if (!p) return;
- }
- setEvent(
- newEventType(
- p.defaultScheduleId ?? p.schedules[0].id,
- [capabilities.userId()],
- !!scope().teamId
- )
- );
- };
- const duplicate = (item: EventType) => {
- const existing = profile()?.eventTypes ?? [];
- let slug = `${item.slug}-copy`;
- let suffix = 2;
- while (existing.some((e) => e.slug === slug))
- slug = `${item.slug}-copy-${suffix++}`;
- setEvent({
- ...structuredClone(unwrap(item)),
- id: crypto.randomUUID(),
- title: `${item.title} (copy)`,
- slug,
- enabled: false,
- });
- };
- return (
- <SchedulingWorkspace
- page={page()}
- onNavigate={navigate}
- editor={!!event()}
- title={!editing() ? pageInfo()?.name : undefined}
- description={pageInfo()?.description}
- publicLink={
- profile()?.revision ? capabilities.link(profile()!) : undefined
+ const [search, setSearch] = createSignal('');
+ // Key by ID so profile updates and refreshed team metadata keep drafts mounted.
+ const owners = createMemo(
+ mapArray(
+ () => capabilities.scopes().map((scope) => scope.id),
+ (id) => {
+ const scope = () =>
+ capabilities.scopes().find((item) => item.id === id)!;
+ return createSchedulingOwner(capabilities, scope, () => ({
+ from: new Date(`${bookingFrom()}T00:00:00`).toISOString(),
+ to: new Date(
+ `${shiftReportDate(bookingTo(), 1)}T00:00:00`
+ ).toISOString(),
+ }));
}
- onCopy={() => {
- const p = profile();
- if (p) void action(() => capabilities.copyLink(p));
- }}
- onConnections={capabilities.openConnections}
- actions={
+ )
+ );
+ const matching = (owner: SchedulingOwner) =>
+ owner.source
+ .profile()
+ ?.eventTypes.some((event) =>
+ `${event.title} ${event.slug} ${owner.scope().name} ${owner.scope().teamId ? 'team' : 'personal'}`
+ .toLowerCase()
+ .includes(search().trim().toLowerCase())
+ );
+ const section = (kind: 'availability' | 'page' | 'bookings' | 'insights') => (
+ <div class="flex flex-col gap-8">
+ <For each={owners()}>
+ {(owner) => <OwnerSettingsSection kind={kind} owner={owner} />}
+ </For>
+ </div>
+ );
+ return (
+ <SettingsPage
+ title="Booking links"
+ description="Manage your booking links, availability, and scheduled meetings."
+ >
+ <For each={owners()}>
+ {(owner) => (
+ <>
+ <Show when={owner.source.loading()}>
+ <p role="status" class="text-sm text-ink-muted">
+ Loading {owner.scope().name} scheduling…
+ </p>
+ </Show>
+ <Show when={owner.source.error() || owner.error()}>
+ <div
+ role="alert"
+ class="flex flex-wrap items-center gap-3 rounded-xl border border-edge-muted p-4"
+ >
+ <OwnerBadge scope={owner.scope()} />
+ <p class="flex-1 text-sm text-failure">
+ {owner.error() || owner.source.error()}
+ </p>
+ <Show when={owner.source.error()}>
+ <Button
+ variant="outline"
+ size="sm"
+ onClick={owner.source.reload}
+ >
+ Try again
+ </Button>
+ </Show>
+ </div>
+ </Show>
+ <Show when={!owner.scope().canEdit}>
+ <p class="flex flex-wrap items-center gap-2 text-sm text-ink-muted">
+ <OwnerBadge scope={owner.scope()} />
+ Only team owners and admins can edit these settings.
+ </p>
+ </Show>
+ </>
+ )}
+ </For>
+ <SettingsSection
+ title="Booking links"
+ description="Personal and team links, together in one place."
+ actions={<CreateAction owners={owners()} kind="event" />}
+ >
+ <div class="max-w-sm">
+ <TextInput
+ type="search"
+ aria-label="Search booking links"
+ placeholder="Search booking links…"
+ value={search()}
+ onInput={(event) => setSearch(event.currentTarget.value)}
+ />
+ </div>
+ <For each={owners()}>
+ {(owner) => (
+ <Show when={owner.event() || matching(owner)}>
+ <OwnerSettingsSection
+ kind="links"
+ owner={owner}
+ search={search()}
+ />
+ </Show>
+ )}
+ </For>
<Show
when={
- !editing() &&
- (page() === 'Event types' || page() === 'Availability')
+ !owners().some((owner) => owner.event() || matching(owner)) &&
+ !owners().some((owner) => owner.source.loading())
}
>
+ <p class="py-6 text-center text-sm text-ink-muted">
+ {search()
+ ? 'No matching booking links.'
+ : 'Create your first booking link to let people book time with you.'}
+ </p>
+ </Show>
+ </SettingsSection>
+ <SettingsSection
+ title="Availability"
+ description="Working hours and date overrides for your personal and team calendars."
+ actions={<CreateAction owners={owners()} kind="schedule" />}
+ >
+ {section('availability')}
+ </SettingsSection>
+ <SettingsSection
+ title="Booking pages"
+ description="Customize and share your personal and team booking pages."
+ >
+ {section('page')}
+ </SettingsSection>
+ <SettingsSection
+ title="Teams"
+ description="Schedule together with your Macro team."
+ actions={
<Button
- variant="strong"
- disabled={!scope().canEdit || source.saving() || !profile()}
- onClick={() =>
- page() === 'Event types'
- ? void action(createEvent)
- : setSchedule(
- newSchedule(
- Intl.DateTimeFormat().resolvedOptions().timeZone
- )
- )
- }
+ variant="outline"
+ size="sm"
+ onClick={capabilities.openTeamSettings}
>
- <Plus class="size-4" />
- {page() === 'Event types' ? 'New event type' : 'New schedule'}
+ Manage teams
</Button>
- </Show>
- }
- >
- <Show when={!editing() && page() !== 'Insights'}>
- <div class="flex flex-wrap items-center justify-between gap-3">
- <div class="w-56">
- <SelectInput
- label="Calendar owner"
- value={scope().id}
- options={capabilities
- .scopes()
- .map((s) => ({ value: s.id, label: s.name }))}
- disabled={source.saving() || !!busyBooking()}
- onChange={changeScope}
- />
- </div>
- <Show when={page() === 'Event types' || page() === 'Booking page'}>
- <Button
- variant="outline"
- disabled={!profile()?.revision}
- onClick={() => {
- const p = profile();
- if (p) void action(() => capabilities.copyLink(p));
- }}
- >
- <Copy class="size-4" />
- Copy public link
- </Button>
- </Show>
- </div>
- </Show>
- <Show when={!scope().canEdit}>
- <p class="rounded-lg border border-edge-muted px-4 py-3 text-sm text-ink-muted">
- Team members can view scheduling. Owners and admins manage links and
- availability.
- </p>
- </Show>
- <Show when={page() === 'Bookings'}>
+ }
+ >
+ <SettingsCard>
+ <For
+ each={owners().filter((owner) => owner.scope().teamId)}
+ fallback={
+ <SettingsRow
+ label="No team connected"
+ description="Create or join a team to offer collective and round-robin meetings."
+ />
+ }
+ >
+ {(owner) => (
+ <SettingsRow
+ label={owner.scope().name}
+ description={
+ owner.scope().canEdit
+ ? 'Owner or admin · Collective and round-robin scheduling'
+ : 'Team member'
+ }
+ />
+ )}
+ </For>
+ </SettingsCard>
+ </SettingsSection>
+ <SettingsSection
+ title="Bookings"
+ description="Review and manage meetings booked through your links."
+ >
<div class="flex flex-wrap items-end gap-4">
<Field
label="From"
@@ -201,12 +267,12 @@ export function SchedulingSettingsView() {
type="date"
value={bookingFrom()}
max={bookingTo()}
- onChange={(e) => {
+ onChange={(event) => {
if (
- e.currentTarget.value &&
- e.currentTarget.value <= bookingTo()
+ event.currentTarget.value &&
+ event.currentTarget.value <= bookingTo()
)
- setBookingFrom(e.currentTarget.value);
+ setBookingFrom(event.currentTarget.value);
}}
/>
</Field>
@@ -215,367 +281,24 @@ export function SchedulingSettingsView() {
type="date"
value={bookingTo()}
min={bookingFrom()}
- onChange={(e) => {
+ onChange={(event) => {
if (
- e.currentTarget.value &&
- e.currentTarget.value >= bookingFrom()
+ event.currentTarget.value &&
+ event.currentTarget.value >= bookingFrom()
)
- setBookingTo(e.currentTarget.value);
+ setBookingTo(event.currentTarget.value);
}}
/>
</Field>
</div>
- </Show>
- <Show when={source.error()}>
- <div
- role="alert"
- class="flex flex-wrap items-center justify-between gap-3 rounded-xl border border-edge-muted p-5"
- >
- <p class="text-sm">{source.error()}</p>
- <Button variant="outline" onClick={source.reload}>
- Try again
- </Button>
- </div>
- </Show>
- <Show when={source.loading()}>
- <p role="status" class="text-sm text-ink-muted">
- Loading scheduling…
- </p>
- </Show>
- <Show when={error()}>
- <p role="alert" class="text-sm text-failure">
- {error()}
- </p>
- </Show>
- <Show when={profile()}>
- {(p) => (
- <>
- <Show when={!editing()}>
- <Show when={page() === 'Event types'}>
- <EventTypesPanel
- events={p().eventTypes}
- canEdit={scope().canEdit}
- saving={source.saving()}
- onEdit={setEvent}
- onDuplicate={duplicate}
- link={(item) => capabilities.link(p(), item.slug)}
- onCopy={(item) =>
- void action(() => capabilities.copyLink(p(), item.slug))
- }
- onToggle={(item, enabled) =>
- void action(() =>
- save({
- ...p(),
- eventTypes: p().eventTypes.map((e) =>
- e.id === item.id ? { ...e, enabled } : e
- ),
- })
- )
- }
- onDelete={(item) =>
- void action(() =>
- save({
- ...p(),
- eventTypes: p().eventTypes.filter(
- (e) => e.id !== item.id
- ),
- })
- )
- }
- />
- </Show>
- <Show when={page() === 'Availability'}>
- <AvailabilityPanel
- profile={p()}
- canEdit={scope().canEdit}
- saving={source.saving()}
- onEdit={setSchedule}
- onDefault={(s) =>
- void action(() => save({ ...p(), defaultScheduleId: s.id }))
- }
- onDelete={(s) =>
- void action(async () => {
- if (p().eventTypes.some((e) => e.scheduleId === s.id))
- throw new Error(
- 'Move event types to another schedule first.'
- );
- const schedules = p().schedules.filter(
- (x) => x.id !== s.id
- );
- await save({
- ...p(),
- schedules,
- defaultScheduleId:
- p().defaultScheduleId === s.id
- ? (schedules[0]?.id ?? null)
- : p().defaultScheduleId,
- });
- })
- }
- />
- </Show>
- <Show when={page() === 'Bookings'}>
- <BookingsPanel
- bookings={source.bookings()}
- events={p().eventTypes}
- members={capabilities.members()}
- currentUserId={capabilities.userId()}
- canEdit={scope().canEdit}
- busyId={busyBooking()}
- onApprove={(id) =>
- void bookingAction(id, () => source.approve(id))
- }
- onCancel={(id) =>
- void bookingAction(id, () => source.cancel(id))
- }
- onManage={(id) =>
- void bookingAction(id, () => capabilities.manageBooking(id))
- }
- onAttendance={(id, attendance) =>
- void bookingAction(id, () =>
- source.setAttendance(id, attendance)
- )
- }
- />
- </Show>
- <Show when={page() === 'Insights'}>
- <Show when={scope().id} keyed>
- {(_scopeId) => (
- <InsightsView
- scopeSelector={
- <div class="w-48">
- <SelectInput
- label="Calendar owner"
- value={scope().id}
- options={capabilities
- .scopes()
- .map((s) => ({ value: s.id, label: s.name }))}
- onChange={changeScope}
- />
- </div>
- }
- source={source}
- events={p().eventTypes}
- members={capabilities.members()}
- timeZone={
- p().schedules.find(
- (s) => s.id === p().defaultScheduleId
- )?.timeZone ??
- p().schedules[0]?.timeZone ??
- Intl.DateTimeFormat().resolvedOptions().timeZone
- }
- />
- )}
- </Show>
- </Show>
- <Show when={page() === 'Teams'}>
- <div class="rounded-xl border border-edge-muted bg-panel">
- <div class="flex items-center justify-between border-b border-edge-muted bg-surface-1 px-6 py-5">
- <div>
- <h2 class="font-semibold">Your teams</h2>
- <p class="mt-1 text-sm text-ink-muted">
- Team links use your existing Macro memberships.
- </p>
- </div>
- <Button
- variant="outline"
- onClick={capabilities.openTeamSettings}
- >
- Manage teams
- </Button>
- </div>
- <For
- each={capabilities
- .scopes()
- .filter((s) => s.teamId && s.id === s.teamId)}
- fallback={
- <div class="flex flex-col items-center gap-3 p-12 text-center">
- <Users class="size-8 text-ink-muted" />
- <p class="font-medium">Bring your team together</p>
- <p class="text-sm text-ink-muted">
- Create or join a Macro team to offer collective and
- round-robin meetings.
- </p>
- <Button
- variant="strong"
- onClick={capabilities.openTeamSettings}
- >
- Open team settings
- </Button>
- </div>
- }
- >
- {(team) => (
- <div class="flex flex-wrap items-center justify-between gap-4 px-6 py-5">
- <div>
- <h3 class="font-semibold">{team.name}</h3>
- <p class="mt-1 text-sm text-ink-muted">
- {team.canEdit ? 'Owner or admin' : 'Team member'} ·
- Collective & round-robin scheduling
- </p>
- </div>
- <Button
- variant="outline"
- onClick={() => {
- changeScope(team.id);
- navigate('Event types');
- }}
- >
- View event types
- </Button>
- </div>
- )}
- </For>
- </div>
- <Show when={scope().teamId}>
- <div class="overflow-hidden rounded-xl border border-edge-muted">
- <div class="border-b border-edge-muted bg-surface-1 px-6 py-4">
- <h2 class="font-semibold">Team members</h2>
- <p class="mt-1 text-sm text-ink-muted">
- Hosts need a connected calendar. Their personal working
- hours are respected when configured.
- </p>
- </div>
- <For each={capabilities.members()}>
- {(member) => (
- <div class="flex items-center gap-3 border-b border-edge-muted px-6 py-4 last:border-b-0">
- <span class="flex size-9 items-center justify-center rounded-full bg-active text-sm font-medium">
- {member.name.slice(0, 1).toUpperCase()}
- </span>
- <div>
- <p class="text-sm font-medium">{member.name}</p>
- <p class="text-xs text-ink-muted">{member.email}</p>
- </div>
- </div>
- )}
- </For>
- </div>
- </Show>
- </Show>
- <Show when={page() === 'Booking page'}>
- <div class="grid gap-6 @min-[850px]:grid-cols-[1fr_320px]">
- <div class="flex flex-col gap-6 rounded-xl border border-edge-muted p-6">
- <Field label="Display name">
- <TextInput
- disabled={!scope().canEdit}
- value={profileDraft()?.name ?? p().name}
- onInput={(e) =>
- setProfileDraft({
- name: e.currentTarget.value,
- description:
- profileDraft()?.description ?? p().description,
- })
- }
- />
- </Field>
- <Field label="Introduction">
- <TextArea
- disabled={!scope().canEdit}
- value={profileDraft()?.description ?? p().description}
- onInput={(e) =>
- setProfileDraft({
- name: profileDraft()?.name ?? p().name,
- description: e.currentTarget.value,
- })
- }
- />
- </Field>
- <Button
- class="self-start"
- variant="strong"
- disabled={
- !scope().canEdit || !profileDraft() || source.saving()
- }
- onClick={() =>
- void action(async () => {
- await save({ ...p(), ...profileDraft() });
- setProfileDraft(undefined);
- })
- }
- >
- Save booking page
- </Button>
- </div>
- <aside class="rounded-xl border border-edge-muted bg-surface-1 p-6">
- <p class="text-xs font-medium uppercase tracking-wide text-ink-muted">
- Preview
- </p>
- <span class="mt-6 flex size-12 items-center justify-center rounded-full bg-active text-lg font-semibold">
- {(profileDraft()?.name ?? p().name).slice(0, 1)}
- </span>
- <h2 class="mt-4 font-semibold">
- {profileDraft()?.name ?? p().name}
- </h2>
- <p class="mt-2 whitespace-pre-wrap text-sm text-ink-muted">
- {profileDraft()?.description ?? p().description}
- </p>
- <Show when={p().revision > 0}>
- <a
- class="mt-6 inline-block text-sm underline underline-offset-4"
- href={capabilities.link(p())}
- target="_blank"
- rel="noopener noreferrer"
- >
- View public page ↗
- </a>
- </Show>
- </aside>
- </div>
- </Show>
- </Show>
- <Show when={event()} keyed>
- {(value) => (
- <EventEditor
- event={value}
- events={p().eventTypes}
- schedules={p().schedules}
- members={capabilities.members()}
- team={!!scope().teamId}
- saving={source.saving()}
- onCancel={() => setEvent(undefined)}
- onSave={async (next) => {
- const exists = p().eventTypes.some((e) => e.id === next.id);
- await save({
- ...p(),
- eventTypes: exists
- ? p().eventTypes.map((e) =>
- e.id === next.id ? next : e
- )
- : [...p().eventTypes, next],
- });
- if (event()?.id === next.id) setEvent(undefined);
- }}
- />
- )}
- </Show>
- <Show when={schedule()} keyed>
- {(value) => (
- <ScheduleEditor
- schedule={value}
- saving={source.saving()}
- onCancel={() => setSchedule(undefined)}
- onSave={async (next) => {
- const exists = p().schedules.some((s) => s.id === next.id);
- await save({
- ...p(),
- defaultScheduleId:
- p().defaultScheduleId ??
- p().schedules[0]?.id ??
- next.id,
- schedules: exists
- ? p().schedules.map((s) =>
- s.id === next.id ? next : s
- )
- : [...p().schedules, next],
- });
- if (schedule()?.id === next.id) setSchedule(undefined);
- }}
- />
- )}
- </Show>
- </>
- )}
- </Show>
- </SchedulingWorkspace>
+ {section('bookings')}
+ </SettingsSection>
+ <SettingsSection
+ title="Insights"
+ description="See how your personal and team booking links are being used."
+ >
+ {section('insights')}
+ </SettingsSection>
+ </SettingsPage>
);
}
diff --git a/apps/web/src/features/scheduling/vitest.config.ts b/apps/web/src/features/scheduling/vitest.config.ts
index f3646196dc..979759d7e2 100644
--- a/apps/web/src/features/scheduling/vitest.config.ts
+++ b/apps/web/src/features/scheduling/vitest.config.ts
@@ -1,11 +1,16 @@
import { fileURLToPath } from 'node:url';
import solidPlugin from 'vite-plugin-solid';
+import solidSvg from 'vite-plugin-solid-svg';
import tsconfigPaths from 'vite-tsconfig-paths';
import { defineConfig } from 'vitest/config';
export default defineConfig({
root: fileURLToPath(new URL('../../..', import.meta.url)),
- plugins: [tsconfigPaths(), solidPlugin()],
+ plugins: [
+ tsconfigPaths(),
+ solidPlugin(),
+ solidSvg({ defaultAsComponent: true }),
+ ],
ssr: { resolve: { conditions: ['browser', 'development'] } },
test: {
name: 'scheduling',
diff --git a/apps/web/src/features/settings/Account.tsx b/apps/web/src/features/settings/Account.tsx
index a665d74d9e..0a59f2f07c 100644
--- a/apps/web/src/features/settings/Account.tsx
+++ b/apps/web/src/features/settings/Account.tsx
@@ -407,7 +407,7 @@ export function Account() {
return (
<SettingsPage title="Account">
- <SettingsSection>
+ <SettingsSection title="Profile">
<SettingsCard>
<Show when={ENABLE_PROFILE_PICTURES}>
<Show when={userId()} keyed>
@@ -645,13 +645,8 @@ export function Account() {
);
}
-function Row(props: { label: string; children?: any }) {
- return (
- <div class="bg-surface flex items-center justify-between gap-4 min-h-15.25 px-6 py-3">
- <div class="text-sm">{props.label}</div>
- <div class="text-right">{props.children}</div>
- </div>
- );
+function Row(props: { label: string; children?: JSX.Element }) {
+ return <SettingsRow label={props.label}>{props.children}</SettingsRow>;
}
function NotificationToggle() {
diff --git a/apps/web/src/features/settings/Agent.tsx b/apps/web/src/features/settings/Agent.tsx
index 3027b36012..b0fe6980fa 100644
--- a/apps/web/src/features/settings/Agent.tsx
+++ b/apps/web/src/features/settings/Agent.tsx
@@ -1,5 +1,5 @@
import { McpSetupCards } from '@core/component/AI/component/McpSetupCards';
-import { SettingsPage } from './primitives';
+import { SettingsPage, SettingsSection } from './primitives';
/**
* The "MCP server" tab: setup instructions for pointing other agents and MCP
@@ -13,7 +13,9 @@ export function Agent() {
title="Macro MCP server"
description="Connect other agents and tools to your Macro workspace."
>
- <McpSetupCards class="max-w-none" />
+ <SettingsSection title="Connect a client">
+ <McpSetupCards class="max-w-none" />
+ </SettingsSection>
</SettingsPage>
);
}
diff --git a/apps/web/src/features/settings/Agents.tsx b/apps/web/src/features/settings/Agents.tsx
index 3a838ac6df..4c916b7847 100644
--- a/apps/web/src/features/settings/Agents.tsx
+++ b/apps/web/src/features/settings/Agents.tsx
@@ -1220,15 +1220,9 @@ function AgentFormSection(props: {
children: import('solid-js').JSX.Element;
}) {
return (
- <section>
- <div class="mb-2 px-1">
- <h2 class="text-sm font-semibold text-ink">{props.title}</h2>
- <p class="mt-0.5 text-xs text-ink-muted">{props.description}</p>
- </div>
- <div class="rounded-xl border border-ink/[0.06] bg-surface-2 p-4">
- {props.children}
- </div>
- </section>
+ <SettingsSection title={props.title} description={props.description}>
+ <div class="pt-2">{props.children}</div>
+ </SettingsSection>
);
}
diff --git a/apps/web/src/features/settings/Appearance.tsx b/apps/web/src/features/settings/Appearance.tsx
index 3c18b35a47..6aea9e607f 100644
--- a/apps/web/src/features/settings/Appearance.tsx
+++ b/apps/web/src/features/settings/Appearance.tsx
@@ -1,6 +1,5 @@
import { toast } from '@core/component/Toast/Toast';
import { DropdownMenu as KobalteDropdownMenu } from '@kobalte/core/dropdown-menu';
-import CheckIcon from '@phosphor/check.svg';
import ClipboardIcon from '@phosphor/clipboard.svg';
import PencilIcon from '@phosphor/pencil-simple.svg';
import PlusIcon from '@phosphor/plus.svg';
@@ -17,7 +16,6 @@ import {
setIsThemeSaved,
setLightModeTheme,
setThemeMode,
- systemMode,
themeMode,
themes,
userThemes,
@@ -29,7 +27,6 @@ import {
deleteTheme,
exportTheme,
getLiveTheme,
- pinTheme,
previewTheme,
resolveActiveThemeId,
saveTheme,
@@ -43,6 +40,7 @@ import {
tooltipsEnabled,
} from '@ui/signals/signals';
import { createSignal, For, Show } from 'solid-js';
+import { AppearanceModePicker } from './components/appearance-mode-picker';
import {
SettingsCard,
SettingsPage,
@@ -57,7 +55,7 @@ function CopyThemeButton(props: { themeId: string; name: string }) {
<button
type="button"
aria-label={`Copy ${props.name}`}
- class="rounded p-0.5 hover:text-ink touch:p-1.5"
+ class="inline-flex items-center justify-center rounded-lg p-0.5 hover:bg-ink/5 hover:text-ink focus-visible:outline-2 focus-visible:outline-accent touch:p-1.5"
onPointerDown={(e) => e.stopPropagation()}
onPointerUp={(e) => e.stopPropagation()}
onClick={(e) => {
@@ -80,7 +78,7 @@ function EditThemeButton(props: { name: string; onEdit: () => void }) {
<button
type="button"
aria-label={`Edit ${props.name}`}
- class="rounded p-0.5 hover:text-ink touch:p-1.5"
+ class="inline-flex items-center justify-center rounded-lg p-0.5 hover:bg-ink/5 hover:text-ink focus-visible:outline-2 focus-visible:outline-accent touch:p-1.5"
onClick={(e) => {
e.preventDefault();
e.stopPropagation();
@@ -104,7 +102,7 @@ function ThemePillActions(props: {
onEdit: () => void;
}) {
return (
- <span class="flex shrink-0 items-center gap-0.5 text-ink-extra-muted">
+ <span class="flex shrink-0 items-center text-ink/50 [&_button]:size-8 [&_svg]:size-4">
<EditThemeButton name={props.name} onEdit={props.onEdit} />
<CopyThemeButton themeId={props.themeId} name={props.name} />
</span>
@@ -347,7 +345,7 @@ function InterfaceThemeSelect(props: {
);
return (
- <div class="flex items-center gap-1">
+ <div class="flex items-center gap-2">
<Dropdown
open={open()}
onOpenChange={(isOpen) => {
@@ -359,8 +357,9 @@ function InterfaceThemeSelect(props: {
>
<KobalteDropdownMenu.Trigger
as={ThemeChipPill}
- class="h-auto text-xs rounded-lg border border-edge-muted py-1 pl-1 pr-1.5 hover:bg-ink/4"
+ class="h-9 w-52 gap-2 text-sm rounded-lg border-1 border-ink/8 bg-transparent px-1.5 hover:bg-ink/4 focus-visible:outline-2 focus-visible:outline-accent"
caret
+ maxLabelWidth="flex-1 text-left"
// With no stored theme selected (e.g. the active theme was just
// deleted), fall back to the live tokens so the swatch still reflects
// the current colors and the label reads "Unsaved Theme".
@@ -464,217 +463,62 @@ function InterfaceThemeSelect(props: {
);
}
-/** Sentinel radio value for the "follow the OS" option, distinct from any
- * theme id (theme ids are default names or UUIDs, never "system"). */
-const SYSTEM_VALUE = 'system';
-
-/**
- * The "Active theme" picker: a chip showing the currently-active theme that
- * opens a dropdown to either follow the OS ("System preference") or pin a
- * specific theme by name. Replaces the old segmented control. Hovering an option
- * previews it live (reverted on close); picking commits via the callbacks.
- * System preference shows a swatch of whatever the OS scheme currently resolves
- * to, so the user sees the theme it would apply.
- */
-function ActiveThemeSelect(props: {
- onChooseTheme: (theme: ThemeV3) => void;
- onChooseSystem: () => void;
-}) {
- const [open, setOpen] = createSignal(false);
-
- // The theme the OS scheme currently resolves to (for the System preference
- // swatch). Falls back to the live tokens so a swatch always renders.
- const systemTheme = (): ThemeV3 => {
- const id = systemMode() === 'dark' ? darkModeTheme() : lightModeTheme();
- return themes().find((theme) => theme.id === id) ?? getLiveTheme();
- };
-
- // The active theme shown on the chip: the OS-resolved theme in system mode,
- // otherwise the pinned theme (via resolveActiveThemeId).
- const activeTheme = (): ThemeV3 =>
- themes().find((theme) => theme.id === resolveActiveThemeId()) ??
- getLiveTheme();
-
- // The checked radio value: the sentinel in system mode, else the active
- // theme's id.
- const selectedValue = () =>
- themeMode() === 'system' ? SYSTEM_VALUE : resolveActiveThemeId();
-
- const onChange = (value: string) => {
- if (value === SYSTEM_VALUE) {
- props.onChooseSystem();
- return;
- }
- const theme = themes().find((t) => t.id === value);
- if (theme) props.onChooseTheme(theme);
- };
-
- return (
- <Dropdown
- // Right-align the menu's edge with the (right-aligned) chip pill.
- placement="bottom-end"
- open={open()}
- onOpenChange={(isOpen) => {
- setOpen(isOpen);
- // Closing without picking reverts the hover preview; a pick commits via
- // applyTheme first, which makes this a no-op.
- if (!isOpen) clearThemePreview();
- }}
- >
- <KobalteDropdownMenu.Trigger
- as={ThemeChipPill}
- class="h-auto text-xs rounded-lg border border-edge-muted py-1 pl-1 pr-1.5 hover:bg-ink/4"
- caret
- // Let "System preference" display in full rather than truncating.
- maxLabelWidth="max-w-none"
- theme={activeTheme()}
- name={
- themeMode() === 'system' ? 'System preference' : activeTheme().name
- }
- />
- <Dropdown.Content
- as="div"
- class="w-56 overflow-hidden border border-ink/[0.05] bg-surface shadow-menu"
- onMouseLeave={clearThemePreview}
- >
- <Layer depth={3}>
- <Dropdown.RadioGroup value={selectedValue()} onChange={onChange}>
- <div class="bg-surface p-1.5">
- <Dropdown.RadioItem
- value={SYSTEM_VALUE}
- class="justify-between"
- closeOnSelect
- onFocus={() => previewTheme(systemTheme().id)}
- >
- <span class="flex min-w-0 flex-1 items-center gap-2">
- <ThemeChips theme={systemTheme()} size="sm" />
- <span class="flex min-w-0 flex-col">
- <span class="truncate">System preference</span>
- <span class="text-xs text-ink-extra-muted">
- Currently {systemMode() === 'dark' ? 'Dark' : 'Light'}
- </span>
- </span>
- </span>
- <Dropdown.ItemIndicator class="shrink-0">
- <CheckIcon class="size-3.5 text-accent" />
- </Dropdown.ItemIndicator>
- </Dropdown.RadioItem>
- </div>
- <Dropdown.Separator class="h-px border-0 bg-edge-muted" />
- <div class="max-h-64 overflow-y-auto bg-surface p-1.5">
- <For each={themes()}>
- {(theme) => (
- <Dropdown.RadioItem
- value={theme.id}
- class="justify-between"
- closeOnSelect
- onFocus={() => previewTheme(theme.id)}
- >
- <span class="flex min-w-0 flex-1 items-center gap-2">
- <ThemeChips theme={theme} size="sm" />
- <span class="truncate">{theme.name}</span>
- </span>
- <Dropdown.ItemIndicator class="shrink-0">
- <CheckIcon class="size-3.5 text-accent" />
- </Dropdown.ItemIndicator>
- </Dropdown.RadioItem>
- )}
- </For>
- </div>
- </Dropdown.RadioGroup>
- </Layer>
- </Dropdown.Content>
- </Dropdown>
- );
-}
-
-/**
- * The full "Active theme" row: the picker chip plus copy/edit affordances for
- * the active theme and its own inline theme editor (opened by the edit button),
- * mirroring the per-mode ThemeSelectorRow. Picking a theme pins it — the mode
- * follows the theme's intrinsic light/dark and it becomes that mode's stored
- * theme, so resolveActiveThemeId / systemThemeEffect apply it live.
- */
-function ActiveThemeRow() {
- // Saving a new theme from the editor pins it as the active theme.
- const editor = createThemeEditorController((id) => {
- const theme = themes().find((t) => t.id === id);
- if (theme) pinTheme(theme);
- });
-
- const activeName = () =>
- themes().find((theme) => theme.id === resolveActiveThemeId())?.name ??
- 'Unsaved Theme';
-
- return (
- <>
- <SettingsRow
- label="Active theme"
- description="Match your system, or always use light or dark."
- stackOnNarrow
- >
- <div class="flex items-center gap-1">
- <ActiveThemeSelect
- // Pin + commit + close any open editor, via the shared controller.
- onChooseTheme={(theme) => editor.chooseTheme(theme.id)}
- onChooseSystem={() => {
- setThemeMode('system');
- editor.discardAndCloseEditor();
- }}
- />
- <ThemePillActions
- themeId={resolveActiveThemeId()}
- name={activeName()}
- onEdit={() =>
- editor.editorOpen()
- ? editor.discardAndCloseEditor()
- : editor.editTheme(resolveActiveThemeId())
- }
- />
- </div>
- </SettingsRow>
-
- <Show when={editor.editorOpen()}>
- <ThemeEditor
- name={editor.themeName()}
- onNameChange={editor.setThemeName}
- onClose={editor.discardAndCloseEditor}
- onSave={editor.saveCurrentTheme}
- />
- </Show>
- </>
- );
-}
-
export function Appearance() {
+ const modeTheme = (mode: 'light' | 'dark') =>
+ themes().find(
+ (theme) =>
+ theme.id === (mode === 'light' ? lightModeTheme() : darkModeTheme())
+ ) ?? DEFAULT_THEMES.find((theme) => theme.mode === mode)!;
return (
<div class="h-full">
<SettingsPage title="Appearance">
- <SettingsSection title="Color Theme">
- {/* Establish a container so the rows can stack (label/description over
- the picker) when the panel is narrower than 460px. */}
+ <SettingsSection
+ title="Color Theme"
+ description="Choose how Macro looks on your screen."
+ >
+ <div
+ class="mx-auto w-full max-w-lg py-4"
+ data-settings-target="active-theme"
+ >
+ <AppearanceModePicker
+ value={themeMode()}
+ lightTheme={modeTheme('light')}
+ darkTheme={modeTheme('dark')}
+ onChange={(mode) => {
+ setThemeMode(mode);
+ applyTheme(resolveActiveThemeId());
+ }}
+ />
+ <p class="mt-4 text-center text-xs text-ink-muted">
+ {themeMode() === 'system'
+ ? 'Switches between your light and dark themes with your device.'
+ : `Always use your ${themeMode()} theme.`}
+ </p>
+ </div>
<SettingsCard class="@container">
- {/* Active theme: pin a specific theme by name, or follow the OS. */}
- <ActiveThemeRow />
-
- {/* When following the OS, these pick which theme each system scheme
- maps to. Hidden when a specific theme is pinned (Active theme
- isn't System preference), since it fully determines the look. */}
- <Show when={themeMode() === 'system'}>
- <ThemeSelectorRow
- label="Light theme"
- description="Used when your system is set to light."
- value={lightModeTheme}
- onSelect={setLightModeTheme}
- filter={(theme) => theme.mode === 'light'}
- />
- <ThemeSelectorRow
- label="Dark theme"
- description="Used when your system is set to dark."
- value={darkModeTheme}
- onSelect={setDarkModeTheme}
- filter={(theme) => theme.mode === 'dark'}
- />
+ <Show when={themeMode()} keyed>
+ {(mode) => (
+ <>
+ <Show when={mode !== 'dark'}>
+ <ThemeSelectorRow
+ label="Light theme"
+ description="Colors and style for light mode."
+ value={lightModeTheme}
+ onSelect={setLightModeTheme}
+ filter={(theme) => theme.mode === 'light'}
+ />
+ </Show>
+ <Show when={mode !== 'light'}>
+ <ThemeSelectorRow
+ label="Dark theme"
+ description="Colors and style for dark mode."
+ value={darkModeTheme}
+ onSelect={setDarkModeTheme}
+ filter={(theme) => theme.mode === 'dark'}
+ />
+ </Show>
+ </>
+ )}
</Show>
</SettingsCard>
</SettingsSection>
@@ -687,6 +531,7 @@ export function Appearance() {
>
<ToggleSwitch
size="md"
+ aria-label="Monochrome icons"
onChange={setMonochromeIcons}
checked={monochromeIcons()}
/>
@@ -697,6 +542,7 @@ export function Appearance() {
>
<ToggleSwitch
size="md"
+ aria-label="Show tooltips"
onChange={setTooltipsEnabled}
checked={tooltipsEnabled()}
/>
diff --git a/apps/web/src/features/settings/Billing.test.tsx b/apps/web/src/features/settings/Billing.test.tsx
index c54dfadcbc..6fc2203fd7 100644
--- a/apps/web/src/features/settings/Billing.test.tsx
+++ b/apps/web/src/features/settings/Billing.test.tsx
@@ -86,6 +86,9 @@ vi.mock('./AiUsage', () => ({
vi.mock('@ui', () => ({
cn: (...values: unknown[]) => values.filter(Boolean).join(' '),
Layer: (props: { children: JSX.Element }) => <>{props.children}</>,
+ ComposerSurface: (props: { children: JSX.Element; class?: string }) => (
+ <div class={props.class}>{props.children}</div>
+ ),
Button: (props: JSX.ButtonHTMLAttributes<HTMLButtonElement>) => (
<button type="button" onClick={props.onClick}>
{props.children}
diff --git a/apps/web/src/features/settings/Billing.tsx b/apps/web/src/features/settings/Billing.tsx
index d750efd8b0..12ab07b3b3 100644
--- a/apps/web/src/features/settings/Billing.tsx
+++ b/apps/web/src/features/settings/Billing.tsx
@@ -190,7 +190,7 @@ export const Billing = () => {
</>
}
>
- <SettingsSection>
+ <SettingsSection title="Subscription">
<SettingsCard>
<section class="flex flex-col gap-4 p-4">
<header class="flex items-center gap-2">
diff --git a/apps/web/src/features/settings/ConnectedAccounts.tsx b/apps/web/src/features/settings/ConnectedAccounts.tsx
index 88f41e32b4..4055d22018 100644
--- a/apps/web/src/features/settings/ConnectedAccounts.tsx
+++ b/apps/web/src/features/settings/ConnectedAccounts.tsx
@@ -1,11 +1,21 @@
import { ENABLE_EMAIL } from '@core/constant/featureFlags';
+import { useSettingsState } from '@core/constant/SettingsState';
+import { useSettingsTabAvailable } from '@core/constant/settingsTabsConfig';
+import { Button } from '@ui';
import { Show, Suspense } from 'solid-js';
import { EmailCard } from './Email';
import { GitHubCard } from './GitHub';
-import { SettingsPage, SettingsSection } from './primitives';
+import {
+ SettingsCard,
+ SettingsPage,
+ SettingsRow,
+ SettingsSection,
+} from './primitives';
/** Personal account links. Agent MCP integrations live in Connections. */
export function ConnectedAccounts() {
+ const { openSettings } = useSettingsState();
+ const isAvailable = useSettingsTabAvailable();
return (
<SettingsPage
title="Integrations"
@@ -23,6 +33,44 @@ export function ConnectedAccounts() {
</Suspense>
</div>
</SettingsSection>
+ <SettingsSection
+ title="Related settings"
+ description="Manage the same accounts where you use them."
+ >
+ <SettingsCard>
+ <Show when={ENABLE_EMAIL}>
+ <SettingsRow label="Email accounts and signatures">
+ <Button
+ variant="ghost"
+ size="sm"
+ onClick={() => openSettings('Email')}
+ >
+ Email settings
+ </Button>
+ </SettingsRow>
+ </Show>
+ <Show when={isAvailable('Calendar')}>
+ <SettingsRow label="Calendar connections and colors">
+ <Button
+ variant="ghost"
+ size="sm"
+ onClick={() => openSettings('Calendar')}
+ >
+ Calendar settings
+ </Button>
+ </SettingsRow>
+ </Show>
+ <SettingsRow label="Apps and tools for agents">
+ <Button
+ variant="ghost"
+ size="sm"
+ onClick={() => openSettings('Connections')}
+ >
+ Agent connections
+ </Button>
+ </SettingsRow>
+ </SettingsCard>
+ </SettingsSection>
</SettingsPage>
);
}
diff --git a/apps/web/src/features/settings/Email.tsx b/apps/web/src/features/settings/Email.tsx
index d6c9f77e1f..fc128bec75 100644
--- a/apps/web/src/features/settings/Email.tsx
+++ b/apps/web/src/features/settings/Email.tsx
@@ -9,7 +9,6 @@ import { toast } from '@core/component/Toast/Toast';
import {
ENABLE_INBOX_RESYNC,
ENABLE_INBOX_SYNC_STATUS,
- enableEmailSignatures,
enableMultiInbox,
} from '@core/constant/featureFlags';
import { useEmail, useUserId } from '@core/context/user';
@@ -22,13 +21,10 @@ import {
calendarConsentScopes,
reconnectScopes,
} from '@core/email-link/consent';
-import { registerHotkey, useHotkeyDOMScope } from '@core/hotkey/hotkeys';
import GmailIcon from '@icon/mcp-gmail.svg';
import ArrowsClockwiseIcon from '@phosphor-icons/core/regular/arrows-clockwise.svg?component-solid';
import CalendarSlashIcon from '@phosphor-icons/core/regular/calendar-slash.svg?component-solid';
import PlusIcon from '@phosphor-icons/core/regular/plus.svg?component-solid';
-import SignatureIcon from '@phosphor-icons/core/regular/signature.svg?component-solid';
-import TrashIcon from '@phosphor-icons/core/regular/trash.svg?component-solid';
import {
type BackfillProgress,
estimateEtaSeconds,
@@ -42,17 +38,17 @@ import {
type Link as EmailLink,
SyncStatus,
} from '@service-email/generated/schemas';
-import { Button, Dialog, Panel, Tooltip } from '@ui';
+import { Dialog, Panel, Tooltip } from '@ui';
import { createMemo, createSignal, For, Match, Show, Switch } from 'solid-js';
import { match } from 'ts-pattern';
import { ConnectAction, StatusDot } from './integration-ui';
-import { IntegrationRow, SettingsCard, SettingsRow } from './primitives';
import {
- clearSignatureState,
- isSignatureExpanded,
- SignatureSection,
- toggleSignatureExpanded,
-} from './SignatureSection';
+ SettingsButton as Button,
+ IntegrationRow,
+ SettingsCard,
+ SettingsRow,
+} from './primitives';
+import { clearSignatureState } from './SignatureSection';
/**
* Gmail integration as a single Connected-accounts card: a header row with the
@@ -78,7 +74,9 @@ export function EmailCard() {
// as "complete").
const latestBackfillByLinkId = createMemo(() => {
const latest = new Map<string, BackfillJob>();
- for (const job of backfillJobsQuery.data?.jobs ?? []) {
+ for (const job of backfillJobsQuery.isSuccess
+ ? backfillJobsQuery.data.jobs
+ : []) {
if (job.link_id && !latest.has(job.link_id)) {
latest.set(job.link_id, job);
}
@@ -110,7 +108,7 @@ export function EmailCard() {
// The primary inbox is the user's own is_primary link; it sorts to the top
// and is labelled. Everything else (other own inboxes + delegated/shared) follows.
const inboxes = createMemo(() => {
- const links = emailLinksQuery.data?.links ?? [];
+ const links = emailLinksQuery.isSuccess ? emailLinksQuery.data.links : [];
const uid = userId();
const primary = links.find(
(link) => link.is_primary && link.macro_id === uid
@@ -266,12 +264,13 @@ export function EmailCard() {
<Tooltip label="Add inbox">
<Button
variant="outline"
- size="icon-sm"
+ size="md"
depth={3}
aria-label="Add inbox"
onClick={openAddInboxDialog}
>
- <PlusIcon class="size-4" />
+ <PlusIcon class="size-3.5" />
+ Add account
</Button>
</Tooltip>
</SettingsRow>
@@ -406,7 +405,7 @@ function Chip(props: { label: string }) {
// flow, which re-links and backfills.
function DisabledPrimaryRow(props: { email: string; onEnable: () => void }) {
return (
- <div class="bg-surface flex items-center justify-between gap-3 h-15.25 px-6">
+ <div class="flex items-center justify-between gap-3 min-h-16 px-4 py-4">
<div class="min-w-0 flex flex-col gap-0.5">
<div class="flex items-center gap-2 min-w-0">
<span class="ph-no-capture text-sm truncate text-ink-muted">
@@ -417,7 +416,7 @@ function DisabledPrimaryRow(props: { email: string; onEnable: () => void }) {
</div>
<span class="text-xs text-ink-muted">Sync disabled</span>
</div>
- <Button variant="outline" size="sm" depth={3} onClick={props.onEnable}>
+ <Button variant="outline" size="md" depth={3} onClick={props.onEnable}>
Enable
</Button>
</div>
@@ -436,32 +435,10 @@ function InboxRow(props: {
onRemove: () => void;
onTurnOffCalendar: () => void;
}) {
- const emailSignaturesFlag = useFeatureFlag(enableEmailSignatures);
const calendarUiEnabled = useCalendarUiFlag();
- const showSignature = () => isSignatureExpanded(props.link.id);
- const signatureSectionId = `signature-section-${props.link.id}`;
- const [attachHotkeys, signatureHotkeyScope] =
- useHotkeyDOMScope('email-signature');
- let signatureTrigger: HTMLButtonElement | undefined;
- const closeSignature = () => {
- if (!showSignature()) return;
- toggleSignatureExpanded(props.link.id);
- signatureTrigger?.focus();
- };
- registerHotkey({
- scopeId: signatureHotkeyScope,
- hotkey: 'escape',
- description: 'Close signature editor',
- condition: showSignature,
- runWithInputFocused: true,
- keyDownHandler: () => {
- closeSignature();
- return true;
- },
- });
return (
- <div class="bg-surface flex flex-col" ref={attachHotkeys}>
- <div class="flex items-center justify-between gap-3 min-h-15.25 py-2 px-6">
+ <div class="flex flex-col">
+ <div class="flex flex-wrap items-center justify-between gap-3 min-h-15.25 py-4 px-4">
<div class="min-w-0 flex flex-col gap-0.5">
<div class="flex items-center gap-2 min-w-0">
<span class="ph-no-capture text-sm truncate">
@@ -516,27 +493,11 @@ function InboxRow(props: {
</Switch>
</Show>
</div>
- <div class="flex items-center gap-2 shrink-0">
- <Show when={emailSignaturesFlag().enabled && props.isOwn}>
- <Tooltip label="Edit signature">
- <Button
- variant="outline"
- size="icon-sm"
- depth={3}
- ref={signatureTrigger}
- onClick={() => toggleSignatureExpanded(props.link.id)}
- aria-label={`Edit signature for ${props.link.email_address}`}
- aria-expanded={showSignature()}
- aria-controls={signatureSectionId}
- >
- <SignatureIcon class="size-4" />
- </Button>
- </Tooltip>
- </Show>
+ <div class="flex flex-wrap items-center gap-2 shrink-0">
<Show when={props.link.needs_reauth}>
<Button
variant="accent"
- size="sm"
+ size="md"
depth={3}
onClick={props.onReconnect}
aria-label={`Reconnect ${props.link.email_address}`}
@@ -550,8 +511,8 @@ function InboxRow(props: {
when={calendarUiEnabled() && props.link.needs_calendar_permission}
>
<Button
- variant="accent"
- size="sm"
+ variant="outline"
+ size="md"
depth={3}
onClick={props.onEnableCalendar}
aria-label={`Enable calendar for ${props.link.email_address}`}
@@ -604,24 +565,17 @@ function InboxRow(props: {
</Show>
<Tooltip label="Remove inbox">
<Button
- variant="outline"
- size="icon-sm"
+ variant="ghost"
+ size="md"
depth={3}
onClick={props.onRemove}
aria-label={`Remove ${props.link.email_address}`}
>
- <TrashIcon class="size-4" />
+ Remove
</Button>
</Tooltip>
</div>
</div>
- <Show
- when={emailSignaturesFlag().enabled && props.isOwn && showSignature()}
- >
- <div id={signatureSectionId} class="px-6 pb-4">
- <SignatureSection link={props.link} onClose={closeSignature} />
- </div>
- </Show>
</div>
);
}
diff --git a/apps/web/src/features/settings/McpConnections.tsx b/apps/web/src/features/settings/McpConnections.tsx
index 5e1109eef4..bb40d0aafc 100644
--- a/apps/web/src/features/settings/McpConnections.tsx
+++ b/apps/web/src/features/settings/McpConnections.tsx
@@ -14,7 +14,7 @@ export function McpConnections() {
when={pipedreamMcp()}
fallback={
<SettingsPage
- title="Connections"
+ title="Agent connections"
description="Connect the tools your team already uses so Macro's agent can work in them."
>
<Suspense>
diff --git a/apps/web/src/features/settings/MobileSettings.tsx b/apps/web/src/features/settings/MobileSettings.tsx
index 641b50627c..18263d8866 100644
--- a/apps/web/src/features/settings/MobileSettings.tsx
+++ b/apps/web/src/features/settings/MobileSettings.tsx
@@ -1,5 +1,7 @@
+import { useFeatureFlag } from '@app/lib/analytics/posthog';
import { useLogout } from '@core/auth/logout';
import { UserIcon } from '@core/component/UserIcon';
+import { enableEmailSignatures } from '@core/constant/featureFlags';
import { useSettingsTabs } from '@core/constant/settingsTabsConfig';
import { useEmail, useUserId } from '@core/context/user';
import { isRealNamePart, useOwnUserName } from '@queries/auth/user-name-self';
@@ -10,7 +12,8 @@ import { SettingsTabContent } from './SettingsTabContent';
export function MobileSettings() {
const settings = useMobileSettings();
- const { groups } = useSettingsTabs();
+ const signatures = useFeatureFlag(enableEmailSignatures);
+ const { groups, searchGroups } = useSettingsTabs();
const userId = useUserId();
const email = useEmail();
const name = useOwnUserName();
@@ -23,27 +26,14 @@ export function MobileSettings() {
'Your account'
);
};
- const mobileGroups = () => {
- const general =
- groups().find((group) => group.label === 'General')?.items ?? [];
- const preferences = general.filter((item) =>
- ['Appearance', 'Notifications'].includes(item.tab)
- );
- return [
- {
- label: 'Account',
- items: general.filter((item) => !preferences.includes(item)),
- },
- { label: 'Preferences', items: preferences },
- ...groups().filter((group) => group.label !== 'General'),
- ].filter((group) => group.items.length > 0);
- };
return (
<MobileSettingsSheet
open={settings.open()}
page={settings.page()}
- groups={mobileGroups()}
+ groups={groups()}
+ searchGroups={searchGroups()}
+ emailSignatures={signatures().enabled}
name={displayName()}
email={email() ?? ''}
avatar={
diff --git a/apps/web/src/features/settings/MobileSettingsSheet.test.tsx b/apps/web/src/features/settings/MobileSettingsSheet.test.tsx
index f902155093..712fe88f01 100644
--- a/apps/web/src/features/settings/MobileSettingsSheet.test.tsx
+++ b/apps/web/src/features/settings/MobileSettingsSheet.test.tsx
@@ -18,6 +18,7 @@ vi.mock('@core/mobile/virtualKeyboard', () => ({
vi.mock('@ui', () => ({
cn: (...values: unknown[]) => values.filter(Boolean).join(' '),
Layer: (props: ParentProps) => props.children,
+ Surface: (props: ParentProps) => <div>{props.children}</div>,
Button: (props: JSX.ButtonHTMLAttributes<HTMLButtonElement>) => (
<button {...props} />
),
diff --git a/apps/web/src/features/settings/MobileSettingsSheet.tsx b/apps/web/src/features/settings/MobileSettingsSheet.tsx
index 8140362a04..cb8037617b 100644
--- a/apps/web/src/features/settings/MobileSettingsSheet.tsx
+++ b/apps/web/src/features/settings/MobileSettingsSheet.tsx
@@ -1,4 +1,5 @@
import './MobileSettingsSheet.css';
+import { SearchBar } from '@app/components/view-shell';
import { MobileDrawer } from '@components/app/mobile/MobileDrawer';
import type { SettingsTab } from '@core/constant/SettingsState';
import type { SettingsTabGroup } from '@core/constant/settingsTabsConfig';
@@ -8,14 +9,30 @@ import PencilIcon from '@phosphor/pencil-simple.svg';
import SignOutIcon from '@phosphor/sign-out.svg';
import XIcon from '@phosphor/x.svg';
import { Button } from '@ui';
-import { ErrorBoundary, For, type JSX, Show, Suspense } from 'solid-js';
+import {
+ createMemo,
+ createSignal,
+ ErrorBoundary,
+ For,
+ type JSX,
+ Show,
+ Suspense,
+} from 'solid-js';
import { Dynamic } from 'solid-js/web';
+import { SettingsSearchResults } from './components/settings-search-results';
+import { SettingsSearchTarget } from './components/settings-search-target';
+import {
+ type SettingsSearchResult,
+ searchSettings,
+} from './core/settings-search';
import { SettingsSheetContext } from './primitives';
type MobileSettingsSheetProps = {
open: boolean;
page?: SettingsTab;
groups: SettingsTabGroup[];
+ searchGroups?: SettingsTabGroup[];
+ emailSignatures?: boolean;
name: string;
email: string;
avatar: JSX.Element;
@@ -27,25 +44,32 @@ type MobileSettingsSheetProps = {
/** Mobile presentation; account data and settings actions are supplied by the host. */
export function MobileSettingsSheet(props: MobileSettingsSheetProps) {
+ const [query, setQuery] = createSignal('');
+ const [selection, setSelection] = createSignal<SettingsSearchResult>();
+ const results = createMemo(() =>
+ searchSettings(props.searchGroups ?? props.groups, query(), {
+ emailSignatures: props.emailSignatures,
+ })
+ );
let mainScrollTop = 0;
let scrollRef: HTMLDivElement | undefined;
let headingRef: HTMLHeadingElement | undefined;
- // Legacy runtime links share the single Agents management navigation entry.
- const navigationPage = () =>
- props.page === 'Harness' ? 'Agents' : props.page;
+ const navigationPage = () => props.page;
const pageLabel = () =>
props.groups
.flatMap((group) => group.items)
.find((item) => item.tab === navigationPage())?.label ??
- (props.page === 'Harness' ? 'Agents' : undefined) ??
+ (props.page === 'Harness' ? 'Runtimes' : undefined) ??
props.page ??
'Settings';
- const navigate = (page?: SettingsTab) => {
+ const navigate = (page?: SettingsTab, focusHeading = true) => {
+ setSelection(undefined);
if (!props.page) mainScrollTop = scrollRef?.scrollTop ?? 0;
props.onNavigate(page);
- queueMicrotask(() => headingRef?.focus({ preventScroll: true }));
+ if (focusHeading)
+ queueMicrotask(() => headingRef?.focus({ preventScroll: true }));
};
return (
@@ -133,39 +157,59 @@ export function MobileSettingsSheet(props: MobileSettingsSheetProps) {
</span>
</button>
<div class="flex flex-col gap-6 px-3">
- <For each={props.groups}>
- {(group) => (
- <section>
- <h2 class="px-4 pb-2 text-sm font-medium text-ink-muted">
- {group.label}
- </h2>
- <div class="overflow-hidden rounded-[26px] bg-ink/5 p-1">
- <For each={group.items}>
- {(item, index) => (
- <>
- <Show when={index() > 0}>
- <div class="ml-12 mr-3 h-px bg-ink/6" />
- </Show>
- <MobileDrawer.Item
- onClick={() => navigate(item.tab)}
- class="min-h-13 gap-3.5 px-3.5 text-base"
- >
- <Dynamic
- component={item.icon}
- class="size-5 shrink-0"
- />
- <span class="min-w-0 flex-1 text-left">
- {item.label}
- </span>
- <CaretRightIcon class="size-4 shrink-0 text-ink-extra-muted" />
- </MobileDrawer.Item>
- </>
- )}
- </For>
- </div>
- </section>
- )}
- </For>
+ <SearchBar
+ label="Search settings"
+ placeholder="Search settings"
+ value={query()}
+ onValueChange={setQuery}
+ onEscape={() => setQuery('')}
+ />
+ <Show
+ when={!query().trim()}
+ fallback={
+ <SettingsSearchResults
+ results={results()}
+ onSelect={(result) => {
+ navigate(result.tab, false);
+ setSelection({ ...result });
+ }}
+ />
+ }
+ >
+ <For each={props.groups}>
+ {(group) => (
+ <section>
+ <h2 class="px-4 pb-2 text-sm font-medium text-ink-muted">
+ {group.label}
+ </h2>
+ <div class="overflow-hidden rounded-[26px] bg-ink/5 p-1">
+ <For each={group.items}>
+ {(item, index) => (
+ <>
+ <Show when={index() > 0}>
+ <div class="ml-12 mr-3 h-px bg-ink/6" />
+ </Show>
+ <MobileDrawer.Item
+ onClick={() => navigate(item.tab)}
+ class="min-h-13 gap-3.5 px-3.5 text-base"
+ >
+ <Dynamic
+ component={item.icon}
+ class="size-5 shrink-0"
+ />
+ <span class="min-w-0 flex-1 text-left">
+ {item.label}
+ </span>
+ <CaretRightIcon class="size-4 shrink-0 text-ink-extra-muted" />
+ </MobileDrawer.Item>
+ </>
+ )}
+ </For>
+ </div>
+ </section>
+ )}
+ </For>
+ </Show>
<div class="mb-3 rounded-[26px] bg-ink/5 p-1">
<MobileDrawer.Item
onClick={props.onLogout}
@@ -222,7 +266,13 @@ export function MobileSettingsSheet(props: MobileSettingsSheetProps) {
</div>
}
>
- {props.renderPage(page)}
+ <SettingsSearchTarget
+ result={
+ selection()?.tab === page ? selection() : undefined
+ }
+ >
+ {props.renderPage(page)}
+ </SettingsSearchTarget>
</Show>
</Suspense>
</ErrorBoundary>
diff --git a/apps/web/src/features/settings/RuntimePairingPage.tsx b/apps/web/src/features/settings/RuntimePairingPage.tsx
index d33734ac19..7b93e69c04 100644
--- a/apps/web/src/features/settings/RuntimePairingPage.tsx
+++ b/apps/web/src/features/settings/RuntimePairingPage.tsx
@@ -9,7 +9,7 @@ import { useCurrentTeamQuery } from '@queries/team/teams';
import { Button, Checkbox } from '@ui';
import { createEffect, createSignal, Match, Show, Switch } from 'solid-js';
import { RuntimeSetupSteps } from './components/runtime-setup-steps';
-import { ChoiceRow, SettingsPage } from './primitives';
+import { ChoiceRow, SettingsPage, SettingsSurface } from './primitives';
const PAIRING_ERROR_FALLBACK =
'This pairing code is invalid, expired, or already claimed.';
@@ -146,254 +146,254 @@ export function RuntimePairingPage(props: {
</Button>
}
>
- <section
- aria-label="New runtime"
- class="@container rounded-xl border border-edge-muted bg-surface-2 p-6"
- >
- <Switch>
- <Match when={approved()}>
- <p class="text-sm leading-5 text-ink-muted">
- Runtime connected. macrod will finish pairing automatically.
- </p>
- </Match>
+ <section aria-label="New runtime">
+ <SettingsSurface class="@container p-6">
+ <Switch>
+ <Match when={approved()}>
+ <p class="text-sm leading-5 text-ink-muted">
+ Runtime connected. macrod will finish pairing automatically.
+ </p>
+ </Match>
- <Match when={errorMessage()}>
- {(message) => (
- <div class="flex flex-col gap-3">
- <p class="text-sm leading-5 text-negative">{message()}</p>
- <div>
- <Button
- type="button"
- variant="outline"
- size="sm"
- onClick={tryAnotherCode}
- >
- Try another code
- </Button>
+ <Match when={errorMessage()}>
+ {(message) => (
+ <div class="flex flex-col gap-3">
+ <p class="text-sm leading-5 text-negative">{message()}</p>
+ <div>
+ <Button
+ type="button"
+ variant="outline"
+ size="sm"
+ onClick={tryAnotherCode}
+ >
+ Try another code
+ </Button>
+ </div>
</div>
- </div>
- )}
- </Match>
+ )}
+ </Match>
- <Match when={pairingData()}>
- {(pairing) => (
- <div class="flex flex-col gap-4">
- <div class="flex flex-col gap-1.5">
- <div class="rounded-lg border border-edge-muted bg-ink/[0.025] px-3 py-3 text-center font-mono text-2xl tracking-[0.2em] text-ink">
- {pairing().code}
+ <Match when={pairingData()}>
+ {(pairing) => (
+ <div class="flex flex-col gap-4">
+ <div class="flex flex-col gap-1.5">
+ <div class="rounded-lg border border-edge-muted bg-ink/[0.025] px-3 py-3 text-center font-mono text-2xl tracking-[0.2em] text-ink">
+ {pairing().code}
+ </div>
+ <p class="text-xs text-ink-muted">
+ Confirm this matches the code macrod printed.
+ </p>
</div>
- <p class="text-xs text-ink-muted">
- Confirm this matches the code macrod printed.
- </p>
- </div>
- <div class="flex flex-col gap-0.5 text-xs text-ink-muted">
- <span>
- Requested name:{' '}
- <span class="text-ink">{pairing().requested_name}</span>
- </span>
- <Show when={pairing().host}>
- {(host) => (
- <span>
- Host: <span class="text-ink">{host()}</span>
- </span>
- )}
- </Show>
- <span>
- Expires in {expiresInMinutes(pairing().expires_at)} minutes
- </span>
- </div>
+ <div class="flex flex-col gap-0.5 text-xs text-ink-muted">
+ <span>
+ Requested name:{' '}
+ <span class="text-ink">{pairing().requested_name}</span>
+ </span>
+ <Show when={pairing().host}>
+ {(host) => (
+ <span>
+ Host: <span class="text-ink">{host()}</span>
+ </span>
+ )}
+ </Show>
+ <span>
+ Expires in {expiresInMinutes(pairing().expires_at)}{' '}
+ minutes
+ </span>
+ </div>
- <label class="flex flex-col gap-1.5">
- <span class="text-xs font-medium text-ink">Name</span>
- <input
- class="settings-input w-full"
- value={name()}
- onInput={(event) => {
- setNameEdited(true);
- setName(event.currentTarget.value);
- }}
- />
- </label>
+ <label class="flex flex-col gap-1.5">
+ <span class="text-xs font-medium text-ink">Name</span>
+ <input
+ class="settings-input w-full"
+ value={name()}
+ onInput={(event) => {
+ setNameEdited(true);
+ setName(event.currentTarget.value);
+ }}
+ />
+ </label>
- <fieldset class="grid grid-cols-1 gap-2 @min-[440px]:grid-cols-2">
- <legend class="sr-only">Share</legend>
- <ChoiceRow
- name="harness-share"
- value="private"
- checked={share() === 'Private'}
- title="Private"
- description="Only you can run agents on this runtime."
- onChange={() => {
- setShareEdited(true);
- setShare('Private');
- }}
- />
- <ChoiceRow
- name="harness-share"
- value="team"
- checked={share() === 'Team'}
- title="Team"
- description={
- canShareWithTeam()
- ? 'Your team can run agents on this runtime.'
- : 'Create or join a team before sharing runtimes.'
- }
- disabled={!canShareWithTeam()}
- onChange={() => {
- setShareEdited(true);
- setShare('Team');
- }}
- />
- </fieldset>
- <div class="flex flex-col gap-2">
- <Checkbox
- class="flex items-center gap-3 text-sm"
- checked={allowPermissionBypass()}
- disabled={
- pairing().requested_allow_permission_bypass === false
- }
- onChange={(allowed) => {
- setPermissionBypassEdited(true);
- setAllowPermissionBypass(allowed);
- }}
- >
- <Checkbox.Control />
- <Checkbox.Label>
- Allow bypassing permission requests
- </Checkbox.Label>
- </Checkbox>
- <p class="text-xs text-ink-muted">
- {pairing().requested_allow_permission_bypass === false
- ? 'This daemon requires permission prompts. Change its setting and pair again to allow bypass.'
- : 'When off, every agent on this runtime must ask for permission.'}
- </p>
- <Show when={allowPermissionBypass()}>
- <p class="text-xs text-negative" role="alert">
- Agents can run commands and edit files on this machine
- without approval. Only enable this if you trust everyone
- who can create agents on this runtime.
+ <fieldset class="grid grid-cols-1 gap-2 @min-[440px]:grid-cols-2">
+ <legend class="sr-only">Share</legend>
+ <ChoiceRow
+ name="harness-share"
+ value="private"
+ checked={share() === 'Private'}
+ title="Private"
+ description="Only you can run agents on this runtime."
+ onChange={() => {
+ setShareEdited(true);
+ setShare('Private');
+ }}
+ />
+ <ChoiceRow
+ name="harness-share"
+ value="team"
+ checked={share() === 'Team'}
+ title="Team"
+ description={
+ canShareWithTeam()
+ ? 'Your team can run agents on this runtime.'
+ : 'Create or join a team before sharing runtimes.'
+ }
+ disabled={!canShareWithTeam()}
+ onChange={() => {
+ setShareEdited(true);
+ setShare('Team');
+ }}
+ />
+ </fieldset>
+ <div class="flex flex-col gap-2">
+ <Checkbox
+ class="flex items-center gap-3 text-sm"
+ checked={allowPermissionBypass()}
+ disabled={
+ pairing().requested_allow_permission_bypass === false
+ }
+ onChange={(allowed) => {
+ setPermissionBypassEdited(true);
+ setAllowPermissionBypass(allowed);
+ }}
+ >
+ <Checkbox.Control />
+ <Checkbox.Label>
+ Allow bypassing permission requests
+ </Checkbox.Label>
+ </Checkbox>
+ <p class="text-xs text-ink-muted">
+ {pairing().requested_allow_permission_bypass === false
+ ? 'This daemon requires permission prompts. Change its setting and pair again to allow bypass.'
+ : 'When off, every agent on this runtime must ask for permission.'}
</p>
- </Show>
- </div>
- </div>
- )}
- </Match>
-
- <Match when={committedCode()}>
- <p class="text-sm text-ink-muted">Looking up pairing code…</p>
- </Match>
-
- <Match when>
- <RuntimeSetupSteps>
- <div class="flex flex-col gap-1.5">
- <label
- for="harness-pairing-code"
- class="text-xs font-medium text-ink"
- >
- Pairing code
- </label>
- <div class="flex min-w-0 items-center gap-2 rounded-lg border border-edge-muted bg-ink/[0.025] px-3 py-2">
- <input
- id="harness-pairing-code"
- autocomplete="off"
- aria-describedby="harness-pairing-code-help"
- spellcheck={false}
- class="min-w-0 flex-1 bg-transparent font-mono text-sm uppercase tracking-widest text-ink outline-none"
- placeholder="KX7M-4QHD"
- value={codeInput()}
- onInput={(event) =>
- setCodeInput(event.currentTarget.value.toUpperCase())
- }
- onKeyDown={(event) => {
- if (event.key === 'Enter') lookUp();
- }}
- />
+ <Show when={allowPermissionBypass()}>
+ <p class="text-xs text-negative" role="alert">
+ Agents can run commands and edit files on this machine
+ without approval. Only enable this if you trust everyone
+ who can create agents on this runtime.
+ </p>
+ </Show>
+ </div>
</div>
- <p
- id="harness-pairing-code-help"
- class="text-xs text-ink-extra-muted"
- >
- Already configured? Press <kbd>p</kbd> in macrod to get a new
- code.
- </p>
- </div>
- </RuntimeSetupSteps>
- </Match>
- </Switch>
- <div class="mt-6 flex justify-end gap-2 border-t border-edge-muted pt-4">
- <Switch>
- <Match when={approved()}>
- <Button
- type="button"
- variant="cta"
- size="sm"
- onClick={props.onClose}
- >
- Done
- </Button>
- </Match>
- <Match when={errorMessage()}>
- <Button
- type="button"
- variant="ghost"
- size="sm"
- onClick={props.onClose}
- >
- Close
- </Button>
- </Match>
- <Match when={pairingData()}>
- <Button
- type="button"
- variant="ghost"
- size="sm"
- disabled={approveMutation.isPending}
- onClick={props.onClose}
- >
- Cancel
- </Button>
- <Button
- type="button"
- variant="cta"
- size="sm"
- disabled={!canApprove()}
- onClick={() => void approve()}
- >
- {approveMutation.isPending ? 'Approving…' : 'Approve'}
- </Button>
+ )}
</Match>
+
<Match when={committedCode()}>
- <Button
- type="button"
- variant="ghost"
- size="sm"
- onClick={props.onClose}
- >
- Cancel
- </Button>
+ <p class="text-sm text-ink-muted">Looking up pairing code…</p>
</Match>
+
<Match when>
- <Button
- type="button"
- variant="ghost"
- size="sm"
- onClick={props.onClose}
- >
- Cancel
- </Button>
- <Button
- type="button"
- variant="cta"
- size="sm"
- disabled={codeInput().trim().length === 0}
- onClick={lookUp}
- >
- Look up
- </Button>
+ <RuntimeSetupSteps>
+ <div class="flex flex-col gap-1.5">
+ <label
+ for="harness-pairing-code"
+ class="text-xs font-medium text-ink"
+ >
+ Pairing code
+ </label>
+ <div class="flex min-w-0 items-center gap-2 rounded-lg border border-edge-muted bg-ink/[0.025] px-3 py-2">
+ <input
+ id="harness-pairing-code"
+ autocomplete="off"
+ aria-describedby="harness-pairing-code-help"
+ spellcheck={false}
+ class="min-w-0 flex-1 bg-transparent font-mono text-sm uppercase tracking-widest text-ink outline-none"
+ placeholder="KX7M-4QHD"
+ value={codeInput()}
+ onInput={(event) =>
+ setCodeInput(event.currentTarget.value.toUpperCase())
+ }
+ onKeyDown={(event) => {
+ if (event.key === 'Enter') lookUp();
+ }}
+ />
+ </div>
+ <p
+ id="harness-pairing-code-help"
+ class="text-xs text-ink-extra-muted"
+ >
+ Already configured? Press <kbd>p</kbd> in macrod to get a
+ new code.
+ </p>
+ </div>
+ </RuntimeSetupSteps>
</Match>
</Switch>
- </div>
+ <div class="mt-6 flex justify-end gap-2 border-t border-edge-muted pt-4">
+ <Switch>
+ <Match when={approved()}>
+ <Button
+ type="button"
+ variant="cta"
+ size="sm"
+ onClick={props.onClose}
+ >
+ Done
+ </Button>
+ </Match>
+ <Match when={errorMessage()}>
+ <Button
+ type="button"
+ variant="ghost"
+ size="sm"
+ onClick={props.onClose}
+ >
+ Close
+ </Button>
+ </Match>
+ <Match when={pairingData()}>
+ <Button
+ type="button"
+ variant="ghost"
+ size="sm"
+ disabled={approveMutation.isPending}
+ onClick={props.onClose}
+ >
+ Cancel
+ </Button>
+ <Button
+ type="button"
+ variant="cta"
+ size="sm"
+ disabled={!canApprove()}
+ onClick={() => void approve()}
+ >
+ {approveMutation.isPending ? 'Approving…' : 'Approve'}
+ </Button>
+ </Match>
+ <Match when={committedCode()}>
+ <Button
+ type="button"
+ variant="ghost"
+ size="sm"
+ onClick={props.onClose}
+ >
+ Cancel
+ </Button>
+ </Match>
+ <Match when>
+ <Button
+ type="button"
+ variant="ghost"
+ size="sm"
+ onClick={props.onClose}
+ >
+ Cancel
+ </Button>
+ <Button
+ type="button"
+ variant="cta"
+ size="sm"
+ disabled={codeInput().trim().length === 0}
+ onClick={lookUp}
+ >
+ Look up
+ </Button>
+ </Match>
+ </Switch>
+ </div>
+ </SettingsSurface>
</section>
</SettingsPage>
);
diff --git a/apps/web/src/features/settings/Settings.tsx b/apps/web/src/features/settings/Settings.tsx
index bb4ebb583e..d40282f386 100644
--- a/apps/web/src/features/settings/Settings.tsx
+++ b/apps/web/src/features/settings/Settings.tsx
@@ -1,4 +1,5 @@
-import { SearchBar, ViewShell, ViewSidebar } from '@app/components/view-shell';
+import { useViewShell, ViewShell } from '@app/components/view-shell';
+import { useFeatureFlag } from '@app/lib/analytics/posthog';
import {
useParams,
useNavigate as useSplitNavigate,
@@ -7,12 +8,12 @@ import { PillTabs } from '@components/app/mobile/PillTabs';
import { SplitHeaderLeft } from '@components/app/split-layout/components/SplitHeader';
import { SplitPanel } from '@components/app/split-panel';
import { useLogout } from '@core/auth/logout';
+import { enableEmailSignatures } from '@core/constant/featureFlags';
import {
type SettingsTab,
useSettingsState,
} from '@core/constant/SettingsState';
import {
- type SettingsTabGroup,
settingsSlugToTab,
settingsTabToSlug,
useSettingsTabs,
@@ -22,20 +23,21 @@ import type { ValidHotkey } from '@core/hotkey/types';
import { isMobile } from '@core/mobile/isMobile';
import { isTouchDevice } from '@core/mobile/isTouchDevice';
import { activeTabId, setActiveTabId } from '@core/signal/settingsTab';
-import SignOutIcon from '@phosphor/sign-out.svg';
-import { pressHandlers } from '@ui';
import {
createMemo,
createRenderEffect,
createSignal,
- For,
onMount,
Show,
untrack,
} from 'solid-js';
-import { Dynamic } from 'solid-js/web';
+import { SettingsSearchTarget } from './components/settings-search-target';
+import { SettingsSidebar } from './components/settings-sidebar';
+import {
+ type SettingsSearchResult,
+ searchSettings,
+} from './core/settings-search';
import { SettingsTabContent } from './SettingsTabContent';
-import { filterSettingsTabGroups } from './settingsSearch';
export function SettingsPanelComponentWrapper() {
const params = useParams<{ tab?: string }>();
@@ -81,27 +83,22 @@ type SettingsPanelProps = {
export function SettingsPanel(props: SettingsPanelProps) {
const { closeSettings, activeTabId, selectTab } = useSettingsState();
const splitNavigate = useSplitNavigate();
- const { searchGroups, flatTabs } = useSettingsTabs();
+ const { groups, searchGroups, flatTabs } = useSettingsTabs();
const logout = useLogout();
+ const signatures = useFeatureFlag(enableEmailSignatures);
- const activeNavigationTab = () =>
- activeTabId() === 'Harness' ? 'Agents' : activeTabId();
+ const activeNavigationTab = activeTabId;
const [searchQuery, setSearchQuery] = createSignal('');
-
- const filteredGroups = createMemo(() =>
- filterSettingsTabGroups(searchGroups(), searchQuery())
+ const [searchSelection, setSearchSelection] =
+ createSignal<SettingsSearchResult>();
+ const searchResults = createMemo(() =>
+ searchSettings(searchGroups(), searchQuery(), {
+ emailSignatures: signatures().enabled,
+ })
);
- // Runtimes is a search-only row. While it is on screen, highlight that row
- // for the Harness tab; otherwise the standing Agents row stands in for it.
- const showsHarnessResult = () =>
- filteredGroups().some((group) =>
- group.items.some((item) => item.tab === 'Harness')
- );
- const isItemActive = (tab: SettingsTab) =>
- activeTabId() === tab ||
- (tab === 'Agents' && activeTabId() === 'Harness' && !showsHarnessResult());
+ const isItemActive = (tab: SettingsTab) => activeTabId() === tab;
// Set up hotkey scope for settings panel
const [attachHotkeys, settingsHotkeyScope] = useHotkeyDOMScope('settings');
@@ -118,7 +115,10 @@ export function SettingsPanel(props: SettingsPanelProps) {
});
function handleEscapeKey() {
- closeSettings();
+ if (searchQuery()) {
+ setSearchQuery('');
+ setSearchSelection(undefined);
+ } else closeSettings();
return true;
}
@@ -131,6 +131,7 @@ export function SettingsPanel(props: SettingsPanelProps) {
});
const selectRoutedTab = (tab: SettingsTab) => {
+ setSearchSelection(undefined);
selectTab(tab, (next) => {
splitNavigate(`/settings/${settingsTabToSlug(next)}`);
});
@@ -149,44 +150,6 @@ export function SettingsPanel(props: SettingsPanelProps) {
return false;
}
- function getCurrentTabIndex() {
- return flatTabs().findIndex((tab) => tab.tab === activeNavigationTab());
- }
-
- function handleNextTab() {
- const tabs = flatTabs();
- const nextIndex =
- getCurrentTabIndex() >= tabs.length - 1 ? 0 : getCurrentTabIndex() + 1;
- navigateToTabIndex(nextIndex);
- return true;
- }
-
- function handlePreviousTab() {
- const tabs = flatTabs();
- const nextIndex =
- getCurrentTabIndex() <= 0 ? tabs.length - 1 : getCurrentTabIndex() - 1;
- navigateToTabIndex(nextIndex);
- return true;
- }
-
- // Register Tab key for next tab navigation
- registerHotkey({
- hotkey: 'tab',
- scopeId: settingsHotkeyScope,
- description: 'Next settings tab',
- keyDownHandler: handleNextTab,
- hide: true,
- });
-
- // Register Shift+Tab for previous tab navigation
- registerHotkey({
- description: 'Previous settings tab',
- keyDownHandler: handlePreviousTab,
- scopeId: settingsHotkeyScope,
- hotkey: 'shift+tab',
- hide: true,
- });
-
// Register number keys 1-9 for direct tab navigation
for (let i = 1; i <= 9; i++) {
const keyNum = i;
@@ -214,7 +177,15 @@ export function SettingsPanel(props: SettingsPanelProps) {
const content = () => (
<Show when={activeTabId()}>
- {(tab) => <SettingsTabContent tab={tab()} />}
+ {(tab) => (
+ <SettingsSearchTarget
+ result={
+ searchSelection()?.tab === tab() ? searchSelection() : undefined
+ }
+ >
+ <SettingsTabContent tab={tab()} />
+ </SettingsSearchTarget>
+ )}
</Show>
);
@@ -262,11 +233,21 @@ export function SettingsPanel(props: SettingsPanelProps) {
asidePreferenceKey="settings"
resizable
aside={{ preserveDuringResize: false }}
- main={{ preferredWidth: 720 }}
+ main={{ preferredWidth: 960 }}
>
<ViewShell.Aside>
<SettingsSidebar
- groups={filteredGroups()}
+ groups={groups()}
+ results={searchResults()}
+ selectedResultId={
+ searchSelection()?.tab === activeTabId()
+ ? searchSelection()?.id
+ : undefined
+ }
+ onSelectResult={(result) => {
+ selectRoutedTab(result.tab);
+ setSearchSelection({ ...result });
+ }}
searchQuery={searchQuery()}
onSearchQueryChange={setSearchQuery}
isItemActive={isItemActive}
@@ -275,7 +256,7 @@ export function SettingsPanel(props: SettingsPanelProps) {
/>
</ViewShell.Aside>
<ViewShell.Main>
- <ViewShell.TopBar />
+ <SettingsNavigationBar />
<div class="relative min-h-0 flex-1 overflow-hidden">
{content()}
</div>
@@ -288,83 +269,12 @@ export function SettingsPanel(props: SettingsPanelProps) {
);
}
-/**
- * Settings' inner navigation, laid out like every other view's sidebar: a
- * title bar, a search field, the grouped section pills, and Log out pinned to
- * the bottom.
- */
-function SettingsSidebar(props: {
- groups: SettingsTabGroup[];
- searchQuery: string;
- onSearchQueryChange: (query: string) => void;
- isItemActive: (tab: SettingsTab) => boolean;
- onSelect: (tab: SettingsTab) => void;
- onLogout: () => void;
-}) {
+/** Reserve toolbar space only when the navigation controls are visible. */
+function SettingsNavigationBar() {
+ const shell = useViewShell();
return (
- <ViewSidebar.Root aria-label="Settings navigation">
- <ViewSidebar.Header>
- <div class="flex min-w-0 items-center gap-1">
- <ViewSidebar.CloseButton class="shrink-0" />
- <ViewSidebar.Title>Settings</ViewSidebar.Title>
- </div>
- </ViewSidebar.Header>
-
- <ViewSidebar.Primary>
- <SearchBar
- label="Search settings"
- placeholder="Search"
- autocomplete="off"
- value={props.searchQuery}
- onValueChange={props.onSearchQueryChange}
- class="h-9"
- />
- </ViewSidebar.Primary>
-
- <ViewSidebar.Content class="gap-4">
- <Show
- when={props.groups.length > 0}
- fallback={
- <div class="py-4 text-center text-sm text-ink-muted">
- No settings found
- </div>
- }
- >
- <For each={props.groups}>
- {(group) => (
- <section class="flex min-w-0 flex-col gap-0.5">
- <h2 class="flex h-7 min-w-0 items-center px-(--sidebar-item-inset) text-sm font-medium text-ink-extra-muted">
- <span class="truncate">{group.label}</span>
- </h2>
- <ViewSidebar.Nav aria-label={group.label}>
- <For each={group.items}>
- {(item) => (
- <ViewSidebar.Item
- active={props.isItemActive(item.tab)}
- {...pressHandlers(() => props.onSelect(item.tab))}
- >
- <ViewSidebar.Icon>
- <Dynamic component={item.icon} class="size-4" />
- </ViewSidebar.Icon>
- <span class="truncate">{item.label}</span>
- </ViewSidebar.Item>
- )}
- </For>
- </ViewSidebar.Nav>
- </section>
- )}
- </For>
- </Show>
- </ViewSidebar.Content>
-
- <ViewSidebar.Footer class="py-(--sidebar-gutter)">
- <ViewSidebar.Item {...pressHandlers(() => props.onLogout())}>
- <ViewSidebar.Icon>
- <SignOutIcon class="size-4" />
- </ViewSidebar.Icon>
- <span class="truncate">Log out</span>
- </ViewSidebar.Item>
- </ViewSidebar.Footer>
- </ViewSidebar.Root>
+ <Show when={shell.aside.isCollapsed() || shell.aside.isOverlay()}>
+ <ViewShell.TopBar />
+ </Show>
);
}
diff --git a/apps/web/src/features/settings/SettingsTabContent.tsx b/apps/web/src/features/settings/SettingsTabContent.tsx
index 8b02fc70ab..0aed6cbd5c 100644
--- a/apps/web/src/features/settings/SettingsTabContent.tsx
+++ b/apps/web/src/features/settings/SettingsTabContent.tsx
@@ -1,6 +1,7 @@
import type { SettingsTab } from '@core/constant/SettingsState';
import { useSettingsTabAvailable } from '@core/constant/settingsTabsConfig';
import { Show, Suspense } from 'solid-js';
+import { CalendarSettings } from '../calendar/calendar-settings';
import { CrmSettings as Crm } from '../crm/crm-settings';
import { SchedulingSettings } from '../scheduling/scheduling';
import { Account } from './Account';
@@ -12,6 +13,7 @@ import { Appearance } from './Appearance';
import { Billing } from './Billing';
import { Bots } from './Bots';
import { ConnectedAccounts } from './ConnectedAccounts';
+import { EmailSettings } from './email-settings';
import { McpConnections } from './McpConnections';
import { MobileApp } from './MobileApp';
import { Notifications } from './Notifications';
@@ -35,7 +37,13 @@ export function SettingsTabContent(props: { tab: SettingsTab }) {
<Show when={isCurrentTab('Account')}>
<Account />
</Show>
+ <Show when={isCurrentTab('Email')}>
+ <EmailSettings />
+ </Show>
<Show when={isCurrentTab('Calendar')}>
+ <CalendarSettings />
+ </Show>
+ <Show when={isCurrentTab('Booking links')}>
<SchedulingSettings />
</Show>
<Show when={isCurrentTab('API Keys')}>
diff --git a/apps/web/src/features/settings/Shortcuts.tsx b/apps/web/src/features/settings/Shortcuts.tsx
index 56ac9c049a..e69ea81332 100644
--- a/apps/web/src/features/settings/Shortcuts.tsx
+++ b/apps/web/src/features/settings/Shortcuts.tsx
@@ -1,11 +1,7 @@
import { IS_MAC } from '@core/constant/isMac';
-import { cn, Hotkey, ToggleSwitch } from '@ui';
-import {
- enableScreencastHotkeys,
- setEnableScreencastHotkeys,
-} from '@ui/components/ScreencastHotkeys';
-import { createMemo, createSignal, For, Index, type JSX } from 'solid-js';
-import { SettingsCard, SettingsPage } from './primitives';
+import { cn, Hotkey } from '@ui';
+import { createMemo, createSignal, For, Index, type JSX, Show } from 'solid-js';
+import { SettingsPage, SettingsSection, SettingsSurface } from './primitives';
interface ShortcutItem {
description: JSX.Element;
@@ -1011,9 +1007,7 @@ function Kbd(props: { shortcut: string; class?: string }) {
return (
<span
class={cn(
- 'inline-flex items-center text-xs px-1.5 py-0.5 rounded-sm uppercase transition-colors',
- 'border border-edge-muted bg-ink/4 text-ink-muted',
- 'group-hover:border-accent/30 group-hover:bg-accent/10 group-hover:text-accent',
+ 'inline-flex items-center rounded-md px-2 py-1 text-sm uppercase text-ink/60',
props.class
)}
>
@@ -1025,43 +1019,38 @@ function Kbd(props: { shortcut: string; class?: string }) {
function ShortcutRow(props: { item: ShortcutItem; spacer?: string }) {
return (
<div
- class="group flex items-center gap-2 py-1.5 rounded-md hover:bg-hover transition-colors"
+ class="group flex min-h-13 items-center justify-between gap-6 py-3 hover:bg-ink/3"
onMouseEnter={() => setHoveredCodes(props.item.codes)}
onMouseLeave={() => setHoveredCodes([])}
>
- <div class="shrink-0 flex items-center gap-1 uppercase">
+ <span class="min-w-0 text-base text-ink">{props.item.description}</span>
+ <div class="flex shrink-0 flex-wrap justify-end items-center gap-2 uppercase">
<Index each={props.item.keys}>
{(key, index) => (
<>
- <Kbd shortcut={key()} />
- {props.spacer && index < props.item.keys.length - 1 && (
- <span class="text-ink-muted text-xs lowercase px-1">
+ <Show when={index > 0 && props.spacer}>
+ <span class="text-xs lowercase text-ink/40">
{props.spacer}
</span>
- )}
+ </Show>
+ <Kbd shortcut={key()} />
</>
)}
</Index>
</div>
- <span class="text-sm text-ink-muted group-hover:text-accent transition-colors">
- {props.item.description}
- </span>
</div>
);
}
function ShortcutSectionComponent(props: { section: ShortcutSection }) {
return (
- <div class="mb-4">
- <h3 class="text-sm font-semibold text-ink mb-1.5 flex items-center gap-2">
- {props.section.title}
- </h3>
- <div class="flex flex-col">
+ <SettingsSection title={props.section.title}>
+ <div class="divide-y divide-ink/5">
<For each={props.section.items}>
{(item) => <ShortcutRow item={item} spacer="or" />}
</For>
</div>
- </div>
+ </SettingsSection>
);
}
@@ -1069,42 +1058,19 @@ export function Shortcuts() {
return (
<SettingsPage
title="Keyboard shortcuts"
- actions={
- <div class="flex items-center gap-2">
- <span class="text-sm text-ink-muted">Screencast keys</span>
- <ToggleSwitch
- size="md"
- onChange={setEnableScreencastHotkeys}
- checked={enableScreencastHotkeys()}
- />
- </div>
- }
+ description="Quick ways to navigate, search, and work in Macro."
>
- <SettingsCard class="px-5 py-4">
- <Keyboard keys={hoveredCodes()} />
- </SettingsCard>
-
- <div class="@container">
- <div class="grid grid-cols-1 @[600px]:grid-cols-2 gap-x-8">
- {/* Core - left column */}
- <ShortcutSectionComponent section={shortcutSections[0]} />
-
- {/* Splits - right column */}
- <ShortcutSectionComponent section={shortcutSections[1]} />
-
- {/* Unified List - spans both columns with its own 2-column layout */}
- <div class="@[600px]:col-span-2">
- <h3 class="text-sm font-semibold text-ink mb-1.5 flex items-center gap-2">
- {shortcutSections[2].title}
- </h3>
- <div class="grid grid-cols-1 @[600px]:grid-cols-2 gap-x-8">
- <For each={shortcutSections[2].items}>
- {(item) => <ShortcutRow item={item} spacer="or" />}
- </For>
- </div>
+ <SettingsSurface class="px-5 py-4">
+ <details>
+ <summary class="text-sm text-ink/60">Keyboard preview</summary>
+ <div class="pt-4">
+ <Keyboard keys={hoveredCodes()} />
</div>
- </div>
- </div>
+ </details>
+ </SettingsSurface>
+ <For each={shortcutSections}>
+ {(section) => <ShortcutSectionComponent section={section} />}
+ </For>
</SettingsPage>
);
}
diff --git a/apps/web/src/features/settings/SignatureEditor.css b/apps/web/src/features/settings/SignatureEditor.css
index ef48255fd1..d8ee24c8b9 100644
--- a/apps/web/src/features/settings/SignatureEditor.css
+++ b/apps/web/src/features/settings/SignatureEditor.css
@@ -28,11 +28,11 @@
/* Match the settings surface without changing the signature's saved HTML or
overriding explicit text/background colors in pasted content. */
.signature-editor .ql-container.ql-snow {
- background-color: var(--color-surface);
+ background-color: transparent;
}
.signature-editor .ql-editor {
- min-height: 8rem;
+ min-height: 12rem;
color: var(--color-ink);
}
diff --git a/apps/web/src/features/settings/SignatureEditor.tsx b/apps/web/src/features/settings/SignatureEditor.tsx
index e35f73aac2..d01e91b283 100644
--- a/apps/web/src/features/settings/SignatureEditor.tsx
+++ b/apps/web/src/features/settings/SignatureEditor.tsx
@@ -79,6 +79,8 @@ export default function SignatureEditor(props: {
/** Fires with the editor's current HTML on every edit; '' when emptied. */
onInput: (html: string) => void;
placeholder?: string;
+ label?: string;
+ disabled?: boolean;
/** Exposes an imperative handle once mounted so commit actions (Save/Remove)
* can set the editor content deterministically, not via the reactive value. */
onReady?: (handle: { setContent: (html: string) => void }) => void;
@@ -199,6 +201,10 @@ export default function SignatureEditor(props: {
},
},
});
+ quill.enable(!props.disabled);
+ quill.root.setAttribute('role', 'textbox');
+ quill.root.setAttribute('aria-multiline', 'true');
+ quill.root.setAttribute('aria-label', props.label ?? 'Email signature');
setHtml(props.value);
quill.on('text-change', () => props.onInput(currentHtml()));
teardownResizer = setupImageResizer(quill);
@@ -226,6 +232,10 @@ export default function SignatureEditor(props: {
onCleanup(() => quill?.root.removeEventListener('paste', onPaste, true));
});
+ createEffect(() => {
+ quill?.enable(!props.disabled);
+ });
+
// Reseed the editor when `props.value` changes. The draft store keeps
// `props.value` equal to the editor's own content while typing, so this is a
// no-op then and never clobbers an in-progress edit; it only diverges after
diff --git a/apps/web/src/features/settings/SignatureSection.tsx b/apps/web/src/features/settings/SignatureSection.tsx
index b632e5f069..af22ec1b94 100644
--- a/apps/web/src/features/settings/SignatureSection.tsx
+++ b/apps/web/src/features/settings/SignatureSection.tsx
@@ -1,60 +1,23 @@
import { toast } from '@core/component/Toast/Toast';
import { isMobile } from '@core/mobile/isMobile';
import { ThrownResultError } from '@core/util/result';
-import SignatureIcon from '@phosphor-icons/core/regular/signature.svg?component-solid';
-import XIcon from '@phosphor-icons/core/regular/x.svg?component-solid';
import { useEmailSignature } from '@queries/email/link';
import { useUpdateEmailSettingsMutation } from '@queries/email/settings';
import { SIGNATURE_IMAGES_UNRESOLVED_CODE } from '@service-email/client';
import type { Link as EmailLink } from '@service-email/generated/schemas';
-import { Button, ToggleSwitch } from '@ui';
-import { createSignal, lazy, Show, Suspense } from 'solid-js';
+import { createSignal } from 'solid-js';
+import { SignatureForm } from './components/signature-form';
-// Quill (and its CSS) is heavy and only needed once a signature section is
-// expanded, so load it as its own chunk on demand instead of in the settings
-// bundle.
-const SignatureEditor = lazy(() => import('./SignatureEditor'));
-
-// Unsaved signature drafts and per-inbox expanded state, keyed by link id and
-// held at module scope. The settings panel unmounts the Connected Accounts tab
-// when you switch away (and the links query can recreate an inbox row on
-// refetch); keeping this outside that subtree means tabbing away and back no
-// longer closes the editor or discards unsaved edits.
+// Keep drafts when navigating away from Email settings. Quill loads on demand.
const [signatureDrafts, setSignatureDrafts] = createSignal<
Record<string, string>
>({});
-const [signatureExpanded, setSignatureExpanded] = createSignal<
- Record<string, boolean>
->({});
-
-/** Whether an inbox's signature editor is expanded (reactive). */
-export function isSignatureExpanded(linkId: string): boolean {
- return signatureExpanded()[linkId] ?? false;
-}
-
-/** Toggles an inbox's signature editor open/closed. */
-export function toggleSignatureExpanded(linkId: string): void {
- setSignatureExpanded((prev) => ({
- ...prev,
- [linkId]: !isSignatureExpanded(linkId),
- }));
-}
-
-/**
- * Drops a link's draft + expanded entries so the module store doesn't retain
- * state for an inbox that no longer exists (called when an inbox is removed).
- */
export function clearSignatureState(linkId: string): void {
setSignatureDrafts((prev) => {
const next = { ...prev };
delete next[linkId];
return next;
});
- setSignatureExpanded((prev) => {
- const next = { ...prev };
- delete next[linkId];
- return next;
- });
}
/**
@@ -78,10 +41,7 @@ function saveSignatureErrorMessage(error: Error): string {
* patches `email_settings` on save. The "replies & forwards" toggle patches
* immediately (the backend patch is partial, so it leaves the signature alone).
*/
-export function SignatureSection(props: {
- link: EmailLink;
- onClose: () => void;
-}) {
+export function SignatureSection(props: { link: EmailLink }) {
const signature = useEmailSignature(() => props.link.id);
// Draft lives in the module-level store (keyed by link id) so it survives the
// settings tab unmounting; `null` means "no unsaved edit".
@@ -163,87 +123,25 @@ export function SignatureSection(props: {
};
return (
- <div class="flex flex-col gap-3 rounded-xl border border-edge-muted p-3">
- <div class="flex items-center justify-between gap-3">
- <h3 class="text-sm font-medium">Signature</h3>
- <Button
- variant="ghost"
- size="icon-sm"
- tooltip="Close signature editor"
- aria-label="Close signature editor"
- onClick={props.onClose}
- >
- <XIcon class="size-4" />
- </Button>
- </div>
- {/* Editing (Quill) is desktop-only; on mobile the section still offers
- the replies/forwards toggle and Remove, with a pointer to desktop. */}
- <Show
- when={!isMobile()}
- fallback={
- <div class="flex flex-col items-center gap-1.5 rounded-lg border border-dashed border-edge-muted px-3 py-6 text-center">
- <SignatureIcon class="size-5 text-ink-muted" />
- <p class="text-sm text-ink-muted">
- Update your signature on desktop.
- </p>
- </div>
- }
- >
- <Suspense
- fallback={
- <div class="h-44 animate-pulse rounded-lg border border-edge-muted" />
- }
- >
- <SignatureEditor
- value={draft() ?? persisted()}
- onInput={(html) => {
- setDraft(html);
- setSaveError(null);
- }}
- onReady={(api) => {
- editorApi = api;
- }}
- />
- </Suspense>
- </Show>
- {/* Stacks on narrow screens so the toggle label and buttons never
- crowd each other onto wrapped lines. */}
- <div class="flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between">
- <ToggleSwitch
- checked={props.link.settings.signature_on_replies_forwards ?? false}
- onChange={setOnRepliesForwards}
- label={
- <span class="text-sm text-ink-muted">
- Add to replies & forwards
- </span>
- }
- />
- <div class="flex items-center justify-end gap-2">
- <Button
- variant="outline"
- size="sm"
- depth={3}
- disabled={!hasContent() || updateSettings.isPending}
- onClick={removeSignature}
- >
- Remove
- </Button>
- <Show when={!isMobile()}>
- <Button
- variant="accent"
- size="sm"
- depth={3}
- disabled={!isDirty() || updateSettings.isPending}
- onClick={saveSignature}
- >
- Save
- </Button>
- </Show>
- </div>
- </div>
- <Show when={saveError()}>
- {(msg) => <p class="text-right text-sm text-failure-ink">{msg()}</p>}
- </Show>
- </div>
+ <SignatureForm
+ email={props.link.email_address}
+ value={draft() ?? persisted()}
+ onInput={(html) => {
+ setDraft(html);
+ setSaveError(null);
+ }}
+ onReady={(api) => {
+ editorApi = api;
+ }}
+ onSave={saveSignature}
+ onClear={removeSignature}
+ dirty={isDirty()}
+ hasContent={hasContent()}
+ pending={updateSettings.isPending}
+ replies={props.link.settings.signature_on_replies_forwards ?? false}
+ onRepliesChange={setOnRepliesForwards}
+ error={saveError()}
+ mobile={isMobile()}
+ />
);
}
diff --git a/apps/web/src/features/settings/Team.tsx b/apps/web/src/features/settings/Team.tsx
index 407261f42b..7f14365343 100644
--- a/apps/web/src/features/settings/Team.tsx
+++ b/apps/web/src/features/settings/Team.tsx
@@ -442,7 +442,7 @@ function MemberRow(props: {
};
return (
- <div class="flex items-center justify-between gap-2 px-6 py-3 bg-surface">
+ <div class="flex items-center justify-between gap-2 px-4 py-4">
<div class="flex items-center gap-3 min-w-0 flex-1">
<div class="shrink-0">
<UserIcon id={props.member.user_id} isDeleted={false} size="lg" />
@@ -548,7 +548,7 @@ function InviteRow(props: {
};
return (
- <div class="flex items-center justify-between gap-2 px-6 py-3 bg-surface">
+ <div class="flex items-center justify-between gap-2 px-4 py-4">
<div class="flex items-center gap-3 min-w-0 flex-1">
<div class="size-8 rounded-full bg-accent/10 flex items-center justify-center shrink-0">
<EnvelopeIcon class="size-4 text-accent" />
@@ -604,7 +604,7 @@ function UserInviteRow(props: {
isDeclining: boolean;
}) {
return (
- <div class="flex items-center justify-between gap-3 px-6 py-3 bg-surface">
+ <div class="flex items-center justify-between gap-3 px-4 py-4">
<div class="flex items-center gap-3 min-w-0 flex-1">
<div class="size-8 rounded-full bg-accent/10 flex items-center justify-center shrink-0">
<EnvelopeIcon class="size-4 text-accent" />
diff --git a/apps/web/src/features/settings/browser-test/fixture.tsx b/apps/web/src/features/settings/browser-test/fixture.tsx
new file mode 100644
index 0000000000..e568aabfce
--- /dev/null
+++ b/apps/web/src/features/settings/browser-test/fixture.tsx
@@ -0,0 +1,252 @@
+import '@fontsource-variable/inter';
+import '../../../index.css';
+import { ViewShell } from '@app/components/view-shell';
+import type { SettingsTab } from '@core/constant/SettingsState';
+import { SETTINGS_TAB_GROUPS } from '@core/constant/settingsTabsConfig';
+import { ToggleSwitch } from '@ui';
+import { createMemo, createSignal, For, onMount, Show } from 'solid-js';
+import { render } from 'solid-js/web';
+import { macroDarkTheme } from '../../theme/themes/macro-dark';
+import { macroLightTheme } from '../../theme/themes/macro-light';
+import { themeCssVars } from '../../theme/utils/themeColorTokens';
+import { Appearance } from '../Appearance';
+import { SettingsSearchTarget } from '../components/settings-search-target';
+import { SettingsSidebar } from '../components/settings-sidebar';
+import { SignatureForm } from '../components/signature-form';
+import {
+ type SettingsSearchResult,
+ searchSettings,
+} from '../core/settings-search';
+import { MobileSettingsSheet } from '../MobileSettingsSheet';
+import {
+ SettingsButton as Button,
+ SettingsCard,
+ SettingsPage,
+ SettingsRow,
+ SettingsSection,
+} from '../primitives';
+import { Shortcuts } from '../Shortcuts';
+
+function Fixture() {
+ const [tab, setTab] = createSignal<SettingsTab>('Email');
+ const [query, setQuery] = createSignal('');
+ const [selected, setSelected] = createSignal<SettingsSearchResult>();
+ const [dark, setDark] = createSignal(false);
+ const [narrow, setNarrow] = createSignal(false);
+ const [mobile, setMobile] = createSignal(false);
+ const [mobilePage, setMobilePage] = createSignal<SettingsTab>();
+ const applyTheme = (value: boolean) => {
+ setDark(value);
+ for (const [key, token] of Object.entries(
+ themeCssVars(value ? macroDarkTheme : macroLightTheme)
+ ))
+ document.documentElement.style.setProperty(key, token);
+ document.documentElement.style.colorScheme = value ? 'dark' : 'light';
+ document.documentElement.dataset.themeLight = String(!value);
+ };
+ onMount(() => applyTheme(false));
+ const groups = SETTINGS_TAB_GROUPS.filter(
+ (group) => group.label !== 'Admin'
+ ).map((group) => ({
+ ...group,
+ items: group.items.filter((item) => !item.searchOnly),
+ }));
+ const results = createMemo(() =>
+ searchSettings(SETTINGS_TAB_GROUPS, query())
+ );
+ const title = (page: SettingsTab) =>
+ SETTINGS_TAB_GROUPS.flatMap((group) => group.items).find(
+ (item) => item.tab === page
+ )?.label ?? page;
+ const sampleContent = (page: SettingsTab) => (
+ <Show
+ when={page === 'Email'}
+ fallback={
+ <SettingsPage
+ title={title(page)}
+ description="Sample settings for navigation and layout verification."
+ >
+ <SettingsSection title="Profile">
+ <SettingsCard>
+ <SettingsRow label="Name">Alex Morgan</SettingsRow>
+ </SettingsCard>
+ </SettingsSection>
+ <SettingsSection title="Color Theme">
+ <SettingsCard>
+ <SettingsRow label="Dark mode">
+ <ToggleSwitch checked={dark()} onChange={applyTheme} />
+ </SettingsRow>
+ </SettingsCard>
+ </SettingsSection>
+ <SettingsSection title="Delivery">
+ <SettingsCard>
+ <SettingsRow
+ label="Email digest"
+ description="Get a summary of your notifications."
+ >
+ <ToggleSwitch />
+ </SettingsRow>
+ </SettingsCard>
+ </SettingsSection>
+ </SettingsPage>
+ }
+ >
+ <SettingsPage
+ title="Email"
+ description="Manage your inboxes and the signature you send with each account."
+ >
+ <SettingsSection
+ title="Accounts"
+ description="Connect Gmail accounts and manage their sync with Macro."
+ >
+ <SettingsCard>
+ {(email) => (
+ <SettingsRow label={email} description="Up to date">
+ <Show when={email === '[email protected]'}>
+ <Button variant="outline" size="md">
+ Enable calendar
+ </Button>
+ </Show>
+ <Button variant="ghost" size="md">
+ Remove
+ </Button>
+ </SettingsRow>
+ )}
+ </For>
+ <SettingsRow
+ label="Add another inbox"
+ description="Connect more Gmail accounts."
+ >
+ <Button variant="outline" size="md">
+ Add account
+ </Button>
+ </SettingsRow>
+ </SettingsCard>
+ </SettingsSection>
+ <SettingsSection
+ title="Signatures"
+ description="Create a signature for each of your email accounts. Format text, add links, or insert an image below."
+ >
+ {(email) => <FixtureSignature email={email} />}
+ </For>
+ </SettingsSection>
+ </SettingsPage>
+ </Show>
+ );
+ const content = (page: SettingsTab) => (
+ <Show when={page !== 'Appearance'} fallback={<Appearance />}>
+ <Show when={page !== 'Shortcuts'} fallback={<Shortcuts />}>
+ {sampleContent(page)}
+ </Show>
+ </Show>
+ );
+ return (
+ <div class="h-dvh bg-panel text-ink flex flex-col">
+ <Show when={narrow()}>
+ <style>{`.mobile-settings-sheet {max-width:390px; margin-inline:auto;}`}</style>
+ </Show>
+ <div class="p-2 flex items-center gap-3 border-b border-edge-muted text-xs">
+ <span>Local fixture · changes stay in this preview</span>
+ <Button size="sm" onClick={() => setNarrow(!narrow())}>
+ Narrow layout
+ </Button>
+ <Button size="sm" onClick={() => applyTheme(!dark())}>
+ Toggle theme
+ </Button>
+ <Button size="sm" onClick={() => setMobile(true)}>
+ Mobile settings
+ </Button>
+ </div>
+ <div class="min-h-0 flex-1">
+ <ViewShell.Root main={{ preferredWidth: 960 }}>
+ <ViewShell.Aside>
+ <SettingsSidebar
+ groups={groups}
+ results={results()}
+ selectedResultId={selected()?.id}
+ searchQuery={query()}
+ onSearchQueryChange={setQuery}
+ isItemActive={(item) => item === tab()}
+ onSelect={(page) => {
+ setSelected(undefined);
+ setTab(page);
+ }}
+ onSelectResult={(result) => {
+ setTab(result.tab);
+ setSelected({ ...result });
+ }}
+ onLogout={() => {}}
+ />
+ </ViewShell.Aside>
+ <ViewShell.Main>
+ <div class="h-full min-h-0">
+ <SettingsSearchTarget result={selected()}>
+ {content(tab())}
+ </SettingsSearchTarget>
+ </div>
+ </ViewShell.Main>
+ </ViewShell.Root>
+ </div>
+ <MobileSettingsSheet
+ open={mobile()}
+ page={mobilePage()}
+ groups={groups}
+ searchGroups={SETTINGS_TAB_GROUPS}
+ name="Alex Morgan"
+ avatar="A"
+ onClose={() => {
+ setMobile(false);
+ setMobilePage(undefined);
+ }}
+ onNavigate={setMobilePage}
+ onLogout={() => {}}
+ renderPage={content}
+ />
+ </div>
+ );
+}
+function FixtureSignature(props: { email: string }) {
+ const [saved, setSaved] = createSignal('<p>Alex Morgan</p>');
+ const [value, setValue] = createSignal(saved());
+ const [replies, setReplies] = createSignal(true);
+ const [status, setStatus] = createSignal('');
+ let api: { setContent: (html: string) => void } | undefined;
+ return (
+ <>
+ <SignatureForm
+ email={props.email}
+ value={value()}
+ onInput={setValue}
+ onReady={(editor) => {
+ api = editor;
+ }}
+ onSave={() => {
+ setSaved(value());
+ setStatus('Signature saved');
+ }}
+ onClear={() => {
+ setValue('');
+ setSaved('');
+ api?.setContent('');
+ setStatus('Signature cleared');
+ }}
+ dirty={saved() !== value()}
+ hasContent={!!value()}
+ pending={false}
+ replies={replies()}
+ onRepliesChange={setReplies}
+ mobile={false}
+ />
+ <Show when={status()}>
+ <p role="status" class="text-sm text-ink-muted">
+ {status()}
+ </p>
+ </Show>
+ </>
+ );
+}
+const root = document.getElementById('root');
+if (root) render(() => <Fixture />, root);
diff --git a/apps/web/src/features/settings/browser-test/index.html b/apps/web/src/features/settings/browser-test/index.html
new file mode 100644
index 0000000000..2172463d56
--- /dev/null
+++ b/apps/web/src/features/settings/browser-test/index.html
@@ -0,0 +1 @@
+<!doctype html><html lang="en" data-modality="keyboard"><head><meta charset="UTF-8"/><meta name="viewport" content="width=device-width,initial-scale=1.0"/><title>Settings interaction preview</title></head><body><div id="root"></div><script type="module" src="./fixture.tsx"></script></body></html>
diff --git a/apps/web/src/features/settings/components/appearance-mode-picker.test.tsx b/apps/web/src/features/settings/components/appearance-mode-picker.test.tsx
new file mode 100644
index 0000000000..c3c4be8e58
--- /dev/null
+++ b/apps/web/src/features/settings/components/appearance-mode-picker.test.tsx
@@ -0,0 +1,37 @@
+import { cleanup, fireEvent, render, screen } from '@solidjs/testing-library';
+import { macroDarkTheme } from '@theme/themes/macro-dark';
+import { macroLightTheme } from '@theme/themes/macro-light';
+import { createSignal } from 'solid-js';
+import { afterEach, expect, it } from 'vitest';
+import { AppearanceModePicker } from './appearance-mode-picker';
+
+afterEach(cleanup);
+
+it('offers one mutually exclusive choice and reports the selected appearance mode', () => {
+ let chosen = 'system';
+ render(() => {
+ const [mode, setMode] = createSignal<'system' | 'light' | 'dark'>('system');
+ return (
+ <AppearanceModePicker
+ value={mode()}
+ onChange={(value) => {
+ chosen = value;
+ setMode(value);
+ }}
+ lightTheme={macroLightTheme}
+ darkTheme={macroDarkTheme}
+ />
+ );
+ });
+ const selected = () =>
+ screen
+ .getAllByRole('radio')
+ .filter((radio) => (radio as HTMLInputElement).checked);
+ expect(selected()).toEqual([screen.getByRole('radio', { name: 'System' })]);
+ for (const name of ['Dark', 'Light', 'System']) {
+ const radio = screen.getByRole('radio', { name });
+ fireEvent.click(radio);
+ expect(chosen).toBe(name.toLowerCase());
+ expect(selected()).toEqual([radio]);
+ }
+});
diff --git a/apps/web/src/features/settings/components/appearance-mode-picker.tsx b/apps/web/src/features/settings/components/appearance-mode-picker.tsx
new file mode 100644
index 0000000000..cf1693c1f1
--- /dev/null
+++ b/apps/web/src/features/settings/components/appearance-mode-picker.tsx
@@ -0,0 +1,93 @@
+import type { ThemeV3 } from '@theme/types/themeTypes';
+import { themeCssVars } from '@theme/utils/themeColorTokens';
+import { createUniqueId, For, Show } from 'solid-js';
+
+type AppearanceMode = 'system' | 'light' | 'dark';
+
+/** A small, token-accurate preview of Macro, rather than a generic color chip. */
+function ThemePreview(props: { theme: ThemeV3 }) {
+ return (
+ <div
+ class="absolute inset-0 overflow-hidden rounded-lg bg-page p-2.5"
+ style={{
+ ...themeCssVars(props.theme),
+ '--color-panel': props.theme.colorTokens.panel,
+ }}
+ >
+ <div class="flex h-full overflow-hidden rounded-md border border-edge-muted bg-panel shadow-sm">
+ <div class="flex w-[28%] flex-col gap-1.5 border-r border-edge-muted bg-page p-1.5">
+ <div class="mb-1 flex gap-0.5">
+ <For each={[0, 1, 2]}>
+ {() => <span class="size-1 rounded-full bg-ink/20" />}
+ </For>
+ </div>
+ <div class="h-1.5 rounded-sm bg-accent/25" />
+ <div class="h-1 w-4/5 rounded-sm bg-ink/15" />
+ <div class="h-1 w-3/5 rounded-sm bg-ink/15" />
+ </div>
+ <div class="flex flex-1 flex-col gap-1.5 p-2">
+ <div class="h-1.5 w-2/3 rounded-sm bg-ink/60" />
+ <div class="h-1 w-full rounded-sm bg-ink/15" />
+ <div class="h-1 w-4/5 rounded-sm bg-ink/15" />
+ <div class="mt-auto flex h-6 items-end justify-end rounded border border-edge-muted bg-panel p-1 shadow-sm">
+ <span class="size-2.5 rounded-full bg-accent" />
+ </div>
+ </div>
+ </div>
+ </div>
+ );
+}
+
+export function AppearanceModePicker(props: {
+ value: AppearanceMode;
+ onChange: (mode: AppearanceMode) => void;
+ lightTheme: ThemeV3;
+ darkTheme: ThemeV3;
+}) {
+ const name = createUniqueId();
+ const modes = [
+ { value: 'system', label: 'System' },
+ { value: 'light', label: 'Light' },
+ { value: 'dark', label: 'Dark' },
+ ] as const;
+ return (
+ <fieldset class="min-w-0" aria-label="Appearance mode">
+ <div class="grid grid-cols-3 gap-3">
+ <For each={modes}>
+ {(mode) => (
+ <label class="group flex min-w-0 flex-col items-center gap-2">
+ <input
+ type="radio"
+ name={name}
+ value={mode.value}
+ checked={props.value === mode.value}
+ onChange={() => props.onChange(mode.value)}
+ class="peer sr-only"
+ />
+ <span
+ aria-hidden="true"
+ class="relative block h-24 w-full rounded-xl border border-ink/10 p-1 transition-colors group-hover:border-ink/25 peer-checked:border-accent peer-checked:ring-2 peer-checked:ring-accent/30 peer-focus-visible:outline-2 peer-focus-visible:outline-offset-4 peer-focus-visible:outline-accent"
+ >
+ <span class="absolute inset-1 overflow-hidden rounded-lg">
+ <ThemePreview
+ theme={
+ mode.value === 'dark' ? props.darkTheme : props.lightTheme
+ }
+ />
+ <Show when={mode.value === 'system'}>
+ <span class="absolute inset-0 [clip-path:inset(0_0_0_50%)]">
+ <ThemePreview theme={props.darkTheme} />
+ </span>
+ </Show>
+ </span>
+ </span>
+ <span class="text-sm text-ink-muted peer-checked:font-medium peer-checked:text-ink">
+ {mode.label}
+ </span>
+ </label>
+ )}
+ </For>
+ </div>
+ </fieldset>
+ );
+}
diff --git a/apps/web/src/features/settings/components/bring-your-own-agent.tsx b/apps/web/src/features/settings/components/bring-your-own-agent.tsx
index 4820fe3262..6b1d6c918f 100644
--- a/apps/web/src/features/settings/components/bring-your-own-agent.tsx
+++ b/apps/web/src/features/settings/components/bring-your-own-agent.tsx
@@ -4,52 +4,55 @@ import TerminalIcon from '@phosphor/terminal-window.svg';
import { Button } from '@ui';
import { For } from 'solid-js';
import './bring-your-own-agent.css';
+import { SettingsSurface } from '../primitives';
const AGENTS = ['Claude Code', 'OpenCode', 'OpenClaw', 'Hermes'];
/** A quiet, CSS-only word rotation; reduced motion shows a static invitation. */
export function BringYourOwnAgent(props: { onAddRuntime: () => void }) {
return (
- <section class="byoa-card relative overflow-hidden rounded-xl border border-edge-muted bg-surface-2 p-6">
- <div class="mb-5 flex items-center gap-2 text-xs font-medium text-ink-muted">
- <TerminalIcon class="size-4" />
- Bring your own agent
- </div>
- <h2 class="text-xl font-medium tracking-tight text-ink">
- <span class="sr-only">Bring your agent to Macro</span>
- <span
- aria-hidden="true"
- class="flex flex-wrap items-baseline gap-x-1.5"
- >
- Bring
- <span class="byoa-word text-center text-accent">
- <For each={AGENTS}>
- {(agent, index) => (
- <span style={{ '--word-index': index() }}>{agent}</span>
- )}
- </For>
+ <section>
+ <SettingsSurface class="byoa-card relative overflow-hidden p-6">
+ <div class="mb-5 flex items-center gap-2 text-xs font-medium text-ink-muted">
+ <TerminalIcon class="size-4" />
+ Bring your own agent
+ </div>
+ <h2 class="text-xl font-medium tracking-tight text-ink">
+ <span class="sr-only">Bring your agent to Macro</span>
+ <span
+ aria-hidden="true"
+ class="flex flex-wrap items-baseline gap-x-1.5"
+ >
+ Bring
+ <span class="byoa-word text-center text-accent">
+ <For each={AGENTS}>
+ {(agent, index) => (
+ <span style={{ '--word-index': index() }}>{agent}</span>
+ )}
+ </For>
+ </span>
+ to Macro.
</span>
- to Macro.
- </span>
- </h2>
- <p class="mt-3 max-w-lg text-sm leading-relaxed text-ink-muted">
- Your agent, on your machine. Connect a runtime with macrod, then give
- your agent instructions and a place in your workspace.
- </p>
- <div class="mt-5 flex flex-wrap items-center gap-3">
- <Button variant="outline" size="sm" onClick={props.onAddRuntime}>
- <PlusIcon />
- New runtime
- </Button>
- <a
- href="https://docs.macro.com/AI/bring-your-own"
- target="_blank"
- rel="noopener noreferrer"
- class="inline-flex items-center gap-1 text-xs text-ink-muted hover:text-ink focus-visible:outline-accent"
- >
- Setup guide <ArrowUpRightIcon class="size-3" />
- </a>
- </div>
+ </h2>
+ <p class="mt-3 max-w-lg text-sm leading-relaxed text-ink-muted">
+ Your agent, on your machine. Connect a runtime with macrod, then give
+ your agent instructions and a place in your workspace.
+ </p>
+ <div class="mt-5 flex flex-wrap items-center gap-3">
+ <Button variant="outline" size="sm" onClick={props.onAddRuntime}>
+ <PlusIcon />
+ New runtime
+ </Button>
+ <a
+ href="https://docs.macro.com/AI/bring-your-own"
+ target="_blank"
+ rel="noopener noreferrer"
+ class="inline-flex items-center gap-1 text-xs text-ink-muted hover:text-ink focus-visible:outline-accent"
+ >
+ Setup guide <ArrowUpRightIcon class="size-3" />
+ </a>
+ </div>
+ </SettingsSurface>
</section>
);
}
diff --git a/apps/web/src/features/settings/components/settings-search-results.tsx b/apps/web/src/features/settings/components/settings-search-results.tsx
new file mode 100644
index 0000000000..37517f776a
--- /dev/null
+++ b/apps/web/src/features/settings/components/settings-search-results.tsx
@@ -0,0 +1,51 @@
+import { For, Show } from 'solid-js';
+import { Dynamic } from 'solid-js/web';
+import type { SettingsSearchResult } from '../core/settings-search';
+
+export function SettingsSearchResults(props: {
+ results: SettingsSearchResult[];
+ selectedId?: string;
+ onSelect: (result: SettingsSearchResult) => void;
+}) {
+ return (
+ <nav aria-label="Settings search results" class="flex flex-col gap-1">
+ <span class="sr-only" role="status">
+ {props.results.length} settings found
+ </span>
+ <Show
+ when={props.results.length}
+ fallback={
+ <div class="px-3 py-6 text-sm text-ink-muted">
+ No settings found. Try “signature”, “theme”, or “calendar”.
+ </div>
+ }
+ >
+ <For each={props.results}>
+ {(result) => (
+ <button
+ type="button"
+ aria-current={props.selectedId === result.id ? 'true' : undefined}
+ onClick={() => props.onSelect(result)}
+ class="flex w-full items-start gap-(--sidebar-label-gap) rounded-lg px-(--sidebar-item-inset) py-3 text-left hover:bg-hover focus-visible:outline-2 focus-visible:outline-accent aria-[current=true]:bg-active"
+ >
+ <Dynamic
+ component={result.page.icon}
+ class="mt-0.5 size-(--sidebar-icon-slot) shrink-0 p-0.5 text-ink"
+ />
+ <span class="min-w-0">
+ <span class="block text-sm leading-5 text-ink">
+ {result.title}
+ </span>
+ <Show when={result.title !== result.page.label}>
+ <span class="mt-1 block text-sm text-ink/50">
+ {result.page.label}
+ </span>
+ </Show>
+ </span>
+ </button>
+ )}
+ </For>
+ </Show>
+ </nav>
+ );
+}
diff --git a/apps/web/src/features/settings/components/settings-search-target.test.tsx b/apps/web/src/features/settings/components/settings-search-target.test.tsx
new file mode 100644
index 0000000000..a3369388d5
--- /dev/null
+++ b/apps/web/src/features/settings/components/settings-search-target.test.tsx
@@ -0,0 +1,70 @@
+import { cleanup, render, waitFor } from '@solidjs/testing-library';
+import { createSignal, Show } from 'solid-js';
+import { afterEach, describe, expect, it, vi } from 'vitest';
+import type { SettingsSearchResult } from '../core/settings-search';
+import { SettingsSearchTarget } from './settings-search-target';
+
+const result: SettingsSearchResult = {
+ id: 'Email:Signatures',
+ tab: 'Email',
+ title: 'Signatures',
+ target: 'signatures',
+ keywords: '',
+ page: { tab: 'Email', label: 'Email', keywords: [], icon: () => null },
+};
+afterEach(cleanup);
+describe('settings search navigation', () => {
+ it('scrolls only the page, keeping the surrounding drawer header in place', () => {
+ const scroll = vi.fn();
+ const { getByText } = render(() => (
+ <SettingsSearchTarget result={result}>
+ <div
+ data-settings-page
+ ref={(el) => {
+ el.scrollTo = scroll;
+ }}
+ >
+ <section data-settings-target="signatures">Signature editor</section>
+ </div>
+ </SettingsSearchTarget>
+ ));
+ expect(scroll).toHaveBeenCalledOnce();
+ expect(document.activeElement).toBe(getByText('Signature editor'));
+ });
+ it('waits for a lazy section to become available', async () => {
+ const [ready, setReady] = createSignal(false);
+ const { getByText } = render(() => (
+ <SettingsSearchTarget result={result}>
+ <div
+ data-settings-page
+ ref={(el) => {
+ el.scrollTo = vi.fn();
+ }}
+ >
+ <Show when={ready()}>
+ <section data-settings-target="signatures">Loaded editor</section>
+ </Show>
+ </div>
+ </SettingsSearchTarget>
+ ));
+ setReady(true);
+ await waitFor(() =>
+ expect(document.activeElement).toBe(getByText('Loaded editor'))
+ );
+ });
+ it('focuses the heading for a page-level result', () => {
+ const { getByText } = render(() => (
+ <SettingsSearchTarget result={{ ...result, target: undefined }}>
+ <div
+ data-settings-page
+ ref={(el) => {
+ el.scrollTo = vi.fn();
+ }}
+ >
+ <h1>Email</h1>
+ </div>
+ </SettingsSearchTarget>
+ ));
+ expect(document.activeElement).toBe(getByText('Email'));
+ });
+});
diff --git a/apps/web/src/features/settings/components/settings-search-target.tsx b/apps/web/src/features/settings/components/settings-search-target.tsx
new file mode 100644
index 0000000000..6ea6fc70d4
--- /dev/null
+++ b/apps/web/src/features/settings/components/settings-search-target.tsx
@@ -0,0 +1,59 @@
+import { createEffect, type JSX, onCleanup } from 'solid-js';
+import type { SettingsSearchResult } from '../core/settings-search';
+
+/** Waits for a routed/lazy settings page, then reveals its matching control. */
+export function SettingsSearchTarget(props: {
+ result?: SettingsSearchResult;
+ children: JSX.Element;
+}) {
+ let root!: HTMLDivElement;
+ createEffect(() => {
+ const result = props.result;
+ if (!result) return;
+ let highlighted: HTMLElement | undefined;
+ const reveal = () => {
+ const candidates = root.querySelectorAll<HTMLElement>(
+ '[data-settings-target]'
+ );
+ const target = result.target
+ ? [...candidates].find(
+ (el) => el.dataset.settingsTarget === result.target
+ )
+ : root.querySelector<HTMLElement>('[data-settings-page] h1');
+ if (!target) return false;
+ target.tabIndex = -1;
+ const page = target.closest<HTMLElement>('[data-settings-page]');
+ if (page)
+ page.scrollTo({
+ top:
+ page.scrollTop +
+ target.getBoundingClientRect().top -
+ page.getBoundingClientRect().top -
+ 16,
+ behavior: 'instant',
+ });
+ target.focus({ preventScroll: true });
+ target.classList.add('ring-2', 'ring-accent', 'ring-offset-2');
+ highlighted = target;
+ return true;
+ };
+ const observer = new MutationObserver(() => {
+ if (reveal()) observer.disconnect();
+ });
+ if (!reveal()) observer.observe(root, { childList: true, subtree: true });
+ const timeout = setTimeout(() => {
+ observer.disconnect();
+ highlighted?.classList.remove('ring-2', 'ring-accent', 'ring-offset-2');
+ }, 4000);
+ onCleanup(() => {
+ clearTimeout(timeout);
+ observer.disconnect();
+ highlighted?.classList.remove('ring-2', 'ring-accent', 'ring-offset-2');
+ });
+ });
+ return (
+ <div ref={root} class="relative h-full min-h-0">
+ {props.children}
+ </div>
+ );
+}
diff --git a/apps/web/src/features/settings/components/settings-sidebar.tsx b/apps/web/src/features/settings/components/settings-sidebar.tsx
new file mode 100644
index 0000000000..8154d978de
--- /dev/null
+++ b/apps/web/src/features/settings/components/settings-sidebar.tsx
@@ -0,0 +1,121 @@
+import { SearchBar, ViewSidebar } from '@app/components/view-shell';
+import type { SettingsTab } from '@core/constant/SettingsState';
+import type { SettingsTabGroup } from '@core/constant/settingsTabsConfig';
+import SignOutIcon from '@phosphor/sign-out.svg';
+import { pressHandlers } from '@ui';
+import { For, Show } from 'solid-js';
+import { Dynamic } from 'solid-js/web';
+import type { SettingsSearchResult } from '../core/settings-search';
+import { SettingsSearchResults } from './settings-search-results';
+
+/**
+ * Settings' inner navigation, laid out like every other view's sidebar: a
+ * title bar, a search field, the grouped section pills, and Log out pinned to
+ * the bottom.
+ */
+export function SettingsSidebar(props: {
+ groups: SettingsTabGroup[];
+ results: SettingsSearchResult[];
+ selectedResultId?: string;
+ onSelectResult: (result: SettingsSearchResult) => void;
+ searchQuery: string;
+ onSearchQueryChange: (query: string) => void;
+ isItemActive: (tab: SettingsTab) => boolean;
+ onSelect: (tab: SettingsTab) => void;
+ onLogout: () => void;
+}) {
+ let root: HTMLDivElement | undefined;
+ return (
+ <ViewSidebar.Root
+ ref={root}
+ aria-label="Settings navigation"
+ class="bg-[color-mix(in_srgb,var(--color-panel)_99%,var(--color-ink))]"
+ >
+ <ViewSidebar.Header>
+ <div class="flex min-w-0 items-center gap-1">
+ <ViewSidebar.CloseButton class="shrink-0" />
+ <ViewSidebar.Title>Settings</ViewSidebar.Title>
+ </div>
+ </ViewSidebar.Header>
+
+ <ViewSidebar.Primary>
+ <SearchBar
+ label="Search settings"
+ placeholder="Search settings"
+ autocomplete="off"
+ value={props.searchQuery}
+ onValueChange={props.onSearchQueryChange}
+ class="border-0 bg-ink/5 shadow-none"
+ onEscape={() => props.onSearchQueryChange('')}
+ onKeyDown={(event) => {
+ if (event.key === 'ArrowDown') {
+ const first =
+ root?.querySelector<HTMLButtonElement>('nav button');
+ if (first) {
+ event.preventDefault();
+ first.focus();
+ }
+ }
+ }}
+ />
+ </ViewSidebar.Primary>
+
+ <ViewSidebar.Content>
+ <Show
+ when={!props.searchQuery.trim()}
+ fallback={
+ <SettingsSearchResults
+ results={props.results}
+ selectedId={props.selectedResultId}
+ onSelect={props.onSelectResult}
+ />
+ }
+ >
+ <Show
+ when={props.groups.length > 0}
+ fallback={
+ <div class="py-4 text-center text-sm text-ink-muted">
+ No settings found
+ </div>
+ }
+ >
+ <For each={props.groups}>
+ {(group) => (
+ <section class="flex min-w-0 flex-col gap-0.5">
+ <h2 class="flex h-7 min-w-0 items-center px-(--sidebar-item-inset) text-xs font-medium text-ink/50">
+ <span class="truncate">{group.label}</span>
+ </h2>
+ <ViewSidebar.Nav aria-label={group.label}>
+ <For each={group.items}>
+ {(item) => (
+ <ViewSidebar.Item
+ active={props.isItemActive(item.tab)}
+ class="text-ink"
+ {...pressHandlers(() => props.onSelect(item.tab))}
+ >
+ <ViewSidebar.Icon>
+ <Dynamic component={item.icon} class="size-4" />
+ </ViewSidebar.Icon>
+ <span class="truncate">{item.label}</span>
+ </ViewSidebar.Item>
+ )}
+ </For>
+ </ViewSidebar.Nav>
+ </section>
+ )}
+ </For>
+ </Show>
+ </Show>
+ </ViewSidebar.Content>
+
+ <ViewSidebar.Footer class="py-(--sidebar-gutter)">
+ <ViewSidebar.Item {...pressHandlers(() => props.onLogout())}>
+ <ViewSidebar.Icon>
+ <SignOutIcon class="size-4" />
+ </ViewSidebar.Icon>
+ <span class="truncate">Log out</span>
+ </ViewSidebar.Item>
+ </ViewSidebar.Footer>
+ </ViewSidebar.Root>
+ );
+}
diff --git a/apps/web/src/features/settings/components/signature-form.tsx b/apps/web/src/features/settings/components/signature-form.tsx
new file mode 100644
index 0000000000..14e4f79603
--- /dev/null
+++ b/apps/web/src/features/settings/components/signature-form.tsx
@@ -0,0 +1,100 @@
+import SignatureIcon from '@phosphor-icons/core/regular/signature.svg?component-solid';
+import { ToggleSwitch } from '@ui';
+import { lazy, Show, Suspense } from 'solid-js';
+
+import { SettingsButton as Button, SettingsSurface } from '../primitives';
+
+const SignatureEditor = lazy(() => import('../SignatureEditor'));
+
+export function SignatureForm(props: {
+ email: string;
+ value: string;
+ onInput: (html: string) => void;
+ onReady: (api: { setContent: (html: string) => void }) => void;
+ onSave: () => void;
+ onClear: () => void;
+ dirty: boolean;
+ hasContent: boolean;
+ pending: boolean;
+ replies: boolean;
+ onRepliesChange: (checked: boolean) => void;
+ error?: string | null;
+ mobile: boolean;
+}) {
+ return (
+ <SettingsSurface class="@container/signature flex flex-col gap-4 rounded-2xl border border-edge-muted p-4">
+ <div>
+ <h3 class="text-base font-medium break-all">{props.email}</h3>
+ <p class="mt-1 text-sm text-ink-muted">
+ Automatically added to new emails from this account.
+ </p>
+ </div>
+ {/* Editing (Quill) is desktop-only; on mobile the section still offers
+ the replies/forwards toggle and Remove, with a pointer to desktop. */}
+ <Show
+ when={!props.mobile}
+ fallback={
+ <div class="flex flex-col items-center gap-1.5 rounded-lg border border-dashed border-edge-muted px-3 py-6 text-center">
+ <SignatureIcon class="size-5 text-ink-muted" />
+ <p class="text-sm text-ink-muted">
+ Update your signature on desktop.
+ </p>
+ </div>
+ }
+ >
+ <Suspense
+ fallback={
+ <div class="h-44 animate-pulse rounded-lg border-1 border-ink/10" />
+ }
+ >
+ <SignatureEditor
+ label={`Signature for ${props.email}`}
+ value={props.value}
+ disabled={props.pending}
+ onInput={props.onInput}
+ onReady={props.onReady}
+ />
+ </Suspense>
+ </Show>
+ {/* Stacks on narrow screens so the toggle label and buttons never
+ crowd each other onto wrapped lines. */}
+ <div class="flex flex-col gap-3 @[520px]/signature:flex-row @[520px]/signature:items-center @[520px]/signature:justify-between">
+ <ToggleSwitch
+ checked={props.replies}
+ onChange={props.onRepliesChange}
+ disabled={props.pending}
+ label={
+ <span class="text-sm text-ink-muted">
+ Add to replies & forwards
+ </span>
+ }
+ />
+ <div class="flex items-center justify-end gap-2">
+ <Button
+ variant="outline"
+ size="md"
+ depth={3}
+ disabled={!props.hasContent || props.pending}
+ onClick={props.onClear}
+ >
+ Clear signature
+ </Button>
+ <Show when={!props.mobile}>
+ <Button
+ variant="cta"
+ size="md"
+ depth={3}
+ disabled={!props.dirty || props.pending}
+ onClick={props.onSave}
+ >
+ {props.pending ? 'Saving…' : 'Save signature'}
+ </Button>
+ </Show>
+ </div>
+ </div>
+ <Show when={props.error}>
+ {(msg) => <p class="text-right text-sm text-failure-ink">{msg()}</p>}
+ </Show>
+ </SettingsSurface>
+ );
+}
diff --git a/apps/web/src/features/settings/connections/ConnectionsPage.tsx b/apps/web/src/features/settings/connections/ConnectionsPage.tsx
index bab8ac2e1a..d81cfe205f 100644
--- a/apps/web/src/features/settings/connections/ConnectionsPage.tsx
+++ b/apps/web/src/features/settings/connections/ConnectionsPage.tsx
@@ -61,7 +61,7 @@ function ConnectionsContent(props: { onOpenMacroMcp: () => void }) {
when={!error()}
fallback={
<SettingsPage
- title="Connections"
+ title="Agent connections"
description={description}
onBack={view.provider() ? view.closeProvider : undefined}
>
@@ -79,7 +79,7 @@ function ConnectionsContent(props: { onOpenMacroMcp: () => void }) {
keyed
fallback={
<SettingsPage
- title="Connections"
+ title="Agent connections"
description={description}
signpost={<MacroMcpSignpost onOpen={props.onOpenMacroMcp} />}
>
diff --git a/apps/web/src/features/settings/connections/primitives.tsx b/apps/web/src/features/settings/connections/primitives.tsx
index 32ef45dcbe..2165728d16 100644
--- a/apps/web/src/features/settings/connections/primitives.tsx
+++ b/apps/web/src/features/settings/connections/primitives.tsx
@@ -1,7 +1,10 @@
import CaretLeftIcon from '@phosphor/caret-left.svg';
-import { cn, Layer } from '@ui';
+import { cn } from '@ui';
import { type JSX, Show, useContext } from 'solid-js';
-import { SettingsSheetContext } from '../primitives';
+import {
+ SettingsSheetContext,
+ SettingsCard as SharedSettingsCard,
+} from '../primitives';
/*
* Connections presentation adapted from #6151. Kept local to the Connections
@@ -39,18 +42,19 @@ export function SettingsPage(props: {
const inSheet = useContext(SettingsSheetContext);
return (
<div
+ data-settings-page
data-drawer-scroll-body={inSheet ? true : undefined}
- class="h-full min-h-0 overflow-y-auto [overflow-anchor:none]"
+ class="h-full min-h-0 overflow-y-auto [overflow-anchor:none] bg-[color-mix(in_srgb,var(--color-panel)_99%,var(--color-ink))] [&_[data-variant=cta]]:bg-ink [&_[data-variant=cta]]:text-panel [&_[data-variant=cta]]:focus-visible:ring-panel/70 [&_:has(>input[type=checkbox])]:[--color-accent:var(--color-ink)] [&_input[type=checkbox]]:accent-ink"
>
{/* On mobile/tablet the page is full-frame: the chrome insets live inside the
scroll content (plus the usual breathing room) so pages scroll under
the floating header and bottom rows like every other block. */}
<div
class={cn(
- 'mx-auto w-full max-w-[710px]',
+ 'mx-auto w-full max-w-[960px]',
inSheet
? 'px-3 pt-2 pb-[max(24px,var(--mobile-sheet-safe-padding))]'
- : 'px-10 pt-4 pb-24 touch:px-5 touch:pt-[calc(var(--mobile-content-inset-top,0px)+2rem)] touch:pb-[calc(var(--mobile-content-inset-bottom,0px)+3rem)]'
+ : 'px-12 pt-8 pb-24 touch:px-5 touch:pt-[calc(var(--mobile-content-inset-top,0px)+2rem)] touch:pb-[calc(var(--mobile-content-inset-bottom,0px)+3rem)]'
)}
>
<Show when={props.onBack}>
@@ -72,7 +76,7 @@ export function SettingsPage(props: {
{props.icon}
</div>
</Show>
- <h1 class="min-w-0 text-2xl/tight font-semibold text-ink">
+ <h1 class="min-w-0 text-[26px]/tight font-medium tracking-[-0.025em] text-ink">
{props.title}
</h1>
</div>
@@ -89,7 +93,7 @@ export function SettingsPage(props: {
<Show when={props.signpost}>{props.signpost}</Show>
</header>
<div
- class={cn('flex flex-col', inSheet ? 'mt-3 gap-6' : 'mt-9 gap-10')}
+ class={cn('flex flex-col', inSheet ? 'mt-3 gap-6' : 'mt-12 gap-12')}
>
{props.children}
</div>
@@ -98,41 +102,7 @@ export function SettingsPage(props: {
);
}
-/**
- * A titled group within a page. The heading/description are optional so a page
- * can also drop a bare card straight under the title.
- */
-export function SettingsSection(props: {
- title?: JSX.Element;
- description?: string;
- /** Right-aligned controls beside the section heading. */
- actions?: JSX.Element;
- class?: string;
- children: JSX.Element;
-}) {
- return (
- <section class={cn('flex flex-col gap-3', props.class)}>
- <Show when={props.title || props.actions}>
- <div class="flex items-end justify-between gap-4">
- <div class="flex flex-col gap-0.5 min-w-0">
- <Show when={props.title}>
- <h2 class="text-[15px] font-semibold text-ink">{props.title}</h2>
- </Show>
- <Show when={props.description}>
- <p class="text-sm text-ink-muted text-balance">
- {props.description}
- </p>
- </Show>
- </div>
- <Show when={props.actions}>
- <div class="shrink-0">{props.actions}</div>
- </Show>
- </div>
- </Show>
- {props.children}
- </section>
- );
-}
+export { SettingsSection } from '../primitives';
/**
* A quiet outlined card. Direct children are treated as rows and get a divider
@@ -141,20 +111,10 @@ export function SettingsSection(props: {
* `border-1` is 1px. The default `border` utility is a 0.5px hairline.
*/
export function SettingsCard(props: { class?: string; children: JSX.Element }) {
- // Raised a level above the content panel so the card reads as a subtly
- // lighter surface (theme-safe via the depth system) rather than just an
- // outline on the same fill.
return (
- <Layer depth={2}>
- <div
- class={cn(
- '@container rounded-xl border-1 border-ink/[0.05] bg-surface overflow-hidden settings-row-dividers',
- props.class
- )}
- >
- {props.children}
- </div>
- </Layer>
+ <SharedSettingsCard class={cn('@container', props.class)}>
+ {props.children}
+ </SharedSettingsCard>
);
}
@@ -182,7 +142,7 @@ export function SettingsRow(props: {
return (
<div
class={cn(
- 'flex gap-4 px-6 py-3.5 min-h-[60px]',
+ 'flex gap-4 px-4 py-3.5 min-h-[60px]',
props.stackOnNarrow
? 'flex-col gap-3 @[460px]:flex-row @[460px]:justify-between @[460px]:gap-4'
: 'justify-between',
@@ -210,7 +170,7 @@ export function SettingsRow(props: {
<Show when={props.description}>
<div
class={cn(
- 'text-xs text-ink-extra-muted text-balance mobile:text-[11px]',
+ 'text-sm text-ink-muted text-balance',
props.hideDescriptionOnMobile && 'mobile:hidden'
)}
>
@@ -255,7 +215,7 @@ export function IntegrationRow(props: {
class?: string;
}) {
return (
- <div class={cn('flex items-start gap-4 px-6 py-5 touch:px-4', props.class)}>
+ <div class={cn('flex items-start gap-4 px-4 py-5', props.class)}>
<Show when={props.icon}>
<div
class={cn(
diff --git a/apps/web/src/features/settings/core/settings-search.test.ts b/apps/web/src/features/settings/core/settings-search.test.ts
new file mode 100644
index 0000000000..1f2287b5e4
--- /dev/null
+++ b/apps/web/src/features/settings/core/settings-search.test.ts
@@ -0,0 +1,73 @@
+import { SETTINGS_TAB_GROUPS } from '@core/constant/settingsTabsConfig';
+import { describe, expect, it } from 'vitest';
+import { searchSettings } from './settings-search';
+
+const search = (query: string) => searchSettings(SETTINGS_TAB_GROUPS, query);
+describe('individual settings search', () => {
+ it('routes calendar connections and scheduling controls to separate pages', () => {
+ expect(
+ search('calendar color').find(
+ (result) => result.title === 'Connected calendars'
+ )
+ ).toMatchObject({
+ tab: 'Calendar',
+ target: 'connected-calendars',
+ });
+ expect(search('working hours')[0]).toMatchObject({
+ tab: 'Booking links',
+ target: 'availability',
+ });
+ expect(search('reschedule')[0]).toMatchObject({
+ tab: 'Booking links',
+ target: 'bookings',
+ });
+ });
+ it('finds and targets a signature without knowing its page', () => {
+ expect(search('signatre')[0]).toMatchObject({
+ tab: 'Email',
+ title: 'Email signatures',
+ target: 'signatures',
+ });
+ });
+ it('tolerates transposed and wrong letters', () => {
+ expect(search('singature')[0].title).toBe('Email signatures');
+ expect(search('signoture')[0].title).toBe('Email signatures');
+ });
+ it('requires every word and combines page and setting terms', () => {
+ expect(search('calendar color').map((item) => item.title)).toContain(
+ 'Connected calendars'
+ );
+ expect(search('email digest')[0].target).toBe('email-digest');
+ expect(search('signature xyz123')).toEqual([]);
+ });
+ it('ranks a specific control above a broad keyword match', () => {
+ expect(search('theme')[0].title).toBe('Color theme');
+ expect(search('replies').some((item) => item.tab === 'Notifications')).toBe(
+ true
+ );
+ });
+ it('never returns pages excluded by feature or permission gates', () => {
+ const groups = SETTINGS_TAB_GROUPS.map((group) => ({
+ ...group,
+ items: group.items.filter((item) => item.tab !== 'Email'),
+ }));
+ expect(searchSettings(groups, 'signature')).toEqual([]);
+ });
+ it('keeps runtime credentials separate from Macro API keys', () => {
+ expect(search('cursor')[0].tab).toBe('Harness');
+ expect(search('cursor').some((item) => item.tab === 'API Keys')).toBe(
+ false
+ );
+ });
+ it('omits disabled signature controls', () => {
+ expect(
+ searchSettings(SETTINGS_TAB_GROUPS, 'signature', {
+ emailSignatures: false,
+ }).some((result) => result.title === 'Email signatures')
+ ).toBe(false);
+ });
+ it('has no results for empty or unrelated queries', () => {
+ expect(search(' ')).toEqual([]);
+ expect(search('xyz123')).toEqual([]);
+ });
+});
diff --git a/apps/web/src/features/settings/core/settings-search.ts b/apps/web/src/features/settings/core/settings-search.ts
new file mode 100644
index 0000000000..e57b8fba98
--- /dev/null
+++ b/apps/web/src/features/settings/core/settings-search.ts
@@ -0,0 +1,375 @@
+import type { SettingsTab } from '@core/constant/SettingsState';
+import type {
+ SettingsTabGroup,
+ SettingsTabItem,
+} from '@core/constant/settingsTabsConfig';
+import { NOTIFICATION_EVENT_GROUPS } from '../../notifications/notification-event-catalog';
+import { settingsTarget } from './settings-target';
+
+type Setting = {
+ tab: SettingsTab;
+ title: string;
+ target?: string;
+ keywords: string;
+};
+export type SettingsSearchResult = Setting & {
+ id: string;
+ page: SettingsTabItem;
+};
+
+// Targets are the visible SettingsSection/SettingsRow labels, not DOM selectors.
+// Keep individual controls here so finding a setting doesn't require its page name.
+const SETTINGS: Setting[] = [
+ {
+ tab: 'CRM',
+ title: 'Deal stages',
+ target: 'Deal stages',
+ keywords: 'pipeline reorder status closed stages sales',
+ },
+ {
+ tab: 'CRM',
+ title: 'Enable CRM',
+ target: 'General',
+ keywords: 'disable customers contacts companies team',
+ },
+ {
+ tab: 'Shortcuts',
+ title: 'Search and command menu shortcuts',
+ target: 'Core',
+ keywords: 'keyboard hotkeys find create settings chat',
+ },
+ {
+ tab: 'Shortcuts',
+ title: 'Split navigation shortcuts',
+ target: 'Splits',
+ keywords: 'keyboard hotkeys back forward panel close',
+ },
+ {
+ tab: 'Shortcuts',
+ title: 'List and email shortcuts',
+ target: 'Unified List',
+ keywords: 'keyboard hotkeys select read unread delete preview',
+ },
+
+ ...NOTIFICATION_EVENT_GROUPS.flatMap((group) =>
+ group.events.map((event) => ({
+ tab: 'Notifications' as const,
+ title: `${event.label} · ${group.label}`,
+ target: group.label,
+ keywords: `${group.label} ${event.description}`,
+ }))
+ ),
+ {
+ tab: 'Email',
+ title: 'Email accounts',
+ target: 'Accounts',
+ keywords: 'gmail connect add inbox sync reconnect remove',
+ },
+ {
+ tab: 'Email',
+ title: 'Email signatures',
+ target: 'Signatures',
+ keywords: 'signature footer signoff formatting image replies forwards',
+ },
+ {
+ tab: 'Calendar',
+ title: 'Connected calendars',
+ target: 'Connected calendars',
+ keywords:
+ 'google gmail connect accounts visibility show hide color colour subcalendar',
+ },
+ {
+ tab: 'Booking links',
+ title: 'Booking links',
+ target: 'Booking links',
+ keywords: 'event types meeting duration scheduling public link',
+ },
+ {
+ tab: 'Booking links',
+ title: 'Availability',
+ target: 'Availability',
+ keywords: 'working hours timezone schedule time zone',
+ },
+ {
+ tab: 'Booking links',
+ title: 'Booking page',
+ target: 'Booking pages',
+ keywords: 'public profile scheduling name username',
+ },
+ {
+ tab: 'Booking links',
+ title: 'Bookings',
+ target: 'Bookings',
+ keywords: 'upcoming past cancel reschedule meetings',
+ },
+ {
+ tab: 'Booking links',
+ title: 'Scheduling teams',
+ target: 'Teams',
+ keywords: 'members collective round robin',
+ },
+ {
+ tab: 'Booking links',
+ title: 'Scheduling insights',
+ target: 'Insights',
+ keywords: 'analytics statistics',
+ },
+ {
+ tab: 'Agents',
+ title: 'Team agents',
+ target: 'Team agents',
+ keywords: 'shared ai assistant configure',
+ },
+ {
+ tab: 'Agents',
+ title: 'Private agents',
+ target: 'Private agents',
+ keywords: 'personal ai assistant configure',
+ },
+ {
+ tab: 'Harness',
+ title: 'Agent runtimes and credentials',
+ keywords: 'cursor harness runtime api key provider pairing daemon',
+ },
+ {
+ tab: 'Account',
+ title: 'Profile picture',
+ target: 'Profile',
+ keywords: 'avatar photo image',
+ },
+ {
+ tab: 'Account',
+ title: 'Name and email address',
+ target: 'Profile',
+ keywords: 'first last profile account',
+ },
+ {
+ tab: 'Account',
+ title: 'Delete account',
+ target: 'Delete account',
+ keywords: 'remove close deletion',
+ },
+ {
+ tab: 'Appearance',
+ title: 'Color theme',
+ target: 'Color Theme',
+ keywords: 'dark light system mode custom colour',
+ },
+ {
+ tab: 'Appearance',
+ title: 'Monochrome icons',
+ target: 'Monochrome icons',
+ keywords: 'color colourful sidebar',
+ },
+ {
+ tab: 'Appearance',
+ title: 'Show tooltips',
+ target: 'Show tooltips',
+ keywords: 'hover hints help',
+ },
+ {
+ tab: 'Notifications',
+ title: 'Notification delivery',
+ target: 'Delivery',
+ keywords: 'push desktop browser mobile alerts permissions',
+ },
+ {
+ tab: 'Notifications',
+ title: 'Email digest',
+ target: 'Email digest',
+ keywords: 'summary notification daily mail',
+ },
+ {
+ tab: 'Notifications',
+ title: 'Snoozed items',
+ target: 'Snoozed items',
+ keywords: 'pause resume notifications',
+ },
+ {
+ tab: 'Notifications',
+ title: 'Muted items',
+ target: 'Muted items',
+ keywords: 'unmute silence notifications',
+ },
+ {
+ tab: 'Billing',
+ title: 'Plan and payment',
+ target: 'Subscription',
+ keywords: 'subscription invoice billing credit card cancel manage upgrade',
+ },
+ {
+ tab: 'Billing',
+ title: 'AI usage',
+ target: 'AI usage',
+ keywords: 'limits quota tokens credits consumption',
+ },
+ {
+ tab: 'Team',
+ title: 'Team name and URL',
+ target: 'General',
+ keywords: 'workspace slug rename',
+ },
+ {
+ tab: 'Team',
+ title: 'Members',
+ target: 'Members',
+ keywords: 'invite users role permissions remove workspace team',
+ },
+ {
+ tab: 'Team',
+ title: 'Pending invites',
+ target: 'Pending invites',
+ keywords: 'invitations cancel resend',
+ },
+ {
+ tab: 'Team',
+ title: 'Auto-join on domain',
+ target: 'Auto-join on domain',
+ keywords: 'email workspace membership automatic',
+ },
+ {
+ tab: 'Team',
+ title: 'Members can invite',
+ target: 'Members can invite',
+ keywords: 'permissions invitation',
+ },
+ {
+ tab: 'Team',
+ title: 'Default link sharing',
+ target: 'Default link sharing',
+ keywords: 'access public private permission',
+ },
+ {
+ tab: 'Team',
+ title: 'Team GitHub connection',
+ target: 'Connections',
+ keywords: 'repository app install integration',
+ },
+ {
+ tab: 'Tags',
+ title: 'Personal tags',
+ target: 'Personal',
+ keywords: 'label organize category',
+ },
+ {
+ tab: 'Tags',
+ title: 'Team tags',
+ target: 'Team',
+ keywords: 'shared label workspace category',
+ },
+ {
+ tab: 'Connected',
+ title: 'GitHub account',
+ target: 'Accounts',
+ keywords: 'connect integration repository pull request',
+ },
+ {
+ tab: 'Connections',
+ title: 'Agent apps and tools',
+ keywords: 'mcp integration connect external services',
+ },
+ {
+ tab: 'Agent',
+ title: 'Connect to the Macro MCP server',
+ keywords: 'claude chatgpt external client url setup',
+ },
+ {
+ tab: 'API Keys',
+ title: 'Create and revoke API keys',
+ keywords: 'token secret developer authentication',
+ },
+ {
+ tab: 'Mobile App',
+ title: 'Get the mobile app',
+ keywords: 'download phone ios android qr code',
+ },
+];
+
+function words(value: string): string[] {
+ return (
+ value
+ .toLowerCase()
+ .normalize('NFKD')
+ .replace(/[\u0300-\u036f]/g, '')
+ .match(/[a-z0-9]+/g) ?? []
+ );
+}
+
+/** One insertion, deletion, substitution, or adjacent transposition. */
+function isNearWord(a: string, b: string): boolean {
+ if (a.length < 4 || Math.abs(a.length - b.length) > 1) return false;
+ let i = 0;
+ while (i < a.length && a[i] === b[i]) i++;
+ if (a.length === b.length) {
+ return (
+ a.slice(i + 1) === b.slice(i + 1) ||
+ (a[i] === b[i + 1] &&
+ a[i + 1] === b[i] &&
+ a.slice(i + 2) === b.slice(i + 2))
+ );
+ }
+ return a.length > b.length
+ ? a.slice(i + 1) === b.slice(i)
+ : a.slice(i) === b.slice(i + 1);
+}
+
+function tokenScore(query: string, candidate: string): number {
+ if (query === candidate) return 12;
+ if (candidate.startsWith(query)) return 9;
+ if (query.length >= 3 && candidate.includes(query)) return 6;
+ if (
+ isNearWord(query, candidate) ||
+ (candidate.endsWith('s') && isNearWord(query, candidate.slice(0, -1)))
+ )
+ return 4;
+ return 0;
+}
+
+export function searchSettings(
+ groups: readonly SettingsTabGroup[],
+ query: string,
+ options: { emailSignatures?: boolean } = {}
+): SettingsSearchResult[] {
+ const tokens = words(query);
+ if (!tokens.length) return [];
+ const pages = groups.flatMap((group) => group.items);
+ const entries = pages.flatMap((page) => [
+ {
+ id: page.tab,
+ tab: page.tab,
+ title: page.label,
+ keywords: page.keywords.join(' '),
+ page,
+ },
+ ...SETTINGS.filter(
+ (setting) =>
+ setting.tab === page.tab &&
+ (options.emailSignatures !== false ||
+ setting.title !== 'Email signatures')
+ ).map((setting) => ({
+ ...setting,
+ target: settingsTarget(setting.target),
+ id: `${page.tab}:${setting.title}`,
+ page,
+ })),
+ ]);
+ return entries
+ .map((entry) => {
+ const titleWords = words(entry.title);
+ const otherWords = words(`${entry.keywords} ${entry.page.label}`);
+ const scores = tokens.map((token) =>
+ Math.max(
+ 0,
+ ...titleWords.map((word) => tokenScore(token, word) * 2),
+ ...otherWords.map((word) => tokenScore(token, word))
+ )
+ );
+ const score = scores.every(Boolean)
+ ? scores.reduce((a, b) => a + b, 0)
+ : 0;
+ return { entry, score };
+ })
+ .filter(({ score }) => score > 0)
+ .sort((a, b) => b.score - a.score)
+ .map(({ entry }) => entry);
+}
diff --git a/apps/web/src/features/settings/core/settings-target.ts b/apps/web/src/features/settings/core/settings-target.ts
new file mode 100644
index 0000000000..b73b6875bd
--- /dev/null
+++ b/apps/web/src/features/settings/core/settings-target.ts
@@ -0,0 +1,7 @@
+/** Shared by the search catalog and the actual section/row markup. */
+export function settingsTarget(label?: string): string | undefined {
+ return label
+ ?.toLowerCase()
+ .replace(/[^a-z0-9]+/g, '-')
+ .replace(/^-|-$/g, '');
+}
diff --git a/apps/web/src/features/settings/email-settings.tsx b/apps/web/src/features/settings/email-settings.tsx
new file mode 100644
index 0000000000..3ff300ffc7
--- /dev/null
+++ b/apps/web/src/features/settings/email-settings.tsx
@@ -0,0 +1,148 @@
+import { useFeatureFlag } from '@app/lib/analytics/posthog';
+import { enableEmailSignatures } from '@core/constant/featureFlags';
+import { useSettingsState } from '@core/constant/SettingsState';
+import { useSettingsTabAvailable } from '@core/constant/settingsTabsConfig';
+import { useUserId } from '@core/context/user';
+import { useEmailLinks } from '@core/email-link';
+import { Button } from '@ui';
+import { For, Show, Suspense } from 'solid-js';
+import { EmailCard } from './Email';
+import {
+ SettingsCard,
+ SettingsPage,
+ SettingsRow,
+ SettingsSection,
+} from './primitives';
+import { SignatureSection } from './SignatureSection';
+
+export function EmailSettings() {
+ const signatures = useFeatureFlag(enableEmailSignatures);
+ const { openSettings } = useSettingsState();
+ const isAvailable = useSettingsTabAvailable();
+ return (
+ <SettingsPage
+ title="Email"
+ description="Manage your inboxes and the signature you send with each account."
+ >
+ <SettingsSection
+ title="Accounts"
+ description="Connect Gmail accounts and manage their sync with Macro."
+ >
+ <Suspense
+ fallback={
+ <p role="status" class="text-sm text-ink-muted">
+ Loading accounts…
+ </p>
+ }
+ >
+ <EmailCard />
+ </Suspense>
+ </SettingsSection>
+ <Show when={signatures().enabled}>
+ <SettingsSection
+ title="Signatures"
+ description="Create a signature for each of your email accounts. Format text, add links, or insert an image below."
+ >
+ <Suspense
+ fallback={
+ <p role="status" class="text-sm text-ink-muted">
+ Loading signatures…
+ </p>
+ }
+ >
+ <EmailSignatures />
+ </Suspense>
+ </SettingsSection>
+ </Show>
+ <Show when={isAvailable('Notifications') || isAvailable('Calendar')}>
+ <SettingsSection title="Related settings">
+ <SettingsCard>
+ <Show when={isAvailable('Notifications')}>
+ <SettingsRow
+ stackOnNarrow
+ label="Email notifications"
+ description="Choose your email alerts and digest delivery."
+ >
+ <Button
+ variant="ghost"
+ size="sm"
+ onClick={() => openSettings('Notifications')}
+ >
+ Manage notifications
+ </Button>
+ </SettingsRow>
+ </Show>
+ <Show when={isAvailable('Calendar')}>
+ <SettingsRow
+ stackOnNarrow
+ label="Calendars"
+ description="Manage the calendars connected to your Google accounts."
+ >
+ <Button
+ variant="ghost"
+ size="sm"
+ onClick={() => openSettings('Calendar')}
+ >
+ Manage calendars
+ </Button>
+ </SettingsRow>
+ </Show>
+ </SettingsCard>
+ </SettingsSection>
+ </Show>
+ </SettingsPage>
+ );
+}
+
+function EmailSignatures() {
+ const userId = useUserId();
+ const { query } = useEmailLinks();
+ const links = () =>
+ query.isSuccess
+ ? query.data.links.filter((link) => link.macro_id === userId())
+ : [];
+ return (
+ <Show
+ when={!query.isError}
+ fallback={
+ <SettingsCard>
+ <SettingsRow label="Couldn't load signatures">
+ <Button variant="outline" onClick={() => void query.refetch()}>
+ Try again
+ </Button>
+ </SettingsRow>
+ </SettingsCard>
+ }
+ >
+ <Show
+ when={!query.isPending}
+ fallback={
+ <p role="status" class="text-sm text-ink-muted">
+ Loading signatures…
+ </p>
+ }
+ >
+ <For
+ each={links()}
+ fallback={
+ <SettingsCard>
+ <SettingsRow label="Connect an email account above to add a signature." />
+ </SettingsCard>
+ }
+ >
+ {(link) => (
+ <Suspense
+ fallback={
+ <p role="status" class="text-sm text-ink-muted">
+ Loading signature…
+ </p>
+ }
+ >
+ <SignatureSection link={link} />
+ </Suspense>
+ )}
+ </For>
+ </Show>
+ </Show>
+ );
+}
diff --git a/apps/web/src/features/settings/primitives.tsx b/apps/web/src/features/settings/primitives.tsx
index 73c64f0abd..b3328d3a73 100644
--- a/apps/web/src/features/settings/primitives.tsx
+++ b/apps/web/src/features/settings/primitives.tsx
@@ -1,5 +1,6 @@
-import { cn, Layer } from '@ui';
-import { createContext, type JSX, Show, useContext } from 'solid-js';
+import { Button, type ButtonProps, ComposerSurface, cn } from '@ui';
+import { children, createContext, type JSX, Show, useContext } from 'solid-js';
+import { settingsTarget } from './core/settings-target';
/** Detail pages inherit the mobile sheet's header and compact spacing. */
export const SettingsSheetContext = createContext(false);
@@ -7,7 +8,7 @@ export const SettingsSheetContext = createContext(false);
/*
* Shared building blocks for the settings panels. Every settings tab composes
* these so the whole menu shares one rhythm: a generous, centered content
- * column with a large page title, sections, and quiet outlined cards whose rows
+ * column with a large page title and raised composer surfaces whose rows
* are separated by hairline dividers.
*
* <SettingsPage title="Account" description="…">
@@ -39,36 +40,30 @@ export function SettingsPage(props: {
<div
data-settings-page
data-drawer-scroll-body={inSheet ? true : undefined}
- class="@container/settings-page h-full min-h-0 overflow-y-auto [overflow-anchor:none] select-children"
+ class="@container/settings-page h-full min-h-0 overflow-y-auto [overflow-anchor:none] select-children bg-[color-mix(in_srgb,var(--color-panel)_99%,var(--color-ink))] [&_[data-variant=cta]]:bg-ink [&_[data-variant=cta]]:text-panel [&_[data-variant=cta]]:focus-visible:ring-panel/70 [&_:has(>input[type=checkbox])]:[--color-accent:var(--color-ink)] [&_input[type=checkbox]]:accent-ink"
>
{/* On mobile/tablet the page is full-frame: the chrome insets live inside the
scroll content (plus the usual breathing room) so pages scroll under
the floating header and bottom rows like every other block. */}
<div
class={cn(
- 'mx-auto w-full max-w-[710px]',
+ 'mx-auto w-full max-w-[960px]',
inSheet
? '@container px-3 pt-2 pb-[max(24px,var(--mobile-sheet-safe-padding))]'
- : 'px-10 pt-4 pb-24 @max-[480px]/settings-page:px-4 touch:px-5 touch:pt-[calc(var(--mobile-content-inset-top,0px)+2rem)] touch:pb-[calc(var(--mobile-content-inset-bottom,0px)+3rem)]'
+ : '@container px-12 pt-8 pb-24 @max-[480px]/settings-page:px-4 touch:px-5 touch:pt-[calc(var(--mobile-content-inset-top,0px)+2rem)] touch:pb-[calc(var(--mobile-content-inset-bottom,0px)+3rem)]'
)}
>
- {/* Headers are inset by the card's inner padding so the title and
- section labels line up with the leftmost content inside the cards,
- while the cards themselves stay full-width. */}
- <header
- class={cn(
- 'flex items-start justify-between gap-4 @max-[480px]/settings-page:flex-col @max-[480px]/settings-page:gap-3',
- inSheet ? 'px-4' : 'px-6'
- )}
- >
+ <header class="flex items-start justify-between gap-4 @max-[480px]/settings-page:flex-col @max-[480px]/settings-page:gap-3">
<div class="flex flex-col gap-1.5 min-w-0">
<Show when={!inSheet || props.showTitleInSheet}>
- <h1 class="text-2xl/tight font-semibold text-ink">
+ <h1 class="text-[26px]/tight font-medium tracking-[-0.025em] text-ink">
{props.title}
</h1>
</Show>
<Show when={props.description}>
- <p class="text-sm text-ink-muted">{props.description}</p>
+ <p class="text-sm leading-relaxed text-ink/60">
+ {props.description}
+ </p>
</Show>
</div>
<Show when={props.actions}>
@@ -76,7 +71,7 @@ export function SettingsPage(props: {
</Show>
</header>
<div
- class={cn('flex flex-col', inSheet ? 'gap-6 mt-3' : 'mt-9 gap-10')}
+ class={cn('flex flex-col', inSheet ? 'gap-6 mt-3' : 'mt-12 gap-12')}
>
{props.children}
</div>
@@ -90,59 +85,89 @@ export function SettingsPage(props: {
* can also drop a bare card straight under the title.
*/
export function SettingsSection(props: {
- title?: string;
+ title?: JSX.Element;
description?: string;
/** Right-aligned controls beside the section heading. */
actions?: JSX.Element;
class?: string;
children: JSX.Element;
}) {
+ const actions = children(() => props.actions);
return (
- <section class={cn('flex flex-col gap-3', props.class)}>
- <Show when={props.title || props.actions}>
- <div class="flex items-end justify-between gap-4 px-6">
- <div class="flex flex-col gap-0.5 min-w-0">
- <Show when={props.title}>
- <h2 class="text-sm font-semibold text-ink">{props.title}</h2>
- </Show>
- <Show when={props.description}>
- <p class="text-sm text-ink-muted">{props.description}</p>
+ <section
+ data-settings-target={
+ typeof props.title === 'string'
+ ? settingsTarget(props.title)
+ : undefined
+ }
+ tabIndex={-1}
+ class={cn('scroll-mt-4 outline-none rounded-[26.25px]', props.class)}
+ >
+ <SettingsSurface class="flex flex-col gap-2 p-5 touch:p-4">
+ <Show when={props.title || actions()}>
+ <div class="flex flex-wrap items-end justify-between gap-3">
+ <div class="flex flex-col gap-0.5 min-w-0">
+ <Show when={props.title}>
+ <h2 class="text-base font-medium text-ink">{props.title}</h2>
+ </Show>
+ <Show when={props.description}>
+ <p class="text-sm leading-relaxed text-ink/60">
+ {props.description}
+ </p>
+ </Show>
+ </div>
+ <Show when={actions()}>
+ <div class="shrink-0">{actions()}</div>
</Show>
</div>
- <Show when={props.actions}>
- <div class="shrink-0">{props.actions}</div>
- </Show>
- </div>
- </Show>
- {props.children}
+ </Show>
+ {props.children}
+ </SettingsSurface>
</section>
);
}
-/**
- * A quiet outlined card. Direct children are treated as rows and get a hairline
- * divider between them (via `settings-row-dividers`); a single-child card draws
- * no divider, so it doubles as a plain container.
- */
-export function SettingsCard(props: { class?: string; children: JSX.Element }) {
- const inSheet = useContext(SettingsSheetContext);
- // Raised a level above the content panel so the card reads as a subtly
- // lighter surface (theme-safe via the depth system) rather than just an
- // outline on the same fill.
+/** Nested groups share their section's surface instead of stacking shadows. */
+const SettingsSurfaceContext = createContext(false);
+
+export function SettingsSurface(props: {
+ class?: string;
+ children: JSX.Element;
+}) {
+ const nested = useContext(SettingsSurfaceContext);
return (
- <Layer depth={2}>
- <div
+ <Show
+ when={!nested}
+ fallback={<div class={props.class}>{props.children}</div>}
+ >
+ <ComposerSurface
+ as="div"
class={cn(
- 'overflow-hidden settings-row-dividers',
- inSheet
- ? 'rounded-[26px] bg-ink/5'
- : 'rounded-xl border border-ink/[0.05] bg-surface',
+ 'relative min-w-0 touch:rounded-3xl touch:border touch:border-edge-muted touch:bg-composer touch:text-composer-ink',
props.class
)}
>
- {props.children}
- </div>
- </Layer>
+ <SettingsSurfaceContext.Provider value={true}>
+ {props.children}
+ </SettingsSurfaceContext.Provider>
+ </ComposerSurface>
+ </Show>
+ );
+}
+
+/** Rows share a surface; standalone cards use the email composer's elevation. */
+export function SettingsCard(props: { class?: string; children: JSX.Element }) {
+ const nested = useContext(SettingsSurfaceContext);
+ return (
+ <SettingsSurface
+ class={cn(
+ 'overflow-hidden settings-row-dividers [--color-edge-divider:color-mix(in_srgb,var(--color-ink)_5%,transparent)] [&>*:not(:last-child)]:after:inset-x-4',
+ nested && '-mx-4',
+ props.class
+ )}
+ >
+ {props.children}
+ </SettingsSurface>
);
}
@@ -168,9 +193,15 @@ export function SettingsRow(props: {
const inSheet = useContext(SettingsSheetContext);
return (
<div
+ data-settings-target={
+ typeof props.label === 'string'
+ ? settingsTarget(props.label)
+ : undefined
+ }
+ tabIndex={-1}
class={cn(
- 'flex gap-4 py-3.5 min-h-[60px]',
- inSheet ? 'px-4 flex-wrap' : 'px-6',
+ 'scroll-mt-4 outline-none flex gap-4 py-4 min-h-[64px]',
+ inSheet ? 'px-4 flex-wrap' : 'px-4',
props.stackOnNarrow
? 'flex-col gap-1.5 @[460px]:flex-row @[460px]:justify-between @[460px]:gap-4'
: 'justify-between',
@@ -187,11 +218,11 @@ export function SettingsRow(props: {
)}
>
<div class="flex flex-col gap-0.5 min-w-0">
- <div class="text-sm text-ink">{props.label}</div>
+ <div class="text-base text-ink">{props.label}</div>
<Show when={props.description}>
<div
class={cn(
- 'text-xs text-ink-extra-muted mobile:text-[11px]',
+ 'text-sm leading-relaxed text-ink/60',
props.hideDescriptionOnMobile && 'mobile:hidden'
)}
>
@@ -273,7 +304,7 @@ export function IntegrationRow(props: {
class?: string;
}) {
return (
- <div class={cn('flex items-center gap-4 px-6 py-4', props.class)}>
+ <div class={cn('flex flex-wrap items-center gap-4 px-4 py-4', props.class)}>
<div class="flex size-9 shrink-0 items-center justify-center [&_svg]:size-6">
{props.icon}
</div>
@@ -283,7 +314,9 @@ export function IntegrationRow(props: {
<Show when={props.status}>{props.status}</Show>
</div>
<Show when={props.description}>
- <div class="text-sm text-ink-muted truncate">{props.description}</div>
+ <div class="text-sm leading-relaxed text-ink/60">
+ {props.description}
+ </div>
</Show>
</div>
<Show when={props.children}>
@@ -292,3 +325,13 @@ export function IntegrationRow(props: {
</div>
);
}
+
+/** Quiet, compact actions for settings forms and account rows. */
+export function SettingsButton(props: ButtonProps) {
+ return (
+ <Button
+ {...props}
+ class={cn('rounded-lg font-normal gap-1.5', props.class)}
+ />
+ );
+}
diff --git a/apps/web/src/features/settings/settingsSearch.test.ts b/apps/web/src/features/settings/settingsSearch.test.ts
deleted file mode 100644
index 7cb80c652c..0000000000
--- a/apps/web/src/features/settings/settingsSearch.test.ts
+++ /dev/null
@@ -1,36 +0,0 @@
-import { SETTINGS_TAB_GROUPS } from '@core/constant/settingsTabsConfig';
-import { describe, expect, it } from 'vitest';
-import { filterSettingsTabGroups } from './settingsSearch';
-
-function tabsFor(query: string) {
- return filterSettingsTabGroups(SETTINGS_TAB_GROUPS, query).flatMap((group) =>
- group.items.map((item) => item.tab)
- );
-}
-
-describe('filterSettingsTabGroups', function () {
- it('hides search-only destinations when the query is empty', function () {
- expect(tabsFor('')).not.toContain('Harness');
- expect(tabsFor(' ')).not.toContain('Harness');
- expect(tabsFor('')).toContain('Agents');
- });
-
- it('sends cursor to runtimes instead of Macro API keys', function () {
- const tabs = tabsFor('cursor');
- expect(tabs).toContain('Harness');
- expect(tabs).not.toContain('API Keys');
- });
-
- it('fuzzy-matches a missing letter in a keyword', function () {
- expect(tabsFor('curso')).toContain('Harness');
- expect(tabsFor('curso')).not.toContain('API Keys');
- });
-
- it('matches keywords declared on the tab', function () {
- expect(tabsFor('hotkey')).toEqual(['Shortcuts']);
- });
-
- it('returns no groups when nothing matches', function () {
- expect(tabsFor('xyz123')).toEqual([]);
- });
-});
diff --git a/apps/web/src/features/settings/settingsSearch.ts b/apps/web/src/features/settings/settingsSearch.ts
deleted file mode 100644
index 50da86e758..0000000000
--- a/apps/web/src/features/settings/settingsSearch.ts
+++ /dev/null
@@ -1,37 +0,0 @@
-import type {
- SettingsTabGroup,
- SettingsTabItem,
-} from '@core/constant/settingsTabsConfig';
-import { fuzzyFilter } from '@core/util/fuzzy';
-
-/** Label plus keywords, lowercased for the shared uFuzzy index. */
-export function settingsTabSearchText(item: SettingsTabItem): string {
- return [item.label, ...item.keywords].join(' ').toLowerCase();
-}
-
-/**
- * Filters settings groups by a fuzzy query against each tab's label and
- * keywords. An empty query returns the standing nav and hides search-only
- * destinations such as Runtimes.
- */
-export function filterSettingsTabGroups(
- groups: readonly SettingsTabGroup[],
- query: string
-): SettingsTabGroup[] {
- const trimmed = query.trim().toLowerCase();
- if (!trimmed) {
- return groups
- .map((group) => ({
- label: group.label,
- items: group.items.filter((item) => !item.searchOnly),
- }))
- .filter((group) => group.items.length > 0);
- }
-
- return groups
- .map((group) => ({
- label: group.label,
- items: fuzzyFilter(trimmed, group.items, settingsTabSearchText),
- }))
- .filter((group) => group.items.length > 0);
-}
diff --git a/apps/web/src/lib/core/constant/SettingsState.tsx b/apps/web/src/lib/core/constant/SettingsState.tsx
index e0180c7e14..6e5aee3bf2 100644
--- a/apps/web/src/lib/core/constant/SettingsState.tsx
+++ b/apps/web/src/lib/core/constant/SettingsState.tsx
@@ -13,6 +13,7 @@ import { settingsTabToSlug } from './settingsTabsConfig';
export type SettingsTab =
| 'Calendar'
+ | 'Booking links'
| 'Account'
| 'API Keys'
| 'Notifications'
diff --git a/apps/web/src/lib/core/constant/settingsTabsConfig.test.ts b/apps/web/src/lib/core/constant/settingsTabsConfig.test.ts
index 2b4ad31d8c..c529bac0c3 100644
--- a/apps/web/src/lib/core/constant/settingsTabsConfig.test.ts
+++ b/apps/web/src/lib/core/constant/settingsTabsConfig.test.ts
@@ -5,7 +5,12 @@ import {
settingsTabToSlug,
} from './settingsTabsConfig';
-describe('settings Connections tab', () => {
+describe('settings navigation', () => {
+ it('gives calendar connections and booking links separate routes', () => {
+ expect(settingsSlugToTab('calendar')).toBe('Calendar');
+ expect(settingsSlugToTab('booking-links')).toBe('Booking links');
+ expect(settingsTabToSlug('Booking links')).toBe('booking-links');
+ });
it('routes agent-connections to the Connections tab', () => {
expect(settingsSlugToTab('agent-connections')).toBe('Connections');
expect(settingsTabToSlug('Connections')).toBe('agent-connections');
@@ -15,15 +20,23 @@ describe('settings Connections tab', () => {
expect(settingsSlugToTab('connections')).toBe('Connected');
});
- it('places Connections right after Integrations in Workspace', () => {
+ it('groups blocks first and separates account and agent integrations', () => {
+ expect(SETTINGS_TAB_GROUPS[0].label).toBe('Blocks');
+ expect(SETTINGS_TAB_GROUPS[0].items.map((item) => item.tab)).toEqual([
+ 'Email',
+ 'Calendar',
+ 'Booking links',
+ 'Agents',
+ 'CRM',
+ ]);
const workspace = SETTINGS_TAB_GROUPS.find(
(group) => group.label === 'Workspace'
);
- const tabs = workspace?.items.map((item) => item.tab) ?? [];
- const integrations = tabs.indexOf('Connected');
- expect(tabs.slice(integrations, integrations + 2)).toEqual([
- 'Connected',
- 'Connections',
- ]);
+ const developer = SETTINGS_TAB_GROUPS.find(
+ (group) => group.label === 'Developer'
+ );
+ expect(workspace?.items.map((item) => item.tab)).toContain('Connected');
+ expect(developer?.items.map((item) => item.tab)).toContain('Connections');
+ expect(developer?.items.map((item) => item.tab)).toContain('Harness');
});
});
diff --git a/apps/web/src/lib/core/constant/settingsTabsConfig.tsx b/apps/web/src/lib/core/constant/settingsTabsConfig.tsx
index 3b4420f292..b2bc3cb85d 100644
--- a/apps/web/src/lib/core/constant/settingsTabsConfig.tsx
+++ b/apps/web/src/lib/core/constant/settingsTabsConfig.tsx
@@ -6,9 +6,11 @@ import CalendarIcon from '@phosphor/calendar-blank.svg';
import CpuIcon from '@phosphor/cpu.svg';
import CreditCardIcon from '@phosphor/credit-card.svg';
import DeviceMobileIcon from '@phosphor/device-mobile-speaker.svg';
+import EmailIcon from '@phosphor/envelope-simple.svg';
import HardDrivesIcon from '@phosphor/hard-drives.svg';
import KeyIcon from '@phosphor/key.svg';
import KeyboardIcon from '@phosphor/keyboard.svg';
+import LinkIcon from '@phosphor/link.svg';
import PlugIcon from '@phosphor/plug.svg';
import PlugsConnectedIcon from '@phosphor/plugs-connected.svg';
import BotIcon from '@phosphor/robot.svg';
@@ -26,6 +28,7 @@ import {
botManagement,
DEV_MODE_ENV,
ENABLE_APP_STORE_QR_CODE,
+ ENABLE_EMAIL,
enableCalendarScheduling,
enableChatV3Agents,
enableCrm,
@@ -64,7 +67,42 @@ export type SettingsTabGroup = {
*/
export const SETTINGS_TAB_GROUPS: SettingsTabGroup[] = [
{
- label: 'General',
+ label: 'Blocks',
+ items: [
+ {
+ tab: 'Email',
+ label: 'Email',
+ icon: EmailIcon,
+ keywords: ['gmail', 'inbox', 'signature', 'sync'],
+ },
+ {
+ tab: 'Calendar',
+ label: 'Calendar',
+ icon: CalendarIcon,
+ keywords: ['google', 'accounts', 'visibility', 'colors'],
+ },
+ {
+ tab: 'Booking links',
+ label: 'Booking links',
+ icon: LinkIcon,
+ keywords: ['scheduling', 'bookings', 'availability', 'meetings'],
+ },
+ {
+ tab: 'Agents',
+ label: 'Agents',
+ icon: AgentIcon,
+ keywords: ['ai', 'assistant', 'bot'],
+ },
+ {
+ tab: 'CRM',
+ label: 'CRM',
+ icon: BuildingsIcon,
+ keywords: ['contacts', 'customers', 'deals'],
+ },
+ ],
+ },
+ {
+ label: 'Personal',
items: [
{
tab: 'Account',
@@ -73,10 +111,10 @@ export const SETTINGS_TAB_GROUPS: SettingsTabGroup[] = [
keywords: ['profile', 'user', 'email', 'name'],
},
{
- tab: 'API Keys',
- label: 'API Keys',
- icon: KeyIcon,
- keywords: ['api', 'key', 'token', 'authentication'],
+ tab: 'Appearance',
+ label: 'Appearance',
+ icon: SwatchesIcon,
+ keywords: ['theme', 'dark', 'light', 'color'],
},
{
tab: 'Notifications',
@@ -84,43 +122,24 @@ export const SETTINGS_TAB_GROUPS: SettingsTabGroup[] = [
icon: BellIcon,
keywords: ['alerts', 'email', 'sound'],
},
+ {
+ tab: 'Shortcuts',
+ label: 'Keyboard shortcuts',
+ icon: KeyboardIcon,
+ keywords: ['keyboard', 'hotkey', 'keybinding'],
+ },
{
tab: 'Billing',
label: 'Billing',
icon: CreditCardIcon,
keywords: ['payment', 'subscription', 'invoice', 'plan'],
},
- {
- tab: 'Appearance',
- label: 'Appearance',
- icon: SwatchesIcon,
- keywords: ['theme', 'dark', 'light', 'color'],
- },
- {
- tab: 'Agents',
- label: 'Agents',
- icon: AgentIcon,
- keywords: ['ai', 'assistant', 'bot'],
- },
- {
- tab: 'Harness',
- label: 'Runtimes',
- icon: HardDrivesIcon,
- keywords: ['cursor', 'harness', 'runtime', 'credential', 'api key'],
- searchOnly: true,
- },
{
tab: 'Mobile App',
label: 'Mobile App',
icon: DeviceMobileIcon,
keywords: ['phone', 'ios', 'android'],
},
- {
- tab: 'Shortcuts',
- label: 'Shortcuts',
- icon: KeyboardIcon,
- keywords: ['keyboard', 'hotkey', 'keybinding'],
- },
],
},
{
@@ -138,36 +157,41 @@ export const SETTINGS_TAB_GROUPS: SettingsTabGroup[] = [
icon: TagIcon,
keywords: ['label', 'category'],
},
- {
- tab: 'CRM',
- label: 'CRM',
- icon: BuildingsIcon,
- keywords: ['contacts', 'customers', 'deals'],
- },
- {
- tab: 'Calendar',
- label: 'Calendar',
- icon: CalendarIcon,
- keywords: ['scheduling', 'bookings', 'availability'],
- },
{
tab: 'Connected',
label: 'Integrations',
icon: CpuIcon,
keywords: ['integrations', 'apps', 'connections'],
},
+ ],
+ },
+ {
+ label: 'Developer',
+ items: [
{
tab: 'Connections',
- label: 'Connections',
+ label: 'Agent connections',
icon: PlugsConnectedIcon,
keywords: ['agent', 'tools', 'apps', 'mcp'],
},
+ {
+ tab: 'Harness',
+ label: 'Runtimes',
+ icon: HardDrivesIcon,
+ keywords: ['cursor', 'harness', 'runtime', 'credential', 'api key'],
+ },
{
tab: 'Agent',
label: 'MCP server',
icon: PlugIcon,
keywords: ['mcp', 'server', 'protocol'],
},
+ {
+ tab: 'API Keys',
+ label: 'API Keys',
+ icon: KeyIcon,
+ keywords: ['api', 'key', 'token', 'authentication'],
+ },
{
tab: 'Bots',
label: 'Bots',
@@ -207,6 +231,7 @@ const SETTINGS_TAB_SLUGS: Record<SettingsTab, string> = {
Bots: 'bots',
Team: 'team',
Calendar: 'calendar',
+ 'Booking links': 'booking-links',
Tags: 'tags',
CRM: 'crm',
Connected: 'connections',
@@ -256,7 +281,10 @@ export const useSettingsTabAvailable = () => {
case 'Account':
case 'Billing':
return true;
+ case 'Email':
+ return ENABLE_EMAIL;
case 'Calendar':
+ case 'Booking links':
return calendarSchedulingFlag().enabled;
// Issuing and copying a key is desk work, and the mobile sheet has no
// good place for a one-time secret.
diff --git a/apps/web/src/lib/core/hotkey/hotkeys.ts b/apps/web/src/lib/core/hotkey/hotkeys.ts
index ec5669ddf9..0e69f03458 100644
--- a/apps/web/src/lib/core/hotkey/hotkeys.ts
+++ b/apps/web/src/lib/core/hotkey/hotkeys.ts
@@ -803,9 +803,6 @@ export function useHotKeyRoot() {
commandFound: !!commandCaptured,
commandCaptured: commandCaptured,
eventType: e.type as 'keydown' | 'keyup',
- isNonModifierKeypress: ![...currentPressedKeys].every((key) =>
- ['cmd', 'ctrl', 'opt', 'shift'].includes(key)
- ),
};
// Notify all subscribers with the context
diff --git a/apps/web/src/lib/core/hotkey/types.ts b/apps/web/src/lib/core/hotkey/types.ts
index 94f7d3bcc5..9418dd8cb4 100644
--- a/apps/web/src/lib/core/hotkey/types.ts
+++ b/apps/web/src/lib/core/hotkey/types.ts
@@ -471,6 +471,4 @@ export interface KeypressContext {
commandCaptured: HotkeyCommand | undefined;
/** The event type ('keydown' or 'keyup') */
eventType: 'keydown' | 'keyup';
- /** Whether the keypress includes a non-modifier key */
- isNonModifierKeypress: boolean;
}
diff --git a/docs/AGENT_GUIDE/surfaces.md b/docs/AGENT_GUIDE/surfaces.md
index b74ab3004e..604c9902f1 100644
--- a/docs/AGENT_GUIDE/surfaces.md
+++ b/docs/AGENT_GUIDE/surfaces.md
@@ -1131,15 +1131,35 @@ public booking and receipt links show an unavailable page without fetching
scheduling data. When enabling a production rollout, include anonymous visitors
so invitees can open those links.
-When enabled, calendar scheduling lives in **Settings → Calendar** (`/app/settings/calendar`).
-The scheduling sidebar opens Event types, Bookings, Availability, Teams, Insights,
-and Booking page. Event editors have a grouped settings sidebar; booking status
-filters use the same segmented control as the CRM sidebar.
+Calendar connections live in **Settings → Calendar** (`/app/settings/calendar`).
+Scheduling lives in the separate **Settings → Booking links** item
+(`/app/settings/booking-links`), with Booking links, Availability, Booking pages,
+Teams, Bookings, and Insights in one scrolling page. The calendar toolbar’s
+booking actions open Booking links; email and integration connection shortcuts
+continue to open Calendar.
+There is no second sidebar or global owner switch. Personal and team booking links
+appear together with ownership badges. New booking link and New schedule ask which
+owner to create for when multiple editable owners are available, then open inline editors;
+event options are stacked sections. Save changes or Cancel returns to the list.
+Connected calendars offers Connect account (the existing Google consent flow),
+Connect calendar for accounts missing calendar permission, and Disconnect with
+confirmation. Disconnect removes calendar access/data, not the Gmail connection.
+Account checkboxes show/hide all child calendars; partial selection is shown as
+mixed. Individual calendars can also be shown/hidden. The account color is the
+default for its calendars; a child color overrides it. Click a color dot to open
+the theme-matched picker: drag the color field and hue slider, choose a named
+swatch, or enter a three- or six-digit hex value. Arrow keys adjust the focused
+color field (Shift makes larger steps). **Reset to default** clears the override.
+Visibility and colors share the calendar sidebar's browser-local preferences,
+survive reload, and do not change the Google calendar or booking conflict checks.
+Booking status filters use the same segmented control as the CRM sidebar.
In Availability, each weekday has an enable switch, time ranges, an add button,
and a copy-hours menu; select target days and Apply before saving the schedule.
Date overrides and the searchable timezone picker sit below the weekly hours.
-Choose Personal or your Macro team in `Calendar owner`. Team owners/admins can
-edit team links; ordinary members can view them. `Event types` creates, edits,
+Ownership badges identify Personal or Team · team name on links and availability.
+Public booking pages, bookings, and insights are grouped by owner and remain visible
+together; editing one owner does not switch the rest of the page. Search booking
+links by title, slug, or owner. Team owners/admins can edit team links; ordinary members can view them. `Event types` creates, edits,
pauses, duplicates, previews, and copies booking links. Event settings include
weekly availability, collective/all-host or round-robin/one-host assignment,
notice, buffers, booking horizon, daily limits, and custom questions. New event
@@ -1148,7 +1168,8 @@ types stay paused until `Accept bookings` is selected and changes are saved.
zone. Set a default schedule for new event types; a schedule cannot be deleted
until its event types use another one. Collective and round-robin team meetings
respect each host’s personal default hours when configured, plus busy calendars.
-`Teams` uses existing Macro team membership and links to team settings.
+`Teams` summarizes connected teams and links to team settings; the member roster
+lives in team settings. Choose hosts for a team booking link inside its editor.
`Booking page` edits the public name and description. `Bookings` shows
upcoming, unconfirmed, past, and cancelled meetings; admins can confirm requests,
reschedule, or cancel them. Choose From/Through dates to load bookings (initially 30 days before and after today), then search by guest/title/email and filter by event type. Dates use your browser time zone; shorten the range if more than 5,000 bookings match.
@@ -1870,14 +1891,15 @@ live-backend release gates and documents staging retention and recovery.
### Email signatures
-In Integrations, **Edit signature** beside an owned inbox expands its editor.
-The editor uses the app's background and text colors, including in dark mode;
-explicit colors in signature content are preserved. **Close signature editor**
-(the X) or Escape while focused in that inbox row collapses it and returns focus
-to **Edit signature**. Unsaved edits remain when reopened; closing does not save
-or remove the signature.
-The inbox row's trash icon removes the inbox through the existing confirmation;
-it is separate from the signature editor's close control.
+Open **Settings → Email → Signatures**. Each owned inbox has a visible editor;
+there is no expand/collapse control. Format the text, add links or images, and
+choose **Save signature**. **Clear signature** removes only the signature, while
+**Remove inbox** in Accounts uses the existing inbox removal confirmation.
+**Add to replies & forwards** saves that preference immediately. Unsaved drafts
+survive switching settings pages. On phones, signature editing remains desktop-only;
+the replies/forwards toggle and clear action are available.
+Email accounts can also be managed from **Integrations**. Its **Email settings**
+link opens the dedicated page, and Email links to Notifications and Calendar.
With a composer open, save a changed signature or reply-signature preference and
verify its preview updates. Once the account refresh completes, reopen a composer
offline and confirm it uses the saved settings.
@@ -1941,8 +1963,9 @@ same-domain signup is not added automatically.
### Navigation
On phones, **More views → Settings** opens an inset glass sheet over the current
-page. The main page has a profile shortcut and grouped Account, Preferences,
-Workspace, and enabled agent/admin sections. Tap a row to open that settings
+page. The main page has a profile shortcut and the same grouped Blocks, Personal, Workspace,
+and Developer sections as desktop, plus enabled admin settings. Search finds
+individual settings; selecting a result opens its page and reveals the section. Tap a row to open that settings
page inside the sheet; **Back to settings** returns to the grouped list at its
previous scroll position. `API Keys` is desktop-only and has no row here.
**Close settings** at the top right, Escape, an
@@ -1964,9 +1987,35 @@ settings split that shares the layout, or steps back to the previous view when
it is the only split (Home when there is none). Leave settings by picking any
other rail item; there is no separate back or fullscreen control.
-Left nav: General → `Account` (profile, delete account), `API Keys` (create /
-list / delete personal keys; the secret is shown only once and is sent as
-`x-macro-user-api-key`), `Notifications`, `Billing` (current plan card with
+Settings pages use the email composer’s raised surfaces on the page background.
+Section headings and controls share a white surface in light mode and the
+composer border in dark mode, with subtle row separators. The compact sidebar
+uses the shared workspace width.
+
+Left nav (feature and platform gates still apply):
+
+- **Blocks**: Email, Calendar, Agents, CRM.
+- **Personal**: Account, Appearance, Notifications, Keyboard shortcuts, Billing, Mobile App.
+- **Workspace**: Team, Tags, Integrations (personal Gmail/GitHub accounts).
+- **Developer**: Agent connections, Runtimes, MCP server, API Keys, Bots.
+
+Search checks individual setting titles and keywords, tolerates common typos,
+and shows the parent page below each control result. Selecting a result opens
+that page, scrolls to its section or row, and briefly highlights it. Try
+`singature`, `email digest`, `calendar color`, or `cursor`. Arrow Down from search
+focuses the first result; Tab moves through controls normally. Escape in the
+search field clears the query. Clearing search restores the grouped navigation. Keyboard shortcuts are listed
+by category with the action on the left and keys on the right; expand **Keyboard
+preview** for the visual key map.
+Appearance starts with visual **System**, **Light**, and **Dark** mode choices.
+The previews use the saved themes; System follows the device and exposes both
+per-mode theme selectors. Light or Dark shows its own theme selector. Each selector
+retains theme search, editing, copying, and custom theme creation.
+
+Existing settings URLs remain valid; `connections` still opens Integrations,
+`agent-connections` opens Agent connections, and `harness` aliases Runtimes.
+
+`Billing` (current plan card with
`Manage`; only in dev (`dev.macro.com/app` or a local frontend using the dev
backend), paid plans show an **AI usage** card with the period meter, credit
balance, credit-pack buttons `$10`/`$25`/`$50`/`$100` that redirect to Stripe
@@ -1974,18 +2023,15 @@ Checkout, and a `Usage billing` toggle with per-period limit pills; these
controls and usage-billing promotional copy are hidden outside dev; an `Upgrade`
card for Free users to buy Premium, no Max purchase or upgrade control, and a
`Switch to Premium` link on Max; on a team the downgrade moves only the viewer's
-own seat),
-`Appearance`, `Agents`, `Mobile App`, `Shortcuts` (interactive keyboard visualization, not a list);
-Workspace → `Team` (members list; on a paid team each row shows the seat's plan,
+own seat)
+
+`Team` (members list; on a paid team each row shows the seat's plan,
and admins/owners can move an existing Max seat to Premium with the `Seat plan`
-menu; Premium seats have no Max option; moves are prorated at once), `Tags`, `CRM` (enable/disable; once enabled, a `Deal stages` section
+menu; Premium seats have no Max option; moves are prorated at once). CRM (enable/disable; once enabled, a `Deal stages` section
with `Customize stages`, inline rename, reorder by drag handle or arrow keys (up/down
buttons on touch), delete, `Add stage`, `Reset to defaults`, and `Closed stages`
-checkboxes, editable by the role set as `edit_stages_role`),
-`Integrations` (personal Gmail/GitHub accounts), `Connections` (agent tool
-connections; the same page as Agents → Connections, URL slug `agent-connections`), `MCP server`
-(setup snippets for Claude Code / Codex CLI / Claude.ai / ChatGPT / IDE), `Bots`;
-`Log out`.
+checkboxes, editable by the role set as `edit_stages_role`)
+
`Agents` unifies agent definitions and runtime configuration in one page, also used by the Agents workspace. Its `Agents` section lists team and private agents. `New agent` / `Edit <name>` open full-page forms grouped
Profile, Behavior, Runtime, Connections, Channels, Share. Connections is a radio pair:
`Use my connected apps` (default; the agent gets whatever the person running it has
@@ -1996,7 +2042,7 @@ that opens the Pipedream Connect flow inside the page. Unconnected picks never b
saving; each teammate connects their own account. An agent session that calls a picked
but unconnected app gets a tool result saying so, and the agent's reply renders a
`Connect <app>` chip that opens Agents → Connections for that app. The same page
-is also available as Settings → Connections.
+is also available as Settings → Agent connections.
To change an agent's picture, open `Edit <name>`, choose an image with `Upload`,
wait for `Uploading…` to finish, then click `Save changes`. Images up to 16 MB