Skip to content

perf: remove intermediate activities after stream ends#5798

Open
OEvgeny wants to merge 6 commits intomainfrom
perf/remove-livestream-after-end
Open

perf: remove intermediate activities after stream ends#5798
OEvgeny wants to merge 6 commits intomainfrom
perf/remove-livestream-after-end

Conversation

@OEvgeny
Copy link
Copy Markdown
Collaborator

@OEvgeny OEvgeny commented Apr 3, 2026

Fixes #

Changelog Entry

  • Improved livestream performance by pruning intermediate revision activities after a stream session is finalized, in PR #5798, by @OEvgeny

Description

After a livestream session is finalized, intermediate revision activities are no longer needed. This change prunes them from the sorted activity list and filters stale graph nodes from the ordered activities state, reducing the number of activities held in memory and rendered.

Design

Pruning happens at two layers:

  1. computeSortedActivities — A new yieldSessionActivities generator checks whether a session is finalized. If so, it yields only the last (final) revision instead of all intermediate revisions.
  2. GraphProvider — Because the graph does not support node deletion, stale nodes linger after the Redux store prunes activities. The orderedActivitiesState memo now cross-checks each graph node against the current Redux store activities and filters out any that no longer exist.

Specific Changes

  • Added yieldSessionActivities helper in computeSortedActivities.ts that yields only the final revision for finalized livestream sessions
  • Updated GraphProvider.tsx to filter orderedActivityNodes against current Redux store activities, removing stale graph nodes from the output

  • I have added tests and executed them locally
  • I have updated CHANGELOG.md
  • I have updated documentation

Review Checklist

This section is for contributors to review your work.

  • Accessibility reviewed (tab order, content readability, alt text, color contrast)
  • Browser and platform compatibilities reviewed
  • CSS styles reviewed (minimal rules, no z-index)
  • Documents reviewed (docs, samples, live demo)
  • Internationalization reviewed (strings, unit formatting)
  • package.json and package-lock.json reviewed
  • Security reviewed (no data URIs, check for nonce leak)
  • Tests reviewed (coverage, legitimacy)

@OEvgeny OEvgeny marked this pull request as ready for review April 3, 2026 20:42
Copilot AI review requested due to automatic review settings April 3, 2026 20:42
@OEvgeny OEvgeny requested a review from tdurnford as a code owner April 3, 2026 20:42
@OEvgeny OEvgeny marked this pull request as draft April 3, 2026 20:43
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves livestream performance by pruning intermediate livestream revision activities once a stream session is finalized, and by preventing stale graph nodes (created from now-pruned revisions) from surfacing in the graph-derived ordered activities.

Changes:

  • Updated computeSortedActivities to yield only the final revision for finalized livestream sessions.
  • Updated GraphProvider to filter ordered graph activity nodes against the current Redux activities list to exclude pruned/stale nodes.
  • Updated unit and HTML2 livestream tests plus CHANGELOG.md to reflect the new pruning behavior.

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
packages/core/src/reducers/activities/sort/private/computeSortedActivities.ts Adds yieldSessionActivities to omit intermediate livestream revisions after finalization.
packages/api-graph/src/private/GraphProvider.tsx Filters graph-ordered activity nodes to exclude ones no longer present in Redux activities.
packages/core/src/reducers/activities/sort/upsert.livestream.spec.ts Updates expectations so finalized streams only contribute the final activity to sortedActivities.
packages/core/src/reducers/activities/sort/upsert.howToWithLivestream.spec.ts Updates expectations for finalized livestream sessions inside part groupings.
packages/core/src/reducers/activities/sort/deleteActivityByLocalId.livestream.spec.ts Adjusts deletion test indexing/lengths due to pruning behavior.
packages/core/src/reducers/activities/sort/deleteActivityByLocalId.howToWithLivestream.spec.ts Adjusts deletion test indexing/lengths due to pruning behavior in groupings.
tests/html2/livestream/*.html Updates livestream key expectations to reflect intermediate-revision pruning.
CHANGELOG.md Adds changelog entry for the performance improvement.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@OEvgeny OEvgeny marked this pull request as ready for review April 3, 2026 20:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants