Skip to content

[codex] fix: ignore stale shell reducer events#3517

Merged
juliusmarminge merged 3 commits into
pingdotgg:mainfrom
StiensWout:staging/guard-shell-reducer-stale-sequence
Jun 23, 2026
Merged

[codex] fix: ignore stale shell reducer events#3517
juliusmarminge merged 3 commits into
pingdotgg:mainfrom
StiensWout:staging/guard-shell-reducer-stale-sequence

Conversation

@StiensWout

@StiensWout StiensWout commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Ignore stale shell reducer events whose sequence is older than the current shell state.
  • Preserve newer shell state when out-of-order lifecycle events arrive.

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.ts
  • PATH="$HOME/.vite-plus/bin:$PATH" vp check
  • PATH="$HOME/.vite-plus/bin:$PATH" vp run typecheck

Note

Low Risk
Small, pure reducer guard with targeted tests; shared by web/mobile but behavior is strictly more conservative on stale events.

Overview
applyShellStreamEvent now bails out before the event switch when event.sequence is less than or equal to the snapshot’s snapshotSequence, 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 applyShellStreamEvent to ignore stale shell reducer events

Adds an early return in applyShellStreamEvent that skips any event whose sequence number is less than or equal to the current snapshotSequence, returning the original snapshot reference unchanged. This prevents out-of-order or duplicate events from incorrectly mutating state.

Macroscope summarized 8757ca5.

@coderabbitai

coderabbitai Bot commented Jun 23, 2026

Copy link
Copy Markdown

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: 26a98c37-a79f-4628-b1b6-54e07113e3ec

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.

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:XS 0-9 changed lines (additions + deletions). labels Jun 23, 2026
@macroscopeapp

macroscopeapp Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Approvability

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

@juliusmarminge
juliusmarminge merged commit 4abf8b4 into pingdotgg:main Jun 23, 2026
14 checks passed
simonbetton pushed a commit to simonbetton/reviewer that referenced this pull request Jun 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XS 0-9 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