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): keep linked item navigation in customers (#9298)

dev-rbf0a6ccaefea0
diff --git a/apps/web/AGENTS.md b/apps/web/AGENTS.md
index 7d96f7211d..27ab25db14 100644
--- a/apps/web/AGENTS.md
+++ b/apps/web/AGENTS.md
@@ -332,7 +332,20 @@ resolved session ID; keep the existing `AgentSessionProvider` subscription to
- Share URL recognition with `packages/lexical-core/utils/auto-link.ts`; preserve explicit unlink markers when saving and rendering messages. See `packages/lexical-core/README.md` at the repository root.
- Empty human DMs use the shared centered conversations graphic and explain email delivery to nonusers; keep this state out of agent DMs, loading/error states, and populated timelines.
-- Keep CRM database discovery row-linked and permission-scoped; use horizontally centered actionable list states raised toward the toolbar and shared skeletons, with separate search-empty and retry states. Company/contact touch headers use a Switch view drawer that honors host collapse and square copy-link islands; keep phone breadcrumbs above the switcher and leave the workspace view strip unchanged. Record search fills the row beside filters with header spacing; section creation replaces the default floating dock action through FloatRegion. See `src/features/crm/README.md` and `docs/agent-guide/crm.md` at the repo root.
+- Keep CRM database discovery row-linked and permission-scoped; use horizontally
+ centered actionable list states raised toward the toolbar and shared skeletons,
+ with separate search-empty and retry states. Company/contact touch headers use a
+ Switch view drawer that honors host collapse and square copy-link islands; keep
+ phone breadcrumbs above the switcher and leave the workspace view strip unchanged.
+ Open linked items under their Customers source URL; typed record sections append
+ only `<id>` and reject redundant typed URLs. Workspace activity and record
+ Files/overview notes retain item metadata on their own scoped routes. Keep
+ source and record breadcrumbs without section labels or extra preview-title
+ separators, retain entity menus and sharing, and return the current record
+ breadcrumb to its captured section and history entry.
+ Record search fills the row beside filters with header spacing; section creation
+ replaces the default floating dock action through FloatRegion. See
+ `src/features/crm/README.md` and `docs/agent-guide/crm.md` at the repo root.
- Main Tasks mounts reusable GraphQL saved views; keep embedded Project/CRM task lists unchanged. Read `src/features/tasks-view/AGENTS.md` for filter, draft, navigation, and browser checks.
- Enable persisted email/calendar review controls only for the review’s saved acting account; historical reviews fall back to the session owner. Require session edit access on desktop and mobile.
- Email draft reads compare server generations before choosing cached delivery state over a restored working copy; only a definitive first-submission rejection permits local send recovery without server cancellation.
diff --git a/apps/web/src/components/app/split-layout/split-router/app-middleware.ts b/apps/web/src/components/app/split-layout/split-router/app-middleware.ts
index d72b803c7f..3b74bd995c 100644
--- a/apps/web/src/components/app/split-layout/split-router/app-middleware.ts
+++ b/apps/web/src/components/app/split-layout/split-router/app-middleware.ts
@@ -86,8 +86,12 @@ function redirectLegacyRoutes(
// Touch shows records on their own pages, as the Customers lists open them.
if (rootId === 'view-companies' && isTouch) {
- const { recordType, recordId } = routeParams(route);
- if (typeof recordType === 'string' && typeof recordId === 'string') {
+ const { recordType, recordId, itemId } = routeParams(route);
+ if (
+ typeof recordType === 'string' &&
+ typeof recordId === 'string' &&
+ typeof itemId !== 'string'
+ ) {
return redirect(`/${recordType}/${encodeURIComponent(recordId)}`);
}
}
diff --git a/apps/web/src/features/crm/README.md b/apps/web/src/features/crm/README.md
index 24cb7231e3..824cbfc1f9 100644
--- a/apps/web/src/features/crm/README.md
+++ b/apps/web/src/features/crm/README.md
@@ -18,7 +18,7 @@ crm/
crm-create.tsx / crm-link.tsx
crm-actions.ts / crm-hide-action.ts / crm-action-items.ts / crm-user-action.tsx
crm-search.ts / crm-tool-renderers.tsx
- crm-route.ts Route params, record trail, and legacy pipeline link decoding
+ crm-route.ts Route params, record and item trails, and legacy pipeline link decoding
route-views.tsx Authenticated route and shared-view decoding
crm-hosted-content.ts Split content that opens Customers on a pipeline or record
*-adapter.* Production sources, navigation, persistence, download, collection wiring
@@ -115,6 +115,25 @@ a record independently of the row; additional values use the shared overflow men
Email still matches visible company domains and contact addresses for feed
membership, but the row displays only stored properties, not inferred matches.
No separate CRM association metadata lookup or row footer runs during paging.
+Linked Tasks, Email, Notes, Calls and Databases open through nested Customers
+routes from workspace activity and record sections. Tasks, Emails, Calls and
+Databases record sections append only `<item-id>` because their section determines
+the renderer; Tasks also omit the redundant `md/task` suffix. These sections reject
+redundant typed item URLs rather than retaining fallback routes. Workspace activity
+retains `<item-type>/<item-id>` and document metadata; record Files and overview
+notes use document-metadata routes restricted to those sections. The route stores
+the item name and record trail in entry state. Route params retain the record and
+section; pane search retains the workspace tab. `route-adapter.ts` owns item
+navigation and close/history restoration. Keep workspace/pipeline item variants
+in its shared route-family table and identify history entries through merged route
+params instead of enumerating item route IDs.
+`views/item-detail.tsx` renders authorized details in the existing CRM shell
+with source, record trail and item breadcrumbs, omitting section labels such as
+Tasks and Files. The current record breadcrumb returns to the captured section
+and entry state. Preview headers append their own live title and menu after the
+source trail without an extra separator; do not duplicate the selected title in
+the prefix. Modified clicks keep their existing split behavior.
+Standalone record previews retain their normal navigation outside the workspace.
Record-detail lists and activity membership remain unchanged.
Sidebar Tasks reuse the production Tasks filters, sort, grouping, and list/board/Gantt
layouts (subject to the normal feature flags and touch fallback). They use a separate
diff --git a/apps/web/src/features/crm/activity-tasks-adapter.tsx b/apps/web/src/features/crm/activity-tasks-adapter.tsx
index d6372e5ae3..d498decb48 100644
--- a/apps/web/src/features/crm/activity-tasks-adapter.tsx
+++ b/apps/web/src/features/crm/activity-tasks-adapter.tsx
@@ -26,11 +26,13 @@ import {
CrmListSkeleton,
} from './components/list-state';
import { useCrmContext } from './context/crm-context';
+import { useCrmWorkspace } from './context/workspace-context';
/** Production Tasks layouts for the workspace-wide CRM activity scope. */
export function CrmActivityTasks(props: { title?: JSX.Element }) {
const crm = useCrmContext();
const layout = useSplitLayout();
+ const workspace = useCrmWorkspace();
return (
<TagSetsQueryProvider>
<TasksViewProvider
@@ -38,6 +40,19 @@ export function CrmActivityTasks(props: { title?: JSX.Element }) {
restoreEntryState
scopeKey="crm:activity:tasks"
onOpenTask={(task, options) => {
+ if (
+ workspace.host.record.openItem(
+ {
+ type: 'document',
+ id: task.id,
+ name: task.fallbackName ?? 'Task',
+ fileType: 'md',
+ subType: { type: 'task' },
+ },
+ options?.event
+ )
+ )
+ return true;
layout.openWithSplit(
{ type: 'task', id: task.id },
{ preferNewSplit: options?.event?.shiftKey }
diff --git a/apps/web/src/features/crm/context/workspace-context.tsx b/apps/web/src/features/crm/context/workspace-context.tsx
index 32e35c80ee..c40e786d9b 100644
--- a/apps/web/src/features/crm/context/workspace-context.tsx
+++ b/apps/web/src/features/crm/context/workspace-context.tsx
@@ -24,6 +24,26 @@ export type CrmRecordNavigation = {
/** Shows the last record of `trail` at its Overview. */
open(trail: readonly CrmRecordRef[]): void;
setSection(section: CrmRecordSection): void;
+ item: Accessor<
+ | {
+ itemType: 'document' | 'email' | 'call' | 'database';
+ itemId: string;
+ itemFileType?: string;
+ itemSubType?: 'task' | 'snippet' | 'skill';
+ name: string;
+ }
+ | undefined
+ >;
+ openItem(
+ entity:
+ | EntityData
+ | Pick<
+ Extract<EntityData, { type: 'document' }>,
+ 'type' | 'id' | 'name' | 'fileType' | 'subType'
+ >,
+ event?: MouseEvent | KeyboardEvent
+ ): boolean;
+ closeItem(): void;
/** Returns to the list the records were opened from. */
close(): void;
};
@@ -82,8 +102,9 @@ export type CrmWorkspace = {
};
const Context = createContext<CrmWorkspace>();
export const CrmWorkspaceProvider = Context.Provider;
+export const useOptionalCrmWorkspace = () => useContext(Context);
export function useCrmWorkspace(): CrmWorkspace {
- const value = useContext(Context);
+ const value = useOptionalCrmWorkspace();
if (!value)
throw new Error('CRM workspace views require a CrmWorkspaceProvider');
return value;
diff --git a/apps/web/src/features/crm/crm-route.test.ts b/apps/web/src/features/crm/crm-route.test.ts
index 617644461d..b0016386c5 100644
--- a/apps/web/src/features/crm/crm-route.test.ts
+++ b/apps/web/src/features/crm/crm-route.test.ts
@@ -11,18 +11,25 @@ import { paneRoute } from '@app/routes/app-route';
import {
appRoute,
companiesRoute,
+ crmItemRoute,
+ crmPipelineItemRoute,
+ crmPipelineRecordFileItemRoute,
+ crmPipelineRecordItemRoute,
crmPipelineRecordRoute,
crmPipelineRoute,
+ crmRecordFileItemRoute,
+ crmRecordItemRoute,
crmRecordRoute,
legacyContentRoute,
notFoundRoute,
+ taskDetailRoute,
} from '@app/routes/routes';
import { createAppSplitRouterMiddleware } from '@components/app/split-layout/split-router/app-middleware';
import { createMacroMentionLinkResolver } from '@components/app/split-layout/split-router/mention-links';
import { describe, expect, it, vi } from 'vitest';
import { pipelineTab } from './core/navigation';
import type { CrmViewConfig } from './core/saved-view';
-import { crmSearchCodec } from './crm-route';
+import { crmRecordItemParams, crmSearchCodec } from './crm-route';
import { encodeCrmViewParam } from './queries/saved-view-codec';
vi.mock('@components/app/split-layout/componentRegistry', () => ({
@@ -50,8 +57,19 @@ const routes = createRoutesManifest({
{
...companiesRoute,
children: [
- { ...crmPipelineRoute, children: [crmPipelineRecordRoute] },
+ {
+ ...crmPipelineRoute,
+ children: [
+ crmPipelineItemRoute,
+ crmPipelineRecordRoute,
+ crmPipelineRecordItemRoute,
+ crmPipelineRecordFileItemRoute,
+ ],
+ },
+ crmItemRoute,
crmRecordRoute,
+ crmRecordItemRoute,
+ crmRecordFileItemRoute,
],
},
legacyContentRoute,
@@ -158,6 +176,168 @@ describe('record and pipeline URLs', () => {
});
});
+describe('CRM item URLs', () => {
+ const itemId = '01a1212c-74e5-79bd-8767-0d4943d55b18';
+
+ it('claims a CRM task as the same document shown by the Tasks view', () => {
+ expect(
+ crmItemRoute.claim?.({
+ itemType: 'document',
+ itemId,
+ itemFileType: 'md',
+ itemSubType: 'task',
+ })
+ ).toEqual(taskDetailRoute.claim?.({ taskId: itemId }));
+ });
+ it.each([
+ ['tasks', 'document', 'md', 'task', 'task'],
+ ['emails', 'email', undefined, undefined, 'email'],
+ ['calls', 'call', undefined, undefined, 'call'],
+ ['databases', 'database', undefined, undefined, 'database'],
+ ])(
+ 'decodes a %s record item and references the item, not the record',
+ (section, itemType, itemFileType, itemSubType, block) => {
+ const path = `/companies/contact/${contactId}/${section}/${itemId}`;
+ expect(leafOf(path.slice(1))).toEqual({
+ id: crmRecordItemRoute.id,
+ params: {
+ recordType: 'contact',
+ recordId: contactId,
+ section,
+ itemId,
+ itemType,
+ ...(itemFileType ? { itemFileType } : {}),
+ ...(itemSubType ? { itemSubType } : {}),
+ },
+ });
+ expect(resolveMention(appUrl(path))).toEqual({
+ id: itemId,
+ block,
+ params: {},
+ });
+ }
+ );
+
+ it('claims a compact task as the same document as its generic and Tasks URLs', () => {
+ const decoded = crmRecordItemParams.safeParse(
+ leafOf(`companies/company/${companyId}/tasks/${itemId}`)?.params
+ );
+ expect(decoded.success).toBe(true);
+ if (!decoded.success) throw new Error('Expected a compact task');
+ expect(crmRecordItemRoute.claim?.(decoded.data)).toEqual(
+ taskDetailRoute.claim?.({ taskId: itemId })
+ );
+ expect(crmRecordItemRoute.claim?.(decoded.data)).toEqual(
+ crmItemRoute.claim?.({
+ itemType: 'document',
+ itemId,
+ itemFileType: 'md',
+ itemSubType: 'task',
+ })
+ );
+ });
+
+ it('decodes a pipeline record item and mentions the selected call', () => {
+ const path = `/companies/pipeline/${pipelineId}/company/${companyId}/calls/${itemId}`;
+ expect(leafOf(path.slice(1))).toEqual({
+ id: crmPipelineRecordItemRoute.id,
+ params: {
+ recordType: 'company',
+ recordId: companyId,
+ section: 'calls',
+ itemId,
+ itemType: 'call',
+ },
+ });
+ expect(resolveMention(appUrl(path))).toEqual({
+ id: itemId,
+ block: 'call',
+ params: {},
+ });
+ });
+
+ it.each([
+ [`document/${itemId}/md/task`, 'task'],
+ [`document/${itemId}/md`, 'md'],
+ [`document/${itemId}/pdf`, 'pdf'],
+ ])(
+ 'references a Files item with its document metadata: %s',
+ (item, block) => {
+ expect(
+ resolveMention(appUrl(`/companies/company/${companyId}/files/${item}`))
+ ).toEqual({ id: itemId, block, params: {} });
+ }
+ );
+
+ it.each([
+ ['companies', crmItemRoute.id],
+ [`companies/pipeline/${pipelineId}`, crmPipelineItemRoute.id],
+ ])('retains the workspace source of %s', (source, id) => {
+ expect(leafOf(`${source}/email/${itemId}`)).toEqual({
+ id,
+ params: { itemType: 'email', itemId },
+ });
+ });
+
+ it.each([
+ [
+ `companies/company/${companyId}`,
+ crmRecordFileItemRoute.id,
+ 'company',
+ companyId,
+ undefined,
+ ],
+ [
+ `companies/company/${companyId}/files`,
+ crmRecordFileItemRoute.id,
+ 'company',
+ companyId,
+ 'files',
+ ],
+ [
+ `companies/pipeline/${pipelineId}/contact/${contactId}`,
+ crmPipelineRecordFileItemRoute.id,
+ 'contact',
+ contactId,
+ undefined,
+ ],
+ [
+ `companies/pipeline/${pipelineId}/contact/${contactId}/files`,
+ crmPipelineRecordFileItemRoute.id,
+ 'contact',
+ contactId,
+ 'files',
+ ],
+ ])(
+ 'retains the Files/Notes source of %s',
+ (source, id, recordType, recordId, section) => {
+ expect(leafOf(`${source}/document/${itemId}/md`)).toEqual({
+ id,
+ params: {
+ recordType,
+ recordId,
+ ...(section ? { section } : {}),
+ itemType: 'document',
+ itemId,
+ itemFileType: 'md',
+ },
+ });
+ }
+ );
+
+ it.each([
+ `companies/company/${companyId}/tasks/document/${itemId}/md/task`,
+ `companies/contact/${contactId}/emails/email/${itemId}`,
+ `companies/company/${companyId}/calls/call/${itemId}`,
+ `companies/contact/${contactId}/databases/database/${itemId}`,
+ `companies/pipeline/${pipelineId}/contact/${contactId}/tasks/document/${itemId}/md/task`,
+ `companies/pipeline/${pipelineId}/company/${companyId}/emails/email/${itemId}`,
+ ])('rejects obsolete typed record item URLs: %s', (path) => {
+ expect(leafOf(path)?.id).toBe(notFoundRoute.id);
+ expect(resolveMention(appUrl(`/${path}`))).toBeUndefined();
+ });
+});
+
describe('pipeline links', () => {
it('pastes a copied pipeline link as a mention of the pipeline', () => {
expect(
@@ -369,6 +549,28 @@ describe('legacy CRM URLs', () => {
expect(run(recordEntry('company', companyId))).toBeUndefined();
});
+ it('keeps a record item link inside Customers on touch instead of dropping the item', () => {
+ const entry: Entry = {
+ id: 'entry',
+ location: {
+ route: paneRoute(
+ { id: companiesRoute.id, params: {} },
+ {
+ id: crmRecordItemRoute.id,
+ params: {
+ recordType: 'company',
+ recordId: companyId,
+ section: 'emails',
+ itemType: 'email',
+ itemId: 'thread-1',
+ },
+ }
+ ),
+ },
+ };
+ expect(run(entry, { touch: true })).toBeUndefined();
+ });
+
it('carries a linked Discussion message into the record on entry', () => {
const path = `/companies/company/${companyId}`;
const result = run(recordEntry('company', companyId), {
diff --git a/apps/web/src/features/crm/crm-route.ts b/apps/web/src/features/crm/crm-route.ts
index 7042e43698..4c14e521ae 100644
--- a/apps/web/src/features/crm/crm-route.ts
+++ b/apps/web/src/features/crm/crm-route.ts
@@ -49,6 +49,52 @@ export const crmRecordParams = z.object({
export type CrmRecordParams = z.infer<typeof crmRecordParams>;
+/** A CRM-linked item keeps its source record trail and display name in history. */
+export const crmItemParams = z.object({
+ itemType: z.enum(['document', 'email', 'call', 'database']),
+ itemId: z.string().min(1),
+ itemFileType: z.string().optional(),
+ itemSubType: z.enum(['task', 'snippet', 'skill']).optional(),
+});
+
+export type CrmItemParams = z.infer<typeof crmItemParams>;
+
+const CRM_SECTION_ITEM_TYPES = {
+ tasks: { itemType: 'document', itemFileType: 'md', itemSubType: 'task' },
+ emails: { itemType: 'email' },
+ calls: { itemType: 'call' },
+ databases: { itemType: 'database' },
+} as const;
+
+/** Typed record sections supply all renderer metadata without extra URL segments. */
+export const crmRecordItemParams = crmRecordParams
+ .extend({
+ section: z.enum(['tasks', 'emails', 'calls', 'databases']),
+ itemId: crmItemParams.shape.itemId,
+ })
+ .transform((params) => ({
+ ...params,
+ ...CRM_SECTION_ITEM_TYPES[params.section],
+ }));
+
+/** Files and overview notes need document metadata, unlike typed sections. */
+export const crmRecordFileItemParams = crmRecordParams.extend({
+ ...crmItemParams.shape,
+ section: z.enum(['overview', 'files']).optional(),
+ itemType: z.literal('document'),
+});
+
+/** The canonical entity kind used by item claims, references, and fallback names. */
+export function crmItemBlockType({
+ itemType,
+ itemFileType,
+ itemSubType,
+}: CrmItemParams) {
+ return itemType === 'document'
+ ? (itemSubType ?? itemFileType ?? 'md')
+ : itemType;
+}
+
/** Records opened on the way to the shown one, kept with its history entry. */
export const crmRecordTrailSchema = z
.array(
@@ -60,6 +106,11 @@ export const crmRecordTrailSchema = z
)
.min(1);
+export const crmItemStateSchema = z.object({
+ trail: crmRecordTrailSchema.optional(),
+ name: z.string(),
+});
+
export function crmRecordClaim({ recordType, recordId }: CrmRecordParams) {
return { namespace: 'block', id: `${recordType}:${recordId}` };
}
diff --git a/apps/web/src/features/crm/record-tasks-adapter.test.tsx b/apps/web/src/features/crm/record-tasks-adapter.test.tsx
index bf07786fa1..8622ec319a 100644
--- a/apps/web/src/features/crm/record-tasks-adapter.test.tsx
+++ b/apps/web/src/features/crm/record-tasks-adapter.test.tsx
@@ -6,14 +6,26 @@ import { CrmActivityTasks } from './activity-tasks-adapter';
import type { CrmRecordScope } from './core/record';
import { CrmRecordTasks } from './record-tasks-adapter';
-const { openWithSplit, popoverSplit, adaptive, openTaskComposer } = vi.hoisted(
- () => ({
- openWithSplit: vi.fn(),
- popoverSplit: vi.fn(),
- adaptive: vi.fn(() => false),
- openTaskComposer: vi.fn(),
- })
-);
+const {
+ openWithSplit,
+ popoverSplit,
+ adaptive,
+ openTaskComposer,
+ openItem,
+ workspacePresent,
+} = vi.hoisted(() => ({
+ openWithSplit: vi.fn(),
+ popoverSplit: vi.fn(),
+ adaptive: vi.fn(() => false),
+ openTaskComposer: vi.fn(),
+ openItem: vi.fn(() => false),
+ workspacePresent: vi.fn(() => true),
+}));
+vi.mock('./context/workspace-context', () => ({
+ useCrmWorkspace: () => ({ host: { record: { openItem } } }),
+ useOptionalCrmWorkspace: () =>
+ workspacePresent() ? { host: { record: { openItem } } } : undefined,
+}));
vi.mock('./context/crm-context', () => ({
useCrmContext: () => ({ openTaskComposer }),
}));
@@ -87,6 +99,7 @@ vi.mock('./components/record-section', () => ({
afterEach(() => {
cleanup();
vi.clearAllMocks();
+ workspacePresent.mockReturnValue(true);
});
const scopes: CrmRecordScope[] = [
@@ -151,3 +164,22 @@ it('forwards board and Gantt creation defaults through the CRM composer', () =>
composerContext: { key: 'crm-board', initialPropertyValues: {} },
});
});
+
+it('opens an unmodified task in the CRM record instead of a separate split', () => {
+ openItem.mockReturnValueOnce(true);
+ render(() => <CrmRecordTasks scope={scopes[0]} />);
+ fireEvent.click(screen.getByRole('button', { name: 'Open task' }));
+ expect(openItem).toHaveBeenCalledOnce();
+ expect(openWithSplit).not.toHaveBeenCalled();
+});
+
+it('keeps standalone record previews independent of a CRM workspace', () => {
+ workspacePresent.mockReturnValue(false);
+ render(() => <CrmRecordTasks scope={scopes[0]} />);
+ fireEvent.click(screen.getByRole('button', { name: 'Open task' }));
+ expect(openItem).not.toHaveBeenCalled();
+ expect(openWithSplit).toHaveBeenCalledExactlyOnceWith(
+ { type: 'task', id: 'task-1' },
+ { preferNewSplit: false }
+ );
+});
diff --git a/apps/web/src/features/crm/record-tasks-adapter.tsx b/apps/web/src/features/crm/record-tasks-adapter.tsx
index f786d3fe9e..605097865f 100644
--- a/apps/web/src/features/crm/record-tasks-adapter.tsx
+++ b/apps/web/src/features/crm/record-tasks-adapter.tsx
@@ -20,6 +20,7 @@ import {
CrmListSkeleton,
} from './components/list-state';
import { RecordSection } from './components/record-section';
+import { useOptionalCrmWorkspace } from './context/workspace-context';
import type { CrmRecordScope } from './core/record';
import { crmTaskComposerContext } from './task-composer';
@@ -31,6 +32,7 @@ import { crmTaskComposerContext } from './task-composer';
*/
export function CrmRecordTasks(props: { scope: CrmRecordScope }) {
const layout = useSplitLayout();
+ const workspace = useOptionalCrmWorkspace();
return (
<Show when={props.scope} keyed>
{(scope) => (
@@ -40,6 +42,19 @@ export function CrmRecordTasks(props: { scope: CrmRecordScope }) {
restoreEntryState
scopeKey={`crm:${scope.type}:${scope.id}:tasks`}
onOpenTask={(task, options) => {
+ if (
+ workspace?.host.record.openItem(
+ {
+ type: 'document',
+ id: task.id,
+ name: task.fallbackName ?? 'Task',
+ fileType: 'md',
+ subType: { type: 'task' },
+ },
+ options?.event
+ )
+ )
+ return true;
layout.openWithSplit(
{ type: 'task', id: task.id },
{ preferNewSplit: options?.event?.shiftKey }
diff --git a/apps/web/src/features/crm/route-adapter.test.tsx b/apps/web/src/features/crm/route-adapter.test.tsx
index acf4fedcea..e60c8b9aea 100644
--- a/apps/web/src/features/crm/route-adapter.test.tsx
+++ b/apps/web/src/features/crm/route-adapter.test.tsx
@@ -11,8 +11,14 @@ import { paneRoute } from '@app/routes/app-route';
import {
appRoute,
companiesRoute,
+ crmItemRoute,
+ crmPipelineItemRoute,
+ crmPipelineRecordFileItemRoute,
+ crmPipelineRecordItemRoute,
crmPipelineRecordRoute,
crmPipelineRoute,
+ crmRecordFileItemRoute,
+ crmRecordItemRoute,
crmRecordRoute,
} from '@app/routes/routes';
import { cleanup, render, screen } from '@solidjs/testing-library';
@@ -38,9 +44,10 @@ vi.mock('@service-connection/websocket', () => ({
afterEach(cleanup);
let route: CrmRoute;
+let capture = vi.fn();
function Customers() {
- route = createCrmRoute();
+ route = createCrmRoute(capture);
return (
<>
<p data-testid="customers">
@@ -49,6 +56,7 @@ function Customers() {
.map((record) => `${record.type}:${record.id}:${record.name}`)
.join(',')}`}
</p>
+ <p data-testid="item">{route.item()?.name ?? '-'}</p>
<p data-testid="comment">{route.commentTarget()?.commentId ?? '-'}</p>
</>
);
@@ -63,8 +71,19 @@ const routes: SplitRoutes = {
...companiesRoute,
component: Customers,
children: [
- { ...crmPipelineRoute, children: [crmPipelineRecordRoute] },
+ {
+ ...crmPipelineRoute,
+ children: [
+ crmPipelineItemRoute,
+ crmPipelineRecordRoute,
+ crmPipelineRecordItemRoute,
+ crmPipelineRecordFileItemRoute,
+ ],
+ },
+ crmItemRoute,
crmRecordRoute,
+ crmRecordItemRoute,
+ crmRecordFileItemRoute,
],
},
],
@@ -74,6 +93,7 @@ const routes: SplitRoutes = {
};
function renderCustomers(url: string) {
+ capture = vi.fn();
const history = createMemoryHistory(url);
let router: SplitRouterInstance | undefined;
render(() => {
@@ -105,6 +125,7 @@ function renderCustomers(url: string) {
),
canGo: (delta: number) => router!.canGo(pane(), delta),
go: (delta: number) => router!.navigatePane(pane(), delta),
+ navigate: (path: string) => router!.navigatePane(pane(), path),
};
}
@@ -210,3 +231,324 @@ it('shows a linked Discussion message only on the record it was asked for', asyn
expect(screen.getByTestId('comment').textContent).toBe('-');
expect(url()).toBe('/companies/contact/maya');
});
+
+it('keeps an activity item in its source list across close and forward', async () => {
+ const { url, shows, canGo, go } = renderCustomers(
+ '/companies?s0.crm.tab=tasks'
+ );
+ await shows('tab:tasks section:- records:');
+ expect(
+ route.openItem({
+ type: 'document',
+ id: 'task-1',
+ name: 'Follow up',
+ fileType: 'md',
+ subType: { type: 'task' },
+ })
+ ).toBe(true);
+ await vi.waitFor(() =>
+ expect(screen.getByTestId('item').textContent).toBe('Follow up')
+ );
+ expect(url()).toBe('/companies/document/task-1/md/task?s0.crm.tab=tasks');
+ route.closeItem();
+ await vi.waitFor(() =>
+ expect(screen.getByTestId('item').textContent).toBe('-')
+ );
+ expect(url()).toBe('/companies?s0.crm.tab=tasks');
+ expect(canGo(-1)).toBe(false);
+ expect(canGo(1)).toBe(true);
+ await go(1);
+ await vi.waitFor(() =>
+ expect(screen.getByTestId('item').textContent).toBe('Follow up')
+ );
+});
+
+it('retains a record trail, Files section and pipeline source for a note', async () => {
+ const { url, shows, go } = renderCustomers('/companies/pipeline/sales');
+ await shows('tab:pipeline:sales section:- records:');
+ route.open([acme, maya]);
+ await shows(
+ 'tab:pipeline:sales section:- records:company:acme:Acme,contact:maya:Maya'
+ );
+ route.setSection('files');
+ await shows(
+ 'tab:pipeline:sales section:files records:company:acme:Acme,contact:maya:Maya'
+ );
+ route.openItem({
+ type: 'document',
+ id: 'note-1',
+ name: 'Note',
+ fileType: 'md',
+ });
+ await vi.waitFor(() =>
+ expect(screen.getByTestId('item').textContent).toBe('Note')
+ );
+ expect(url()).toBe(
+ '/companies/pipeline/sales/contact/maya/files/document/note-1/md'
+ );
+ await shows(
+ 'tab:pipeline:sales section:files records:company:acme:Acme,contact:maya:Maya'
+ );
+ route.closeItem();
+ await vi.waitFor(() =>
+ expect(screen.getByTestId('item').textContent).toBe('-')
+ );
+ expect(url()).toBe('/companies/pipeline/sales/contact/maya/files');
+ await go(1);
+ await vi.waitFor(() =>
+ expect(screen.getByTestId('item').textContent).toBe('Note')
+ );
+});
+
+it('opens a contact task at its compact URL and restores its trail on forward', async () => {
+ const { url, shows, canGo, go } = renderCustomers(
+ '/companies?s0.crm.tab=people'
+ );
+ await shows('tab:people section:- records:');
+ route.open([acme, maya]);
+ await shows(
+ 'tab:people section:- records:company:acme:Acme,contact:maya:Maya'
+ );
+ route.setSection('tasks');
+ await shows(
+ 'tab:people section:tasks records:company:acme:Acme,contact:maya:Maya'
+ );
+ expect(
+ route.openItem({
+ type: 'document',
+ id: 'task-1',
+ name: 'Follow up',
+ fileType: 'md',
+ subType: { type: 'task' },
+ })
+ ).toBe(true);
+ await vi.waitFor(() => expect(route.item()?.name).toBe('Follow up'));
+ expect(url()).toBe('/companies/contact/maya/tasks/task-1?s0.crm.tab=people');
+ expect(route.item()).toMatchObject({
+ itemType: 'document',
+ itemId: 'task-1',
+ itemFileType: 'md',
+ itemSubType: 'task',
+ });
+ route.closeItem();
+ await vi.waitFor(() => expect(route.item()).toBeUndefined());
+ expect(url()).toBe('/companies/contact/maya/tasks?s0.crm.tab=people');
+ expect(canGo(1)).toBe(true);
+ await go(1);
+ await vi.waitFor(() => expect(route.item()?.name).toBe('Follow up'));
+ await shows(
+ 'tab:people section:tasks records:company:acme:Acme,contact:maya:Maya'
+ );
+ expect(url()).toBe('/companies/contact/maya/tasks/task-1?s0.crm.tab=people');
+});
+
+it('opens a pipeline email at its compact URL and restores it after close', async () => {
+ const { url, shows, canGo, go } = renderCustomers(
+ '/companies/pipeline/sales'
+ );
+ route.open([acme]);
+ await shows('tab:pipeline:sales section:- records:company:acme:Acme');
+ route.setSection('emails');
+ await shows('tab:pipeline:sales section:emails records:company:acme:Acme');
+ expect(
+ route.openItem({
+ type: 'email',
+ id: 'thread-1',
+ name: 'Thread',
+ ownerId: 'owner',
+ isRead: true,
+ isDraft: false,
+ isImportant: false,
+ done: false,
+ })
+ ).toBe(true);
+ await vi.waitFor(() => expect(route.item()?.name).toBe('Thread'));
+ expect(url()).toBe('/companies/pipeline/sales/company/acme/emails/thread-1');
+ expect(route.item()).toMatchObject({ itemType: 'email', itemId: 'thread-1' });
+ route.closeItem();
+ await vi.waitFor(() => expect(route.item()).toBeUndefined());
+ expect(url()).toBe('/companies/pipeline/sales/company/acme/emails');
+ expect(canGo(1)).toBe(true);
+ await go(1);
+ await vi.waitFor(() => expect(route.item()?.name).toBe('Thread'));
+ expect(url()).toBe('/companies/pipeline/sales/company/acme/emails/thread-1');
+});
+
+it.each([
+ [
+ '/companies/contact/maya/databases/db-1',
+ 'contact',
+ 'maya',
+ 'databases',
+ 'database',
+ 'db-1',
+ '/companies/contact/maya/databases',
+ ],
+ [
+ '/companies/pipeline/sales/company/acme/calls/call-1',
+ 'company',
+ 'acme',
+ 'calls',
+ 'call',
+ 'call-1',
+ '/companies/pipeline/sales/company/acme/calls',
+ ],
+])(
+ 'reloads %s with inferred metadata and closes to its record section',
+ async (path, type, id, section, itemType, itemId, parent) => {
+ const { url, shows, canGo } = renderCustomers(path);
+ const tab = path.includes('/pipeline/') ? 'pipeline:sales' : 'active';
+ await shows(`tab:${tab} section:${section} records:${type}:${id}:`);
+ expect(route.item()).toMatchObject({ itemType, itemId });
+ route.closeItem();
+ await vi.waitFor(() => expect(route.item()).toBeUndefined());
+ expect(url()).toBe(parent);
+ expect(canGo(-1)).toBe(true);
+ }
+);
+
+it('keeps document metadata in Files and Notes URLs', async () => {
+ const { url, shows } = renderCustomers('/companies');
+ route.open([acme]);
+ await shows('tab:active section:- records:company:acme:Acme');
+ route.setSection('files');
+ await shows('tab:active section:files records:company:acme:Acme');
+ route.openItem({
+ type: 'document',
+ id: 'file-1',
+ name: 'File',
+ fileType: 'pdf',
+ });
+ await vi.waitFor(() => expect(route.item()?.name).toBe('File'));
+ expect(url()).toBe('/companies/company/acme/files/document/file-1/pdf');
+ route.closeItem();
+ await vi.waitFor(() => expect(route.item()).toBeUndefined());
+ route.setSection('overview');
+ await shows('tab:active section:- records:company:acme:Acme');
+ route.openItem({
+ type: 'document',
+ id: 'note-1',
+ name: 'Note',
+ fileType: 'md',
+ });
+ await vi.waitFor(() => expect(route.item()?.name).toBe('Note'));
+ expect(url()).toBe('/companies/company/acme/document/note-1/md');
+});
+
+it('skips consecutive items when restoring the captured record section', async () => {
+ const { url, shows, canGo, go } = renderCustomers(
+ '/companies/pipeline/sales'
+ );
+ route.open([acme, maya]);
+ await shows(
+ 'tab:pipeline:sales section:- records:company:acme:Acme,contact:maya:Maya'
+ );
+ route.setSection('files');
+ await shows(
+ 'tab:pipeline:sales section:files records:company:acme:Acme,contact:maya:Maya'
+ );
+ route.openItem({
+ type: 'document',
+ id: 'file-1',
+ name: 'File',
+ fileType: 'pdf',
+ });
+ await vi.waitFor(() => expect(route.item()?.itemId).toBe('file-1'));
+ route.openItem({
+ type: 'document',
+ id: 'note-1',
+ name: 'Note',
+ fileType: 'md',
+ });
+ await vi.waitFor(() => expect(route.item()?.itemId).toBe('note-1'));
+
+ route.closeItem();
+ await vi.waitFor(() => expect(route.item()).toBeUndefined());
+ expect(url()).toBe('/companies/pipeline/sales/contact/maya/files');
+ expect(route.records()).toEqual([acme, maya]);
+ expect(canGo(1)).toBe(true);
+ await go(1);
+ expect(route.item()).toMatchObject({ itemId: 'file-1', itemFileType: 'pdf' });
+ await go(1);
+ expect(route.item()).toMatchObject({ itemId: 'note-1', itemFileType: 'md' });
+});
+
+it.each([
+ [
+ '/companies/contact/maya/tasks',
+ '/companies/contact/maya/emails/thread-1',
+ '/companies/contact/maya/emails',
+ ],
+ [
+ '/companies/company/acme/emails',
+ '/companies/contact/maya/emails/thread-1',
+ '/companies/contact/maya/emails',
+ ],
+ [
+ '/companies/pipeline/first/contact/maya/emails',
+ '/companies/pipeline/second/contact/maya/emails/thread-1',
+ '/companies/pipeline/second/contact/maya/emails',
+ ],
+ [
+ '/companies?s0.crm.tab=notes',
+ '/companies/email/thread-1?s0.crm.tab=email',
+ '/companies?s0.crm.tab=email',
+ ],
+])(
+ 'does not restore an unrelated source entry at %s',
+ async (source, item, parent) => {
+ const { url, canGo, navigate } = renderCustomers(source);
+ await navigate(item);
+ await vi.waitFor(() => expect(route.item()?.itemId).toBe('thread-1'));
+ route.closeItem();
+ await vi.waitFor(() => expect(route.item()).toBeUndefined());
+ expect(url()).toBe(parent);
+ expect(canGo(1)).toBe(false);
+ }
+);
+
+it('closes a directly loaded item to its record section without a prior entry', async () => {
+ const { url, shows, canGo } = renderCustomers(
+ '/companies/company/acme/emails/thread-1'
+ );
+ await shows('tab:active section:emails records:company:acme:');
+ expect(route.item()?.itemId).toBe('thread-1');
+ route.closeItem();
+ await shows('tab:active section:emails records:company:acme:');
+ await vi.waitFor(() => expect(route.item()).toBeUndefined());
+ expect(url()).toBe('/companies/company/acme/emails');
+ expect(canGo(-1)).toBe(true);
+});
+
+it.each(['metaKey', 'ctrlKey', 'shiftKey', 'altKey'])(
+ 'leaves %s item opens to the split navigation handler',
+ async (modifier) => {
+ const { shows, canGo } = renderCustomers('/companies?s0.crm.tab=tasks');
+ await shows('tab:tasks section:- records:');
+ expect(
+ route.openItem(
+ { type: 'document', id: 'task-1', name: 'Follow up', fileType: 'md' },
+ new MouseEvent('click', { [modifier]: true })
+ )
+ ).toBe(false);
+ expect(route.item()).toBeUndefined();
+ expect(capture).not.toHaveBeenCalled();
+ expect(canGo(-1)).toBe(false);
+ }
+);
+
+it('returns to the activity list when its sidebar destination is selected again', async () => {
+ const { url, shows, canGo } = renderCustomers('/companies?s0.crm.tab=notes');
+ await shows('tab:notes section:- records:');
+ route.openItem({
+ type: 'document',
+ id: 'note-1',
+ name: 'Note',
+ fileType: 'md',
+ });
+ await vi.waitFor(() => expect(route.item()).toBeDefined());
+ route.close();
+ await vi.waitFor(() => expect(route.item()).toBeUndefined());
+ expect(url()).toBe('/companies?s0.crm.tab=notes');
+ expect(canGo(-1)).toBe(false);
+});
diff --git a/apps/web/src/features/crm/route-adapter.ts b/apps/web/src/features/crm/route-adapter.ts
index 85839a833a..6734a9142f 100644
--- a/apps/web/src/features/crm/route-adapter.ts
+++ b/apps/web/src/features/crm/route-adapter.ts
@@ -1,6 +1,7 @@
import {
createSearchParams,
type Entry,
+ routeParams,
useNavigate,
usePaneHistory,
useParams,
@@ -8,22 +9,53 @@ import {
} from '@app/lib/split-router';
import {
companiesRoute,
+ crmItemRoute,
+ crmPipelineItemRoute,
+ crmPipelineRecordFileItemRoute,
+ crmPipelineRecordItemRoute,
crmPipelineRecordRoute,
crmPipelineRoute,
+ crmRecordFileItemRoute,
+ crmRecordItemRoute,
crmRecordRoute,
} from '@app/routes/routes';
+import {
+ blockNameToDefaultFile,
+ fileTypeToBlockName,
+ fileTypeToResolvedBlockName,
+} from '@core/constant/allBlocks';
import { fireAndForget } from '@core/util/fireAndForget';
-import type { CrmRoute } from './context/workspace-context';
+import { Telemetry } from '@macro-inc/observability';
+import type {
+ CrmRecordNavigation,
+ CrmRoute,
+} from './context/workspace-context';
import { pipelineIdOfTab, pipelineTab } from './core/navigation';
import type { CrmRecordRef, CrmRecordSection } from './core/record';
import {
+ type CrmItemParams,
type CrmRecordParams,
+ crmItemBlockType,
crmRecordSearch,
crmSearch,
crmSearchCodec,
} from './crm-route';
-type CrmBranchParams = Partial<CrmRecordParams> & { pipelineId?: string };
+type CrmBranchParams = Partial<CrmRecordParams & CrmItemParams> & {
+ pipelineId?: string;
+};
+
+const CRM_ITEM_ROUTES = {
+ activity: { workspace: crmItemRoute, pipeline: crmPipelineItemRoute },
+ section: {
+ workspace: crmRecordItemRoute,
+ pipeline: crmPipelineRecordItemRoute,
+ },
+ files: {
+ workspace: crmRecordFileItemRoute,
+ pipeline: crmPipelineRecordFileItemRoute,
+ },
+};
/** The list tab an entry shows, or undefined for a record. */
function listTab(entry: Entry): string | undefined {
@@ -37,12 +69,40 @@ function listTab(entry: Entry): string | undefined {
.value.tab;
}
+function itemDestination(source: CrmBranchParams, item: CrmItemParams) {
+ let kind: keyof typeof CRM_ITEM_ROUTES = 'activity';
+ if (source.recordType && source.recordId) {
+ kind =
+ !source.section ||
+ source.section === 'overview' ||
+ source.section === 'files'
+ ? 'files'
+ : 'section';
+ }
+ const routes = CRM_ITEM_ROUTES[kind];
+ return {
+ route: source.pipelineId ? routes.pipeline : routes.workspace,
+ params: {
+ pipelineId: source.pipelineId,
+ recordType: source.recordType,
+ recordId: source.recordId,
+ section: source.section,
+ ...item,
+ },
+ };
+}
+
/** The Customers location held by the pane's route. */
-export function createCrmRoute(): CrmRoute {
+export function createCrmRoute(captureEntryState?: () => void): CrmRoute {
const [search] = createSearchParams(crmSearch);
const [recordSearch] = createSearchParams(crmRecordSearch);
const params = useParams<CrmBranchParams>();
const routeTrail = useRouteState(companiesRoute);
+ const itemStates = Object.values(CRM_ITEM_ROUTES).flatMap((routes) => [
+ useRouteState(routes.workspace),
+ useRouteState(routes.pipeline),
+ ]);
+ const itemState = () => itemStates.find((state) => state())?.();
const navigate = useNavigate();
const history = usePaneHistory();
@@ -57,7 +117,7 @@ export function createCrmRoute(): CrmRoute {
const records = (): readonly CrmRecordRef[] => {
const record = shown();
if (!record) return [];
- const trail = routeTrail();
+ const trail = itemState()?.trail ?? routeTrail();
const end = trail?.at(-1);
if (trail && end?.type === record.type && end.id === record.id)
return trail;
@@ -117,8 +177,104 @@ export function createCrmRoute(): CrmRoute {
);
};
+ const item = () => {
+ if (!params.itemType || !params.itemId) return;
+ const state = itemState();
+ const current = {
+ itemType: params.itemType,
+ itemId: params.itemId,
+ itemFileType: params.itemFileType,
+ itemSubType: params.itemSubType,
+ };
+ return {
+ ...current,
+ name:
+ state?.name ??
+ blockNameToDefaultFile(fileTypeToBlockName(crmItemBlockType(current))),
+ };
+ };
+
+ const openItem: CrmRecordNavigation['openItem'] = (entity, event) => {
+ if (
+ event &&
+ (event.metaKey ||
+ event.ctrlKey ||
+ event.shiftKey ||
+ event.altKey ||
+ (event instanceof MouseEvent && event.button !== 0))
+ )
+ return false;
+ if (
+ entity.type !== 'document' &&
+ entity.type !== 'email' &&
+ entity.type !== 'call' &&
+ entity.type !== 'database'
+ )
+ return false;
+ const itemParams: CrmItemParams = {
+ itemType: entity.type,
+ itemId: entity.id,
+ ...(entity.type === 'document'
+ ? {
+ itemFileType: fileTypeToResolvedBlockName(entity.fileType ?? 'md'),
+ itemSubType: entity.subType?.type,
+ }
+ : {}),
+ };
+ captureEntryState?.();
+ const trail = records();
+ const destination = itemDestination(params, itemParams);
+ fireAndForget(
+ Telemetry.span('crm.item.open', async (span) => {
+ span.setAttr('entity.id', entity.id);
+ span.setAttr('entity.type', entity.type);
+ await navigate(destination, {
+ state: {
+ trail: trail.length ? [...trail] : undefined,
+ name: entity.name,
+ },
+ });
+ }),
+ 'crm'
+ );
+ return true;
+ };
+
+ const restoreItemSource = () => {
+ const snapshot = history();
+ if (!snapshot) return false;
+ const currentRecord = shown();
+ for (let index = snapshot.index - 1; index >= 0; index--) {
+ const previous = snapshot.entries[index];
+ const matches = previous.location.route.matches;
+ if (!matches.some((match) => match.id === companiesRoute.id)) break;
+ const previousParams = routeParams<CrmBranchParams>(
+ previous.location.route
+ );
+ if (previousParams.itemId) continue;
+ const sameSource = currentRecord
+ ? previousParams.recordId === currentRecord.id &&
+ previousParams.recordType === currentRecord.type &&
+ previousParams.section === params.section &&
+ (!params.pipelineId ||
+ previousParams.pipelineId === params.pipelineId)
+ : listTab(previous) === tab();
+ if (!sameSource) break;
+ fireAndForget(navigate(index - snapshot.index), 'crm');
+ return true;
+ }
+ return false;
+ };
+
+ const closeItem = () => {
+ if (!item() || restoreItemSource()) return;
+ const trail = records();
+ if (trail.length) showRecord(trail, params.section);
+ else showList(tab());
+ };
+
const close = () => {
- if (!shown()) return;
+ if (!shown()) return closeItem();
const current = tab();
// The list's own entry restores its scroll position.
const snapshot = history();
@@ -148,6 +304,9 @@ export function createCrmRoute(): CrmRoute {
: undefined,
open: (trail) => showRecord(trail, undefined),
setSection: (section) => showRecord(records(), section),
+ item,
+ openItem,
+ closeItem,
close,
};
}
diff --git a/apps/web/src/features/crm/route-views.test.tsx b/apps/web/src/features/crm/route-views.test.tsx
index f944c2916a..30259d619a 100644
--- a/apps/web/src/features/crm/route-views.test.tsx
+++ b/apps/web/src/features/crm/route-views.test.tsx
@@ -18,6 +18,9 @@ vi.mock('@components/app/split-layout/split-router/app-route-shell', () => ({
vi.mock('@components/app/split-layout/view-restoration', () => ({
useViewRestoration: () => {},
}));
+vi.mock('@components/app/split-layout/layoutUtils', () => ({
+ useSplitPanel: () => ({ handle: { captureEntryState: vi.fn() } }),
+}));
vi.mock('@core/constant/featureFlags', () => ({
enableCrm: 'crm',
isFeatureEnabled: () => true,
diff --git a/apps/web/src/features/crm/route-views.tsx b/apps/web/src/features/crm/route-views.tsx
index 06927b42b8..c464d9e1c7 100644
--- a/apps/web/src/features/crm/route-views.tsx
+++ b/apps/web/src/features/crm/route-views.tsx
@@ -1,3 +1,4 @@
+import { useSplitPanel } from '@components/app/split-layout/layoutUtils';
import {
RedirectSplit,
usePageViewTracking,
@@ -24,7 +25,8 @@ export const CompaniesRouteView = withAuth(() => {
return <RedirectSplit to={{ type: 'component', id: 'home' }} />;
useViewRestoration();
usePageViewTracking('companies');
- const route = createCrmRoute();
+ const panel = useSplitPanel();
+ const route = createCrmRoute(() => panel?.handle.captureEntryState());
const crmView = new URLSearchParams(window.location.search).get(
CRM_VIEW_URL_PARAM
);
diff --git a/apps/web/src/features/crm/views/crm-workspace.test.tsx b/apps/web/src/features/crm/views/crm-workspace.test.tsx
index b2e3aeb54f..aa0743fcd1 100644
--- a/apps/web/src/features/crm/views/crm-workspace.test.tsx
+++ b/apps/web/src/features/crm/views/crm-workspace.test.tsx
@@ -193,6 +193,7 @@ vi.mock('../components/pipeline-dialog', () => ({
vi.mock('./activity', () => ({
CrmActivityView: (props: { tab: string }) => <div>{props.tab} feed</div>,
}));
+vi.mock('./item-detail', () => ({ CrmItemDetail: () => null }));
vi.mock('./record-detail', () => ({
CrmRecordDetail: (props: {
viewName: string;
@@ -294,6 +295,9 @@ function setup(
records,
section: () => undefined,
commentTarget: () => undefined,
+ item: () => undefined,
+ openItem: vi.fn(),
+ closeItem: vi.fn(),
open: vi.fn(setRecords),
setSection: vi.fn(),
close: vi.fn(() => setRecords([])),
diff --git a/apps/web/src/features/crm/views/crm-workspace.tsx b/apps/web/src/features/crm/views/crm-workspace.tsx
index 037bc5e524..5d3e0e761e 100644
--- a/apps/web/src/features/crm/views/crm-workspace.tsx
+++ b/apps/web/src/features/crm/views/crm-workspace.tsx
@@ -75,6 +75,7 @@ import { useApplyCrmView } from './apply-view';
import { Crm as CrmSettings } from './crm-settings';
import { CrmExport } from './export-companies';
import { CrmImport } from './import-companies';
+import { CrmItemDetail } from './item-detail';
import { PipelineView } from './pipeline';
import { CrmRecordDetail } from './record-detail';
import { CompanyDisplayMenu, CompanyViewsMenu } from './saved-views-menu';
@@ -287,7 +288,12 @@ export function CrmWorkspaceView(props: {
const settings = view.host.settings;
const { openWithSplit } = useCrmContext().createNavigation();
const records = view.host.record.records;
- const recordOpen = () => records().length > 0;
+ const itemKey = () => {
+ const item = view.host.record.item();
+ return item ? `${item.itemType}:${item.itemId}` : undefined;
+ };
+ const itemOpen = () => !!itemKey();
+ const recordOpen = () => records().length > 0 && !itemOpen();
const showRecord = (record: CrmRecordRef) => {
// The list unmounts; its entry keeps the scroll position for the return.
view.host.captureEntryState();
@@ -594,7 +600,7 @@ export function CrmWorkspaceView(props: {
</>
}
>
- <Show when={isTouchDevice() && !recordOpen()}>
+ <Show when={isTouchDevice() && !recordOpen() && !itemOpen()}>
<ViewShell.Header>
<CrmMobileTabs
active={activeRecord()}
@@ -622,6 +628,16 @@ export function CrmWorkspaceView(props: {
</Suspense>
</Show>
</Show>
+ <Show when={itemKey()} keyed>
+ <CrmItemDetail
+ sourceName={activePipeline()?.name ?? title()}
+ navigation={
+ <NavigationToggle onExpand={() => setCollapsed(false)}>
+ <Suspense>{sidebar()}</Suspense>
+ </NavigationToggle>
+ }
+ />
+ </Show>
<Show when={recordOpen()}>
<CrmRecordDetail
records={records()}
@@ -639,7 +655,7 @@ export function CrmWorkspaceView(props: {
}
/>
</Show>
- <Show when={!recordOpen() && pipelineId()} keyed>
+ <Show when={!recordOpen() && !itemOpen() && pipelineId()} keyed>
{(id) => (
<Show when={activePipeline()}>
{(pipeline) => (
@@ -669,7 +685,11 @@ export function CrmWorkspaceView(props: {
</Show>
)}
</Show>
- <Show when={!recordOpen() && pipelineId() && !activePipeline()}>
+ <Show
+ when={
+ !recordOpen() && !itemOpen() && pipelineId() && !activePipeline()
+ }
+ >
<Show
when={!pipelines.loading()}
fallback={<CrmListSkeleton label="Loading pipeline" />}
@@ -687,10 +707,19 @@ export function CrmWorkspaceView(props: {
</Button>
</Show>
</Show>
- <Show when={!recordOpen() && !pipelineId() && activityPending()}>
+ <Show
+ when={
+ !recordOpen() && !itemOpen() && !pipelineId() && activityPending()
+ }
+ >
<CrmListSkeleton label="Loading CRM activity" />
</Show>
- <Show when={!recordOpen() && !pipelineId() && activityTab()} keyed>
+ <Show
+ when={
+ !recordOpen() && !itemOpen() && !pipelineId() && activityTab()
+ }
+ keyed
+ >
{(tab) => (
<Suspense
fallback={<CrmListSkeleton label="Loading CRM activity" />}
@@ -714,6 +743,7 @@ export function CrmWorkspaceView(props: {
<Show
when={
!recordOpen() &&
+ !itemOpen() &&
!pipelineId() &&
!activityTab() &&
!activityPending()
diff --git a/apps/web/src/features/crm/views/item-detail.tsx b/apps/web/src/features/crm/views/item-detail.tsx
new file mode 100644
index 0000000000..e935a58401
--- /dev/null
+++ b/apps/web/src/features/crm/views/item-detail.tsx
@@ -0,0 +1,259 @@
+import {
+ EntityDetail,
+ entityDetailBlockType,
+} from '@app/components/entity-detail/EntityDetail';
+import { EntityDetailBreadcrumbSkeleton } from '@app/components/entity-detail/EntityDetailBreadcrumbSkeleton';
+import type { EntityDetailTarget } from '@app/components/entity-detail/entity-detail-target';
+import { ViewBreadcrumbs, ViewShell } from '@app/components/view-shell';
+import { FileDetailBreadcrumbItem } from '@app/features/drive-view/views/FileDetailBreadcrumbItem';
+import { MarkdownDetail } from '@app/features/drive-view/views/MarkdownDetail';
+import { MarkdownDetailBreadcrumbItem } from '@block-md/component/MarkdownDetailBreadcrumbItem';
+import { SidePanel } from '@components/app/side-panel';
+import { useSplitPanelOrThrow } from '@components/app/split-layout/layoutUtils';
+import { EntityIcon } from '@core/component/EntityIcon';
+import { ShareTrigger } from '@core/component/TopBar/ShareButton';
+import { useDocumentShareModal } from '@core/component/TopBar/shareModal';
+import { For, type JSX, onCleanup, Show } from 'solid-js';
+import { useCrmContext } from '../context/crm-context';
+import { useCrmWorkspace } from '../context/workspace-context';
+import { createRecordName } from './record-detail';
+
+type DocumentTarget = Extract<EntityDetailTarget, { type: 'document' }>;
+
+/** A linked item retains the Customers shell and its route-owned source trail. */
+export function CrmItemDetail(props: {
+ sourceName: string;
+ navigation: JSX.Element;
+}) {
+ const route = useCrmWorkspace().host.record;
+ const panel = useSplitPanelOrThrow();
+ const item = () => route.item()!;
+ const records = route.records;
+ const value = () => `item:${item().itemType}:${item().itemId}`;
+ const target = (): EntityDetailTarget => {
+ const current = item();
+ if (current.itemType === 'document') {
+ return {
+ type: 'document',
+ id: current.itemId,
+ fileType: current.itemFileType ?? 'md',
+ ...(current.itemSubType
+ ? { subType: { type: current.itemSubType } }
+ : {}),
+ fallbackName: current.name,
+ };
+ }
+ return {
+ type: current.itemType,
+ id: current.itemId,
+ fallbackName: current.name,
+ };
+ };
+ const document = () => {
+ const current = target();
+ return current.type === 'document' ? current : undefined;
+ };
+ const nativeDocument = () => {
+ const current = document();
+ const blockType = current && entityDetailBlockType(current);
+ return current && blockType && blockType !== 'spreadsheet'
+ ? { target: current, blockType }
+ : undefined;
+ };
+ const openShare = useDocumentShareModal(() => {
+ const current = nativeDocument();
+ if (!current) return;
+ return { documentId: current.target.id, blockAlias: current.blockType };
+ });
+ onCleanup(useCrmContext().registerTaskComposerRecord(() => records().at(-1)));
+
+ return (
+ <ViewBreadcrumbs.Root
+ value={value()}
+ onChange={(next) => {
+ if (next === 'crm-view')
+ return records().length ? route.close() : route.closeItem();
+ const index = records().findIndex(
+ (record) => `${record.type}:${record.id}` === next
+ );
+ if (index === -1) return;
+ if (index === records().length - 1) return route.closeItem();
+ route.open(records().slice(0, index + 1));
+ }}
+ >
+ <ViewBreadcrumbs.Item
+ value="crm-view"
+ metadata={{ type: 'companies' }}
+ order={0}
+ >
+ {(crumb) => (
+ <ViewBreadcrumbs.ReturnButton onClick={crumb.onSelect}>
+ {props.sourceName}
+ </ViewBreadcrumbs.ReturnButton>
+ )}
+ </ViewBreadcrumbs.Item>
+ <For each={records()}>
+ {(record, index) => {
+ const name = createRecordName(record);
+ return (
+ <ViewBreadcrumbs.Item
+ value={`${record.type}:${record.id}`}
+ metadata={{ type: record.type, id: record.id }}
+ order={index() + 1}
+ >
+ {(crumb) => (
+ <ViewBreadcrumbs.Button
+ class="gap-1.5"
+ isActive={crumb.isActive()}
+ onClick={crumb.onSelect}
+ tooltip={name()}
+ >
+ <EntityIcon
+ targetType={
+ record.type === 'company' ? 'crm_company' : 'contact'
+ }
+ size="xs"
+ class="shrink-0"
+ />
+ <span class="truncate">{name()}</span>
+ </ViewBreadcrumbs.Button>
+ )}
+ </ViewBreadcrumbs.Item>
+ );
+ }}
+ </For>
+ <SidePanel.Root floating>
+ <div class="flex size-full min-h-0 min-w-0 flex-col overflow-hidden">
+ <Show when={nativeDocument()}>
+ {(current) => (
+ <ViewShell.TopBar class="touch:flex">
+ {props.navigation}
+ <ViewBreadcrumbs.Outlet
+ aria-label="CRM item location"
+ fallback={<EntityDetailBreadcrumbSkeleton />}
+ />
+ <div class="ml-auto flex shrink-0 items-center gap-1">
+ <SidePanel.HeaderActionsOutlet />
+ <ShareTrigger
+ onClick={openShare}
+ id={current().target.id}
+ blockType={current().blockType}
+ hotkeyScope={panel.splitHotkeyScope}
+ />
+ <SidePanel.Toggle />
+ </div>
+ </ViewShell.TopBar>
+ )}
+ </Show>
+ <div class="relative min-h-0 min-w-0 flex-1">
+ {/* Preview headers own the live item title and menu after this source prefix. */}
+ <Show
+ when={document()}
+ fallback={
+ <EntityDetail
+ target={target()}
+ previewHeaderLeading={
+ <>
+ {props.navigation}
+ <ViewBreadcrumbs.Outlet
+ aria-label="CRM item location"
+ class="max-w-[min(40vw,24rem)] overflow-hidden"
+ />
+ </>
+ }
+ />
+ }
+ >
+ {(current) => (
+ <CrmDocumentDetail
+ target={current()}
+ value={value()}
+ order={records().length + 1}
+ headerLeading={
+ <>
+ {props.navigation}
+ <ViewBreadcrumbs.Outlet aria-label="CRM item location" />
+ </>
+ }
+ />
+ )}
+ </Show>
+ </div>
+ </div>
+ </SidePanel.Root>
+ </ViewBreadcrumbs.Root>
+ );
+}
+
+function CrmDocumentDetail(props: {
+ target: DocumentTarget;
+ value: string;
+ order: number;
+ headerLeading: JSX.Element;
+}) {
+ const route = useCrmWorkspace().host.record;
+ const markdown = () => {
+ const blockType = entityDetailBlockType(props.target);
+ return blockType === 'md' ||
+ blockType === 'task' ||
+ blockType === 'snippet' ||
+ blockType === 'skill'
+ ? props.target
+ : undefined;
+ };
+ const duplicate = (id: string, name: string) =>
+ route.openItem({ ...props.target, name, id });
+ return (
+ <Show
+ when={markdown()}
+ fallback={
+ <EntityDetail
+ target={props.target}
+ previewHeaderLeading={props.headerLeading}
+ >
+ {(context) => {
+ if (context.type !== 'document') return null;
+ return (
+ <FileDetailBreadcrumbItem
+ value={props.value}
+ metadata={props.target}
+ order={props.order}
+ documentMetadata={context.documentMetadata}
+ userAccessLevel={context.userAccessLevel}
+ blockType={entityDetailBlockType(props.target)!}
+ download={context.download}
+ operations={context.operations}
+ fallbackName={props.target.fallbackName}
+ onClose={route.closeItem}
+ onDuplicate={duplicate}
+ />
+ );
+ }}
+ </EntityDetail>
+ }
+ >
+ {(current) => (
+ <MarkdownDetail
+ documentId={current().id}
+ kind={current().subType?.type ?? 'document'}
+ fallbackName={current().fallbackName}
+ >
+ {(context) => (
+ <MarkdownDetailBreadcrumbItem
+ value={props.value}
+ metadata={props.target}
+ order={props.order}
+ documentId={current().id}
+ kind={current().subType?.type ?? 'document'}
+ fallbackName={current().fallbackName}
+ ownerId={context.documentMetadata.owner}
+ projectId={context.documentMetadata.projectId ?? undefined}
+ onClose={route.closeItem}
+ onDuplicate={duplicate}
+ />
+ )}
+ </MarkdownDetail>
+ )}
+ </Show>
+ );
+}
diff --git a/apps/web/src/features/crm/views/record-detail.tsx b/apps/web/src/features/crm/views/record-detail.tsx
index bbb6d8c1d9..953d0465dc 100644
--- a/apps/web/src/features/crm/views/record-detail.tsx
+++ b/apps/web/src/features/crm/views/record-detail.tsx
@@ -43,7 +43,7 @@ import { useCompanyQuery, useContactQuery } from './use-crm';
const recordKey = (record: CrmRecordRef) => `${record.type}:${record.id}`;
-function createRecordName(record: CrmRecordRef): () => string {
+export function createRecordName(record: CrmRecordRef): () => string {
const fallback =
record.name || (record.type === 'company' ? 'Company' : 'Contact');
if (record.type === 'company') {
diff --git a/apps/web/src/features/crm/views/record-item-list.tsx b/apps/web/src/features/crm/views/record-item-list.tsx
index 3054761e5f..e68e58a781 100644
--- a/apps/web/src/features/crm/views/record-item-list.tsx
+++ b/apps/web/src/features/crm/views/record-item-list.tsx
@@ -27,6 +27,7 @@ import {
} from '../components/list-state';
import { useCrmContext } from '../context/crm-context';
import type { ItemListSource } from '../context/crm-sources';
+import { useOptionalCrmWorkspace } from '../context/workspace-context';
import { recordItemMatchesSearch } from '../core/record-search';
/**
@@ -54,6 +55,7 @@ export function RecordItemList(props: {
dateField?: 'updated_at' | 'created_at' | 'viewed_at';
}) {
const { openEntity } = useCrmContext().createNavigation();
+ const workspace = useOptionalCrmWorkspace();
// Reading `data` before the first page resolves would suspend the tab.
const items = () =>
props.source.isPending ? [] : (props.source.data?.entities ?? []);
@@ -215,7 +217,10 @@ export function RecordItemList(props: {
entity={entity}
hideCheckbox
timestamp={entity.updatedAt}
- onClick={() => openEntity(entity)}
+ onClick={(event) => {
+ if (!workspace?.host.record.openItem(entity, event))
+ openEntity(entity);
+ }}
referencePropertyIds={props.referencePropertyIds}
/>
</>
diff --git a/apps/web/src/features/crm/workspace-adapter.tsx b/apps/web/src/features/crm/workspace-adapter.tsx
index 5d6dcf1166..cbaab8f4e9 100644
--- a/apps/web/src/features/crm/workspace-adapter.tsx
+++ b/apps/web/src/features/crm/workspace-adapter.tsx
@@ -119,7 +119,9 @@ export function createCrmWorkspace(
return tab !== VIEW_TAB_PRESETS.companies.default ? tab : undefined;
});
// A record link names its list; nothing may move it off the record.
- const initialRecordOpen = untrack(() => route.records().length > 0);
+ const initialRecordOpen = untrack(
+ () => route.records().length > 0 || !!route.item()
+ );
const initialTabPreset =
initialUrlTab && initialUrlTab in VIEW_TAB_PRESETS.companies.tabs
? getViewPreset('companies', initialUrlTab)
diff --git a/apps/web/src/routes/app-router-view.tsx b/apps/web/src/routes/app-router-view.tsx
index bb6f0a3c81..70a7e0515c 100644
--- a/apps/web/src/routes/app-router-view.tsx
+++ b/apps/web/src/routes/app-router-view.tsx
@@ -101,8 +101,14 @@ import {
channelsSplitRoute,
codersRoute,
companiesRoute,
+ crmItemRoute,
+ crmPipelineItemRoute,
+ crmPipelineRecordFileItemRoute,
+ crmPipelineRecordItemRoute,
crmPipelineRecordRoute,
crmPipelineRoute,
+ crmRecordFileItemRoute,
+ crmRecordItemRoute,
crmRecordRoute,
debugRoutes,
driveCallRoute,
@@ -428,9 +434,15 @@ export function AppRouterView() {
<Route definition={callDetailRoute} component={CallDetailRouteView} />
<Route definition={companiesRoute} component={CompaniesRouteView}>
<Route definition={crmPipelineRoute}>
+ <Route definition={crmPipelineItemRoute} />
<Route definition={crmPipelineRecordRoute} />
+ <Route definition={crmPipelineRecordItemRoute} />
+ <Route definition={crmPipelineRecordFileItemRoute} />
</Route>
+ <Route definition={crmItemRoute} />
<Route definition={crmRecordRoute} />
+ <Route definition={crmRecordItemRoute} />
+ <Route definition={crmRecordFileItemRoute} />
</Route>
<Route definition={foldersRoute} component={FoldersRouteView} />
<Route definition={searchRoute} component={SearchRouteView} />
diff --git a/apps/web/src/routes/routes.ts b/apps/web/src/routes/routes.ts
index 7e9378749a..b5cfcb7728 100644
--- a/apps/web/src/routes/routes.ts
+++ b/apps/web/src/routes/routes.ts
@@ -11,9 +11,14 @@ import { CALENDAR_VIEW_ID } from '@app/features/calendar-view/types';
import { changesSearch } from '@app/features/changes/changes-search';
import { mobileSearchRouteStateSchema } from '@app/features/command/mobile/mobile-search-route-state';
import {
+ crmItemBlockType,
+ crmItemParams,
+ crmItemStateSchema,
crmPipelineParams,
crmPipelineReference,
crmRecordClaim,
+ crmRecordFileItemParams,
+ crmRecordItemParams,
crmRecordParams,
crmRecordReference,
crmRecordTrailSchema,
@@ -675,6 +680,50 @@ export const crmPipelineRecordRoute = defineRoute({
toReference: crmRecordReference,
});
+/** An item opened from a Customers activity view or record section. */
+export const crmItemRoute = defineRoute({
+ id: 'companies-item',
+ path: ':itemType/:itemId/:itemFileType?/:itemSubType?',
+ params: crmItemParams,
+ state: crmItemStateSchema,
+ claim: (params) => ({
+ namespace: 'block',
+ id: `${driveDocumentBlockType(crmItemBlockType(params))}:${params.itemId}`,
+ }),
+ toReference: (params) =>
+ uuidRouteReference(params.itemId, crmItemBlockType(params)),
+});
+
+export const crmPipelineItemRoute = defineRoute({
+ ...crmItemRoute,
+ id: 'companies-pipeline-item',
+});
+
+/** A typed record section already identifies the selected item's renderer. */
+export const crmRecordItemRoute = defineRoute({
+ ...crmItemRoute,
+ id: 'companies-record-item',
+ path: ':recordType/:recordId/:section/:itemId',
+ params: crmRecordItemParams,
+});
+
+export const crmPipelineRecordItemRoute = defineRoute({
+ ...crmRecordItemRoute,
+ id: 'companies-pipeline-record-item',
+});
+
+export const crmRecordFileItemRoute = defineRoute({
+ ...crmItemRoute,
+ id: 'companies-record-file-item',
+ path: ':recordType/:recordId/:section?/:itemType/:itemId/:itemFileType?/:itemSubType?',
+ params: crmRecordFileItemParams,
+});
+
+export const crmPipelineRecordFileItemRoute = defineRoute({
+ ...crmRecordFileItemRoute,
+ id: 'companies-pipeline-record-file-item',
+});
+
export const crmPipelineRoute = defineRoute({
id: 'companies-pipeline',
path: 'pipeline/:pipelineId',
diff --git a/docs/agent-guide/crm.md b/docs/agent-guide/crm.md
index 6085dc632a..88bdd7a544 100644
--- a/docs/agent-guide/crm.md
+++ b/docs/agent-guide/crm.md
@@ -178,8 +178,8 @@ Customers too: `/app/company/<uuid>` and `/app/contact/<uuid>` links (which
**Copy link** still copies), `@` mentions, search and Command-K results,
favorites, and CRM discussion notifications. A contact opens under People, so its
breadcrumb returns to People. A split already showing that record is brought
-forward instead. Touch devices keep the standalone pages, and a
-Customers record URL opened on touch redirects to its standalone page.
+forward instead. Touch devices keep the standalone record pages; a Customers
+record URL redirects there unless it opens a linked item inside Customers.
Each record opened from the details appends a breadcrumb and a history entry: a
contact from a company's Team tab gives `Companies > <company> > <contact>`, and
a person's Company link gives `People > <contact> > <company>`. Opening a record
@@ -284,10 +284,24 @@ Files also includes attachments of emails with its address. Tasks created from a
contact also reference its company. The side panel keeps Sharing (admins only)
and adds References.
-In a company or contact's Tasks tab, clicking a task (or pressing Enter on its
-focused row) opens the task detail view at `/app/tasks/<task-id>`, including on
-mobile. Shift-click opens it in a separate split. Verify that the task's status
-and properties appear, rather than the regular Drive markdown editor.
+In workspace activity and a company or contact's embedded sections, clicking a
+Task, Email, Note, Call, or Database opens its authorized detail inside Customers.
+The CRM sidebar stays in place and the breadcrumb shows the source view, record
+trail (when present), and selected item, without section labels such as Tasks or
+Files or an extra separator before preview titles. The current record breadcrumb
+returns to the captured section and entry state. The item URL is nested under
+`/app/companies` or `/app/companies/pipeline/<uuid>`. Typed record sections use
+`/<record-type>/<record-id>/<tasks-emails-calls-or-databases>/<item-id>`, without
+repeating the item type or a task's `md/task` suffix. Redundant typed URLs for
+these sections do not resolve. Workspace activity retains
+`/<item-type>/<item-id>` and document metadata. Record Files and overview notes
+retain document metadata on routes restricted to those sections.
+Back and Forward restore the item and source; selecting the source breadcrumb or
+closing the item returns to the source list or record with its entry state.
+Reload keeps the selected item's URL. Shift-click uses the existing separate
+split behavior; modified row clicks keep the existing split behavior. On touch,
+the existing header and breadcrumb conventions apply without a new navigation UI.
+Verify that tasks display their status and properties, not the Drive editor.
Verify the real CRM routes separately with accessible and inaccessible databases,
multiple matching rows per database, empty matches, and a second page of results.
diff --git a/docs/agent-guide/navigation.md b/docs/agent-guide/navigation.md
index b7bd7c0add..9abbe4ac90 100644
--- a/docs/agent-guide/navigation.md
+++ b/docs/agent-guide/navigation.md
@@ -206,8 +206,9 @@ successfully rather than hashing the empty JavaScript placeholder.
| `/app/agents/chat/<uuid>` | Legacy AI chat opened in the Agents workspace (`/app/agent-chats/<uuid>` remains a compatibility alias) |
| `/app/calls` | Calls list |
| `/app/companies` | Customers (CRM; needs a team). The selected list is `sN.crm.tab` |
-| `/app/companies/<company-or-contact>/<uuid>` | Customers with a company or contact opened inline, keeping its list's `sN.crm.tab`; a record tab other than Overview adds `/<team-emails-files-tasks-or-calls>`. On desktop, `/app/company/<uuid>` and `/app/contact/<uuid>` redirect here, a `comment_id` moving to `sN.crm-record.commentId`; touch devices keep those standalone pages |
+| `/app/companies/<company-or-contact>/<uuid>` | Customers with a company or contact opened inline, keeping its list's `sN.crm.tab`; a record tab other than Overview adds `/<team-emails-files-tasks-calls-or-databases>`. On desktop, `/app/company/<uuid>` and `/app/contact/<uuid>` redirect here, a `comment_id` moving to `sN.crm-record.commentId`; touch devices keep those standalone pages |
| `/app/companies/pipeline/<uuid>` | Customers on a pipeline; `/<company-or-contact>/<uuid>` after it opens a record from the pipeline. `/app/pipeline/<uuid>` redirects here |
+| `/app/companies/<company-or-contact>/<uuid>/<tasks-emails-calls-or-databases>/<item-id>` | Customers with the selected item inline; the section determines its type, with no redundant typed URL fallback. The same suffix works under a pipeline; workspace activity and record Files/overview notes retain type metadata |
| `/app/activity` | Activity heatmap + feed |
| `/app/calendar/<month-or-week-or-day>` | Calendar; the focused event, its occurrence, and the locator range use `sN.calendar.*` |
| `/app/calendar` | Redirects to `/app/calendar/<month-or-week-or-day>` at the remembered period (Day on phones and Week on desktop by default), keeping an `eventId` |