3776
*/
3777
private _registerRestoredSubagent(child: IRestoredSubagentSession, parentSummary: SessionSummary, parentSessionStr: string): void {
3779
>
if (this._stateManager.getSessionState(resourceStr)) {
3780
return;
3781
}
3783
>
this._stateManager.restoreSession(
3784
>
{
3785
>
resource: resourceStr,
3786
>
provider: 'subagent',
3787
>
title: child.title,
3788
>
status: SessionStatus.Idle,
3789
>
createdAt: registeredNow,
3790
>
modifiedAt: registeredNow,
3791
>
...(parentSummary.project ? { project: parentSummary.project } : {}),
3792
>
},
3793
>
[...child.turns],
3794
>
);
3795
>
3796
>
// Mirror the live `_handleSubagentStarted` flow on restore: surface the
3797
>
// subagent as a read-only peer chat in the PARENT session's catalog so it
3798
>
// reappears as a tab (and the inline "Open Agent" link can reveal it)
3799
>
// after a restart. Uses the same `ahp-chat://subagent/...` chat URI form
3800
>
// as the live path so the sessions provider parses and surfaces it.
3801
>
const subagentChatUri = buildSubagentChatUri(parentSessionStr, child.toolCallId);
3802
>
this._stateManager.addChat(parentSessionStr, subagentChatUri, {
3803
>
title: child.title,
3804
>
turns: [...child.turns],
3805
>
origin: { kind: ChatOriginKind.Tool, chat: buildDefaultChatUri(parentSessionStr), toolCallId: child.toolCallId },
3806
>
interactivity: ChatInteractivity.ReadOnly,
3807
>
});
3808
>
}
3809
3810
private _findProviderForSession(session: URI | string): IAgent | undefined {