From cb46b08efc70cf7b85f72da313dbd88a1e54e109 Mon Sep 17 00:00:00 2001 From: Tak Hoffman <781889+Takhoffman@users.noreply.github.com> Date: Thu, 26 Mar 2026 11:54:33 -0500 Subject: [PATCH] fix: include dashboard children in owner filters --- src/gateway/session-utils.test.ts | 27 +++++++++++++++++++++++++++ src/gateway/session-utils.ts | 2 +- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/gateway/session-utils.test.ts b/src/gateway/session-utils.test.ts index bd20aa7ebac..109d110de67 100644 --- a/src/gateway/session-utils.test.ts +++ b/src/gateway/session-utils.test.ts @@ -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 = { + "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 = { diff --git a/src/gateway/session-utils.ts b/src/gateway/session-utils.ts index e23b1feeca5..b5c0e0f1a2a 100644 --- a/src/gateway/session-utils.ts +++ b/src/gateway/session-utils.ts @@ -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) {