mirror of
https://github.com/anomalyco/opencode.git
synced 2026-07-19 16:53:31 +00:00
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
|
||||
// historical subagents beyond the projected message window still get tabs.
|
||||
const family = await input.sdk.v2.session
|
||||
.list({ limit: FAMILY_LIST_LIMIT, order: "desc" }, { throwOnError: true })
|
||||
.then((response) => response.data.data.filter((session) => session.parentID === input.sessionID))
|
||||
.list({ parentID: input.sessionID, limit: FAMILY_LIST_LIMIT, order: "desc" }, { throwOnError: true })
|
||||
.then((response) => response.data.data)
|
||||
.catch(() => [])
|
||||
for (const session of family) {
|
||||
const child = ensureChild(session.id)
|
||||
|
|
|
|||
|
|
@ -119,11 +119,20 @@ function sdk(input: {
|
|||
// The generated methods have conditional return types for throwOnError; the
|
||||
// minimal shapes below are enough for family discovery and model fallback.
|
||||
spyOn(client.v2.session, "list").mockImplementation(
|
||||
() =>
|
||||
ok({
|
||||
(request) => {
|
||||
const parentID = request?.parentID
|
||||
return ok({
|
||||
location: { directory: "/tmp", project: { id: "proj_1", directory: "/tmp" } },
|
||||
data: input.sessions ?? [],
|
||||
}) as never,
|
||||
data:
|
||||
input.sessions?.filter((session) =>
|
||||
parentID === undefined
|
||||
? true
|
||||
: parentID === null
|
||||
? session.parentID === undefined
|
||||
: session.parentID === parentID,
|
||||
) ?? [],
|
||||
}) as never
|
||||
},
|
||||
)
|
||||
spyOn(client.v2.model, "default").mockImplementation(
|
||||
() =>
|
||||
|
|
@ -1237,6 +1246,10 @@ describe("V2 mini transport", () => {
|
|||
footer: ui.api,
|
||||
})
|
||||
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([
|
||||
{
|
||||
sessionID: "ses_child_old",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue