Skip to content

Remove image preview in favor of core image previewer - #341900

Merged
Logan Ramos (lramos15) merged 4 commits into
mainfrom
lramos15/agents/image-preview-context-menu-fix
Oct 20, 2026
Merged

Logan Ramos (lramos15) merged 4 commits into
mainfrom
lramos15/agents/image-preview-context-menu-fix

Conversation

@lramos15

@lramos15 Logan Ramos (lramos15) commented Oct 16, 2026 •

Copy link
Copy Markdown
Member

This helps reduce duplication across image carousel and the image preview extension

The built-in media-preview extension is removed. Its image, video and audio previews now live in core under src/vs/workbench/contrib/mediaPreview:

  • Shared ImageViewer: zoom, a context menu and Copy. Used by both the new core image editor and the image carousel, so the carousel now has a context menu.
  • Image editor: reloads on file changes, including changes reported by extension file systems. Supports view state, Save As, the Git LFS pointer message, and status bar zoom, dimensions and file size. The status bar also follows the focused side of media diffs.
  • Audio and video: rendered in a webview editor, because the workbench CSP doesn't allow blob: media sources.
  • Copy: PNG sources are copied as is. Other formats are encoded in a worker, with a main-thread fallback, which keeps the fix for the delayed copy from Fix image preview copy performance by using a worker for encoding #341783. Desktop writes through a new IClipboardService.writeImage, because the workbench window can't use clipboard-sanitized-write. Copy works with Cmd/Ctrl+C through the copy command and the browser's native copy event.
  • Compatibility: the editor IDs imagePreview.previewEditor, vscode.videoPreview and vscode.audioPreview are kept, and editors restored from the old custom editor are migrated.

How to test

  1. Open PNG, JPEG, SVG, video and audio files. Check zoom, the context menu, Copy (including Cmd/Ctrl+C) and the status bar.
  2. Compare two images and click each side. The status bar should follow the focused side.
  3. Open the image carousel in the Agents window. Check the context menu and Copy, and navigate quickly between images.
  4. Change an open image on disk. The preview should reload.

Validation

  • npm run typecheck-client: passed
  • npm run eslint -- <changed files>: passed
  • npm run valid-layers-check: passed
  • Hygiene pre-commit hook: passed
  • ./scripts/test.sh --reporter dot with the 5 mediaPreview test files and the 2 imageCarousel test files: 40 passing
  • Manual check in Code OSS: image/video/audio previews, Copy, and the image diff status bar

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Unresolved copying, refresh, navigation, and accessibility regressions prevent approval.

6 open findings
What changed in this PR

Moves image, audio, and video previews from the bundled extension into the workbench, sharing image rendering with the carousel.

Changes:

  • Adds core preview editors, commands, status information, and legacy-editor migration.
  • Shares image zooming and copying, with browser and native clipboard support.
  • Removes the extension and updates tests, build configuration, and localization.
File Description
src/​vs/​workbench/​workbench.common.main.ts Loads core media previews.
src/​vs/​workbench/​test/​electron-browser/​workbenchTestServices.ts Adds native clipboard stub.
src/​vs/​workbench/​test/​browser/​componentFixtures/​imageCarousel.fixture.ts Provides context-menu service.
src/​vs/​workbench/​services/​clipboard/​electron-browser/​clipboardService.ts Forwards image writes.
src/​vs/​workbench/​contrib/​mediaPreview/​test/​common/​mediaPreview.test.ts Tests LFS detection.
src/​vs/​workbench/​contrib/​mediaPreview/​test/​browser/​mediaPreviewErrors.test.ts Tests text-editor fallback.
src/​vs/​workbench/​contrib/​mediaPreview/​test/​browser/​mediaPreviewEditorInputs.test.ts Tests input behavior and saving.
src/​vs/​workbench/​contrib/​mediaPreview/​test/​browser/​imageViewer.test.ts Tests shared viewer behavior.
src/​vs/​workbench/​contrib/​mediaPreview/​test/​browser/​imagePreviewEditor.test.ts Tests asynchronous image reloads.
src/​vs/​workbench/​contrib/​mediaPreview/​common/​mediaPreview.ts Defines preview identifiers and helpers.
src/​vs/​workbench/​contrib/​mediaPreview/​browser/​mediaPreviewStatusBar.ts Displays preview metadata.
src/​vs/​workbench/​contrib/​mediaPreview/​browser/​mediaPreviewSaveAs.ts Implements media Save As.
src/​vs/​workbench/​contrib/​mediaPreview/​browser/​mediaPreviewErrors.ts Provides text-editor recovery.
src/​vs/​workbench/​contrib/​mediaPreview/​browser/​mediaPreviewActions.ts Registers preview actions.
src/​vs/​workbench/​contrib/​mediaPreview/​browser/​mediaPreview.contribution.ts Registers editors and migration.
src/​vs/​workbench/​contrib/​mediaPreview/​browser/​mediaPlayerEditorInput.ts Implements audio/video previews.
src/​vs/​workbench/​contrib/​mediaPreview/​browser/​media/​imageViewer.css Styles the shared viewer.
src/​vs/​workbench/​contrib/​mediaPreview/​browser/​media/​imagePreviewEditor.css Styles image previews.
src/​vs/​workbench/​contrib/​mediaPreview/​browser/​imageViewer.ts Shares rendering, zoom, and copying.
src/​vs/​workbench/​contrib/​mediaPreview/​browser/​imagePreviewEditorInput.ts Defines image editor inputs.
src/​vs/​workbench/​contrib/​mediaPreview/​browser/​imagePreviewEditor.ts Loads and watches image resources.
src/​vs/​workbench/​contrib/​imageCarousel/​browser/​media/​imageCarousel.css Uses shared viewer styling.
src/​vs/​workbench/​contrib/​imageCarousel/​browser/​imageCarouselEditor.ts Adopts the shared viewer.
src/​vs/​workbench/​contrib/​imageCarousel/​AGENTS.md Documents shared viewer behavior.
src/​vs/​sessions/​sessions.common.main.ts Enables previews in Agents Window.
src/​vs/​platform/​native/​electron-main/​nativeHostMainService.ts Writes native clipboard images.
src/​vs/​platform/​native/​common/​native.ts Extends native clipboard contract.
src/​vs/​platform/​clipboard/​test/​common/​testClipboardService.ts Records image writes in tests.
src/​vs/​platform/​clipboard/​common/​clipboardService.ts Adds image-writing API.
src/​vs/​platform/​clipboard/​browser/​clipboardService.ts Implements browser image writes.
src/​vs/​base/​common/​network.ts Adds Git URI scheme constant.
extensions/​vscode-api-tests/​src/​singlefolder-tests/​env.test.ts Replaces removed extension reference.
extensions/​media-preview/​tsconfig.json Removes extension compiler configuration.
extensions/​media-preview/​tsconfig.browser.json Removes browser compiler configuration.
extensions/​media-preview/​src/​videoPreview.ts Removes extension video provider.
extensions/​media-preview/​src/​util/​uuid.ts Removes duplicated UUID helper.
extensions/​media-preview/​src/​util/​dom.ts Removes extension HTML helper.
extensions/​media-preview/​src/​util/​dispose.ts Removes extension disposal helper.
extensions/​media-preview/​src/​ownedStatusBarEntry.ts Removes extension status ownership.
extensions/​media-preview/​src/​mediaPreview.ts Removes extension preview base.
extensions/​media-preview/​src/​imagePreview/​zoomStatusBarEntry.ts Removes extension zoom status.
extensions/​media-preview/​src/​imagePreview/​sizeStatusBarEntry.ts Removes extension dimension status.
extensions/​media-preview/​src/​imagePreview/​index.ts Removes extension image provider.
extensions/​media-preview/​src/​extension.ts Removes extension activation.
extensions/​media-preview/​src/​binarySizeStatusBarEntry.ts Removes extension file-size status.
extensions/​media-preview/​src/​audioPreview.ts Removes extension audio provider.
extensions/​media-preview/​README.md Removes extension documentation.
extensions/​media-preview/​package.nls.json Removes extension localization strings.
extensions/​media-preview/​package.json Removes extension manifest.
extensions/​media-preview/​package-lock.json Removes extension dependency lockfile.
extensions/​media-preview/​media/​videoPreview.js Removes video webview script.
extensions/​media-preview/​media/​videoPreview.css Removes video webview styles.
extensions/​media-preview/​media/​loading.svg Removes loading asset.
extensions/​media-preview/​media/​loading-hc.svg Removes high-contrast loading asset.
extensions/​media-preview/​media/​loading-dark.svg Removes dark loading asset.
extensions/​media-preview/​media/​imagePreview.js Removes image webview implementation.
extensions/​media-preview/​media/​imagePreview.css Removes image webview styles.
extensions/​media-preview/​media/​audioPreview.js Removes audio webview script.
extensions/​media-preview/​media/​audioPreview.css Removes audio webview styles.
extensions/​media-preview/​esbuild.mts Removes Node bundling configuration.
extensions/​media-preview/​esbuild.browser.mts Removes browser bundling configuration.
extensions/​media-preview/​.vscodeignore Removes packaging exclusions.
extensions/​media-preview/​.npmrc Removes extension npm configuration.
eslint.config.js Removes extension entries; corrects comment.
build/​npm/​dirs.ts Removes extension installation directory.
build/​lib/​i18n.resources.json Registers core preview localization.
build/​gulpfile.extensions.ts Removes extension compilation entry.
.eslint-allowed-javascript-files Removes deleted script exemptions.
Files not reviewed (1)
  • extensions/media-preview/package-lock.json: Generated file

🧠 Review effort: Balanced


💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@lramos15
Logan Ramos (lramos15) marked this pull request as draft October 16, 2026 00:19
Encode copied images in a worker and pass PNG sources through as is, handle the browser's native copy event, discard stale carousel image loads, refresh previews on uncorrelated file changes from extension file systems, keep the keyboard focus ring, and show status bar info for the focused side of media diffs.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@vs-code-engineering

Copy link
Copy Markdown
Contributor

📬 CODENOTIFY

The following users are being notified based on files changed in this PR:

Benjamin Christopher Simmonds (@benibenj)

Matched files:

  • src/vs/workbench/browser/parts/editor/sideBySideEditor.ts

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Open the image context menu from the keyboard on the viewer's focus target, copy the image that is displayed rather than re-reading the file, show Git LFS and load errors within the preview so the other side of a diff stays visible, and make the zoom actions and status bar follow the focused side of image diffs. Tests now await signals or use faked timers instead of polling.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.

7 participants