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(web): key recent channel rows by entity id (#6099)

Sean Ayecef28734807e
diff --git a/apps/web/src/features/channel/sidebar/channels-recent-widget.tsx b/apps/web/src/features/channel/sidebar/channels-recent-widget.tsx
index 01ad1b194f..7337a2748e 100644
--- a/apps/web/src/features/channel/sidebar/channels-recent-widget.tsx
+++ b/apps/web/src/features/channel/sidebar/channels-recent-widget.tsx
@@ -35,6 +35,7 @@ import {
import { getChannelNotificationParams } from '@notifications/notification-navigation';
import type { UnifiedNotification } from '@notifications/types';
import { useSoupAstItemsQuery } from '@queries/soup/items';
+import { Key } from '@solid-primitives/keyed';
import { makePersisted } from '@solid-primitives/storage';
import { cn, NavRow, Surface, ToggleSwitch, Tooltip } from '@ui';
import {
@@ -511,14 +512,14 @@ export const ChannelsRecentWidget = (props: {
lastUserScrollAt = Date.now();
}}
>
- <For each={visibleChannels()}>
+ <Key each={visibleChannels()} by={(channel) => channel.entity.id}>
{(channel) => (
<ChannelRow
- channel={channel}
+ channel={channel()}
onFloatingOpenChange={props.onDropdownOpenChange}
/>
)}
- </For>
+ </Key>
<Show when={showAllCaughtUp()}>
<div class="flex h-7 w-full items-center gap-2 px-2 py-1 text-sm font-medium text-ink-extra-muted/60">
<span class="truncate">All caught up</span>
@@ -549,9 +550,9 @@ export const ChannelsRecentWidget = (props: {
fallback={
<Show when={slimVisible().length > 0}>
<section class="w-full py-1.5 flex flex-col items-start gap-0.5">
- <For each={slimVisible()}>
- {(channel) => <ChannelRow channel={channel} isSlim />}
- </For>
+ <Key each={slimVisible()} by={(channel) => channel.entity.id}>
+ {(channel) => <ChannelRow channel={channel()} isSlim />}
+ </Key>
<Show when={slimOverflow() > 0}>
<span class="w-full text-center text-xxs text-ink-muted mt-1">
+{slimOverflow()}
diff --git a/apps/web/src/lib/queries/soup/backfill.test.tsx b/apps/web/src/lib/queries/soup/backfill.test.tsx
index 13b7d29dbc..57df9be045 100644
--- a/apps/web/src/lib/queries/soup/backfill.test.tsx
+++ b/apps/web/src/lib/queries/soup/backfill.test.tsx
@@ -213,9 +213,8 @@ describe('runSoupBackfills', () => {
rendered.unmount();
});
- it('retries cache-host lookup after it was initially unavailable', async () => {
- const [isLeader, setIsLeader] = createSignal(true);
- leaderMocks.createTabLeaderSignal.mockReturnValue(isLeader);
+ it('starts when only the cache host becomes available', async () => {
+ vi.useFakeTimers();
let cacheHost: object | undefined;
graphqlMocks.getGraphqlSoupCacheHost.mockImplementation(() => cacheHost);
graphqlMocks.hydrateGraphqlSoup.mockResolvedValue({ nextCursor: null });
@@ -225,12 +224,10 @@ describe('runSoupBackfills', () => {
expect(graphqlMocks.hydrateGraphqlSoup).not.toHaveBeenCalled();
cacheHost = {};
- setIsLeader(false);
- setIsLeader(true);
+ await vi.advanceTimersByTimeAsync(100);
- await vi.waitFor(() =>
- expect(graphqlMocks.hydrateGraphqlSoup).toHaveBeenCalled()
- );
+ expect(graphqlMocks.getGraphqlSoupCacheHost).toHaveBeenCalledTimes(2);
+ expect(graphqlMocks.hydrateGraphqlSoup).toHaveBeenCalled();
rendered.unmount();
});
diff --git a/apps/web/src/lib/queries/soup/backfill.ts b/apps/web/src/lib/queries/soup/backfill.ts
index 9ff65ae524..7d6dd1e167 100644
--- a/apps/web/src/lib/queries/soup/backfill.ts
+++ b/apps/web/src/lib/queries/soup/backfill.ts
@@ -29,6 +29,8 @@ const EMAIL_CONTENT_PAGE_LIMIT = 5;
const PAGE_DELAY_MS = 2_000;
const BACKFILL_RETRY_COUNT = 5;
const BACKFILL_RETRY_SCHEDULE = Schedule.exponential('1 second');
+const CACHE_HOST_RETRY_COUNT = 6;
+const CACHE_HOST_RETRY_SCHEDULE = Schedule.exponential('100 millis');
const BACKFILL_PROGRESS_PAGE_INTERVAL = 10;
const EXCLUDED_ENTITY_ID = '00000000-0000-0000-0000-000000000000';
@@ -469,9 +471,21 @@ export const runSoupBackfills = Effect.fn('runSoupBackfills')(function* (
);
});
+const waitForGraphqlSoupCacheHost = Effect.suspend(() =>
+ getGraphqlSoupCacheHost() === undefined
+ ? Effect.fail('cache-host-unavailable' as const)
+ : Effect.void
+).pipe(
+ Effect.retry({
+ times: CACHE_HOST_RETRY_COUNT,
+ schedule: CACHE_HOST_RETRY_SCHEDULE,
+ })
+);
+
/**
* Runs the checkpointed backfill Effect while this tab owns leadership.
- * Interrupting the fiber cancels the active fetch or inter-page sleep.
+ * Interrupting the fiber cancels cache readiness waits, active fetches, and
+ * inter-page sleeps.
*/
export function useSoupBackfills(userId: string): void {
const graphqlSoupFlag = useFeatureFlag(ENABLE_GRAPHQL_SOUP_FLAG, {
@@ -482,18 +496,16 @@ export function useSoupBackfills(userId: string): void {
);
createEffect(() => {
- // Read reactive gates before the non-reactive cache-host lookup so a host
- // that becomes available after flag loading or leader election is retried.
- if (
- !ENABLE_GRAPHQL_BACKFILL ||
- !graphqlSoupFlag().enabled ||
- !isLeader() ||
- getGraphqlSoupCacheHost() === undefined
- ) {
+ if (!ENABLE_GRAPHQL_BACKFILL || !graphqlSoupFlag().enabled || !isLeader()) {
return;
}
- const fiber = Effect.runFork(runSoupBackfills(userId));
+ const fiber = Effect.runFork(
+ waitForGraphqlSoupCacheHost.pipe(
+ Effect.flatMap(() => runSoupBackfills(userId)),
+ Effect.ignore
+ )
+ );
onCleanup(() => {
Effect.runFork(Fiber.interrupt(fiber));
});