You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
🤖 fix: make temp directory cleanup non-blocking for faster stream interruption (#459)
## Problem
When interrupting a stream (especially on SSH), the UI experienced a
noticeable delay of 500ms-2s before responding. The user would hit
Ctrl+C/Escape but the UI would remain in "streaming" state for 1-2
seconds.
## Root Cause
The delay occurred because stream interruption waited for
`processingPromise` to complete before emitting the `stream-abort`
event. In the `finally` block of `processStreamWithCleanup()`, we were
executing:
```typescript
const result = await streamInfo.runtime.exec(`rm -rf "${streamInfo.runtimeTempDir}"`, {
cwd: "~",
timeout: 10,
});
await result.exitCode; // Wait for completion
```
For SSH runtimes, this meant:
1. SSH connection to remote host
2. Execute recursive directory deletion
3. Wait for command completion
4. Close SSH connection
5. Return exit code
Even with an empty directory, this SSH round-trip takes 500ms-2s,
blocking the UI update.
## Solution
Made the temp directory cleanup **fire-and-forget** using `void`
promise. The cleanup still happens (and errors are logged), but it no
longer blocks the critical path for emitting the `stream-abort` event.
The change is safe because:
- Temp directories are stream-specific (no conflicts between streams)
- Cleanup is best-effort (failures already logged, don't affect stream)
- No data loss (temp dir only contains tool outputs already captured in
message)
- OS cleanup as fallback
## Testing
Verify with SSH workspace:
1. Start a stream that uses tools (generates temp directory)
2. Hit Ctrl+C to interrupt
3. UI should respond instantly (no 1-2 second delay)
4. Check logs to verify temp directory cleanup still happens in
background
_Generated with `cmux`_
0 commit comments