mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 04:44:21 +01:00
fix(activity): report failed worktree lookups instead of showing partial session lists
This commit is contained in:
1 parent
bfbbbf08ef
commit
62c2eb8aed
5 files changed
+35
-4
No files matched your search
@@ -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),
|
||||
}),
|
||||
})
|
||||
}
|
||||
Reference in new issue
Block a user