Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions packages/opencode/src/cli/cmd/tui/attach.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,26 @@ export const AttachCommand = cmd({
describe: "session id to continue",
}),
handler: async (args) => {
let directory = args.dir
if (args.dir) {
try {
process.chdir(args.dir)
// Use resolved path for local directories to ensure file autocomplete,
// theme discovery, and exports use the correct directory
directory = process.cwd()
} catch {
// If the directory doesn't exist locally (remote attach), pass it through.
// If the directory doesn't exist locally (remote attach), pass it through
// and skip defaulting to cwd
await tui({
url: args.url,
args: { sessionID: args.session },
directory: args.dir,
})
return
}
}
// Always pass client's cwd so attached sessions operate in the client's directory
// This ensures file autocomplete, theme discovery, and exports use the correct directory
await tui({
url: args.url,
args: { sessionID: args.session },
directory,
directory: process.cwd(),
})
},
})