fix(run): use parentID filter for subagent hydration (#35168)
This commit is contained in:
parent
88dc960af8
commit
698ef25f33
2 changed files with 19 additions and 6 deletions
|
|
@ -657,8 +657,8 @@ export function createSubagentTracker(input: SubagentTrackerInput): SubagentTrac
|
||||||
// Family index: adopt children directly from the current session list so
|
// Family index: adopt children directly from the current session list so
|
||||||
// historical subagents beyond the projected message window still get tabs.
|
// historical subagents beyond the projected message window still get tabs.
|
||||||
const family = await input.sdk.v2.session
|
const family = await input.sdk.v2.session
|
||||||
.list({ limit: FAMILY_LIST_LIMIT, order: "desc" }, { throwOnError: true })
|
.list({ parentID: input.sessionID, limit: FAMILY_LIST_LIMIT, order: "desc" }, { throwOnError: true })
|
||||||
.then((response) => response.data.data.filter((session) => session.parentID === input.sessionID))
|
.then((response) => response.data.data)
|
||||||
.catch(() => [])
|
.catch(() => [])
|
||||||
for (const session of family) {
|
for (const session of family) {
|
||||||
const child = ensureChild(session.id)
|
const child = ensureChild(session.id)
|
||||||
|
|
|
||||||
|
|
@ -119,11 +119,20 @@ function sdk(input: {
|
||||||
// The generated methods have conditional return types for throwOnError; the
|
// The generated methods have conditional return types for throwOnError; the
|
||||||
// minimal shapes below are enough for family discovery and model fallback.
|
// minimal shapes below are enough for family discovery and model fallback.
|
||||||
spyOn(client.v2.session, "list").mockImplementation(
|
spyOn(client.v2.session, "list").mockImplementation(
|
||||||
() =>
|
(request) => {
|
||||||
ok({
|
const parentID = request?.parentID
|
||||||
|
return ok({
|
||||||
location: { directory: "/tmp", project: { id: "proj_1", directory: "/tmp" } },
|
location: { directory: "/tmp", project: { id: "proj_1", directory: "/tmp" } },
|
||||||
data: input.sessions ?? [],
|
data:
|
||||||
}) as never,
|
input.sessions?.filter((session) =>
|
||||||
|
parentID === undefined
|
||||||
|
? true
|
||||||
|
: parentID === null
|
||||||
|
? session.parentID === undefined
|
||||||
|
: session.parentID === parentID,
|
||||||
|
) ?? [],
|
||||||
|
}) as never
|
||||||
|
},
|
||||||
)
|
)
|
||||||
spyOn(client.v2.model, "default").mockImplementation(
|
spyOn(client.v2.model, "default").mockImplementation(
|
||||||
() =>
|
() =>
|
||||||
|
|
@ -1237,6 +1246,10 @@ describe("V2 mini transport", () => {
|
||||||
footer: ui.api,
|
footer: ui.api,
|
||||||
})
|
})
|
||||||
const states = ui.events.flatMap((event) => (event.type === "stream.subagent" ? [event.state] : []))
|
const states = ui.events.flatMap((event) => (event.type === "stream.subagent" ? [event.state] : []))
|
||||||
|
expect(client.v2.session.list).toHaveBeenCalledWith(
|
||||||
|
{ parentID: "ses_1", limit: 100, order: "desc" },
|
||||||
|
{ throwOnError: true },
|
||||||
|
)
|
||||||
expect(states.at(-1)?.tabs).toMatchObject([
|
expect(states.at(-1)?.tabs).toMatchObject([
|
||||||
{
|
{
|
||||||
sessionID: "ses_child_old",
|
sessionID: "ses_child_old",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue