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(calendar): open a calendar notification in the calendar split that is already open (#8640)

gbirman2383d797577b
diff --git a/apps/web/src/features/calendar-view/calendar-navigation.test.ts b/apps/web/src/features/calendar-view/calendar-navigation.test.ts
index 28425c1b38..c0d61ab000 100644
--- a/apps/web/src/features/calendar-view/calendar-navigation.test.ts
+++ b/apps/web/src/features/calendar-view/calendar-navigation.test.ts
@@ -67,6 +67,20 @@ describe('Calendar view navigation', () => {
expect(manager.openWithSplit).not.toHaveBeenCalled();
});
+ it('retargets an existing Calendar without taking focus when asked not to', () => {
+ const replace = vi.fn();
+ const activate = vi.fn();
+ const manager = {
+ getSplitByContent: vi.fn(() => ({ replace, activate })),
+ openWithSplit: vi.fn(),
+ } as unknown as SplitManager;
+
+ openCalendarView({ eventId: 'event-4' }, { manager, activate: false });
+
+ expect(replace).toHaveBeenCalledOnce();
+ expect(activate).not.toHaveBeenCalled();
+ });
+
it('opens the Calendar route when no instance exists', () => {
const manager = {
getSplitByContent: vi.fn(),
diff --git a/apps/web/src/features/calendar-view/calendar-navigation.ts b/apps/web/src/features/calendar-view/calendar-navigation.ts
index a0ecff1881..63a5a22fb6 100644
--- a/apps/web/src/features/calendar-view/calendar-navigation.ts
+++ b/apps/web/src/features/calendar-view/calendar-navigation.ts
@@ -69,6 +69,8 @@ export function openCalendarView(
mergeHistory?: boolean;
referredFrom?: ReferredFrom;
onApplied?: VoidFunction;
+ /** False retargets an open Calendar split without taking focus from the caller. */
+ activate?: boolean;
} = {}
): void {
const manager = options.manager ?? globalSplitManager();
@@ -95,13 +97,13 @@ export function openCalendarView(
mergeHistory: options.mergeHistory ?? true,
referredFrom: options.referredFrom,
});
- existing.activate();
+ if (options.activate !== false) existing.activate();
reportApplied();
return;
}
const result = manager.openWithSplit(content, {
- activate: true,
+ activate: options.activate !== false,
referredFrom: options.referredFrom ?? null,
preferNewSplit: options.openInNewSplit,
handle: options.handle,
diff --git a/apps/web/src/features/home/components/HomeList.tsx b/apps/web/src/features/home/components/HomeList.tsx
index 7fedec9a5f..c7700d8eda 100644
--- a/apps/web/src/features/home/components/HomeList.tsx
+++ b/apps/web/src/features/home/components/HomeList.tsx
@@ -91,7 +91,10 @@ type HomeListActivationMetadata = {
type HomeListProps = {
hasPreview: boolean;
- onPreviewEntityChange: (entity: PreviewSelection | undefined) => void;
+ onPreviewEntityChange: (
+ entity: PreviewSelection | undefined,
+ options?: { activate?: boolean }
+ ) => void;
onPreviewActivate?: () => void;
};
@@ -168,7 +171,7 @@ export function HomeList(props: HomeListProps) {
if (!isTouchDevice() && !newSplit) {
markEntitySeen(sourceRow.entity);
- showPreview(sourceRow.entity);
+ showPreview(sourceRow.entity, { activate: true });
props.onPreviewActivate?.();
return;
}
@@ -189,9 +192,13 @@ export function HomeList(props: HomeListProps) {
}
}
- function showPreview(entity: WithNotification<EntityData>) {
+ function showPreview(
+ entity: WithNotification<EntityData>,
+ options?: { activate?: boolean }
+ ) {
props.onPreviewEntityChange(
- entity?.type === 'initiative' ? undefined : entity
+ entity?.type === 'initiative' ? undefined : entity,
+ options
);
}
diff --git a/apps/web/src/features/home/home-calendar-preview.test.ts b/apps/web/src/features/home/home-calendar-preview.test.ts
new file mode 100644
index 0000000000..132c05bd34
--- /dev/null
+++ b/apps/web/src/features/home/home-calendar-preview.test.ts
@@ -0,0 +1,91 @@
+import { createRoot } from 'solid-js';
+import { afterEach, describe, expect, it, vi } from 'vitest';
+import { useHomeCalendarPreview } from './home-calendar-preview';
+
+const mocks = vi.hoisted(() => ({
+ navigate: vi.fn(async () => {}),
+ openCalendarView: vi.fn(),
+ calendarSplit: undefined as object | undefined,
+}));
+
+vi.mock('@app/lib/split-router', async (importOriginal) => ({
+ ...(await importOriginal<object>()),
+ useNavigate: () => mocks.navigate,
+ useRouteParams: () => ({}),
+ createSearchParams: () => [{}],
+}));
+vi.mock('@app/routes/routes', () => ({ homeCalendarRoute: 'home-calendar' }));
+vi.mock('@app/signal/splitLayout', () => ({
+ globalSplitManager: () => ({
+ getSplitByContent: (type: string, id: string) =>
+ type === 'component' && id === 'calendar'
+ ? mocks.calendarSplit
+ : undefined,
+ }),
+}));
+vi.mock('@app/features/calendar-view/calendar-navigation', () => ({
+ openCalendarView: mocks.openCalendarView,
+}));
+vi.mock('@core/constant/featureFlags', async (importOriginal) => ({
+ ...(await importOriginal<object>()),
+ isFeatureEnabled: () => true,
+}));
+vi.mock('@components/app/previewTarget', () => ({
+ previewCalendarTarget: (entity: { id: string; occurrenceKey?: string }) => ({
+ eventId: entity.id,
+ occurrenceKey: entity.occurrenceKey,
+ }),
+}));
+
+const event = {
+ type: 'calendar_event',
+ id: 'event-1',
+ occurrenceKey: '2026-10-24T18:00:00Z',
+} as never;
+
+function openFromHome(options?: { activate?: boolean }) {
+ return createRoot((dispose) => {
+ const preview = useHomeCalendarPreview((search) => search);
+ const opened = preview.openCalendarEvent(event, options);
+ dispose();
+ return opened;
+ });
+}
+
+afterEach(() => {
+ vi.clearAllMocks();
+ mocks.calendarSplit = undefined;
+});
+
+describe('Home calendar preview', () => {
+ it('opens the event inside Home when no Calendar split is open', () => {
+ expect(openFromHome({ activate: true })).toBe(true);
+
+ expect(mocks.navigate).toHaveBeenCalledOnce();
+ expect(mocks.openCalendarView).not.toHaveBeenCalled();
+ });
+
+ it('retargets and focuses a Calendar already open in another split on a click', () => {
+ mocks.calendarSplit = {};
+
+ expect(openFromHome({ activate: true })).toBe(true);
+
+ expect(mocks.openCalendarView).toHaveBeenCalledWith(
+ { eventId: 'event-1', occurrenceKey: '2026-10-24T18:00:00Z' },
+ { activate: true, referredFrom: 'home' }
+ );
+ expect(mocks.navigate).not.toHaveBeenCalled();
+ });
+
+ it('retargets the open Calendar without focusing it while browsing the list', () => {
+ mocks.calendarSplit = {};
+
+ expect(openFromHome()).toBe(true);
+
+ expect(mocks.openCalendarView).toHaveBeenCalledWith(
+ { eventId: 'event-1', occurrenceKey: '2026-10-24T18:00:00Z' },
+ { activate: false, referredFrom: 'home' }
+ );
+ expect(mocks.navigate).not.toHaveBeenCalled();
+ });
+});
diff --git a/apps/web/src/features/home/home-calendar-preview.ts b/apps/web/src/features/home/home-calendar-preview.ts
index 90b2f53152..894da1b6d1 100644
--- a/apps/web/src/features/home/home-calendar-preview.ts
+++ b/apps/web/src/features/home/home-calendar-preview.ts
@@ -1,8 +1,10 @@
+import { openCalendarView } from '@app/features/calendar-view/calendar-navigation';
import {
calendarSearch,
calendarSearchTarget,
calendarTargetSearch,
} from '@app/features/calendar-view/calendar-url';
+import { CALENDAR_VIEW_ID } from '@app/features/calendar-view/types';
import type { CalendarPreviewSelection } from '@app/features/next-soup/utils';
import {
createSearchParams,
@@ -11,6 +13,7 @@ import {
useRouteParams,
} from '@app/lib/split-router';
import { homeCalendarRoute } from '@app/routes/routes';
+import { globalSplitManager } from '@app/signal/splitLayout';
import { previewCalendarTarget } from '@components/app/previewTarget';
import {
enableCalendarUi,
@@ -33,11 +36,25 @@ export function useHomeCalendarPreview(withTab: WithTab) {
const [calendarRefocus, setCalendarRefocus] = createSignal(0);
const calendarOpen = () => typeof calendarParams.period === 'string';
- const openCalendarEvent = (entity: CalendarPreviewSelection) => {
+ const openCalendarEvent = (
+ entity: CalendarPreviewSelection,
+ options: { activate?: boolean } = {}
+ ) => {
if (!isFeatureEnabled(enableCalendarUi)) return false;
const calendarTarget = previewCalendarTarget(entity);
const navigation = homeCalendarNavigation(calendarTarget);
if (!navigation) return false;
+ // A Calendar already open in another split takes the event, as it does
+ // from the notifications panel, instead of a second calendar in Home.
+ if (
+ globalSplitManager()?.getSplitByContent('component', CALENDAR_VIEW_ID)
+ ) {
+ openCalendarView(calendarTarget, {
+ activate: options.activate ?? false,
+ referredFrom: 'home',
+ });
+ return true;
+ }
const alreadyOpen =
calendarOpen() &&
calendarParams.period === navigation.params.period &&
diff --git a/apps/web/src/features/home/home-view-context.tsx b/apps/web/src/features/home/home-view-context.tsx
index 577568a1bb..bd8171875c 100644
--- a/apps/web/src/features/home/home-view-context.tsx
+++ b/apps/web/src/features/home/home-view-context.tsx
@@ -72,7 +72,10 @@ export type HomeViewContext = {
calendarOpen: Accessor<boolean>;
/** Bumped when the open calendar event is requested again, to re-aim in place. */
calendarRefocus: Accessor<number>;
- openPreview: (entity: PreviewSelection) => boolean;
+ openPreview: (
+ entity: PreviewSelection,
+ options?: { activate?: boolean }
+ ) => boolean;
closePreview: () => void;
setTab: (tab: HomeTab) => void;
setFacets: (facets: FacetSelection) => void;
@@ -179,8 +182,13 @@ export const [HomeViewProvider, useHomeView] = createAssertedContextProvider<
};
const [previewNavigationRequest, setPreviewNavigationRequest] =
createSignal(0);
- const openPreview = (entity: PreviewSelection) => {
- if (entity.type === 'calendar_event') return openCalendarEvent(entity);
+ const openPreview = (
+ entity: PreviewSelection,
+ options?: { activate?: boolean }
+ ) => {
+ if (entity.type === 'calendar_event') {
+ return openCalendarEvent(entity, options);
+ }
return openPreviewTarget(previewBlockTarget(entity));
};
const openPreviewTarget = (target: PreviewBlockTarget) => {
diff --git a/apps/web/src/features/home/home-view.tsx b/apps/web/src/features/home/home-view.tsx
index 548c390cf9..fa50dbebf6 100644
--- a/apps/web/src/features/home/home-view.tsx
+++ b/apps/web/src/features/home/home-view.tsx
@@ -50,7 +50,10 @@ function HomeFallback() {
function HomeListPane(props: {
hasPreview: boolean;
- onPreviewEntityChange: (entity: PreviewSelection | undefined) => void;
+ onPreviewEntityChange: (
+ entity: PreviewSelection | undefined,
+ options?: { activate?: boolean }
+ ) => void;
onNewChat: () => void;
}) {
const shell = useViewShell();
@@ -89,8 +92,11 @@ function HomeViewRoot() {
useHomeView();
const newChat = closePreview;
- const onPreviewEntityChange = (entity: PreviewSelection | undefined) => {
- if (entity) openPreview(entity);
+ const onPreviewEntityChange = (
+ entity: PreviewSelection | undefined,
+ options?: { activate?: boolean }
+ ) => {
+ if (entity) openPreview(entity, options);
else closePreview();
};
diff --git a/docs/agent-guide/navigation.md b/docs/agent-guide/navigation.md
index 3ab059dc8b..8db7d06ad8 100644
--- a/docs/agent-guide/navigation.md
+++ b/docs/agent-guide/navigation.md
@@ -177,6 +177,10 @@ reminder routes and the former Home reminder detail route are removed.
When an event opens inline from Home, changing the Calendar period stays under
`/app/home/calendar/`, updates the period segment, and re-focuses that event.
Back/Forward restores the period and its event locator from `sN.calendar.*`.
+When Calendar is already open in another split, a Home calendar row (a reminder,
+a join request, or any event) retargets that split instead: a click or Enter
+also focuses it, and arrow-key browsing moves it without taking focus from the
+list. Shift-click keeps reusing that split, as the notifications panel does.
Home uses the shared channel and file details for channel conversations and
supported documents, with a **Home** breadcrumb that returns to the list. A