feat(desktop): support opening transient external files via preview grants - #154
Open
krit22 wants to merge 9 commits into
Open
feat(desktop): support opening transient external files via preview grants#154krit22 wants to merge 9 commits into
krit22 wants to merge 9 commits into
Conversation
krit22
marked this pull request as ready for review
August 11, 2026 19:05
krit22
marked this pull request as draft
August 11, 2026 19:07
krit22
marked this pull request as ready for review
August 11, 2026 19:15
PPRAMANIK62
requested changes
Aug 11, 2026
PPRAMANIK62
left a comment
Collaborator
There was a problem hiding this comment.
Request changes required:
- External HTML/PDF/image/DOCX/audio viewers never receive or use
activeTab.file.grantId; they continue to load normal folder-scoped/assetURLs, so external previews fail without an active folder or can resolve the wrong same-named library file. Browser-loaded grant URLs must also include the target window identity, since they cannot send the window header. - Video extensions are accepted but the renderer has neither a
videoOpenFile.formatnor a video viewer, producing blank tabs. path.resolve()does not canonicalize a symlink; a granted symlink can later be repointed to a different file. Resolve/store the real path before granting and for containment checks.- The global pre-ready native-open queue can be drained by a different window from the most-recently-focused target; queue entries by target window.
- Unsupported multi-file drops emit one toast per file instead of the required bounded summary.
Please address these before merge.
…es, and revoke leaked grants
krit22
force-pushed
the
feat/152-transient-external-files
branch
from
August 16, 2026 09:31
5d1f80b to
b9ac612
Compare
Contributor
Author
|
Thanks for the review @PPRAMANIK62! All requested changes have been addressed and validated:
All pre-commit verification gates ( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves #152
Summary
This PR introduces support for opening transient, read-only external files (triggered via desktop file drop on the main content pane or native OS file-open events like Finder "Open With", CLI argv, or second-instance launches) using secure, window-scoped preview grants. External files are rendered in-place using existing document viewers without copying them to the library folder or triggering indexing pipelines.
What changed
Electron & IPC Bridge
activePreviewGrantsregistry on the main process to track allowed file paths per window ID.grant:register(reuses internal workspace tab if path resides in active folder, otherwise registers a UUIDgrantId) andgrant:revoke(removes grant).open-fileevents until the renderer fires a ready signal, then dispatches them to avoid race conditions. Routes second-instance requests to the last focused live window.Express Server Validators
/api/internal/grantsroutes to sync registered preview grants./api/grant/:grantId/textand/asset-preview-grant/:grantIdto validate that the request's window ID (currentWindowId()) matches the grant's registered window. Denial returns 403 Forbidden. Sibling directory traversal is blocked.Store State & Reducer
OpenFileto carry transient properties:isExternal,isReadOnly,grantId, andabsolutePath.FILE_OPENreducer to setoutOfFolder = truewhenisExternalis set, isolating external tabs from selection highlighting, search results, vector indexing, Quick Open, and recents logging.refreshActiveTabFromDiskto reload external tabs viagetExternalFileTextor HEAD requests. If the file is unmounted or deleted, the tab transitions to an unavailable warning state (⚠️ This external file is no longer available.) instead of duplicating.Split Drag Overlay & UI
useGlobalDragDrop.tsto identify cursor hover zones ('sidebar' | 'main') using the.sidebargroup class, setting pointerdropEffectto'copy'on the Files sidebar and'link'on the main pane.MotionDropVeilto draw two side-by-side drag regions ("Copy to library" vs "Open temporarily") with interactive borders and custom background highlights.Impact
Users can drop files onto the main editor area or open them via command line/double-click to preview documents instantly without cluttering their local database, uploading assets, or triggering vector embedding runs.
Validation
pnpm typecheck(SUCCESS)npx vite build --config web-src/vite.config.ts(SUCCESS)pnpm test:renderer(All 212 tests passed, including reducer test coverage for external file properties)pnpm test:library-files(All 7 tests passed, including the new/server/routes/internal-grants.test.tschecking grant boundary security limits)pnpm test:electron(All 15 tests passed)