Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
fix(calendar): open a bare calendar path at the preferred period (#8946)
teo17b84d5abf20
diff --git a/apps/web/src/components/app/split-layout/split-router/legacy-route.test.ts b/apps/web/src/components/app/split-layout/split-router/legacy-route.test.tsindex 24e143cfda..d1fbbb60f8 100644--- a/apps/web/src/components/app/split-layout/split-router/legacy-route.test.ts+++ b/apps/web/src/components/app/split-layout/split-router/legacy-route.test.ts@@ -1,11 +1,26 @@-import { createRoutesManifest, type SplitRoutes } from '@app/lib/split-router';+import { CALENDAR_PREFERENCES_KEY } from '@app/features/calendar/calendar-preferences';+import {+ createMemoryPaneStore,+ createRoutesManifest,+ createSolidRouterHistory,+ createSplitRouter,+ parseLocation,+ type SplitRoutes,+} from '@app/lib/split-router';+import { createFakeSolidRouter } from '@app/lib/split-router/tests/fake-solid-router';+import { createTestPolicy } from '@app/lib/split-router/tests/fixtures';import {appRoute,+ baseRoute,+ calendarSplitRoute,+ homeCalendarRoute,homeSplitRoute,legacyContentRoute,notFoundRoute,} from '@app/routes/routes';-import { describe, expect, it, vi } from 'vitest';+import { createRoot } from 'solid-js';+import { afterEach, describe, expect, it, vi } from 'vitest';+import { createAppSplitRouterMiddleware } from './app-middleware';import { resolveContentLocation, upgradeLegacyPath } from './legacy-route';vi.mock('@components/app/split-layout/componentRegistry', () => ({@@ -22,15 +37,57 @@ vi.mock('@service-connection/websocket', () => ({createConnectionWebsocketEffect: vi.fn(),}));-const routes = createRoutesManifest({+const definitions = {definitions: [+ baseRoute,{...appRoute,- children: [homeSplitRoute, legacyContentRoute, notFoundRoute],+ children: [+ { ...homeSplitRoute, children: [homeCalendarRoute] },+ calendarSplitRoute,+ legacyContentRoute,+ notFoundRoute,+ ],},],- defaultRoute: () => ({ matches: [{ id: 'view-home', params: {} }] }),-} satisfies SplitRoutes);+ defaultRoute: () => ({ matches: [{ id: baseRoute.id, params: {} }] }),+} satisfies SplitRoutes;+const routes = createRoutesManifest(definitions);++let cleanup: (() => void) | undefined;++function openApp(url: string) {+ const solid = createFakeSolidRouter(url);+ return createRoot((dispose) => {+ const router = createSplitRouter({+ routes: definitions,+ history: (manifest) =>+ createSolidRouterHistory({+ location: solid.location,+ navigate: solid.navigate,+ base: '/app',+ transformPath: (path) => upgradeLegacyPath(manifest, path),+ }),+ paneStore: createMemoryPaneStore(),+ policy: createTestPolicy().policy,+ middleware: createAppSplitRouterMiddleware({+ isTouchDevice: () => false,+ }),+ });+ cleanup = () => {+ router.dispose();+ dispose();+ };+ return { solid, router };+ });+}++afterEach(() => {+ cleanup?.();+ cleanup = undefined;+ localStorage.clear();+ vi.useRealTimers();+});describe('upgradeLegacyPath', () => {it('sends the retired Getting Started path to Home', () => {@@ -38,6 +95,41 @@ describe('upgradeLegacyPath', () => {});});+describe('opening an app URL', () => {+ it('opens a bare Calendar path at the preferred period with its event', async () => {+ vi.useFakeTimers();+ localStorage.setItem(+ CALENDAR_PREFERENCES_KEY,+ JSON.stringify({ periodView: 'dayGridMonth' })+ );+ const { solid, router } = openApp('/app/calendar?eventId=event-1');+ await router.settled();+ vi.runAllTimers();++ expect(parseLocation(solid.landed()).path).toBe('/app/calendar/month');+ const entry = router.entry(router.panes()[0]!);+ expect(entry?.location.route.matches.at(-1)).toEqual({+ id: calendarSplitRoute.id,+ params: { period: 'dayGridMonth' },+ });+ expect(entry?.location.search).toEqual({+ calendar: { eventId: ['event-1'] },+ });+ });++ it.each(['/app/calendar/week', '/app/home/calendar/day'])(+ 'keeps %s',+ async (url) => {+ vi.useFakeTimers();+ const { solid, router } = openApp(url);+ await router.settled();+ vi.runAllTimers();++ expect(solid.landed()).toBe(url);+ }+ );+});+describe('resolveContentLocation', () => {it.each(['company', 'contact'] as const)('keeps the Discussion message a %s opens at',diff --git a/apps/web/src/components/app/split-layout/split-router/legacy-route.ts b/apps/web/src/components/app/split-layout/split-router/legacy-route.tsindex 40d80ab2a4..eebee42691 100644--- a/apps/web/src/components/app/split-layout/split-router/legacy-route.ts+++ b/apps/web/src/components/app/split-layout/split-router/legacy-route.ts@@ -142,6 +142,17 @@ export function handleLegacySplitPath(return [{ route: paneRoute({ id: 'view-home', params: {} }) }];}+ if (segments.length === 1 && segments[0] === 'calendar') {+ return [+ {+ route: paneRoute({+ id: CALENDAR_ROUTE_ID,+ params: { period: getPreferredCalendarPeriodView() },+ }),+ },+ ];+ }+if (context.matchedRouteId &&context.matchedRouteId !== 'settings' &&diff --git a/docs/agent-guide/navigation.md b/docs/agent-guide/navigation.mdindex 9e9f9f6278..1658e833fb 100644--- a/docs/agent-guide/navigation.md+++ b/docs/agent-guide/navigation.md@@ -172,6 +172,7 @@ successfully rather than hashing the empty JavaScript placeholder.| `/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/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` || `/app/scheduling` | Scheduling workspace: booking links, availability, bookings, insights, and booking page || `/app/external` | External: link a personal WhatsApp account and adopt independently shared WhatsApp groups (requires the `enable-whatsapp-linked` flag; see [External](external.md)) || `/app/<document-type>/<uuid>` | Legacy document URL (including `md`, `pdf`, `canvas`, `spreadsheet`, and the other Drive document types); redirects to `/app/drive/<document-type>/<uuid>` |