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(channels): gate query reads until ready (#6493)

Peter Chinman0db2322912cc
diff --git a/apps/web/src/features/channel/Channel/Channel.tsx b/apps/web/src/features/channel/Channel/Channel.tsx
index 53a88dc636..b07b429f6a 100644
--- a/apps/web/src/features/channel/Channel/Channel.tsx
+++ b/apps/web/src/features/channel/Channel/Channel.tsx
@@ -68,6 +68,7 @@ import {
import { threadRepliesQueryOptions } from '@queries/channel/thread-replies';
import { usePostTypingUpdateMutation } from '@queries/channel/typing';
import { queryClient } from '@queries/client';
+import { queryReadyGate } from '@queries/gate';
import { ChannelTypeEnum } from '@service-storage/client';
import { useBeforeLeave } from '@solidjs/router';
import {
@@ -237,8 +238,11 @@ export function Channel(props: ChannelProps) {
)
);
- const messageIndex = createMessageIndex(
- () => messagesQuery.data as ChannelMessagesData | undefined
+ // The index reads immediately, before EntityLoadGate's boundary exists.
+ const messageIndex = createMessageIndex(() =>
+ queryReadyGate(messagesQuery)
+ ? (messagesQuery.data as ChannelMessagesData)
+ : undefined
);
const messages = createMemo(() => [...messageIndex.items]);
diff --git a/apps/web/src/features/channel/Thread/ChannelThread.tsx b/apps/web/src/features/channel/Thread/ChannelThread.tsx
index d2d09746b3..7dcbb34b48 100644
--- a/apps/web/src/features/channel/Thread/ChannelThread.tsx
+++ b/apps/web/src/features/channel/Thread/ChannelThread.tsx
@@ -4,6 +4,7 @@ import { isTouchDevice } from '@core/mobile/isTouchDevice';
import { getDisplayName, tryMacroId } from '@core/user';
import { MarkMessageNotifications } from '@notifications/components/MarkMessageNotifications';
import { useThreadRepliesQuery } from '@queries/channel/thread-replies';
+import { queryReadyGate } from '@queries/gate';
import type { ApiThreadReply } from '@service-storage/generated/schemas/apiThreadReply';
import {
createEffect,
@@ -68,8 +69,7 @@ export function ChannelThread(props: ThreadProps) {
);
const queryReplies = (): Array<ApiThreadReply> | undefined => {
- if (repliesQuery.isLoading) return undefined;
- return repliesQuery.data;
+ return queryReadyGate(repliesQuery) ? repliesQuery.data : undefined;
};
const loadedReplies = () => queryReplies() ?? [];
diff --git a/apps/web/src/features/channel/use-channel-bot-mention-users.ts b/apps/web/src/features/channel/use-channel-bot-mention-users.ts
index 94bd634821..d1f84481b2 100644
--- a/apps/web/src/features/channel/use-channel-bot-mention-users.ts
+++ b/apps/web/src/features/channel/use-channel-bot-mention-users.ts
@@ -5,6 +5,7 @@ import { useAgentsQuery } from '@queries/agents/agents';
import { useCodexStatusQuery } from '@queries/auth/codex';
import { useCursorApiKeyStatusQuery } from '@queries/auth/cursor-api-key';
import { useChannelBotsQuery } from '@queries/channel/channel-bots';
+import { queryReadyGate } from '@queries/gate';
import type { Agent } from '@service-storage/generated/schemas/agent';
import type { Bot } from '@service-storage/generated/schemas/bot';
import { type Accessor, createMemo } from 'solid-js';
@@ -71,9 +72,9 @@ export function useChannelBotMentionUsers(
return createMemo(() =>
availableBotMentionUsers(
- channelBots.isSuccess ? channelBots.data : [],
- agents.isSuccess ? agents.data : [],
- cursorStatus.isSuccess ? cursorStatus.data.registered : false,
+ queryReadyGate(channelBots) ? channelBots.data : [],
+ queryReadyGate(agents) ? agents.data : [],
+ queryReadyGate(cursorStatus) ? cursorStatus.data.registered : false,
canUseCodex() &&
codexStatus.isSuccess &&
codexStatus.data.connected &&
diff --git a/docs/AGENT_GUIDE/channels.md b/docs/AGENT_GUIDE/channels.md
index 9f5c85f0ff..4fad718922 100644
--- a/docs/AGENT_GUIDE/channels.md
+++ b/docs/AGENT_GUIDE/channels.md
@@ -215,6 +215,11 @@ A touch tap leaves pending navigation intact; a vertical finger drag cancels it.
The `[data-channel-scroll]` element is the scroll surface. Its virtualized rows are
keyed by message ID; offscreen rows are normally absent from the DOM.
+On a cold channel open, verify that delayed bot/agent mention requests leave the
+messages and composer visible. Expand a thread while its replies are still
+loading: existing preview replies should remain visible until the full list
+arrives. Repeat after reopening the channel to cover both cold and cached data.
+
Reopening a channel already loaded this session requests
`GET /dss/channels/<id>/messages/catch-up?after=<newest cached created_at>&limit=50`
and merges the result into the cached first page. A first open, a message link,