Repository navigation
foolscap:// links open a document from other apps and web pages - #46
Merged
Merged
Conversation
seamoss
added a commit
that referenced
this pull request
Sep 29, 2026
⌥⌘C puts the rendered document on the clipboard with its styles inlined and the markdown as the plain-text flavor — a rewrite of the one pipeline's output, never a second parser; each tab now remembers whether it was in preview or the editor, with no source flash on the way in; and foolscap://open?path=… lets other apps open a document, guarded to absolute paths of existing markdown files, with a cold-launch fix so a linked file stays the active tab after the session restores (#44–#46, Brandon Dohman @productengineered).
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.
Other apps and web pages can now open a document in Foolscap with a link:
What it does
protocolsin electron-builder.yml putsCFBundleURLTypesin Info.plist, and the main process callsapp.setAsDefaultProtocolClient('foolscap')(in dev, withprocess.execPathand the app path, for Windows/Linux).open-url, registered at the top level because a cold launch fires it beforeready. Links queue until the app is ready. Windows/Linux get the link in argv, both on first launch and relayed throughsecond-instance.pathsFromArgvnow skipsfoolscap:arguments so a link is never mistaken for a file to create.openFileFromOutside, the same path as a Finder double-click: same batching, same choice of window, and a file that's already open gets its tab brought forward instead of a duplicate. On a cold launch it joins the launch arguments, so the session still restores.src/main/open-link.ts(pure, tested) accepts only hostopen, reads only thepathparameter (anything else is ignored), and requires an absolute path to an existing.md,.markdown, or.txtfile. Anything else opens nothing and shows a one-line toast, through a small newapp:noticechannel (WindowSession.notify).A fix it turned up
On a cold launch that restores a session, a file arriving at launch (a link or a Finder open) could open as a background tab.
restore()ran its tabs oneawaitat a time and then activated its saved tab after the incoming file had already become active. Restore now queues on the sameopeningchain as opens, so the incoming file lands after the restored tabs and stays active. The untitled-tab fallback indid-finish-loadskips windows with a queued restore, so it doesn't leave a stray Untitled tab.Testing
pnpm typecheckandpnpm testpass. New tests:open-link.test.tscovers spaces and unicode, extra parameters, dot segments, missing files, wrong types, relative paths, other hosts and schemes, and garbage input;cli.test.tschecks that argv links are skipped.open "foolscap://open?path=…":.pngeach show the toast and open nothing.Notes: on macOS,
setAsDefaultProtocolClientignores its path and arguments, sopnpm devregisters Electron.app itself. Whichever Foolscap launched last owns the scheme. In the Mac App Store edition, the sandbox will only allow paths the app already has access to.