@@ -1110,21 +1110,32 @@ export class WorkspaceService extends EventEmitter {
11101110 ? expandTildeForSSH ( legacyPlanPath )
11111111 : shellQuote ( expandTilde ( legacyPlanPath ) ) ;
11121112
1113- // Delete plan files through runtime (supports both local and SSH)
1114- const runtime = createRuntime ( metadata . runtimeConfig , {
1115- projectPath : metadata . projectPath ,
1116- } ) ;
1117-
1118- try {
1119- // Use exec to delete files since runtime doesn't have a deleteFile method
1120- // Delete both paths in one command for efficiency
1121- await runtime . exec ( `rm -f ${ quotedPlanPath } ${ quotedLegacyPlanPath } ` , {
1122- cwd : metadata . projectPath ,
1123- timeout : 10 ,
1113+ // SSH runtime: delete via remote shell so $HOME expands on the remote.
1114+ if ( isSSHRuntime ( metadata . runtimeConfig ) ) {
1115+ const runtime = createRuntime ( metadata . runtimeConfig , {
1116+ projectPath : metadata . projectPath ,
11241117 } ) ;
1125- } catch {
1126- // Plan files don't exist or can't be deleted - ignore
1118+
1119+ try {
1120+ await runtime . exec ( `rm -f ${ quotedPlanPath } ${ quotedLegacyPlanPath } ` , {
1121+ cwd : metadata . projectPath ,
1122+ timeout : 10 ,
1123+ } ) ;
1124+ } catch {
1125+ // Plan files don't exist or can't be deleted - ignore
1126+ }
1127+
1128+ return ;
11271129 }
1130+
1131+ // Local runtimes: delete directly on the local filesystem.
1132+ const planPathAbs = expandTilde ( planPath ) ;
1133+ const legacyPlanPathAbs = expandTilde ( legacyPlanPath ) ;
1134+
1135+ await Promise . allSettled ( [
1136+ fsPromises . rm ( planPathAbs , { force : true } ) ,
1137+ fsPromises . rm ( legacyPlanPathAbs , { force : true } ) ,
1138+ ] ) ;
11281139 }
11291140
11301141 async truncateHistory ( workspaceId : string , percentage ?: number ) : Promise < Result < void > > {
0 commit comments