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
feat: don't update viewed at optimistically for preview blocks (#1390)
gbirman2eb967fb45d5
diff --git a/js/app/packages/app/component/PreviewPanel.tsx b/js/app/packages/app/component/PreviewPanel.tsxindex 0a02196c1d..9e5f105bdd 100644--- a/js/app/packages/app/component/PreviewPanel.tsx+++ b/js/app/packages/app/component/PreviewPanel.tsx@@ -58,7 +58,7 @@ const PreviewPanelContent: Component<NonNullableFields<PreviewPanel>> = (`split=${splitPanelContext.splitHotkeyScope}`);- const [previewState, setPreviewState] = createSignal(false);+ const [previewState, setPreviewState] = createSignal(true);const splitName = createMemo(() => {const { type, id } = splitPanelContext.handle.content();if (type === 'component') return id;diff --git a/js/app/packages/core/internal/BlockLoader.tsx b/js/app/packages/core/internal/BlockLoader.tsxindex e4b115824d..3e6f2a0592 100644--- a/js/app/packages/core/internal/BlockLoader.tsx+++ b/js/app/packages/core/internal/BlockLoader.tsx@@ -2,7 +2,7 @@ import { type AllTrackingEventValues, withAnalytics } from '@coparse/analytics';import type { OwnedBlockHandle } from '@core/orchestrator';import type { AccessLevel as UserAccessLevel } from '@service-storage/generated/schemas/accessLevel';import { createAsync } from '@solidjs/router';-import { createEffect, type JSX, onCleanup } from 'solid-js';+import { createEffect, type JSX, onCleanup, useContext } from 'solid-js';import {type BlockDefinition,type BlockName,@@ -26,6 +26,7 @@ import {import type { Source, SourcePreload } from '../source';import { err, isErr, type ObjectLike, ok } from '../util/maybeResult';import { useQueryClient } from '@queries/client';+import { SplitPanelContext } from '@app/component/split-layout/context';export const blockDataSignal = createBlockSignal<unknown>();export const blockLiveTrackingEnabledSignal = createBlockSignal<boolean>();@@ -74,6 +75,9 @@ export function BlockLoader<const setEditPermissionEnabled = blockEditPermissionEnabledSignal.set;const setHandle = blockHandleSignal.set;const isNested = useIsNestedBlock();+ const splitPanelContext = useContext(SplitPanelContext);+ // NOTE: not reactive but PreviewPanel component manually creates a true signal for the context provider+ const isPreview = splitPanelContext?.previewState?.[0]() ?? false;setLiveTrackingEnabled(props.definition.liveTrackingEnabled ?? false);setEditPermissionEnabled(props.definition.editPermissionEnabled ?? false);@@ -133,10 +137,14 @@ Check that the load function does not return a preload source when the intent isreturn null;});- if (!isNested && data) {+ if (!isNested && !isPreview && data) {// we need to pass in a client accessor since the mutation is dynamically imported outside a query context providerimport('./trackBlockOpened').then(({ track }) => {- track(props.id, data.__block, useQueryClient);+ track({+ itemId: props.id,+ blockName: data.__block,+ client: useQueryClient,+ });});// for analyticsdiff --git a/js/app/packages/core/internal/trackBlockOpened.ts b/js/app/packages/core/internal/trackBlockOpened.tsindex 285270e9c5..49cbd5c7ae 100644--- a/js/app/packages/core/internal/trackBlockOpened.ts+++ b/js/app/packages/core/internal/trackBlockOpened.ts@@ -16,11 +16,15 @@ import type { Accessor } from 'solid-js';* Tracks opening of a block and updates history accordingly.* We have this in a separate file to prevent cyclic dependencies.*/-export function track(- itemId: string,- blockName: BlockName,- client: Accessor<QueryClient>-) {+export function track({+ itemId,+ blockName,+ client,+}: {+ itemId: string;+ blockName: BlockName;+ client: Accessor<QueryClient>;+}) {const itemType = blockNameToItemType(blockName);const inSoup = hasSoupItem(itemId);