Skip to content

fix: preview update bug when tab and sidebar previews are both open - #2493

Open
prlygates1121 wants to merge 1 commit into
Myriad-Dreamin:mainfrom
prlygates1121:fix-preview-multi-webview-routing-alt
Open

fix: preview update bug when tab and sidebar previews are both open#2493
prlygates1121 wants to merge 1 commit into
Myriad-Dreamin:mainfrom
prlygates1121:fix-preview-multi-webview-routing-alt

Conversation

@prlygates1121

Copy link
Copy Markdown

Summary

Fixes a preview update bug where opening the Tinymist sidebar Content preview could stop an already-open tab preview from updating, and vice versa.

The preview backend creates one renderer per connected webview, but webview-originated render requests were previously sent through the shared broadcast channel. As a result, when one preview frontend connected and sent "current", every render actor handled that request, including renderers belonging to other preview views.

This PR routes webview-local render requests through a per-webview direct channel while keeping compile-driven render updates broadcast to all preview clients.

What Changed

  • Added a direct render mailbox to RenderActor.
  • Changed WebviewActor to send local render requests through mpsc instead of the shared broadcast channel.
  • Created a direct render channel per websocket connection in the preview data plane setup.
  • Kept compile updates on the existing broadcast path so all connected previews continue receiving document updates.
  • Fixed render batching so an incremental document update is applied before sending a full snapshot when both requests are received together.
  • Made the preview frontend tolerate an empty websocket URL, which is used by the sidebar Content preview before an active preview connection is available.

Why

Each webview has independent incremental renderer state. A "current" request from one webview should only affect that webview’s renderer. Broadcasting that request lets one preview view disturb another view’s renderer state, causing one of the previews to stop updating.

Manually Verified:

  • Open preview tab first, then sidebar Content preview; both update while editing.
  • Open sidebar Content preview first, then preview tab; both update while editing.

Fixes a preview update bug where opening the Tinymist sidebar Content preview could stop an already-open tab preview from updating, and vice versa.

The preview backend creates one renderer per connected webview, but webview-originated render requests were previously sent through the shared broadcast channel. As a result, when one preview frontend connected and sent `"current"`, every render actor handled that request, including renderers belonging to other preview views.

This PR routes webview-local render requests through a per-webview direct channel while keeping compile-driven render updates broadcast to all preview clients.
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