perf: make streaming projection and activity appends incremental #6608
Closedx1xhlol(GitHub profile, opens in a new tab)wants to merge 4 commits into
main fromrefs/pull/6608/headopened View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:M
- packages/client-runtime/src/state/threadReducer.ts line 592Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -571,3 +571,10 @@571571 // thread.reverted that discards turns can still resolve a value from572572 // the turns that survive.573573 const supersedesContextWindow = isResolvableContextWindowActivity(activity);574+ // Live streams append in order: when the new activity sorts at or after575+ // the tail and its id is unseen, a plain append preserves ordering576+ // without re-filtering and re-sorting the whole history on every event.577+ const lastActivity = thread.activities.at(-1);578+ if (579+ !supersedesContextWindow &&580+ (lastActivity === undefined || activityOrder(lastActivity, activity) <= 0) &&
- packages/client-runtime/src/state/threadReducer.ts line 607Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -571,3 +571,21 @@571571 // thread.reverted that discards turns can still resolve a value from572572 // the turns that survive.573573 const supersedesContextWindow = isResolvableContextWindowActivity(activity);574+ // Live streams append in order: when the new activity sorts at or after575+ // the tail and its id is unseen, a plain append preserves ordering576+ // without re-filtering and re-sorting the whole history on every event.577+ const lastActivity = thread.activities.at(-1);578+ if (579+ !supersedesContextWindow &&580+ (lastActivity === undefined || activityOrder(lastActivity, activity) <= 0) &&581+ !thread.activities.some((entry) => entry.id === activity.id)582+ ) {583+ return {584+ kind: "updated",585+ thread: {586+ ...thread,587+ activities: Arr.append(thread.activities, activity),588+ updatedAt: event.occurredAt,589+ },590+ };591+ }
github-actions[bot](GitHub profile, opens in a new tab) removed labelssize:M
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
github-actions[bot](GitHub profile, opens in a new tab) removed labelssize:L
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:M
t3dotgg(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.


Important
Review skipped#
Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID:
3bcc83ab-8871-4ec8-872b-97592ad05587You can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.Use the checkbox below for a quick retry:
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