fix(web): ignore stale runtime projection snapshots#2301
fix(web): ignore stale runtime projection snapshots#2301juliusmarminge merged 1 commit intopingdotgg:mainfrom
Conversation
|
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 This is a focused bug fix that adds sequence-based filtering to prevent stale projection snapshots and events from overwriting newer state in the runtime service. The logic is straightforward comparison operations with comprehensive test coverage. You can customize Macroscope's approvability policy. Learn more. |
(cherry picked from commit 0d55a42)
What Changed
Why
The shell stream and shell snapshot recovery path can arrive out of order. When an older snapshot lands after a newer shell event or snapshot, the client can briefly replace the current project and thread state with stale data. That shows up as threads or projects disappearing and then reappearing on the next update.
This change makes shell projection application monotonic by sequence and timestamp so older state is ignored instead of overwriting newer state.
Checklist
Note
Medium Risk
Changes the runtime environment projection sync to drop out-of-order snapshots and stream events; a bug in the version comparison/tracking could cause clients to ignore legitimate updates and appear stuck.
Overview
Makes shell projection application monotonic per environment by tracking the last applied
{sequence, updatedAt}and ignoring stale shell snapshots (older sequence or same sequence with olderupdatedAt).Also drops duplicate/out-of-order shell stream events by sequence, updates the tracked version after applying accepted events/snapshots, and clears this per-environment state on disconnect/test resets. Adds focused unit tests for snapshot/event acceptance and rejection edge cases.
Reviewed by Cursor Bugbot for commit 781f242. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Ignore stale runtime projection snapshots and events in environment service
shouldApplyProjectionSnapshotandshouldApplyProjectionEventguards in service.ts to skip applying outdated data. Snapshots are compared by sequence first, thenupdatedAtas a tiebreaker; events require a strictly increasing sequence.lastAppliedProjectionVersionByEnvironmentmap, cleared when a connection is removed.applyShellEventandsyncShellSnapshothandlers now silently drop duplicate or out-of-order updates instead of applying them.Macroscope summarized 781f242.