Repository navigation
Closing the desktop app's window keeps it running, as the Mac app does - #240
Merged
Merged
Conversation
Closing the window hides it while the core is open (the app hides on macOS, the window minimizes elsewhere); the tray's Open Hush, a notification, the Dock icon or a second launch bring it back. A second launch finds the running copy through a loopback port and token in the data folder, asks it to show its window, and ends; one that can't reach it says "Hush is already running." GPUI's own quit (the Dock's Quit, logging out) now writes the drafts and stops the core within the 200 ms GPUI gives it: the draft writer runs off the main thread, which that quit blocks. Windows and Linux quit only through the orderly quit, not as the window closes.
…s them at quit A launch refused the data (two at once) no longer takes the running file from the Hush that has it: listening starts once the core opened. Quitting removes the file, so later launches don't wait on a closed port. A draft write that fails while GPUI's quit blocks the main thread is logged where it fails. Comments corrected: Linux's logout, the system's close, quit modes.
A recording playing (or about to) stops and a view-once look ends when the window closes, as they go with the Mac app's window. A launch gives a refused loopback connection 250 ms, not the seconds Windows retries it.
Owner
Author
Review (pr-review-toolkit: code, silent failures, tests, comments)Nothing Critical. Fixes are in 1db548f and 902e52f. The branch is merged with the latest main, and the gate passes on that head (fmt, both clippy legs, Important: fixed
Declined
For the owner (not changed)
|
This was referenced Nov 28, 2026
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.
What changed
The desktop app now does what the Mac app does when its window closes (owner's call on #228: match the Mac).
running::show, which on macOS also unhides the app, since activating an app isn't documented to undo hiding it. With the tray hidden on Windows and Linux, launching again is the way back (the owner's accepted rule).runningin its data folder. It removes the file when it quits. A later launch reads the file, sends the token, and if the running Hush answers, it brings up that Hush's window and exits before opening a window of its own. The running Hush only answers its own token, so a port it left behind after a crash, later taken by another program or by another user's Hush, is never mistaken for it. A launch refused the data (two started at once) never takes the file from the Hush that has it. A refused connection gives up after 250 ms. A launch that can't reach the running Hush now says "Hush is already running." (the Mac app's words) instead of "couldn't open the data: the data is already open…".WM_ENDSESSIONon Windows) used to skip the orderly stop. It now runs the samestopas ⌘Q / Ctrl+Q and the tray's Quit: the drafts are written, then the core stops. GPUI waits only 200 ms for this, and it blocks the main thread while it waits. So the draft writer now runs on a background thread (a task on the main thread could never finish there). Its failures are logged where they happen and still reach the window.app::quit(QuitMode::Explicit). GPUI's default there quits as soon as the last window closes, which cut the orderly quit short.⌘Q / Ctrl+Q and the tray's Quit work as before.
What remains (as far as each OS allows)
.terminateLater, which GPUI doesn't offer.shortcut:Linux logout: GPUI catches no signal, so Hush is ended without running the stop (the last draft and a clean stop are lost there). To fix it: catch SIGTERM and callquit.runningfile and shows "Hush is already running." until the old core has stopped.shortcut:On Windows and Linux the window minimizes rather than hides, so the taskbar keeps its button. GPUI can't hide a window, and Wayland has no hidden windows. A tiling window manager that ignores minimizing leaves the window where it is. To hide it instead:ShowWindow(SW_HIDE)on Windows, unmapping on X11.How it was tested
New tests in
app/running.rs. Each of the first five failed with its behaviour taken out, then passed:a_later_launch_brings_up_the_running_hush: a launch reaches the listener and is answered, twice.a_launch_that_cant_reach_the_running_hush_says_it_runs: before, the message was "couldn't open the data: …".closing_the_window_keeps_hush_running_once_its_core_is_open(window test): without a core the window closes; with one it stays, its view-once look ends, andshowbrings it up (active).a_later_launch_brings_up_the_window_once_this_hush_has_the_data(window test): norunningfile until this Hush's core is open; then a launch brings the window up, twice.quitting_from_the_dock_or_at_logout_keeps_the_draft_and_stops_the_core(window test): after GPUI's own quit, the data opens again with the draft typed just before. Before, the core was still holding the data. Also checks therunningfile is gone after the quit.only_the_hush_that_wrote_the_folder_is_taken_for_running: a port taken by another Hush with another token, a dead port, or a garbled file all read as "not running".What the tests can't show: that
stopwaits for the drafts. The test context runs the draft write before the quit starts; drafts.rs's existing writer test covers the wait. Also: GPUI's test scheduler runs every task while it waits, so it can't reproduce the main thread being blocked during GPUI's quit. The background draft writer is based on reading GPUI'sPlatformScheduler::block, which polls only the quit future.Gate (from
core/):cargo fmt --check: passcargo clippy --all-targets -q -- -D warnings: passcargo clippy --all-targets --features hush-desktop/snapshot -q -- -D warnings: passcargo test --features hush-desktop/snapshot -q: pass (301 desktop, 537 core), run on the head merged with the latest mainSwift leg (xcodebuild) not run: nothing in
app/changed. Snapshots:--snapshotstill renders every demo screen. The change draws nothing new; the only new text is the failed-start screen's message, which has no demo screen. Not run on Windows or Linux: there's no machine for them here.Closes #228