Skip to content

fix(web): ignore stale runtime projection snapshots#2301

Merged
juliusmarminge merged 1 commit intopingdotgg:mainfrom
Pedro-Revez-Silva:fix/stale-runtime-snapshots
Apr 23, 2026
Merged

fix(web): ignore stale runtime projection snapshots#2301
juliusmarminge merged 1 commit intopingdotgg:mainfrom
Pedro-Revez-Silva:fix/stale-runtime-snapshots

Conversation

@Pedro-Revez-Silva
Copy link
Copy Markdown
Contributor

@Pedro-Revez-Silva Pedro-Revez-Silva commented Apr 23, 2026

What Changed

  • track the last applied shell projection version per environment in the runtime service
  • drop stale shell snapshots and duplicate or out-of-order shell stream events instead of applying them
  • add targeted tests for older-sequence, older-timestamp, duplicate-event, and newer-event cases

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

  • This PR is small and focused
  • I explained what changed and why
  • I included before/after screenshots for any UI changes
  • I included a video for animation/interaction changes

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 older updatedAt).

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

  • Adds shouldApplyProjectionSnapshot and shouldApplyProjectionEvent guards in service.ts to skip applying outdated data. Snapshots are compared by sequence first, then updatedAt as a tiebreaker; events require a strictly increasing sequence.
  • Tracks the last applied projection version per environment in a new lastAppliedProjectionVersionByEnvironment map, cleared when a connection is removed.
  • Behavioral Change: applyShellEvent and syncShellSnapshot handlers now silently drop duplicate or out-of-order updates instead of applying them.

Macroscope summarized 781f242.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 23, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 596b099d-ad73-4b1e-a06c-4b6e70adb305

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:L 100-499 changed lines (additions + deletions). labels Apr 23, 2026
@macroscopeapp
Copy link
Copy Markdown
Contributor

macroscopeapp Bot commented Apr 23, 2026

Approvability

Verdict: 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.

@juliusmarminge juliusmarminge enabled auto-merge (squash) April 23, 2026 15:42
@juliusmarminge juliusmarminge merged commit 0d55a42 into pingdotgg:main Apr 23, 2026
12 checks passed
@Pedro-Revez-Silva Pedro-Revez-Silva deleted the fix/stale-runtime-snapshots branch April 23, 2026 15:54
yazandabbas pushed a commit to yazandabbas/Presence that referenced this pull request Apr 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L 100-499 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants