Skip to content

fix(web): render srcdoc preview without requiring Edit (#2791)#3042

Open
leno23 wants to merge 1 commit into
nexu-io:mainfrom
leno23:fix/2791-srcdoc-preview-blank
Open

fix(web): render srcdoc preview without requiring Edit (#2791)#3042
leno23 wants to merge 1 commit into
nexu-io:mainfrom
leno23:fix/2791-srcdoc-preview-blank

Conversation

@leno23
Copy link
Copy Markdown

@leno23 leno23 commented May 26, 2026

/claim #2791

Summary

Artifacts that route through the srcdoc transport (external <script src>, sandbox shim, Draw/Tweaks, etc.) could stay blank because the visible iframe remained on the lazy activation shell after URL-load preview switched off. Clicking Edit forced a full srcdoc reload, which is why the page appeared only after toolbar interaction.

  • Use lazy srcdoc transport only while URL-load is the active preview transport.
  • When srcdoc becomes active, mount the real artifact HTML directly in the iframe srcDoc attribute.
  • Remount the srcdoc iframe when leaving URL-load so a stale empty shell cannot remain visible.

Related: #2253 (activation race), #2361 (sandbox/localStorage blank preview).

Surface area

  • apps/web/src/components/FileViewer.tsx
  • apps/web/tests/components/FileViewer.test.tsx

Validation

  • cd apps/web && pnpm test tests/components/FileViewer.test.tsx

Made with Cursor

Lazy srcdoc transport was still active after URL-load preview switched off,
leaving the visible iframe on an empty activation shell until Edit forced a
full srcdoc reload. Mount real artifact HTML whenever srcdoc is the active
transport and remount when leaving URL-load.

Fixes nexu-io#2791
@lefarcen lefarcen requested a review from mrcfps May 26, 2026 16:28
@lefarcen lefarcen added size/S PR changes 20-100 lines risk/medium Medium risk: regular code changes type/bugfix Bug fix labels May 26, 2026
Copy link
Copy Markdown
Contributor

@lefarcen lefarcen left a comment

Choose a reason for hiding this comment

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

Hi @leno23! Thanks for spelling out the blank-preview path and tying it back to #2791 — the Summary and Validation are clear. One template bit before pool review: could you add the current PR template's Surface area checklist and tick the applicable box(es) for this preview rendering change? The file list is useful, but the checklist helps reviewers and release notes quickly see whether this affects UI/default behavior.

Related: #2791 is the reporter scenario this targets; #2704 and #2361/#2805 are nearby blank-preview context for reviewers to keep in mind.

@github-actions
Copy link
Copy Markdown
Contributor

Visual regression review

Head: 3428aa6 · Base: 1d72914

0 changed · 17 unchanged · 0 missing baseline · 0 failed

Unchanged cases
Case Main PR Diff
visual-avatar-menu main pr diff
visual-design-systems main pr diff
visual-home main pr diff
visual-home-catalog main pr diff
visual-home-context-picker main pr diff
visual-home-plugin-filter main pr diff
visual-integrations main pr diff
visual-integrations-use-everywhere main pr diff
visual-new-project-modal main pr diff
visual-plugin-details main pr diff
visual-plugins main pr diff
visual-projects main pr diff
visual-projects-kanban main pr diff
visual-settings-byok main pr diff
visual-settings-execution main pr diff
visual-tasks main pr diff
visual-topbar-execution-switcher main pr diff

Visual diff is advisory only and does not block merging.

Copy link
Copy Markdown
Contributor

@mrcfps mrcfps left a comment

Choose a reason for hiding this comment

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

@leno23 I walked through the FileViewer transport switch and the new regression coverage for sandbox-shim and Draw/srcdoc activation paths. The updated remount logic keeps the active iframe on the real srcdoc markup when URL-load turns off, which matches the bug report and closes the stale lazy-shell path. Thanks for tightening up this preview edge case. 🙌

🔁 Powered by Looper · runner=reviewer · agent=opencode · An autonomous AI dev team for your GitHub repos.

@lefarcen
Copy link
Copy Markdown
Contributor

Pool review and CI are green now — flagged this for the maintainers. Thanks @leno23 for the focused fix and @mrcfps for the review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk/medium Medium risk: regular code changes size/S PR changes 20-100 lines type/bugfix Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants