mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 04:44:21 +01:00
feat(opencode): migrate OpenCode Manager to OpenCode 2 (#359)
* feat(opencode): migrate OpenCode Manager to OpenCode 2 Port the backend lifecycle, generated plugins, event aggregation, schedules, worktrees, provider credentials, MCP, config handling, the frontend chat model, and the ocm CLI to OpenCode 2. Adopt @opencode/client 2.0.15 as the single typed V2 API contract, require OpenCode 2.0.0 or newer (pinned 2.0.15), and delete every V1-only code path. * refactor(opencode): reload config in place and drop v1 compatibility shims Route config/skill/AGENTS.md changes through the OpenCode location reload API instead of a full server restart, stop auto-resuming interrupted sessions, remove the restart coordinator and v1 MCP/version shims, and pin support to OpenCode >=2.0.15 <3.0.0. Adds integration-ready retries, service-mode launch, ocm-cli repo proxy, and new frontend form/MCP helpers. * refactor(opencode): consolidate v2 migration helpers and harden install, proxy, and session flows - extract shared semver and model-ref utilities, reuse across version checks - share the OpenCode release download script across Docker, entrypoint, dev setup - unify install/upgrade failure recovery and guard externally managed OPENCODE_BIN - scope the repo proxy location rewrite and surface ocm proxy errors - rework frontend session projection, permission lookup, and cache invalidation * fix(schedules): reject unavailable agents before creating a session * feat(opencode): add ocm install, schedule agent fallback, and session move guards
This commit is contained in:
1 parent
6c2ebd764b
commit
dacde879d6
383 files changed
+29905
-46566
No files matched your search
@@ -1,4 +1,4 @@
|
||||
import { describe, it, expect, vi, beforeEach } from 'vitest'
|
||||
import { describe, it, expect, vi, beforeAll, beforeEach } from 'vitest'
|
||||
import { render, screen, waitFor } from '@testing-library/react'
|
||||
import userEvent from '@testing-library/user-event'
|
||||
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
|
||||
@@ -42,6 +42,13 @@ function renderDialog(onUpdate: (content: Record<string, unknown>) => Promise<vo
|
||||
}
|
||||
|
||||
describe('AddMcpServerDialog', () => {
|
||||
beforeAll(() => {
|
||||
Element.prototype.hasPointerCapture ??= () => false
|
||||
Element.prototype.setPointerCapture ??= () => {}
|
||||
Element.prototype.releasePointerCapture ??= () => {}
|
||||
Element.prototype.scrollIntoView ??= () => {}
|
||||
})
|
||||
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks()
|
||||
mockGetOpenCodeConfig.mockResolvedValue(config)
|
||||
@@ -62,16 +69,47 @@ describe('AddMcpServerDialog', () => {
|
||||
expect(mockUpdateOpenCodeConfig).not.toHaveBeenCalled()
|
||||
expect(onUpdate).toHaveBeenCalledWith({
|
||||
mcp: {
|
||||
filesystem: {
|
||||
type: 'local',
|
||||
enabled: true,
|
||||
command: ['npx', 'server-filesystem', '/tmp'],
|
||||
servers: {
|
||||
filesystem: {
|
||||
type: 'local',
|
||||
command: ['npx', 'server-filesystem', '/tmp'],
|
||||
disabled: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
expect(mockAddServerAsync).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
|
||||
it('writes a remote server with V2 OAuth keys and the Manager callback', async () => {
|
||||
const onUpdate = vi.fn<(content: Record<string, unknown>) => Promise<void>>().mockResolvedValue(undefined)
|
||||
const user = userEvent.setup()
|
||||
renderDialog(onUpdate)
|
||||
|
||||
await user.type(screen.getByLabelText('Server ID'), 'remote-tools')
|
||||
await user.click(screen.getByRole('combobox'))
|
||||
await user.click(screen.getByRole('option', { name: 'Remote (HTTP)' }))
|
||||
await user.type(screen.getByLabelText('Server URL'), 'https://mcp.example.com')
|
||||
await user.click(screen.getByLabelText('Enable OAuth'))
|
||||
await user.type(screen.getByLabelText('Client ID'), 'client-1')
|
||||
await user.type(screen.getByLabelText('Timeout (ms)'), '9000')
|
||||
await user.click(screen.getByRole('button', { name: 'Add MCP Server' }))
|
||||
|
||||
await waitFor(() => expect(onUpdate).toHaveBeenCalledTimes(1))
|
||||
const serverConfig = {
|
||||
type: 'remote',
|
||||
url: 'https://mcp.example.com',
|
||||
oauth: {
|
||||
client_id: 'client-1',
|
||||
redirect_uri: `${window.location.origin}/api/mcp-oauth-proxy/callback`,
|
||||
},
|
||||
disabled: false,
|
||||
timeout: { catalog: 9000, execution: 9000 },
|
||||
}
|
||||
expect(onUpdate).toHaveBeenCalledWith({ mcp: { servers: { 'remote-tools': serverConfig } } })
|
||||
expect(mockAddServerAsync).toHaveBeenCalledWith({ name: 'remote-tools', config: serverConfig })
|
||||
})
|
||||
|
||||
it('passes only the merged content to onUpdate', async () => {
|
||||
const fetched = makeOpenCodeConfigFile({ revision: 'rev-B' })
|
||||
mockGetOpenCodeConfig.mockResolvedValue(fetched)
|
||||
@@ -86,7 +124,8 @@ describe('AddMcpServerDialog', () => {
|
||||
await waitFor(() => expect(onUpdate).toHaveBeenCalledTimes(1))
|
||||
const [content] = onUpdate.mock.calls[0]
|
||||
expect(onUpdate.mock.calls[0]).toHaveLength(1)
|
||||
expect((content.mcp as Record<string, unknown>).filesystem).toBeDefined()
|
||||
const mcp = content.mcp as Record<string, unknown>
|
||||
expect(mcp.servers).toBeDefined()
|
||||
expect(mockUpdateOpenCodeConfig).not.toHaveBeenCalled()
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user