Skip to content

Conversation

@blueemp
Copy link

@blueemp blueemp commented Jan 15, 2026

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

…anomalyco#8580)

- Fix anomalyco#8588: Add null check for sync.data.formatter in dialog-status.tsx
- Fix anomalyco#8579: Add null checks for local.agent.current() in prompt and agent dialogs
- Improve anomalyco#8580: Add helpful message to ECONNRESET error about network/proxy settings

These fixes prevent TUI crashes when formatter data or current agent
are undefined during startup or initialization. Also improves error messaging
for network connection issues.
@github-actions
Copy link
Contributor

Hey! Your PR title Fix TUI crashes from undefined values (#8588, #8579, #8580) doesn't follow conventional commit format.

Please update it to start with one of:

  • feat: or feat(scope): new feature
  • fix: or fix(scope): bug fix
  • docs: or docs(scope): documentation changes
  • chore: or chore(scope): maintenance tasks
  • refactor: or refactor(scope): code refactoring
  • test: or test(scope): adding or updating tests

Where scope is the package name (e.g., app, desktop, opencode).

See CONTRIBUTING.md for details.

@github-actions
Copy link
Contributor

The following comment was made by an LLM, it may be inaccurate:

No duplicate PRs found

The search results show several related historical PRs addressing similar local.agent.current() undefined issues (PRs #7689, #7748, #7747, #7796, #7940, #7920), but these are all closed/merged fixes from earlier development. PR #8635 is a new PR addressing fresh crash bugs (#8588, #8579, #8580) with different root causes and solutions, so it is not a duplicate of any currently open PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant