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): keep Home's open calendar on a calendar row (#8656)

gbirmanbe431c524904
diff --git a/apps/web/src/features/home/home-calendar-preview.test.ts b/apps/web/src/features/home/home-calendar-preview.test.ts
index 132c05bd34..39b9365278 100644
--- a/apps/web/src/features/home/home-calendar-preview.test.ts
+++ b/apps/web/src/features/home/home-calendar-preview.test.ts
@@ -6,12 +6,13 @@ const mocks = vi.hoisted(() => ({
navigate: vi.fn(async () => {}),
openCalendarView: vi.fn(),
calendarSplit: undefined as object | undefined,
+ homeCalendarParams: {} as { period?: string },
}));
vi.mock('@app/lib/split-router', async (importOriginal) => ({
...(await importOriginal<object>()),
useNavigate: () => mocks.navigate,
- useRouteParams: () => ({}),
+ useRouteParams: () => mocks.homeCalendarParams,
createSearchParams: () => [{}],
}));
vi.mock('@app/routes/routes', () => ({ homeCalendarRoute: 'home-calendar' }));
@@ -55,6 +56,7 @@ function openFromHome(options?: { activate?: boolean }) {
afterEach(() => {
vi.clearAllMocks();
mocks.calendarSplit = undefined;
+ mocks.homeCalendarParams = {};
});
describe('Home calendar preview', () => {
@@ -77,6 +79,16 @@ describe('Home calendar preview', () => {
expect(mocks.navigate).not.toHaveBeenCalled();
});
+ it("keeps the event in Home's own calendar while it is open beside a Calendar split", () => {
+ mocks.calendarSplit = {};
+ mocks.homeCalendarParams = { period: 'week' };
+
+ expect(openFromHome({ activate: true })).toBe(true);
+
+ expect(mocks.navigate).toHaveBeenCalledOnce();
+ expect(mocks.openCalendarView).not.toHaveBeenCalled();
+ });
+
it('retargets the open Calendar without focusing it while browsing the list', () => {
mocks.calendarSplit = {};
diff --git a/apps/web/src/features/home/home-calendar-preview.ts b/apps/web/src/features/home/home-calendar-preview.ts
index 894da1b6d1..85517e8603 100644
--- a/apps/web/src/features/home/home-calendar-preview.ts
+++ b/apps/web/src/features/home/home-calendar-preview.ts
@@ -20,6 +20,7 @@ import {
isFeatureEnabled,
} from '@core/constant/featureFlags';
import { fireAndForget } from '@core/util/fireAndForget';
+import { Telemetry } from '@macro-inc/observability';
import deepEqual from 'fast-deep-equal';
import { createSignal } from 'solid-js';
import { homeCalendarNavigation } from './home-preview-navigation';
@@ -44,35 +45,51 @@ export function useHomeCalendarPreview(withTab: WithTab) {
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',
- });
+ const span = Telemetry.span('calendar.open_from_home');
+ try {
+ if (calendarTarget.eventId) {
+ span.setAttr('calendar.event_id', calendarTarget.eventId);
+ }
+ // Home's own calendar keeps the event while it is open, as Home's preview
+ // does for a document it already shows. Otherwise a Calendar already open
+ // in another split takes it, as it does from the notifications panel,
+ // instead of a second calendar in Home.
+ if (
+ !calendarOpen() &&
+ globalSplitManager()?.getSplitByContent('component', CALENDAR_VIEW_ID)
+ ) {
+ openCalendarView(calendarTarget, {
+ activate: options.activate ?? false,
+ referredFrom: 'home',
+ });
+ span.setAttr('calendar.destination', 'calendar_split');
+ return true;
+ }
+ const alreadyOpen =
+ calendarOpen() &&
+ calendarParams.period === navigation.params.period &&
+ deepEqual(
+ calendarTargetSearch(calendarTarget),
+ calendarTargetSearch(calendarSearchTarget(openCalendarSearch))
+ );
+ // The same URL still needs to refocus the event in the inline calendar.
+ if (alreadyOpen) {
+ setCalendarRefocus((count) => count + 1);
+ span.setAttr('calendar.destination', 'home_refocus');
+ } else {
+ fireAndForget(
+ navigate(
+ { route: homeCalendarRoute, params: navigation.params },
+ { search: withTab(navigation.search) }
+ ),
+ 'home-view'
+ );
+ span.setAttr('calendar.destination', 'home_calendar');
+ }
return true;
+ } finally {
+ span.end();
}
- const alreadyOpen =
- calendarOpen() &&
- calendarParams.period === navigation.params.period &&
- deepEqual(
- calendarTargetSearch(calendarTarget),
- calendarTargetSearch(calendarSearchTarget(openCalendarSearch))
- );
- // The same URL still needs to refocus the event in the inline calendar.
- if (alreadyOpen) setCalendarRefocus((count) => count + 1);
- else
- fireAndForget(
- navigate(
- { route: homeCalendarRoute, params: navigation.params },
- { search: withTab(navigation.search) }
- ),
- 'home-view'
- );
- return true;
};
return { calendarOpen, calendarRefocus, openCalendarEvent };
diff --git a/docs/agent-guide/navigation.md b/docs/agent-guide/navigation.md
index c00be1e236..81a678a45f 100644
--- a/docs/agent-guide/navigation.md
+++ b/docs/agent-guide/navigation.md
@@ -177,10 +177,13 @@ 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.
+While Home's own calendar is open, a Home calendar row (a reminder, a join
+request, or any event) re-aims it in place, even when Calendar is also open in
+another split, as Home's preview does for a document it already shows. When
+Home shows its list or another item and Calendar is open in another split, the
+row 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