@@ -38,7 +38,12 @@ import type {
3838} from "@/common/types/workspace" ;
3939import type { MuxMessage } from "@/common/types/message" ;
4040import type { RuntimeConfig } from "@/common/types/runtime" ;
41- import { hasSrcBaseDir , getSrcBaseDir , isSSHRuntime } from "@/common/types/runtime" ;
41+ import {
42+ hasSrcBaseDir ,
43+ getSrcBaseDir ,
44+ isSSHRuntime ,
45+ isDockerRuntime ,
46+ } from "@/common/types/runtime" ;
4247import { defaultModel } from "@/common/utils/ai/models" ;
4348import type { StreamEndEvent , StreamAbortEvent } from "@/common/types/stream" ;
4449import type { TerminalService } from "@/node/services/terminalService" ;
@@ -1150,17 +1155,19 @@ export class WorkspaceService extends EventEmitter {
11501155 const planPath = getPlanFilePath ( metadata . name , metadata . projectName ) ;
11511156 const legacyPlanPath = getLegacyPlanFilePath ( workspaceId ) ;
11521157
1153- // For SSH: use $HOME expansion so remote shell resolves to remote home directory
1154- // For local: expand tilde locally since shellQuote prevents shell expansion
1155- const quotedPlanPath = isSSHRuntime ( metadata . runtimeConfig )
1158+ const isRemoteRuntime =
1159+ isSSHRuntime ( metadata . runtimeConfig ) || isDockerRuntime ( metadata . runtimeConfig ) ;
1160+
1161+ // For SSH/Docker: use $HOME expansion so the runtime shell resolves to the runtime home directory.
1162+ // For local: expand tilde locally since shellQuote prevents shell expansion.
1163+ const quotedPlanPath = isRemoteRuntime
11561164 ? expandTildeForSSH ( planPath )
11571165 : shellQuote ( expandTilde ( planPath ) ) ;
1158- const quotedLegacyPlanPath = isSSHRuntime ( metadata . runtimeConfig )
1166+ const quotedLegacyPlanPath = isRemoteRuntime
11591167 ? expandTildeForSSH ( legacyPlanPath )
11601168 : shellQuote ( expandTilde ( legacyPlanPath ) ) ;
11611169
1162- // SSH runtime: delete via remote shell so $HOME expands on the remote.
1163- if ( isSSHRuntime ( metadata . runtimeConfig ) ) {
1170+ if ( isRemoteRuntime ) {
11641171 const runtime = createRuntime ( metadata . runtimeConfig , {
11651172 projectPath : metadata . projectPath ,
11661173 } ) ;
@@ -1172,8 +1179,16 @@ export class WorkspaceService extends EventEmitter {
11721179 cwd : metadata . projectPath ,
11731180 timeout : 10 ,
11741181 } ) ;
1175- // Wait for completion so callers can rely on the plan file actually being removed.
1176- await execStream . exitCode ;
1182+
1183+ try {
1184+ await execStream . stdin . close ( ) ;
1185+ } catch {
1186+ // Ignore stdin-close errors (e.g. already closed).
1187+ }
1188+
1189+ await execStream . exitCode . catch ( ( ) => {
1190+ // Best-effort: ignore failures.
1191+ } ) ;
11771192 } catch {
11781193 // Plan files don't exist or can't be deleted - ignore
11791194 }
0 commit comments