fix(activity): report failed worktree lookups instead of showing partial session lists

This commit is contained in:
Chris Scott committed 2026-10-16 20:50:35 +00:00
1 parent bfbbbf08ef
commit 62c2eb8aed
5 files changed
+35 -4

No files matched your search

+5 -2
View File
@@ -7,12 +7,14 @@ import type { Repo } from '@/api/types'
/**
* Discovers each repo's worktrees from its siblings while enabled, keyed by directory so a session
* running in a worktree resolves to the repo that owns it. Each query is skipped for repos without
* a positive id. `isLoading` is true while any enabled siblings query is still loading.
* a positive id. `isLoading` is true while any enabled siblings query is still loading. `isError`
* is true only when a siblings query has failed with no data, so a failed refetch that still has
* cached data is not an error.
*/
export function useRepoWorktrees(
repos: Repo[],
enabled: boolean,
): { worktrees: ActiveWorktree[]; isLoading: boolean } {
): { worktrees: ActiveWorktree[]; isLoading: boolean; isError: boolean } {
return useQueries({
queries: repos.map((repo) => ({
queryKey: repoSiblingsQueryKey(repo.id),
@@ -23,6 +25,7 @@ export function useRepoWorktrees(
combine: (results) => ({
worktrees: buildWorktreeActivity(repos, results),
isLoading: results.some((result) => result.isLoading),
isError: results.some((result) => result.isError && result.data === undefined),
}),
})
}