mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 21:04:23 +01:00
Feat/assistant session list (#198)
* feat: add assistant mode integration and fix test environment - Add assistant-mode service for managing assistant workspace files (AGENTS.md, opencode.json) - Add backend GET/POST routes for assistant-mode status and initialization - Add AssistantRedirect page and useAssistantSessionLauncher hook - Update mobile navigation to include Assistant tab (replaces Alerts) - Fix React.act compatibility by setting NODE_ENV=test in vitest config - Add shared Zod schemas for AssistantMode types and requests * feat: enhance assistant mode with session list view and legacy config migration - Add session list view for assistant mode with full workspace management - Migrate legacy opencode.json permission format to granular permissions - Enable assistant navigation from mobile tab bar and repo switcher - Preserve assistant context in session routes via query params - Auto-restart OpenCode server after assistant mode initialization - Add comprehensive tests for legacy config detection and navigation
This commit is contained in:
1 parent
0a2e337efc
commit
c894ff5756
22 files changed
+1347
-154
No files matched your search
@@ -1,6 +1,6 @@
|
||||
import { render, screen, fireEvent, waitFor } from '@testing-library/react'
|
||||
import { describe, it, expect, vi } from 'vitest'
|
||||
import { MemoryRouter } from 'react-router-dom'
|
||||
import { MemoryRouter, Route, Routes, useLocation } from 'react-router-dom'
|
||||
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
|
||||
import { RepoQuickSwitchSheet } from './RepoQuickSwitchSheet'
|
||||
import { listRepos } from '@/api/repos'
|
||||
@@ -24,6 +24,11 @@ function createWrapper() {
|
||||
)
|
||||
}
|
||||
|
||||
function LocationSpy() {
|
||||
const { pathname, search } = useLocation()
|
||||
return <div data-testid="location">{`${pathname}${search}`}</div>
|
||||
}
|
||||
|
||||
describe('RepoQuickSwitchSheet', () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks()
|
||||
@@ -117,4 +122,46 @@ describe('RepoQuickSwitchSheet', () => {
|
||||
fireEvent.click(screen.getByText('repo1'))
|
||||
expect(handleClose).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('navigates directly to assistant when mobileTabAction is assistant', async () => {
|
||||
vi.mocked(listRepos).mockResolvedValue([
|
||||
{
|
||||
id: 1,
|
||||
repoUrl: 'https://github.com/test/repo1.git',
|
||||
localPath: '/path/to/repo1',
|
||||
sourcePath: null,
|
||||
currentBranch: 'main',
|
||||
isLocal: false,
|
||||
createdAt: new Date().toISOString(),
|
||||
updatedAt: new Date().toISOString(),
|
||||
},
|
||||
])
|
||||
const handleClose = vi.fn()
|
||||
render(
|
||||
<QueryClientProvider client={new QueryClient()}>
|
||||
<MemoryRouter initialEntries={['/schedules?mobileTab=repos&mobileTabAction=assistant']}>
|
||||
<Routes>
|
||||
<Route
|
||||
path="*"
|
||||
element={
|
||||
<>
|
||||
<RepoQuickSwitchSheet isOpen onClose={handleClose} />
|
||||
<LocationSpy />
|
||||
</>
|
||||
}
|
||||
/>
|
||||
</Routes>
|
||||
</MemoryRouter>
|
||||
</QueryClientProvider>,
|
||||
)
|
||||
|
||||
await waitFor(() => {
|
||||
expect(screen.getByText('repo1')).toBeInTheDocument()
|
||||
})
|
||||
|
||||
fireEvent.click(screen.getByText('repo1'))
|
||||
|
||||
expect(screen.getByTestId('location')).toHaveTextContent('/repos/1/assistant')
|
||||
expect(handleClose).not.toHaveBeenCalled()
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user