Skip to content

Commit 8ebb766

Browse files
authored
fix(attach): allow remote --dir (anomalyco#8969)
1 parent 46de1ed commit 8ebb766

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

‎packages/opencode/src/cli/cmd/tui/attach.ts‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,19 @@ export const AttachCommand = cmd({
2121
describe: "session id to continue",
2222
}),
2323
handler: async (args) => {
24-
if (args.dir) process.chdir(args.dir)
24+
let directory = args.dir
25+
if (args.dir) {
26+
try {
27+
process.chdir(args.dir)
28+
directory = process.cwd()
29+
} catch {
30+
// If the directory doesn't exist locally (remote attach), pass it through.
31+
}
32+
}
2533
await tui({
2634
url: args.url,
2735
args: { sessionID: args.session },
28-
directory: args.dir ? process.cwd() : undefined,
36+
directory,
2937
})
3038
},
3139
})

0 commit comments

Comments
 (0)