Repository navigation
fix(desktop): make the Windows shell load its own origin and hide the console - #5399
Conversation
… console Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
|
Important Review skippedBot user detected. To trigger a single review, invoke the ⚙️ Run configurationConfiguration used: Repository: lidge-jun/opencodex/.coderabbit.yaml Review profile: ASSERTIVE Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
✅ Deterministic PR hygiene checks passed. |
⏳ DRAFT
What to do
Review readiness checklist
0/4 boxes ticked. Automatic draft conversion failed. Please convert this pull request to a draft manually until every box above is ticked. |
… is gone Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
리뷰 · 우선순위 61 / 80이 PR은 Windows에서 데스크톱 셸이 자기 화면을 못 띄우던 문제를 고칩니다. Tauri는 macOS/Linux에서 앱 화면을 라인 - 라인 - 라인 - 메인테이너의 판단이 필요한 지점
너의 추천 머지 방향은 맞습니다. Windows 빈 웹뷰 원인( 이 댓글은 grok-bot이 작성했습니다 |
…uck Stop proxy Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
Addressed in 6d63412:
Kept |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
#5399 made the window load its own origin and hid the Windows console, and it landed on the three files this lane owns. The console attribute in main.rs and the Stop-settle intent in tray.rs carry through unchanged - the second is now the coordinator's job, which confirms the stop through the bundled CLI instead of polling /healthz and reports a stuck one rather than printing to a console that is no longer there. The app origin is one function now instead of the two the auto-merge left side by side. It keeps #5399's contract - the custom scheme everywhere, the http spelling WebView2 needs, https refused because that is not what the pinned Tauri serves the app over, and not gated on the platform - and adds this lane's tightening: no port, because a port means something else is answering rather than the app. #5399's test asserted through navigation_allowed, which now takes an AppHandle and cannot be built in a unit test, so its cases moved onto the helper directly and its loopback-endpoint case is covered by the source oracle.
#5399 made the window load its own origin and hid the Windows console, and it landed on the three files this lane owns. The console attribute in main.rs and the Stop-settle intent in tray.rs carry through unchanged - the second is now the coordinator's job, which confirms the stop through the bundled CLI instead of polling /healthz and reports a stuck one rather than printing to a console that is no longer there. The app origin is one function now instead of the two the auto-merge left side by side. It keeps #5399's contract - the custom scheme everywhere, the http spelling WebView2 needs, https refused because that is not what the pinned Tauri serves the app over, and not gated on the platform - and adds this lane's tightening: no port, because a port means something else is answering rather than the app. #5399's test asserted through navigation_allowed, which now takes an AppHandle and cannot be built in a unit test, so its cases moved onto the helper directly and its loopback-endpoint case is covered by the source oracle.
…be (#5384) * feat(desktop): one exit path, one startup surface and a real tray probe Closing the window, the platform quit gesture and the tray's Quit all used to mean the same thing. There was no ExitRequested handler, so the quit gesture reached RunEvent::Exit and called CommandChild::kill() on the runtime this app had started - a SIGKILL on Unix, cutting off the in-flight requests, the client-configuration restore and the state-file clearing that the CLI's stop performs, on a keystroke the user reads as "hide". exit.rs now holds the exit, drains what the app owns and only then lets the process end. An installed update asks for a coordinated restart down the same drain rather than restarting straight into the kill, and a runtime counts as stopped only when the child reports its own exit or the endpoint refuses a connection. macOS needed one thing more than the handler: Tauri's default menu carries a predefined Quit wired to Cocoa's terminate:, and the pinned tao implements no cancellable applicationShouldTerminate, so that Cmd+Q never raised the event at all. menu.rs rebuilds the default menu with an ordinary item on the same accelerator, keeping the clipboard items the failure diagnostic needs. Startup ran inside setup() before any window existed, and the spawn event stream was destructured into _events and dropped, so a sidecar that exited immediately looked exactly like a slow one. The window is created and shown first now, and startup.rs runs the whole sequence inside it - registering, resolving, probing, attaching or starting, waiting - under one 30-second deadline, with every probe bounded by the time left rather than by the HTTP client's own timeout. Registering comes first so a failed start still leaves a tray to reopen from. The failure state carries a retry, the child's exit code and a copyable diagnostic; a retry waits on a child that has not exited rather than racing it, and a spawn cannot interleave with a quit because both take the same lock. Tray availability is asked of the session bus: not whether the watcher exists, which proves nothing, but whether it reports a host registered. The pinned Linux backend creates an AppIndicator and reports success either way. Where there is no host, no icon is claimed, the window is shown whatever the launch origin, and closing it quits through the same drain. * test(desktop): pin exit ownership, the startup surface and tray availability These are wiring facts, not behaviour a hosted runner can observe: CI builds the shell against a zero-byte sidecar and has no graphical session to press Cmd+Q in, so the ordering and the branches are read out of the source the way the Start at Login default already is. The no-kill scan enumerates the shell's Rust files from disk rather than from a list, so a new module cannot opt itself out. Every assertion was driven red once against the shape it replaces: tray Quit calling app.exit, a kill in the shell, the predefined macOS Quit, any endpoint error read as a stopped runtime, a spawn that ignores an exit in flight, _events discarded, the window shown after the sequence, resolve back in setup(), a probe bounded only by the client timeout, a page failure that cannot report itself, the weaker watcher question, a Linux tray assumed before the probe, and a migration marker claimed before its rewrite succeeded. * docs(structure): record the desktop shell's exit, startup and tray contracts INV-DESKTOP-01 and INV-DESKTOP-02 bind the two rules that are easy to regress silently: what is allowed to end the app, and what counts as a tray. Both state the no-tray exception rather than claiming a uniform rule, and the shell document says plainly that an incomplete drain still exits and can leave the runtime standing. * fix(desktop): keep the macOS-only menu out of every other platform's build Hosted CI rejected the first head: the menu module compiled everywhere while its only caller was macOS-gated, so gesture, QUIT_ID and on_event were dead code on Linux and clippy -D warnings refused them. The module is now macOS-only, and the window's close handler routes through exit::gesture instead of repeating the decision, which gives that function a caller on every platform and leaves one place where a close and a quit gesture are decided. Four more things a review round found, none of them visible from behaviour: The tray verdict was published before the icon existed and was never downgraded when the build failed, so a close in that window hid into nothing. It is now published only after a successful install, and a failed install is a session with no tray. Registering ran again on every retry, which would have built a second tray icon with its own refresh loop and its own menu handlers - the app appearing to duplicate itself each time the user pressed Retry. It now happens once per process and a retry re-runs only the runtime half. The exit coordinator held its lock across process creation, which put spawning in front of the main thread's exit handler; a wedged spawn would have been a Quit that never answered. The spawn is reserved instead, and a quit arriving in between is deferred until the child is owned and then drains it. Every tray menu setter dispatches to the main thread and waits, and the tray is built on the main thread holding the menu mutex, so calling a setter under that lock is a cycle. The handles are copied out from under it first. Registration's session-bus probe and its main-thread callback are also bounded by the sequence deadline now, so neither can strand the page in a state whose retry could do nothing. * test(desktop): follow the shell contracts to where they now live The close handler, the spawn reservation, the tray verdict and the one-time registration all moved, so the oracles move with them. Two assertions were also too weak to bind what they claimed: the no-kill scan now walks the source tree instead of listing its top level, and the setup-does-nothing check is bounded to the setup closure rather than running to end of file. Each literal and each ordering these files assert was checked against the current source by reading it, not by running them. * docs(structure): state the tray verdict, registration and spawn rules exactly The contracts now say when the tray verdict is published rather than implying it is known up front, that registration happens once per process, that a quit during a spawn is deferred rather than refused, and why a menu setter is never called under the menu mutex. * test(desktop): follow claim_drain into the match that replaced its guard Hosted CI caught this one: the assertion still looked for the early-return guard that claim_drain used before it grew a Spawning arm, and the phrase it searched for had moved to begin_spawn - so a global search for the text found it while the scoped assertion did not. It now reads the Idle arm itself and pins the number of places that move the phase to draining. * feat(desktop): hold this installation's own id and read ownership by lane C's rule The shared service install state now records who owns the running proxy, and the claim names the owning installation rather than the user or the machine. So the app needs a value of its own to compare against: identity.rs mints one into the app's config directory, once and exclusively, so two launches racing each other answer to the same id rather than to two - and a second id would find a claim that is not its own and ask again for consent the user had already given. An id kept only in the shared record would be whoever wrote it last, which is why D3 accepted two records and the re-consent a lost app-local one forces. ownership.rs mirrors the claim, the three answers a read can give and the comparison, all of which src/service/state.ts defines. It does not read the record: resolving one means reading every state path and failing closed on an unreadable one, on a corrupt anchor and on paths that disagree, and a second weaker implementation of a question core already answers is the mistake that gave discovery.rs its own port guess. The types are the CLI's answer as it will arrive on the wire, field for field, so lane A's contract fills a hole instead of reshaping this file. Until it lands, resolve is unavailable - which is not "nobody owns it", because the question has not been put - so no takeover is attempted and nothing is recorded. The registering state and the failure diagnostic say which of the two it is. * test(desktop): read both halves of the ownership claim together The shell's half and src/service/state.ts's half are asserted in one file, so a change to the owner values, the wire field names, the three resolution kinds or the comparison rule breaks here rather than leaving the two to disagree somewhere only a real takeover would reveal. It also pins what the comparison does not look at: the generation moves on every grant, and comparing it would make a consent the app already holds look foreign. * docs(structure): record the app's half of the runtime-ownership claim Points at the contract lane C published rather than restating it, and says plainly that an unavailable answer is not an unowned runtime. * fix(desktop): drain before an update installs, and stop calling a failed drain a drain Removing the direct kill put the update on a coordinated path only if the coordination is reached. On Windows it was not: the pinned updater's install hands off to the installer process and ends this one with process::exit(0), so the restart asked for after download_and_install() never ran, and the package was replaced under a runtime still serving out of those files. The order is now download and signature-check, confirm who owns the running runtime, drain it and confirm the child is gone, and only then install. A drain that did not complete refuses the install and leaves the update pending rather than proceeding. A failed drain was also being recorded as a drain: the same completion path ran for both, so a stop that was refused or timed out still ended in the exiting or restarting branch. For a quit that is a defensible trade - refusing to close when the user asked is worse, and a standing runtime is recoverable. For a restart it is not the same judgement, because the new app comes back attached to the old runtime while the user believes they upgraded. DrainFailed and OwnershipUnknown are now states of their own, a quit proceeds from either, and a coordinated restart refuses both. The tray's Stop ran its own drain beside the coordinator, so Stop pressed twice, Stop then Quit, and Stop during an update were separate executions over one child. It takes the same phase now, and a quit that lands during a stop is deferred and run afterwards rather than dropped. * fix(desktop): confirm the instance before owning it or sending it a credential Ownership of the running process was a bool set when the child was spawned, and attaching to a different proxy left it set. A child that dies and an npm service that takes the port back gives the combination the audit named: the connection is somebody else's runtime and the flag still says ours, and Stop or Quit then sends an owner's stop to it. Durable consent and current process ownership are now separate facts. Consent stays in the recorded claim; ownership is re-established each time from the pid the endpoint reports, and an answer that cannot be read leaves the app owning nothing. The same unauthenticated health body settles who the management token may be sent to. It carries the marker, the pid and the port, so the client confirms the instance before the credential rather than sending it to whatever holds the port, and a request is bound to that pid, that port and the generation it was authorised under. The client also refuses redirects - the pinned reqwest does not treat this custom header as sensitive, so it would carry across a hop - and refuses system proxies. This is the local management client only; the updater's download client keeps its own policy. Two smaller ones in the same area. The Windows app origin is allowed: the pinned Tauri serves the app from tauri.localhost there because wry needs an http origin, and without it the window's first navigation to its own page went to the external browser. That exact host with no port, not localhost generally. And the budget for finding an existing runtime is counted from when probing starts rather than from process start, so a slow tray or session-bus registration cannot spend it and turn into "nothing is listening", which starts a second proxy beside the one already there. * test(desktop): pin the update order, the failure states and the instance check The order inside the update, which states a restart refuses, that Stop and Quit share one execution, that ownership comes from the answering pid, and that the credential follows the confirmation rather than the other way round. The Windows origin case asserts what is not allowed as well as what is, since the risk there is width rather than absence. * docs(structure): record the update order, the drain verdicts and the client policy Says which failure a quit tolerates and a restart refuses, why the install waits for a confirmed stop, and that the management client has a network policy of its own separate from the updater's download client. * fix(desktop): let a refused restart be tried again The new failure states were a dead end. A drain that did not complete left the coordinator in DrainFailed, and every later claim returned None - so the update stayed pending in the tray and pressing Install again did nothing, on the one machine where the user most needs to retry: the one whose runtime would not stop. A terminal failure is not work in flight, so claiming it again re-enters the drain. A successful drain still cannot be re-entered, and a quit that claimed the reason first still wins it, so the retry cannot turn a pending quit into a restart. * test(desktop): follow finish_drain into its verdict argument The call takes the verdict now, so the assertion that still looked for a bare finish_drain() was stale. Hosted CI caught it, which my own literal scan should have: the scan used a look-behind, rg's default engine rejects that, and a rejected pattern produces no output - so the loop ran zero times and reported clean on every file. It is fixed and now fails loudly if the extraction errors, and the corrected run over all five files found this one assertion and nothing else. * feat(desktop): resolve the runtime through the bundled CLI, and stop guessing D5. The shell used to answer this itself, in a file called discovery.rs that read runtime-port.json, fell back to 10100 and started there - so a user with a configured config.port was started on a port they had not chosen, and the tuned probe budgets that decision needs were sitting unused one layer down. It asks ocx resolve --json now and reads one ocx-resolve/1 document. Liveness keeps its three answers, and the third one is the point. live means attach as a guest; absent-proven means every recorded and configured endpoint was definitively dead, and only that authorises starting a runtime. Everything else is unknown - a non-zero exit, a timeout, output that will not parse, a schema this shell does not know, a missing binary - and unknown fails the state with a diagnostic and a retry. It is never read as absence, because that is the reading that puts a second proxy next to the one already running. Two things a live verdict does not settle on its own. Core's liveness predicate accepts a connected client's listener on purpose, so duplicate-start avoidance can see it, and a caller that needs the management plane has to discriminate on the role rather than narrow that predicate - this shell needs it, so a client listener is live and unusable rather than something to attach to. And a runtime bound somewhere 127.0.0.1 cannot reach is the same kind of answer. Neither is an absence, so neither authorises a start. The sequence also stops reporting Ready against an instance it could not identify. bind returns its answer now instead of swallowing it, and both call sites fail the state on None: the management token is only ever sent to a bound instance, so a dashboard there would not load anyway. * fix(desktop): stop the runtime with the bundled ocx stop, and read what it said D4. The shell was ending the runtime with a management call from inside the process it was ending. That cannot own its own teardown: launchd and systemd can terminate the request handler during self-unload, and the Windows respawn window can only be verified after the process exits. ocx stop --json runs the real teardown - the receipt, the drain, the respawn verification, the client-config restore - and the shell reads the ocx-stop/1 summary instead of inferring an outcome from an HTTP response. A stop counts only when five facts hold together. The process exited 0 and the document says so, through both ok and exitCode, so 1, 79 and 80 are refusals however the rest reads - taking the summary's word for its own exit status is taking a claim as its own evidence. runtimeDown has to be true, because a service that failed while the proxy happened to stop is exactly the case that may respawn it. And the document has to agree with itself: only a stopped outcome beside a stopped or orphaned proxy, or not-running beside not-running, is a runtime that is down. An outcome or proxy state this shell does not know fails to parse, which is the same answer as a stop that did not happen. * test(desktop): read both CLI contracts against the CLI that defines them The schema strings, the status and outcome vocabularies, the three-valued liveness rule and the stop's accept-set are asserted on both sides in one file, so a change to either is found here rather than on a user's machine. The liveness test pins what must never happen as firmly as what must: no path reaches a spawn without a proven absence, and a live listener this app cannot manage is neither attached to nor started beside. * docs(structure): record that the shell resolves and stops through the CLI What the three liveness answers mean, which one authorises a start, and why a stop is accepted only on exit 0 with the runtime reported down. * fix(desktop): follow the stop outcome into its own type One assertion still compared the summary's outcome to a string after it became a closed enum, and clippy --all-targets compiles the test target, so the Rust tests were skipped behind it rather than run. My static pass checked the code paths and the source oracles and did not re-read the crate's own unit tests after the type changed; the sweep now looks for any comparison of either typed field against a string literal, and finds none. * fix(desktop): merge the app-origin rule rather than pick a side of it #5399 made the window load its own origin and hid the Windows console, and it landed on the three files this lane owns. The console attribute in main.rs and the Stop-settle intent in tray.rs carry through unchanged - the second is now the coordinator's job, which confirms the stop through the bundled CLI instead of polling /healthz and reports a stuck one rather than printing to a console that is no longer there. The app origin is one function now instead of the two the auto-merge left side by side. It keeps #5399's contract - the custom scheme everywhere, the http spelling WebView2 needs, https refused because that is not what the pinned Tauri serves the app over, and not gated on the platform - and adds this lane's tightening: no port, because a port means something else is answering rather than the app. #5399's test asserted through navigation_allowed, which now takes an AppHandle and cannot be built in a unit test, so its cases moved onto the helper directly and its loopback-endpoint case is covered by the source oracle. * fix(desktop): give a foreign runtime its own widget state `ProxyError::Foreign` was added without updating the widget's match on it. `widget.rs` compiles only on macOS, so the Linux `desktop shell` job never sees it and the non-exhaustive match surfaced as a lone E0004 in `macos widget + bundle`, which then failed the aggregate `ci`. The new arm is explicit rather than a catch-all. A runtime this app did not start is a different event from a fault: folding it into `degraded` or `unreachable` would tell a user whose own npm or CLI runtime holds the port that something is broken. It gets its own `foreign` state, which the widget renders in the neutral secondary colour because `tone` does not know the string. Keeping the match exhaustive also means the next variant added to `ProxyError` is a compile error here again rather than a silent mislabel. * test(clients): follow the owner check into the install-state contract #5400 moved the runtime validation of an ownership claim out of `src/service/state.ts` into `src/service/install-state-contract.mjs`, and the receiver changed from `ownership` to `value`. The oracle asserted the old literal, so it went red on the merge with `dev` while both sides were green alone — each of the two reads its own half and neither compiles the other. The assertion now reads both halves of core's answer: the runtime rejection a record on disk actually meets, and the exported `ServiceOwner` type every caller is compiled against. Splitting them matters here, because a parse that accepted a third owner and a type that forbade it would disagree exactly where a takeover happens, which is the case this file exists to catch.
Summary
Found while running the dev-branch Tauri shell end-to-end on Windows Server 2022 (MSI install).
window::navigation_allowedonly admitted thetauri:scheme as the app's own origin. On Windows, Tauri servesfrontendDistashttp://tauri.localhost, so the very first navigation (index.html?port=…) fell into the "foreign http(s)" branch, got pushed to the default browser (an Edge error tab), and the webview stayed blank until the tray's Open Dashboard was used.is_app_origin()now accepts both forms; a unit test coverstauri://localhost,http://tauri.localhost, the proxy origin and a rejectedfile:URL.main.rsgets the standard#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")], so the release exe no longer opens a console window beside the tray app.stoppedfrom a singlestop()result or one immediateis_alive()probe. When the sidecar drops the connection while answeringstop,stop()errs and the probe still sees the dying server, so the child was never reaped and the menu item stayed enabled even though the proxy was gone. It now pollsis_alive()for up to ~2s before giving up.bun run build:localpicks the host platform's bundles (app,dmg/msi,nsis/appimage,deb) instead of always asking for macOS bundles, and prints every produced bundle. The release workflow (which already ships the Windows MSI) is untouched.Verification
cargo test --locked,cargo fmt --check,cargo clippy --locked --all-targets -- -D warningsindesktop/src-tauri(Windows, stable).bun run build:gui,bun run prepare-sidecar,bun run build:localon Windows →OpenCodex_2.61.0_x64_en-US.msiandOpenCodex_2.61.0_x64-setup.exe./healthz200 on 10100), tray menu, Open Dashboard / Open in Browser, Usage/Providers/Logs pages in the webview, close-to-tray, Start at Login toggle (HKCU Run key), single instance, Stop proxy, Quit (both processes exit), Check for Updates. Before the fix launch opened an Edge tab and left a black console window; after it the dashboard loads in the webview and no console appears.Note: Check for Updates currently reports a fetch failure because the configured
releases/latest/download/latest.jsonredirects tov2.60.0/latest.json, which 404s — no manifest has been published yet. Not addressed here.Checklist
Review readiness checklist
This PR stays in draft until every box below is ticked. Tick all four boxes once the requirements are met:
All CI tests are green on my local testing.
I pushed my PR to the latest dev commit.
I resolved all correct Codex and CodeRabbit findings.
My PR is ready for review.
Link to Devin session: https://app.devin.ai/sessions/4db70541242d43fbb1e7b443729655a7
Open in Devin Desktop: https://app.devin.ai/desktop/session/4db70541242d43fbb1e7b443729655a7?variant=devin
Requested by: @lidge-jun