mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 12:54:20 +01:00
fix(sessions): include worktree sessions in the session picker
This commit is contained in:
1 parent
d9843a0ff7
commit
08c03235c8
2 files changed
+58
-2
No files matched your search
@@ -14,6 +14,7 @@ const mocks = vi.hoisted(() => ({
|
||||
fetchNextPage: vi.fn(),
|
||||
deleteSessionMock: vi.fn(),
|
||||
togglePinMock: vi.fn(),
|
||||
siblings: [] as Array<Repo & { worktreeSource?: 'opencode' | 'schedule' | 'git' }>,
|
||||
sessionPins: [] as Array<{ sessionId: string; directory: string; pinnedAt: number }>,
|
||||
repos: [] as Repo[],
|
||||
}))
|
||||
@@ -47,6 +48,10 @@ vi.mock('@/hooks/useOpenCode', async (importOriginal) => {
|
||||
}
|
||||
})
|
||||
|
||||
vi.mock('@/hooks/useRepoSiblings', () => ({
|
||||
useRepoSiblings: () => ({ data: mocks.siblings }),
|
||||
}))
|
||||
|
||||
vi.mock('@/hooks/useSessionPins', () => ({
|
||||
useSessionPins: () => ({ data: mocks.sessionPins }),
|
||||
useToggleSessionPin: () => ({ mutate: mocks.togglePinMock }),
|
||||
@@ -85,6 +90,10 @@ function repo(id: number, name: string, fullPath: string): Repo {
|
||||
}
|
||||
}
|
||||
|
||||
function worktreeSibling(id: number, name: string, fullPath: string): Repo & { worktreeSource: 'opencode' } {
|
||||
return { ...repo(id, name, fullPath), isWorktree: true, worktreeSource: 'opencode' }
|
||||
}
|
||||
|
||||
function renderPicker(overrides: Partial<React.ComponentProps<typeof SessionPickerDialog>> = {}) {
|
||||
const onOpenChange = vi.fn()
|
||||
const onSelectSession = vi.fn()
|
||||
@@ -110,6 +119,7 @@ describe('SessionPickerDialog', () => {
|
||||
stubMatchMedia(true)
|
||||
localStorage.clear()
|
||||
mocks.deleteSessionMock.mockResolvedValue(undefined)
|
||||
mocks.siblings = []
|
||||
mocks.sessionPins = []
|
||||
mocks.repos = [repo(1, 'alpha', '/w/a'), repo(2, 'beta', '/w/b')]
|
||||
mocks.sessionsData = []
|
||||
@@ -212,6 +222,26 @@ describe('SessionPickerDialog', () => {
|
||||
expect(localStorage.getItem('oc:session-picker:all-projects')).toBe('false')
|
||||
})
|
||||
|
||||
it('includes the repo worktrees and labels worktree sessions with the folder name', () => {
|
||||
mocks.repos = [repo(1, 'alpha', '/w/a')]
|
||||
mocks.siblings = [
|
||||
repo(1, 'alpha', '/w/a'),
|
||||
worktreeSibling(2, 'alpha', '/w/worktrees/alpha-feature'),
|
||||
]
|
||||
mocks.sessionsData = [
|
||||
session('ses_root', 'Root session', '/w/a', 2000),
|
||||
session('ses_wt', 'Worktree session', '/w/worktrees/alpha-feature', 1000),
|
||||
]
|
||||
|
||||
renderPicker()
|
||||
|
||||
expect(mocks.lastDirectories).toEqual(['/w/a', '/w/worktrees/alpha-feature'])
|
||||
expect(screen.getByText('Worktree session')).toBeInTheDocument()
|
||||
expect(screen.getByText('Root session')).toBeInTheDocument()
|
||||
expect(screen.getByText('alpha-feature')).toBeInTheDocument()
|
||||
expect(screen.getByRole('option', { name: /Root session/ }).textContent).not.toContain('alpha-feature')
|
||||
})
|
||||
|
||||
it('does not query sessions while closed and queries after opening', async () => {
|
||||
mocks.sessionsData = [session('ses_1', 'First', '/w/a', 3000)]
|
||||
|
||||
|
||||
Reference in new issue
Block a user