Skip to content

fix(tui): prevent crash when task references missing child session#26944

Open
shalin-dev wants to merge 2 commits into
anomalyco:devfrom
shalin-dev:fix/tui-crash-missing-child-session
Open

fix(tui): prevent crash when task references missing child session#26944
shalin-dev wants to merge 2 commits into
anomalyco:devfrom
shalin-dev:fix/tui-crash-missing-child-session

Conversation

@shalin-dev
Copy link
Copy Markdown

@shalin-dev shalin-dev commented May 11, 2026

Issue for this PR

Closes #26871

Type of change

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

What does this PR do?

The Task component in the session TUI route fires sync.session.sync(sessionId) as a fire-and-forget promise (void ...) without .catch(). When the child session referenced by a task tool part has been deleted or doesn't exist, the SDK call throws and the unhandled promise rejection crashes the TUI process.

Two changes:

  1. Added .catch(() => {}) to the void sync.session.sync() call in onMount. This is a fire-and-forget sync with no user-facing error to show, so swallowing the rejection is appropriate. The sync was only needed to populate local state for a session that no longer exists.

  2. Added a childExists memo that checks sync.data.session for the child session ID, and guards the onClick navigation with it. Without this, clicking a task row for a missing session would navigate to a dead-end session view.

How did you verify your code works?

  • Wrote a regression test at test/cli/tui/task-missing-session.test.ts confirming .catch() prevents unhandled rejection on missing sessions
  • bun run typecheck passes across all 14 packages
  • bun test test/cli/tui/task-missing-session.test.ts - 1 pass, 0 fail

Screenshots / recordings

N/A - TUI behavior change, no visual diff.

Checklist

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

The Task component's onMount fires sync.session.sync(sessionId) as a
fire-and-forget promise without .catch(). When the child session has
been deleted or doesn't exist, the unhandled rejection crashes the TUI.

Guard the onClick navigation with a childExists memo to prevent
navigating to a dead-end session view for missing sessions.

Closes anomalyco#26871
@github-actions github-actions Bot added needs:compliance This means the issue will auto-close after 2 hours. and removed needs:compliance This means the issue will auto-close after 2 hours. labels May 11, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

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 crashes when task history references a missing child session

1 participant