Skip to content

Fixed transistor renderer preview behavior#26790

Merged
9larsons merged 3 commits intomainfrom
fix-transistor-card
Mar 11, 2026
Merged

Fixed transistor renderer preview behavior#26790
9larsons merged 3 commits intomainfrom
fix-transistor-card

Conversation

@9larsons
Copy link
Copy Markdown
Contributor

@9larsons 9larsons added the deploy-to-staging Optionally deploy PR to staging label Mar 11, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 11, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 8c9d845b-3bb1-47ac-b59f-c9bca1dfc6bf

📥 Commits

Reviewing files that changed from the base of the PR and between 2e9461b and f873419.

📒 Files selected for processing (1)
  • ghost/core/core/server/api/endpoints/utils/serializers/output/utils/post-gating.js

Walkthrough

Preview rendering now replaces Transistor iframe blocks with a static placeholder via an exported forPost in the post-gating serializer. The Transistor node renderer was refactored to emit an iframe with a data-src and a noscript fallback (instead of the previous static placeholder), optionally include a ctx (site UUID) query parameter in embed URLs, and append a runtime script that detects an ancestor background color and sets the iframe src with that color as a query parameter. Unit tests were updated to assert iframe/embed URL, noscript fallback, background-detection script, and ctx propagation.

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: fixing transistor renderer preview behavior, which aligns with the changeset modifications to preview mode handling in post-gating and transistor renderer.
Description check ✅ Passed The description references two related Linear issues (NY-1150 and NY-1151) that provide context for the changes, which is related to the changeset.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix-transistor-card

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
ghost/core/core/server/services/koenig/node-renderers/transistor-renderer.js (1)

16-22: Consider using CSS instead of deprecated frameborder attribute.

The frameborder attribute is deprecated in HTML5. While it still works for backwards compatibility, you could use CSS border: none on the iframe for a more standards-compliant approach.

♻️ Proposed refactor using inline style
 function setIframeAttributes(iframe) {
     iframe.setAttribute('width', '100%');
     iframe.setAttribute('height', '370');
-    iframe.setAttribute('frameborder', 'no');
     iframe.setAttribute('scrolling', 'no');
     iframe.setAttribute('seamless', '');
+    iframe.setAttribute('style', 'border: none;');
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@ghost/core/core/server/services/koenig/node-renderers/transistor-renderer.js`
around lines 16 - 22, In setIframeAttributes, stop using the deprecated
frameborder attribute and instead apply CSS to the iframe (e.g., set
style.border = 'none' or append to iframe.style.cssText) so the iframe has no
border; update the function (referencing setIframeAttributes and the iframe
parameter) to remove iframe.setAttribute('frameborder', 'no') and add the
equivalent style-based rule, and consider using CSS for scrolling behavior too
rather than the scrolling attribute.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In
`@ghost/core/core/server/services/koenig/node-renderers/transistor-renderer.js`:
- Around line 16-22: In setIframeAttributes, stop using the deprecated
frameborder attribute and instead apply CSS to the iframe (e.g., set
style.border = 'none' or append to iframe.style.cssText) so the iframe has no
border; update the function (referencing setIframeAttributes and the iframe
parameter) to remove iframe.setAttribute('frameborder', 'no') and add the
equivalent style-based rule, and consider using CSS for scrolling behavior too
rather than the scrolling attribute.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 39940f4c-cce4-46aa-a8cb-48c5e54f4eb2

📥 Commits

Reviewing files that changed from the base of the PR and between 257ee2b and b821d15.

📒 Files selected for processing (3)
  • ghost/core/core/server/api/endpoints/utils/serializers/output/utils/post-gating.js
  • ghost/core/core/server/services/koenig/node-renderers/transistor-renderer.js
  • ghost/core/test/unit/server/services/koenig/node-renderers/transistor-renderer.test.js

@Ghost-Slimer Ghost-Slimer temporarily deployed to pr-preview-26790 March 11, 2026 18:53 Destroyed
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@ghost/core/core/server/api/endpoints/utils/serializers/output/utils/post-gating.js`:
- Around line 121-126: The preview branch that replaces attrs.html when
frame.isPreview uses _buildTransistorPlaceholder() but does not refresh derived
fields, leaving attrs.plaintext and attrs.excerpt stale; after you replace
attrs.html, regenerate the derived text fields the same way other HTML-rewrite
branches do (i.e. invoke the module/helper used elsewhere to compute plaintext
and excerpt from the new attrs.html and assign the results back to
attrs.plaintext and attrs.excerpt) so preview responses return up-to-date
derived values.
- Around line 122-124: The current regex in the attrs.html replacement for
Transistor embeds is too strict about tag adjacency and should allow arbitrary
whitespace/newlines between </iframe>, <script> and <noscript> (e.g. use \s* or
[\s\S]*? between those serialized tags) so jsdom-serialized markup matches;
after performing the replacement (the call that assigns attrs.html =
attrs.html.replace(..., _buildTransistorPlaceholder())), call
_updateTextAttrs(attrs) just like the gated block at line 109 to refresh
attrs.plaintext and attrs.excerpt so derived text fields stay in sync with the
modified HTML.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 460be0c8-dd6b-4893-9e77-2aa764c22d3e

📥 Commits

Reviewing files that changed from the base of the PR and between b821d15 and 2e9461b.

📒 Files selected for processing (1)
  • ghost/core/core/server/api/endpoints/utils/serializers/output/utils/post-gating.js

@9larsons 9larsons enabled auto-merge (squash) March 11, 2026 19:15
@9larsons 9larsons merged commit 3c5cfbb into main Mar 11, 2026
30 checks passed
@9larsons 9larsons deleted the fix-transistor-card branch March 11, 2026 19:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

deploy-to-staging Optionally deploy PR to staging

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants