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.

feat(tasks): load grouped task and Soup pages as they scroll into view (#9140)

Peter Chinmandd39f329786d
diff --git a/apps/web/src/components/gantt/gantt-rows.tsx b/apps/web/src/components/gantt/gantt-rows.tsx
index f57ab389c1..7d7a563546 100644
--- a/apps/web/src/components/gantt/gantt-rows.tsx
+++ b/apps/web/src/components/gantt/gantt-rows.tsx
@@ -3,6 +3,7 @@ import {
createVirtualizer,
defaultRangeExtractor,
type Range,
+ type VirtualItem,
} from '@tanstack/solid-virtual';
import { cn } from '@ui';
import {
@@ -13,6 +14,7 @@ import {
For,
type JSX,
on,
+ onCleanup,
Show,
splitProps,
} from 'solid-js';
@@ -66,6 +68,40 @@ function VirtualRows<T>(props: RowsProps<T>) {
createEffect(
on(gantt.rowHeight, () => virtualizer.measure(), { defer: true })
);
+ // Rows inserted above the viewport, such as a group's page that arrives
+ // after the reader scrolled past it, keep the first visible row in place.
+ let anchor: { key: VirtualItem['key']; offset: number } | undefined;
+ const recordAnchor = () => {
+ const offset = virtualizer.scrollOffset ?? 0;
+ const item =
+ offset > 0 ? virtualizer.getVirtualItemForOffset(offset) : undefined;
+ anchor = item && { key: item.key, offset: offset - item.start };
+ };
+ createEffect(
+ on(gantt.viewport, (viewport) => {
+ if (!viewport) return;
+ viewport.addEventListener('scroll', recordAnchor, { passive: true });
+ onCleanup(() => viewport.removeEventListener('scroll', recordAnchor));
+ })
+ );
+ createEffect(
+ on(
+ () => props.items,
+ (items) => {
+ const current = anchor;
+ if (!current) return;
+ const index = items.findIndex(
+ (item) => props.getKey(item) === current.key
+ );
+ const start = virtualizer.measurementsCache[index]?.start;
+ if (start === undefined) return;
+ const offset = start + current.offset;
+ if (Math.abs(offset - (virtualizer.scrollOffset ?? 0)) >= 1)
+ virtualizer.scrollToOffset(offset);
+ },
+ { defer: true }
+ )
+ );
return (
<div
class="relative"
diff --git a/apps/web/src/features/crm/activity-tasks-adapter.tsx b/apps/web/src/features/crm/activity-tasks-adapter.tsx
index 452a2def8e..d6372e5ae3 100644
--- a/apps/web/src/features/crm/activity-tasks-adapter.tsx
+++ b/apps/web/src/features/crm/activity-tasks-adapter.tsx
@@ -117,21 +117,6 @@ function ActivityTasksBody(props: {
/>
</ListHeader>
</Show>
- <Show when={source.paginationError?.()}>
- <div
- role="alert"
- class="flex items-center gap-3 px-3 py-2 text-sm text-ink-muted"
- >
- Some tasks could not be loaded.
- <Button
- variant="ghost"
- size="sm"
- onClick={() => source.retryPagination?.()}
- >
- Try again
- </Button>
- </div>
- </Show>
<div class="min-h-0 flex-1">
<TasksContent
loadingContent={<CrmListSkeleton label="Loading tasks" />}
diff --git a/apps/web/src/features/next-soup/soup-view/soup-group-continuation.tsx b/apps/web/src/features/next-soup/soup-view/soup-group-continuation.tsx
new file mode 100644
index 0000000000..730932d91d
--- /dev/null
+++ b/apps/web/src/features/next-soup/soup-view/soup-group-continuation.tsx
@@ -0,0 +1,40 @@
+import { useInfiniteScrollSentinel } from '@app/lib/primitives/infinite-scroll-sentinel';
+import SpinnerIcon from '@icon/system/regular/spinner.svg';
+import { Button } from '@ui';
+import { createSignal, Show } from 'solid-js';
+
+/**
+ * The end of a group with more items on the server. It requests the next page
+ * whenever it is near the visible area and idle; a failed page waits for Retry.
+ */
+export function SoupGroupContinuation(props: {
+ isLoading: boolean;
+ failed: boolean;
+ onLoad: () => void;
+}) {
+ const [row, setRow] = createSignal<HTMLDivElement>();
+ useInfiniteScrollSentinel({
+ sentinel: row,
+ hasNextPage: () => !props.failed,
+ isFetchingNextPage: () => props.isLoading,
+ fetchNextPage: () => props.onLoad(),
+ });
+
+ return (
+ <div
+ ref={setRow}
+ aria-busy={!props.failed}
+ class="my-1 flex min-h-9 items-center justify-center gap-2 text-sm text-ink-muted"
+ >
+ <Show
+ when={props.failed}
+ fallback={<SpinnerIcon class="size-4 animate-spin" />}
+ >
+ <span>Couldn’t load more items.</span>
+ <Button variant="secondary" size="xs" onClick={() => props.onLoad()}>
+ Retry
+ </Button>
+ </Show>
+ </div>
+ );
+}
diff --git a/apps/web/src/features/next-soup/soup-view/soup-view-context.tsx b/apps/web/src/features/next-soup/soup-view/soup-view-context.tsx
index 2c2da53b9d..3c3294adc2 100644
--- a/apps/web/src/features/next-soup/soup-view/soup-view-context.tsx
+++ b/apps/web/src/features/next-soup/soup-view/soup-view-context.tsx
@@ -199,6 +199,7 @@ export interface SoupViewContextValues {
fetchNextGroupPage: (groupKey: string) => Promise<void>;
isFetchingGroupPage: (groupKey: string) => boolean;
hasNextGroupPage: (groupKey: string) => boolean;
+ groupPageError: (groupKey: string) => unknown;
}
const SoupViewContext = createContext<SoupViewContextValues>();
@@ -1178,6 +1179,9 @@ export const createSoupViewState = (props: SoupViewContextProviderProps) => {
const hasNextGroupPage = (groupKey: string) =>
groupQueryFor(groupKey)?.hasNextPage() ?? false;
+ const groupPageError = (groupKey: string) =>
+ groupQueryFor(groupKey)?.error() ?? null;
+
const resolveGroupLabel = (key: string): string | undefined => {
const field = groupByField();
const definitionId =
@@ -1592,6 +1596,7 @@ export const createSoupViewState = (props: SoupViewContextProviderProps) => {
fetchNextGroupPage,
isFetchingGroupPage,
hasNextGroupPage,
+ groupPageError,
};
return { context, rows: builtRows };
diff --git a/apps/web/src/features/next-soup/soup-view/soup-view.tsx b/apps/web/src/features/next-soup/soup-view/soup-view.tsx
index 2708a547b3..6b987525bd 100644
--- a/apps/web/src/features/next-soup/soup-view/soup-view.tsx
+++ b/apps/web/src/features/next-soup/soup-view/soup-view.tsx
@@ -96,7 +96,6 @@ import {
type SearchLocation,
} from '@entity';
import type { SoupRowFamily } from '@entity/composed/list-entity/row-geometry';
-import CaretDownIcon from '@icon/system/regular/caret-down.svg';
import ChevronRightIcon from '@icon/system/regular/caret-right.svg';
import CheckIcon from '@icon/system/regular/check.svg';
import InfoIcon from '@icon/system/regular/info.svg';
@@ -128,6 +127,7 @@ import { makeMarkNotDoneAction } from '../actions/make-mark-not-done-action';
import { SOUP_TOUR } from '../tour';
import { SearchAskAiButton } from './search-ask-ai-button';
import { SoupEntitySelectionToolbar } from './soup-entity-selection-toolbar';
+import { SoupGroupContinuation } from './soup-group-continuation';
import { useSoupNavigationHotkeys } from './use-soup-navigation-hotkeys';
import { useSoupViewHotkeys } from './use-soup-view-hotkeys';
@@ -607,6 +607,7 @@ const SoupViewListContent = (props: SoupViewListProps) => {
clientSort,
fetchNextGroupPage,
isFetchingGroupPage,
+ groupPageError,
} = useSoupView();
const { hasActiveRefinements, hasHiddenItems, resetToTabDefaults } =
useFilterRefinements();
@@ -732,6 +733,11 @@ const SoupViewListContent = (props: SoupViewListProps) => {
isFetchingNextPage: source.isFetchingNextPage,
fetchNextPage: source.fetchNextPage,
error: source.error,
+ groupPaging: {
+ load: fetchNextGroupPage,
+ isLoading: isFetchingGroupPage,
+ failed: (groupKey) => Boolean(groupPageError(groupKey)),
+ },
});
// Register entity action hotkeys
@@ -1297,7 +1303,7 @@ const SoupViewListContent = (props: SoupViewListProps) => {
)}
</Match>
- {/* Load more row */}
+ {/* Group continuation row */}
<Match
when={
row.group?.isExpanded() &&
@@ -1305,58 +1311,21 @@ const SoupViewListContent = (props: SoupViewListProps) => {
row.group
}
>
- {(group) => {
- const highlighted = () => row.isFocused();
- return (
- <div
- class={cn(
- 'my-1 rounded min-h-9 flex items-center justify-center',
- highlighted()
- ? 'w-[calc(100%-0.5rem)] mx-1 bg-active/60'
- : 'mx-auto'
- )}
- >
- <Show
- when={
- !isFetchingGroupPage(group().key)
- }
- fallback={
- <Button
- variant="secondary"
- size="xs"
- class={cn({
- 'bg-surface': !highlighted(),
- 'border-transparent':
- highlighted(),
- })}
- disabled
- >
- <Spinner class="size-3 animate-spin" />
- Loading...
- </Button>
- }
- >
- <Button
- variant="secondary"
- size="xs"
- class={cn({
- 'bg-surface': !highlighted(),
- 'border-transparent':
- highlighted(),
- })}
- onClick={() => {
- fetchNextGroupPage(
- group().key
- ).catch(reportSoupViewError);
- }}
- >
- <CaretDownIcon class="size-2.5" />
- Load More
- </Button>
- </Show>
- </div>
- );
- }}
+ {(group) => (
+ <SoupGroupContinuation
+ isLoading={isFetchingGroupPage(
+ group().key
+ )}
+ failed={Boolean(
+ groupPageError(group().key)
+ )}
+ onLoad={() => {
+ fetchNextGroupPage(group().key).catch(
+ reportSoupViewError
+ );
+ }}
+ />
+ )}
</Match>
{/* Entity row */}
diff --git a/apps/web/src/features/next-soup/soup-view/use-soup-navigation-hotkeys.test.ts b/apps/web/src/features/next-soup/soup-view/use-soup-navigation-hotkeys.test.ts
index a9cdc0186e..4090d16619 100644
--- a/apps/web/src/features/next-soup/soup-view/use-soup-navigation-hotkeys.test.ts
+++ b/apps/web/src/features/next-soup/soup-view/use-soup-navigation-hotkeys.test.ts
@@ -370,6 +370,84 @@ describe('useSoupNavigationHotkeys', () => {
}
});
+ it('waits on the last loaded row of a group for its next page, or moves on after a failure', () => {
+ const load = vi.fn(async () => {});
+ let failed = false;
+ const { soup, dispose } = createRoot((dispose) => {
+ const soup = createSoupState();
+ useSoupNavigationHotkeys({
+ scopeId: 'test-scope',
+ soup,
+ splitHandle: createSplitHandleStub(),
+ virtualizerHandle: () => undefined,
+ groupPaging: {
+ load,
+ isLoading: () => false,
+ failed: () => failed,
+ },
+ });
+ return { soup, dispose };
+ });
+ const groupA = createTestGroup('a', 3);
+ const groupB = createTestGroup('b', 1);
+ const [a1, a2, a3, b1] = ['a1', 'a2', 'a3', 'b1'].map(createTestEntity);
+ const rows = (loaded: EntityData[]) => [
+ soup.buildRow({
+ id: 'header:a',
+ index: 0,
+ original: a1,
+ group: groupA,
+ isGrouped: true,
+ }),
+ ...loaded.map((entity, i) =>
+ soup.buildRow({
+ id: entity.id,
+ index: i + 1,
+ original: entity,
+ group: groupA,
+ })
+ ),
+ soup.buildRow({
+ id: 'loadmore:a',
+ index: loaded.length + 1,
+ original: loaded[loaded.length - 1],
+ group: groupA,
+ isLoadMore: true,
+ }),
+ soup.buildRow({
+ id: 'header:b',
+ index: loaded.length + 2,
+ original: b1,
+ group: groupB,
+ isGrouped: true,
+ }),
+ soup.buildRow({
+ id: 'b1',
+ index: loaded.length + 3,
+ original: b1,
+ group: groupB,
+ }),
+ ];
+ try {
+ soup.setRows(rows([a1, a2]));
+ soup.focus.set('a2');
+ handlerFor('j')();
+ expect(soup.focus.id()).toBe('a2');
+ expect(load).toHaveBeenCalledExactlyOnceWith('a');
+
+ soup.setRows(rows([a1, a2, a3]));
+ handlerFor('j')();
+ expect(soup.focus.id()).toBe('a3');
+
+ failed = true;
+ handlerFor('j')();
+ expect(soup.focus.id()).toBe('b1');
+ expect(load).toHaveBeenCalledOnce();
+ } finally {
+ dispose();
+ }
+ });
+
it('arrow keys share the header-skipping navigation', () => {
const { soup, dispose } = setupHotkeys();
soup.focus.set('a2');
diff --git a/apps/web/src/features/next-soup/soup-view/use-soup-navigation-hotkeys.ts b/apps/web/src/features/next-soup/soup-view/use-soup-navigation-hotkeys.ts
index 8ea0916736..ccbb45ba76 100644
--- a/apps/web/src/features/next-soup/soup-view/use-soup-navigation-hotkeys.ts
+++ b/apps/web/src/features/next-soup/soup-view/use-soup-navigation-hotkeys.ts
@@ -27,6 +27,12 @@ type UseSoupNavigationHotkeysOptions = {
isFetchingNextPage?: Accessor<boolean>;
fetchNextPage?: () => Promise<void>;
error?: Accessor<Error | null>;
+ /** Server-grouped lists continue each group with its own pages. */
+ groupPaging?: {
+ load: (groupKey: string) => Promise<void>;
+ isLoading: (groupKey: string) => boolean;
+ failed: (groupKey: string) => boolean;
+ };
};
// These callbacks outlive SoupViewList. Keep their closure separate from the
@@ -95,7 +101,18 @@ function createPersistentNavigation(
};
const navigateToOpenableEntity = (offset: -1 | 1) =>
- soup.navigate.by(offset, { skipGroupHeaders: true });
+ soup.navigate.by(offset, { skipGroupHeaders: true, skipLoadMore: true });
+
+ // A group's next page continues right after the focused row: wait for it
+ // rather than skipping the rest of the group. A failed page lets focus move on.
+ const pendingGroupPage = () => {
+ const { groupPaging } = options;
+ if (!groupPaging) return;
+ const next = soup.rows()[soup.focus.index() + 1];
+ if (!next?.getIsLoadMore() || !next.group?.isExpanded()) return;
+ if (groupPaging.failed(next.group.key)) return;
+ return next.group.key;
+ };
const { fetchNextPage, isFetching, isFetchingNextPage, hasNextPage } =
options;
@@ -108,6 +125,13 @@ function createPersistentNavigation(
};
const navigateDown = () => {
+ const groupKey = pendingGroupPage();
+ if (groupKey !== undefined) {
+ if (!options.groupPaging?.isLoading(groupKey))
+ options.groupPaging?.load(groupKey).catch(reportSoupNavigationError);
+ return true;
+ }
+
const rowCount = soup.rows().length;
const next = navigateToOpenableEntity(1);
@@ -199,12 +223,16 @@ export const useSoupNavigationHotkeys = (
isFetchingNextPage: options.isFetchingNextPage,
fetchNextPage: options.fetchNextPage,
error: options.error,
+ groupPaging: options.groupPaging,
},
viewport
);
const navigateAndSelectEntity = (offset: number) => {
- const nextRow = soup.navigate.by(offset, { skipGroupHeaders: true });
+ const nextRow = soup.navigate.by(offset, {
+ skipGroupHeaders: true,
+ skipLoadMore: true,
+ });
if (!nextRow) return true;
soup.selection.select(nextRow.row.original);
scrollTo(nextRow.index);
@@ -213,7 +241,10 @@ export const useSoupNavigationHotkeys = (
const handleNavigationSelection = (offset: number) => {
const focusedEntity = soup.focus.item();
- const next = soup.navigate.peekOffset(offset, { skipGroupHeaders: true });
+ const next = soup.navigate.peekOffset(offset, {
+ skipGroupHeaders: true,
+ skipLoadMore: true,
+ });
const selection = soup.selection;
@@ -245,7 +276,7 @@ export const useSoupNavigationHotkeys = (
if (selection.isSelected(nextEntity.id)) {
selection.toggle(focusedEntity);
- soup.navigate.by(offset, { skipGroupHeaders: true });
+ soup.navigate.by(offset, { skipGroupHeaders: true, skipLoadMore: true });
scrollTo(next.index);
return true;
}
diff --git a/apps/web/src/features/projects/queries/project-tasks.test.ts b/apps/web/src/features/projects/queries/project-tasks.test.ts
index 4d4b240e7f..bcdc0462f4 100644
--- a/apps/web/src/features/projects/queries/project-tasks.test.ts
+++ b/apps/web/src/features/projects/queries/project-tasks.test.ts
@@ -70,7 +70,6 @@ it('scopes tasks to the Project property and disables the shared source immediat
entityId: 'project',
});
expect(mock.options?.enabled?.()).toBe(true);
- expect(mock.options?.loadAll).toBe(true);
expect(mock.options?.board?.()).toBe(false);
setBoard(true);
expect(mock.options?.board?.()).toBe(true);
diff --git a/apps/web/src/features/projects/queries/project-tasks.ts b/apps/web/src/features/projects/queries/project-tasks.ts
index 46025cbab5..039c67d263 100644
--- a/apps/web/src/features/projects/queries/project-tasks.ts
+++ b/apps/web/src/features/projects/queries/project-tasks.ts
@@ -19,7 +19,6 @@ export function createProjectTasksDataSource(
): TasksDataSource {
const source = useTasksDataSource(state, {
...options,
- loadAll: true,
reference: () => ({
propertyDefinitionId: SYSTEM_PROPERTY_IDS.PROJECT,
entityId: projectId,
diff --git a/apps/web/src/features/projects/views/project-tasks-list.tsx b/apps/web/src/features/projects/views/project-tasks-list.tsx
index ae3aaccd57..7a8019bbdc 100644
--- a/apps/web/src/features/projects/views/project-tasks-list.tsx
+++ b/apps/web/src/features/projects/views/project-tasks-list.tsx
@@ -70,7 +70,7 @@ export function ProjectTasksList(props: ProjectTasksListProps) {
}
function ProjectTasksListBody(props: ProjectTasksListProps) {
- const { state, setState, source } = useTasksView();
+ const { state, setState } = useTasksView();
return (
<div class="flex size-full min-h-0 flex-col">
<div class="flex h-12 min-w-0 shrink-0 items-center gap-3 overflow-x-auto scrollbar-hidden px-4 py-2">
@@ -90,21 +90,6 @@ function ProjectTasksListBody(props: ProjectTasksListProps) {
</Show>
</div>
</div>
- <Show when={source.paginationError?.()}>
- <div
- role="alert"
- class="flex items-center gap-3 px-3 pb-2 text-sm text-ink-muted"
- >
- Some tasks could not be loaded.
- <Button
- variant="ghost"
- size="sm"
- onClick={() => source.retryPagination?.()}
- >
- Try again
- </Button>
- </div>
- </Show>
<TasksContent />
</div>
);
diff --git a/apps/web/src/features/tasks-view/components/task-list/TaskList.tsx b/apps/web/src/features/tasks-view/components/task-list/TaskList.tsx
index a25394a1db..871bb7ecbb 100644
--- a/apps/web/src/features/tasks-view/components/task-list/TaskList.tsx
+++ b/apps/web/src/features/tasks-view/components/task-list/TaskList.tsx
@@ -32,19 +32,19 @@ import {
} from '@entity';
import { useListLayout } from '@entity/composed/list-entity/shared';
import { soupPropertyToProperty } from '@entity/extractors-property';
-import CaretDownIcon from '@icon/system/regular/caret-down.svg';
import CheckIcon from '@icon/system/regular/check.svg';
import SpinnerIcon from '@icon/system/regular/spinner.svg';
import { PROPERTY_OPTION_IDS, SYSTEM_PROPERTY_IDS } from '@property';
import { useBulkSaveEntityPropertiesMutation } from '@queries/properties/entity';
import { EntityType } from '@service-properties/generated/schemas/entityType';
-import { Button, cn } from '@ui';
+import { Button } from '@ui';
import {
createEffect,
createMemo,
createSignal,
type JSX,
Match,
+ on,
type Setter,
Show,
Switch,
@@ -61,6 +61,7 @@ import {
useTasksView,
} from '../../tasks-view-context';
import { TaskGroupHeader } from './TaskGroupHeader';
+import { TaskListContinuationRow } from './TaskListContinuationRow';
import { TaskListEntity } from './TaskListEntity';
import { TaskListHeader } from './TaskListHeader';
import { taskGridColumnCount } from './task-grid-template';
@@ -154,24 +155,6 @@ export function TaskList(props: TaskListProps) {
return;
}
- if (item.kind === 'load-more' && item.groupId !== undefined) {
- const focusIndex = list.items.indexOf(item.id);
- fireAndForget(
- source.loadMoreGroup(item.groupId).then(() => {
- if (list.focus.requestedKey() !== item.id) return;
-
- list.focus.restore(item.id, {
- fallback: 'nearest',
- nearestIndex: focusIndex,
- retainUnavailable: false,
- });
- }),
- 'tasks-view'
- );
-
- return;
- }
-
if (item.kind !== 'entity') return;
const sourceRow = source
@@ -304,6 +287,17 @@ export function TaskList(props: TaskListProps) {
scrollHandle: virtualizer,
enabled: panel.isPanelActive,
navigation: {
+ // Hold focus at a group's last loaded task until its next page arrives;
+ // a failed page lets focus continue into the next group.
+ onBeforeMove: ({ direction, current }) => {
+ if (direction !== 1 || !current) return true;
+ const next = list.items.at(current.index + 1);
+ return (
+ next?.kind !== 'load-more' ||
+ next.groupId === undefined ||
+ Boolean(source.groupError?.(next.groupId))
+ );
+ },
onNavigate: (event) => {
if (event.kind !== 'move' || event.direction !== 1) return;
if (source.isLoadingMore() || !source.hasMore()) {
@@ -397,6 +391,39 @@ export function TaskList(props: TaskListProps) {
});
});
+ // A group's next page can arrive after the reader scrolled past that group,
+ // inserting rows above the viewport. Keep the first visible row in place.
+ let scrollAnchor: { id: string; offset: number } | undefined;
+ function recordScrollAnchor() {
+ const handle = virtualizer();
+ if (!handle || handle.scrollOffset <= 0) {
+ scrollAnchor = undefined;
+ return;
+ }
+ const index = handle.findItemIndex(handle.scrollOffset);
+ const row = visibleRows()[index];
+ scrollAnchor = row && {
+ id: row.id,
+ offset: handle.scrollOffset - handle.getItemOffset(index),
+ };
+ }
+ createEffect(
+ on(
+ visibleRows,
+ (rows) => {
+ const handle = virtualizer();
+ const anchor = scrollAnchor;
+ if (!handle || !anchor) return;
+ const index = rows.findIndex((row) => row.id === anchor.id);
+ if (index < 0) return;
+ const offset = handle.getItemOffset(index) + anchor.offset;
+ if (Math.abs(offset - handle.scrollOffset) >= 1)
+ handle.scrollTo(offset);
+ },
+ { defer: true }
+ )
+ );
+
function checkNearEnd() {
const handle = virtualizer();
if (!handle) return;
@@ -510,7 +537,10 @@ export function TaskList(props: TaskListProps) {
viewportRef={setViewport}
items={visibleRows()}
focusedIndex={list.focus.index()}
- onScroll={checkNearEnd}
+ onScroll={() => {
+ recordScrollAnchor();
+ checkNearEnd();
+ }}
>
{(row) => (
<Switch>
@@ -626,68 +656,29 @@ export function TaskList(props: TaskListProps) {
</div>
)}
</Match>
- <Match when={row.kind === 'load-more' ? row : undefined}>
- {(loadMore) => {
- const highlighted = () =>
- list.focus.key() === loadMore().id;
- const buttonClass = () =>
- cn({
- 'bg-surface': !highlighted(),
- 'border-transparent': highlighted(),
- });
- const activate = () => {
- if (loadMore().isLoading) return;
- list.activate.key(loadMore().id, {
- reason: 'pointer',
- });
- };
-
- return (
- <div id={loadMore().id} role="row">
- <div
- role="gridcell"
- aria-colspan={columnCount()}
- aria-busy={loadMore().isLoading}
- onMouseMove={() =>
- list.focus.set(loadMore().id, {
- reason: 'hover',
- })
- }
- onClick={activate}
- class={cn(
- 'my-1 flex min-h-9 items-center justify-center rounded',
- highlighted()
- ? 'mx-1 w-[calc(100%-0.5rem)] bg-active/60'
- : 'mx-auto'
- )}
- >
- <Show
- when={!loadMore().isLoading}
- fallback={
- <Button
- variant="secondary"
- size="xs"
- class={buttonClass()}
- disabled
- >
- <SpinnerIcon class="size-3 animate-spin" />
- Loading...
- </Button>
- }
- >
- <Button
- variant="secondary"
- size="xs"
- class={buttonClass()}
- >
- <CaretDownIcon class="size-2.5" />
- Load More
- </Button>
- </Show>
- </div>
- </div>
- );
- }}
+ <Match
+ when={
+ row.kind === 'load-more' && row.groupId !== undefined
+ ? { ...row, groupId: row.groupId }
+ : undefined
+ }
+ >
+ {(continuation) => (
+ <TaskListContinuationRow
+ id={continuation().id}
+ columnCount={columnCount()}
+ isLoading={continuation().isLoading ?? false}
+ failed={Boolean(
+ source.groupError?.(continuation().groupId)
+ )}
+ onLoad={() =>
+ fireAndForget(
+ source.loadMoreGroup(continuation().groupId),
+ 'tasks-view'
+ )
+ }
+ />
+ )}
</Match>
</Switch>
)}
diff --git a/apps/web/src/features/tasks-view/components/task-list/TaskListContinuationRow.tsx b/apps/web/src/features/tasks-view/components/task-list/TaskListContinuationRow.tsx
new file mode 100644
index 0000000000..e295924200
--- /dev/null
+++ b/apps/web/src/features/tasks-view/components/task-list/TaskListContinuationRow.tsx
@@ -0,0 +1,45 @@
+import { useInfiniteScrollSentinel } from '@app/lib/primitives/infinite-scroll-sentinel';
+import SpinnerIcon from '@icon/system/regular/spinner.svg';
+import { Button } from '@ui';
+import { createSignal, Show } from 'solid-js';
+
+/**
+ * The end of a group with more tasks on the server. It requests the next page
+ * whenever it is near the visible area and idle; a failed page waits for Retry.
+ */
+export function TaskListContinuationRow(props: {
+ id: string;
+ columnCount: number;
+ isLoading: boolean;
+ failed: boolean;
+ onLoad: () => void;
+}) {
+ const [row, setRow] = createSignal<HTMLDivElement>();
+ useInfiniteScrollSentinel({
+ sentinel: row,
+ hasNextPage: () => !props.failed,
+ isFetchingNextPage: () => props.isLoading,
+ fetchNextPage: () => props.onLoad(),
+ });
+
+ return (
+ <div ref={setRow} id={props.id} role="row">
+ <div
+ role="gridcell"
+ aria-colspan={props.columnCount}
+ aria-busy={!props.failed}
+ class="my-1 flex min-h-9 items-center justify-center gap-2 text-sm text-ink-muted"
+ >
+ <Show
+ when={props.failed}
+ fallback={<SpinnerIcon class="size-4 animate-spin" />}
+ >
+ <span>Couldn’t load more tasks.</span>
+ <Button variant="secondary" size="xs" onClick={props.onLoad}>
+ Retry
+ </Button>
+ </Show>
+ </div>
+ </div>
+ );
+}
diff --git a/apps/web/src/features/tasks-view/queries/automatic-task-pagination.test.ts b/apps/web/src/features/tasks-view/queries/automatic-task-pagination.test.ts
deleted file mode 100644
index 9ad947d1a4..0000000000
--- a/apps/web/src/features/tasks-view/queries/automatic-task-pagination.test.ts
+++ /dev/null
@@ -1,111 +0,0 @@
-import { createRoot, createSignal } from 'solid-js';
-import { afterEach, expect, it, vi } from 'vitest';
-import {
- createAutomaticTaskPagination,
- type TaskPageSource,
-} from './automatic-task-pagination';
-
-let dispose: (() => void) | undefined;
-afterEach(() => dispose?.());
-function setup(
- sources: () => TaskPageSource[],
- enabled = () => true,
- scope = () => 'project'
-) {
- return createRoot((cleanup) => {
- dispose = cleanup;
- return createAutomaticTaskPagination({ sources, enabled, scope });
- });
-}
-
-it('drains every group independently without duplicate in-flight requests', async () => {
- const [pages, setPages] = createSignal([3, 2]);
- const pending = Promise.withResolvers<void>();
- const load = vi.fn(async (index: number) => {
- await pending.promise;
- setPages((counts) =>
- counts.map((count, i) => (i === index ? count - 1 : count))
- );
- });
- setup(() =>
- pages().map((count, index) => ({
- id: String(index),
- hasMore: count > 0,
- pending: false,
- load: () => load(index),
- error: () => null,
- }))
- );
- expect(load).toHaveBeenCalledTimes(2);
- pending.resolve();
- await vi.waitFor(() => expect(pages()).toEqual([0, 0]));
- expect(load).toHaveBeenCalledTimes(5);
-});
-
-it('stops after a resolved query failure and resumes only on retry', async () => {
- const [remaining, setRemaining] = createSignal(true);
- let failure: Error | null = new Error('Offline');
- const load = vi.fn(async () => {
- if (!failure) setRemaining(false);
- });
- const pagination = setup(() => [
- {
- id: 'group',
- hasMore: remaining(),
- pending: false,
- load,
- error: () => failure,
- },
- ]);
- await vi.waitFor(() => expect(pagination.error()).toBe(failure));
- expect(load).toHaveBeenCalledOnce();
- failure = null;
- pagination.retry();
- await vi.waitFor(() => expect(remaining()).toBe(false));
- expect(load).toHaveBeenCalledTimes(2);
-});
-
-it('does not continue fetching when access is lost during a request', async () => {
- const [enabled, setEnabled] = createSignal(true);
- const pending = Promise.withResolvers<void>();
- const load = vi.fn(() => pending.promise);
- setup(
- () => [
- { id: 'group', hasMore: true, pending: false, load, error: () => null },
- ],
- enabled
- );
- setEnabled(false);
- pending.resolve();
- await pending.promise;
- await Promise.resolve();
- expect(load).toHaveBeenCalledOnce();
-});
-
-it('ignores a stale request failure after the project or filters change', async () => {
- const [scope, setScope] = createSignal('old');
- const [remaining, setRemaining] = createSignal(true);
- const pending = Promise.withResolvers<void>();
- const pagination = setup(
- () => [
- {
- id: 'group',
- hasMore: remaining(),
- pending: false,
- load:
- scope() === 'old'
- ? () => pending.promise
- : async () => {
- setRemaining(false);
- },
- error: () => null,
- },
- ],
- () => true,
- scope
- );
- setScope('new');
- pending.reject(new Error('Old request failed'));
- await vi.waitFor(() => expect(remaining()).toBe(false));
- expect(pagination.error()).toBeUndefined();
-});
diff --git a/apps/web/src/features/tasks-view/queries/automatic-task-pagination.ts b/apps/web/src/features/tasks-view/queries/automatic-task-pagination.ts
deleted file mode 100644
index f4c9ff5ceb..0000000000
--- a/apps/web/src/features/tasks-view/queries/automatic-task-pagination.ts
+++ /dev/null
@@ -1,76 +0,0 @@
-import { fireAndForget } from '@core/util/fireAndForget';
-import {
- type Accessor,
- createEffect,
- createSignal,
- onCleanup,
- untrack,
-} from 'solid-js';
-
-export type TaskPageSource = {
- id: string;
- hasMore: boolean;
- pending: boolean;
- load(): Promise<void>;
- error(): unknown;
-};
-
-/** Drains independent cursor chains, one request per chain at a time. */
-export function createAutomaticTaskPagination(options: {
- enabled: Accessor<boolean>;
- scope: Accessor<string>;
- sources: Accessor<TaskPageSource[]>;
-}) {
- const [error, setError] = createSignal<unknown>();
- const [revision, setRevision] = createSignal(0);
- const running = new Map<string, object>();
- let scope: string | undefined;
- let generation = 0;
- let disposed = false;
- onCleanup(() => {
- disposed = true;
- });
-
- const load = async (
- source: TaskPageSource,
- token: object,
- version: number
- ) => {
- try {
- await source.load();
- if (disposed || version !== generation) return;
- const failure = source.error();
- if (failure) setError(() => failure);
- } catch (failure) {
- if (!disposed && version === generation) setError(() => failure);
- } finally {
- if (!disposed && running.get(source.id) === token) {
- running.delete(source.id);
- setRevision((value) => value + 1);
- }
- }
- };
-
- // This effect drives network reads as cursors settle; it does not derive UI state.
- createEffect(() => {
- revision();
- const nextScope = options.scope();
- if (nextScope !== scope) {
- scope = nextScope;
- generation += 1;
- running.clear();
- setError(undefined);
- }
- if (!options.enabled() || error()) return;
- for (const source of options.sources()) {
- if (!source.hasMore || source.pending || running.has(source.id)) continue;
- const token = {};
- running.set(source.id, token);
- untrack(() =>
- fireAndForget(load(source, token, generation), 'tasks-view')
- );
- }
- });
-
- return { error, retry: () => setError(undefined) };
-}
diff --git a/apps/web/src/features/tasks-view/queries/use-tasks-query.test.ts b/apps/web/src/features/tasks-view/queries/use-tasks-query.test.ts
index cf8c35b95c..95ec54f28d 100644
--- a/apps/web/src/features/tasks-view/queries/use-tasks-query.test.ts
+++ b/apps/web/src/features/tasks-view/queries/use-tasks-query.test.ts
@@ -52,94 +52,6 @@ vi.mock('@queries/soup/grouped/create-grouped-soup-queries', () => ({
import { useTasksDataSource } from './use-tasks-query';
-it.each([false, true])(
- 'loads all group pages only when requested (%s)',
- async (loadAll) => {
- const tasks = Array.from({ length: 20 }, (_, index) => ({
- type: 'document',
- fileType: 'md',
- id: `task-${index}`,
- name: `Task ${index}`,
- ownerId: 'viewer',
- createdAt: new Date(),
- updatedAt: new Date(),
- subType: { type: 'task', is_completed: false },
- properties: [],
- })) as unknown as TaskEntityWithProperties[];
- const [loaded, setLoaded] = createSignal(false);
- const fetchNextPage = vi.fn(async () => {
- setLoaded(true);
- });
- fixture.query = {
- isLoading: false,
- isPending: false,
- isPlaceholderData: false,
- hasNextPage: false,
- data: {
- entities: tasks.slice(0, 10),
- itemsById: {},
- groups: [
- {
- key: 'todo',
- label: 'To do',
- displayOrder: 0,
- totalCount: 20,
- itemIds: tasks.slice(0, 10).map((task) => task.id),
- nextCursor: 'next',
- },
- ],
- },
- };
- fixture.groupQueries = new Map([
- [
- 'todo',
- {
- key: 'todo',
- data: () => ({ entities: loaded() ? tasks.slice(10) : [] }),
- hasNextPage: () => !loaded(),
- isFetchingNextPage: () => false,
- fetchNextPage,
- error: () => null,
- },
- ],
- ]);
- let cleanup = () => {};
- const source = createRoot((dispose) => {
- cleanup = dispose;
- return useTasksDataSource(
- {
- tab: 'team-tasks',
- search: '',
- facets: {},
- groupBy: 'status',
- sort: [],
- },
- {
- userId: () => 'viewer',
- tagSets: () => [],
- tagSetsReady: () => true,
- isGroupExpanded: () => true,
- loadAll,
- }
- );
- });
- try {
- await vi.waitFor(() =>
- expect(
- source.items().filter((row) => row.kind === 'entity')
- ).toHaveLength(loadAll ? 20 : 10)
- );
- expect(fetchNextPage).toHaveBeenCalledTimes(loadAll ? 1 : 0);
- expect(source.items().some((row) => row.kind === 'load-more')).toBe(
- !loadAll
- );
- } finally {
- cleanup();
- fixture.groupQueries = new Map();
- }
- }
-);
-
it('delegates grouped task pagination to the current Soup query owner', async () => {
const [paging, setPaging] = createSignal<GroupedSoupPaging>();
const [hasMore, setHasMore] = createSignal(true);
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 812d697a9a..6fdd6ad6d3 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
@@ -41,7 +41,6 @@ import type {
TaskReferenceScope,
TasksViewState,
} from '../types';
-import { createAutomaticTaskPagination } from './automatic-task-pagination';
import { createScopedTaskSearch } from './scoped-task-search';
import { buildTaskQuery } from './task-query';
import { buildTaskSearchRequest } from './task-search';
@@ -67,8 +66,6 @@ export type UseTasksDataSourceOptions = {
crm?: Accessor<TaskCrmScope>;
enabled?: Accessor<boolean>;
networkPaused?: Accessor<boolean>;
- /** Project lists drain all cursors instead of requiring per-group Load More. */
- loadAll?: boolean;
board?: Accessor<boolean>;
};
@@ -76,8 +73,6 @@ export type TasksDataSourceItem = SoupRow<TaskEntityWithProperties>;
export type TasksDataSource = ListDataSource<TasksDataSourceItem> & {
loadMoreGroup: (groupId: string) => Promise<void>;
- paginationError?: Accessor<unknown>;
- retryPagination?: () => void;
/** Uncollapsed rows for alternative layouts; the query owner is shared. */
boardRows?: Accessor<TasksDataSourceItem[]>;
boardSearching?: Accessor<boolean>;
@@ -290,56 +285,6 @@ export function useTasksDataSource(
const groupQueryFor = (groupKey: string) =>
groupedQueries.map().get(groupKey);
- const automatic = createAutomaticTaskPagination({
- enabled: () =>
- Boolean(options.loadAll) &&
- facetOptionsReady() &&
- !options.networkPaused?.(),
- scope: () =>
- JSON.stringify([
- queryArgs(),
- state.search,
- options.userId(),
- options.enabled?.(),
- ]),
- sources: () => {
- if (search.isSearching()) {
- return [
- {
- id: 'search',
- hasMore: search.hasNextPage(),
- pending: search.isFetching(),
- load: async () => {
- await search.fetchNextPage();
- },
- error: search.error,
- },
- ];
- }
- if (query.isPending || query.isPlaceholderData) return [];
- return [
- {
- id: 'list',
- hasMore: query.hasNextPage,
- pending: query.isFetching,
- load: async () => {
- await query.fetchNextPage();
- },
- error: () => query.error,
- },
- ...[...groupedQueries.map().values()].map((group) => ({
- id: `group:${group.key}`,
- hasMore: group.hasNextPage(),
- pending: group.isFetchingNextPage(),
- load: async () => {
- await group.fetchNextPage();
- },
- error: group.error,
- })),
- ];
- },
- });
-
const continuations: TaskGroupContinuationReader = {
entities: (groupKey) =>
(groupQueryFor(groupKey)?.data()?.entities ?? []).flatMap((entity) =>
@@ -410,7 +355,7 @@ export function useTasksDataSource(
count: group.totalCount,
};
- if (!options.loadAll && continuations.hasMore(group.key)) {
+ if (continuations.hasMore(group.key)) {
taskGroup.loadMore = {
scopeId: `tasks:${group.key}`,
isLoading: continuations.isLoading(group.key),
@@ -458,7 +403,6 @@ export function useTasksDataSource(
};
const hasMore = () => {
- if (options.loadAll) return false;
if (usesServiceSearch()) return search.hasNextPage();
return query.hasNextPage;
};
@@ -527,7 +471,5 @@ export function useTasksDataSource(
loadMoreGroup: continuations.loadMore,
loadMore,
refresh,
- paginationError: automatic.error,
- retryPagination: automatic.retry,
} satisfies TasksDataSource;
}
diff --git a/apps/web/src/features/tasks-view/tasks-view-context.tsx b/apps/web/src/features/tasks-view/tasks-view-context.tsx
index 93719cb9d4..4fe18c2d88 100644
--- a/apps/web/src/features/tasks-view/tasks-view-context.tsx
+++ b/apps/web/src/features/tasks-view/tasks-view-context.tsx
@@ -470,7 +470,9 @@ export const [TasksViewProvider, useTasksView] = createAssertedContextProvider<
selection: {
getKey: (row) => (row.kind === 'entity' ? row.entity.id : row.id),
},
- isNavigable: (row) => row.kind !== 'section-header',
+ // Continuation rows load on their own when scrolled into view.
+ isNavigable: (row) =>
+ row.kind === 'entity' || row.kind === 'group-header',
isSelectable: (row) => row.kind === 'entity',
onActivate: (value) => activation.current?.(value),
})
diff --git a/apps/web/src/features/tasks-view/views/task-board-view.tsx b/apps/web/src/features/tasks-view/views/task-board-view.tsx
index 6b479deb25..efa10637dc 100644
--- a/apps/web/src/features/tasks-view/views/task-board-view.tsx
+++ b/apps/web/src/features/tasks-view/views/task-board-view.tsx
@@ -1,6 +1,8 @@
+import { useInfiniteScrollSentinel } from '@app/lib/primitives/infinite-scroll-sentinel';
import { toast } from '@core/component/Toast/Toast';
import { fireAndForget } from '@core/util/fireAndForget';
import PlusIcon from '@icon/system/regular/plus.svg';
+import SpinnerIcon from '@icon/system/regular/spinner.svg';
import { SYSTEM_PROPERTY_IDS } from '@property/identifiers';
import { hasValue } from '@property/utils/typeGuards';
import { Button } from '@ui/components/Button';
@@ -9,8 +11,10 @@ import {
createSignal,
For,
type JSX,
+ Match,
Show,
Suspense,
+ Switch,
} from 'solid-js';
import { TaskBoard } from '../components/task-board';
import {
@@ -95,26 +99,6 @@ export function TaskBoardView(props: {
}
};
- const loadMore = async (columnId?: string) => {
- if (columnId === undefined) {
- await source.loadMore();
- const error = source.error();
-
- if (error) {
- throw error;
- }
-
- return;
- }
-
- await source.loadMoreGroup(columnId);
- const error = source.groupError?.(columnId);
-
- if (error) {
- throw error;
- }
- };
-
const renderProperty = (
task: Accessor<TaskBoardTask>,
readOnly: Accessor<boolean>,
@@ -290,23 +274,30 @@ export function TaskBoardView(props: {
</p>
}
footer={
- <Show when={column().hasMore}>
- <div class="py-3">
- <Button
- size="sm"
- variant="secondary"
- disabled={column().loadingMore}
- onClick={() =>
+ <Switch>
+ <Match when={column().hasMore}>
+ <TaskBoardColumnContinuation
+ isLoading={column().loadingMore}
+ failed={Boolean(source.groupError?.(column().id))}
+ onLoad={() =>
fireAndForget(
- read(() => loadMore(column().id)),
+ source.loadMoreGroup(column().id),
'tasks-view'
)
}
- >
- {column().loadingMore ? 'Loading…' : 'Load more tasks'}
- </Button>
- </div>
- </Show>
+ />
+ </Match>
+ {/* Ungrouped results (search) continue from any column's end. */}
+ <Match when={source.hasMore()}>
+ <TaskBoardColumnContinuation
+ isLoading={source.isLoadingMore()}
+ failed={Boolean(source.error())}
+ onLoad={() =>
+ fireAndForget(source.loadMore(), 'tasks-view')
+ }
+ />
+ </Match>
+ </Switch>
}
>
{(task) => {
@@ -333,22 +324,38 @@ export function TaskBoardView(props: {
)}
</TaskBoard.Columns>
</TaskBoard.Root>
- <Show when={source.hasMore()}>
- <div class="p-3">
- <Button
- size="sm"
- variant="secondary"
- disabled={source.isLoadingMore()}
- onClick={() =>
- fireAndForget(
- read(() => loadMore()),
- 'tasks-view'
- )
- }
- >
- {source.isLoadingMore() ? 'Loading…' : 'Load more tasks'}
- </Button>
- </div>
+ </div>
+ );
+}
+
+/** Requests the column's next page while near its visible cards; a failure waits for Retry. */
+function TaskBoardColumnContinuation(props: {
+ isLoading: boolean;
+ failed: boolean;
+ onLoad: () => void;
+}) {
+ const [sentinel, setSentinel] = createSignal<HTMLDivElement>();
+ useInfiniteScrollSentinel({
+ sentinel,
+ hasNextPage: () => !props.failed,
+ isFetchingNextPage: () => props.isLoading,
+ fetchNextPage: () => props.onLoad(),
+ });
+
+ return (
+ <div
+ ref={setSentinel}
+ aria-busy={!props.failed}
+ class="flex flex-wrap items-center justify-center gap-2 py-3 text-xs text-ink-muted"
+ >
+ <Show
+ when={props.failed}
+ fallback={<SpinnerIcon class="size-4 animate-spin" />}
+ >
+ <span>Couldn’t load more tasks.</span>
+ <Button size="sm" variant="secondary" onClick={() => props.onLoad()}>
+ Retry
+ </Button>
</Show>
</div>
);
diff --git a/apps/web/src/features/tasks-view/views/task-gantt-view.tsx b/apps/web/src/features/tasks-view/views/task-gantt-view.tsx
index 4d2f6c3aed..722fce7435 100644
--- a/apps/web/src/features/tasks-view/views/task-gantt-view.tsx
+++ b/apps/web/src/features/tasks-view/views/task-gantt-view.tsx
@@ -1,6 +1,8 @@
import type { GanttCreation } from '@app/components/gantt/create-gantt-creation';
import { Gantt } from '@app/components/gantt/gantt';
import { deriveGanttRange } from '@app/components/gantt/gantt-date';
+import type { SoupLoadMoreRow } from '@app/features/soup';
+import { useInfiniteScrollSentinel } from '@app/lib/primitives/infinite-scroll-sentinel';
import { UserIcon } from '@core/component/UserIcon';
import { fireAndForget } from '@core/util/fireAndForget';
import {
@@ -19,6 +21,7 @@ import type { ComponentProps } from 'solid-js';
import {
type Accessor,
createMemo,
+ createSignal,
type JSX,
Match,
Show,
@@ -26,10 +29,7 @@ import {
} from 'solid-js';
import { STATUS_GROUP_HEADER_TINTS } from '../components/task-list/TaskGroupHeader';
import { taskGanttDates } from '../queries/task-gantt';
-import type {
- TasksDataSource,
- TasksDataSourceItem,
-} from '../queries/use-tasks-query';
+import type { TasksDataSource } from '../queries/use-tasks-query';
import type { TaskGroupBy } from '../types';
function EntityGroupLabel(props: {
@@ -40,6 +40,46 @@ function EntityGroupLabel(props: {
return <>{name()}</>;
}
+/** Requests the next page while near the visible rows; a failure waits for Retry. */
+function GanttContinuation(props: {
+ isLoading: boolean;
+ failed: boolean;
+ onLoad: () => void;
+}) {
+ const [sentinel, setSentinel] = createSignal<HTMLDivElement>();
+ useInfiniteScrollSentinel({
+ sentinel,
+ hasNextPage: () => !props.failed,
+ isFetchingNextPage: () => props.isLoading,
+ fetchNextPage: () => props.onLoad(),
+ });
+ const status = () => (
+ <Show
+ when={props.failed}
+ fallback={
+ <span class="flex items-center gap-1.5 px-2 text-ink-muted">
+ <SpinnerIcon class="size-3 animate-spin" />
+ Loading tasks…
+ </span>
+ }
+ >
+ <Button size="sm" variant="ghost" onClick={() => props.onLoad()}>
+ Retry loading tasks
+ </Button>
+ </Show>
+ );
+
+ return (
+ <>
+ {/* The label drawer can be hidden; this wrapper always spans the row. */}
+ <div ref={setSentinel} class="absolute inset-0">
+ <Gantt.Label>{status()}</Gantt.Label>
+ </div>
+ <Gantt.Pagination>{status()}</Gantt.Pagination>
+ </>
+ );
+}
+
export function TaskGanttView(props: {
createAssigneeName: (id: Accessor<string>) => Accessor<string>;
createProjectName: (id: Accessor<string>) => Accessor<string>;
@@ -67,9 +107,7 @@ export function TaskGanttView(props: {
props.source
.items()
.some((row) => row.kind === 'load-more' && row.groupId === undefined);
- const loadMore = (row: TasksDataSourceItem) => {
- if (row.kind !== 'load-more') return;
-
+ const loadMore = (row: SoupLoadMoreRow) => {
if (row.groupId !== undefined) {
fireAndForget(props.source.loadMoreGroup(row.groupId), 'tasks-view');
return;
@@ -77,6 +115,12 @@ export function TaskGanttView(props: {
fireAndForget(props.source.loadMore?.(), 'tasks-view');
};
+ const loadMoreFailed = (row: SoupLoadMoreRow) =>
+ Boolean(
+ row.groupId === undefined
+ ? error()
+ : props.source.groupError?.(row.groupId)
+ );
return (
<div ref={props.ref} class="flex size-full min-h-0 min-w-0 flex-col">
@@ -312,40 +356,11 @@ export function TaskGanttView(props: {
when={row.kind === 'load-more' ? row : undefined}
>
{(more) => (
- <>
- <div class="absolute inset-0">
- <Gantt.Label>
- <Button
- size="sm"
- variant="ghost"
- disabled={more().isLoading}
- onClick={() => loadMore(more())}
- >
- <Show when={more().isLoading}>
- <SpinnerIcon class="size-3 animate-spin" />
- </Show>
- {more().isLoading
- ? 'Loading tasks…'
- : 'Load more tasks'}
- </Button>
- </Gantt.Label>
- </div>
- <Gantt.Pagination>
- <Button
- size="sm"
- variant="ghost"
- disabled={more().isLoading}
- onClick={() => loadMore(more())}
- >
- <Show when={more().isLoading}>
- <SpinnerIcon class="size-3 animate-spin" />
- </Show>
- {more().isLoading
- ? 'Loading tasks…'
- : 'Load more tasks'}
- </Button>
- </Gantt.Pagination>
- </>
+ <GanttContinuation
+ isLoading={more().isLoading ?? false}
+ failed={loadMoreFailed(more())}
+ onLoad={() => loadMore(more())}
+ />
)}
</Match>
<Match
@@ -363,45 +378,13 @@ export function TaskGanttView(props: {
when={props.source.hasMore?.() && !hasGlobalLoadMoreRow()}
>
<Gantt.Row>
- <div class="absolute inset-0">
- <Gantt.Label>
- <Button
- size="sm"
- variant="ghost"
- disabled={props.source.isLoadingMore?.()}
- onClick={() =>
- fireAndForget(
- props.source.loadMore?.(),
- 'tasks-view'
- )
- }
- >
- <Show when={props.source.isLoadingMore?.()}>
- <SpinnerIcon class="size-3 animate-spin" />
- </Show>
- {props.source.isLoadingMore?.()
- ? 'Loading tasks…'
- : 'Load more tasks'}
- </Button>
- </Gantt.Label>
- </div>
- <Gantt.Pagination>
- <Button
- size="sm"
- variant="ghost"
- disabled={props.source.isLoadingMore?.()}
- onClick={() =>
- fireAndForget(props.source.loadMore?.(), 'tasks-view')
- }
- >
- <Show when={props.source.isLoadingMore?.()}>
- <SpinnerIcon class="size-3 animate-spin" />
- </Show>
- {props.source.isLoadingMore?.()
- ? 'Loading tasks…'
- : 'Load more tasks'}
- </Button>
- </Gantt.Pagination>
+ <GanttContinuation
+ isLoading={props.source.isLoadingMore?.() ?? false}
+ failed={Boolean(error())}
+ onLoad={() =>
+ fireAndForget(props.source.loadMore?.(), 'tasks-view')
+ }
+ />
</Gantt.Row>
</Show>
<Gantt.TodayMarker />
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 8ab72d2229..10e3f3f686 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,3 +1,4 @@
+import { fireAndForget } from '@core/util/fireAndForget';
import {
type Client,
CombinedError,
@@ -6,7 +7,12 @@ import {
type OperationContext,
type OperationResult,
} from '@urql/core';
-import { createComputed, createRoot, createSignal } from 'solid-js';
+import {
+ createComputed,
+ createEffect,
+ 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';
@@ -222,18 +228,14 @@ describe('grouped Soup live ownership', () => {
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'),
- },
- ],
+ // A reader that requests the next page as soon as one is reported, as a
+ // group whose end is already on screen does.
+ createEffect(() => {
+ if (
+ state.query.paging.hasNextPage('todo') &&
+ !state.query.paging.isFetchingNextPage('todo')
+ )
+ fireAndForget(state.query.paging.fetchNextPage('todo'), 'test');
});
});
state.executions[0].publish(page([groupedDocument('a')]));
@@ -615,5 +617,3 @@ 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/docs/agent-guide/soup-live-updates.md b/docs/agent-guide/soup-live-updates.md
index b25a650d5f..e2686185c6 100644
--- a/docs/agent-guide/soup-live-updates.md
+++ b/docs/agent-guide/soup-live-updates.md
@@ -40,8 +40,9 @@ network behavior.
### Grouped views
With maintained GraphQL cache queries, supported filters and a created/updated
-sort, loaded grouped rows also reconcile locally. Initial and per-group “load
-more” pages share one owner. Property edits (including multiple assignees),
+sort, loaded grouped rows also reconcile locally. Initial and per-group
+continuation pages share one owner; a group's next page loads when the end of
+that group scrolls into view. Property edits (including multiple assignees),
project changes and UTC date rollover can move loaded rows between bins; proven
filter nonmatches leave the view. Unknown evidence keeps the previous membership.
If local selection is incomplete, normalized display-field updates from initial
@@ -50,16 +51,17 @@ This is not a complete offline grouping query: uncached/unloaded candidates are
not added, and counts preserve unseen server rows rather than counting only the
loaded page. Unsupported sorts/filters retain server membership.
-To verify, load a second page in a property group, then edit a property on a row
+To verify, scroll to the end of a property group to load its second page, then
+edit a property on a row
from that page. It should appear in its destination once, disappear from its old
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
+multi-value membership and group counts, then scroll to 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
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
+An in-flight continuation page must remain covered by the replacement chain. Refreshes
emit `graphql_cache.soup_grouped_refresh`; the local phase emits
`graphql_cache.soup_grouped_local_evaluation`.
diff --git a/docs/agent-guide/tasks.md b/docs/agent-guide/tasks.md
index db07ab8096..af6ee69d77 100644
--- a/docs/agent-guide/tasks.md
+++ b/docs/agent-guide/tasks.md
@@ -50,13 +50,17 @@ wrapping property pills, description, and discussion for Overview; toolbar and
rows for Tasks. The mobile skeleton uses the same compact insets as the content.
The description has its own subtle three-line skeleton while its collaborative
editor initializes; the project title, properties, and discussion stay visible.
-Project task lists automatically fetch all matching pages in every group, without
-per-group `Load More` rows. A failed continuation stops automatic requests and shows
-`Try again` above the list; already fetched group rows remain available.
+Task lists, including project and CRM task lists, load a group's next page when
+the end of that group scrolls into view, with a spinner row instead of a
+`Load More` button. A failed
+page shows `Retry` in that row and stops automatic requests for the group.
+ArrowDown waits on a group's last loaded task until the next page arrives; after
+a failure it continues into the next group. Collapsed groups load nothing. A page
+that arrives after you scroll past its group must not move the rows on screen.
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.
+regular Tasks list and a project task list (scroll and ArrowDown). Both must use
+the parent Soup query's continuation owner; reaching
+the last page removes the group's paging row 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,
@@ -284,11 +288,13 @@ The timeline reuses the list's filtered, sorted, grouped rows and collapsed
state. Sidebar items fill the list's inset width and share vertical scrolling with
bars. Compact group headers show the grouping's icon and span both the list and
calendar; they remain visible when the list is collapsed.
-Pagination remains available in the item list and as a quiet, labeled action at
-the visible calendar's left edge outside the open list, even after horizontal
-panning. Group pagination stays after its group; the global continuation appears
-once after the loaded rows. Loading shows a spinner and disables both actions;
-pagination and group headers do not start range creation.
+A continuation row loads the next page when it scrolls near the visible rows,
+showing a spinner in the item list and at the visible calendar's left edge
+outside the open list, even after horizontal panning. A failed page shows
+**Retry loading tasks** there instead. Group continuations stay after their
+group; the global continuation appears once after the loaded rows. As in the
+list, a page that lands above the visible rows keeps them in place. Continuation
+rows and group headers do not start range creation.
The chart contains loaded results, not an implied complete schedule. Selecting
Gantt persists in `tasks.layout` or `projectTasks.layout`, just like List and Board.
@@ -327,7 +333,10 @@ Layout, primary sort, sort direction, and grouping are reflected in `tasks.layou
`tasks.sort`, `tasks.sortReversed`, and `tasks.groupBy` search parameters.
Explicit URL values override saved preferences; back/forward navigation
restores the corresponding controls, including the layout.
-Columns are 336px wide. Each column pages independently with **Load more tasks**.
+Columns are 336px wide. Each column loads its next page when the end of its cards
+scrolls into view; a failed page shows **Retry** at the bottom of that column.
+Ungrouped results, such as a search, load their next page from the end of any
+column.
Use the horizontal scrollbar to reach more columns. Vertical wheel input over
empty board background or gaps also scrolls horizontally. A wheel gesture stays
with its original scroll area until momentum stops, even if another column moves