[PR #7920] fix(opencode): add null checks for agent.current() in prompt #12565

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

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

State: open
Merged: No


Fixes #7918

What does this PR do?

Adds null safety checks for local.agent.current() across the TUI codebase.
local.agent.current() can return undefined when:

  • Auth plugins (like opencode-antigravity-auth) trigger before agent initialization
  • The agents array is empty during startup
    This caused TypeError: undefined is not an object crashes.
    Files changed:
  • prompt/index.tsx: 6 fixes
  • local.tsx: 8 fixes
  • dialog-agent.tsx: 1 fix
    All use optional chaining (?.) with fallback to "default".

How did you verify your code works?

  1. Built locally with ./packages/opencode/script/build.ts --single
  2. Tested with opencode-antigravity-auth plugin enabled
  3. Confirmed TUI no longer crashes during auth flow
  4. Pre-push typecheck passes
**Original Pull Request:** https://github.com/anomalyco/opencode/pull/7920 **State:** open **Merged:** No --- Fixes #7918 ### What does this PR do? Adds null safety checks for `local.agent.current()` across the TUI codebase. `local.agent.current()` can return `undefined` when: - Auth plugins (like `opencode-antigravity-auth`) trigger before agent initialization - The agents array is empty during startup This caused `TypeError: undefined is not an object` crashes. **Files changed:** - [prompt/index.tsx](cci:7://file:///tmp/opencode-src/packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx:0:0-0:0): 6 fixes - [local.tsx](cci:7://file:///tmp/opencode-src/packages/opencode/src/cli/cmd/tui/context/local.tsx:0:0-0:0): 8 fixes - [dialog-agent.tsx](cci:7://file:///tmp/opencode-src/packages/opencode/src/cli/cmd/tui/component/dialog-agent.tsx:0:0-0:0): 1 fix All use optional chaining (`?.`) with fallback to `"default"`. ### How did you verify your code works? 1. Built locally with `./packages/opencode/script/build.ts --single` 2. Tested with `opencode-antigravity-auth` plugin enabled 3. Confirmed TUI no longer crashes during auth flow 4. Pre-push typecheck passes
yindo added the pull-request label 2026-02-16 18:17:28 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#12565