Skip to content

fix(preview): preserve comment DOM anchors across fetch + re-share#244

Merged
tomasz-tomczyk merged 1 commit into
mainfrom
audit/dom-anchor-roundtrip
May 30, 2026
Merged

fix(preview): preserve comment DOM anchors across fetch + re-share#244
tomasz-tomczyk merged 1 commit into
mainfrom
audit/dom-anchor-roundtrip

Conversation

@tomasz-tomczyk
Copy link
Copy Markdown
Owner

@tomasz-tomczyk tomasz-tomczyk commented May 30, 2026

Summary

Preview comments are DOM pins, but dom_anchor was being dropped on two round-trip legs (found in the pre-release audit of v0.9.0..main):

  • Export legoutput.ex serialize_comment_for_export/1 (the crit fetch export at GET /api/export/:token/comments) omitted dom_anchor, so the CLI couldn't read anchors back. Now aligned with the live serializer Reviews.serialize_comment/1.
  • Persist legreviews.ex replace_comments/3 hand-built its attrs map without dom_anchor, so re-sharing/upserting a review stripped every anchor. Now 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.

Review

  • Code review: passed (fresh expert review; fix lines reverted to confirm tests are non-vacuous)
  • Parity audit: N/A (backend)

Test plan

🤖 Generated with Claude Code

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>
@codecov
Copy link
Copy Markdown

codecov Bot commented May 30, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.43%. Comparing base (21a90e5) to head (6c8e53d).

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              
Flag Coverage Δ
unit 82.43% <100.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@tomasz-tomczyk tomasz-tomczyk merged commit dd00aff into main May 30, 2026
4 checks passed
@tomasz-tomczyk tomasz-tomczyk deleted the audit/dom-anchor-roundtrip branch May 30, 2026 13:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant