Parent
Part of #478 — PWA first-class excellence/hardening.
Product opportunity
A capable Chromium-class PWA can interact with user-selected local files/directories through the File System Access API without installing a privileged native package. Combined with installed-PWA file handling where supported, this can make WorldScript behave much more like a desktop writing tool while preserving the browser sandbox and explicit user grants.
This is a PWA-first advantage: zero-install + user-granted native-like file workflows.
Current state
The current PWA is primarily browser-storage-backed. Repository search found no dedicated showOpenFilePicker / showSaveFilePicker / FileSystemFileHandle integration or dedicated file-handler issue.
The manifest already contains several advanced installed-PWA entries (launch_handler, handle_links, share target, protocol handler), so this should be designed as part of a coherent installed-app contract rather than as a one-off picker button.
Design principle
File System Access must be an optional adapter, not a replacement for IndexedDB/OPFS authority across all browsers.
Shared project import/export semantics
│
├── Browser baseline: upload/download
├── PWA enhanced: File System Access handles
└── Native Qt: native filesystem adapter
Do not leak browser file handles into shared domain models.
Candidate user workflows
1. Open project/package from disk
- user chooses a supported WorldScript project/export/package;
- validate MIME/extension only as hints — parse and schema-validate content independently;
- show import/open semantics explicitly;
- never execute embedded content;
- retain a handle only with clear user benefit and browser permission semantics.
2. Save / Save As to a user-selected file
Provide direct repeated saves after a user grant where supported, with safe fallback to download elsewhere.
Important distinction:
- browser storage may remain authoritative for live autosave;
- external file can be a user-controlled durable mirror/export;
- or a future mode may deliberately make a selected file authoritative, but only after a separate design decision and conflict model.
Do not accidentally create two silent authorities.
3. User-selected backup folder
Where directory access is supported, allow an opt-in backup target:
- timestamped/versioned backups;
- explicit retention policy;
- no background claim that writes will occur if browser permission/lifecycle does not permit it;
- visible last successful external backup time;
- failure does not corrupt browser authority.
4. Attach/import research assets
Use file handles/pickers for images, documents, references, screenplay assets, or other supported imports without requiring an intermediate browser download/upload dance.
5. Installed-PWA file handling
Evaluate manifest file_handlers for supported WorldScript project/export extensions so opening a project file from the OS can launch the installed PWA.
Use launchQueue/consumer semantics where supported and validate every incoming file exactly as an untrusted import.
Permission model
- request access only in direct response to user intent;
- do not ask for broad directory access at startup;
- explain read vs read/write access;
- detect revoked/expired permissions;
- re-prompt only when the user invokes a workflow that needs it;
- provide “Disconnect local file/folder” controls;
- never imply browser grants are equivalent to unrestricted native filesystem access.
Conflict model
If a retained file changes externally:
- detect using available metadata/content fingerprinting when reopening/saving;
- never overwrite an externally modified file silently;
- offer compare/reload/save-copy/reconcile choices;
- preserve current browser-backed project before destructive import/reload.
Do not build a fragile polling filesystem watcher if the browser cannot provide reliable semantics.
Security
Treat all selected/opened files as untrusted.
- strict schema validation;
- bounded decompression/import sizes;
- zip-slip/path traversal protection for archives;
- safe MIME sniffing/content handling;
- no HTML/script execution from imported files;
- sanitize filenames shown in UI;
- do not persist more path/handle metadata than needed;
- never expose local paths in telemetry/logs.
Coordinate security truth with #382/#478.
Cross-browser fallback
File System Access support is not uniform. Feature-detect rather than UA-sniff.
Fallbacks:
<input type=file> for open/import;
- Blob/download for save/export;
- browser storage for autosave;
- explicit capability UI rather than broken buttons.
The enhanced Chromium experience is allowed to exceed other browsers; basic writing/import/export must remain usable without it.
Tests
Cover:
- open valid/invalid project;
- permission granted/denied/revoked;
- save succeeds/fails/disk unavailable;
- external modification conflict;
- backup folder permission loss;
- malformed archive/oversized import;
- installed-PWA file launch;
- multiple files launched;
- fallback browser path;
- offline operation;
- encrypted project/export semantics where applicable.
Acceptance criteria
Non-goals
- unrestricted filesystem access;
- making File System Access mandatory for PWA use;
- pretending unsupported browsers provide identical behavior;
- replacing the future Qt filesystem authority with browser handles;
- background writes that browser lifecycle/permissions cannot honestly guarantee.
Parent
Part of #478 — PWA first-class excellence/hardening.
Product opportunity
A capable Chromium-class PWA can interact with user-selected local files/directories through the File System Access API without installing a privileged native package. Combined with installed-PWA file handling where supported, this can make WorldScript behave much more like a desktop writing tool while preserving the browser sandbox and explicit user grants.
This is a PWA-first advantage: zero-install + user-granted native-like file workflows.
Current state
The current PWA is primarily browser-storage-backed. Repository search found no dedicated
showOpenFilePicker/showSaveFilePicker/FileSystemFileHandleintegration or dedicated file-handler issue.The manifest already contains several advanced installed-PWA entries (
launch_handler,handle_links, share target, protocol handler), so this should be designed as part of a coherent installed-app contract rather than as a one-off picker button.Design principle
File System Access must be an optional adapter, not a replacement for IndexedDB/OPFS authority across all browsers.
Do not leak browser file handles into shared domain models.
Candidate user workflows
1. Open project/package from disk
2. Save / Save As to a user-selected file
Provide direct repeated saves after a user grant where supported, with safe fallback to download elsewhere.
Important distinction:
Do not accidentally create two silent authorities.
3. User-selected backup folder
Where directory access is supported, allow an opt-in backup target:
4. Attach/import research assets
Use file handles/pickers for images, documents, references, screenplay assets, or other supported imports without requiring an intermediate browser download/upload dance.
5. Installed-PWA file handling
Evaluate manifest
file_handlersfor supported WorldScript project/export extensions so opening a project file from the OS can launch the installed PWA.Use
launchQueue/consumer semantics where supported and validate every incoming file exactly as an untrusted import.Permission model
Conflict model
If a retained file changes externally:
Do not build a fragile polling filesystem watcher if the browser cannot provide reliable semantics.
Security
Treat all selected/opened files as untrusted.
Coordinate security truth with #382/#478.
Cross-browser fallback
File System Access support is not uniform. Feature-detect rather than UA-sniff.
Fallbacks:
<input type=file>for open/import;The enhanced Chromium experience is allowed to exceed other browsers; basic writing/import/export must remain usable without it.
Tests
Cover:
Acceptance criteria
Non-goals