fix: include dashboard children in owner filters

This commit is contained in:
Tak Hoffman
2026-03-26 11:54:33 -05:00
parent c48a3e4fc9
commit cb46b08efc
2 changed files with 28 additions and 1 deletions

View File

@@ -1985,6 +1985,33 @@ describe("listSessionsFromStore subagent metadata", () => {
expect(child?.parentSessionKey).toBe("agent:main:main");
});
test("returns dashboard child sessions when filtering by parentSessionKey owner", () => {
resetSubagentRegistryForTests({ persist: false });
const now = Date.now();
const store: Record<string, SessionEntry> = {
"agent:main:main": {
sessionId: "sess-main",
updatedAt: now,
} as SessionEntry,
"agent:main:dashboard:child": {
sessionId: "sess-dashboard-child",
updatedAt: now - 1_000,
parentSessionKey: "agent:main:main",
} as SessionEntry,
};
const result = listSessionsFromStore({
cfg,
storePath: "/tmp/sessions.json",
store,
opts: {
spawnedBy: "agent:main:main",
},
});
expect(result.sessions.map((session) => session.key)).toEqual(["agent:main:dashboard:child"]);
});
test("falls back to persisted subagent timing after run archival", () => {
const now = Date.now();
const store: Record<string, SessionEntry> = {

View File

@@ -1314,7 +1314,7 @@ export function listSessionsFromStore(params: {
latest.controllerSessionKey?.trim() || latest.requesterSessionKey?.trim();
return latestControllerSessionKey === spawnedBy;
}
return entry?.spawnedBy === spawnedBy;
return entry?.spawnedBy === spawnedBy || entry?.parentSessionKey === spawnedBy;
})
.filter(([, entry]) => {
if (!label) {