Skip to content

[BUG] TUI Fatal Error: Cannot read property 'name' of undefined (local.agent.current()) #11262

Closed

Description

@barry2323

Describe the bug

OpenCode TUI crashes with a fatal error when trying to access local.agent.current().name because local.agent.current() returns undefined.

Error Message

Full stack trace:

To Reproduce

  1. Open OpenCode TUI
  2. Error appears on startup or during certain operations
  3. TUI crashes with fatal error dialog showing three options: Copy issue URL, Reset TUI, Exit

Expected behavior

TUI should start and run normally without local.agent.current() returning undefined.

Screenshots

Environment

  • OpenCode Version:
  • OS:
  • Terminal:
  • Node.js:
  • Installation method:

Root Cause Analysis

The error occurs in src/cli/cmd/tui/component/prompt/index.tsx at line 857. The code attempts to access .name on the result of local.agent.current() without checking if it returns undefined.

Possible causes:

Image

  1. local.agent is not properly initialized
  2. No agent is currently selected but the code assumes one exists
  3. State management issue causing agent data to be lost

Suggested Fix

Add null-safety check before accessing the property:

// Current code (likely)
const agentName = local.agent.current().name;

// Suggested fix
const currentAgent = local.agent.current();
const agentName = currentAgent?.name ?? 'Unknown Agent';

Activity

  1. added
    opentuiThis relates to changes in v1.0, now that opencode uses opentui
    on Jan 30, 2026
  2. github-actions commented on Jan 30, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    Both issues describe the exact same problem where local.agent.current() returns undefined and the code attempts to access .name without null-safety checks.

    Feel free to ignore if none of these address your specific case.

  3. github-actions commented on Apr 1, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 90 days of no activity. If the issue is still relevant please open a new one.

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

Metadata

Metadata

Assignees

Labels

opentuiThis relates to changes in v1.0, now that opencode uses opentui

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions