fix(preview): preserve comment DOM anchors across fetch + re-share#244
Merged
Conversation
Preview comments are DOM pins, but dom_anchor was dropped on two round-trip legs: - output.ex serialize_comment_for_export/1 (the `crit fetch` export at GET /api/export/:token/comments) omitted dom_anchor, so the CLI could not read anchors back. - reviews.ex replace_comments/3 hand-built its attrs map without dom_anchor, so re-sharing/upserting a review stripped every anchor. Both serializers now emit dom_anchor and the upsert path carries it forward (prefer payload, else the existing row matched by external_id, mirroring the user_id attribution carry-forward). Also removes a dead `stats: Crit.Statistics.totals()` assign from the homepage controller — no page_html template consumes @stats since the marketing revamp removed the stats band; it was an unused DB aggregate on every homepage load. Adds tests: dom_anchor survives re-share (payload + carry-forward), and the export JSON includes dom_anchor. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2 tasks
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #244 +/- ##
==========================================
+ Coverage 82.42% 82.43% +0.01%
==========================================
Files 89 89
Lines 3089 3091 +2
==========================================
+ Hits 2546 2548 +2
Misses 543 543
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
Summary
Preview comments are DOM pins, but
dom_anchorwas being dropped on two round-trip legs (found in the pre-release audit of v0.9.0..main):output.exserialize_comment_for_export/1(thecrit fetchexport atGET /api/export/:token/comments) omitteddom_anchor, so the CLI couldn't read anchors back. Now aligned with the live serializerReviews.serialize_comment/1.reviews.exreplace_comments/3hand-built its attrs map withoutdom_anchor, so re-sharing/upserting a review stripped every anchor. Now carries it forward (prefer payload, else the existing row matched byexternal_id, mirroring theuser_idattribution carry-forward).Also removes a dead
stats: Crit.Statistics.totals()assign from the homepage controller — nopage_htmltemplate consumes@statssince the marketing revamp removed the stats band; it was an unused DB aggregate on every homepage load.Review
Test plan
mix precommit(compile --warnings-as-errors, format, sobelow, tests): 1018 tests, 0 failuresdom_anchorsurvives re-share (payload + carry-forward viaexternal_id); export JSON includesdom_anchor🤖 Generated with Claude Code