forked from anomalyco/opencode
-
Notifications
You must be signed in to change notification settings - Fork 0
Closed
Description
Problem
The Setting up environment... spinner completes in ~2 seconds, showing ✓ Ready, but the backend is NOT actually ready. When user types /start immediately after, the system hangs for 5-10 more seconds.
Root Cause (Confirmed by Research)
bootstrap() only loads config, plugins, and file watchers (~2s). The HEAVY initialization is lazy:
Provider.state()(~1-3s) — fetches model configs, checks auth keys for ~30 providersMCP.state()(~2-5s) — connects to each MCP server (stdio/HTTP transport +listTools())Agent.state()(~0.2s) — loads agent definitions
These trigger on the FIRST command (resolveTools() in session/tools.ts), NOT during bootstrap.
Fix
Force eager initialization INSIDE the bootstrap callback, before showing ✓ Ready:
await bootstrap(process.cwd(), async () => {
// Force eager init of heavy subsystems
await Promise.all([
Provider.list(), // Forces Provider.state()
MCP.tools(), // Forces MCP.state() — connects all servers
])
// Now we're actually ready
setup.stop(true)
write('✓ Ready')
})This moves the 5-10s delay INTO the spinner, so users see ⠋ Setting up environment... for the full duration and ✓ Ready means it's truly ready.
Key Files
packages/opencode/src/cli/lite/index.ts— add eager init calls inside bootstrap callbackpackages/opencode/src/provider/provider.ts—Provider.list()forces state initpackages/opencode/src/mcp/index.ts—MCP.tools()forces connection
Related
- UX: Redraw screen on oclite boot — cursor at bottom #85 (clear screen on boot)
- [Architecture] oclite: Live Block rendering with log-update for tools, tasks, and todos #82 (Live Block)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels