Commit 411f348
fix(desktop): Windows applied the first-launch deep link twice, and the first one was too early to work (GDK-293) (#34)
`desktop/main.go` applied argv whenever `runtime.GOOS != "darwin"`. The
comment right above it explained the hazard correctly — apply argv on a
platform that also emits the event and you navigate twice — and then put
Windows on the wrong side of it. The pinned wails
(v3.0.0-beta.6) emits ApplicationLaunchedWithUrl on Windows when
`len(os.Args) == 2` and the argument contains "://", which is exactly the
shape the CLI's own launcher produces.
Confirmed on real hardware before this change: Windows 11 Home, WebView2
151.0.4129.86, a probe build logging both paths.
PROBE293 event-path applying deep link "gadak://view?issue=NMB-1"
deep link →/#/?issue=NMB-1
[WebView2] Environment created successfully
wails runtime ready
PROBE293 argv-path applying deep link "gadak://view?issue=NMB-1"
deep link →/#/?issue=NMB-1
The ordering in that log is why "pick one of the two" would have been the
wrong fix: the event path runs *before* the webview environment exists, so
the first application was already a no-op and the one that reached the
screen was the second. Picking the event without an ordering contract would
have picked the dead one.
So there are two changes, not one. `coldStartDecisionFor(goos, args)` is
now the single owner of where a cold-start URL comes from, and exactly one
source is armed per platform and argv shape — darwin defers to the event,
Linux always reads argv because GTK4 never emits it, and Windows defers
only when wails will actually emit, falling back to argv for every other
argv shape. There is no `!= darwin` left; that negation was the bug,
because it lumped two platforms with opposite behaviour into one branch.
And `coldStartGate` holds anything offered before WindowRuntimeReady in a
one-slot queue and flushes it there, so nothing is handed to a webview that
does not exist yet.
Double application is now structurally impossible rather than avoided by
care: `ApplyArgv` and `DeferToEvent` are mutually exclusive, and the event
handler returns early unless it is the armed source.
`OnSecondInstanceLaunch` is untouched — that path was always correct — and
the macOS reopen case still works, because the event arrives after ready and
the gate applies it immediately.
Two comments corrected. The one on ApplicationShouldHandleReopen used to
analogise it to ApplicationLaunchedWithUrl ("never fires off darwin — same
as"), which is the same false premise; it now says the opposite explicitly.
FAIL-first, reproduced by the lead by restoring the `!= darwin` rule under
the new table: the Windows launcher row comes back as
`{ApplyArgv:true DeferToEvent:true}` — both sources armed — against a want
of `{ApplyArgv:false DeferToEvent:true}`, plus two more Windows rows. The
test pins the decision, not the rendering; no runtime event ordering is
asserted, because three rounds have just been spent on timing-sensitive
tests.
Debuggability: the probe build is no longer needed to answer "which source
supplied this URL" — `deep link source=argv|event` is logged beside the
existing `deep link →` line.
Gates, lead-run in desktop/: build, vet, `go test ./... -count=1` ok
(4.6s). Cross-compile windows/amd64 and darwin/arm64 both build.
linux/amd64 with CGO_ENABLED=0 fails on wails' own menu_linux.go, which is
the pre-existing reason ci.yml documents, not this change.
Co-authored-by: midagedev <midagedev@users.noreply.github.com>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>1 parent 43c2f34 commit 411f348
2 files changed
Lines changed: 240 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
| |||
61 | 62 | | |
62 | 63 | | |
63 | 64 | | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
64 | 150 | | |
65 | 151 | | |
66 | 152 | | |
| |||
225 | 311 | | |
226 | 312 | | |
227 | 313 | | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
228 | 324 | | |
229 | 325 | | |
230 | 326 | | |
231 | | - | |
232 | | - | |
233 | | - | |
234 | | - | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
235 | 338 | | |
236 | | - | |
| 339 | + | |
237 | 340 | | |
238 | 341 | | |
239 | 342 | | |
| |||
242 | 345 | | |
243 | 346 | | |
244 | 347 | | |
245 | | - | |
246 | | - | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
247 | 353 | | |
248 | 354 | | |
249 | | - | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
250 | 359 | | |
251 | 360 | | |
252 | 361 | | |
253 | 362 | | |
254 | | - | |
255 | | - | |
| 363 | + | |
| 364 | + | |
256 | 365 | | |
257 | 366 | | |
258 | 367 | | |
| |||
0 commit comments