opencode
opencode copied to clipboard
fix(tui): add null check for local.agent.current()
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)