Skip to content

fix(tui): publish session event when custom tool import fails#37185

Closed
mgajda wants to merge 4 commits into
anomalyco:devfrom
mgajda:fix/tui-tool-load-event
Closed

fix(tui): publish session event when custom tool import fails#37185
mgajda wants to merge 4 commits into
anomalyco:devfrom
mgajda:fix/tui-tool-load-event

Conversation

@mgajda

@mgajda mgajda commented Jul 15, 2026

Copy link
Copy Markdown

Custom tool load errors are caught gracefully (warning logged, tool skipped) but nothing appears in the TUI. Publish a Session.Event.Error so the TUI can surface the failure, matching the pattern used by plugin load errors and skill load errors.

Fixes #37186

mgajda added 4 commits July 15, 2026 20:53
When a custom tool file under .opencode/tool/ imports @opencode-ai/plugin but the package is not installed, the dynamic import() throws an unresolvable module error that crashes session startup with a raw stack trace.

Instead, catch the import error, log a warning with the hinted message, and skip the tool. The tool loader continues with remaining tools.
…ct.catchAllCause

Effect.catchAllCause does not exist in this version of Effect-TS.
Use Effect.catchDefect to catch the synchronous ResolveMessage
that Bun throws during dynamic import() of tool files with
unresolvable imports.

Also remove duplicate EventV2Bridge import that caused typecheck
failure after rebase on dev.
- Wrap dynamic import() in Effect.promise + Effect.catchDefect so
  Bun's synchronous ResolveMessage is caught gracefully
- Log a warning and skip the failing tool instead of crashing
- Add test verifying broken import is skipped, valid tool loads
- Add missing EventV2Bridge import
- Typecheck: 30/30, Tests: 15/16 (1 pre-existing Zod test failure)
@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label Jul 15, 2026
@github-actions

Copy link
Copy Markdown
Contributor

This PR doesn't fully meet our contributing guidelines and PR template.

What needs to be fixed:

  • PR description is missing required template sections. Please use the PR template.

Please edit this PR description to address the above within 2 hours, or it will be automatically closed.

If you believe this was flagged incorrectly, please let a maintainer know.

@github-actions

Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions

Copy link
Copy Markdown
Contributor

This pull request has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window.

Feel free to open a new pull request that follows our guidelines.

@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Jul 16, 2026
@github-actions github-actions Bot closed this Jul 16, 2026
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.

tui: surface custom tool load failures in the UI

1 participant