fix(background-agent): pass query directory to session.get in 4 call-sites (#2937)

resolveSubagentSpawnContext and related lookups called client.session.get
without the query.directory parameter, causing project-scoped sessions
to 404 under newer OpenCode SDK versions. Threaded directory through
SpawnerContext/BackgroundManager so all four call-sites pass it.

🤖 Generated with OhMyOpenCode assistance
https://github.com/code-yeongyu/oh-my-opencode
This commit is contained in:
YeonGyu-Kim
2026-04-12 02:30:01 +09:00
parent d8b9bf1aad
commit 3bfa3bd608
9 changed files with 192 additions and 22 deletions
@@ -0,0 +1,26 @@
import { describe, expect, mock, test } from "bun:test"
import type { OpencodeClient } from "./opencode-client"
import { verifySessionExists } from "./session-existence"
describe("verifySessionExists", () => {
test("passes query directory to session lookup when provided", async () => {
// given
const get = mock(async () => ({ data: { id: "session-123" } }))
const client = {
session: {
get,
},
} as unknown as OpencodeClient
// when
const result = await verifySessionExists(client, "session-123", "/project/root")
// then
expect(result).toBe(true)
expect(get).toHaveBeenCalledWith({
path: { id: "session-123" },
query: { directory: "/project/root" },
})
})
})