Skip to content

fix(desktop): keep Rust preview available after window close on macOS, Windows and Linux #6668

Closed

Description

@me2seeks

What happened

Rust preview exits the Desktop application when its main window closes. Windows consequently has no tray entry for reopening or explicitly quitting the application. Source inspection shows the corresponding lifecycle gap in the macOS AppKit and Linux GPUI backends; those platforms require native validation.

The requested model follows the TypeScript desktop on main: retain the Desktop main process, not a new Host residency mechanism. The Host remains an independent execution owner.

How to reproduce

  1. Start Rust preview Desktop on Windows.
  2. Close its main window.
  3. Observe that the Desktop process exits, with no tray entry to open Maka or explicitly quit.
  4. Compare with main: Windows retains the Electron main process, tray and Runtime Host manager. Tray Open focuses or recreates the window; explicit application Quit performs cleanup.

Expected behavior and implementation plan

  • Keep the Desktop main process and its existing admitted Host connection alive after window close. This is the real application client, not a dummy keepalive connection.
  • Release the closed window's UI engine, renderer, subscriptions and window-scoped resources. Do not merely hide a fully live Workbench. Recreate UI from the retained connection and persisted state on Open.
  • Provide Open Maka and Quit in Windows/Linux trays and a macOS menu-bar entry. Preserve Dock reopen and native application Quit. Opening an already visible window focuses it instead of duplicating it.
  • Only explicit application Quit performs the existing bounded Desktop-client detach and exits the Desktop main process. Do not change Host idle retirement, introduce Host desktop residency, or make Host own the tray. Do not terminate shared Hosts or cancel their accepted work.
  • Avoid inaccessible background applications if tray setup fails. Where no native reopen entry exists, fall back to close-and-exit; handle tray-host restarts/loss and report failures.
  • Keep optional macOS GPUI behavior coherent with the default backend.

Implementation boundaries:

  1. Desktop shell owns the retained connection, tray/menu actions, application exit and UI creation/release.
  2. Native backends expose minimal window/application lifecycle facilities without changing defaults for unrelated NSH consumers.
  3. Restore existing persisted conversation/window state; do not promise unpersisted in-memory UI state.
  4. Verify real close/reopen, resource release, repeated cycles, focus without duplicate windows, hidden/visible Quit, tray-unavailable recovery and continued Host work/other clients. Keep tests behavioral.
  5. Update shared CI routing/consumer inputs if native backends, embedded assets or test suites change.

Environment

  • Rust preview base: 72162299fab4008435dbf4b063440443b864afe0
  • TypeScript reference: local main at 5d3a0629a
  • Reported OS: Windows, exact version not supplied
  • Targets: macOS/AppKit, Windows/Direct2D, Linux/GPUI

Logs, screenshots, or additional context

Relevant entrypoints: products/maka/desktop-shell/src/{appkit,direct2d,window,host}.rs, NSH native application hooks under third-party/nsh/crates/, and main's apps/desktop/src/main/{windows-app-tray,runtime-host-boot,app-quit-coordinator}.ts.

This user-confirmed plan supersedes suggestions to move the tray into Host or add Host desktop residency. Linux tray support is new capability; the TypeScript version does not already implement Linux trays.

Human owner: @me2seeks. Issue/plan drafted and implementation assisted by Maka (AI agent).

Activity

  1. added
    bug
    on Nov 6, 2026
  2. me2seeks commented on Nov 6, 2026

    @me2seeks
    ContributorAuthor

    take

  3. self-assigned this
    on Nov 6, 2026
  4. me2seeks commented on Nov 6, 2026

    @me2seeks
    ContributorAuthor

    Implementation progress (Maka-assisted; local branch fix/6668-desktop-tray, current code commit bc93674ab):

    • Keep the Desktop process and its real, already-admitted Host client when closing a window; release the window/UI engine and recreate UI on Open. Explicit Quit performs the bounded client detach. Host lifecycle policy is unchanged.
    • Preserve presentation state through the existing per-plugin reload snapshots, with attempt IDs and window-identity checks to reject stale close replies.
    • Fall back to close-and-exit without a usable tray. Recover an operable window when the Linux watcher disappears while hidden, and resume resident behavior after re-registration.

    Validation completed locally:

    • Windows: four desktop product tests; real Win32 resident close/reopen/hidden-Quit/resource-release test; strict Clippy. The resident regression was verified to fail with the previous last-window-exits behavior and pass with the fix.
    • Ubuntu Desktop/GNOME/XWayland: full product build and ten desktop tests; real native painted-window close/reopen over three cycles, UI engine thread retirement on each close, unchanged Desktop/Host processes, no duplicate windows, watcher-loss recovery/re-registration, hidden tray Quit and original Host idle retirement. The current GNOME session has no StatusNotifierWatcher, so normal-session no-tray fallback was tested separately. Tray actions used an isolated D-Bus watcher, not a claim of visible GNOME panel-icon acceptance.
    • A painted-window-specific GPUI lifetime bug was found: a published input handler could release the final entity owner after the last App collection pass. Generic Window destruction now takes that handler before deferred native cleanup. The focused-paint/native-state-retention regression was verified red/green; the existing standalone core suite passed 757 tests (3 existing ignored).
    • Thirty JavaScript checks passed (CI routing/archive behavior, close snapshots and license discovery). Dependency inventory/notices were regenerated with locked npm dependencies, preserving the Pele/Lucide notices and adding ksni's Unlicense text. ASF header audit passed.

    Still outstanding: a complete native macOS build and AppKit/optional-GPUI runtime acceptance. The revised status-menu module passed a macOS-target metadata type check, but that is not a native desktop run. Native macOS desktop compilation/testing is routed through the shared CI definitions. No claim that all three platforms have completed native acceptance yet.

  5. added a commit that references this issue on Nov 9, 2026
    9864d52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions