Skip to content

fix(vscode): prevent preview sync feedback loop - #2680

Merged
antfu merged 2 commits into
slidevjs:mainfrom
fredcallaway:codex/fix-preview-sync-feedback-loop
Jul 31, 2026
Merged

antfu merged 2 commits into
slidevjs:mainfrom
fredcallaway:codex/fix-preview-sync-feedback-loop

Conversation

@fredcallaway

@fredcallaway fredcallaway commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Warning: this is mostly AI-generated (Codex 5.6 Sol Medium). Take or leave as you wish.

I was getting terrible oscillation jitter whenever I progressed through animations with cursor sync on. I confirmed the bad behavior in a fresh slidev project. With the fix, it has been working perfectly.

-- end human generated content --

Summary

  • watch the focused slide only while the preview is in slide mode
  • watch the editor viewport only while the preview is in overview mode
  • prevent preview navigation from being reversed by a stale editor viewport update

Problem

With preview sync enabled, Slidev: Navigate to next click in preview window can oscillate between adjacent slides when the click crosses a slide boundary. The preview moves to slide N+1 and starts focusing that slide in the editor, but the editor's visible range can update before the debounced focused slide does. Because the same watcher observes both values, it sends the stale slide N back to the preview, creating a feedback loop that also moves the cursor repeatedly.

The overview viewport is irrelevant in slide mode, and the focused cursor slide is irrelevant in overview mode. Selecting the watched value based on the active preview mode removes the cross-trigger while preserving both sync directions.

Reproduction

  1. Run Slidev 52.18.0 with the VS Code extension 52.18.0 and preview sync enabled.
  2. Put the preview on the final click of a slide.
  3. Run Slidev: Navigate to next click in preview window.
  4. The preview and editor cursor repeatedly jump between the current and next slides.

This also reproduces in a fresh project created with pnpm create slidev.

Validation

  • pnpm -C packages/vscode build
  • pnpm typecheck
  • pnpm exec eslint packages/vscode/src/views/previewWebview.ts
  • manually installed the rebuilt extension in Cursor and confirmed the reproduction no longer oscillates

@netlify

netlify Bot commented Jul 20, 2026

Copy link
Copy Markdown

Deploy Preview for slidev ready!

Name Link
🔨 Latest commit 2791400
🔍 Latest deploy log https://app.netlify.com/projects/slidev/deploys/6a604f467f64ee0008947161
😎 Deploy Preview https://deploy-preview-2680--slidev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@fredcallaway
fredcallaway marked this pull request as ready for review July 20, 2026 12:16
@pkg-pr-new

pkg-pr-new Bot commented Jul 22, 2026

Copy link
Copy Markdown

Open in StackBlitz

@slidev/client

npm i https://pkg.pr.new/@slidev/client@2680

create-slidev

npm i https://pkg.pr.new/create-slidev@2680

create-slidev-theme

npm i https://pkg.pr.new/create-slidev-theme@2680

@slidev/parser

npm i https://pkg.pr.new/@slidev/parser@2680

@slidev/cli

npm i https://pkg.pr.new/@slidev/cli@2680

@slidev/types

npm i https://pkg.pr.new/@slidev/types@2680

commit: 2791400

@antfu
antfu merged commit 94ea037 into slidevjs:main Jul 31, 2026
21 checks passed
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.

3 participants