Skip to content

fix:Guard against missing agent, add warning & fallbacks, and fix dialog mouse selection handling#19685

Closed
yejiming wants to merge 5 commits into
anomalyco:devfrom
yejiming:jimmy/2026-03-29
Closed

fix:Guard against missing agent, add warning & fallbacks, and fix dialog mouse selection handling#19685
yejiming wants to merge 5 commits into
anomalyco:devfrom
yejiming:jimmy/2026-03-29

Conversation

@yejiming
Copy link
Copy Markdown
Contributor

Issue for this PR

Closes #19565
Closes #19591

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

This PR fixes two TUI interaction bugs:

  1. Prevents crashes when local.agent.current() is temporarily undefined (startup/race condition path, reported on Windows).

    • Guarded prompt submit paths and UI reads in prompt/index.tsx.
    • Added a warning toast and early return when no agent is available.
    • Updated agent dialog to safely pass current as optional.
  2. Fixes dialog overlay dismiss behavior so clicking outside closes on the first click.

    • In ui/dialog.tsx, clearing selection no longer consumes the first outside click.
    • Non-left clicks are still ignored for dismiss.

These changes preserve existing behavior when data is ready, while avoiding undefined access and improving dialog UX.

How did you verify your code works?

  • Ran bun typecheck in packages/opencode (fails in this environment because tsgo is not installed).
  • Ran bun test test/cli/tui --filter dialog in packages/opencode (fails in this environment because @opentui/solid/preload is unavailable).
  • Verified all changed call sites now handle missing agent defensively and compile logically.

Screenshots / recordings

N/A (TUI interaction fix; no browser UI screenshot).

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions
Copy link
Copy Markdown
Contributor

Hey! Your PR title Guard against missing agent, add warning & fallbacks, and fix dialog mouse selection handling doesn't follow conventional commit format.

Please update it to start with one of:

  • feat: or feat(scope): new feature
  • fix: or fix(scope): bug fix
  • docs: or docs(scope): documentation changes
  • chore: or chore(scope): maintenance tasks
  • refactor: or refactor(scope): code refactoring
  • test: or test(scope): adding or updating tests

Where scope is the package name (e.g., app, desktop, opencode).

See CONTRIBUTING.md for details.

@yejiming yejiming changed the title Guard against missing agent, add warning & fallbacks, and fix dialog mouse selection handling fix:Guard against missing agent, add warning & fallbacks, and fix dialog mouse selection handling Mar 29, 2026
Comment on lines +30 to +32
if (renderer.getSelection()) {
renderer.clearSelection()
}
Copy link
Copy Markdown
Contributor

@JosXa JosXa Mar 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check if renderer.clearSelection() is no-op safe. It may not be necessary to check before clearing

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You’re right, renderer.clearSelection() is no-op safe. I’ve changed it to call renderer.clearSelection() directly.

@rekram1-node
Copy link
Copy Markdown
Collaborator

Automated PR Cleanup

Thank you for contributing to opencode.

Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions.

This PR was closed because it matched the following cleanup criteria:

  • The PR was created more than 1 month ago
  • The PR had fewer than 2 positive reactions
  • Positive reactions are counted as thumbs-up, heart, celebration, or rocket reactions on the PR

PRs created within the last month are not affected by this cleanup.

If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate.

Thanks again for taking the time to contribute.

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.

Message Actions window requires two clicks outside to close opentui: fatal: undefined is not an object (evaluating 'local.agent.current().name')

3 participants