mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 12:54:20 +01:00
refactor: move assistant workspace install before OpenCode server start (#263)
* refactor: move assistant workspace install before OpenCode server start * refactor: skip assistant-mode status fetch on open, use repo fullPath and cached session
This commit is contained in:
1 parent
0d14e754e1
commit
0d384d6cf0
9 files changed
+151
-169
No files matched your search
@@ -45,7 +45,7 @@ import { createOpenCodeClient } from './services/opencode/client'
|
||||
import { NotificationService } from './services/notification'
|
||||
import { ScheduleRunner, ScheduleService } from './services/schedules'
|
||||
import { migrateGlobalSkills } from './services/skills'
|
||||
import { warmAssistantWorkspace } from './services/assistant-mode'
|
||||
import { installAssistantWorkspace } from './services/assistant-mode'
|
||||
import { getOpenCodeImportStatus, syncOpenCodeImport } from './services/opencode-import'
|
||||
import { OpenCodeSupervisor } from './services/opencode-supervisor'
|
||||
import { OpenCodeConfigSchema } from '@opencode-manager/shared/schemas'
|
||||
@@ -263,6 +263,12 @@ try {
|
||||
|
||||
await migrateGlobalSkills()
|
||||
|
||||
await installAssistantWorkspace({
|
||||
db,
|
||||
apiBaseUrl: `http://localhost:${PORT}/api/internal`,
|
||||
})
|
||||
logger.info('Assistant workspace installed')
|
||||
|
||||
ipcServer = await createIPCServer(process.env.STORAGE_PATH || undefined)
|
||||
await gitAuthService.initialize(ipcServer, db)
|
||||
logger.info(`Git IPC server running at ${ipcServer.ipcHandlePath}`)
|
||||
@@ -273,11 +279,6 @@ try {
|
||||
const openCodeStatus = await openCodeSupervisor.start()
|
||||
if (openCodeStatus.healthy) {
|
||||
logger.info(`OpenCode server running on port ${openCodeStatus.port}`)
|
||||
void warmAssistantWorkspace({
|
||||
db,
|
||||
apiBaseUrl: `http://localhost:${PORT}/api/internal`,
|
||||
openCodeClient,
|
||||
})
|
||||
} else {
|
||||
logger.warn(`OpenCode server unavailable after startup recovery: ${openCodeStatus.lastError ?? openCodeStatus.state}`)
|
||||
}
|
||||
|
||||
@@ -17,10 +17,7 @@ import { ASSISTANT_REPO_ID, ASSISTANT_REPO_PATH } from '@opencode-manager/shared
|
||||
import { getReposPath, ENV } from '@opencode-manager/shared/config/env'
|
||||
import type { Database } from 'bun:sqlite'
|
||||
import { getOrCreateInternalToken } from './internal-token'
|
||||
import type { OpenCodeClient } from './opencode/client'
|
||||
import { logger } from '../utils/logger'
|
||||
|
||||
const ASSISTANT_WARMUP_OPENCODE_TIMEOUT_MS = 90000
|
||||
|
||||
const ASSISTANT_MODE_DIR = ASSISTANT_REPO_PATH
|
||||
const ASSISTANT_MODE_RELATIVE_PATH = 'repos/assistant'
|
||||
@@ -1080,22 +1077,12 @@ export async function getAssistantModeStatus(repo: Repo): Promise<AssistantModeS
|
||||
}
|
||||
}
|
||||
|
||||
export async function warmAssistantWorkspace(deps: {
|
||||
export async function installAssistantWorkspace(deps: {
|
||||
db: Database
|
||||
apiBaseUrl: string
|
||||
openCodeClient: OpenCodeClient
|
||||
}): Promise<void> {
|
||||
try {
|
||||
const status = await ensureAssistantMode(buildAssistantRepo(), {
|
||||
db: deps.db,
|
||||
apiBaseUrl: deps.apiBaseUrl,
|
||||
})
|
||||
await deps.openCodeClient.getJson('/api/session?limit=1&order=desc', {
|
||||
directory: status.directory,
|
||||
signal: AbortSignal.timeout(ASSISTANT_WARMUP_OPENCODE_TIMEOUT_MS),
|
||||
})
|
||||
logger.info('Assistant workspace warmed')
|
||||
} catch (error) {
|
||||
logger.warn('Assistant workspace warmup failed (non-fatal):', error)
|
||||
}
|
||||
}): Promise<AssistantModeStatus> {
|
||||
return ensureAssistantMode(buildAssistantRepo(), {
|
||||
db: deps.db,
|
||||
apiBaseUrl: deps.apiBaseUrl,
|
||||
})
|
||||
}
|
||||
Reference in new issue
Block a user