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.

fix(crm): align mobile navigation and pipeline layout (#7800)

teof38e8b480de7
diff --git a/apps/web/src/features/crm/components/crm-mobile-tabs.tsx b/apps/web/src/features/crm/components/crm-mobile-tabs.tsx
new file mode 100644
index 0000000000..5bd8634df8
--- /dev/null
+++ b/apps/web/src/features/crm/components/crm-mobile-tabs.tsx
@@ -0,0 +1,40 @@
+import { type PillTabItem, PillTabs } from '@components/app/mobile/PillTabs';
+import type { JSX } from 'solid-js';
+import { CRM_RECORDS } from '../core/navigation';
+
+export function CrmMobileTabs(props: {
+ active: string;
+ pipelines: readonly { id: string; name: string }[];
+ lists: readonly { id: string; name: string }[];
+ leading?: JSX.Element;
+ onNavigate(id: string): void;
+}) {
+ const items = (): PillTabItem[] => [
+ ...CRM_RECORDS.map((record) => ({
+ value: record.id,
+ label: record.label,
+ })),
+ ...props.pipelines.map((pipeline) => ({
+ value: `pipeline:${pipeline.id}`,
+ label: pipeline.name,
+ })),
+ ...props.lists.map((list) => ({
+ value: `list:${list.id}`,
+ label: list.name,
+ })),
+ ];
+
+ return (
+ <nav aria-label="CRM views" class="flex h-10 min-w-0 flex-1">
+ <PillTabs
+ scrollable
+ class="-ml-(--mobile-chrome-gutter) w-[calc(100%+2*var(--mobile-chrome-gutter))] max-w-none flex-none"
+ contentClass="px-(--mobile-chrome-gutter)"
+ leading={props.leading}
+ items={items()}
+ value={props.active}
+ onChange={props.onNavigate}
+ />
+ </nav>
+ );
+}
diff --git a/apps/web/src/features/crm/context/pipelines.ts b/apps/web/src/features/crm/context/pipelines.ts
index c5649c3969..a8e45e26f6 100644
--- a/apps/web/src/features/crm/context/pipelines.ts
+++ b/apps/web/src/features/crm/context/pipelines.ts
@@ -1,4 +1,4 @@
-import type { Accessor, Component } from 'solid-js';
+import type { Accessor, Component, JSX } from 'solid-js';
import type { NewPipeline, Pipeline } from '../core/pipeline';
export type PipelinesSource = {
@@ -11,7 +11,11 @@ export type PipelinesSource = {
trash(id: string): Promise<void>;
};
-export type PipelineEditor = Component<{ pipeline: Pipeline }>;
+export type PipelineEditor = Component<{
+ pipeline: Pipeline;
+ /** Compact host actions placed alongside the editor's record controls. */
+ actions?: JSX.Element;
+}>;
export type PipelineSharing = Component<{
pipeline: Pipeline;
diff --git a/apps/web/src/features/crm/pipeline-adapter.tsx b/apps/web/src/features/crm/pipeline-adapter.tsx
index 6f0780a359..e349814881 100644
--- a/apps/web/src/features/crm/pipeline-adapter.tsx
+++ b/apps/web/src/features/crm/pipeline-adapter.tsx
@@ -11,7 +11,14 @@ import type { CardPosition } from '@service-storage/generated/schemas/cardPositi
import type { DatabaseView } from '@service-storage/generated/schemas/databaseView';
import { useQueryClient } from '@tanstack/solid-query';
import { Button } from '@ui';
-import { createSignal, onCleanup, onMount, Show, Suspense } from 'solid-js';
+import {
+ createSignal,
+ type JSX,
+ onCleanup,
+ onMount,
+ Show,
+ Suspense,
+} from 'solid-js';
import { match } from 'ts-pattern';
import {
DatabaseMentionPicker,
@@ -64,7 +71,10 @@ export function PipelineShare(props: {
}
/** The CRM adapter supplies authorized data to the reusable records UI. */
-export function PipelineDatabaseEditor(props: { pipeline: Pipeline }) {
+export function PipelineDatabaseEditor(props: {
+ pipeline: Pipeline;
+ actions?: JSX.Element;
+}) {
return (
<div
class="@container/database flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden bg-canvas-base text-ink"
@@ -76,7 +86,12 @@ export function PipelineDatabaseEditor(props: { pipeline: Pipeline }) {
}
>
<Show when={props.pipeline.id} keyed>
- {(_id) => <PipelineRecords pipeline={props.pipeline} />}
+ {(_id) => (
+ <PipelineRecords
+ pipeline={props.pipeline}
+ actions={props.actions}
+ />
+ )}
</Show>
</Suspense>
</div>
@@ -86,7 +101,7 @@ export function PipelineDatabaseEditor(props: { pipeline: Pipeline }) {
const viewFailure = (failure: DatabaseOpFailure) =>
toast.failure(databaseOpMessage(failure, 'this view'));
-function PipelineRecords(props: { pipeline: Pipeline }) {
+function PipelineRecords(props: { pipeline: Pipeline; actions?: JSX.Element }) {
const deps = { storage: storageServiceClient, client: useQueryClient() };
const tableQuery = usePipelineTableQuery(deps, props.pipeline);
const views = createPipelineViews(deps, props.pipeline);
@@ -148,7 +163,7 @@ function PipelineRecords(props: { pipeline: Pipeline }) {
>
<PipelineRefresh />
<DatabaseRecords
- contentClass="mx-4 mb-4 mt-1 rounded-xl border border-edge-muted"
+ contentClass="mx-4 mb-4 mt-1 rounded-xl border border-edge-muted touch:m-0 touch:rounded-none touch:border-0"
view={view()}
stored={!!selectedView()}
onViewChange={changeView}
@@ -175,6 +190,7 @@ function PipelineRecords(props: { pipeline: Pipeline }) {
onSelectView={setSelectedViewId}
onChangeView={changeView}
actions={actions}
+ pipelineActions={props.actions}
/>
)}
/>
@@ -194,6 +210,7 @@ function PipelineToolbar(props: {
onSelectView: (id: string | undefined) => void;
onChangeView: (change: ViewChange) => void;
actions: DatabaseRecordsActions;
+ pipelineActions?: JSX.Element;
}) {
const database = useDatabase();
const columns = () => database.data.rows.columns();
@@ -247,16 +264,19 @@ function PipelineToolbar(props: {
return props.views.remove(target);
}}
actions={
- <Show when={props.canEdit}>
- <Button
- variant="outline"
- disabled={props.actions.pending()}
- onClick={() => void props.actions.createRecord()}
- >
- <PlusIcon class="size-4" />
- {props.recordType === 'company' ? 'Add company' : 'Add contact'}
- </Button>
- </Show>
+ <>
+ <Show when={props.canEdit}>
+ <Button
+ variant="outline"
+ disabled={props.actions.pending()}
+ onClick={() => void props.actions.createRecord()}
+ >
+ <PlusIcon class="size-4" />
+ {props.recordType === 'company' ? 'Add company' : 'Add contact'}
+ </Button>
+ </Show>
+ {props.pipelineActions}
+ </>
}
/>
);
diff --git a/apps/web/src/features/crm/views/companies.tsx b/apps/web/src/features/crm/views/companies.tsx
index 21438ee817..6c33967685 100644
--- a/apps/web/src/features/crm/views/companies.tsx
+++ b/apps/web/src/features/crm/views/companies.tsx
@@ -1,8 +1,5 @@
-import { SplitHeaderLeft } from '@components/app/split-layout/components/SplitHeader';
import { isTouchDevice } from '@core/mobile/isTouchDevice';
import { Show, Suspense } from 'solid-js';
-import { MobileFilterDrawer } from '../../next-soup/soup-view/filters-bar/mobile-filter-drawer';
-import { SoupFiltersBar } from '../../next-soup/soup-view/filters-bar/soup-filters-bar';
import { SoupViewList } from '../../next-soup/soup-view/soup-view';
import { useCrmWorkspace } from '../context/workspace-context';
import { CompanyGroupHeader } from './company-group-header';
@@ -23,20 +20,6 @@ export function Companies() {
class="size-full flex flex-col @container"
data-list-view="companies"
>
- {/* People keeps the workspace title row and search on touch. */}
- <Show when={isTouchDevice() && !people()}>
- <div class="flex flex-col w-full">
- <SplitHeaderLeft>
- <div class="h-full flex gap-3 @max-[380px]/split-header:gap-2 items-center w-full flex-1 min-w-0">
- <div class="pointer-events-auto flex shrink-0 items-center gap-2">
- {options.mobileHeaderLeading}
- <MobileFilterDrawer />
- </div>
- </div>
- </SplitHeaderLeft>
- </div>
- <SoupFiltersBar />
- </Show>
<div class="relative grow min-h-1 flex max-sm:flex-col flex-row size-full">
<Suspense>
<Show
diff --git a/apps/web/src/features/crm/views/crm-workspace.test.tsx b/apps/web/src/features/crm/views/crm-workspace.test.tsx
new file mode 100644
index 0000000000..908b63391a
--- /dev/null
+++ b/apps/web/src/features/crm/views/crm-workspace.test.tsx
@@ -0,0 +1,222 @@
+import {
+ cleanup,
+ fireEvent,
+ render,
+ screen,
+ within,
+} from '@solidjs/testing-library';
+import { createSignal, type JSX, type ParentProps } from 'solid-js';
+import { afterEach, expect, it, vi } from 'vitest';
+import { CrmWorkspaceView } from './crm-workspace';
+
+const fixture = vi.hoisted(() => ({
+ workspace: undefined as unknown,
+ pipelinesEnabled: true,
+ listsEnabled: true,
+}));
+
+vi.mock('@app/components/view-shell', () => ({
+ ViewShell: {
+ Root: (props: ParentProps) => props.children,
+ Aside: () => null,
+ Main: (props: ParentProps) => props.children,
+ Header: (props: ParentProps) => <header>{props.children}</header>,
+ },
+ useViewShell: () => ({
+ aside: { isCollapsed: () => true },
+ breakpoints: { narrow: () => false },
+ }),
+ useViewControlHotkeys: () => {},
+ SearchBar: () => null,
+}));
+vi.mock('@app/preferences/use-preference', () => ({
+ usePreference: () => createSignal(false),
+}));
+vi.mock('@core/mobile/isTouchDevice', () => ({ isTouchDevice: () => true }));
+vi.mock('@core/mobile/haptics', () => ({ hapticImpact: vi.fn() }));
+vi.mock('@core/mobile/virtualKeyboard', () => ({
+ virtualKeyboardVisible: () => false,
+}));
+vi.mock('@solid-primitives/resize-observer', () => ({
+ createElementSize: () => ({ width: 0, height: 40 }),
+}));
+vi.mock('@entity', () => ({
+ isCrmCompanyEntity: () => false,
+ isCrmContactEntity: () => false,
+}));
+vi.mock('@ui', async () => ({
+ ...(await import('../../../components/ui/utils/classname')),
+ Layer: (props: ParentProps) => props.children,
+ Tooltip: (props: ParentProps) => props.children,
+ Button: (
+ props: JSX.ButtonHTMLAttributes<HTMLButtonElement> & { label?: string }
+ ) => <button aria-label={props.label} {...props} />,
+}));
+vi.mock('@ui/components/Tour', () => ({ tourTarget: () => () => {} }));
+vi.mock('@app/components/view-shell/tour', () => ({
+ VIEW_SHELL_TOUR: { sidebarToggle: 'sidebar-toggle' },
+}));
+vi.mock('@app/features/next-soup/sidebar/soup-filter-presets', () => ({
+ getViewPreset: () => ({ filters: {}, clientFilters: {} }),
+}));
+vi.mock(
+ '@app/features/next-soup/soup-view/filters-bar/soup-active-filters-bar',
+ () => ({
+ SoupActiveFiltersBar: () => null,
+ })
+);
+vi.mock(
+ '@app/features/next-soup/soup-view/filters-bar/mobile-filter-drawer',
+ () => ({
+ MobileFilterDrawer: () => null,
+ })
+);
+vi.mock(
+ '@app/features/next-soup/soup-view/filters-bar/soup-filters-bar',
+ () => ({
+ SoupFiltersBar: () => null,
+ })
+);
+vi.mock(
+ '@app/features/next-soup/soup-view/filters-bar/soup-view-context-group',
+ () => ({
+ SoupViewContextGroup: () => null,
+ })
+);
+vi.mock(
+ '@app/features/next-soup/soup-view/filters-bar/soup-view-context-sort',
+ () => ({
+ SoupViewContextSort: () => null,
+ })
+);
+vi.mock(
+ '@app/features/next-soup/soup-view/filters-bar/unified-filter-dropdown',
+ () => ({
+ UnifiedFilterDropdown: () => null,
+ })
+);
+vi.mock(
+ '@app/features/next-soup/soup-view/filters-bar/use-filter-refinements',
+ () => ({
+ useFilterRefinements: () => ({ consolidatedFiltersList: () => [] }),
+ })
+);
+vi.mock('../components/company-list-dialog', () => ({
+ CrmListDialog: () => null,
+}));
+vi.mock('../components/crm-sidebar', () => ({ CrmSidebar: () => null }));
+vi.mock('../components/pipeline-sidebar', () => ({
+ PipelineSidebar: () => null,
+}));
+vi.mock('../components/pipeline-dialog', () => ({
+ PipelineDialog: () => null,
+}));
+vi.mock('./record-detail', () => ({ CrmRecordDetail: () => null }));
+vi.mock('./export-companies', () => ({ CrmExport: () => null }));
+vi.mock('./import-companies', () => ({ CrmImport: () => null }));
+vi.mock('./pipeline', () => ({
+ PipelineView: (props: { pipeline: { name: string } }) => (
+ <div>{props.pipeline.name} table</div>
+ ),
+}));
+vi.mock('./saved-views-menu', () => ({
+ CompanyDisplayMenu: () => null,
+ CompanyViewsMenu: () => null,
+}));
+vi.mock('../context/workspace-context', () => ({
+ useCrmWorkspace: () => fixture.workspace,
+}));
+vi.mock('../context/crm-context', () => ({
+ useCrmContext: () => ({
+ pipelinesEnabled: () => () => fixture.pipelinesEnabled,
+ listsEnabled: () => () => fixture.listsEnabled,
+ createPipelines: () => ({
+ pipelines: () => [{ id: 'sales', name: 'Sales' }],
+ loading: () => false,
+ error: () => false,
+ }),
+ }),
+}));
+vi.mock('./use-crm', () => ({
+ useCurrentTeamQuery: () => ({
+ isSuccess: true,
+ data: { team: { id: 'team', crm_enabled: true } },
+ }),
+ useCrmLists: () => ({
+ lists: () => [
+ {
+ id: 'favorites',
+ name: 'Favorites',
+ config: { companyIds: ['company'] },
+ },
+ ],
+ query: { isLoading: false, isError: false },
+ }),
+}));
+vi.mock('./apply-view', () => ({
+ useApplyCrmView: () => (config: { activeTab: string }) => {
+ const workspace = fixture.workspace as {
+ setActiveTab(value: string): void;
+ };
+ workspace.setActiveTab(config.activeTab);
+ },
+}));
+
+afterEach(() => {
+ cleanup();
+ fixture.pipelinesEnabled = true;
+ fixture.listsEnabled = true;
+});
+
+function setup() {
+ const [activeTab, setActiveTab] = createSignal<string | undefined>('active');
+ fixture.workspace = {
+ activeTab,
+ setActiveTab,
+ host: { scopeId: 'crm', isActive: () => true },
+ source: {},
+ queryFilters: { state: { include: {} } },
+ };
+ render(() => (
+ <CrmWorkspaceView>{() => <div>Record list</div>}</CrmWorkspaceView>
+ ));
+ return { activeTab };
+}
+
+it('keeps sidebar destinations in the mobile header when switching records, pipelines and lists', () => {
+ const { activeTab } = setup();
+ const tabs = () =>
+ within(screen.getByRole('navigation', { name: 'CRM views' }));
+ expect(
+ screen.queryByRole('button', { name: 'Expand CRM sidebar' })
+ ).toBeNull();
+ expect(
+ tabs().getByRole('button', { name: 'Companies', pressed: true })
+ ).toBeTruthy();
+ fireEvent.click(tabs().getByRole('button', { name: 'People' }));
+ expect(activeTab()).toBe('people');
+ expect(
+ tabs().getByRole('button', { name: 'People', pressed: true })
+ ).toBeTruthy();
+ fireEvent.click(tabs().getByRole('button', { name: 'Sales' }));
+ expect(activeTab()).toBe('pipeline:sales');
+ expect(screen.getByText('Sales table')).toBeTruthy();
+ expect(
+ tabs().getByRole('button', { name: 'Sales', pressed: true })
+ ).toBeTruthy();
+ fireEvent.click(tabs().getByRole('button', { name: 'Favorites' }));
+ expect(activeTab()).toBe('list:favorites');
+ expect(
+ tabs().getByRole('button', { name: 'Favorites', pressed: true })
+ ).toBeTruthy();
+});
+
+it('omits pipelines and lists when those features are disabled', () => {
+ fixture.pipelinesEnabled = false;
+ fixture.listsEnabled = false;
+ setup();
+ const tabs = within(screen.getByRole('navigation', { name: 'CRM views' }));
+ expect(
+ tabs.getAllByRole('button').map((button) => button.textContent)
+ ).toEqual(['Companies', 'People']);
+});
diff --git a/apps/web/src/features/crm/views/crm-workspace.tsx b/apps/web/src/features/crm/views/crm-workspace.tsx
index 9b4d2e7cab..3388a06942 100644
--- a/apps/web/src/features/crm/views/crm-workspace.tsx
+++ b/apps/web/src/features/crm/views/crm-workspace.tsx
@@ -7,7 +7,9 @@ import {
import { VIEW_SHELL_TOUR } from '@app/components/view-shell/tour';
import { NIL_UUID } from '@app/features/next-soup/filters/filter-store';
import { getViewPreset } from '@app/features/next-soup/sidebar/soup-filter-presets';
+import { MobileFilterDrawer } from '@app/features/next-soup/soup-view/filters-bar/mobile-filter-drawer';
import { SoupActiveFiltersBar } from '@app/features/next-soup/soup-view/filters-bar/soup-active-filters-bar';
+import { SoupFiltersBar } from '@app/features/next-soup/soup-view/filters-bar/soup-filters-bar';
import { SoupViewContextGroup } from '@app/features/next-soup/soup-view/filters-bar/soup-view-context-group';
import { SoupViewContextSort } from '@app/features/next-soup/soup-view/filters-bar/soup-view-context-sort';
import { UnifiedFilterDropdown } from '@app/features/next-soup/soup-view/filters-bar/unified-filter-dropdown';
@@ -33,6 +35,7 @@ import {
Suspense,
} from 'solid-js';
import { CrmListDialog } from '../components/company-list-dialog';
+import { CrmMobileTabs } from '../components/crm-mobile-tabs';
import { CrmSidebar } from '../components/crm-sidebar';
import { PipelineDialog } from '../components/pipeline-dialog';
import { PipelineSidebar } from '../components/pipeline-sidebar';
@@ -61,7 +64,7 @@ function NavigationToggle(props: {
// CRM collapses its own sidebar, so its toggle stands in for the shell's.
const toggleTarget = tourTarget(VIEW_SHELL_TOUR.sidebarToggle);
return (
- <Show when={shell.aside.isCollapsed()}>
+ <Show when={!isTouchDevice() && shell.aside.isCollapsed()}>
<Show
when={shell.breakpoints.narrow?.()}
fallback={
@@ -83,12 +86,10 @@ function NavigationToggle(props: {
<Dropdown.Trigger
variant="ghost"
size="icon-sm"
- depth={isTouchDevice() ? 3 : undefined}
- class="touch:island touch:pointer-events-auto touch:size-10 touch:shrink-0 touch:bg-chrome"
aria-label="Show CRM navigation"
ref={toggleTarget}
>
- <ListIcon class="size-4 touch:size-6" />
+ <ListIcon class="size-4" />
</Dropdown.Trigger>
</Tooltip>
<Dropdown.Content class="w-55 max-h-[80vh] overflow-auto p-0">
@@ -195,7 +196,6 @@ function CrmFilterChips(props: { onReset: () => void }) {
export function CrmWorkspaceView(props: {
children: (options: {
onOpenEntity?: (entity: EntityData) => boolean;
- mobileHeaderLeading?: JSX.Element;
}) => JSX.Element;
}) {
const {
@@ -362,6 +362,32 @@ export function CrmWorkspaceView(props: {
</Suspense>
</ViewShell.Aside>
<ViewShell.Main>
+ <Show when={isTouchDevice() && !selectedRecord()}>
+ <ViewShell.Header>
+ <CrmMobileTabs
+ active={activeRecord()}
+ pipelines={pipelinesEnabled() ? pipelines.pipelines() : []}
+ lists={listsEnabled() ? lists.lists() : []}
+ onNavigate={(id) =>
+ id.startsWith('pipeline:')
+ ? selectPipeline(id.slice('pipeline:'.length))
+ : navigate(id)
+ }
+ leading={
+ <Show when={!peopleActive() && !pipelineId()}>
+ <Suspense>
+ <MobileFilterDrawer />
+ </Suspense>
+ </Show>
+ }
+ />
+ </ViewShell.Header>
+ <Show when={!peopleActive() && !pipelineId()}>
+ <Suspense>
+ <SoupFiltersBar />
+ </Suspense>
+ </Show>
+ </Show>
<Show when={selectedRecord()} keyed>
{(record) => (
<CrmRecordDetail
@@ -393,9 +419,11 @@ export function CrmWorkspaceView(props: {
}
onTrashed={() => navigate('active')}
navigation={
- <NavigationToggle onExpand={() => setCollapsed(false)}>
- <Suspense>{sidebar()}</Suspense>
- </NavigationToggle>
+ <Show when={!isTouchDevice()}>
+ <NavigationToggle onExpand={() => setCollapsed(false)}>
+ <Suspense>{sidebar()}</Suspense>
+ </NavigationToggle>
+ </Show>
}
/>
)}
@@ -418,21 +446,23 @@ export function CrmWorkspaceView(props: {
</Show>
<Show when={!selectedRecord() && !pipelineId()}>
<Show when={!isTouchDevice() || peopleActive()}>
- <div class="flex h-12 shrink-0 items-center gap-3 px-4">
- <NavigationToggle onExpand={() => setCollapsed(false)}>
- <Suspense>{sidebar()}</Suspense>
- </NavigationToggle>
- <h1
- class="flex h-7 min-w-0 flex-1 items-center px-1 text-sm font-semibold tracking-[-0.03em]"
- title={title()}
- >
- <span class="truncate">{title()}</span>
- </h1>
- </div>
+ <Show when={!isTouchDevice()}>
+ <div class="flex h-12 shrink-0 items-center gap-3 px-4">
+ <NavigationToggle onExpand={() => setCollapsed(false)}>
+ <Suspense>{sidebar()}</Suspense>
+ </NavigationToggle>
+ <h1
+ class="flex h-7 min-w-0 flex-1 items-center px-1 text-sm font-semibold tracking-[-0.03em]"
+ title={title()}
+ >
+ <span class="truncate">{title()}</span>
+ </h1>
+ </div>
+ </Show>
<Show
when={!peopleActive()}
fallback={
- <ViewShell.Header>
+ <ViewShell.Header class="touch:pt-0">
<div class="flex min-w-0 items-center justify-between gap-3">
<PeopleSearchBar />
<Button
@@ -490,11 +520,6 @@ export function CrmWorkspaceView(props: {
<div class="flex min-h-0 min-w-0 flex-1 flex-col">
{props.children({
onOpenEntity: isTouchDevice() ? undefined : openRecord,
- mobileHeaderLeading: isTouchDevice() ? (
- <NavigationToggle onExpand={() => setCollapsed(false)}>
- <Suspense>{sidebar()}</Suspense>
- </NavigationToggle>
- ) : undefined,
})}
</div>
</Show>
diff --git a/apps/web/src/features/crm/views/pipeline.test.tsx b/apps/web/src/features/crm/views/pipeline.test.tsx
new file mode 100644
index 0000000000..febc8dc65b
--- /dev/null
+++ b/apps/web/src/features/crm/views/pipeline.test.tsx
@@ -0,0 +1,177 @@
+import {
+ cleanup,
+ fireEvent,
+ render,
+ screen,
+ waitFor,
+ within,
+} from '@solidjs/testing-library';
+import { Show } from 'solid-js';
+import { afterEach, beforeEach, expect, it, vi } from 'vitest';
+import type { Pipeline } from '../core/pipeline';
+import { PipelineView } from './pipeline';
+
+const device = vi.hoisted(() => ({ touch: true }));
+vi.mock('@core/mobile/isTouchDevice', () => ({
+ isTouchDevice: () => device.touch,
+}));
+vi.mock('@core/component/InlineTitleEditor', () => ({
+ InlineTitleEditor: (props: { value: string; ariaLabel: string }) => (
+ <input aria-label={props.ariaLabel} value={props.value} />
+ ),
+}));
+vi.mock('@ui/components/DeleteDialog', () => ({
+ DeleteDialog: (props: {
+ open: boolean;
+ onDelete(): void;
+ onOpenChange(open: boolean): void;
+ }) => (
+ <Show when={props.open}>
+ <div role="alertdialog" aria-label="Trash pipeline?">
+ <button onClick={props.onDelete}>Confirm trash</button>
+ <button onClick={() => props.onOpenChange(false)}>Cancel trash</button>
+ </div>
+ </Show>
+ ),
+}));
+
+const pipeline: Pipeline = {
+ id: 'pipeline',
+ name: 'Sales',
+ teamId: 'team',
+ userId: 'owner',
+ recordType: 'company',
+ databaseId: 'database',
+ tableId: 'table',
+ primaryColumnId: 'company',
+ sharing: 'private',
+ grant: 'view',
+ createdAt: '',
+ trashedAt: null,
+};
+
+function setup(grant: Pipeline['grant'] = 'view') {
+ const currentPipeline = { ...pipeline, grant };
+ const rename = vi.fn(async (_id: string, _name: string) => {});
+ const trash = vi.fn(async (_id: string) => {});
+ const copyLink = vi.fn();
+ const onTrashed = vi.fn();
+ render(() => (
+ <PipelineView
+ pipeline={currentPipeline}
+ source={{
+ pipelines: () => [pipeline],
+ loading: () => false,
+ error: () => false,
+ refresh: async () => {},
+ create: vi.fn(),
+ rename,
+ trash,
+ }}
+ Editor={(props) => (
+ <>
+ {props.actions}
+ <div role="grid" aria-label="Sales records" />
+ </>
+ )}
+ Sharing={(props) => (
+ <button
+ aria-label={`Share ${props.pipeline.name}`}
+ onClick={props.onCopyLink}
+ >
+ Share pipeline
+ </button>
+ )}
+ onCopyLink={copyLink}
+ onTrashed={onTrashed}
+ />
+ ));
+ return { rename, trash, copyLink, onTrashed };
+}
+
+let motionStyles: HTMLStyleElement;
+beforeEach(() => {
+ vi.spyOn(window, 'scrollTo').mockImplementation(() => {});
+ motionStyles = document.createElement('style');
+ // jsdom does not load the app's dialog transition styles.
+ motionStyles.textContent =
+ '* { transition-duration: 0s; animation-name: none; }';
+ document.head.append(motionStyles);
+});
+afterEach(() => {
+ cleanup();
+ motionStyles.remove();
+ device.touch = true;
+ vi.restoreAllMocks();
+});
+
+it('keeps mobile pipeline controls in a compact action sheet without the title row', () => {
+ setup();
+ expect(screen.getByRole('grid', { name: 'Sales records' })).toBeTruthy();
+ expect(screen.queryByRole('heading', { name: 'Sales' })).toBeNull();
+ expect(screen.queryByRole('button', { name: 'Share Sales' })).toBeNull();
+ fireEvent.click(screen.getByRole('button', { name: 'Pipeline actions' }));
+ expect(screen.getByRole('dialog', { name: 'Pipeline actions' })).toBeTruthy();
+ expect(screen.getByRole('button', { name: 'Share Sales' })).toBeTruthy();
+});
+
+it.each(['view', 'comment', 'edit', 'owner'] as const)(
+ 'respects the %s grant in mobile actions',
+ (grant) => {
+ const { copyLink } = setup(grant);
+ fireEvent.click(screen.getByRole('button', { name: 'Pipeline actions' }));
+ const sheet = within(
+ screen.getByRole('dialog', { name: 'Pipeline actions' })
+ );
+ expect(!!sheet.queryByRole('button', { name: 'Rename pipeline' })).toBe(
+ grant === 'edit' || grant === 'owner'
+ );
+ expect(!!sheet.queryByRole('button', { name: 'Trash pipeline' })).toBe(
+ grant === 'owner'
+ );
+ fireEvent.click(sheet.getByRole('button', { name: 'Share Sales' }));
+ expect(copyLink).toHaveBeenCalledOnce();
+ }
+);
+
+it('renames from mobile and keeps a failed attempt open for retry', async () => {
+ const { rename } = setup('edit');
+ rename.mockRejectedValueOnce(new Error('Request failed'));
+ fireEvent.click(screen.getByRole('button', { name: 'Pipeline actions' }));
+ fireEvent.click(screen.getByRole('button', { name: 'Rename pipeline' }));
+ fireEvent.input(screen.getByRole('textbox', { name: 'Pipeline name' }), {
+ target: { value: ' Renewals ' },
+ });
+ fireEvent.click(screen.getByRole('button', { name: 'Save name' }));
+ await waitFor(() =>
+ expect(screen.getByRole('alert').textContent).toContain('Could not save')
+ );
+ expect(
+ (screen.getByRole('textbox', { name: 'Pipeline name' }) as HTMLInputElement)
+ .value
+ ).toBe(' Renewals ');
+ fireEvent.click(screen.getByRole('button', { name: 'Save name' }));
+ await waitFor(() => expect(screen.queryByRole('dialog')).toBeNull());
+ expect(rename).toHaveBeenCalledTimes(2);
+ expect(rename).toHaveBeenLastCalledWith('pipeline', 'Renewals');
+});
+
+it('requires confirmation before trashing a pipeline from mobile', async () => {
+ const { trash, onTrashed } = setup('owner');
+ fireEvent.click(screen.getByRole('button', { name: 'Pipeline actions' }));
+ fireEvent.click(screen.getByRole('button', { name: 'Trash pipeline' }));
+ expect(
+ screen.getByRole('alertdialog', { name: 'Trash pipeline?' })
+ ).toBeTruthy();
+ expect(trash).not.toHaveBeenCalled();
+ fireEvent.click(screen.getByRole('button', { name: 'Confirm trash' }));
+ await waitFor(() => expect(onTrashed).toHaveBeenCalledOnce());
+ expect(trash).toHaveBeenCalledExactlyOnceWith('pipeline');
+});
+
+it('keeps the title and sharing controls on desktop', () => {
+ device.touch = false;
+ setup();
+ expect(screen.getByRole('heading', { name: 'Sales' })).toBeTruthy();
+ expect(screen.getByRole('button', { name: 'Share Sales' })).toBeTruthy();
+});
diff --git a/apps/web/src/features/crm/views/pipeline.tsx b/apps/web/src/features/crm/views/pipeline.tsx
index baa052094a..b1927fb3f0 100644
--- a/apps/web/src/features/crm/views/pipeline.tsx
+++ b/apps/web/src/features/crm/views/pipeline.tsx
@@ -1,9 +1,14 @@
import { InlineTitleEditor } from '@core/component/InlineTitleEditor';
+import { isTouchDevice } from '@core/mobile/isTouchDevice';
import DotsThreeIcon from '@phosphor/dots-three.svg';
import PencilIcon from '@phosphor/pencil-line.svg';
import TrashIcon from '@phosphor/trash-simple.svg';
+import { ActionDialogShell } from '@ui/components/ActionDialogShell';
+import { Button } from '@ui/components/Button';
import { DeleteDialog } from '@ui/components/DeleteDialog';
+import { Dialog } from '@ui/components/Dialog';
import { Dropdown } from '@ui/components/Dropdown';
+import { Input } from '@ui/components/Input';
import { createSignal, type JSX, Show } from 'solid-js';
import type {
PipelineEditor,
@@ -26,17 +31,23 @@ export function PipelineView(props: {
const [pending, setPending] = createSignal(false);
const [error, setError] = createSignal('');
const [deleting, setDeleting] = createSignal(false);
+ const [actionsOpen, setActionsOpen] = createSignal(false);
+ const [renaming, setRenaming] = createSignal(false);
+ const [name, setName] = createSignal('');
let title: HTMLSpanElement | undefined;
+ let mobileNameInput: HTMLInputElement | undefined;
const canEdit = () => ['owner', 'edit'].includes(props.pipeline.grant);
const isOwner = () => props.pipeline.grant === 'owner';
async function save(action: () => Promise<void>) {
- if (pending()) return;
+ if (pending()) return false;
setPending(true);
setError('');
try {
await action();
+ return true;
} catch {
setError('Could not save this change. Please try again.');
+ return false;
} finally {
setPending(false);
}
@@ -46,70 +57,199 @@ export function PipelineView(props: {
input?.focus();
input?.select();
};
+ const openActions = () => {
+ setName(props.pipeline.name);
+ setError('');
+ setRenaming(false);
+ setActionsOpen(true);
+ };
+ const startRenaming = () => {
+ setRenaming(true);
+ queueMicrotask(() => {
+ mobileNameInput?.focus();
+ mobileNameInput?.select();
+ });
+ };
+ const rename = async (event: SubmitEvent) => {
+ event.preventDefault();
+ const nextName = name().trim();
+ if (!canEdit() || !nextName || nextName === props.pipeline.name) return;
+ if (await save(() => props.source.rename(props.pipeline.id, nextName))) {
+ setActionsOpen(false);
+ }
+ };
return (
- <div class="flex size-full min-h-0 flex-col">
- <div class="flex h-12 min-w-0 shrink-0 items-center gap-2 px-4">
- {props.navigation}
- <Show
- when={canEdit()}
- fallback={
- <h1 class="min-w-0 truncate px-1 text-sm font-semibold">
- {props.pipeline.name}
- </h1>
- }
- >
- <span ref={title} class="flex min-w-0 px-1">
- <InlineTitleEditor
- value={props.pipeline.name}
- placeholder="Untitled pipeline"
- ariaLabel="Pipeline name"
- class="text-sm"
- onRename={(name) =>
- void save(() => props.source.rename(props.pipeline.id, name))
- }
+ <div class="flex min-h-0 min-w-0 flex-1 flex-col touch:pb-[max(var(--safe-bottom,0px),var(--mobile-content-inset-bottom,0px))]">
+ <Show when={!isTouchDevice()}>
+ <div class="flex h-12 min-w-0 shrink-0 items-center gap-2 px-4">
+ {props.navigation}
+ <Show
+ when={canEdit()}
+ fallback={
+ <h1 class="min-w-0 truncate px-1 text-sm font-semibold">
+ {props.pipeline.name}
+ </h1>
+ }
+ >
+ <span ref={title} class="flex min-w-0 px-1">
+ <InlineTitleEditor
+ value={props.pipeline.name}
+ placeholder="Untitled pipeline"
+ ariaLabel="Pipeline name"
+ class="text-sm"
+ onRename={(name) =>
+ void save(() => props.source.rename(props.pipeline.id, name))
+ }
+ />
+ </span>
+ </Show>
+ <Show when={canEdit() || isOwner()}>
+ <Dropdown placement="bottom-start">
+ <Dropdown.Trigger
+ variant="ghost"
+ size="icon-sm"
+ aria-label="Pipeline actions"
+ class="shrink-0"
+ disabled={pending()}
+ >
+ <DotsThreeIcon class="size-4" />
+ </Dropdown.Trigger>
+ <Dropdown.Content class="min-w-44">
+ <Show when={canEdit()}>
+ <Dropdown.Item onSelect={() => queueMicrotask(editTitle)}>
+ <PencilIcon class="size-4" />
+ Rename
+ </Dropdown.Item>
+ </Show>
+ <Show when={isOwner()}>
+ <Dropdown.Item onSelect={() => setDeleting(true)}>
+ <TrashIcon class="size-4" />
+ Trash pipeline
+ </Dropdown.Item>
+ </Show>
+ </Dropdown.Content>
+ </Dropdown>
+ </Show>
+ <div class="ml-auto flex shrink-0 items-center gap-1">
+ <props.Sharing
+ pipeline={props.pipeline}
+ onCopyLink={props.onCopyLink}
/>
- </span>
- </Show>
- <Show when={canEdit() || isOwner()}>
- <Dropdown placement="bottom-start">
- <Dropdown.Trigger
- variant="ghost"
- size="icon-sm"
- aria-label="Pipeline actions"
- class="shrink-0"
- disabled={pending()}
- >
- <DotsThreeIcon class="size-4" />
- </Dropdown.Trigger>
- <Dropdown.Content class="min-w-44">
- <Show when={canEdit()}>
- <Dropdown.Item onSelect={() => queueMicrotask(editTitle)}>
- <PencilIcon class="size-4" />
- Rename
- </Dropdown.Item>
- </Show>
- <Show when={isOwner()}>
- <Dropdown.Item onSelect={() => setDeleting(true)}>
- <TrashIcon class="size-4" />
- Trash pipeline
- </Dropdown.Item>
- </Show>
- </Dropdown.Content>
- </Dropdown>
- </Show>
- <div class="ml-auto flex shrink-0 items-center gap-1">
- <props.Sharing
- pipeline={props.pipeline}
- onCopyLink={props.onCopyLink}
- />
+ </div>
</div>
- </div>
- <Show when={error()}>
+ </Show>
+ <Show when={error() && !actionsOpen()}>
<p role="alert" class="px-4 pb-2 text-sm text-failure-ink">
{error()}
</p>
</Show>
- <props.Editor pipeline={props.pipeline} />
+ <props.Editor
+ pipeline={props.pipeline}
+ actions={
+ <Show when={isTouchDevice()}>
+ <Button
+ variant="ghost"
+ size="icon-md"
+ label="Pipeline actions"
+ onClick={openActions}
+ >
+ <DotsThreeIcon class="size-4" />
+ </Button>
+ </Show>
+ }
+ />
+ <Dialog
+ open={actionsOpen()}
+ onOpenChange={(open) => !pending() && setActionsOpen(open)}
+ class="w-96 max-w-[calc(100vw-2rem)]"
+ >
+ <ActionDialogShell>
+ <ActionDialogShell.Body>
+ <ActionDialogShell.Header>
+ <ActionDialogShell.Title>
+ Pipeline actions
+ </ActionDialogShell.Title>
+ </ActionDialogShell.Header>
+ <Show when={canEdit()}>
+ <Show
+ when={renaming()}
+ fallback={
+ <Button
+ variant="ghost"
+ class="w-full justify-start"
+ onClick={startRenaming}
+ >
+ <PencilIcon class="size-4" />
+ Rename pipeline
+ </Button>
+ }
+ >
+ <form
+ class="flex flex-col gap-3"
+ onSubmit={(event) => void rename(event)}
+ >
+ <label class="flex flex-col gap-1.5 text-sm">
+ Pipeline name
+ <Input
+ ref={mobileNameInput}
+ value={name()}
+ onInput={(event) => setName(event.currentTarget.value)}
+ disabled={pending()}
+ maxlength={200}
+ required
+ />
+ </label>
+ <Button
+ type="submit"
+ variant="outline"
+ disabled={
+ pending() ||
+ !name().trim() ||
+ name().trim() === props.pipeline.name
+ }
+ >
+ Save name
+ </Button>
+ </form>
+ </Show>
+ </Show>
+ <div class="flex items-center justify-between gap-3">
+ <span class="text-sm">Sharing</span>
+ <props.Sharing
+ pipeline={props.pipeline}
+ onCopyLink={props.onCopyLink}
+ />
+ </div>
+ <Show when={isOwner()}>
+ <Button
+ variant="danger"
+ disabled={pending()}
+ onClick={() => {
+ setActionsOpen(false);
+ setDeleting(true);
+ }}
+ >
+ <TrashIcon class="size-4" />
+ Trash pipeline
+ </Button>
+ </Show>
+ <Show when={error()}>
+ <p role="alert" class="text-sm text-failure-ink">
+ {error()}
+ </p>
+ </Show>
+ </ActionDialogShell.Body>
+ <ActionDialogShell.Footer>
+ <Button
+ variant="ghost"
+ disabled={pending()}
+ onClick={() => setActionsOpen(false)}
+ >
+ Done
+ </Button>
+ </ActionDialogShell.Footer>
+ </ActionDialogShell>
+ </Dialog>
<DeleteDialog
open={deleting()}
onOpenChange={setDeleting}
diff --git a/docs/AGENT_GUIDE/surfaces.md b/docs/AGENT_GUIDE/surfaces.md
index f3b81df89d..0bb8b04cac 100644
--- a/docs/AGENT_GUIDE/surfaces.md
+++ b/docs/AGENT_GUIDE/surfaces.md
@@ -1906,11 +1906,17 @@ below, and a **Create …** button that also submits on Command-Enter.
`Search companies` and `Search people` use the shared Email/Tasks search bar.
Command-F focuses it, `Clear search` resets it, and Escape leaves the field.
-On touch devices, Companies uses the same full-frame list layout as the other
-mobile views: floating CRM-navigation and filter buttons and the global
-**+ Company** action above the dock. People keeps its title row, search and
-**New contact**. The navigation button opens the CRM records, pipelines and
-lists; the embedded detail stack stays out of the mobile flow, so selecting a
+On touch devices, CRM uses the same scrollable pill tabs as Tasks in the top
+header: Companies, People, available pipelines, and enabled lists. Swipe the
+strip horizontally to reach every destination; the selected tab stays visible.
+The tabs remain available inside pipelines, with no hamburger button. Company
+filters lead the strip when available. On mobile, pipelines omit their title
+and sharing row and use an edge-to-edge table, below the top safe area and above
+the bottom dock. The compact **Pipeline actions** button in the table toolbar
+opens rename and sharing controls; only owners see **Trash pipeline**, which
+requires confirmation. Sharing opens the existing share dialog. Companies uses
+the full-frame list with the global **+ Company** action above the dock. People keeps its search and **New contact** below the tab
+strip. The embedded detail stack stays out of the mobile flow, so selecting a
row navigates in place.
On desktop, clicking a company or a person in the list (or pressing Enter on a