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.

feat(calendar): add calendar view block (#5697)

dev-rbddf4eac31140
diff --git a/apps/web/src/components/app/app-sidebar/sidebar.tsx b/apps/web/src/components/app/app-sidebar/sidebar.tsx
index ce0cdabd2e..ffaca07f1c 100644
--- a/apps/web/src/components/app/app-sidebar/sidebar.tsx
+++ b/apps/web/src/components/app/app-sidebar/sidebar.tsx
@@ -25,6 +25,7 @@ import { useAnalytics } from '@app/lib/analytics/analytics-context';
import { useFeatureFlag } from '@app/lib/analytics/posthog';
import { useHotkeyInterceptor } from '@app/signal/hotkeyRoot';
import { globalSplitManager } from '@app/signal/splitLayout';
+import { CALENDAR_BLOCK_ID } from '@block-calendar/types';
import { useCallContextOptional } from '@channel/Call/CallContext';
import { InCallPanel } from '@channel/Call/InCallPanel';
import {
@@ -300,6 +301,15 @@ const isMarkdownDocumentsParams = (
return initialClientFilters?.or?.includes('doc-markdown') ?? false;
};
+function sidebarContent(
+ viewId: SidebarItem['id'],
+ params?: SidebarItem['params']
+): SplitContent {
+ return viewId === 'calendar'
+ ? { type: 'calendar', id: CALENDAR_BLOCK_ID }
+ : { type: 'component', id: viewId, params };
+}
+
/**
* Navigate to a sidebar view by pushing a fresh entry into the active split.
* Holding shift opens it in a new split. Use in-app back/forward to return to
@@ -332,15 +342,12 @@ function navigateToSidebarView(args: {
}
}
- return openWithSplit(
- { type: 'component', id: viewId, params },
- {
- preferNewSplit: shiftKey,
- mergeHistory: false,
- allowDuplicate: true,
- referredFrom,
- }
- );
+ return openWithSplit(sidebarContent(viewId, params), {
+ preferNewSplit: shiftKey,
+ mergeHistory: false,
+ allowDuplicate: viewId !== 'calendar',
+ referredFrom,
+ });
}
const registerSidebarHotkeys = ({
@@ -661,7 +668,11 @@ const SidebarDropdownLink = (
if (!activeContent) {
return location.pathname.split('/').filter(Boolean).includes(props.id);
}
- return activeContent.id === props.id;
+ const expectedContent = sidebarContent(props.id, props.params);
+ return (
+ activeContent.type === expectedContent.type &&
+ activeContent.id === expectedContent.id
+ );
};
const handleContextMenuOpenChange = (open: boolean) => {
@@ -698,7 +709,7 @@ const SidebarDropdownLink = (
const openFullscreen = () => {
analytics.track('sidebar_click', { view: props.id });
const handle = layout.replaceAllSplits(
- { type: 'component', id: props.id, params: props.params },
+ sidebarContent(props.id, props.params),
{ referredFrom: 'sidebar' }
);
if (props.id === 'search' && handle) requestSearchFocus(handle.id);
@@ -1777,6 +1788,7 @@ const SidebarLink = (props: SidebarLinkProps) => {
const layout = useSplitLayout();
const location = useLocation();
+ const content = () => sidebarContent(props.id, props.params);
// Always read the manager signal live: it is undefined until the split
// layout mounts, which happens after the sidebar.
@@ -1790,16 +1802,13 @@ const SidebarLink = (props: SidebarLinkProps) => {
return paths.includes(props.id);
}
- return activeContent?.id === props.id;
+ const expectedContent = content();
+ return (
+ activeContent.type === expectedContent.type &&
+ activeContent.id === expectedContent.id
+ );
};
- const content = () =>
- ({
- type: 'component',
- id: props.id,
- params: props.params,
- }) as const;
-
return (
<SidebarOpenInSplitMenu
content={content}
@@ -1836,9 +1845,10 @@ const SidebarLink = (props: SidebarLinkProps) => {
let currentContentHandle = globalSplitManager()?.activeSplit();
const currentContent = currentContentHandle?.content();
+ const expectedContent = content();
const isSameContent =
- currentContent?.type === 'component' &&
- currentContent?.id === props.id;
+ currentContent?.type === expectedContent.type &&
+ currentContent.id === expectedContent.id;
if (!isSameContent || e.shiftKey) {
currentContentHandle = navigateToSidebarView({
diff --git a/apps/web/src/components/app/mobile/mobile-nav-state.ts b/apps/web/src/components/app/mobile/mobile-nav-state.ts
index c968d792b4..a138db5459 100644
--- a/apps/web/src/components/app/mobile/mobile-nav-state.ts
+++ b/apps/web/src/components/app/mobile/mobile-nav-state.ts
@@ -1,23 +1,36 @@
import { globalSplitManager } from '@app/signal/splitLayout';
+import { CALENDAR_BLOCK_ID } from '@block-calendar/types';
import { useSettingsState } from '@core/constant/SettingsState';
import { type Accessor, createMemo } from 'solid-js';
import { useSplitLayout } from '../split-layout/layout';
import { isMobileNavViewId, type MobileNavViewId } from './mobile-nav-views';
-/** The foreground content's id when it is itself a nav view. */
+type MobileSplitNavViewId = Exclude<MobileNavViewId, 'settings'>;
+
+function mobileNavContent(id: MobileSplitNavViewId) {
+ return id === 'calendar'
+ ? ({ type: 'calendar', id: CALENDAR_BLOCK_ID } as const)
+ : ({ type: 'component', id } as const);
+}
+
+/** The mobile navigation view represented by the foreground split content. */
export function useForegroundMobileView(): Accessor<
MobileNavViewId | undefined
> {
return createMemo(() => {
const content = globalSplitManager()?.activeSplit()?.content();
- if (!content || content.type !== 'component') return undefined;
+ if (!content) return undefined;
+ if (content.type === 'calendar') {
+ return content.id === CALENDAR_BLOCK_ID ? 'calendar' : undefined;
+ }
+ if (content.type !== 'component') return undefined;
return isMobileNavViewId(content.id) ? content.id : undefined;
});
}
/**
* Navigate to a nav view from the pill row. Same semantics as the old dock
- * buttons: switching between component views replaces in-place (mergeHistory)
+ * buttons: switching between navigation views replaces in-place (mergeHistory)
* so the switch doesn't push a swipe-back entry; from an entity it is forward
* navigation so the user can swipe back. Settings toggles the settings split.
*/
@@ -31,10 +44,8 @@ export function useMobileNavNavigate(): (id: MobileNavViewId) => void {
return;
}
const fgContent = globalSplitManager()?.activeSplit()?.content();
- const isOnComponentView = fgContent?.type === 'component';
- openWithSplit(
- { type: 'component', id },
- { mergeHistory: isOnComponentView }
- );
+ const isOnNavView =
+ fgContent?.type === 'component' || fgContent?.type === 'calendar';
+ openWithSplit(mobileNavContent(id), { mergeHistory: isOnNavView });
};
}
diff --git a/apps/web/src/components/app/split-layout/componentRegistry.tsx b/apps/web/src/components/app/split-layout/componentRegistry.tsx
index fd63c9a5db..74f91d3004 100644
--- a/apps/web/src/components/app/split-layout/componentRegistry.tsx
+++ b/apps/web/src/components/app/split-layout/componentRegistry.tsx
@@ -2,7 +2,6 @@ import { useActivityFeedFlag } from '@app/features/activity/use-activity-feed-fl
import { EventComposer } from '@app/features/calendar/events/EventComposer';
import type { EventEditorInitialValues } from '@app/features/calendar/events/EventEditorForm';
import type { CalendarEvent } from '@app/features/calendar/events/types';
-import { useCalendarUiFlag } from '@app/features/calendar/use-calendar-ui-flag';
import { GettingStarted } from '@app/features/getting-started';
import { Home } from '@app/features/home';
import { queryStateFrom } from '@app/features/next-soup/filters/filter-store';
@@ -237,32 +236,6 @@ registerComponent(
})
);
-const CalendarView = lazy(() =>
- import('@app/features/calendar/calendar-view').then((module) => ({
- default: module.CalendarView,
- }))
-);
-
-function TrackedCalendarView() {
- usePageViewTracking('calendar');
- return <CalendarView />;
-}
-
-function CalendarViewWrapper() {
- const calendarUiEnabled = useCalendarUiFlag();
-
- return (
- <Show
- when={calendarUiEnabled()}
- fallback={<RedirectSplit to={{ type: 'component', id: 'inbox' }} />}
- >
- <TrackedCalendarView />
- </Show>
- );
-}
-
-registerComponent('calendar', withAuth(CalendarViewWrapper));
-
// The Activity tab briefly shipped as two separate views; restored splits
// may still reference their ids.
registerComponent('firehose', () => (
diff --git a/apps/web/src/components/app/split-layout/components/SplitHeader.tsx b/apps/web/src/components/app/split-layout/components/SplitHeader.tsx
index bc4b7f31cb..19955ed81f 100644
--- a/apps/web/src/components/app/split-layout/components/SplitHeader.tsx
+++ b/apps/web/src/components/app/split-layout/components/SplitHeader.tsx
@@ -1,6 +1,7 @@
import { isListViewID, LIST_VIEW_ID } from '@app/constants/list-views';
import { useSoup } from '@app/features/next-soup/soup-context';
import { openEntityInSplitFromUnifiedList } from '@app/features/next-soup/utils';
+import { CALENDAR_BLOCK_ID } from '@block-calendar/types';
import { useSidebarCollapse } from '@components/app/sidebarVisibility';
import type { BlockName } from '@core/block';
import {
@@ -76,9 +77,10 @@ function getEntitySplitContent(data: EntityDragEvent['draggable']['data']):
// references, which the caller navigates to instead.
if (data.type === 'reminder') return undefined;
- // A calendar event opens the calendar component split, not a block.
+ // Calendar events open the singleton calendar block; the full opening path
+ // supplies the event range used to focus the requested occurrence.
if (data.type === 'calendar_event')
- return { type: 'component', id: 'calendar' };
+ return { type: 'calendar', id: CALENDAR_BLOCK_ID };
// CRM entity types map to their dedicated blocks (entity type !== block name).
if (data.type === 'crm_company') return { type: 'company', id: data.id };
diff --git a/apps/web/src/features/block-calendar/CalendarBlockAdapter.tsx b/apps/web/src/features/block-calendar/CalendarBlockAdapter.tsx
new file mode 100644
index 0000000000..a4aa385fc2
--- /dev/null
+++ b/apps/web/src/features/block-calendar/CalendarBlockAdapter.tsx
@@ -0,0 +1,110 @@
+import { isCalendarRangeSupported } from '@app/features/calendar/calendar-supported-range';
+import { CalendarView } from '@app/features/calendar/calendar-view';
+import { useCalendarUiFlag } from '@app/features/calendar/use-calendar-ui-flag';
+import { useAnalytics } from '@app/lib/analytics/analytics-context';
+import { usePosthog } from '@app/lib/analytics/posthog';
+import { useSplitPanelOrThrow } from '@components/app/split-layout/layoutUtils';
+import { LoadingBlock } from '@core/component/LoadingBlock';
+import { useUserId } from '@core/context/user';
+import { createMethodRegistration } from '@core/orchestrator';
+import { blockHandleSignal } from '@core/signal/load';
+import { useCalendarOccurrencesQuery } from '@queries/calendar/occurrences';
+import { createMemo, createSignal, onMount, Show } from 'solid-js';
+import { isCalendarBlockRange } from './calendar-range';
+import { resolveCalendarBlockTarget } from './calendar-target';
+import type { CalendarBlockProps, CalendarBlockTargetRequest } from './types';
+
+function targetRequestFromParams(
+ params: CalendarBlockProps,
+ requestId: number
+): CalendarBlockTargetRequest | undefined {
+ if (
+ typeof params.eventId !== 'string' ||
+ params.eventId.length === 0 ||
+ !isCalendarBlockRange(params.range)
+ ) {
+ return undefined;
+ }
+
+ return {
+ eventId: params.eventId,
+ range: params.range,
+ occurrenceKey:
+ typeof params.occurrenceKey === 'string'
+ ? params.occurrenceKey
+ : undefined,
+ requestId,
+ requestedAt: Date.now(),
+ };
+}
+
+function CalendarBlockDisabledRedirect() {
+ const panel = useSplitPanelOrThrow();
+ onMount(() => {
+ panel.handle.replace({ next: { type: 'component', id: 'inbox' } });
+ });
+ return null;
+}
+
+/** Bridges the singleton block lifecycle and navigation API to CalendarView. */
+export function CalendarBlockAdapter(props: CalendarBlockProps) {
+ const calendarUiEnabled = useCalendarUiFlag();
+ const posthog = usePosthog();
+ const userId = useUserId();
+ const analytics = useAnalytics();
+ const blockHandle = blockHandleSignal.get;
+ let nextRequestId = 1;
+ const [targetRequest, setTargetRequest] = createSignal<
+ CalendarBlockTargetRequest | undefined
+ >(targetRequestFromParams(props, nextRequestId++));
+
+ createMethodRegistration(blockHandle, {
+ goToLocationFromParams: async (params: Record<string, unknown>) => {
+ const request = targetRequestFromParams(
+ params as CalendarBlockProps,
+ nextRequestId++
+ );
+ setTargetRequest(request);
+ },
+ });
+
+ const occurrencesQuery = useCalendarOccurrencesQuery(
+ () => ({ userId: userId(), range: targetRequest()?.range }),
+ () => {
+ const request = targetRequest();
+ return {
+ enabled:
+ request !== undefined && isCalendarRangeSupported(request.range),
+ refetchOnWindowFocus: false,
+ };
+ }
+ );
+ const focusTarget = createMemo(() => {
+ const request = targetRequest();
+ if (!request || occurrencesQuery.isPlaceholderData) return undefined;
+ return resolveCalendarBlockTarget(
+ occurrencesQuery.data?.items ?? [],
+ request
+ );
+ });
+
+ onMount(() => {
+ analytics.pageView('calendar');
+ analytics.track('open_view', { viewId: 'calendar' });
+ });
+
+ return (
+ <Show
+ when={calendarUiEnabled()}
+ fallback={
+ <Show when={posthog.flagsLoaded()} fallback={<LoadingBlock />}>
+ <CalendarBlockDisabledRedirect />
+ </Show>
+ }
+ >
+ <CalendarView focusTarget={focusTarget()} />
+ </Show>
+ );
+}
+
+export default CalendarBlockAdapter;
diff --git a/apps/web/src/features/block-calendar/calendar-range.ts b/apps/web/src/features/block-calendar/calendar-range.ts
new file mode 100644
index 0000000000..375ae49c65
--- /dev/null
+++ b/apps/web/src/features/block-calendar/calendar-range.ts
@@ -0,0 +1,101 @@
+import {
+ type CalendarOccurrenceQueryRange,
+ createCalendarOccurrenceQueryRange,
+} from '@queries/calendar/occurrences';
+
+/** Event timing fields available to calendar navigation call sites. */
+export type CalendarBlockEventTime =
+ | { kind: 'timed'; startsAt: string; endsAt?: string }
+ | { kind: 'allDay'; startDate: string; endDate?: string };
+
+function parseLocalDate(value: string): Date | undefined {
+ const match = /^(\d{4})-(\d{2})-(\d{2})$/.exec(value);
+ if (!match) return undefined;
+
+ const date = new Date(
+ Number(match[1]),
+ Number(match[2]) - 1,
+ Number(match[3])
+ );
+ return date.getFullYear() === Number(match[1]) &&
+ date.getMonth() === Number(match[2]) - 1 &&
+ date.getDate() === Number(match[3])
+ ? date
+ : undefined;
+}
+
+function nextLocalDay(date: Date) {
+ const next = new Date(date);
+ next.setDate(next.getDate() + 1);
+ return next;
+}
+
+/**
+ * Builds a complete occurrence-query range around an event. Timed events are
+ * expanded to local-day boundaries so both UTC and date-only API boundaries
+ * remain non-empty and can also match all-day projections.
+ */
+export function createCalendarBlockRange(
+ time: CalendarBlockEventTime
+): CalendarOccurrenceQueryRange | undefined {
+ if (time.kind === 'allDay') {
+ const start = parseLocalDate(time.startDate);
+ if (!start) return undefined;
+
+ const parsedEnd = time.endDate ? parseLocalDate(time.endDate) : undefined;
+ const end =
+ parsedEnd && parsedEnd > start ? parsedEnd : nextLocalDay(start);
+ return createCalendarOccurrenceQueryRange(start, end);
+ }
+
+ const startsAt = new Date(time.startsAt);
+ if (!Number.isFinite(startsAt.getTime())) return undefined;
+
+ const start = new Date(startsAt);
+ start.setHours(0, 0, 0, 0);
+
+ const parsedEnd = time.endsAt ? new Date(time.endsAt) : undefined;
+ const eventEnd =
+ parsedEnd && Number.isFinite(parsedEnd.getTime()) && parsedEnd > startsAt
+ ? parsedEnd
+ : startsAt;
+ const end = new Date(eventEnd);
+ const endsAtLocalMidnight =
+ end.getHours() === 0 &&
+ end.getMinutes() === 0 &&
+ end.getSeconds() === 0 &&
+ end.getMilliseconds() === 0;
+ end.setHours(0, 0, 0, 0);
+ if (!endsAtLocalMidnight || end <= start) {
+ end.setDate(end.getDate() + 1);
+ }
+
+ return createCalendarOccurrenceQueryRange(start, end);
+}
+
+/** Whether a runtime value is a complete, non-empty occurrence query range. */
+export function isCalendarBlockRange(
+ value: unknown
+): value is CalendarOccurrenceQueryRange {
+ if (!value || typeof value !== 'object') return false;
+ const range = value as Partial<CalendarOccurrenceQueryRange>;
+ if (
+ typeof range.start !== 'string' ||
+ typeof range.end !== 'string' ||
+ typeof range.startDate !== 'string' ||
+ typeof range.endDate !== 'string'
+ ) {
+ return false;
+ }
+
+ const start = new Date(range.start);
+ const end = new Date(range.end);
+ return (
+ Number.isFinite(start.getTime()) &&
+ Number.isFinite(end.getTime()) &&
+ start < end &&
+ parseLocalDate(range.startDate) !== undefined &&
+ parseLocalDate(range.endDate) !== undefined &&
+ range.startDate < range.endDate
+ );
+}
diff --git a/apps/web/src/features/block-calendar/calendar-target.ts b/apps/web/src/features/block-calendar/calendar-target.ts
new file mode 100644
index 0000000000..cd0f880d13
--- /dev/null
+++ b/apps/web/src/features/block-calendar/calendar-target.ts
@@ -0,0 +1,55 @@
+import type { CalendarFocusTarget } from '@app/features/calendar/calendar-focus-target';
+import type { CalendarOccurrenceItem } from '@service-storage/generated/schemas/calendarOccurrenceItem';
+import type { CalendarBlockTargetRequest } from './types';
+
+function parseLocalDate(value: string): Date | undefined {
+ const match = /^(\d{4})-(\d{2})-(\d{2})$/.exec(value);
+ if (!match) return undefined;
+ const year = Number(match[1]);
+ const month = Number(match[2]) - 1;
+ const day = Number(match[3]);
+ const date = new Date(year, month, day);
+ return date.getFullYear() === year &&
+ date.getMonth() === month &&
+ date.getDate() === day
+ ? date
+ : undefined;
+}
+
+function occurrenceDate(item: CalendarOccurrenceItem): Date | undefined {
+ const time = item.occurrence.time;
+ const date =
+ time.kind === 'timed'
+ ? new Date(time.startsAt)
+ : parseLocalDate(time.startDate);
+ return date && Number.isFinite(date.getTime()) ? date : undefined;
+}
+
+/**
+ * Resolves a block request to one occurrence. Without an occurrence key the
+ * supplied range must contain exactly one instance of the canonical event.
+ */
+export function resolveCalendarBlockTarget(
+ items: CalendarOccurrenceItem[],
+ request: CalendarBlockTargetRequest
+): CalendarFocusTarget | undefined {
+ const matches = items.filter(
+ (item) =>
+ item.event.id === request.eventId &&
+ (request.occurrenceKey === undefined ||
+ item.occurrence.occurrenceKey === request.occurrenceKey)
+ );
+ if (matches.length !== 1) return undefined;
+
+ const item = matches[0];
+ const date = occurrenceDate(item);
+ if (!date) return undefined;
+
+ return {
+ eventId: item.event.id,
+ occurrenceKey: item.occurrence.occurrenceKey,
+ date,
+ requestId: request.requestId,
+ requestedAt: request.requestedAt,
+ };
+}
diff --git a/apps/web/src/features/block-calendar/definition.ts b/apps/web/src/features/block-calendar/definition.ts
new file mode 100644
index 0000000000..db234b96c2
--- /dev/null
+++ b/apps/web/src/features/block-calendar/definition.ts
@@ -0,0 +1,20 @@
+import { defineBlock, type ExtractLoadType, LoadErrors } from '@core/block';
+import { ok } from 'neverthrow';
+import { lazy } from 'solid-js';
+import { CALENDAR_BLOCK_ID } from './types';
+
+export const definition = defineBlock({
+ name: 'calendar',
+ description: 'View calendar events',
+ component: lazy(() => import('./CalendarBlockAdapter')),
+ liveTrackingEnabled: false,
+ openTrackingEnabled: false,
+ async load(source, _intent) {
+ if (source.type !== 'dss') return LoadErrors.MISSING;
+ if (source.id !== CALENDAR_BLOCK_ID) return LoadErrors.INVALID;
+ return ok({ id: source.id });
+ },
+ accepted: {},
+});
+
+export type CalendarData = ExtractLoadType<(typeof definition)['load']>;
diff --git a/apps/web/src/features/block-calendar/types.ts b/apps/web/src/features/block-calendar/types.ts
new file mode 100644
index 0000000000..350459e772
--- /dev/null
+++ b/apps/web/src/features/block-calendar/types.ts
@@ -0,0 +1,23 @@
+import type { CalendarOccurrenceQueryRange } from '@queries/calendar/occurrences';
+
+/** Stable identity used by the singleton calendar block. */
+export const CALENDAR_BLOCK_ID = 'view';
+
+/** Optional navigation parameters accepted by the singleton calendar block. */
+export interface CalendarBlockProps {
+ /** Canonical event to focus after loading `range`. */
+ eventId?: string;
+ /** Exact half-open occurrence API range used to locate `eventId`. */
+ range?: CalendarOccurrenceQueryRange;
+ /** Stable occurrence key, when the target is a recurring event instance. */
+ occurrenceKey?: string;
+}
+
+/** A validated request to locate and focus one event occurrence. */
+export interface CalendarBlockTargetRequest {
+ eventId: string;
+ range: CalendarOccurrenceQueryRange;
+ occurrenceKey?: string;
+ requestId: number;
+ requestedAt: number;
+}
diff --git a/apps/web/src/features/calendar/CalendarPage.tsx b/apps/web/src/features/calendar/CalendarPage.tsx
index 09f1ff1adf..17ef08adb9 100644
--- a/apps/web/src/features/calendar/CalendarPage.tsx
+++ b/apps/web/src/features/calendar/CalendarPage.tsx
@@ -39,9 +39,8 @@ import {
import { useCalendarView } from './CalendarViewContext';
import {
calendarFocusTargetId,
- clearCalendarFocus,
- pendingCalendarFocus,
-} from './calendar-focus-intent';
+ useCalendarFocus,
+} from './calendar-focus-target';
import { isCalendarRangeSupported } from './calendar-supported-range';
import {
DEFAULT_CALENDAR_SOURCE,
@@ -639,33 +638,33 @@ function CalendarPageHost(props: {
const calendar = useFullCalendar();
const pager = useCalendarPager();
const calendarView = useCalendarView();
+ const calendarFocus = useCalendarFocus();
const [element, setElement] = createSignal<HTMLDivElement>();
const isActive = () => pager.isActive(props.id);
- // Deep-link consumption: a pending focus request (set by notification
- // navigation, possibly before this split even mounted) pages the active
- // calendar to the occurrence and opens its details once its chip renders.
+ // A block navigation request pages this calendar instance to one occurrence
+ // and opens its details once FullCalendar has mounted the target chip.
let navigatedFor: number | undefined;
createEffect(() => {
props.chipMounts();
- const intent = pendingCalendarFocus();
- if (!intent || !isActive()) return;
+ const target = calendarFocus.pendingTarget();
+ if (!target || !isActive()) return;
const dateInfo = calendar.dateInfo();
if (!dateInfo) return;
- if (intent.date < dateInfo.start || intent.date >= dateInfo.end) {
+ if (target.date < dateInfo.start || target.date >= dateInfo.end) {
// Navigate once per request; the effect re-runs as the destination
// page's chips mount, and by then the date is inside the view.
- if (navigatedFor !== intent.requestedAt) {
- navigatedFor = intent.requestedAt;
- pager.navigateToDate(intent.date);
+ if (navigatedFor !== target.requestId) {
+ navigatedFor = target.requestId;
+ pager.navigateToDate(target.date);
}
return;
}
- const targetId = calendarFocusTargetId(intent);
+ const targetId = calendarFocusTargetId(target);
const event = props.data.eventsById().get(targetId);
const chip = props.eventElements.get(targetId);
if (!event || !chip?.isConnected) return;
- clearCalendarFocus();
+ calendarFocus.consume(target.requestId);
calendarView.selectEvent(event, chip);
});
diff --git a/apps/web/src/features/calendar/calendar-focus-intent.ts b/apps/web/src/features/calendar/calendar-focus-intent.ts
deleted file mode 100644
index 5042acc7cb..0000000000
--- a/apps/web/src/features/calendar/calendar-focus-intent.ts
+++ /dev/null
@@ -1,55 +0,0 @@
-import { createSignal } from 'solid-js';
-
-/**
- * How long a requested focus stays claimable. A stale intent must not hijack
- * a later visit to the calendar — without this, a chip mounting minutes after
- * a failed navigation would still pop its details open.
- */
-const FOCUS_INTENT_TTL_MS = 15_000;
-
-/** A request to page the calendar to one occurrence and open its details. */
-export interface CalendarFocusIntent {
- /** Canonical calendar event entity id. */
- eventId: string;
- /** Stable occurrence key within the event. */
- occurrenceKey: string;
- /** Occurrence start, used to page the calendar to the right date. */
- date: Date;
- /** When the intent was made, for staleness checks. */
- requestedAt: number;
-}
-
-const [pendingIntent, setPendingIntent] = createSignal<CalendarFocusIntent>();
-
-/** The grid's composite view-model id for an intent's occurrence. */
-export function calendarFocusTargetId(intent: CalendarFocusIntent): string {
- return JSON.stringify([intent.eventId, intent.occurrenceKey]);
-}
-
-/**
- * Ask the calendar view to page to an occurrence and open its details.
- * Module-level rather than context state because the producer (notification
- * navigation) runs outside the calendar's providers, and the split it opens
- * only mounts them afterwards.
- */
-export function requestCalendarFocus(
- intent: Omit<CalendarFocusIntent, 'requestedAt'>
-) {
- setPendingIntent({ ...intent, requestedAt: Date.now() });
-}
-
-/** The pending focus request, dropping one that has gone stale. */
-export function pendingCalendarFocus(): CalendarFocusIntent | undefined {
- const intent = pendingIntent();
- if (!intent) return undefined;
- if (Date.now() - intent.requestedAt > FOCUS_INTENT_TTL_MS) {
- setPendingIntent(undefined);
- return undefined;
- }
- return intent;
-}
-
-/** Consume the pending focus request. */
-export function clearCalendarFocus() {
- setPendingIntent(undefined);
-}
diff --git a/apps/web/src/features/calendar/calendar-focus-target.ts b/apps/web/src/features/calendar/calendar-focus-target.ts
new file mode 100644
index 0000000000..5d601f9c01
--- /dev/null
+++ b/apps/web/src/features/calendar/calendar-focus-target.ts
@@ -0,0 +1,50 @@
+import { createAssertedContextProvider } from '@core/context/createContext';
+import { type Accessor, createSignal, type ParentProps } from 'solid-js';
+
+const FOCUS_TARGET_TTL_MS = 15_000;
+
+/** A request for one calendar view instance to focus a rendered occurrence. */
+export interface CalendarFocusTarget {
+ /** Canonical calendar event entity id. */
+ eventId: string;
+ /** Stable occurrence key within the event. */
+ occurrenceKey: string;
+ /** Occurrence start, used to page the calendar to the right date. */
+ date: Date;
+ /** Monotonic id that allows the same target to be requested repeatedly. */
+ requestId: number;
+ /** Time the navigation was requested, used to reject delayed focus. */
+ requestedAt: number;
+}
+
+/** The grid's composite view-model id for a focus target. */
+export function calendarFocusTargetId(target: CalendarFocusTarget): string {
+ return JSON.stringify([target.eventId, target.occurrenceKey]);
+}
+
+interface CalendarFocusContextProps extends ParentProps {
+ target?: Accessor<CalendarFocusTarget | undefined>;
+}
+
+/** Instance-scoped focus state for one mounted calendar workspace. */
+export const [CalendarFocusContextProvider, useCalendarFocus] =
+ createAssertedContextProvider(
+ 'CalendarFocusContext',
+ (props: CalendarFocusContextProps) => {
+ const [consumedRequestId, setConsumedRequestId] = createSignal<number>();
+ return {
+ pendingTarget: () => {
+ const target = props.target?.();
+ if (
+ !target ||
+ target.requestId === consumedRequestId() ||
+ Date.now() - target.requestedAt > FOCUS_TARGET_TTL_MS
+ ) {
+ return undefined;
+ }
+ return target;
+ },
+ consume: (requestId: number) => setConsumedRequestId(requestId),
+ };
+ }
+ );
diff --git a/apps/web/src/features/calendar/calendar-view.tsx b/apps/web/src/features/calendar/calendar-view.tsx
index e7e98c6440..831101b208 100644
--- a/apps/web/src/features/calendar/calendar-view.tsx
+++ b/apps/web/src/features/calendar/calendar-view.tsx
@@ -40,6 +40,10 @@ import {
CalendarViewContextProvider,
useCalendarView,
} from './CalendarViewContext';
+import {
+ CalendarFocusContextProvider,
+ type CalendarFocusTarget,
+} from './calendar-focus-target';
import { calendarPeriodLabel } from './calendar-label';
import { SelectedEventDetails } from './events/EventDetailsPopover';
import { useOpenEventComposer } from './events/useOpenEventComposer';
@@ -54,13 +58,15 @@ const formatMonthTitle = new Intl.DateTimeFormat(undefined, {
}).format;
/** A calendar-focused workspace view backed by buffered FullCalendar pages. */
-export function CalendarView() {
+export function CalendarView(props: { focusTarget?: CalendarFocusTarget }) {
return (
- <CalendarViewContextProvider>
- <CalendarPagerContextProvider>
- <CalendarPagerRoot />
- </CalendarPagerContextProvider>
- </CalendarViewContextProvider>
+ <CalendarFocusContextProvider target={() => props.focusTarget}>
+ <CalendarViewContextProvider>
+ <CalendarPagerContextProvider>
+ <CalendarPagerRoot />
+ </CalendarPagerContextProvider>
+ </CalendarViewContextProvider>
+ </CalendarFocusContextProvider>
);
}
diff --git a/apps/web/src/features/entity/queries/rename.ts b/apps/web/src/features/entity/queries/rename.ts
index 467cde6d78..266e5df296 100644
--- a/apps/web/src/features/entity/queries/rename.ts
+++ b/apps/web/src/features/entity/queries/rename.ts
@@ -211,6 +211,7 @@ const renameDssSetData = (
itemType !== 'channel_message' &&
itemType !== 'channel_thread' &&
itemType !== 'automation' &&
+ itemType !== 'calendar_event' &&
itemType !== 'foreign' &&
// CRM companies/contacts aren't renamed via the FileList path (their
// names derive from the directory/email, and their soup tags are
diff --git a/apps/web/src/features/entity/utils/buildEntityData.ts b/apps/web/src/features/entity/utils/buildEntityData.ts
index d419aaa927..f44f1412e1 100644
--- a/apps/web/src/features/entity/utils/buildEntityData.ts
+++ b/apps/web/src/features/entity/utils/buildEntityData.ts
@@ -172,6 +172,8 @@ export function buildEntityData(
participantIds: args.participantIds ?? [],
};
})
+ // The singleton calendar block has no entity-shaped block id.
+ .with('calendar', (): undefined => undefined)
// CRM companies/contacts aren't constructed from block args; soup is the source.
.with('company', 'contact', (): undefined => undefined)
// PRs are virtual blocks backed by GitHub, not Macro entities.
diff --git a/apps/web/src/features/next-soup/utils.test.ts b/apps/web/src/features/next-soup/utils.test.ts
index af22643de9..8be63f1dbf 100644
--- a/apps/web/src/features/next-soup/utils.test.ts
+++ b/apps/web/src/features/next-soup/utils.test.ts
@@ -17,6 +17,10 @@ vi.mock('@service-connection/websocket', () => ({
vi.mock('@core/component/Toast/Toast', () => ({
toast: { alert: toastAlert },
}));
+vi.mock('@core/constant/featureFlags', async (importOriginal) => ({
+ ...(await importOriginal<typeof import('@core/constant/featureFlags')>()),
+ ENABLE_CALENDAR_UI: () => true,
+}));
import { setGlobalSplitManager } from '@app/signal/splitLayout';
import type {
@@ -162,6 +166,60 @@ describe('preview duplicate navigation', () => {
});
});
+describe('calendar block navigation', () => {
+ it('opens and targets the singleton calendar block', async () => {
+ const openWithSplit = vi.fn();
+ const goToLocationFromParams = vi.fn();
+ const getBlockHandle = vi.fn(async () => ({ goToLocationFromParams }));
+ setGlobalSplitManager({
+ activeSplit: vi.fn(),
+ getOrchestrator: vi.fn(() => ({ getBlockHandle })),
+ getSplitByContent: vi.fn(),
+ openWithSplit,
+ } as unknown as SplitManager);
+
+ await openEntityInSplitFromUnifiedList(
+ {
+ type: 'calendar_event',
+ id: 'event-1',
+ notifications: () => [
+ {
+ notification_metadata: {
+ tag: 'calendar_event_reminder',
+ content: {
+ eventId: 'event-1',
+ occurrenceKey: 'instance-1',
+ startDate: '2026-01-27',
+ },
+ },
+ } as UnifiedNotification,
+ ],
+ } as unknown as EntityData,
+ {}
+ );
+
+ expect(openWithSplit).toHaveBeenCalledWith(
+ expect.objectContaining({
+ type: 'calendar',
+ id: 'view',
+ params: expect.objectContaining({
+ eventId: 'event-1',
+ occurrenceKey: 'instance-1',
+ range: expect.objectContaining({
+ startDate: '2026-01-27',
+ endDate: '2026-01-28',
+ }),
+ }),
+ }),
+ expect.any(Object)
+ );
+ expect(getBlockHandle).toHaveBeenCalledWith('view', 'calendar');
+ expect(goToLocationFromParams).toHaveBeenCalledWith(
+ expect.objectContaining({ eventId: 'event-1' })
+ );
+ });
+});
+
describe('preview history source', () => {
it('stamps the originating controller entity on viewer content', async () => {
const openWithSplit = vi.fn();
diff --git a/apps/web/src/features/next-soup/utils.ts b/apps/web/src/features/next-soup/utils.ts
index 3069ebcec5..ada8dc286a 100644
--- a/apps/web/src/features/next-soup/utils.ts
+++ b/apps/web/src/features/next-soup/utils.ts
@@ -1,5 +1,10 @@
import { isListViewID } from '@app/constants/list-views';
import { globalSplitManager } from '@app/signal/splitLayout';
+import { createCalendarBlockRange } from '@block-calendar/calendar-range';
+import {
+ CALENDAR_BLOCK_ID,
+ type CalendarBlockProps,
+} from '@block-calendar/types';
import { URL_PARAMS as CALL_PARAMS } from '@block-call/constants';
import { URL_PARAMS as CHANNEL_PARAMS } from '@block-channel/constants';
import {
@@ -80,9 +85,8 @@ import {
removeSoupEntitiesFromDoneFilteredQueries,
} from '@queries/soup/cache';
import { emailClient } from '@service-email/client';
-import { isAfter, parseISO } from 'date-fns';
+import { isAfter } from 'date-fns';
import { match } from 'ts-pattern';
-import { requestCalendarFocus } from '../calendar/calendar-focus-intent';
import { withPreviewSourceEntityId } from './preview-history';
const mergeSearchEntities = <T extends EntityData>(
@@ -226,7 +230,9 @@ export const openEntityInNewTab = ({
// Build URL for the entity
let entityPath: string;
- if (entity.type === 'document') {
+ if (entity.type === 'calendar_event') {
+ entityPath = `/app/calendar/${CALENDAR_BLOCK_ID}`;
+ } else if (entity.type === 'document') {
const { fileType, subType } = entity;
const blockName = fileTypeToBlockName(subType?.type ?? fileType);
entityPath = `/app/${blockName}/${entity.id}`;
@@ -611,17 +617,20 @@ export const openEntityInSplitFromUnifiedList = async (
// A standalone reminder points at nothing, so there is nothing to open.
if (entity.type === 'reminder' && !entity.referencedEntity) return;
- // A calendar event opens the calendar split focused on the alarmed
- // occurrence — the same deep link its notification uses.
+ // Calendar is a singleton block. Event opens retarget that one instance
+ // with a locator range, including repeat clicks on an already-open split.
if (entity.type === 'calendar_event') {
if (!ENABLE_CALENDAR_UI()) return;
- requestCalendarFocusForEntity(entity);
- const existing = splitManager.getSplitByContent('component', 'calendar');
+ const params = calendarBlockParamsForEntity(entity);
+ const existing = splitManager.getSplitByContent(
+ 'calendar',
+ CALENDAR_BLOCK_ID
+ );
if (existing) {
existing.activate();
} else {
splitManager.openWithSplit(
- { type: 'component', id: 'calendar' },
+ { type: 'calendar', id: CALENDAR_BLOCK_ID, params },
{
activate: true,
referredFrom: null,
@@ -630,6 +639,11 @@ export const openEntityInSplitFromUnifiedList = async (
}
);
}
+ const calendarHandle = await blockOrchestrator.getBlockHandle(
+ CALENDAR_BLOCK_ID,
+ 'calendar'
+ );
+ await calendarHandle?.goToLocationFromParams(params);
return;
}
@@ -739,15 +753,10 @@ export function markReminderSeenOnOpen(
});
}
-/**
- * File the calendar deep-link focus for an alarmed event row. The row is the
- * master event; the alarmed occurrence and its start ride on the driving
- * notification's metadata. Without one, the master's own start still pages
- * the calendar to the right date.
- */
-function requestCalendarFocusForEntity(
+/** Build the singleton block params for an event row's target occurrence. */
+function calendarBlockParamsForEntity(
entity: Extract<EntityData, { type: 'calendar_event' }>
-) {
+): CalendarBlockProps {
const notifications = isWithNotification(entity)
? (entity.notifications?.() ?? [])
: [];
@@ -756,23 +765,21 @@ function requestCalendarFocusForEntity(
.find((candidate) => candidate?.tag === 'calendar_event_reminder');
const content =
metadata?.tag === 'calendar_event_reminder' ? metadata.content : undefined;
- const start =
- content?.startsAt ??
- (entity.time?.kind === 'timed' ? entity.time.startsAt : undefined);
- const startDate =
- content?.startDate ??
- (entity.time?.kind === 'allDay' ? entity.time.startDate : undefined);
- const date = start
- ? new Date(start)
- : startDate
- ? parseISO(startDate)
- : undefined;
- if (!date || !Number.isFinite(date.getTime())) return;
- requestCalendarFocus({
- eventId: entity.id,
- occurrenceKey: content?.occurrenceKey ?? '',
- date,
- });
+ const time = content?.startsAt
+ ? {
+ kind: 'timed' as const,
+ startsAt: content.startsAt,
+ endsAt: content.endsAt ?? undefined,
+ }
+ : content?.startDate
+ ? { kind: 'allDay' as const, startDate: content.startDate }
+ : entity.time;
+
+ return {
+ eventId: content?.eventId ?? entity.id,
+ occurrenceKey: content?.occurrenceKey,
+ range: time ? createCalendarBlockRange(time) : undefined,
+ };
}
/**
@@ -827,10 +834,10 @@ function getEntitySplitContent(entity: EntityData) {
}
);
})
- // Calendar events open the calendar component split; the open path
+ // Calendar events open the singleton calendar block; the open path
// branches before reaching here, so this only serves duplicate checks.
.with({ type: 'calendar_event' }, () => {
- return { type: 'component' as const, id: 'calendar' };
+ return { type: 'calendar' as const, id: CALENDAR_BLOCK_ID };
})
.otherwise((entity) => {
return { type: entity.type, id: entity.id };
diff --git a/apps/web/src/features/notifications/notification-navigation.ts b/apps/web/src/features/notifications/notification-navigation.ts
index b2394b47b1..d4f9b1e4f4 100644
--- a/apps/web/src/features/notifications/notification-navigation.ts
+++ b/apps/web/src/features/notifications/notification-navigation.ts
@@ -1,3 +1,5 @@
+import { createCalendarBlockRange } from '@block-calendar/calendar-range';
+import { CALENDAR_BLOCK_ID } from '@block-calendar/types';
import {
getChannelParams,
navigateToChannelMessage,
@@ -23,10 +25,8 @@ import type { EntityType, NotificationType } from '@core/types';
import { openExternalUrl } from '@core/util/url';
import { getNotificationById } from '@queries/notification/user-notifications';
import { getReminderById } from '@queries/reminders/reminders';
-import { parseISO } from 'date-fns';
import { errAsync, ResultAsync } from 'neverthrow';
import { match, P } from 'ts-pattern';
-import { requestCalendarFocus } from '../calendar/calendar-focus-intent';
import { GITHUB_EVENT_TYPES } from './github-event-types';
import { isChannelNotification } from './notification-helpers';
import { DefaultNotificationBlockNameResolver } from './notification-resolvers';
@@ -45,7 +45,7 @@ async function goToLocationInSplit(
layoutManager: SplitManager,
type: BlockName | BlockAlias,
id: string,
- params: Record<string, string>
+ params: Record<string, unknown>
) {
const orchestrator = layoutManager.getOrchestrator();
if (!orchestrator) return;
@@ -65,7 +65,7 @@ function openSplitIfNotOpen(
id: string,
options: {
newSplit?: boolean;
- params?: Record<string, string>;
+ params?: Record<string, unknown>;
sourceHandle?: SplitHandle;
} = {}
) {
@@ -403,23 +403,24 @@ function getSupportedHandler(
// longer meant to have.
if (!ENABLE_CALENDAR_UI()) return;
const content = meta.content;
- // parseISO keeps an all-day date local; `new Date('YYYY-MM-DD')`
- // would read it as UTC midnight and land a day early west of it.
- const start = content.startsAt
- ? new Date(content.startsAt)
+ const time = content.startsAt
+ ? {
+ kind: 'timed' as const,
+ startsAt: content.startsAt,
+ endsAt: content.endsAt ?? undefined,
+ }
: content.startDate
- ? parseISO(content.startDate)
+ ? { kind: 'allDay' as const, startDate: content.startDate }
: undefined;
- if (start) {
- requestCalendarFocus({
- eventId: content.eventId,
- occurrenceKey: content.occurrenceKey,
- date: start,
- });
- }
- openSplitIfNotOpen(lm, 'component', 'calendar', {
+ const range = time ? createCalendarBlockRange(time) : undefined;
+ openSplitIfNotOpen(lm, 'calendar', CALENDAR_BLOCK_ID, {
newSplit,
sourceHandle,
+ params: {
+ eventId: content.eventId,
+ occurrenceKey: content.occurrenceKey,
+ range,
+ },
});
};
})
diff --git a/apps/web/src/lib/core/block.ts b/apps/web/src/lib/core/block.ts
index 3f9b2eeb98..da92add2f2 100644
--- a/apps/web/src/lib/core/block.ts
+++ b/apps/web/src/lib/core/block.ts
@@ -1,3 +1,4 @@
+import type { CalendarBlockProps } from '@block-calendar/types';
import type { BlockCanvasProps } from '@block-canvas/component/Block';
import type { BlockChannelProps } from '@block-channel/component/NewChannelBlockAdapter';
import type { BlockMarkdownProps } from '@block-md/component/Block';
@@ -49,6 +50,7 @@ import type { ObjectLike, ResultError } from './util/result';
*/
export const BlockRegistry = [
'call',
+ 'calendar',
'chat',
'write',
'pdf',
@@ -100,6 +102,7 @@ export type BlockAlias = (typeof BlockAliasRegistry)[BlockAliasKeys];
*/
export const NonDocumentBlockTypes = [
'call',
+ 'calendar',
'chat',
'channel',
'project',
@@ -144,6 +147,7 @@ function exclude(excludeSet: BlockName[]) {
*/
const _ValidBlockCombinations: BlockCombinationRules = {
call: allBlockNames,
+ calendar: allBlockNames,
chat: allBlockNames,
pdf: ENABLE_PDF_MULTISPLIT ? allBlockNames : exclude(['pdf']),
write: exclude(['write']),
@@ -169,6 +173,7 @@ const _ValidBlockCombinations: BlockCombinationRules = {
// maps block name to valid parents
export const ValidNestingCombinations: BlockCombinationRules = {
call: new Set([]),
+ calendar: new Set([]),
canvas: new Set(['md']),
chat: new Set([]),
pdf: new Set(['md']),
@@ -328,6 +333,7 @@ export type ExtractLoadType<T extends LoadFunction<any, any>> =
ExtractSuccessType<Awaited<ReturnType<T>>>;
export interface BlockComponentProps extends Record<BlockName, ObjectLike> {
+ calendar: CalendarBlockProps;
canvas: BlockCanvasProps;
channel: BlockChannelProps;
md: BlockMarkdownProps;
@@ -389,6 +395,9 @@ export type BlockDefinition<
/** flag to indicate wether this block should enable collaborative features. */
liveTrackingEnabled?: boolean;
+ /** Whether mounting this block records entity-open analytics and history. */
+ openTrackingEnabled?: boolean;
+
accepted: Record<string, string>;
/** The default name of the file when creating a new block of this type. */
diff --git a/apps/web/src/lib/core/blockMethodRegistry.ts b/apps/web/src/lib/core/blockMethodRegistry.ts
index 970d2d4436..35ea486f49 100644
--- a/apps/web/src/lib/core/blockMethodRegistry.ts
+++ b/apps/web/src/lib/core/blockMethodRegistry.ts
@@ -18,6 +18,7 @@ type AssertSpec<T> = T extends BlockMethodSpec ? T : EmptySpec;
export interface BlockMethodRegistry {
call: EmptySpec;
+ calendar: EmptySpec;
chat: AssertSpec<BlockChatSpec>;
channel: EmptySpec;
write: EmptySpec;
diff --git a/apps/web/src/lib/core/component/EntityIcon.tsx b/apps/web/src/lib/core/component/EntityIcon.tsx
index b1abc813e9..430122c291 100644
--- a/apps/web/src/lib/core/component/EntityIcon.tsx
+++ b/apps/web/src/lib/core/component/EntityIcon.tsx
@@ -105,6 +105,12 @@ export const ENTITY_ICON_CONFIGS: Record<EntityWithValidIcon, IconConfig> = {
background: 'bg-default/20',
prettyName: 'Call',
},
+ calendar: {
+ icon: WideCalendar,
+ foreground: 'text-default',
+ background: 'bg-default/20',
+ prettyName: 'Calendar',
+ },
canvas: {
icon: Canvas,
foreground: 'text-canvas',
@@ -347,6 +353,7 @@ const WIDE_ICONS: Record<
Component<JSX.SvgSVGAttributes<SVGSVGElement>>
> = {
call: PhoneCall,
+ calendar: WideCalendar,
canvas: WideDiagram,
html: WideFileCode,
channel: WideChannel,
diff --git a/apps/web/src/lib/core/component/FileList/constants.tsx b/apps/web/src/lib/core/component/FileList/constants.tsx
index 320291fc6f..8aa8a6b9f0 100644
--- a/apps/web/src/lib/core/component/FileList/constants.tsx
+++ b/apps/web/src/lib/core/component/FileList/constants.tsx
@@ -66,6 +66,7 @@ const _fileTypeColors: Record<BlockName | BlockAlias | 'default', string> = {
canvas: 'bg-canvas/20 group/item',
video: 'bg-video/20 group/item',
call: defaultFileColor,
+ calendar: defaultFileColor,
contact: defaultFileColor,
company: defaultFileColor,
default: defaultFileColor,
diff --git a/apps/web/src/lib/core/component/LexicalMarkdown/plugins/mentions/mentionsPlugin.ts b/apps/web/src/lib/core/component/LexicalMarkdown/plugins/mentions/mentionsPlugin.ts
index 5f71dc3a5b..52e59e2091 100644
--- a/apps/web/src/lib/core/component/LexicalMarkdown/plugins/mentions/mentionsPlugin.ts
+++ b/apps/web/src/lib/core/component/LexicalMarkdown/plugins/mentions/mentionsPlugin.ts
@@ -301,6 +301,9 @@ const getDocumentMentionItemType = (
.with('channel_thread', () => 'channel')
.with('automation', () => 'automation')
.with('call', () => 'call')
+ .with('calendar_event', () => {
+ throw new Error('calendar blocks cannot be document mentions');
+ })
.with('foreign', () => {
throw new Error('foreign entities cannot be document mentions');
})
diff --git a/apps/web/src/lib/core/constant/allBlocks.ts b/apps/web/src/lib/core/constant/allBlocks.ts
index 2ff5568eac..72a26122d4 100644
--- a/apps/web/src/lib/core/constant/allBlocks.ts
+++ b/apps/web/src/lib/core/constant/allBlocks.ts
@@ -182,6 +182,7 @@ export function fileTypeToBlockName(
if (!blockOrFiletype) return 'unknown';
if (blockOrFiletype === 'channel_message') return 'channel';
+ if (blockOrFiletype === 'calendar_event') return 'calendar';
// CRM entity types map to their dedicated blocks (entity type !== block name).
if (blockOrFiletype === 'crm_company') return 'company';
diff --git a/apps/web/src/lib/core/internal/BlockLoader.tsx b/apps/web/src/lib/core/internal/BlockLoader.tsx
index 8626f9d81a..40b72c4163 100644
--- a/apps/web/src/lib/core/internal/BlockLoader.tsx
+++ b/apps/web/src/lib/core/internal/BlockLoader.tsx
@@ -144,7 +144,7 @@ Check that the load function does not return a preload source when the intent is
const data = result.value;
setError(null);
- if (!isNested && data) {
+ if (!isNested && data && props.definition.openTrackingEnabled !== false) {
const trackOpened = () => {
// we need to pass in a client accessor since the mutation is dynamically imported outside a query context provider
import('./trackBlockOpened').then(({ track }) => {
diff --git a/apps/web/src/lib/core/internal/trackBlockOpened.ts b/apps/web/src/lib/core/internal/trackBlockOpened.ts
index b362e38dd3..dcf6e4f942 100644
--- a/apps/web/src/lib/core/internal/trackBlockOpened.ts
+++ b/apps/web/src/lib/core/internal/trackBlockOpened.ts
@@ -24,6 +24,7 @@ function isSoupEntityTag(
'channel_message',
'channel_thread',
'automation',
+ 'calendar_event',
'foreign',
'crm_company',
'crm_contact',
diff --git a/apps/web/src/lib/service-clients/service-storage/client.ts b/apps/web/src/lib/service-clients/service-storage/client.ts
index 413e12fe0b..386f683f1c 100644
--- a/apps/web/src/lib/service-clients/service-storage/client.ts
+++ b/apps/web/src/lib/service-clients/service-storage/client.ts
@@ -232,6 +232,7 @@ export type ItemType =
| 'channel_thread'
| 'call'
| 'automation'
+ | 'calendar_event'
| 'foreign'
| 'crm_company'
| 'crm_contact';
@@ -325,6 +326,7 @@ const itemTypeSet = new Set([
'channel_message',
'call',
'automation',
+ 'calendar_event',
'thread',
'crm_company',
'crm_contact',
@@ -342,6 +344,8 @@ export function blockNameToItemType(
return 'chat';
case 'call':
return 'call';
+ case 'calendar':
+ return 'calendar_event';
case 'channel':
return 'channel';
case 'project':
@@ -367,6 +371,7 @@ export function stringToItemType(str: string): ItemType | undefined {
return 'email';
}
case 'call':
+ case 'calendar_event':
case 'chat':
case 'document':
case 'project':
diff --git a/apps/web/src/routes/Root.tsx b/apps/web/src/routes/Root.tsx
index 7390497d9a..29bde1c752 100644
--- a/apps/web/src/routes/Root.tsx
+++ b/apps/web/src/routes/Root.tsx
@@ -240,10 +240,6 @@ const ROUTES: RouteDefinition[] = [
path: '/reminders',
component: LAYOUT_ROUTE.component,
},
- {
- path: '/calendar',
- component: LAYOUT_ROUTE.component,
- },
{
path: '/agents',
component: LAYOUT_ROUTE.component,
diff --git a/apps/web/tsconfig.json b/apps/web/tsconfig.json
index e8870b678a..6cb0a4e74f 100644
--- a/apps/web/tsconfig.json
+++ b/apps/web/tsconfig.json
@@ -131,6 +131,9 @@
"@block-chat/*": [
"./src/features/block-chat/*"
],
+ "@block-calendar/*": [
+ "./src/features/block-calendar/*"
+ ],
"@block-code/*": [
"./src/features/block-code/*"
],