mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-05 20:34:18 +01:00
fix(activity): surface worktree sessions in active work, the sidebar and repo badges
- Resolve sessions in repo worktrees to the owning repo in the activity list; show the worktree branch and open the Workspaces tab - Look up worktrees only for unmatched sessions in the window or under an active root, and hold the loading state until it settles - Show schedule-worktree sessions only while running or needing input - Light repo badges for worktree sessions through one app-wide worktree lookup - List worktree sessions under the expanded repo in the sidebar - Subscribe the event stream to active session directories so worktree permissions and forms arrive - Keep the worktree tab when navigating from the desktop Activity panel - Remove the braille spinner's always-dim bottom row
This commit is contained in:
1 parent
1d31286904
commit
bfbbbf08ef
23 files changed
+932
-81
No files matched your search
@@ -0,0 +1,28 @@
|
||||
import { useQueries } from '@tanstack/react-query'
|
||||
import { getRepoSiblings } from '@/api/repos'
|
||||
import { repoSiblingsQueryKey } from '@/hooks/useRepoSiblings'
|
||||
import { buildWorktreeActivity, type ActiveWorktree } from '@/lib/activeWork'
|
||||
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.
|
||||
*/
|
||||
export function useRepoWorktrees(
|
||||
repos: Repo[],
|
||||
enabled: boolean,
|
||||
): { worktrees: ActiveWorktree[]; isLoading: boolean } {
|
||||
return useQueries({
|
||||
queries: repos.map((repo) => ({
|
||||
queryKey: repoSiblingsQueryKey(repo.id),
|
||||
queryFn: () => getRepoSiblings(repo.id),
|
||||
enabled: enabled && repo.id > 0,
|
||||
staleTime: 30_000,
|
||||
})),
|
||||
combine: (results) => ({
|
||||
worktrees: buildWorktreeActivity(repos, results),
|
||||
isLoading: results.some((result) => result.isLoading),
|
||||
}),
|
||||
})
|
||||
}
|
||||
Reference in new issue
Block a user