[codex] fix: ignore stale shell reducer events#3517
Conversation
Co-authored-by: Codex <codex@openai.com>
…stale-sequence
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
ApprovabilityVerdict: Approved Simple defensive guard that prevents stale events from being re-applied to the shell snapshot reducer. The change is minimal (2 lines), follows existing patterns in the file, and includes test coverage. You can customize Macroscope's approvability policy. Learn more. |
Co-authored-by: Codex <codex@openai.com>
Summary
Root cause
The reducer accepted older sequence events after newer state had already been applied.
Impact
Out-of-order shell events no longer regress current shell state.
Validation
PATH="$HOME/.vite-plus/bin:$PATH" vp test packages/client-runtime/src/state/shellReducer.test.tsPATH="$HOME/.vite-plus/bin:$PATH" vp checkPATH="$HOME/.vite-plus/bin:$PATH" vp run typecheckNote
Low Risk
Small, pure reducer guard with targeted tests; shared by web/mobile but behavior is strictly more conservative on stale events.
Overview
applyShellStreamEventnow bails out before the eventswitchwhenevent.sequenceis less than or equal to the snapshot’ssnapshotSequence, returning the same snapshot reference with no project/thread updates.That stops duplicate or out-of-order orchestration shell stream events (e.g. late
project-upserted) from overwriting newer local shell state on web and mobile. A unit test covers sequences 3 and 4 against a snapshot already at 4.Reviewed by Cursor Bugbot for commit 8757ca5. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Fix
applyShellStreamEventto ignore stale shell reducer eventsAdds an early return in
applyShellStreamEventthat skips any event whose sequence number is less than or equal to the currentsnapshotSequence, returning the original snapshot reference unchanged. This prevents out-of-order or duplicate events from incorrectly mutating state.Macroscope summarized 8757ca5.