Problem/Motivation
Advanced Comment Threads renders a 216-comment thread on freelock.com. A review of the module across UI/UX, performance, and security found the architecture is strong on security and the progressive-loading concept is sound, but performance does not scale on large discussions. The intent of this META issue is to capture the full review and to break each performance fix into its own child issue.
The security posture is good and no security follow-ups are required at this time: access is re-checked per comment and per request, GET endpoints are non-mutating, no user input reaches SQL unescaped, cache-control is locked down on all ACT routes, and the XSS surface is minimal. The performance findings below are the actionable output.
Steps to reproduce
Proposed resolution
All five findings are server-side scaling / on-demand loading issues. Each will get a dedicated child issue. Summary of the proposed fixes:
- Full index rebuild per on-demand request. Every fragment/branch/delivery/filter/refresh endpoint calls CommentIndexRepository::load(), which runs an unbounded query for all comments on the node and loads them all, then runs a per-comment access check and full tree build. Fetching one comment costs loading all 216. Fix: bound load() / the fragment endpoints to the requested slice.
- Expand All does not scale. comment-thread.js awaits ensureRendered() for every id in sequence. Measured 139/216 cards after 20 seconds. Fix: batch and parallelize through the existing delivery endpoint (up to 50 ids per request) with a concurrency limit, and mark the button busy.
- Selection prefetches every sibling. selectComment prefetches all siblings, firing ~9 full fragment requests per click. Fix: prefetch a small window or defer until reveal.
- ~190 KB of redundant per-comment URLs shipped. contextUrls/commentUrls/branchUrls contain 3 fully-qualified signed URLs per comment (216 x 3). The signature is field-level, not per-comment. Fix: ship URLs only for initially-visible comments, or build them client-side from a shared signature/template.
- Comment index built twice per node render. build() loads the index for the thread and the history lazy builder loads it again. Fix: thread the built index into the lazy builder, or cache it within the request.
Remaining tasks
- Create child issues for the five fixes above.
- Confirm each fix against a real 200+ comment thread, not just unit tests.
User interface changes
- Expand All: render as busy/disabled while loading, and load the full thread in bounded batches rather than freezing the UI for tens of seconds.
- Filter results: hydrate the capped result set without a long serial reveal that leaves the status on "Searching comments...".
API changes
- Fragment/branch/delivery endpoints should accept and honor an id slice so a partial-thread request is O(slice), not O(total).
- Reduce or eliminate the per-comment URL maps exposed in drupalSettings.
Data model changes
- None anticipated. No schema or config change is required for these fixes.
AI-generated: Yes (used Deepseek Flash 4 Vision to evaluate security, UX, UI, performance on a local site with 200+ comments)
Comments
Comment #2
freelockComment #3
freelockAll issues completed and shipped in Alpha4!