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
fix(channel): no more suspending! (#1394)
teo48d459baba3c
diff --git a/js/app/packages/block-channel/component/Block.tsx b/js/app/packages/block-channel/component/Block.tsxindex e6370957e8..cba9ccf66a 100644--- a/js/app/packages/block-channel/component/Block.tsx+++ b/js/app/packages/block-channel/component/Block.tsx@@ -1,15 +1,22 @@import { useBlockId } from '@core/block';import { useChannelName } from '@core/context/channels';import { DocumentBlockContainer } from '@core/component/DocumentBlockContainer';-import { type JSXElement, Suspense } from 'solid-js';+import { type JSXElement, onMount, Suspense } from 'solid-js';import { Channel } from './Channel';import { URL_PARAMS } from '@block-channel/constants';import type { TargetMessageInfo } from '@block-channel/component/MessageList/MessageList';+import { useChannelQuery } from '@queries/channel/channel';import { ChannelContextProvider } from '@block-channel/hooks/channel';export function WithTopBar(props: { children: JSXElement }) {return <div>{props.children}</div>;}+function ChannelBlockSuspenseFallback() {+ onMount(() => {+ console.warn('[block-channel] Top-level BlockChannel suspense triggered');+ });+ return null;+}export type JoinState = 'REQUIRED' | 'NOT_REQUIRED';@@ -20,6 +27,7 @@ export type BlockChannelProps = IncomingParams & {};export default function BlockChannel(props: BlockChannelProps) {const channelId = useBlockId();const channelName = useChannelName(channelId);+ const channelQuery = useChannelQuery(() => channelId);const targetMessage = () => {const messageID = props[URL_PARAMS.message];@@ -33,9 +41,9 @@ export default function BlockChannel(props: BlockChannelProps) {};return (- <Suspense>+ <Suspense fallback={<ChannelBlockSuspenseFallback />}><DocumentBlockContainer title={channelName() ?? 'Channel'}>- <ChannelContextProvider channelId={() => channelId}>+ <ChannelContextProvider query={channelQuery}><Channel channelId={channelId} target={targetMessage()} /></ChannelContextProvider></DocumentBlockContainer>diff --git a/js/app/packages/block-channel/component/MessageList/MessageList.tsx b/js/app/packages/block-channel/component/MessageList/MessageList.tsxindex b79631bd90..81da86dc04 100644--- a/js/app/packages/block-channel/component/MessageList/MessageList.tsx+++ b/js/app/packages/block-channel/component/MessageList/MessageList.tsx@@ -59,7 +59,7 @@ false && observedSize;type ThreadRow = {id: string;message: Message;- children: Message[];+ children: Accessor<Message[]>;};type MessageListItemProps = {@@ -659,7 +659,8 @@ function MessageListImpl(props: MessageListProps) {const threadRows = mapArray(() => filteredTopLevelMessages().toReversed(),(message) => {- const children = (viewThreads[message.id] ?? []).filter(messageFilterFn);+ const children = () =>+ (viewThreads[message.id] ?? []).filter(messageFilterFn);return { id: message.id, message, children };});@@ -881,7 +882,7 @@ function MessageListImpl(props: MessageListProps) {const ThreadRowItem = (rowProps: { row: ThreadRow }) => {const row = () => rowProps.row;- const threadChildren = () => row().children;+ const threadChildren = () => row().children();const threadState = createMemo(() =>listContext.getThreadState(row().message.id));diff --git a/js/app/packages/block-channel/hooks/channel.tsx b/js/app/packages/block-channel/hooks/channel.tsxindex 912ccefaf4..e8eda25108 100644--- a/js/app/packages/block-channel/hooks/channel.tsx+++ b/js/app/packages/block-channel/hooks/channel.tsx@@ -1,5 +1,5 @@import { createAssertedContextProvider } from '@core/context/createContext';-import { useChannelQuery } from '@queries/channel/channel';+import type { useChannelQuery } from '@queries/channel/channel';import {getThreadMessages,getTopLevelMessages,@@ -27,15 +27,14 @@ type ChannelContextValue = {};type ChannelContextProps = {- channelId: Accessor<string>;+ query: ReturnType<typeof useChannelQuery>;};export const [ChannelContextProvider, useChannelContext] =createAssertedContextProvider<ChannelContextValue>('ChannelContext',(props: ChannelContextProps): ChannelContextValue => {- const channelQuery = useChannelQuery(props.channelId);- const channel = createMemo(() => channelQuery.data);+ const channel = createMemo(() => props.query.data);const channelType = createMemo(() => channel().channel.channel_type);const channelName = createMemo(() => channel().channel.name ?? '');const messages = createMemo(() => getTopLevelMessages(channel()));diff --git a/js/app/packages/core/component/LexicalMarkdown/utils.ts b/js/app/packages/core/component/LexicalMarkdown/utils.tsindex 0cade17300..c4242cf179 100644--- a/js/app/packages/core/component/LexicalMarkdown/utils.ts+++ b/js/app/packages/core/component/LexicalMarkdown/utils.ts@@ -29,6 +29,7 @@ import {INTERNAL_TRANSFORMERS,} from '@lexical-core';import {+ $addUpdateTag,$createParagraphNode,$createRangeSelection,$createTextNode,@@ -63,6 +64,7 @@ import {type SerializedEditorState,type SerializedLexicalNode,type SerializedParagraphNode,+ SKIP_DOM_SELECTION_TAG,type TextNode,} from 'lexical';import type { Setter } from 'solid-js';@@ -236,6 +238,7 @@ export function initializeEditorEmpty(peerId?: () => string | undefined) {editor.update(() => {+ $addUpdateTag(SKIP_DOM_SELECTION_TAG);const root = $getRoot();root.clear();root.append($createParagraphNode().append($createTextNode('')));@@ -345,9 +348,15 @@ export function setEditorStateFromMarkdown(const transformers = weakTransformersByEditor.get(editor)![target];if (!inUpdate) {- editor.update(() =>- $convertFromMarkdownString(markdown, transformers, node, preserveNewLines)- );+ editor.update(() => {+ $addUpdateTag(SKIP_DOM_SELECTION_TAG);+ $convertFromMarkdownString(+ markdown,+ transformers,+ node,+ preserveNewLines+ );+ });editor.read(() => {});return editor.getEditorState();} else {