fix(sidebar): nest delegated subagents under messaging parents (#7263)

Nest delegated subagent sessions under the parent conversation that spawned them instead of forcing them to the sidebar top level.

Co-authored-by: lowlandsheperd <lowlandsheperd@users.noreply.github.com>
This commit is contained in:
Kenanandlowlandsheperd authored and GitHub committed 2026-09-15 16:31:54 -07:00
1 parent 68008e824b
commit b56dd423e7
2 files changed
+186 -6

No files matched your search

+11 -6
View File
@@ -7134,6 +7134,12 @@ function _attachChildSessionsToSidebarRows(collapsedRows, rawSessions, rawRefere
const childRenderable=!!(child&&child.session_id&&renderableChildIds.has(child.session_id));
if(child&&child.session_id&&visibleBySid.has(child.session_id)) continue;
const isForkChild=_isForkWithResolvableParent(child, sessionIdsInList)&&!(child&&child.pinned);
const childRawRole=[
child&&child.raw_source,
child&&child.source_tag,
child&&child.source,
].map(source=>String(source||'').trim().toLowerCase()).find(Boolean)||'';
const childIsDelegatedSubagent=_isChildSession(child)&&childRawRole==='subagent';
const childLineageKey=child&&(child._lineage_root_id||child.lineage_root_id||child.parent_session_id);
const isHiddenLineageReferenceChild=!!(child&&child.archived&&child.parent_session_id&&childLineageKey&&!child.pinned&&!childRenderable);
if(!_isChildSession(child)&&!isForkChild&&!isHiddenLineageReferenceChild) continue;
@@ -7158,11 +7164,10 @@ function _attachChildSessionsToSidebarRows(collapsedRows, rawSessions, rawRefere
hiddenArchivedChildTree.add(child.session_id);
continue;
}
// Cross-surface rows (for example a WebUI continuation from a Telegram
// conversation) should remain top-level when there is no WebUI-owned parent
// row to stack under. But if the parent is visible in this same sidebar
// render, attach normally — delegated subagent rows are also cross-source
// relative to their WebUI parent and should not be forced into orphans.
// Independent cross-surface rows (for example a WebUI continuation from a
// Telegram conversation) remain top-level instead of nesting under an
// external parent. Delegated subagents are also cross-source, but they are
// parent-owned work and should still attach to the visible parent row.
const parentSourceMarker=String(parentRow&&(
parentRow.session_source||parentRow.raw_source||parentRow.source_tag||parentRow.source
)||'').toLowerCase();
@@ -7173,7 +7178,7 @@ function _attachChildSessionsToSidebarRows(collapsedRows, rawSessions, rawRefere
parentRow.session_source==='messaging'||
(parentSourceMarker&&parentSourceMarker!=='webui'&&parentSourceMarker!=='subagent'&&parentSourceMarker!=='other'&&parentSourceMarker!=='fork')
);
if(parentRow&&child._cross_surface_child_session&&parentIsExternal){
if(parentRow&&child._cross_surface_child_session&&parentIsExternal&&!childIsDelegatedSubagent){
if(childRenderable) orphans.push({...child,_orphan_child_session:true});
continue;
}