Validation: Sort comments by most recent activity behind comment_threads flag (#304)
Verdict: PASS
Ticket
ldraney/landscaping-assistant#304 (board item #1901) — Newest-first comment sorting on property detail pages, gated behind
comment_threads feature flag. Threads with recent replies bubble to the top; replies within a thread stay chronological.Merged PR: #315 (commit
5ec3039)Environment
Production cluster, namespace
landscaping-assistant. URL: https://landscaping-assistant.app. Pod: landscaping-assistant-7d5669d55d-575pl, image harbor.tail5b443a.ts.net/landscaping-assistant/app:a0baf9ca04aaa3fea2d5b259a9b325198c9abb76 (latest main, includes #315 merge).Checks
| # | Criterion | Tier | How Verified | Result | Evidence |
|---|---|---|---|---|---|
| 1 | Top-level comments ordered by most recent activity (own created_at or latest reply's created_at) | T1 | Code review of <code>by_most_recent_activity</code> scope + RSpec spec "shows newest comments first" | PASS | Scope uses COALESCE with correlated subquery <code>MAX(replies.created_at)</code>, orders <code>latest_activity DESC</code>. 38 examples, 0 failures. |
| 2 | A new reply to an old thread bumps that thread to the top | T1 | RSpec spec "bumps a thread with a recent reply above newer top-level comments" | PASS | Test creates reply on old_comment with <code>created_at: 1.minute.ago</code>, verifies old thread appears before new_comment in response body. |
| 3 | Replies within a thread still render in chronological order (oldest first) | T1 | Code review of view template + "excludes replies from top-level listing" spec | PASS | View uses <code>comment.replies.sort_by(&:created_at)</code> for chronological order. Replies rendered nested inside parent, not in top-level list. |
| 4 | When comment_threads flag is disabled, comments fall back to oldest_first | T1+T3 | RSpec spec with <code>with_feature_disabled(:comment_threads)</code> + prod flag status check via rails runner | PASS | Controller conditional: <code>feature_enabled?(:comment_threads) ? by_most_recent_activity : oldest_first</code>. Prod flag: <code>enabled: false</code> (correct per feature-flags-first policy). |
| 5 | New comment via Turbo Stream is prepended (not appended) when newest-first sort is active | T1 | RSpec spec "prepends new comments via turbo stream" + code review of create.turbo_stream.erb | PASS | Template uses <code>turbo_stream.prepend "comments-list"</code> when flag enabled, <code>turbo_stream.append</code> when disabled. Spec verifies <code>action="prepend"</code> in response. |
| 6 | Woodpecker pipeline green for merge commit | T3 | Pipeline #831 status check via Woodpecker MCP | PASS | Pipeline #831 (push, main): all 6 steps success (clone, database, bundle-install, lint, test, build-and-push). |
| 7 | Pod running and healthy in production | T3 | <code>kubectl get pods -n landscaping-assistant</code> | PASS | 1/1 Running, 0 restarts. Image tag <code>a0baf9ca</code> matches latest main commit. |
| 8 | Route smoke tests (login, root, metrics, properties, today) | T3 | curl against production URLs | PASS | /login=200, /=302 (auth redirect), /metrics=200, /properties=302 (auth redirect), /today=302 (auth redirect). No 500s. |
Regression Check
All production routes respond correctly with expected status codes. No 500 errors detected. Pod running with 0 restarts. The feature is safely gated behind
comment_threads flag (currently disabled in prod), so existing comment behavior is unchanged until the flag is toggled on. Migration 20260725000001_add_parent_id_to_property_comments applied successfully (prerequisite from #303).Discovered Issues
None. No regressions or new bugs found during validation.