Skip to content

Conversation

@tdawe1
Copy link

@tdawe1 tdawe1 commented Jan 12, 2026

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

@github-actions
Copy link
Contributor

The following comment was made by an LLM, it may be inaccurate:

Potential Duplicate PRs Found

I found 2 related PRs that may be addressing the same issue:

  1. PR fix(tui): handle undefined agent.current() to prevent fatal TypeError #7689 - fix(tui): handle undefined agent.current() to prevent fatal TypeError

  2. PR fix(tui): handle undefined agent.current() to prevent crash on startup #7748 - fix(tui): handle undefined agent.current() to prevent crash on startup

Both of these PRs appear to be tackling the same null safety issue for agent.current() that PR #7920 is addressing. You may want to check if these are already merged or closed, and coordinate with any concurrent work.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Crash when local.agent.current() returns undefined during startup/auth

1 participant