Skip to content

Conversation

akabiru
Copy link
Member

@akabiru akabiru commented Sep 18, 2025

Ticket

https://community.openproject.org/wp/66552

What are you trying to accomplish?

Add lazy loaded pages to the activity tab. Remove the deferred render-all pages mechanism.

🌮 Todos (WIP 🚧 )

  • Address deep-linked comments.
  • Address tab replacement (through sorting or filter changes).
  • Overlay filter & sorting components so that they are always visible (On Desktop)
  • Optimise DB queries, move away from slow array based pagination (https://community.openproject.org/wp/68063)

Important

The last two items, filtering & DB query optimisation will be handled separately.

Screenshots

deep-linking-works.mp4

What approach did you choose and why?

Eager load only one page (current), lazy load all other pages as they become visible (useIntersection#appear()) for at least 75ms.

Note

This work is behind a feature flag to allow for adequate testing & reasonable fallback
OPENPROJECT_FEATURE_WP_ACTIVITY_TAB_LAZY_PAGINATION_ACTIVE

Merge checklist

  • Added/updated tests
  • Added/updated documentation in Lookbook (patterns, previews, etc)
  • Tested major browsers (Chrome, Firefox, Edge, ...)

@akabiru akabiru self-assigned this Sep 18, 2025
@akabiru akabiru force-pushed the bug/66552-large-amount-of-comments-causes-workpackage-to-freeze branch 2 times, most recently from 0f4bfe7 to 65ed336 Compare October 1, 2025 19:22
@akabiru akabiru changed the title Bug/66552 Large amount of comments causes workpackage to freeze (missing lazy-loading and loading indicator for Activity tab) Bug/66552: Large amount of comments causes work package view to freeze (introduce lazy-loading and loading indicator for Activity tab) Oct 1, 2025
@akabiru akabiru requested a review from Copilot October 1, 2025 20:59
Copy link

@Copilot 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 implements lazy loading with infinite scrolling for the Activity tab to address performance issues when work packages have large amounts of comments. The change replaces the previous deferred rendering mechanism with a paginated approach using the Pagy gem.

Key changes include:

  • Introduction of infinite scroll functionality triggered by intersection observer
  • Implementation of Pagy-based pagination with 30 items per page
  • Addition of scroll position preservation during DOM manipulations
  • New skeleton loading indicator for better user experience

Reviewed Changes

Copilot reviewed 19 out of 21 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
frontend/src/stimulus/setup.ts Registers new infinite scroll Stimulus controller
frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/services/dom_helpers.ts Provides scroll preservation utilities for infinite scroll
frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/infinite-scroll.controller.ts Main infinite scroll controller implementation
config/routes.rb Adds page_streams route for pagination
config/initializers/permissions.rb Grants page_streams permission
config/initializers/pagy.rb Pagy pagination library configuration
app/controllers/work_packages/activities_tab_controller.rb Implements pagination logic and page streaming
app/controllers/concerns/op_turbo/component_stream.rb Adds turbo stream helpers for pagination
app/components/work_packages/activities_tab/shared_helpers.rb Adds sorting helper methods
app/components/work_packages/activities_tab/journals/page_component.rb Component for rendering journal pages
app/components/work_packages/activities_tab/journals/infinite_scroll_component.rb Infinite scroll trigger component
app/components/work_packages/activities_tab/journals/index_component.rb Refactored to support pagination
app/components/work_packages/activities_tab/index_component.rb Updated to pass pagination data
app/components/concerns/work_packages/activities_tab/stimulus_controllers.rb Adds infinite scroll controller reference
Gemfile Adds Pagy gem dependency

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@akabiru akabiru force-pushed the bug/66552-large-amount-of-comments-causes-workpackage-to-freeze branch 8 times, most recently from 4d04f29 to 35e67c4 Compare October 8, 2025 07:31
Pick up any changes to sorting or filtering preferences
Add `wait_for_network_idle` at the start of `type_comment`
to ensure all pending Turbo Stream rendering completes before
attempting to interact with the form.

This is needed as the lazy pages now intercept turbo stream rendering.
@akabiru akabiru added this to the 16.5.x milestone Oct 8, 2025
@akabiru akabiru force-pushed the bug/66552-large-amount-of-comments-causes-workpackage-to-freeze branch from eb104e6 to de6c207 Compare October 8, 2025 12:44
@akabiru akabiru changed the base branch from dev to release/16.5 October 8, 2025 12:44
@akabiru akabiru marked this pull request as ready for review October 8, 2025 12:48
@akabiru akabiru requested review from a team, dombesz and myabc October 8, 2025 12:49
@akabiru
Copy link
Member Author

akabiru commented Oct 8, 2025

@akabiru akabiru force-pushed the bug/66552-large-amount-of-comments-causes-workpackage-to-freeze branch from de6c207 to 7940486 Compare October 8, 2025 16:15
Copy link

github-actions bot commented Oct 8, 2025

Caution

The provided work package version does not match the core version

Details:

Please make sure that:

  • The work package version OR your pull request target branch is correct

Copy link
Contributor

@judithroth judithroth left a comment

Choose a reason for hiding this comment

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

Wow, nice work! As far as I can tell this works amazingly! 🎉
I have some small comments / questions, but nothing blocking 🙂

@akabiru akabiru force-pushed the bug/66552-large-amount-of-comments-causes-workpackage-to-freeze branch from 7068e6d to 12a5f55 Compare October 10, 2025 07:20
@akabiru
Copy link
Member Author

akabiru commented Oct 10, 2025

👋🏾 @myabc @dombesz - will merge now to get things moving (Thanks for the review @judithroth ! 💪🏾 ). Please still feel free to share any feedback you have- as I spoke to you both on the topic :)

@akabiru akabiru merged commit 940528e into release/16.5 Oct 10, 2025
20 checks passed
@akabiru akabiru deleted the bug/66552-large-amount-of-comments-causes-workpackage-to-freeze branch October 10, 2025 12:15
@github-actions github-actions bot locked and limited conversation to collaborators Oct 10, 2025
Copy link
Contributor

@dombesz dombesz left a comment

Choose a reason for hiding this comment

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

Nice improvement @akabiru ! Bit late to the party, but I just leave a few comments. None of them are critical.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Development

Successfully merging this pull request may close these issues.

4 participants