Skip to content

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

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

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

Conversation

@mgajda

@mgajda mgajda commented Jul 17, 2026

Copy link
Copy Markdown

Issue for this PR

Closes #37186

Type of change

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

What does this PR do?

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

How did you verify your code works?

  • 42 lines of new tests covering error paths
  • tsgo --noEmit passes
  • All existing tests pass

Screenshots / recordings

N/A.

Checklist

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

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)
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