Skip to content
Open
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
19 changes: 2 additions & 17 deletions src/OpenCodeService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,8 @@ export class OpenCodeService {

this.isInitializing = true;

const prevCwd = process.cwd();
const shouldChdir =
Boolean(workspaceRoot) && fs.existsSync(workspaceRoot as string);

if (shouldChdir) {
this.workspaceDir = workspaceRoot as string;
if (workspaceRoot && fs.existsSync(workspaceRoot)) {
this.workspaceDir = workspaceRoot;
}

try {
Expand All @@ -55,10 +51,6 @@ export class OpenCodeService {

this.ensureOpencodeCliAvailable();

if (shouldChdir) {
process.chdir(workspaceRoot as string);
}

logger.info("Starting OpenCode server...");

this.opencode = await createOpencode({
Expand All @@ -73,13 +65,6 @@ export class OpenCodeService {
await this.showStartupError(error);
throw error;
} finally {
if (shouldChdir) {
try {
process.chdir(prevCwd);
} catch (e) {
getLogger().warn("Failed to restore working directory", e);
}
}
this.isInitializing = false;
}
}
Expand Down