mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 12:54:20 +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
@@ -5,7 +5,9 @@ import { SessionStatusIndicator } from '@/components/ui/session-status-indicator
|
||||
import { RepoActivityIndicator } from '@/components/activity/RepoActivityIndicator'
|
||||
import { useForms, usePermissions } from '@/contexts/EventContext'
|
||||
import { useCreateSession } from '@/hooks/useOpenCode'
|
||||
import { useRepoSiblings } from '@/hooks/useRepoSiblings'
|
||||
import { useSidebarRepoGroups } from '@/hooks/useSidebarRepoGroups'
|
||||
import { buildWorktreeActivity, type ActiveWorktree } from '@/lib/activeWork'
|
||||
import { cn, formatShortRelativeTime, getRepoBranchLabel, getRepoDisplayName } from '@/lib/utils'
|
||||
import { getRepoPath, getSessionPath } from '@/lib/navigation'
|
||||
import {
|
||||
@@ -118,13 +120,14 @@ interface SessionNavRowProps {
|
||||
export function SessionNavRow({ item, isCurrent, onSelect, repoLabel }: SessionNavRowProps) {
|
||||
const { hasForSession: hasPermission } = usePermissions()
|
||||
const { hasForSession: hasForm } = useForms()
|
||||
const branchLabel = item.worktreeBranch ?? item.branchLabel
|
||||
|
||||
return (
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => onSelect(item.path)}
|
||||
aria-current={isCurrent ? 'page' : undefined}
|
||||
title={item.branchLabel ? `${item.repoLabel} · ${item.branchLabel}` : item.repoLabel}
|
||||
title={branchLabel ? `${item.repoLabel} · ${branchLabel}` : item.repoLabel}
|
||||
className={cn(
|
||||
'flex h-9 w-full items-center gap-2 pl-4 pr-3.5 text-left text-[13.5px] text-foreground hover:bg-accent/50',
|
||||
isCurrent && 'bg-primary/25 font-semibold',
|
||||
@@ -137,6 +140,11 @@ export function SessionNavRow({ item, isCurrent, onSelect, repoLabel }: SessionN
|
||||
{repoLabel && (
|
||||
<span className="max-w-24 shrink-0 truncate text-xs text-highlight">{repoLabel}</span>
|
||||
)}
|
||||
{item.worktreeBranch && (
|
||||
<span className="max-w-24 shrink-0 truncate font-mono text-[11px] text-primary">
|
||||
{item.worktreeBranch}
|
||||
</span>
|
||||
)}
|
||||
<SessionStatusIndicator sessionID={item.session.id} size="sm" />
|
||||
{hasPermission(item.session.id) && (
|
||||
<Bell className="h-3 w-3 shrink-0 text-highlight" aria-label="Pending permission" />
|
||||
@@ -186,9 +194,32 @@ interface RepoSessionListProps {
|
||||
}
|
||||
|
||||
function RepoSessionList({ repo, onSelectSession }: RepoSessionListProps) {
|
||||
const siblings = useRepoSiblings(repo.isWorktree ? undefined : repo.id)
|
||||
const worktrees = useMemo(
|
||||
() =>
|
||||
repo.isWorktree
|
||||
? undefined
|
||||
: buildWorktreeActivity([repo], [{ data: siblings.data }]).filter(
|
||||
(worktree) => !worktree.isSchedule,
|
||||
),
|
||||
[repo, siblings.data],
|
||||
)
|
||||
|
||||
if (siblings.isLoading) return <SessionNavStatus>Loading sessions...</SessionNavStatus>
|
||||
|
||||
return <RepoSessionListItems repo={repo} worktrees={worktrees} onSelectSession={onSelectSession} />
|
||||
}
|
||||
|
||||
interface RepoSessionListItemsProps {
|
||||
repo: Repo
|
||||
worktrees?: ActiveWorktree[]
|
||||
onSelectSession: (path: string) => void
|
||||
}
|
||||
|
||||
function RepoSessionListItems({ repo, worktrees, onSelectSession }: RepoSessionListItemsProps) {
|
||||
const location = useLocation()
|
||||
const repos = useMemo(() => [repo], [repo])
|
||||
const { groups, isLoading, isError, hasMore } = useSidebarRepoGroups({ repos })
|
||||
const { groups, isLoading, isError, hasMore } = useSidebarRepoGroups({ repos, worktrees })
|
||||
const items = groups[0]?.items ?? []
|
||||
|
||||
if (isLoading) return <SessionNavStatus>Loading sessions...</SessionNavStatus>
|
||||
|
||||
Reference in new issue
Block a user