fix(background-agent): route session prompts by directory

This commit is contained in:
YeonGyu-Kim
2026-05-12 18:13:39 +09:00
parent 7d09d2c83c
commit 6035a551ad
7 changed files with 221 additions and 31 deletions
@@ -7,6 +7,38 @@ import { BackgroundManager } from "./manager"
import { unsafeTestValue } from "../../../test-support/unsafe-test-value"
describe("BackgroundManager session permission", () => {
test("passes parent directory route when prompting the child session", async () => {
// given
const promptCalls: Array<Record<string, unknown>> = []
const client = {
session: {
get: async () => ({ data: { directory: "/parent" } }),
create: async () => ({ data: { id: "ses_child" } }),
promptAsync: async (input: Record<string, unknown>) => {
promptCalls.push(input)
return {}
},
abort: async () => ({}),
},
}
const manager = new BackgroundManager({ pluginContext: unsafeTestValue<PluginInput>({ client, directory: tmpdir() }) })
// when
await manager.launch({
description: "Test task",
prompt: "Do something",
agent: "explore",
parentSessionId: "ses_parent",
parentMessageId: "msg_parent",
})
await new Promise(resolve => setTimeout(resolve, 50))
manager.shutdown()
// then
expect(promptCalls).toHaveLength(1)
expect(promptCalls[0]?.query).toEqual({ directory: "/parent" })
})
test("passes query directory when loading the parent session", async () => {
// given
const getCalls: Array<Record<string, unknown>> = []