Skip to content

TUI crashes when opening a session that references a removed subagent #29350

@legion-implementer

Description

@legion-implementer

What happens

When the TUI auto-syncs a session that references a subagent task whose own session has since been removed (deleted, cleaned up, or never persisted), the unhandled rejection from the 404 propagates and renders an error toast — or in some cases prevents the Task message from rendering at all.

Where

packages/opencode/src/cli/cmd/tui/routes/session/index.tsx — the auto-sync call in the Task message component fires sync.session.sync(props.metadata.sessionId) without handling the rejection.

Why this happens

Subagent sessions are ephemeral by design — they get GC'd, deleted, or never persisted depending on the agent's lifecycle. The parent session's Task message still references the subagent ID. When the TUI tries to fetch that ID, the backend returns 404.

Expected

The Task message renders without the subagent message preview. No error toast.

Repro

  1. Open a session that used the Task tool to delegate to a subagent
  2. Remove the subagent session (or let it GC)
  3. Reopen the parent session in the TUI
  4. Observe the error toast / missing render

Happy to submit a PR — fix is a one-line .catch(() => {}) plus a comment explaining the reasoning.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions