mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 12:54:20 +01:00
fix: update settings and skills handling with assistant redirect (#220)
* fix: enable swipe-back suspension on more drawer and remove unused variable * refactor(frontend): improve dialog component and settings navigation * fix: disable route swipe suspension in MoreDrawer to prevent unintended navigation * fix(frontend): enable swipe-back suspension on more drawer route * refactor(frontend): improve mobile navigation drawer and tab bar * feat: add schedules service and workspace hook with navigation updates * chore: add workspace hook, schedules library, and tests * fix: prevent MoreDrawer sentinel from undoing navigation * feat: per-agent model selection and UI refinements (#217) * feat: per-agent model selection and UI refinements - Add agentModels store with setAgentModel/getAgentModel - PromptInput uses session model priority and stores agent model on change - useContextUsage derives model from assistant message instead of global - Migrate sub-agent/subtask badges from purple to blue with refined styling - Fix MoreDrawer sentinel to skip history-back on navigation * refactor: improve per-agent model selection and task tool call status indicators * feat: add repo management skill and internal repos API * fix: improve assistant session launcher and UI components * fix: update atomic-json test assertions * refactor: split Assistant Mode instructions between AGENTS.md and assistant.md * loop: todo-header-mobile completed after 3 iterations (#218) * loop: stt-perf-1 completed after 5 iterations * fix: load audio worklet per recording context * fix: canonicalize assistant navigation routes * fix: adjust scroll-up threshold for header visibility * fix: update settings and skills handling with assistant redirect * refactor: simplify context usage indicator and extract token sum helper * feat: add currently selected model row to popover and fix responsive truncate
This commit is contained in:
1 parent
c7291518c8
commit
74cdeb3926
73 files changed
+4073
-632
No files matched your search
@@ -1,5 +1,5 @@
|
||||
import { describe, it, expect, vi, beforeEach } from 'vitest'
|
||||
import { renderHook, waitFor } from '@testing-library/react'
|
||||
import { renderHook } from '@testing-library/react'
|
||||
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
|
||||
import { useMessages } from '../useOpenCode'
|
||||
|
||||
@@ -43,10 +43,8 @@ describe('useMessages fallback poll', () => {
|
||||
expect(mocks.listMessages).toHaveBeenCalledTimes(1)
|
||||
|
||||
await vi.advanceTimersByTimeAsync(5000)
|
||||
|
||||
await waitFor(() => {
|
||||
expect(mocks.listMessages).toHaveBeenCalledTimes(2)
|
||||
})
|
||||
|
||||
expect(mocks.listMessages).toHaveBeenCalledTimes(2)
|
||||
|
||||
vi.useRealTimers()
|
||||
})
|
||||
|
||||
@@ -0,0 +1,136 @@
|
||||
import { describe, it, expect, vi, beforeEach } from 'vitest'
|
||||
import { renderHook, waitFor } from '@testing-library/react'
|
||||
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
|
||||
import { useWorkspace } from '../useWorkspace'
|
||||
import type { AssistantModeStatus, Repo } from '@opencode-manager/shared/types'
|
||||
|
||||
const mocks = vi.hoisted(() => ({
|
||||
getRepo: vi.fn(),
|
||||
getAssistantModeStatus: vi.fn(),
|
||||
}))
|
||||
|
||||
vi.mock('@/api/repos', () => ({
|
||||
getRepo: mocks.getRepo,
|
||||
getAssistantModeStatus: mocks.getAssistantModeStatus,
|
||||
}))
|
||||
|
||||
const createWrapper = () => {
|
||||
const queryClient = new QueryClient({
|
||||
defaultOptions: {
|
||||
queries: { retry: false },
|
||||
mutations: { retry: false },
|
||||
},
|
||||
})
|
||||
return ({ children }: { children: React.ReactNode }) =>
|
||||
<QueryClientProvider client={queryClient}>{children}</QueryClientProvider>
|
||||
}
|
||||
|
||||
describe('useWorkspace', () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks()
|
||||
})
|
||||
|
||||
describe('repoId === 0 (assistant)', () => {
|
||||
it('returns assistant workspace with correct properties', async () => {
|
||||
const mockStatus: AssistantModeStatus = {
|
||||
repoId: 0,
|
||||
directory: '/abs/assistant',
|
||||
relativePath: 'repos/assistant',
|
||||
files: {
|
||||
agentsMd: { path: '', exists: false, created: false },
|
||||
opencodeJson: { path: '', exists: false, created: false },
|
||||
},
|
||||
schedulesSkill: { path: '', exists: false, created: false },
|
||||
}
|
||||
|
||||
mocks.getAssistantModeStatus.mockResolvedValue(mockStatus)
|
||||
|
||||
const { result } = renderHook(() => useWorkspace(0), { wrapper: createWrapper() })
|
||||
|
||||
await waitFor(() => {
|
||||
expect(result.current.workspace).toBeDefined()
|
||||
})
|
||||
|
||||
expect(result.current.workspace?.kind).toBe('assistant')
|
||||
expect(result.current.workspace?.fullPath).toBe('/abs/assistant')
|
||||
expect(result.current.workspace?.repoId).toBe(0)
|
||||
expect(result.current.workspace?.backHref).toBe('/assistant')
|
||||
expect(result.current.isLoading).toBe(false)
|
||||
expect(result.current.isError).toBe(false)
|
||||
})
|
||||
|
||||
it('does not call getRepo for assistant', async () => {
|
||||
mocks.getAssistantModeStatus.mockResolvedValue({
|
||||
directory: '/abs/assistant',
|
||||
relativePath: 'repos/assistant',
|
||||
files: { agentsMd: { path: '', exists: false, created: false }, opencodeJson: { path: '', exists: false, created: false } },
|
||||
schedulesSkill: { path: '', exists: false, created: false },
|
||||
repoId: 0,
|
||||
})
|
||||
|
||||
renderHook(() => useWorkspace(0), { wrapper: createWrapper() })
|
||||
|
||||
await vi.waitFor(() => {
|
||||
expect(mocks.getRepo).not.toHaveBeenCalled()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('repoId === 5 (real repo)', () => {
|
||||
it('returns repo workspace with correct properties', async () => {
|
||||
const mockRepo: Repo = {
|
||||
id: 5,
|
||||
repoUrl: 'https://x/my-repo',
|
||||
localPath: 'repos/my-repo',
|
||||
fullPath: '/abs/repos/my-repo',
|
||||
sourcePath: undefined,
|
||||
defaultBranch: 'main',
|
||||
cloneStatus: 'ready',
|
||||
clonedAt: 0,
|
||||
}
|
||||
|
||||
mocks.getRepo.mockResolvedValue(mockRepo)
|
||||
|
||||
const { result } = renderHook(() => useWorkspace(5), { wrapper: createWrapper() })
|
||||
|
||||
await waitFor(() => {
|
||||
expect(result.current.workspace).toBeDefined()
|
||||
})
|
||||
|
||||
expect(result.current.workspace?.kind).toBe('repo')
|
||||
expect(result.current.workspace?.repoId).toBe(5)
|
||||
expect(result.current.workspace?.fullPath).toBe('/abs/repos/my-repo')
|
||||
expect(result.current.workspace?.backHref).toBe('/repos/5')
|
||||
})
|
||||
|
||||
it('does not call getAssistantModeStatus for repo', async () => {
|
||||
const mockRepo: Repo = {
|
||||
id: 5,
|
||||
repoUrl: 'https://x/my-repo',
|
||||
localPath: 'repos/my-repo',
|
||||
fullPath: '/abs/repos/my-repo',
|
||||
sourcePath: undefined,
|
||||
defaultBranch: 'main',
|
||||
cloneStatus: 'ready',
|
||||
clonedAt: 0,
|
||||
}
|
||||
|
||||
mocks.getRepo.mockResolvedValue(mockRepo)
|
||||
|
||||
renderHook(() => useWorkspace(5), { wrapper: createWrapper() })
|
||||
|
||||
await vi.waitFor(() => {
|
||||
expect(mocks.getAssistantModeStatus).not.toHaveBeenCalled()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('repoId === undefined', () => {
|
||||
it('returns undefined workspace', () => {
|
||||
const { result } = renderHook(() => useWorkspace(undefined), { wrapper: createWrapper() })
|
||||
|
||||
expect(result.current.workspace).toBeUndefined()
|
||||
expect(result.current.isLoading).toBe(false)
|
||||
})
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user