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: compaction stream validation and replay blocking (#1247)
## Summary
Fix several issues causing compaction (`/compact`) and workspace refresh
to fail:
1. **Stream replay blocking `caught-up`**: `replayStream()` iterated a
live `parts` array that continued growing during an active stream. This
could delay the `caught-up` event indefinitely, leaving the UI stuck on
"Loading workspace…". Fixed by snapshotting `parts` before iteration.
2. **ORPC validation failures for stream mode**: Compaction used `mode:
"compact"` in `stream-start` events, but the schema only allowed `plan |
exec`. This caused `EVENT_ITERATOR_VALIDATION_FAILED` errors, triggering
resubscribe loops. Fixed by allowing any string for mode.
3. **Malformed init-output during replay**: Persisted init state could
contain malformed entries that failed schema validation when replayed.
Added defensive checks to skip invalid entries.
4. **Compaction tool policy bug**: `toolPolicy: []` was intended to
disable tools but actually allowed all tools (empty policy = allow all).
Fixed by using an explicit disable-all regex.
## Changes
- `src/node/services/streamManager.ts`: Snapshot parts array before
replay iteration
- `src/common/orpc/schemas/stream.ts`: Loosen mode to
`z.string().optional()`
- `src/common/orpc/schemas/workspaceStats.ts`: Loosen ModeSchema to
string
- `src/node/services/sessionTimingService.ts`: Update mode type to
`string | undefined`
- `src/node/services/initStateManager.ts`: Skip malformed init-output
entries during replay
- `src/browser/utils/messages/compactionOptions.ts`: Use explicit
disable-all tool policy
- `src/browser/utils/messages/StreamingMessageAggregator.ts`: Remove
unnecessary type assertion
## Testing
- Added unit test verifying `replayStream()` snapshots parts and
terminates promptly
- Manual testing of `/compact` with workspace refresh
---
_Generated with `mux` • Model: `anthropic:claude-opus-4-5` • Thinking:
`high`_
0 commit comments