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
🤖 Add defensive checks for init-output and message processing (#413)
## Problem
After #228 merged, encountered two issues:
1. **Init-output crash**: `StreamingMessageAggregator.ts:516` throws
`Cannot read properties of undefined (reading 'trimEnd')` when
processing init-output events with missing `line` field
2. **Inconsistent message appearance**: User messages sometimes don't
appear immediately in chat view
## Solution
### 1. Init-output defensive check
Added null check for `data.line` before calling `trimEnd()`:
```typescript
if (!data.line) return; // Defensive: skip events with missing line data
```
Follows the defensive pattern from #228 - gracefully handle edge cases
during replay.
### 2. Message processing condition tightened
Added `'role' in data` check to the caught-up branch:
```typescript
} else if (isCaughtUp && "role" in data) {
```
Makes the condition symmetric with the buffering branch and ensures only
valid CmuxMessages are processed.
## Testing
- ✅ `make typecheck` passes
- ✅ All 763 unit tests pass
_Generated with `cmux`_
0 commit comments