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
@@ -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