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(comments): stop starting a comment from remounting the document (#6952)
gbirman057ba62a5b74
diff --git a/apps/web/AGENTS.md b/apps/web/AGENTS.mdindex 42eaf27f7a..d8618a5371 100644--- a/apps/web/AGENTS.md+++ b/apps/web/AGENTS.md@@ -72,7 +72,7 @@ Then trigger the interaction and read `window.__inst.log`. `'1,2,3' → '' → '- Prefer wrapping the setter over `createEffect(() => { if (signal()) sideEffect() })`. When setting focus/selection should also clear another stop, blur a control, or scroll, put that work in the setter (or a named helper the setter calls) so the action is explicit at the call site — not a distant effect watching the signal.- Use createMemo only when you need referential stability or the derivation is expensive. Cheap derivations (() => a() + b()) don't need it regardless of subscriber count.- Before rolling your own reactive utility, check solid-primitives first.-- Never read a solid-query `query.data` unguarded from a component body or an eager `createMemo`. `data` is a resource read: while the query is pending it suspends the caller's nearest `<Suspense>`, which detaches and re-attaches that whole subtree — a blank flash, lost scroll position, remounted editors. Gate the read on status (`query.isSuccess ? query.data : fallback`, or check `isPending`/`isLoading` first); every other field is a plain store read and is safe. Remember `createMemo` runs immediately, so a guard inside a `<Show>`/`<Match>` further down does not save you. This has blanked the calendar grid twice — see `focusTarget` in `src/features/block-calendar/CalendarBlockAdapter.tsx` and `useSystemSkillsQuery`.+- Never read a solid-query `query.data` unguarded from a component body or an eager `createMemo`. `data` is a resource read: while the query is pending it suspends the caller's nearest `<Suspense>`, which detaches and re-attaches that whole subtree — a blank flash, lost scroll position, remounted editors. Gate the read on status (`query.isSuccess ? query.data : fallback`, or `queryReadyGate` from `src/lib/queries/gate.ts`); an `isLoading` check is not enough, because a disabled or paused query is pending without loading and its data read still suspends. Every other field is a plain store read and is safe. Remember `createMemo` runs immediately, so a guard inside a `<Show>`/`<Match>` further down does not save you. This has blanked the calendar grid twice — see `focusTarget` in `src/features/block-calendar/CalendarBlockAdapter.tsx` and `useSystemSkillsQuery`.## UI / Components- Prefer composition over configurability. Follow slot-based patterns (see src/features/channel, src/features/entity, or Kobalte).diff --git a/apps/web/src/features/block-md/component/Notebook.tsx b/apps/web/src/features/block-md/component/Notebook.tsxindex 51ea2ffb48..3332f090d2 100644--- a/apps/web/src/features/block-md/component/Notebook.tsx+++ b/apps/web/src/features/block-md/component/Notebook.tsx@@ -300,7 +300,9 @@ export function Notebook(props: {const contentDivClasses = createMemo(() => {const mode = layoutMode();- const shared = 'grow max-w-3xl pt-12 touch:pt-6 min-w-0';+ // A zero basis keeps WebKit from sizing the column by the max-content width+ // of its text, which it recomputes slowly for long unbroken runs.+ const shared = 'grow basis-0 max-w-3xl pt-12 touch:pt-6 min-w-0';switch (mode) {case CommentLayoutMode.lg:return `${shared} mx-auto`;diff --git a/apps/web/src/features/channel/use-channel-participants.test.tsx b/apps/web/src/features/channel/use-channel-participants.test.tsxnew file mode 100644index 0000000000..c7cc336e4f--- /dev/null+++ b/apps/web/src/features/channel/use-channel-participants.test.tsx@@ -0,0 +1,81 @@+import { storageServiceClient } from '@service-storage/client';+import { cleanup, render, screen, waitFor } from '@solidjs/testing-library';+import { QueryClient, QueryClientProvider } from '@tanstack/solid-query';+import { ok } from 'neverthrow';+import { Suspense } from 'solid-js';+import { afterEach, describe, expect, it, vi } from 'vitest';+import { useChannelParticipants } from './use-channel-participants';++vi.mock('@queries/client', () => ({ queryClient: {} }));+vi.mock('@service-storage/client', () => ({+ storageServiceClient: { getChannelParticipants: vi.fn() },+}));++const clients: QueryClient[] = [];+afterEach(() => {+ cleanup();+ for (const client of clients.splice(0)) client.clear();+ vi.clearAllMocks();+});++function mount(channelId: string) {+ const client = new QueryClient({+ defaultOptions: { queries: { retry: false } },+ });+ clients.push(client);+ function View() {+ const participants = useChannelParticipants(() => channelId);+ return (+ <div data-testid="content">+ {participants+ .users()+ .map((user) => user.id)+ .join(',')}+ |{participants.ids().join(',')}+ </div>+ );+ }+ render(() => (+ <QueryClientProvider client={client}>+ <Suspense fallback={<div data-testid="suspended" />}>+ <View />+ </Suspense>+ </QueryClientProvider>+ ));+}++function expectContent(text: string) {+ expect(screen.queryByTestId('suspended')).toBeNull();+ expect(screen.getByTestId('content').textContent).toBe(text);+}++describe('useChannelParticipants', () => {+ it('does not suspend without a channel, as on a document composer', () => {+ mount('');+ expectContent('|');+ expect(storageServiceClient.getChannelParticipants).not.toHaveBeenCalled();+ });++ it('lists the participants once they load, without suspending', async () => {+ const response =+ Promise.withResolvers<+ Awaited<ReturnType<typeof storageServiceClient.getChannelParticipants>>+ >();+ vi.mocked(storageServiceClient.getChannelParticipants).mockReturnValue(+ response.promise+ );+ mount('channel-1');+ expectContent('|');+ response.resolve(+ ok([+ {+ channel_id: 'channel-1',+ joined_at: '2026-09-24T12:00:00Z',+ role: 'member',+ user_id: 'macro|[email protected]',+ },+ ])+ );+ await waitFor(() => expectContent('macro|[email protected]|macro|[email protected]'));+ });+});diff --git a/apps/web/src/features/channel/use-channel-participants.ts b/apps/web/src/features/channel/use-channel-participants.tsindex 25383aef69..a93ab25ea3 100644--- a/apps/web/src/features/channel/use-channel-participants.ts+++ b/apps/web/src/features/channel/use-channel-participants.ts@@ -1,6 +1,7 @@import type { IUser } from '@core/user/types';import { channelParticipantInfo } from '@core/user/util';import { useChannelParticipantsQuery } from '@queries/channel/channel-participants';+import { queryReadyGate } from '@queries/gate';import { type Accessor, createMemo } from 'solid-js';export type ChannelParticipantsData = {@@ -13,13 +14,13 @@ export function useChannelParticipants(const query = useChannelParticipantsQuery(channelId);const users = createMemo(() => {- if (query.isLoading) return [];- return (query.data ?? []).map(channelParticipantInfo);+ if (!queryReadyGate(query)) return [];+ return query.data.map(channelParticipantInfo);});const ids = createMemo(() => {- if (query.isLoading) return [];- return (query.data ?? []).map((p) => p.user_id);+ if (!queryReadyGate(query)) return [];+ return query.data.map((p) => p.user_id);});return { users, ids };