From cd702c0a91e650b3439da8162dfa449c5b7a02ad Mon Sep 17 00:00:00 2001 From: abose Date: Sat, 5 Sep 2026 21:07:57 +0530 Subject: [PATCH] docs(live-preview): notes for static file:// preview of non-project html Records a verified Electron prototype that previews html files outside the project as static file:// pages in a hardened with reload on save, instead of the "Preview Unavailable" page. Includes the security findings (Electron file:// pages can read local files unless the guest session filters requests), the rolled back Electron main-process code, the verification steps and the full patch for this repo. Adds JSDoc pointers to the notes at the relevant functions. No behaviour change. --- .../FILE_PROTOCOL_PREVIEW_NOTES.md | 577 ++++++++++++++++++ .../Phoenix-live-preview/NodeStaticServer.js | 11 +- .../Phoenix-live-preview/main.js | 14 + 3 files changed, 601 insertions(+), 1 deletion(-) create mode 100644 src/extensionsIntegrated/Phoenix-live-preview/FILE_PROTOCOL_PREVIEW_NOTES.md diff --git a/src/extensionsIntegrated/Phoenix-live-preview/FILE_PROTOCOL_PREVIEW_NOTES.md b/src/extensionsIntegrated/Phoenix-live-preview/FILE_PROTOCOL_PREVIEW_NOTES.md new file mode 100644 index 0000000000..5333796cc0 --- /dev/null +++ b/src/extensionsIntegrated/Phoenix-live-preview/FILE_PROTOCOL_PREVIEW_NOTES.md @@ -0,0 +1,577 @@ +# Static `file://` live preview for HTML files outside the project (not shipped yet) + +Status: **prototyped and verified on the Electron desktop shell on 2026-09-05, then rolled back**. Nothing +in this document is live in the product. Keep it until the feature is picked up again; the full working +patch for this repo is at the bottom, and the Electron main-process code is in the middle. + +## Problem + +Opening an HTML file that is not inside the current project shows the "Preview Unavailable!" page +(`Strings.DESCRIPTION_LIVEDEV_PREVIEW_RESTRICTED*`, built in `NodeStaticServer._getExternalPreviewURL`). +We deliberately refuse to serve such files over the live preview http server: a page served from a +non-project location could walk the disk with relative URLs (`../../.aws/credentials`), read the content +and post it to a remote server. Only project files are served, and only from the project root. + +The degraded but safe alternative is to show the file as a plain `file://` page (what a browser does when +you double-click an html file) that reloads on save. No live edit transport, no instrumentation, no popout +tab routing. This works only on the desktop app; the browser build has no local file access at all. + +## What we found (read this before re-implementing) + +1. **A plain ` + `; + ++ /** ++ * Electron desktop only: HTML files outside the project are previewed as plain `file://` pages inside a ++ * `` (Chromium refuses `file://` in an `