Merge pull request #1895 from code-yeongyu/fix/1718-windows-subagent-dir
fix: use correct project directory for Windows subagents (#1718)
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
import { describe, expect, test } from "bun:test"
|
||||
|
||||
import { resolveParentDirectory } from "./parent-directory-resolver"
|
||||
|
||||
describe("background-agent parent-directory-resolver", () => {
|
||||
const originalPlatform = process.platform
|
||||
|
||||
test("uses current working directory on Windows when parent session directory is AppData", async () => {
|
||||
//#given
|
||||
Object.defineProperty(process, "platform", { value: "win32" })
|
||||
try {
|
||||
const client = {
|
||||
session: {
|
||||
get: async () => ({
|
||||
data: { directory: "C:\\Users\\test\\AppData\\Local\\ai.opencode.desktop" },
|
||||
}),
|
||||
},
|
||||
}
|
||||
|
||||
//#when
|
||||
const result = await resolveParentDirectory({
|
||||
client: client as Parameters<typeof resolveParentDirectory>[0]["client"],
|
||||
parentSessionID: "ses_parent",
|
||||
defaultDirectory: "C:\\Users\\test\\AppData\\Roaming\\opencode",
|
||||
})
|
||||
|
||||
//#then
|
||||
expect(result).toBe(process.cwd())
|
||||
} finally {
|
||||
Object.defineProperty(process, "platform", { value: originalPlatform })
|
||||
}
|
||||
})
|
||||
})
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { OpencodeClient } from "../constants"
|
||||
import { log } from "../../../shared"
|
||||
import { log, resolveSessionDirectory } from "../../../shared"
|
||||
|
||||
export async function resolveParentDirectory(options: {
|
||||
client: OpencodeClient
|
||||
@@ -15,7 +15,10 @@ export async function resolveParentDirectory(options: {
|
||||
return null
|
||||
})
|
||||
|
||||
const parentDirectory = parentSession?.data?.directory ?? defaultDirectory
|
||||
const parentDirectory = resolveSessionDirectory({
|
||||
parentDirectory: parentSession?.data?.directory,
|
||||
fallbackDirectory: defaultDirectory,
|
||||
})
|
||||
log(`[background-agent] Parent dir: ${parentSession?.data?.directory}, using: ${parentDirectory}`)
|
||||
return parentDirectory
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user