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(notifications-inbox): open calendar events beside the list (#9879)

teofad1bb97c5fc
diff --git a/apps/web/src/features/notifications-inbox/components/notifications-breadcrumb.tsx b/apps/web/src/features/notifications-inbox/components/notifications-breadcrumb.tsx
new file mode 100644
index 0000000000..2d1f58a009
--- /dev/null
+++ b/apps/web/src/features/notifications-inbox/components/notifications-breadcrumb.tsx
@@ -0,0 +1,20 @@
+import { ViewBreadcrumbs } from '@app/components/view-shell';
+import { t } from '@app/lib/i18n';
+
+/** The way back from what the content area shows to the notifications list. */
+export function NotificationsBreadcrumb(props: { onReturn: () => void }) {
+ return (
+ <nav
+ aria-label={t('notificationsInbox.location')}
+ class="flex items-center gap-0.5"
+ >
+ <ViewBreadcrumbs.ReturnButton
+ data-allow-focus-in-preview
+ onClick={props.onReturn}
+ >
+ {t('nav.notifications')}
+ </ViewBreadcrumbs.ReturnButton>
+ <ViewBreadcrumbs.Separator />
+ </nav>
+ );
+}
diff --git a/apps/web/src/features/notifications-inbox/context/notifications-calendar-context.ts b/apps/web/src/features/notifications-inbox/context/notifications-calendar-context.ts
new file mode 100644
index 0000000000..bc0b99476b
--- /dev/null
+++ b/apps/web/src/features/notifications-inbox/context/notifications-calendar-context.ts
@@ -0,0 +1,21 @@
+import { type Accessor, createContext, useContext } from 'solid-js';
+
+/** What the inline Calendar in the content area needs from the view. */
+export type NotificationsCalendarPaneContext = {
+ /** Bumped when the open event is chosen again, to re-aim at it in place. */
+ refocus: Accessor<number>;
+ /** Close the Calendar and return to the notifications list. */
+ onReturn: () => void;
+};
+
+const Context = createContext<NotificationsCalendarPaneContext>();
+
+export const NotificationsCalendarPaneProvider = Context.Provider;
+
+export function useNotificationsCalendarPane(): NotificationsCalendarPaneContext {
+ const context = useContext(Context);
+ if (!context) {
+ throw new Error('NotificationsCalendarPaneProvider is required');
+ }
+ return context;
+}
diff --git a/apps/web/src/features/notifications-inbox/notifications-calendar-preview.ts b/apps/web/src/features/notifications-inbox/notifications-calendar-preview.ts
new file mode 100644
index 0000000000..033135dc81
--- /dev/null
+++ b/apps/web/src/features/notifications-inbox/notifications-calendar-preview.ts
@@ -0,0 +1,98 @@
+import { getPreferredCalendarPeriodView } from '@app/features/calendar/calendar-preferences';
+import {
+ CALENDAR_SEARCH_NAMESPACE,
+ calendarSearch,
+ calendarSearchCodec,
+ calendarSearchTarget,
+ calendarTargetSearch,
+} from '@app/features/calendar-view/calendar-url';
+import type { CalendarPreviewSelection } from '@app/features/next-soup/utils';
+import {
+ createSearchParams,
+ useNavigate,
+ useRouteParams,
+} from '@app/lib/split-router';
+import {
+ notificationsCalendarRoute,
+ notificationsRoute,
+} from '@app/routes/routes';
+import { previewCalendarTarget } from '@components/app/previewTarget';
+import {
+ enableCalendarUi,
+ 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';
+
+/**
+ * Shows calendar events in the Notifications view's content area: the
+ * Calendar view under the view's own calendar route, aimed at the event.
+ * Choosing the shown event again re-aims at it in place.
+ */
+export function useNotificationsCalendarPreview() {
+ const navigate = useNavigate();
+ const params = useRouteParams(notificationsCalendarRoute);
+ const [openSearch] = createSearchParams(calendarSearch);
+ const [refocus, setRefocus] = createSignal(0);
+ const isOpen = () => typeof params.period === 'string';
+
+ /** Aim the inline Calendar at the event; false when it can't show it. */
+ const open = (entity: CalendarPreviewSelection) => {
+ if (!isFeatureEnabled(enableCalendarUi)) return false;
+ const target = previewCalendarTarget(entity);
+ if (!target.eventId) return false;
+ const span = Telemetry.span('calendar.open_from_notifications');
+ try {
+ span.setAttr('calendar.event_id', target.eventId);
+ const search = calendarTargetSearch(target);
+ const shown =
+ isOpen() &&
+ deepEqual(
+ search,
+ calendarTargetSearch(calendarSearchTarget(openSearch))
+ );
+ if (shown) {
+ setRefocus((count) => count + 1);
+ span.setAttr('calendar.destination', 'refocus');
+ return true;
+ }
+ fireAndForget(
+ navigate(
+ {
+ route: notificationsCalendarRoute,
+ params: {
+ period: params.period ?? getPreferredCalendarPeriodView(),
+ },
+ },
+ {
+ search: {
+ [CALENDAR_SEARCH_NAMESPACE]:
+ calendarSearchCodec.serialize(search),
+ },
+ }
+ ),
+ 'notifications-inbox'
+ );
+ span.setAttr('calendar.destination', 'inline');
+ return true;
+ } finally {
+ span.end();
+ }
+ };
+
+ /** Leave the inline Calendar, when it is open. */
+ const close = () => {
+ if (!isOpen()) return;
+ fireAndForget(
+ navigate(
+ { route: notificationsRoute, params: {} },
+ { search: { [CALENDAR_SEARCH_NAMESPACE]: undefined } }
+ ),
+ 'notifications-inbox'
+ );
+ };
+
+ return { open, close, refocus };
+}
diff --git a/apps/web/src/features/notifications-inbox/notifications-inbox.tsx b/apps/web/src/features/notifications-inbox/notifications-inbox.tsx
index 0e6bc4b182..c8b23d3c96 100644
--- a/apps/web/src/features/notifications-inbox/notifications-inbox.tsx
+++ b/apps/web/src/features/notifications-inbox/notifications-inbox.tsx
@@ -22,6 +22,7 @@ import {
type NotificationsInboxContext,
NotificationsInboxProvider,
} from './context/notifications-inbox-context';
+import { useNotificationsCalendarPreview } from './notifications-calendar-preview';
import { openNotificationInSplit } from './open-notification-in-split';
import { createNotificationInboxSource } from './queries/notification-inbox-source';
import { resolveAccessRequest } from './queries/row-actions';
@@ -84,6 +85,7 @@ export function NotificationsInbox() {
const userId = useUserId();
const { openSettings } = useSettingsState();
const respondToJoinRequest = useRespondToCalendarJoinRequestMutation();
+ const calendarPreview = useNotificationsCalendarPreview();
const answerJoinRequest: NotificationsInboxContext['requests']['answerJoinRequest'] =
async (request, accept) => {
await respondToJoinRequest.mutateAsync({
@@ -99,6 +101,7 @@ export function NotificationsInbox() {
>
<NotificationsView
onOpenSettings={() => openSettings('Notifications')}
+ calendarPreview={calendarPreview}
onOpen={(row, { newSplit, notification }) =>
openNotificationInSplit(row, {
newSplit,
diff --git a/apps/web/src/features/notifications-inbox/route-views.tsx b/apps/web/src/features/notifications-inbox/route-views.tsx
index 7c34d0111b..d4ec53519c 100644
--- a/apps/web/src/features/notifications-inbox/route-views.tsx
+++ b/apps/web/src/features/notifications-inbox/route-views.tsx
@@ -11,6 +11,16 @@ const NotificationsInbox = lazy(async () => ({
default: (await import('./notifications-inbox')).NotificationsInbox,
}));
+const NotificationsCalendarPane = lazy(async () => ({
+ default: (await import('./views/notifications-calendar-pane'))
+ .NotificationsCalendarPane,
+}));
+
+/** A calendar notification's event, in the view's content area. */
+export function NotificationsCalendarRouteView() {
+ return <NotificationsCalendarPane />;
+}
+
function TrackedNotificationsInbox() {
usePageViewTracking('notifications');
return <NotificationsInbox />;
diff --git a/apps/web/src/features/notifications-inbox/views/notifications-calendar-pane.tsx b/apps/web/src/features/notifications-inbox/views/notifications-calendar-pane.tsx
new file mode 100644
index 0000000000..88116ab09e
--- /dev/null
+++ b/apps/web/src/features/notifications-inbox/views/notifications-calendar-pane.tsx
@@ -0,0 +1,47 @@
+import { calendarSearch } from '@app/features/calendar-view/calendar-url';
+import { createSearchParams } from '@app/lib/split-router';
+import { notificationsCalendarRoute } from '@app/routes/routes';
+import { PreviewFrame } from '@components/app/PreviewPanel';
+import { useSplitPanelOrThrow } from '@components/app/split-layout/layoutUtils';
+import { isTouchDevice } from '@core/mobile/isTouchDevice';
+import { lazyNamed } from '@core/util/lazyNamed';
+import { Show } from 'solid-js';
+import { NotificationsBreadcrumb } from '../components/notifications-breadcrumb';
+import { useNotificationsCalendarPane } from '../context/notifications-calendar-context';
+
+// The calendar grid (FullCalendar) only loads once a calendar notification opens.
+const CalendarView = lazyNamed(
+ () => import('@app/features/calendar-view/calendar-view'),
+ 'CalendarView'
+);
+
+/**
+ * The Calendar view aimed at a notification's event, in the notifications
+ * view's content area, as other notifications show there.
+ */
+export function NotificationsCalendarPane() {
+ const panel = useSplitPanelOrThrow();
+ const calendar = useNotificationsCalendarPane();
+ const [search] = createSearchParams(calendarSearch);
+
+ return (
+ <div class="flex size-full min-h-0">
+ <PreviewFrame
+ splitPanelContext={panel}
+ headerLeading={<NotificationsBreadcrumb onReturn={calendar.onReturn} />}
+ hideHeader={!isTouchDevice()}
+ locationKey={() => `${search.eventId}:${search.occurrenceKey}`}
+ >
+ <CalendarView
+ route={notificationsCalendarRoute}
+ refocus={calendar.refocus}
+ headerLeading={
+ <Show when={!isTouchDevice()}>
+ <NotificationsBreadcrumb onReturn={calendar.onReturn} />
+ </Show>
+ }
+ />
+ </PreviewFrame>
+ </div>
+ );
+}
diff --git a/apps/web/src/features/notifications-inbox/views/notifications-view.tsx b/apps/web/src/features/notifications-inbox/views/notifications-view.tsx
index ac5da1c7d3..ad1fb876ee 100644
--- a/apps/web/src/features/notifications-inbox/views/notifications-view.tsx
+++ b/apps/web/src/features/notifications-inbox/views/notifications-view.tsx
@@ -6,12 +6,13 @@ import {
import {
useViewControlHotkeys,
useViewTabHotkeys,
- ViewBreadcrumbs,
ViewShell,
ViewSidebar,
} from '@app/components/view-shell';
import { ListSkeleton } from '@app/components/view-shell/ListSkeleton';
+import type { CalendarPreviewSelection } from '@app/features/next-soup/utils';
import { t } from '@app/lib/i18n';
+import { SplitRouter } from '@app/lib/split-router';
import { createPreviewSelectionGuard } from '@components/app/createPreviewSelectionGuard';
import { useGlobalBlockOrchestrator } from '@components/app/GlobalAppState';
import { MobileTopEdgeFade } from '@components/app/mobile/MobileEdgeFade';
@@ -44,6 +45,7 @@ import { createElementSize } from '@solid-primitives/resize-observer';
import { debounce } from '@solid-primitives/scheduled';
import { Button, EmptyStatePanel } from '@ui';
import {
+ type Accessor,
createComputed,
createEffect,
createMemo,
@@ -70,7 +72,9 @@ import {
} from '../components/inbox-status-tabs';
import { NotificationRow } from '../components/notification-row';
import { NotificationStackItem } from '../components/notification-stack-item';
+import { NotificationsBreadcrumb } from '../components/notifications-breadcrumb';
import { RowActionButtons } from '../components/row-action-buttons';
+import { NotificationsCalendarPaneProvider } from '../context/notifications-calendar-context';
import {
type NotificationInboxRow,
useNotificationsInboxContext,
@@ -110,6 +114,15 @@ export type NotificationsViewProps = {
) => void;
/** Open the settings that decide which notifications are delivered. */
onOpenSettings: () => void;
+ /** Calendar events show in the content area through the view's calendar route. */
+ calendarPreview: {
+ /** Show the event in the content area; false when it can't be shown there. */
+ open: (entity: CalendarPreviewSelection) => boolean;
+ /** Leave the calendar, when it is shown. */
+ close: () => void;
+ /** Bumped when the shown event is chosen again. */
+ refocus: Accessor<number>;
+ };
};
/** Distance from the end of the list, in pixels, that loads the next page. */
@@ -133,8 +146,8 @@ const decisionFailure = (decision: InboxDecision) =>
.exhaustive();
/**
- * What the preview pane can show inline; calendar events and projects open
- * in their own views instead.
+ * What the preview pane can show inline; calendar events show through the
+ * view's calendar route, and projects open in their own view.
*/
const previewSelection = (
entity: EntityData
@@ -143,6 +156,30 @@ const previewSelection = (
? undefined
: entity;
+/** The entity a row, or one of its notifications, is about. */
+const entityOf = (
+ row: NotificationInboxRow,
+ notification?: UnifiedNotification
+) => (notification ? row.content.entityAt(notification) : row.content.entity);
+
+/**
+ * A calendar event row as the Calendar reads it: its notifications, such as
+ * a reminder naming the occurrence, behind an accessor.
+ */
+const calendarSelection = (
+ entity: ReturnType<typeof entityOf>
+): CalendarPreviewSelection | undefined => {
+ if (entity.type !== 'calendar_event') return undefined;
+ const { notifications } = entity;
+ return {
+ ...entity,
+ notifications:
+ typeof notifications === 'function'
+ ? notifications
+ : () => notifications ?? [],
+ };
+};
+
/**
* What the preview shows for a row or one of its notifications; undefined when
* it has no inline preview. An agent's notification opens at its turn, and a
@@ -152,9 +189,7 @@ const previewTargetFor = (
row: NotificationInboxRow,
notification?: UnifiedNotification
) => {
- const entity = previewSelection(
- notification ? row.content.entityAt(notification) : row.content.entity
- );
+ const entity = previewSelection(entityOf(row, notification));
if (!entity) return undefined;
const target = previewBlockTarget(entity);
const params =
@@ -163,23 +198,6 @@ const previewTargetFor = (
return params ? { ...target, params } : target;
};
-function NotificationsBreadcrumb(props: { onReturn: () => void }) {
- return (
- <nav
- aria-label={t('notificationsInbox.location')}
- class="flex items-center gap-0.5"
- >
- <ViewBreadcrumbs.ReturnButton
- data-allow-focus-in-preview
- onClick={props.onReturn}
- >
- {t('nav.notifications')}
- </ViewBreadcrumbs.ReturnButton>
- <ViewBreadcrumbs.Separator />
- </nav>
- );
-}
-
function ListHeader(props: { actions: JSX.Element }) {
return (
<header class="flex shrink-0 flex-col">
@@ -315,23 +333,42 @@ export function NotificationsView(props: NotificationsViewProps) {
};
/**
- * Show a row in the preview, at one of its notifications when one is named,
- * or open it when it has no inline preview.
+ * Show a row in the preview, at one of its notifications when one is named:
+ * a calendar event in the Calendar, anything else in its block. A row with
+ * no inline preview opens instead.
*/
const preview = (
row: NotificationInboxRow,
notification?: UnifiedNotification
) => {
+ const calendarEvent = calendarSelection(entityOf(row, notification));
+ if (
+ calendarEvent &&
+ guard.canSelect(undefined) &&
+ props.calendarPreview.open(calendarEvent)
+ ) {
+ selection.select(row, notification?.id);
+ guard(undefined);
+ markSeen(row);
+ return;
+ }
const target = previewTargetFor(row, notification);
if (!target) {
props.onOpen(row, { newSplit: false, notification });
return;
}
if (!guard.canSelect(target)) return;
+ props.calendarPreview.close();
selection.select(row, notification?.id);
guard(target);
markSeen(row);
};
+
+ /** Leave what the content area shows for the empty state. */
+ const closePreview = () => {
+ props.calendarPreview.close();
+ selection.clear();
+ };
const previewAfterMove = debounce(preview, 150);
onCleanup(() => previewAfterMove.clear());
@@ -370,7 +407,7 @@ export function NotificationsView(props: NotificationsViewProps) {
complete: (row) => {
stacks.collapse(row.id);
const next = selection.afterLeaving([row.id]);
- if (next === 'none') selection.clear();
+ if (next === 'none') closePreview();
else if (next !== 'stay') preview(next);
return feed.markDone([row]);
},
@@ -383,7 +420,7 @@ export function NotificationsView(props: NotificationsViewProps) {
const markDone = (done: readonly NotificationInboxRow[]) => {
for (const row of done) stacks.collapse(row.id);
const next = selection.afterLeaving(done.map((row) => row.id));
- if (next === 'none') selection.clear();
+ if (next === 'none') closePreview();
else if (next !== 'stay') preview(next);
fireAndForget(inbox.markDone(done), 'notifications-inbox');
};
@@ -878,29 +915,47 @@ export function NotificationsView(props: NotificationsViewProps) {
</div>
</ViewShell.Aside>
<ViewShell.Main class="overflow-hidden">
- <Show
- when={previewTarget()}
- fallback={
- <EmptyStatePanel
- centered
- graphic={EmptyStateInboxTrayGraphic}
- title={t('notificationsInbox.noneSelectedTitle')}
- description={t(
- 'notificationsInbox.noneSelectedDescription'
+ <NotificationsCalendarPaneProvider
+ value={{
+ refocus: props.calendarPreview.refocus,
+ onReturn: closePreview,
+ }}
+ >
+ {/* A calendar event shows under the view's calendar route,
+ which loads lazily: suspend only this pane, so the list
+ keeps its place. */}
+ <Suspense>
+ <SplitRouter.Outlet
+ fallback={() => (
+ <Show
+ when={previewTarget()}
+ fallback={
+ <EmptyStatePanel
+ centered
+ graphic={EmptyStateInboxTrayGraphic}
+ title={t('notificationsInbox.noneSelectedTitle')}
+ description={t(
+ 'notificationsInbox.noneSelectedDescription'
+ )}
+ />
+ }
+ >
+ <PreviewPanel
+ target={previewTarget()}
+ navigationRequest={selection.navigationRequest()}
+ orchestrator={orchestrator}
+ splitPanelContext={panel}
+ headerLeading={
+ <NotificationsBreadcrumb
+ onReturn={closePreview}
+ />
+ }
+ />
+ </Show>
)}
/>
- }
- >
- <PreviewPanel
- target={previewTarget()}
- navigationRequest={selection.navigationRequest()}
- orchestrator={orchestrator}
- splitPanelContext={panel}
- headerLeading={
- <NotificationsBreadcrumb onReturn={selection.clear} />
- }
- />
- </Show>
+ </Suspense>
+ </NotificationsCalendarPaneProvider>
</ViewShell.Main>
</ViewShell.Root>
</div>
diff --git a/apps/web/src/routes/app-router-view.tsx b/apps/web/src/routes/app-router-view.tsx
index c2cedad294..6498873827 100644
--- a/apps/web/src/routes/app-router-view.tsx
+++ b/apps/web/src/routes/app-router-view.tsx
@@ -59,6 +59,7 @@ import {
MailRouteView,
MeetingRouter,
NotFound,
+ NotificationsCalendarRouteView,
NotificationsRouteView,
PrDetailRouteView,
ProjectDetailRouteView,
@@ -149,6 +150,7 @@ import {
meetRoute,
mobileEmailSignupRoute,
notFoundRoute,
+ notificationsCalendarRoute,
notificationsRoute,
onboardingRoute,
prDetailRoute,
@@ -390,7 +392,12 @@ export function AppRouterView() {
<Route
definition={notificationsRoute}
component={NotificationsRouteView}
- />
+ >
+ <Route
+ definition={notificationsCalendarRoute}
+ component={NotificationsCalendarRouteView}
+ />
+ </Route>
<Route
definition={agentsViewRoute}
component={AgentsRouteView}
diff --git a/apps/web/src/routes/lazy-route-views.ts b/apps/web/src/routes/lazy-route-views.ts
index 0a172c8f36..a0f2234fa3 100644
--- a/apps/web/src/routes/lazy-route-views.ts
+++ b/apps/web/src/routes/lazy-route-views.ts
@@ -23,6 +23,10 @@ export const CallsCallDetail = lazyNamed(
() => import('@app/features/calls-view/views/call-detail'),
'CallsCallDetail'
);
+export const NotificationsCalendarRouteView = lazyNamed(
+ () => import('@app/features/notifications-inbox/route-views'),
+ 'NotificationsCalendarRouteView'
+);
export const NotificationsRouteView = lazyNamed(
() => import('@app/features/notifications-inbox/route-views'),
'NotificationsRouteView'
diff --git a/apps/web/src/routes/routes.ts b/apps/web/src/routes/routes.ts
index 6ac5cc0d60..0f1cdc2c64 100644
--- a/apps/web/src/routes/routes.ts
+++ b/apps/web/src/routes/routes.ts
@@ -507,6 +507,15 @@ export const notificationsRoute = defineRoute({
claim: () => ({ namespace: 'component', id: 'notifications' }),
});
+/** The Calendar view inline in Notifications, at the Calendar route's own period path and search. */
+export const notificationsCalendarRoute = defineRoute({
+ id: 'notifications-calendar',
+ path: 'calendar/:period',
+ params: calendarPeriodParams,
+ serializeParams: ({ period }) => ({ period: calendarPeriodPath(period) }),
+ search: [CALENDAR_SEARCH_NAMESPACE],
+});
+
export const routinesRoute = defineRoute({
id: ROUTINES_ROUTE_ID,
path: 'routines',
diff --git a/docs/agent-guide/navigation.md b/docs/agent-guide/navigation.md
index 73fec750f0..2bd31df1fd 100644
--- a/docs/agent-guide/navigation.md
+++ b/docs/agent-guide/navigation.md
@@ -226,6 +226,7 @@ successfully rather than hashing the empty JavaScript placeholder.
| `/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/notifications` | Unified Notifications view (`enable-unified-notifications`); redirects to Home when the flag is off |
+| `/app/notifications/calendar/<month-or-week-or-day>` | Notifications with a calendar notification's event open in the Calendar beside the list; the event uses `sN.calendar.*` |
| `/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 |
diff --git a/docs/agent-guide/notifications.md b/docs/agent-guide/notifications.md
index 2e997b3d86..e2ac58c820 100644
--- a/docs/agent-guide/notifications.md
+++ b/docs/agent-guide/notifications.md
@@ -53,8 +53,10 @@ notifications the row hides, and drops its unread dot. With a preview open, `j`/
list and through unfolded notifications; `l` or the right arrow unfolds the focused
stack and the left arrow folds it from anywhere inside it. Opening a notification
marks its whole row seen, and `e` on one marks its whole stack done. Choosing what's
-shown again re-aims it. Calendar events and projects
-open in their own views instead. Shift-click or the alternate key opens a new
+shown again re-aims it. A calendar event or join request opens the Calendar
+beside the list at the event, at `/app/notifications/calendar/<period>` with the
+event in `sN.calendar.*`, under the same breadcrumb; the list keeps its place.
+Projects open in their own view instead. Shift-click or the alternate key opens a new
split. Hover a row and choose **Mark done**, or press `e`, to complete that row
only: the channel thread stays when the channel's top-level row is done, and an
open preview moves to the next row. A toast offers **Undo**, as does