Auto-reload Integrated Browser when previewed local file changes - #324618
Conversation
Adds a BrowserEditorContribution that watches the currently-displayed file:// URL via a correlated file watcher and reloads the browser on change, so editing a local file opened with "Open in Integrated Browser" refreshes the preview without a manual reload. Gated by the new workbench.browser.autoReloadOnFileChange setting (on by default).
📬 CODENOTIFYThe following users are being notified based on files changed in this PR: Kyle Cutler (@kycutler)Matched files:
Joaquín Ruales (@jruales)Matched files:
|
There was a problem hiding this comment.
Pull request overview
This PR implements auto-reload for the Integrated Browser (VS Code's browserView — a native Chromium WebContentsView presented as an editor tab). It adds a new BrowserEditorContribution that, whenever the displayed page is a file:// URL, starts a correlated non-recursive file watcher on that file and reloads the browser (debounced by 300ms) when the file is updated or re-added on disk. This addresses issue #324391, removing the need to manually reload local HTML previews after edits. The behavior is gated by a new default-on setting workbench.browser.autoReloadOnFileChange.
The implementation follows the established local contribution model: it hooks the model lifecycle via onModelAttached, scopes the watcher to the attached model (re-setting up on navigation and configuration changes), and cleans up through DisposableStore/MutableDisposable — consistent with sibling features like the zoom and emulation contributions.
Changes:
- New
BrowserEditorAutoReloadContributionthat watches the currentfile://URL and reloads the browser on change, gated behind a new setting. - Registers the
workbench.browser.autoReloadOnFileChangeboolean configuration (defaulttrue). - Wires the new feature into the desktop browserView contribution entry point.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/vs/workbench/contrib/browserView/electron-browser/features/browserAutoReloadFeatures.ts |
New contribution + setting: watches the displayed local file and reloads the browser on change. |
src/vs/workbench/contrib/browserView/electron-browser/browserView.contribution.ts |
Side-effect import to register the new auto-reload feature. |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Kyle Cutler (kycutler)
left a comment
There was a problem hiding this comment.
The changes look good 🙂 thank you for the PR Karthikeyan M (@karthikkatu)!
ISSUE #324391 : Integrated browser: auto-reload HTML files on change
Adds a BrowserEditorContribution that watches the currently-displayed file:// URL via a correlated file watcher and reloads the browser on change, so editing an local file opened with "Open in Integrated Browser" refreshes the preview without a manual reload. Gated by the new workbench.browser.autoReloadOnFileChange setting (on by default).