[PR #8635] Fix TUI crashes from undefined values (#8588, #8579, #8580) #12818

Open
opened 2026-02-16 18:17:42 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/8635

State: open
Merged: No


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.formatter is 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 currentAgent that 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 currentAgent memo with safe fallback
  • Replace all unsafe local.agent.current().name with currentAgent()

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
**Original Pull Request:** https://github.com/anomalyco/opencode/pull/8635 **State:** open **Merged:** No --- ## 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.formatter` is 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 `currentAgent` that 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 `currentAgent` memo with safe fallback - Replace all unsafe `local.agent.current().name` with `currentAgent()` ### 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
yindo added the pull-request label 2026-02-16 18:17:42 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#12818