fix: ignore stale store ownership in session child lists

This commit is contained in:
Tak Hoffman
2026-03-24 19:28:08 -05:00
parent f7de5c3b83
commit 16d2e68610
2 changed files with 100 additions and 2 deletions

View File

@@ -277,9 +277,18 @@ function resolveChildSessionKeys(
}
const spawnedBy = entry.spawnedBy?.trim();
const parentSessionKey = entry.parentSessionKey?.trim();
if (spawnedBy === controllerSessionKey || parentSessionKey === controllerSessionKey) {
childSessionKeys.add(key);
if (spawnedBy !== controllerSessionKey && parentSessionKey !== controllerSessionKey) {
continue;
}
const latest = getLatestSubagentRunByChildSessionKey(key);
if (latest) {
const latestControllerSessionKey =
latest.controllerSessionKey?.trim() || latest.requesterSessionKey?.trim();
if (latestControllerSessionKey !== controllerSessionKey) {
continue;
}
}
childSessionKeys.add(key);
}
const childSessions = Array.from(childSessionKeys);
return childSessions.length > 0 ? childSessions : undefined;