-
Notifications
You must be signed in to change notification settings - Fork 14.5k
Crash: sync.data.lsp is undefined when sidebar renders LSP panel #20443
Copy link
Copy link
Open
Description
Bug Description
Opening the sidebar with the LSP panel crashes the TUI with:
TypeError: undefined is not an object (evaluating 'sync8.data.lsp.map')
Root Cause
In packages/opencode/src/cli/cmd/tui/plugin/api.tsx:186:
lsp() {
return sync.data.lsp.map((item) => ({ id: item.id, root: item.root, status: item.status }))
}Unlike other methods in the same file that use ?? [] for fallback:
message(sessionID) { return sync.data.message[sessionID] ?? [] }
permission(sessionID) { return sync.data.permission[sessionID] ?? [] }
question(sessionID) { return sync.data.question[sessionID] ?? [] }The lsp() method has no null guard. When the sidebar renders the LSP panel before the LSP service is initialized, sync.data.lsp is undefined, causing the crash.
Reproduction
- Open a project in opencode TUI
- Trigger LSP diagnostics on a file (e.g., open a C/C++ file with clangd)
- Open the sidebar before LSP service finishes initializing
- Crash occurs
Environment
- opencode version: 1.3.9
- OS: Windows 11
- LSP: clangd
Suggested Fix
Add null guard in api.tsx:186:
lsp() {
return (sync.data.lsp ?? []).map((item) => ({ id: item.id, root: item.root, status: item.status }))
}Same pattern should be applied to mcp() at line 189 if sync.data.mcp can also be undefined.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels