Repository navigation
feat(open_url): url_schemes names an app's own schemes, so a flag's URL value isn't a link - #2182
Conversation
…RL value isn't a link On Windows and Linux every scheme:// launch argument was a link for App::on_open_url. An app with a flag that takes a URL (myapp --server http://localhost:4096) got the flag's value in the hook, and with single_instance a later launch with such a flag was not a launch without links, so it did not reopen the app. rune::url_schemes(['myapp']) names the schemes the app registered; from then on only arguments on them are links. Without the call nothing changes.
|
Run on Linux x64 after the merge (a headless Wayland compositor, an app build pinned to this change that calls |
…of --server is not one (#1195) * fix(deps): pin rune to d5c7a5ad (214 commits), the effect warm for backdrop blur only * fix(launch): only links on the app's own scheme are links; the value of --server is not one Rune took every scheme:// launch argument for a link. Started as 'app --server http://127.0.0.1:4096', the app got the server's URL in its link handler ('ignored a link it doesn't open'), and a second launch with that flag was handed over as a link, not as a launch that reopens the app. The app now names its scheme (rune::url_schemes, anomalyco/rune#2182, in the pin of #1192). * chore(pgo): the profiles re-keyed to Rune d5c7a5ad's symbol names A pin move renames every Rune symbol, so the committed profiles were dead for Rune's code on this branch's first commit. Both are re-keyed onto this tree's names, read from the instrumented build of #1193 (scripts/pgo-rekey.mjs). Windows x64: the counts trained on 25 Nov (launch weight 1): 17,961 of 18,439 functions keep their counts, 337 are dropped because their code changed, 141 no longer exist. Apple silicon: the committed profile, not trained anew: 15,030 of 15,445 kept, 285 dropped, 130 gone.
On Windows and Linux every
scheme://launch argument is a link forApp::on_open_url. That also takes a flag's value for one.What goes wrong
For an app started as
myapp --server http://localhost:4096:http://localhost:4096, which is not a link the system opened with the app.rune::single_instance, a later launch with that flag is not "a launch without links", so the running app is not reopened and its window does not come forward. (By readingrelaunched: links go to the hook, only a launch with none calls the reopen.)Change
rune::url_schemes(["myapp"])names the schemes the app registered for itself. From then on only launch arguments on one of them are links, at the first process's start and for every later launch handed to it. Schemes compare without case and match whole (myappdoes not matchmyapp-beta://).main, beforesingle_instance.scheme://argument is still a link.This is what an Electron shell does by hand when it filters
argvfor its own protocol.What it can change for an app
Nothing until the app calls it. After the call, links on schemes the app did not name no longer reach
App::on_open_urlfrom launch arguments.Tests
crates/rune/src/open_url/instance/tests.rs: what counts as a link; every link opens until schemes are named; a flag's URL value is not a link once they are; a launch with only such a flag has no links; whole, caseless scheme match; an app that names no scheme opens no link.Runs
Unit tests (the macOS test workflow, run by hand on this branch): the six new tests pass, and the whole
runelibrary is green (3,321 passed, 0 failed) in the run ona09e71352(this change withdevmerged in). The only failures in that run are threerune-kitintegration tests that aredev's own and fail the same way on a branch without this change:kit_metrics::controls_take_their_metrics_from_the_kitandkit_metrics::text_area_takes_its_type_and_padding_from_the_kit(a prefix lookup in the test, since fixed ondevby fix(rune-kit): require path separator boundary in kit_metrics descendant lookups #2220) anddiff_custom::file_header_replaces_built_in_header_in_list_and_sticky_overlay_and_toggles_collapse(a paint-keep self-check, being looked at separately). A later run on this branch with newerdevmerged in did not build:devitself does not compile from feat(selection): El::selection_enabled(bool), a subtree or window switch for selectable text #2206 on (theTextSpecsize assert; fix in fix(text): TextSpec is 224 bytes again, so rune compiles #2227), which this change does not touch.Compiled in an app: an app pinned to this change (its pinned Rune commit plus this one), calling
rune::url_schemeswith its scheme beforesingle_instance, builds on macOS, Windows x64 and arm64, and Linux x64.Run, Windows x64, that app's build against one without the change: a real window started as
app --server http://127.0.0.1:<port>, then a second launch with the same arguments, then a third with none. The app prints a line for each link it does not open.url_schemeson_open_url)Both later launches exit 0 in 10 to 33 ms on both builds.
Not run: Linux (compiled only); that the window comes forward on the second launch (read from
relaunched, where a launch without links is the one that reopens; not observed); a link on the app's own scheme through a real system open.