GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix: add null safety to local.agent.current() - Issue #10346 by Luckybalabala · Pull Request #10376 · anomalyco/opencode

Conversation

@Luckybalabala

@Luckybalabala Luckybalabala commented Jan 24, 2026

Copy link
Copy Markdown

Problem

When local.agent.current() returns undefined, the code attempts to access properties on it, causing runtime errors.

Solution

Added optional chaining (?.) and nullish coalescing (??) operator to handle the case when no agent is active:

const agent = local.agent.current()
const mode = agent?.mode ?? ""

Testing

  • Verified with existing test suite (752/759 tests passing)
  • Manual testing confirmed no more errors when agent context is undefined

Fixes #10346

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@Luckybalabala
Luckybalabala requested a review from adamdotdevin as a code owner January 24, 2026 12:02
@github-actions

github-actions Bot commented Jan 24, 2026

Copy link
Copy Markdown
Contributor

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

Based on the search results, I found several related PRs addressing similar null safety issues with local.agent.current(). Here are the potential duplicates/related work:

Related PRs:

  1. fix(opencode): add null checks for agent.current() in prompt #7920 - fix(opencode): add null checks for agent.current() in prompt

    • Addresses null checks for agent.current() in a similar context
  2. fix(tui): add null safety for local.agent.current().name (#8858) #8882 - fix(tui): add null safety for local.agent.current().name (#8858)

    • Directly addresses null safety for the same function/property access pattern
  3. fix(tui): add null check for local.agent.current() #8745 - fix(tui): add null check for local.agent.current()

    • Another null safety fix for the same function
  4. Fix TUI crashes from undefined values (#8588, #8579, #8580) #8635 - Fix TUI crashes from undefined values (#8588, #8579, #8580)

    • Broader fix addressing TUI crashes from undefined values, may include agent-related fixes
  5. fix: add fallback for current agent in TUI to prevent crashes #9877 - fix: add fallback for current agent in TUI to prevent crashes

    • Fallback pattern for handling undefined agent

Note: These PRs suggest this is a recurring issue. You may want to check if #8882, #8745, or #9877 already address issue #10346, or if those fixes were incomplete/reverted. There might be a need for a more comprehensive solution to prevent this pattern from reoccurring.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Luckybalabala
Luckybalabala force-pushed the fix/issue-10346-tui-null-safety branch from 1d93fde to 5a350e3 Compare January 24, 2026 12:59
root root
fix(opencode): add null safety to local.agent.current() - Issue anoma…
a1928cc
…lyco#10346
@Luckybalabala
Luckybalabala force-pushed the fix/issue-10346-tui-null-safety branch from 5a350e3 to a1928cc Compare January 24, 2026 13:00
@Luckybalabala Luckybalabala closed this Jan 26, 2026
@Luckybalabala
Luckybalabala deleted the fix/issue-10346-tui-null-safety branch January 26, 2026 05:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@adamdotdevin adamdotdevin Awaiting requested review from adamdotdevin

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

opentui: fatal: undefined is not an object (evaluating 'local.agent.current().name')

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@Luckybalabala
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.