Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions src/renderer/state/sidebarUiStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ interface SidebarUiState {
togglePinnedGitHubWorkflow: (projectId: string, workflowId: number) => void;
setWorktreeCollapsed: (key: string, collapsed: boolean) => void;
toggleWorktreeCollapsed: (key: string) => void;
revealMoreThreads: (projectId: string) => void;
revealMoreThreads: (projectId: string, pageSize?: number) => void;
setFlatListProjectFilter: (projectIds: string[] | null) => void;
setEditingThreadId: (id: string | null) => void;
}
Expand Down Expand Up @@ -109,13 +109,13 @@ export const useSidebarUiStore = create<SidebarUiState>()(
},
};
}),
revealMoreThreads: (projectId) =>
revealMoreThreads: (projectId, pageSize = SIDEBAR_THREAD_LIST_PAGE_SIZE) =>
set((state) => {
const current = state.threadListLimits[projectId] ?? SIDEBAR_THREAD_LIST_PAGE_SIZE;
const current = state.threadListLimits[projectId] ?? pageSize;
return {
threadListLimits: {
...state.threadListLimits,
[projectId]: current + SIDEBAR_THREAD_LIST_PAGE_SIZE,
[projectId]: current + pageSize,
},
};
}),
Expand Down Expand Up @@ -158,8 +158,11 @@ export function useIsProjectCollapsed(projectId: string): boolean {
return useSidebarUiStore((s) => s.collapsedProjects[projectId] ?? false);
}

export function useThreadListLimit(projectId: string): number {
return useSidebarUiStore((s) => s.threadListLimits[projectId] ?? SIDEBAR_THREAD_LIST_PAGE_SIZE);
export function useThreadListLimit(
projectId: string,
pageSize: number = SIDEBAR_THREAD_LIST_PAGE_SIZE,
): number {
return useSidebarUiStore((s) => s.threadListLimits[projectId] ?? pageSize);
}

export function useIsWorktreeCollapsed(key: string): boolean {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ import { useSidebarUiStore, useThreadListLimit } from "@/renderer/state/sidebarU
import { useWorkspaceProjectIds } from "@/renderer/state/workspaceSelectors";
import { NewThreadButton } from "./NewThreadButton";
import { SidebarProjectFilter } from "./SidebarProjectFilter";
import { buildSidebarProjectRows, type SidebarRow } from "./sidebarProjectRows";
import {
buildSidebarProjectRows,
SIDEBAR_FLAT_THREAD_LIST_PAGE_SIZE,
type SidebarRow,
} from "./sidebarProjectRows";
import type { ThreadSortMode } from "./sortMode";
import { SeeMoreThreadsButton, SidebarThreadRow } from "./SidebarThreadRow";

Expand Down Expand Up @@ -55,7 +59,7 @@ export function SidebarFlatThreadList(props: { sortMode: ThreadSortMode }) {
const revealMoreThreads = useSidebarUiStore((s) => s.revealMoreThreads);
const flatListProjectFilter = useSidebarUiStore((s) => s.flatListProjectFilter);
const setFlatListProjectFilter = useSidebarUiStore((s) => s.setFlatListProjectFilter);
const visibleLimit = useThreadListLimit(FLAT_LIST_SCOPE);
const visibleLimit = useThreadListLimit(FLAT_LIST_SCOPE, SIDEBAR_FLAT_THREAD_LIST_PAGE_SIZE);
const currentThreadCount = useCurrentThreadIdsCount();
const source = useDragSource();

Expand Down Expand Up @@ -169,7 +173,9 @@ export function SidebarFlatThreadList(props: { sortMode: ThreadSortMode }) {
return (
<SeeMoreThreadsButton
key={row.key}
onPress={() => revealMoreThreads(FLAT_LIST_SCOPE)}
onPress={() =>
revealMoreThreads(FLAT_LIST_SCOPE, SIDEBAR_FLAT_THREAD_LIST_PAGE_SIZE)
}
/>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ export type SidebarRow =
/** Default number of list items shown per project before the "See more" row. */
export const SIDEBAR_THREAD_LIST_PAGE_SIZE = 10;

/**
* Page size for the flat (cross-project) list. It is the sidebar's only list,
* so it affords a taller first page than a per-project section.
*/
export const SIDEBAR_FLAT_THREAD_LIST_PAGE_SIZE = 20;

const EMPTY_THREAD_ID_SET: ReadonlySet<string> = new Set();

/**
Expand Down