[PR #8745] fix(tui): add null check for local.agent.current() #12852

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

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

State: open
Merged: No


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)
**Original Pull Request:** https://github.com/anomalyco/opencode/pull/8745 **State:** open **Merged:** No --- 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)
yindo added the pull-request label 2026-02-16 18:17:44 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#12852