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(tasks): keep paginated project rows visible during refresh (#8630)

gbirman28ff8122b4a3
diff --git a/apps/web/AGENTS.md b/apps/web/AGENTS.md
index f0a3df3393..a7aa5a0879 100644
--- a/apps/web/AGENTS.md
+++ b/apps/web/AGENTS.md
@@ -199,7 +199,9 @@ ownership. Cancel, logout, and the ten-minute timeout retire pending callbacks.
continuation pages plus their local predicate projection. Group readers only
delegate paging; pass the parent's live `groupedPaging` accessor from every
caller, including Tasks and project-task lists. Do not introduce independent
- continuation owners. Keep server
+ continuation owners. Rebuild refreshed continuation chains before replacing
+ loaded rows; retain them on refresh failure and discard them on scope changes.
+ Keep server
membership snapshots separate from normalized field/link updates; restored
properties do not prove prior membership. Supply complete prior multi-value
memberships when adjusting counts: a row loaded in one bin may already be an
diff --git a/apps/web/docs/graphql-normalized-cache-plan.md b/apps/web/docs/graphql-normalized-cache-plan.md
index e38c34a9fb..48fb93c0c2 100644
--- a/apps/web/docs/graphql-normalized-cache-plan.md
+++ b/apps/web/docs/graphql-normalized-cache-plan.md
@@ -776,7 +776,13 @@ separate date-grouping policy.
Server membership evidence is captured separately from normalized field/link
updates, and local evaluation waits for network persistence. Filter/account/cache
generation changes discard old local evidence and continuation owners. Initial
-network refreshes restart continuation coverage. Group readers delegate paging
+network refreshes rebuild each loaded continuation chain from its new cursor,
+retaining the previous owner until all previously loaded pages are ready (or the
+server ends the chain). Failed replacements leave the old rows available and
+report the paging error; explicit refresh waits for these replacements. A group
+whose fresh initial page has no cursor drops obsolete continuations immediately.
+The `graphql_cache.soup_grouped_refresh` span records the loaded page count and
+replacement outcome. Group readers delegate paging
to this owner, so moving a continuation row cannot leave a second copy behind.
The initial cursor remains baseline metadata; paging follows the last loaded
server continuation, never a locally fabricated cursor.
diff --git a/apps/web/src/features/tasks-view/queries/use-tasks-query.ts b/apps/web/src/features/tasks-view/queries/use-tasks-query.ts
index 2b1dfda173..c16aa35f80 100644
--- a/apps/web/src/features/tasks-view/queries/use-tasks-query.ts
+++ b/apps/web/src/features/tasks-view/queries/use-tasks-query.ts
@@ -449,7 +449,7 @@ export function useTasksDataSource(
await search.refetch();
return;
}
- groupedQueries.resetToInitialPage();
+ if (query.transport !== 'graphql') groupedQueries.resetToInitialPage();
await query.refresh();
};
diff --git a/apps/web/src/lib/queries/soup/graphql/create-grouped-soup-live-query.test.ts b/apps/web/src/lib/queries/soup/graphql/create-grouped-soup-live-query.test.ts
index 95853ac04b..8ab72d2229 100644
--- a/apps/web/src/lib/queries/soup/graphql/create-grouped-soup-live-query.test.ts
+++ b/apps/web/src/lib/queries/soup/graphql/create-grouped-soup-live-query.test.ts
@@ -1,11 +1,12 @@
import {
type Client,
+ CombinedError,
type GraphQLRequest,
makeOperation,
type OperationContext,
type OperationResult,
} from '@urql/core';
-import { createRoot, createSignal } from 'solid-js';
+import { createComputed, createRoot, createSignal } from 'solid-js';
import { afterEach, describe, expect, it, vi } from 'vitest';
import { makeSubject } from 'wonka';
import { createNoopCacheHost } from '../../../graphql-cache/host/noop-host';
@@ -36,7 +37,12 @@ vi.mock('../../../service-clients/service-storage/graphql-soup', () => ({
}));
vi.mock('@macro-inc/observability', () => ({
Telemetry: {
- span: () => ({ setAttr: vi.fn(), end: vi.fn() }),
+ span: () => ({
+ setAttr: vi.fn(),
+ error: vi.fn(),
+ end: vi.fn(),
+ run: (operation: () => unknown) => operation(),
+ }),
error: vi.fn(),
},
}));
@@ -47,7 +53,7 @@ afterEach(() => {
});
function setup() {
- const executions: Array<{
+ type Execution = {
variables: GroupSoupQueryVariables;
publish(
data: GroupSoupQuery,
@@ -57,7 +63,10 @@ function setup() {
| 'normalized-cache-hit'
| 'normalized-cache-patch'
): void;
- }> = [];
+ fail(): void;
+ };
+ const executions: Execution[] = [];
+ const waiting = new Map<number, (execution: Execution) => void>();
const client = {
executeQuery(
request: GraphQLRequest<GroupSoupQuery, GroupSoupQueryVariables>,
@@ -70,7 +79,7 @@ function setup() {
requestPolicy: 'cache-first',
...context,
});
- executions.push({
+ const execution: Execution = {
variables: request.variables,
publish: (data, persistence, source = 'live-network') =>
subject.next({
@@ -82,7 +91,16 @@ function setup() {
__macroNormalizedCache: { source, persistence },
},
}),
- });
+ fail: () =>
+ subject.next({
+ operation,
+ error: new CombinedError({ networkError: new Error('Offline') }),
+ hasNext: false,
+ stale: false,
+ }),
+ };
+ executions.push(execution);
+ waiting.get(executions.length - 1)?.(execution);
return subject.source;
},
} as Client;
@@ -143,7 +161,17 @@ function setup() {
);
return { query, setInput, dispose };
});
- return { ...state, executions, requests, listeners, generations };
+ return {
+ ...state,
+ executions,
+ requests,
+ listeners,
+ generations,
+ execution: (index: number): Promise<Execution> =>
+ executions[index]
+ ? Promise.resolve(executions[index])
+ : new Promise((resolve) => waiting.set(index, resolve)),
+ };
}
function page(
@@ -190,6 +218,188 @@ const ids = (data: GroupSoupQuery | undefined) =>
}));
describe('grouped Soup live ownership', () => {
+ it('does not refetch a continuation started automatically during the initial result', async () => {
+ const state = setup();
+ createRoot((dispose) => {
+ cleanups.push(dispose);
+ createAutomaticTaskPagination({
+ enabled: () => true,
+ scope: () => 'project',
+ sources: () => [
+ {
+ id: 'todo',
+ hasMore: state.query.paging.hasNextPage('todo'),
+ pending: state.query.paging.isFetchingNextPage('todo'),
+ load: () => state.query.paging.fetchNextPage('todo'),
+ error: () => state.query.paging.error('todo'),
+ },
+ ],
+ });
+ });
+ state.executions[0].publish(page([groupedDocument('a')]));
+ state.executions[1].publish(page([groupedDocument('b')], null));
+ await state.query.paging.fetchNextPage('todo');
+ expect(ids(state.query.data())?.[0].ids).toEqual(['a', 'b']);
+ expect(state.query.paging.isFetchingNextPage('todo')).toBe(false);
+ expect(state.executions).toHaveLength(2);
+ });
+
+ it('keeps all eleven rows mounted while refreshing the continuation', async () => {
+ const state = setup();
+ const initial = page(
+ Array.from({ length: 10 }, (_, i) => groupedDocument(`task-${i + 1}`))
+ );
+ initial.user.groupSoup.bins[0].totalCount = 11;
+ state.executions[0].publish(initial);
+ const next = state.query.paging.fetchNextPage('todo');
+ const last = page([groupedDocument('task-11')], null);
+ last.user.groupSoup.bins[0].totalCount = 11;
+ state.executions[1].publish(last);
+ await next;
+ const counts: number[] = [];
+ createRoot((dispose) => {
+ cleanups.push(dispose);
+ createComputed(() => {
+ counts.push(
+ state.query.data()?.user.groupSoup.bins[0].items.length ?? 0
+ );
+ });
+ });
+
+ state.executions[0].publish(initial);
+ expect(ids(state.query.data())?.[0].ids).toHaveLength(11);
+ expect(state.query.paging.isFetchingNextPage('todo')).toBe(true);
+ const refreshed = state.query.paging.fetchNextPage('todo');
+ state.executions[2].publish(last);
+ await refreshed;
+ expect(counts.every((count) => count === 11)).toBe(true);
+ expect(state.query.paging.hasNextPage('todo')).toBe(false);
+ expect(ids(state.query.data())?.[0].count).toBe(11);
+ });
+
+ it('rebuilds changed cursors through every loaded page before replacing rows', async () => {
+ const state = setup();
+ state.executions[0].publish(page([groupedDocument('a')]));
+ const second = state.query.paging.fetchNextPage('todo');
+ state.executions[1].publish(page([groupedDocument('b')], 'third'));
+ await second;
+ const third = state.query.paging.fetchNextPage('todo');
+ state.executions[2].publish(page([groupedDocument('c')], null));
+ await third;
+
+ state.executions[0].publish(page([groupedDocument('a')], 'new-second'));
+ const refreshed = state.query.paging.fetchNextPage('todo');
+ expect(state.executions[3].variables.input.continuation?.cursor).toBe(
+ 'new-second'
+ );
+ state.executions[3].publish(page([groupedDocument('new-b')], 'new-third'));
+ const last = await state.execution(4);
+ expect(last.variables.input.continuation?.cursor).toBe('new-third');
+ expect(ids(state.query.data())?.[0].ids).toEqual(['a', 'b', 'c']);
+ last.publish(page([groupedDocument('new-c')], null));
+ await refreshed;
+ expect(ids(state.query.data())?.[0].ids).toEqual(['a', 'new-b', 'new-c']);
+ expect(state.query.paging.hasNextPage('todo')).toBe(false);
+ });
+
+ it('retains a page whose load-more request was in flight when refresh started', async () => {
+ const state = setup();
+ state.executions[0].publish(page([groupedDocument('a')]));
+ const second = state.query.paging.fetchNextPage('todo');
+ state.executions[1].publish(page([groupedDocument('b')], 'third'));
+ await second;
+ const third = state.query.paging.fetchNextPage('todo');
+ state.executions[0].publish(page([groupedDocument('a')], 'new-second'));
+ const refresh = state.query.paging.fetchNextPage('todo');
+ state.executions[2].publish(page([groupedDocument('c')], null));
+ await third;
+ (await state.execution(3)).publish(
+ page([groupedDocument('new-b')], 'new-third')
+ );
+ const last = await state.execution(4);
+ expect(ids(state.query.data())?.[0].ids).toEqual(['a', 'b', 'c']);
+ last.publish(page([groupedDocument('new-c')], null));
+ await refresh;
+ expect(ids(state.query.data())?.[0].ids).toEqual(['a', 'new-b', 'new-c']);
+ });
+
+ it('keeps the loaded chain on a later-page failure and replaces it on retry', async () => {
+ const state = setup();
+ state.executions[0].publish(page([groupedDocument('a')]));
+ const second = state.query.paging.fetchNextPage('todo');
+ state.executions[1].publish(page([groupedDocument('b')], 'third'));
+ await second;
+ const third = state.query.paging.fetchNextPage('todo');
+ state.executions[2].publish(page([groupedDocument('c')], null));
+ await third;
+
+ const refresh = state.query.refresh();
+ const failure = expect(refresh).rejects.toThrow('Offline');
+ state.executions[3].publish(page([groupedDocument('a')], 'new-second'));
+ state.executions[4].publish(page([groupedDocument('new-b')], 'new-third'));
+ (await state.execution(5)).fail();
+ await failure;
+ expect(ids(state.query.data())?.[0].ids).toEqual(['a', 'b', 'c']);
+ expect(state.query.paging.error('todo')?.message).toContain('Offline');
+ expect(state.query.paging.isFetchingNextPage('todo')).toBe(false);
+
+ const retry = state.query.refresh();
+ state.executions[6].publish(page([groupedDocument('a')], 'retry'));
+ state.executions[7].publish(page([groupedDocument('replacement')], null));
+ await retry;
+ expect(ids(state.query.data())?.[0].ids).toEqual(['a', 'replacement']);
+ expect(state.query.paging.error('todo')).toBeNull();
+ });
+
+ it('drops obsolete rows when the refreshed initial page covers the whole group', async () => {
+ const state = setup();
+ state.executions[0].publish(page([groupedDocument('a')]));
+ const next = state.query.paging.fetchNextPage('todo');
+ state.executions[1].publish(page([groupedDocument('removed')], null));
+ await next;
+ state.executions[0].publish(page([groupedDocument('a')], null));
+ expect(ids(state.query.data())?.[0].ids).toEqual(['a']);
+ expect(state.query.paging.hasNextPage('todo')).toBe(false);
+ expect(state.executions).toHaveLength(2);
+ });
+
+ it('discards an in-flight replacement when the project filter changes', async () => {
+ const state = setup();
+ state.executions[0].publish(page([groupedDocument('a')]));
+ const next = state.query.paging.fetchNextPage('todo');
+ state.executions[1].publish(page([groupedDocument('b')], null));
+ await next;
+ state.executions[0].publish(page([groupedDocument('a')]));
+ const refresh = state.query.paging.fetchNextPage('todo');
+ state.setInput({
+ initial: {
+ sortMethod: 'UPDATED_AT',
+ groupBy: { field: 'PROJECT' },
+ filters: {},
+ },
+ });
+ state.executions[3].publish(page([groupedDocument('new-project')], null));
+ await refresh;
+ state.executions[2].publish(page([groupedDocument('obsolete')], null));
+ expect(ids(state.query.data())?.[0].ids).toEqual(['new-project']);
+ expect(state.query.paging.isFetchingNextPage('todo')).toBe(false);
+ });
+
+ it('does not restart continuation requests for normalized property updates', async () => {
+ const state = setup();
+ state.executions[0].publish(page([groupedDocument('a')]));
+ const next = state.query.paging.fetchNextPage('todo');
+ state.executions[1].publish(page([groupedDocument('b')], null));
+ await next;
+ state.executions[0].publish(
+ page([{ ...groupedDocument('a'), displayName: 'Renamed' }]),
+ undefined,
+ 'normalized-cache-patch'
+ );
+ expect(ids(state.query.data())?.[0].ids).toEqual(['a', 'b']);
+ expect(state.executions).toHaveLength(2);
+ });
+
it('clears grouping before an initial result without reading missing data', () => {
const state = setup();
state.setInput(undefined);
@@ -405,3 +615,5 @@ describe('grouped Soup live ownership', () => {
expect(state.query.paging.hasNextPage('todo')).toBe(true);
});
});
+
+import { createAutomaticTaskPagination } from '@app/features/tasks-view/queries/automatic-task-pagination';
diff --git a/apps/web/src/lib/queries/soup/graphql/create-grouped-soup-live-query.ts b/apps/web/src/lib/queries/soup/graphql/create-grouped-soup-live-query.ts
index ce0084347c..d9fc4cc75f 100644
--- a/apps/web/src/lib/queries/soup/graphql/create-grouped-soup-live-query.ts
+++ b/apps/web/src/lib/queries/soup/graphql/create-grouped-soup-live-query.ts
@@ -1,8 +1,10 @@
import { createUrqlInfiniteQuery, createUrqlQuery } from '@app/lib/urql-solid';
+import { fireAndForget } from '@core/util/fireAndForget';
import { Telemetry } from '@macro-inc/observability';
import type { OperationResult } from '@urql/core';
import {
type Accessor,
+ batch,
createComputed,
createEffect,
createMemo,
@@ -75,7 +77,8 @@ export function createGroupedSoupLiveQuery(
);
const scope = () => JSON.stringify([input(), generation()]);
const initialEvidence = createGroupedPageEvidence(scope);
- let resetContinuations = () => {};
+ let initialResultScope: string | undefined;
+ let refreshContinuations = (_data: GroupSoupQuery) => {};
const query = createUrqlQuery<
GroupSoupQuery,
GroupSoupQueryVariables,
@@ -95,13 +98,20 @@ export function createGroupedSoupLiveQuery(
result: OperationResult<GroupSoupQuery, GroupSoupQueryVariables>
) => {
if (scope() !== requestScope) return;
- if (
- result.data &&
- !result.error &&
- !result.hasNext &&
- normalizedCacheResultMetadata(result)?.source === 'live-network'
- )
- resetContinuations();
+ if (result.data && !result.error && !result.hasNext) {
+ const resultScope = JSON.stringify([
+ requestScope,
+ result.data.user.id,
+ ]);
+ // Auto-pagination can start during the query's first data emission,
+ // before onResult runs. That first response has no old chain to refresh.
+ if (
+ initialResultScope === resultScope &&
+ normalizedCacheResultMetadata(result)?.source === 'live-network'
+ )
+ refreshContinuations(result.data);
+ initialResultScope = resultScope;
+ }
initialEvidence.accept(result, 0, requestScope);
queryOptions.onInitialResult(result);
},
@@ -126,7 +136,8 @@ export function createGroupedSoupLiveQuery(
const createContinuation = (
key: string,
cursor: string,
- initial: GroupedSoupInput
+ initial: GroupedSoupInput,
+ refresh = false
) =>
createRoot((dispose) => {
const requestScope = continuationScope();
@@ -161,7 +172,11 @@ export function createGroupedSoupLiveQuery(
activated() &&
options().enabled &&
continuationScope() === requestScope,
- requestPolicy: options().networkPaused ? 'cache-only' : 'cache-first',
+ requestPolicy: options().networkPaused
+ ? 'cache-only'
+ : refresh
+ ? 'network-only'
+ : 'cache-first',
keepPreviousData: false,
getNextPageParam: (page) =>
page.user.groupSoup.bins.find((bin) => bin.key === key)?.nextCursor ??
@@ -204,9 +219,115 @@ export function createGroupedSoupLiveQuery(
const [continuations, setContinuations] = createSignal<
ReadonlyMap<string, ReturnType<typeof createContinuation>>
>(new Map());
- resetContinuations = () => {
+ type Refresh = {
+ continuation: ReturnType<typeof createContinuation>;
+ done: Promise<void>;
+ };
+ const [refreshes, setRefreshes] = createSignal<ReadonlyMap<string, Refresh>>(
+ new Map()
+ );
+ const [refreshErrors, setRefreshErrors] = createSignal<
+ ReadonlyMap<string, Error>
+ >(new Map());
+ const cancelRefresh = (key: string) => {
+ const refresh = refreshes().get(key);
+ if (!refresh) return;
+ setRefreshes((previous) => {
+ const remaining = new Map(previous);
+ remaining.delete(key);
+ return remaining;
+ });
+ refresh.continuation.dispose();
+ };
+ const resetContinuations = () => {
+ for (const key of refreshes().keys()) cancelRefresh(key);
for (const continuation of continuations().values()) continuation.dispose();
setContinuations(new Map());
+ setRefreshErrors(new Map());
+ };
+
+ // Rebuild from the new cursor without exposing a partially loaded chain.
+ // The previous owner remains live until every previously loaded page is ready.
+ async function replaceContinuation(
+ key: string,
+ previous: ReturnType<typeof createContinuation>,
+ refresh: Refresh
+ ) {
+ const replacement = refresh.continuation;
+ const current = () =>
+ refreshes().get(key) === refresh && continuations().get(key) === previous;
+ const span = Telemetry.span('graphql_cache.soup_grouped_refresh');
+ span.setAttr('grouping.refresh_outcome', 'cancelled');
+ return span.run(async () => {
+ try {
+ // A load-more already in flight can extend the visible chain. Paging
+ // is gated by refreshes while we wait, so its settled depth is final.
+ if (!previous.query.isFetched) await previous.activate();
+ if (previous.query.isFetchingNextPage)
+ await previous.query.fetchNextPage();
+ if (!current()) return;
+ const pageCount = Math.max(1, previous.query.data?.pages().length ?? 0);
+ span.setAttr('grouping.page_count', pageCount);
+ await replacement.activate();
+ if (!current()) return;
+ if (replacement.query.error) throw replacement.query.error;
+ for (let page = 1; page < pageCount; page += 1) {
+ if (!replacement.query.hasNextPage) break;
+ await replacement.query.fetchNextPage({ throwOnError: true });
+ if (!current()) return;
+ }
+ if (!replacement.query.data || !replacement.query.isEnabled) return;
+ batch(() => {
+ setContinuations((owners) => new Map(owners).set(key, replacement));
+ previous.dispose();
+ });
+ span.setAttr('grouping.refresh_outcome', 'replaced');
+ } catch (cause) {
+ if (!current()) return;
+ const error = cause instanceof Error ? cause : new Error(String(cause));
+ setRefreshErrors((errors) => new Map(errors).set(key, error));
+ span.setAttr('grouping.refresh_outcome', 'failed');
+ span.error(error.message);
+ throw error;
+ } finally {
+ if (continuations().get(key) !== replacement) replacement.dispose();
+ if (refreshes().get(key) === refresh) {
+ setRefreshes((previous) => {
+ const remaining = new Map(previous);
+ remaining.delete(key);
+ return remaining;
+ });
+ }
+ span.end();
+ }
+ });
+ }
+ refreshContinuations = (data) => {
+ const initial = input();
+ if (!initial || !options().enabled || options().networkPaused) return;
+ setRefreshErrors(new Map());
+ for (const [key, previous] of continuations()) {
+ cancelRefresh(key);
+ const cursor = data.user.groupSoup.bins.find(
+ (bin) => bin.key === key
+ )?.nextCursor;
+ if (!cursor) {
+ setContinuations((owners) => {
+ const remaining = new Map(owners);
+ remaining.delete(key);
+ return remaining;
+ });
+ previous.dispose();
+ continue;
+ }
+ const refresh = {
+ continuation: createContinuation(key, cursor, initial, true),
+ done: Promise.resolve(),
+ };
+ setRefreshes((previous) => new Map(previous).set(key, refresh));
+ refresh.done = replaceContinuation(key, previous, refresh);
+ fireAndForget(refresh.done, 'soup-grouped-refresh');
+ }
};
createComputed(on(continuationScope, () => resetContinuations()));
createComputed(
@@ -217,6 +338,7 @@ export function createGroupedSoupLiveQuery(
const remaining = new Map(continuations());
for (const [key, continuation] of remaining) {
if (active.has(key)) continue;
+ cancelRefresh(key);
continuation.dispose();
remaining.delete(key);
}
@@ -225,9 +347,7 @@ export function createGroupedSoupLiveQuery(
}
)
);
- onCleanup(() => {
- for (const continuation of continuations().values()) continuation.dispose();
- });
+ onCleanup(resetContinuations);
const serverPages = createMemo(() => {
const initial = currentInitial();
@@ -337,11 +457,18 @@ export function createGroupedSoupLiveQuery(
: Boolean(bins().find((bin) => bin.key === key)?.nextCursor);
},
isFetchingNextPage: (key) =>
- continuations().get(key)?.query.isFetching ?? false,
- error: (key) => continuations().get(key)?.query.error ?? null,
+ refreshes().has(key) ||
+ (continuations().get(key)?.query.isFetching ?? false),
+ error: (key) =>
+ refreshErrors().get(key) ?? continuations().get(key)?.query.error ?? null,
fetchNextPage: async (key) => {
const initial = input();
if (!initial || !options().enabled) return;
+ const refresh = refreshes().get(key);
+ if (refresh) {
+ await refresh.done;
+ return;
+ }
const current = continuations().get(key);
if (current) {
if (current.query.isFetching) return;
@@ -360,6 +487,21 @@ export function createGroupedSoupLiveQuery(
return {
query,
paging,
+ refresh: async () => {
+ const requestScope = continuationScope();
+ await query.refetch({
+ requestPolicy: 'network-only',
+ throwOnError: true,
+ });
+ while (continuationScope() === requestScope && refreshes().size) {
+ await Promise.all(
+ [...refreshes().values()].map((refresh) => refresh.done)
+ );
+ }
+ if (continuationScope() !== requestScope) return;
+ const error = refreshErrors().values().next().value;
+ if (error) throw error;
+ },
data: createMemo((): GroupSoupQuery | undefined => {
const initial = currentInitial();
if (!initial) return query.data?.data;
diff --git a/apps/web/src/lib/queries/soup/graphql/grouped-items.ts b/apps/web/src/lib/queries/soup/graphql/grouped-items.ts
index 4256833da2..69c0388658 100644
--- a/apps/web/src/lib/queries/soup/graphql/grouped-items.ts
+++ b/apps/web/src/lib/queries/soup/graphql/grouped-items.ts
@@ -239,10 +239,7 @@ export function createGraphqlGroupedSoupAstItemsQuery(
resetToInitialPage: grouped.paging.resetToInitialPage,
refresh: async () => {
if (input() === undefined) return;
- await query.refetch({
- requestPolicy: 'network-only',
- throwOnError: true,
- });
+ await grouped.refresh();
},
};
}
diff --git a/apps/web/src/lib/queries/soup/items.transport-refetch.test.ts b/apps/web/src/lib/queries/soup/items.transport-refetch.test.ts
index a3a7e6894d..fe1ee8a3ab 100644
--- a/apps/web/src/lib/queries/soup/items.transport-refetch.test.ts
+++ b/apps/web/src/lib/queries/soup/items.transport-refetch.test.ts
@@ -322,7 +322,7 @@ describe('Soup refetch transport selection', () => {
vi.clearAllMocks();
await refreshActiveGraphqlSoupQueries();
- expect(groupedQuery.resetToInitialPage).toHaveBeenCalledOnce();
+ expect(groupedQuery.resetToInitialPage).not.toHaveBeenCalled();
expect(groupedQuery.refresh).toHaveBeenCalledOnce();
expect(restRefetch).not.toHaveBeenCalled();
});
diff --git a/apps/web/src/lib/queries/soup/items.ts b/apps/web/src/lib/queries/soup/items.ts
index cbf4130459..25c8ffb3f9 100644
--- a/apps/web/src/lib/queries/soup/items.ts
+++ b/apps/web/src/lib/queries/soup/items.ts
@@ -459,8 +459,10 @@ export function useSoupAstItemsQuery(
activeGraphqlQuery().isEnabled() &&
!options?.().networkPaused,
refresh: async () => {
- activeGraphqlQuery().resetToInitialPage();
- options?.().onBeforeGraphqlRefresh?.();
+ if (args().groupBy === undefined) {
+ activeGraphqlQuery().resetToInitialPage();
+ options?.().onBeforeGraphqlRefresh?.();
+ }
await activeGraphqlQuery().refresh();
},
body: () => args().body,
diff --git a/docs/agent-guide/soup-live-updates.md b/docs/agent-guide/soup-live-updates.md
index 4ae1b8ae79..ffa88abd81 100644
--- a/docs/agent-guide/soup-live-updates.md
+++ b/docs/agent-guide/soup-live-updates.md
@@ -56,7 +56,11 @@ group, and reverse on rollback without a grouped-query network round trip. Check
multi-value membership and group counts, then load another page: the request must
use the server continuation cursor. Switch filters or reset the cache during a
pending local read; its late result must not restore old rows. A server refresh
-restarts continuation coverage. The local phase emits
+rebuilds loaded continuation pages while retaining their rows until replacement
+pages are ready. Delay or fail a continuation response and confirm the list does
+not collapse to its first page; retry and verify fresh rows replace the old ones.
+An in-flight load-more must remain covered by the replacement chain. Refreshes
+emit `graphql_cache.soup_grouped_refresh`; the local phase emits
`graphql_cache.soup_grouped_local_evaluation`.
For Documents (including Tasks), Projects, Chats, and participating Channels,
diff --git a/docs/agent-guide/tasks.md b/docs/agent-guide/tasks.md
index 5c1423ce76..0c7927c4c2 100644
--- a/docs/agent-guide/tasks.md
+++ b/docs/agent-guide/tasks.md
@@ -55,6 +55,11 @@ With GraphQL Soup enabled, verify a group with more than one page in both the
regular Tasks list (`Load More`) and a project task list (automatic pagination).
Both must use the parent Soup query's continuation owner; reaching the last page
removes the group's paging control without hiding already loaded tasks.
+Refresh a group containing at least 11 tasks while delaying its continuation
+response: every already loaded continuation row should stay mounted, with no
+brief collapse to the first 10 rows. Verify both background and explicit refresh,
+including a changed cursor and a failed later page. Retrying should replace the
+old pages; changing projects or filters must discard the old scope immediately.
The sidebar has no Tags section: filter by tag from the `Tags` group of the `Filter` menu,
and switching tabs clears it like any other filter. On mobile, the tabs
are pills and the leading sliders button opens one drawer containing Sort, Group, and