Isolate TUI thread cwd resolution test (#25147)

This commit is contained in:
Kit Langton
2026-04-30 15:10:30 -04:00
committed by GitHub
parent 87cd9446d8
commit cedff6fb89
2 changed files with 13 additions and 123 deletions
+7 -4
View File
@@ -71,6 +71,12 @@ async function input(value?: string) {
return piped + "\n" + value
}
export function resolveThreadDirectory(project?: string, envPWD = process.env.PWD, cwd = process.cwd()) {
const root = Filesystem.resolve(envPWD ?? cwd)
if (project) return Filesystem.resolve(path.isAbsolute(project) ? project : path.join(root, project))
return Filesystem.resolve(cwd)
}
export const TuiThreadCommand = cmd({
command: "$0 [project]",
describe: "start opencode tui",
@@ -124,10 +130,7 @@ export const TuiThreadCommand = cmd({
// Resolve relative --project paths from PWD, then use the real cwd after
// chdir so the thread and worker share the same directory key.
const root = Filesystem.resolve(process.env.PWD ?? process.cwd())
const next = args.project
? Filesystem.resolve(path.isAbsolute(args.project) ? args.project : path.join(root, args.project))
: Filesystem.resolve(process.cwd())
const next = resolveThreadDirectory(args.project)
const file = await target()
try {
process.chdir(next)