fix(sessions): cascade delegated subagents on parent deletion

This commit is contained in:
pxxD1998 committed 2026-07-14 18:10:03 +08:00
1 parent 3f3fa9b69a
commit 73b6c5d604
9 files changed
+2304 -27

No files matched your search

+8 -3
View File
@@ -4142,6 +4142,7 @@ function _renderBatchActionBar(){
return {response,session:sessionsById.get(sid)||null};
}));
const retainedCount=_worktreeResponseCount(results);
const cleanupFailedCount=results.filter(result=>result.response&&result.response.state_db_cleanup_failed).length;
ids.forEach(_clearHandoffStorageForSession);
if(S.session&&ids.includes(S.session.session_id)){
S.session=null;S.messages=[];S.entries=[];localStorage.removeItem('hermes-webui-session');
@@ -4150,7 +4151,9 @@ function _renderBatchActionBar(){
if(remaining.sessions&&remaining.sessions.length){await loadSession(remaining.sessions[0].session_id);}
else{$('msgInner').innerHTML='';$('emptyState').style.display='';}
}
showToast((retainedCount?t('session_deleted_worktree'):t('session_delete'))+' ('+ids.length+')');exitSessionSelectMode();await renderSessionList();
if(cleanupFailedCount) showToast(t('delete_failed')+' ('+cleanupFailedCount+'/'+ids.length+')',0,'error');
else showToast((retainedCount?t('session_deleted_worktree'):t('session_delete'))+' ('+ids.length+')');
exitSessionSelectMode();await renderSessionList();
}catch(e){showToast('Delete failed: '+(e.message||e));}
};bar.appendChild(deleteBtn);
}
@@ -8887,6 +8890,7 @@ async function deleteSession(sid, beforeDelete=null){
return false;
}
const response=deleteResult&&deleteResult.response;
const cleanupFailed=!!(response&&response.state_db_cleanup_failed);
if(typeof _clearPersistedSessionQueue==='function') _clearPersistedSessionQueue(sid);
if(!optimisticRendered){
_pendingSessionReflowPositions=reflowPositions;
@@ -8910,10 +8914,11 @@ async function deleteSession(sid, beforeDelete=null){
if(typeof syncAppTitlebar==='function') syncAppTitlebar();
}
}
showToast(_sessionResponseRetainsWorktree(response,session)?t('session_deleted_worktree'):t('session_deleted'));
if(cleanupFailed) showToast(t('delete_failed'),0,'error');
else showToast(_sessionResponseRetainsWorktree(response,session)?t('session_deleted_worktree'):t('session_deleted'));
if(optimisticRendered) void renderSessionList().finally(()=>_optimisticallyRemovedSessionIds.delete(sid));
else await renderSessionList();
return true;
return !cleanupFailed;
}
// ── Project helpers ─────────────────────────────────────────────────────