anomalyco / anomalyco/opencode

Session run defects are silently dropped — UI shows no error, session just goes idle

Open
#42,259 2 comments 0 reactions 1 assignee View on GitHub

@jlongster is already working on this.

Since Aug 13, 2026.

Dominant language
TypeScript
Stars
209k
Forks
27.5k
PR merge metrics
PR metrics pending

Description

Description

When a session run fails with an unexpected defect (e.g. a tool-load failure, a resolver error, a provider bug), no error is surfaced in the UI at all. The session transitions to idle as if it succeeded — the user gets no error message, nothing to indicate the run failed.

Steps to reproduce
  1. Set up a project whose tool load fails (a .opencode/tool/broken.ts importing a nonexistent package).
  2. In the web UI, open a session in that project and send any prompt.
  3. Observed (before fix): the assistant turn ends, the session goes idle, and no error is shown — the real ResolveMessage never appears anywhere in the UI.

(With opencode run in a terminal the failure does surface, but only as the generic masked fallback Unexpected server error. Check server logs for details. — the real cause is still lost.)

Root cause

The session.error event is published after the session.status idle event, so UI consumers that stop processing on idle never render it.

packages/opencode/src/effect/runner.tsfinishRun publishes the session's idle status (via the onIdle hook → session.status idle) before completing the run's Deferred. The failure then propagates out of ensureRunning to the HTTP handler, whose catchCause publishes session.error. The SSE ordering is therefore always:

session.status busy → session.status idle → session.error   (error arrives too late)

Clients that stop consuming on idle never see the error, and the web session renderer marks the turn complete when idle arrives — so the error is never displayed.

Expected

The real error message must reach the UI. The session.error event should be published before the idle status so consumers that stop on idle still receive and render it.

Notes
  • I hit this using headless opencode via the web browser (the opencode serve API driven from a browser session); I did not test or investigate the TUI.
  • Fixed in PR #42253 (publishes session.error before idle). That PR also surfaces tool-load warnings from #42258/#42252 as an inline warning card.
  • The masking boundary lives in packages/opencode/src/server/routes/instance/httpapi/middleware/error.ts (defect-only 500s → NamedError.Unknown with ref); the core problem here is ordering, not just the mask.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.