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
@@ -14,6 +14,7 @@ const WINDOW_MS = 60 * MS_PER_MINUTE
|
||||
const mocks = vi.hoisted(() => ({
|
||||
listSessionPage: vi.fn(),
|
||||
getSession: vi.fn(),
|
||||
getRepoSiblings: vi.fn(),
|
||||
useNavigableRepos: vi.fn(),
|
||||
pendingSessionIDs: [] as string[],
|
||||
}))
|
||||
@@ -27,6 +28,14 @@ vi.mock('@/api/opencode', async (importOriginal) => {
|
||||
}
|
||||
})
|
||||
|
||||
vi.mock('@/api/repos', async (importOriginal) => {
|
||||
const actual = await importOriginal<typeof import('@/api/repos')>()
|
||||
return {
|
||||
...actual,
|
||||
getRepoSiblings: mocks.getRepoSiblings,
|
||||
}
|
||||
})
|
||||
|
||||
vi.mock('@/hooks/useSidebarRepoGroups', () => ({
|
||||
useNavigableRepos: mocks.useNavigableRepos,
|
||||
}))
|
||||
@@ -48,12 +57,17 @@ vi.mock('@/lib/toast', () => ({
|
||||
},
|
||||
}))
|
||||
|
||||
const session = (id: string, updated: number, parentID?: string | null): SessionInfo => ({
|
||||
const session = (
|
||||
id: string,
|
||||
updated: number,
|
||||
parentID?: string | null,
|
||||
directory = REPO_PATH,
|
||||
): SessionInfo => ({
|
||||
id,
|
||||
projectID: 'proj_1',
|
||||
title: `Session ${id}`,
|
||||
time: { created: updated, updated },
|
||||
location: { directory: REPO_PATH },
|
||||
location: { directory },
|
||||
cost: 0,
|
||||
tokens: { input: 0, output: 0, reasoning: 0, cache: { read: 0, write: 0 } },
|
||||
...(parentID === undefined ? {} : { parentID }),
|
||||
@@ -83,6 +97,8 @@ describe('useActiveWork', () => {
|
||||
beforeEach(() => {
|
||||
mocks.listSessionPage.mockReset()
|
||||
mocks.getSession.mockReset()
|
||||
mocks.getRepoSiblings.mockReset()
|
||||
mocks.getRepoSiblings.mockResolvedValue([])
|
||||
mocks.useNavigableRepos.mockReset()
|
||||
mocks.useNavigableRepos.mockReturnValue({ repos: [repo], isLoading: false, refetch: vi.fn() })
|
||||
useSessionStatus.setState({
|
||||
@@ -197,4 +213,50 @@ describe('useActiveWork', () => {
|
||||
|
||||
expect(recentIDs(result.current.groups)).not.toContain('root')
|
||||
})
|
||||
|
||||
it('resolves a session in a worktree to its owning repo and opens the workspaces tab', async () => {
|
||||
const now = Date.now()
|
||||
mocks.listSessionPage.mockResolvedValue({
|
||||
items: [session('wt', now - 500, undefined, '/repo/.worktrees/feature')],
|
||||
})
|
||||
mocks.getRepoSiblings.mockResolvedValue([
|
||||
{
|
||||
...repo,
|
||||
id: -1,
|
||||
fullPath: '/repo/.worktrees/feature',
|
||||
localPath: 'feature',
|
||||
sourcePath: '/repo/.worktrees/feature',
|
||||
currentBranch: 'feature',
|
||||
worktreeSource: 'opencode',
|
||||
},
|
||||
])
|
||||
|
||||
const { result } = renderHook(() => useActiveWork(WINDOW_MS), {
|
||||
wrapper: createWrapper(createQueryClient()),
|
||||
})
|
||||
|
||||
await waitFor(() => expect(recentIDs(result.current.groups)).toContain('wt'))
|
||||
|
||||
expect(result.current.groups.recent[0].repo.id).toBe(1)
|
||||
expect(result.current.groups.recent[0].path).toBe('/repos/1/sessions/wt?repoTab=workspaces')
|
||||
})
|
||||
|
||||
it('never fetches siblings for an orphan session updated outside the window', async () => {
|
||||
const now = Date.now()
|
||||
mocks.listSessionPage.mockResolvedValue({
|
||||
items: [session('orphan', now - 2 * WINDOW_MS, undefined, '/outside/repo')],
|
||||
})
|
||||
|
||||
const { result } = renderHook(() => useActiveWork(WINDOW_MS), {
|
||||
wrapper: createWrapper(createQueryClient()),
|
||||
})
|
||||
|
||||
await waitFor(() => expect(result.current.isLoading).toBe(false))
|
||||
|
||||
await act(async () => {
|
||||
await Promise.resolve()
|
||||
})
|
||||
|
||||
expect(mocks.getRepoSiblings).not.toHaveBeenCalled()
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user