feat(csm-portal-microapp): resolve inline .iix images in comments and update descriptions - #1374
Conversation
Comment/description HTML embeds inline images as auth-gated .iix
sysid references (ServiceNow convention) rather than directly
loadable URLs. Nothing resolved these before, so inline images never
rendered in either surface — CommentBody.tsx (case comments/activity
feed) and UpdatesPage.tsx (update descriptions/security advisory
overviews) both just dumped the raw sanitized HTML via
dangerouslySetInnerHTML.
The webapp already solved this exact problem for the same csm-portal
backend (features/csm-cases/utils/inlineImages.ts +
api/useResolvedInlineImageHtml.ts): extract each .iix reference's
32-char sysid, convert it to the canonical UUID shape the
/attachments/{id}/content endpoint expects, fetch it as an
authenticated Blob, verify it's actually a safe image subtype, and
splice the resulting data: URL back into the HTML string via regex
replacement (rather than post-render DOM mutation, which doesn't
interact cleanly with dangerouslySetInnerHTML's own reconciliation).
Ported that implementation here nearly verbatim
(utils/inlineImages.ts, utils/useResolvedInlineImageHtml.ts), adapted
to the microapp's axios-based Blob fetch instead of the webapp's
api.getBlob.
|
Warning Review limit reached
Next review available in: 48 minutes You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughComment and update HTML rendering now resolves authenticated inline ChangesInline image rendering
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant CommentBody
participant useResolvedInlineImageHtml
participant attachments
CommentBody->>useResolvedInlineImageHtml: sanitized HTML
useResolvedInlineImageHtml->>attachments: getContentById(UUID)
attachments-->>useResolvedInlineImageHtml: image Blob
useResolvedInlineImageHtml-->>CommentBody: resolved HTML
CommentBody->>CommentBody: render resolved HTML
Possibly related PRs
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@apps/csm-portal/microapp/src/components/case-detail/CommentBody.tsx`:
- Around line 57-62: Update HTML detection to recognize img elements in both
apps/csm-portal/microapp/src/components/case-detail/CommentBody.tsx#L57-L62 and
apps/csm-portal/microapp/src/pages/UpdatesPage.tsx#L60-L65 by adding img to each
HTML_FORMAT_RE expression. Preserve the existing sanitization and
useResolvedInlineImageHtml flow so standalone .iix image markup is resolved and
rendered as HTML rather than text.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 0c7f915a-7ae8-4239-b2f2-2c4173797803
📒 Files selected for processing (5)
apps/csm-portal/microapp/src/components/case-detail/CommentBody.tsxapps/csm-portal/microapp/src/pages/UpdatesPage.tsxapps/csm-portal/microapp/src/services/attachments.tsapps/csm-portal/microapp/src/utils/inlineImages.tsapps/csm-portal/microapp/src/utils/useResolvedInlineImageHtml.ts
HTML_FORMAT_RE didn't include img, so content that's only a bare <img> tag with no wrapping p/div/etc (a plausible standalone inline image) fell through to the plain-text branch — never sanitized, never run through useResolvedInlineImageHtml, rendered as literal tag text instead of an image.
Summary
.iixsysid references (ServiceNow convention), not directly loadable URLs. Nothing resolved these, so inline images silently never rendered inCommentBody.tsx(case comments/activity feed) orUpdatesPage.tsx(update descriptions, security advisory overviews) — both just dumped the raw sanitized HTML viadangerouslySetInnerHTML.features/csm-cases/utils/inlineImages.ts+api/useResolvedInlineImageHtml.ts): extract each.iixreference's 32-char sysid, convert it to the canonical UUID shape/attachments/{id}/contentexpects, fetch it as an authenticated Blob, verify it's actually a safe image subtype, and splice the resultingdata:URL back into the HTML string via regex replacement — rather than post-render DOM mutation, which doesn't interact cleanly withdangerouslySetInnerHTML's own reconciliation.utils/inlineImages.ts,utils/useResolvedInlineImageHtml.ts), adapted to the microapp's axios-based Blob fetch (newattachments.getContentById) instead of the webapp'sapi.getBlob.Test plan
npx tsc --noEmitnpx eslint .npm run buildSummary by CodeRabbit
New Features
Bug Fixes