Fix comments UI nullable reply HTML handling#28938
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughComment rendering now treats missing HTML as absent content: published and unpublished layouts only show Suggested reviewers: 🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Guard nullable comment HTML before rendering bodies or generating reply snippets, and only pass concrete open reply forms to ReplyFormBox.
a76d5e0 to
9ae40d9
Compare
|
Thanks @PedroMarianoAlmeida - I changed a few of the patterns and did a little bit of cleanup along the way, but the underlying changes were correct. |
|
| Command | Status | Duration | Result |
|---|---|---|---|
nx run-many --target=build --projects=tag:publi... |
✅ Succeeded | <1s | View ↗ |
nx run @tryghost/comments-ui:test:acceptance |
✅ Succeeded | 48s | View ↗ |
nx run-many -t test:unit -p @tryghost/comments-ui |
✅ Succeeded | 18s | View ↗ |
nx run @tryghost/admin:build |
✅ Succeeded | 5s | View ↗ |
nx run ghost:build:assets |
✅ Succeeded | 2s | View ↗ |
nx run-many -t lint -p @tryghost/comments-ui |
✅ Succeeded | 5s | View ↗ |
nx run ghost:build:tsc |
✅ Succeeded | 6s | View ↗ |
💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗
☁️ Nx Cloud last updated this comment at 2026-07-01 13:22:52 UTC

Why I am making it
This started as a comments-ui typecheck cleanup.
Comment.htmlis typed asstring | null, because deleted comment replies can be returned withhtml: nullwhen they need to stay visible as tombstones for visible descendant replies.Some reply paths still treated
comment.htmlas always being a string when rendering or building the “reply to” snippet. This makes those paths narrow nullable HTML explicitly and adds regression coverage for the deleted reply tombstone case.What it does
null.ReplyFormBoxwhen anopenFormexists.html: nulland a visible child reply.Type errors fixed
This removes the
apps/comments-ui/src/components/content/comment.tsxerrors caused by nullable comment HTML and optional reply form state:Argument of type 'Comment' is not assignable to parameter of type '{ html?: string | undefined; }'Type 'string | null' is not assignable to type 'string | undefined'Type 'OpenCommentForm | undefined' is not assignable to type 'OpenCommentForm'Type 'string | null' is not assignable to type 'string'Why developers need it
This cleans up the comments-ui typecheck path and protects the threaded comments UI from crashing or exposing actions for deleted reply tombstones when API data contains
html: null.Testing
rtk pnpm --filter @tryghost/comments-ui test:acceptance test/e2e/content.test.tsrtk pnpm --dir apps/comments-ui exec eslint --cache -- test/e2e/content.test.ts0with the existing warning that the test file is ignored because comments-ui lint config only targetssrc.Checklist