-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Bug/66552: Large amount of comments causes work package view to freeze (introduce lazy-loading and loading indicator for Activity tab) #20365
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
akabiru
merged 24 commits into
release/16.5
from
bug/66552-large-amount-of-comments-causes-workpackage-to-freeze
Oct 10, 2025
Merged
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
8d10241
Add Pagy dependency
myabc 874bdeb
initializer
myabc 2468d4d
Set up POC for infinite scrolling on AT (Messy Commit!)
akabiru 447a45b
Add infinite scrolling stimulus controller
akabiru aabd15b
Abort infinite scrolling for 1 page collections
akabiru aa7901d
Preserve scroll during infinite scroll page render
akabiru 4f47f31
Lower the intersection threshold to 25%
akabiru c1d070a
Extract `journal_sorting.{asc?,desc?}` inquiry
akabiru cab44aa
Specify scrollable container as the intended target whose bounding re…
akabiru 05c20e4
Tidy up function calls including guard clauses
akabiru 2484b48
Switch from infinite scrolling to managed lazy loaded pages
akabiru 40404ab
Delay loading to allow rapid scrolling without triggering loads
akabiru 79673c5
Support paginated deep linking of comments
akabiru 45b4178
DRY up activity anchor url parsing
akabiru 815beba
Prefer structured `URL` builder
akabiru 406d83d
Decouple observer setup from scroll setup
akabiru 13853fd
Re-initialize pagination JIT for tab replacement
akabiru 2cffdfc
Fix timing issue in Activities#type_comment for lazy-loaded pages
akabiru 448b328
Create enough comments > 1 page
akabiru 790f9a4
Extract work package activity tab pagination
akabiru 7940486
Add feature flag for activity tab lazy pagination
akabiru cfe3a2d
Group pagy with (legacy) will_paginate and remove version constraint
akabiru feb364e
Allow pagy options in paginator for overrides in test
akabiru 12a5f55
Clarify scroll preservation behaviour based on UI layout sorting order
akabiru File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
app/components/concerns/work_packages/activities_tab/journal_sorting_inquirable.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| # -- copyright | ||
| # OpenProject is an open source project management software. | ||
| # Copyright (C) the OpenProject GmbH | ||
| # | ||
| # This program is free software; you can redistribute it and/or | ||
| # modify it under the terms of the GNU General Public License version 3. | ||
| # | ||
| # OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: | ||
| # Copyright (C) 2006-2013 Jean-Philippe Lang | ||
| # Copyright (C) 2010-2013 the ChiliProject Team | ||
| # | ||
| # This program is free software; you can redistribute it and/or | ||
| # modify it under the terms of the GNU General Public License | ||
| # as published by the Free Software Foundation; either version 2 | ||
| # of the License, or (at your option) any later version. | ||
| # | ||
| # This program is distributed in the hope that it will be useful, | ||
| # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| # GNU General Public License for more details. | ||
| # | ||
| # You should have received a copy of the GNU General Public License | ||
| # along with this program; if not, write to the Free Software | ||
| # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
| # | ||
| # See COPYRIGHT and LICENSE files for more details. | ||
| # ++ | ||
|
|
||
| module WorkPackages | ||
| module ActivitiesTab | ||
| module JournalSortingInquirable | ||
| extend ActiveSupport::Concern | ||
|
|
||
| def journal_sorting | ||
| ActiveSupport::StringInquirer | ||
| .new(User.current.preference&.comments_sorting || OpenProject::Configuration.default_comment_sort_order) | ||
| end | ||
| end | ||
| end | ||
| end | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
app/components/work_packages/activities_tab/journals/lazy_index_component.html.erb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| <%= | ||
| component_wrapper(class: "work-packages-activities-tab-journals-index-component") do | ||
| flex_layout(data: { test_selector: "op-wp-journals-#{filter}-#{journal_sorting}" }) do |journals_index_wrapper_container| | ||
| journals_index_wrapper_container.with_row( | ||
| classes: "work-packages-activities-tab-journals-index-component--journals-inner-container", | ||
| mb: inner_container_margin_bottom | ||
| ) do | ||
| flex_layout( | ||
| data: { test_selector: "op-wp-journals-container" } | ||
| ) do |journals_index_container| | ||
| if empty_state? | ||
| journals_index_container.with_row(mt: 2, mb: 3) do | ||
| render(WorkPackages::ActivitiesTab::Journals::EmptyComponent.new) | ||
| end | ||
| else | ||
| journals_index_container.with_row(id: insert_target_modifier_id) do | ||
| pages.map { concat render(it) } | ||
| end | ||
| end | ||
| end | ||
| end | ||
|
|
||
| unless empty_state? | ||
| journals_index_wrapper_container | ||
| .with_row(classes: "work-packages-activities-tab-journals-index-component--stem-connection") | ||
| end | ||
| end | ||
| end | ||
| %> |
78 changes: 78 additions & 0 deletions
78
app/components/work_packages/activities_tab/journals/lazy_index_component.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| # -- copyright | ||
| # OpenProject is an open source project management software. | ||
| # Copyright (C) the OpenProject GmbH | ||
| # | ||
| # This program is free software; you can redistribute it and/or | ||
| # modify it under the terms of the GNU General Public License version 3. | ||
| # | ||
| # OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: | ||
| # Copyright (C) 2006-2013 Jean-Philippe Lang | ||
| # Copyright (C) 2010-2013 the ChiliProject Team | ||
| # | ||
| # This program is free software; you can redistribute it and/or | ||
| # modify it under the terms of the GNU General Public License | ||
| # as published by the Free Software Foundation; either version 2 | ||
| # of the License, or (at your option) any later version. | ||
| # | ||
| # This program is distributed in the hope that it will be useful, | ||
| # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| # GNU General Public License for more details. | ||
| # | ||
| # You should have received a copy of the GNU General Public License | ||
| # along with this program; if not, write to the Free Software | ||
| # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
| # | ||
| # See COPYRIGHT and LICENSE files for more details. | ||
| # ++ | ||
|
|
||
| module WorkPackages | ||
| module ActivitiesTab | ||
| module Journals | ||
| class LazyIndexComponent < IndexComponent | ||
| def initialize(work_package:, journals:, paginator:, filter: :all) | ||
| super(work_package:, filter:, deferred: false) | ||
|
|
||
| @journals = journals | ||
| @paginator = paginator | ||
| end | ||
|
|
||
| def pages | ||
| current_page = paginator.page | ||
|
|
||
| result = (1..paginator.pages).map do |page| | ||
| if page == current_page | ||
| page_component(page) | ||
| else | ||
| lazy_page_component(page) | ||
| end | ||
| end | ||
|
|
||
| result.tap { it.reverse! if journal_sorting.asc? && paginator.pages > 1 } | ||
| end | ||
|
|
||
| def page_component(page) | ||
| WorkPackages::ActivitiesTab::Journals::PageComponent | ||
| .new(journals:, emoji_reactions: wp_journals_grouped_emoji_reactions, page:, filter:) | ||
| end | ||
|
|
||
| def lazy_page_component(page) | ||
| WorkPackages::ActivitiesTab::Journals::LazyPageComponent.new(work_package:, page:) | ||
| end | ||
|
|
||
| def self.insert_target_modifier_id = "#{wrapper_key}-pages" | ||
| delegate :insert_target_modifier_id, to: :class | ||
|
|
||
| private | ||
|
|
||
| attr_reader :journals, :paginator | ||
|
|
||
| def insert_target_modified? | ||
| true | ||
| end | ||
| end | ||
| end | ||
| end | ||
| end |
47 changes: 47 additions & 0 deletions
47
app/components/work_packages/activities_tab/journals/lazy_page_component.html.erb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| <%# -- copyright | ||
| OpenProject is an open source project management software. | ||
| Copyright (C) the OpenProject GmbH | ||
|
|
||
| This program is free software; you can redistribute it and/or | ||
| modify it under the terms of the GNU General Public License version 3. | ||
|
|
||
| OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: | ||
| Copyright (C) 2006-2013 Jean-Philippe Lang | ||
| Copyright (C) 2010-2013 the ChiliProject Team | ||
|
|
||
| This program is free software; you can redistribute it and/or | ||
| modify it under the terms of the GNU General Public License | ||
| as published by the Free Software Foundation; either version 2 | ||
| of the License, or (at your option) any later version. | ||
|
|
||
| This program is distributed in the hope that it will be useful, | ||
| but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| GNU General Public License for more details. | ||
|
|
||
| You should have received a copy of the GNU General Public License | ||
| along with this program; if not, write to the Free Software | ||
| Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
|
|
||
| See COPYRIGHT and LICENSE files for more details. | ||
|
|
||
| ++# %> | ||
|
|
||
| <%= | ||
| component_wrapper(data: wrapper_data_attributes) do | ||
| flex_layout( | ||
| class: "work-packages-activities-tab-journals-item-component", | ||
| bg: :default | ||
| ) do |skeleton| | ||
| 5.times do | ||
| skeleton.with_row(mb: 2) do | ||
| render(Primer::Alpha::SkeletonBox.new(width: "25%", height: "40px")) | ||
| end | ||
|
|
||
| skeleton.with_row(mb: 3) do | ||
| render(Primer::Alpha::SkeletonBox.new(width: "100%", height: "150px")) | ||
| end | ||
| end | ||
| end | ||
| end | ||
| %> |
73 changes: 73 additions & 0 deletions
73
app/components/work_packages/activities_tab/journals/lazy_page_component.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| #-- copyright | ||
| # OpenProject is an open source project management software. | ||
| # Copyright (C) the OpenProject GmbH | ||
| # | ||
| # This program is free software; you can redistribute it and/or | ||
| # modify it under the terms of the GNU General Public License version 3. | ||
| # | ||
| # OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: | ||
| # Copyright (C) 2006-2013 Jean-Philippe Lang | ||
| # Copyright (C) 2010-2013 the ChiliProject Team | ||
| # | ||
| # This program is free software; you can redistribute it and/or | ||
| # modify it under the terms of the GNU General Public License | ||
| # as published by the Free Software Foundation; either version 2 | ||
| # of the License, or (at your option) any later version. | ||
| # | ||
| # This program is distributed in the hope that it will be useful, | ||
| # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| # GNU General Public License for more details. | ||
| # | ||
| # You should have received a copy of the GNU General Public License | ||
| # along with this program; if not, write to the Free Software | ||
| # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
| # | ||
| # See COPYRIGHT and LICENSE files for more details. | ||
| #++ | ||
|
|
||
| module WorkPackages | ||
| module ActivitiesTab | ||
| module Journals | ||
| class LazyPageComponent < ApplicationComponent | ||
| include OpPrimer::ComponentHelpers | ||
| include OpTurbo::Streamable | ||
| include WorkPackages::ActivitiesTab::StimulusControllers | ||
|
|
||
| def initialize(work_package:, page:) | ||
| super | ||
| @work_package = work_package | ||
| @page = page | ||
| end | ||
|
|
||
| def self.wrapper_key | ||
| WorkPackages::ActivitiesTab::Journals::PageComponent.wrapper_key | ||
| end | ||
|
|
||
| def wrapper_uniq_by | ||
| page | ||
| end | ||
|
|
||
| private | ||
|
|
||
| attr_reader :work_package, :page | ||
|
|
||
| def wrapper_data_attributes | ||
| { | ||
| controller: lazy_page_stimulus_controller, | ||
| lazy_page_stimulus_controller("-insert-target-id-value") => wrapper_key, | ||
| lazy_page_stimulus_controller("-page-value") => page, | ||
| lazy_page_stimulus_controller("-url-value") => page_streams_url, | ||
| lazy_page_stimulus_controller("-is-loaded-value") => false | ||
| } | ||
| end | ||
|
|
||
| def page_streams_url | ||
| page_streams_work_package_activities_path(work_package, format: :turbo_stream) | ||
| end | ||
| end | ||
| end | ||
| end | ||
| end |
20 changes: 20 additions & 0 deletions
20
app/components/work_packages/activities_tab/journals/page_component.html.erb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| <%= | ||
| component_wrapper do | ||
| flex_layout do |flex_container| | ||
| journals.each do |record| | ||
| flex_container.with_row do | ||
| if record.is_a?(Changeset) | ||
| render(WorkPackages::ActivitiesTab::Journals::RevisionComponent.new(changeset: record, filter:)) | ||
| else | ||
| render( | ||
| WorkPackages::ActivitiesTab::Journals::ItemComponent.new( | ||
| journal: record, filter:, | ||
| grouped_emoji_reactions: emoji_reactions.fetch(record.id, {}) | ||
| ) | ||
| ) | ||
| end | ||
| end | ||
| end | ||
| end | ||
| end | ||
| %> |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.