Skip to content

fix(mobile): scope child session error to the child sheet - #5413

Open
iscekic wants to merge 3 commits into
mainfrom
sticky-child-error-4214
Open

fix(mobile): scope child session error to the child sheet#5413
iscekic wants to merge 3 commits into
mainfrom
sticky-child-error-4214

Conversation

@iscekic

@iscekic iscekic commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Summary

  • A subagent failure now appears only in the failed subagent's sheet, not on the main session screen.
  • The main session's composer stays clear of a subagent's error.
  • The main composer stays usable and shows Stop while the main session works.
  • A failed subagent with no transcript shows a "Subagent session failed" error screen.
  • A failed subagent with a transcript shows the error as a banner above its messages.

A session.error event with a non-root sessionId now routes to a new onChildSessionError callback and returns before the shared root status or onError path. An event without a sessionId keeps the legacy root behavior. This keeps a child failure from touching the parent status indicator.

Files
  • packages/cloud-agent-sdk/src/service-state.ts — adds onChildSessionError to ServiceStateConfig; processSessionError routes non-root sessionId events to it and returns before the root error path.
  • packages/cloud-agent-sdk/src/session.ts — adds onChildSessionError to CloudAgentSessionConfig and forwards it to createServiceState.

The session manager records each child's failure message in a new childSessionErrorsAtom map and exposes a read-only childSessionError atom that returns the message for a child id, or null. The map clears with the other atoms on switch and destroy, so a stale child error cannot leak into the next session.

Files
  • packages/cloud-agent-sdk/src/session-manager.ts — adds the childSessionError atom to SessionManagerAtoms, the backing map, the derived reader, the onChildSessionError handler, and the clear/reset wiring.

The child session sheet renders a runtime failure only in the failed child: a child with no messages shows a "Subagent session failed" error state, and a child with messages shows an error banner above the transcript. The parent detail screen reads the per-child error atom and passes the open child's message into the sheet.

Files
  • apps/mobile/src/components/agents/child-session-sheet-state.tsgetChildSessionSheetState takes a sessionError argument and returns error for it when the child has no messages.
  • apps/mobile/src/components/agents/child-session-sheet.tsx — accepts sessionError; renders the no-message error state or the above-transcript banner.
  • apps/mobile/src/components/agents/session-detail-content.tsx — reads manager.atoms.childSessionError and passes the open child's message to the sheet.

Tests: 3 test files updated (child-session-sheet-state.test.ts, service-state.test.ts, session-manager.test.ts).
Generated: none.


Verification

One iOS device round ran two cases.

Case What it proves Platform Result
S1 — parent happy path The parent session shows the Stop control while the agent works, then returns the composer to a usable state with no error text above it. iOS passed
S2 — cold-start reopen Reopening the parent session shows a usable composer and no error text above it. iOS passed

No defect was reproduced on an unfixed build: the fix landed before round 1, so no round ran on an unfixed build.

Visual Changes

Parent session detail screen (mobile). The user sees a usable composer and no error banner above it after a message round trip. In the picture, the Preparation complete row sits above the Message... composer, where an error banner would appear, and no error text is present.

01-parent-happy-path-idle.png

Reviewer Notes

Human steps: none needed.

Notes: none.

Route a child session.error (non-root sessionId) to a new optional
onChildSessionError callback instead of the shared root status and onError.
The manager stores the message per child id in a new childSessionErrorsAtom
and exposes a read-only childSessionError atom. Events without a sessionId
keep the legacy root behavior.
Read the per-child error atom in the session detail screen and pass it into
the child sheet. The sheet shows a runtime error only in the failed child:
an error state when the child has no messages, an error banner above the
transcript when it has messages. The parent indicator, error atom, and
composer are untouched.
@iscekic iscekic self-assigned this Aug 21, 2026
@kilo-code-bot

kilo-code-bot Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Executive Summary

Incremental review of the server root-ID adoption fix; child-error routing now stays on the parent path after session.created, with high confidence.

Files Reviewed (2 files)
  • packages/cloud-agent-sdk/src/service-state.ts
  • packages/cloud-agent-sdk/src/service-state.test.ts
Previous Review Summary (commit 6e384af)

Current summary above is authoritative. Previous snapshots are kept for context only.

Previous review (commit 6e384af)

Status: No Issues Found | Recommendation: Merge

Files Reviewed (9 files)
  • packages/cloud-agent-sdk/src/service-state.ts
  • packages/cloud-agent-sdk/src/service-state.test.ts
  • packages/cloud-agent-sdk/src/session.ts
  • packages/cloud-agent-sdk/src/session-manager.ts
  • packages/cloud-agent-sdk/src/session-manager.test.ts
  • apps/mobile/src/components/agents/child-session-sheet-state.ts
  • apps/mobile/src/components/agents/child-session-sheet-state.test.ts
  • apps/mobile/src/components/agents/child-session-sheet.tsx
  • apps/mobile/src/components/agents/session-detail-content.tsx

Reviewed by grok-4.6 · Input: 144K · Output: 8.2K · Cached: 173.3K

Review guidance: REVIEW.md from base branch main

@iscekic iscekic added the human-ready The PR is ready for human review. label Aug 21, 2026

@pandemicsyn pandemicsyn left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm one in line

Comment thread packages/cloud-agent-sdk/src/service-state.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

human-ready The PR is ready for human review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants