Skip to content

[GUI] Add Opt-In Windows Close To Tray - #3612

Open
medking82 wants to merge 6 commits into
Niko1221:mainfrom
medking82:codex/windows-close-to-tray-20261021
Open

medking82 wants to merge 6 commits into
Niko1221:mainfrom
medking82:codex/windows-close-to-tray-20261021

Conversation

@medking82

@medking82 medking82 commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Problem And Result

Closing the Windows App with X destroys its Host, which also interrupts an owner Web UI that uses that Host. This opt-in native hook lets a visible companion keep the same App Host alive while X hides the main window. Launching the App again restores the same instance; explicit Windows --quit and verified-owner exit use the normal Host shutdown path.

Related: #2034 and #3365. Native lifecycle scope proposal. Scope agreement remains requested, not assumed. The managed-model Tray and App contract proposals keep their separate scope.

Approach

  • Require STRATA_CLOSE_TO_TRAY=1, the companion's PID and its absolute executable path. Verify and retain that exact process handle to avoid PID reuse. Missing, inaccessible, mismatched or exited owners keep normal X behavior.
  • Reuse the original single-instance restore, Host shutdown, resource lookup, shutdown token, Windows Job and updater paths. No Engine, Control, server, frontend, dependency, installer or default-setting change is included. The hook is compiled and called only on Windows.
  • Add focused Windows checks. One existing crash-report test now uses the package version instead of a stale literal; runtime logging is unchanged.

Actual Submitted-Candidate GUI Acceptance

Tested native source: 6a4202de18bd8c5b77ac3512875c8230722c0f16, from Windows CI run 39632085918. Executable SHA-256: 2e08024cbbcda10415af59d53462e173c7f3e7aa424e858aef18ffbc3f1db4c2. This exact unbundled executable ran beside copies of unchanged official App 0.2.2 Host/UI/Control resources; its official contract fingerprint matched. No Rust patch was used for local acceptance.

Observed on 2026-10-22 (Asia/Kuala_Lumpur), Windows x64, Engine 0.1.47, RTX 5080 16 GB and 61.4 GB usable RAM:

  • The native App completed PR3612_APP_OK. Clicking the actual native title-bar X removed its window from the visible Windows inventory while the same App, official Node Host, Tray and 8080/8081 listeners remained alive.
  • The running companion's real StrataTray.exe --open-app entry restored the exact same native window, App and Host. This invokes its normal Open App handler; physical notification-area icon clicking was not automated.
  • After another actual X, owner Web completed PR3612_FINAL_WEB_OK while the native window stayed hidden. The same on-demand Huihui V2 Swift IQ3_S model loaded for that request. Authenticated Models metadata and Monitor returned HTTP 200.
  • Effective Context remained 204800 (200K), idle unload remained 1800 seconds (30 Minutes), and Codex Sync reported synced. Reload of an already running Codex client was not verified.
  • Explicit candidate --quit exited its App and Host. The real Tray reopened the original native Extension. All 17 recorded private files and all 29,400 official resource files passed preservation checks. Original activation pointers and the original unloaded, on-demand model state were restored.

Submitted Candidate Restored By The Actual Tray Entry

Submitted Candidate: Completed Web Reply While Hidden

These are real QA captures, not mockups. They contain only QA text and generic UI; no private path, hostname, account identity, credentials, original user screenshot or unrelated chat is published. JPEG header audit found no EXIF/XMP/IPTC/comment metadata. Incidental usage figures are not a benchmark. The sanitized observation receipt records checksums and identity comparisons without private IDs or paths.

Validation

Base: official App 0.2.2 main 011c9e600a93bbc9fd451c563501b5831c32bbca. Current head 6b8363ad8145220f23cf338d88e28339d89c1130 changes evidence/docs only after tested native source 6a4202de18bd8c5b77ac3512875c8230722c0f16. The exact native/build-input comparison is empty:

git diff --exit-code 6a4202de18bd8c5b77ac3512875c8230722c0f16 6b8363ad8145220f23cf338d88e28339d89c1130 -- apps/desktop/src-tauri .github/workflows/desktop-window-lifecycle.yml

Passed:

  • Windows CI: cargo test --locked -- --test-threads=1 passed 25 tests, 0 failed; cargo build --locked --release succeeded. The workflow uses an inert compile-only page and no bundled resources, and retains the exact executable and provenance as the windows-window-lifecycle artifact.
  • Actual native X, same-window Tray Reopen, hidden-window Web inference, Models/Monitor, explicit Quit, original-runtime restore and preservation checks above.
  • git diff --check, exact native/build-input comparison, screenshot visual privacy review and JPEG metadata audit.
  • The separate companion fix passed 313 assertions and its build before the final GUI run. Its site-specific launcher/deployment implementation is outside this native PR.

Observed CI output:

test result: ok. 25 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
Finished `release` profile [optimized] target(s) in 3m 07s

Observed Failure And Resolution: the companion's old Win32 restore shortcut reported success while the window stayed hidden. Direct single-instance App launch worked. The companion now always calls its validated launcher and the App's own restore entry; the final GUI run used this correction. No Rust fix was needed. The earlier Windows Security prompt was resolved manually by the user; automation did not operate that dialog. Actual listeners remained loopback-only.

Not Run: physical notification-area icon clicking; signed-installer update, updater exit and Windows logoff; actual candidate owner-exit GUI execution; other App versions and Linux/macOS builds. Owner-exit logic passed its Windows Rust tests. No C++/CUDA/HIP/SYCL/Metal backend is changed by this PR.

Limits

Companions must provide a visible Open/Exit entry and start the App outside a server-only Job. Process validation proves the configured process is alive; it cannot prove the companion has a usable icon. This does not add a built-in Tray, a general plugin or browser-deployment API. Future-version compatibility and signed-updater execution remain unverified. Scope agreement remains outstanding.

Reproduction, baseline and separate earlier deployed reference: Windows Close To Tray Acceptance.

@medking82
medking82 marked this pull request as ready for review October 21, 2026 22:01
@medking82

Copy link
Copy Markdown
Contributor Author

Could a maintainer please approve the pending Windows Desktop Window Lifecycle workflow and Title area workflow for current head 6b8363ad? Intake passes.

Existing validation:

  • Windows fork CI passed the locked Rust tests (25 passed, 0 failed) and release build on native source 6a4202de. Its native/build inputs are byte-identical to the submitted head; subsequent changes are evidence/docs only.
  • Recorded submitted-candidate GUI acceptance covered actual native X, same-window Tray Reopen, hidden-window Web inference and explicit Quit. Sanitized acceptance receipt.
  • The native/build-input comparison and git diff --check passed.

Fork CI and recorded local acceptance are separate from the pending upstream runs. Owner-exit GUI, signed-updater/logoff and cross-platform acceptance remain unrun.

@Niko1221

Copy link
Copy Markdown
Owner

Thank you for the careful work on close-to-tray. It changes how the app window ends and depends on the tray design, so we will take it up together with the tray. It is planned for a later release, with no date yet, and this will stay open until then.

Retain the upstream shell module and built-in Settings tray close handler
alongside the original opt-in lifecycle for a verified external tray owner.

Validated against main 5e8a4cc on Windows:
- cargo test --locked -- --test-threads=1: 29 passed, no failures or skips.
- cargo build --locked --release: passed with the workflow's compile-only
  resources, then restored tauri.conf.json byte for byte.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants