Code Maintenance/STC-462: Resolve #activity-<journal-sequence> anchors on demand dropping eager journal lateral sequencing#23506
Conversation
The work package activity tab computed a per-journal sequence_version on every render — a ROW_NUMBER() window function over a LATERAL join — only to stamp the legacy data-anchor-activity-id that #activity-N deep links rely on. Nothing mints those links anymore; copy and share links use #comment-<journal id>, which needs no extra query. The activity number is now resolved on demand. Only a request carrying ?anchor=activity-N runs the window function, mapping the number to a journal id the paginator exposes as resolved_anchor. The view hands that to the client, which rewrites #activity-N to the canonical #comment-<id> and scrolls using the comment anchor already present in the DOM. Default renders no longer touch the window function. References WP #68063.
8c5ae96 to
0eff428
Compare
#activity-<journal-sequence> anchors on demand dropping eager journal lateral sequencing
Contributor
There was a problem hiding this comment.
Pull request overview
Drops the ROW_NUMBER() OVER (...) JOIN LATERAL window-function join from the activity-tab's default render path. The legacy #activity-<sequence> URL is now treated as a backwards-compatible alias: when an activity-N anchor arrives, the server resolves it to a journal id once, exposes it as a Stimulus value (resolved-comment-id), and the client rewrites #activity-N to #comment-<id> in the address bar before scrolling. Journal item DOM no longer carries data-anchor-activity-id, only data-anchor-comment-id.
Changes:
- Paginator no longer applies
with_sequence_versionto the page slice; it only invokes the window function when anactivity-Nanchor needs resolution, and exposes the resolved comment id via a newresolved_anchorreader. - Controller, lazy index component, and journal item templates are updated to drop the
sequence_versionjoin from the default path and surfaceresolved_anchoras a Stimulus value to the client. - Frontend
UrlHelpers.canonicalActivityAnchorandAutoScrollingController.canonicalizeActivityAnchortranslate the legacy hash to the canonical comment hash viahistory.replaceState, with corresponding unit, request, and feature specs.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| app/services/work_packages/activities_tab/paginator.rb | Removes with_sequence_version from the page slice and records the resolved comment id only when an activity anchor is used. |
| app/controllers/work_packages/activities_tab_controller.rb | Forwards resolved_anchor to the lazy index component; drops with_sequence_version from find_journal and time-based update paths. |
| app/components/work_packages/activities_tab/lazy_index_component.rb | Accepts resolved_anchor and emits it as the resolved-comment-id Stimulus value when set. |
| app/components/.../journals/item_component(.html.erb, /details.rb) | Drops the now-unused data-anchor-activity-id DOM attribute. |
| frontend/.../services/url-helpers.ts (+ spec) | Adds canonicalActivityAnchor to map an unresolved or resolved activity anchor to a comment anchor. |
| frontend/.../auto-scrolling.controller.ts | Reads the new Stimulus value, canonicalises the URL hash via replaceState, and bails out when an activity anchor is unresolved. |
| spec/services/.../paginator_spec.rb | Asserts resolved_anchor semantics and that the window function is only run for activity anchors. |
| spec/requests/work_packages/activities_tab_spec.rb | New request spec covering the rendered Stimulus value attribute under all three anchor cases. |
| spec/features/.../activities_spec.rb | Adds a feature-level assertion that the URL is rewritten to #comment-<id> while preserving the work-package path. |
The Paginator.paginate class method bypassed the instance, discarding the resolved_anchor state the controller reads after .call; it had no callers, so drop it and keep the single new(...).call entry point. Extract the activity anchor side effect into record_resolved_anchor so the intent is explicit at the call site, and pin the server contract with a request spec asserting an unresolvable activity anchor omits the resolved-comment value.
#activity-<journal-sequence> anchors on demand dropping eager journal lateral sequencing#activity-<journal-sequence> anchors on demand dropping eager journal lateral sequencing
a01c952 to
3533fec
Compare
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Ticket
https://community.openproject.org/wp/STC-462
This builds on:
#activity-<journal-sequence>to#comment-<journal-id>#17721What are you trying to accomplish?
Removes a
ROW_NUMBER() OVER (...) JOIN LATERALwindow function aka.with_sequence_version(~130ms/page on long histories) from the activity-tab's common render path. The legacy#activity-Nanchor is now treated as a backwards-compatible alias and resolved lazily: when such a deep link arrives, the server resolves it to a journal id once, emits it as a resolved-comment-id Stimulus value, and the client canonicalises #activity-N → #comment- in the address bar.On a work package with 702 journals, the page-slice query goes from ~130ms to a few ms:
activity-N.mp4
Merge checklist