opencode icon indicating copy to clipboard operation
opencode copied to clipboard

fix(tui): add null check for local.agent.current()

Open wydrox opened this issue 13 hours ago • 2 comments

fix(tui): add null check for local.agent.current()

The local.agent.current() function can return undefined when no agents are available (empty agents list). This caused a TypeError when trying to access .name property on undefined.

Fix by adding optional chaining and nullish coalescing for safe access:

  • local.agent.current()?.name ?? "build" for agent names
  • local.agent.current()?.name ?? "" for UI display

Affected files:

  • packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx (6 locations)
  • packages/opencode/src/cli/cmd/tui/component/dialog-agent.tsx (1 location)

wydrox avatar Jan 15 '26 22:01 wydrox