opencode
opencode copied to clipboard
Fix TUI crashes from undefined values (#8588, #8579, #8580)
Summary
Fixes three TUI crash bugs:
#8588 - enabledFormatters undefined
-
Problem: TUI crashes with "undefined is not an object (evaluating 'enabledFormatters().length')" when adding MCP server and running
/status -
Root cause:
sync.data.formatteris undefined during initialization -
Fix: Added null check
sync.data.formatter?.filter((f) => f.enabled) ?? []
#8579 - local.agent.current undefined
- Problem: TUI crashes with "undefined is not an object (evaluating 'local.agent.current().name')" during startup
-
Root cause:
local.agent.current()returns undefined during initialization -
Fix: Created safe memo
currentAgentthat returns "build" as fallback, used throughout component
#8580 - ECONNRESET error message
- Problem: Users experiencing "socket connection closed unexpectedly" errors get minimal guidance
- Fix: Enhanced error message to include "If this persists, check your network/proxy settings."
Changes
packages/opencode/src/cli/cmd/tui/component/dialog-status.tsx
- Add null check for
sync.data.formatter
packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx
- Add
currentAgentmemo with safe fallback - Replace all unsafe
local.agent.current().namewithcurrentAgent()
packages/opencode/src/cli/cmd/tui/component/dialog-agent.tsx
- Add null check for
local.agent.current()?.name
packages/opencode/src/session/message-v2.ts
- Improve ECONNRESET error message with network/proxy guidance
packages/opencode/test/session/retry.test.ts
- Update tests to match new error message format
Testing
- All existing tests pass (11 tests in retry.test.ts)
- Manual verification of null safety patterns