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

Open
opened 2026-11-07 15:38:31 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/3612
Author: @medking82
Created: 10/21/2026
Status: 🔄 Open

Base: main ← Head: codex/windows-close-to-tray-20261021


📝 Commits (6)

  • 39ef5d4 feat(desktop): add opt-in Windows close-to-tray lifetime
  • 60ae168 docs: use the verified screenshot media type
  • 6a4202d ci: retain source-bound native shell for GUI acceptance
  • f994c06 docs: add source-bound candidate Web acceptance evidence
  • 6b8363a docs: add submitted-candidate Close To Tray GUI evidence
  • 1492671 Merge upstream main into Windows close-to-tray branch

📊 Changes

11 files changed (+510 additions, -1 deletions)

View changed files

➕ .github/workflows/desktop-window-lifecycle.yml (+70 -0)
📝 apps/desktop/src-tauri/src/desktoplog.rs (+1 -1)
📝 apps/desktop/src-tauri/src/main.rs (+16 -0)
➕ apps/desktop/src-tauri/src/window_lifecycle.rs (+159 -0)
📝 docs/CLOSING.md (+29 -0)
➕ docs/windows-close-to-tray/README.md (+164 -0)
➕ docs/windows-close-to-tray/candidate-tray-reopened.jpg (+0 -0)
➕ docs/windows-close-to-tray/candidate-web-baseline.jpg (+0 -0)
➕ docs/windows-close-to-tray/candidate-web-hidden.jpg (+0 -0)
➕ docs/windows-close-to-tray/gui-acceptance.json (+71 -0)
➕ docs/windows-close-to-tray/web-background.jpg (+0 -0)

📄 Description

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.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Niko1221/Strata/pull/3612 **Author:** [@medking82](https://github.com/medking82) **Created:** 10/21/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `codex/windows-close-to-tray-20261021` --- ### 📝 Commits (6) - [`39ef5d4`](https://github.com/Niko1221/Strata/commit/39ef5d46623cd086e75764755e1400a4ef9f05c3) feat(desktop): add opt-in Windows close-to-tray lifetime - [`60ae168`](https://github.com/Niko1221/Strata/commit/60ae1685a51c8f6d9c0c9700c59844a2ade2e905) docs: use the verified screenshot media type - [`6a4202d`](https://github.com/Niko1221/Strata/commit/6a4202de18bd8c5b77ac3512875c8230722c0f16) ci: retain source-bound native shell for GUI acceptance - [`f994c06`](https://github.com/Niko1221/Strata/commit/f994c06f3701369c9c1ab622cf1689616b1f00c1) docs: add source-bound candidate Web acceptance evidence - [`6b8363a`](https://github.com/Niko1221/Strata/commit/6b8363ad8145220f23cf338d88e28339d89c1130) docs: add submitted-candidate Close To Tray GUI evidence - [`1492671`](https://github.com/Niko1221/Strata/commit/14926710d1e80f2a14b33464d6999f2e3e9c6f43) Merge upstream main into Windows close-to-tray branch ### 📊 Changes **11 files changed** (+510 additions, -1 deletions) <details> <summary>View changed files</summary> ➕ `.github/workflows/desktop-window-lifecycle.yml` (+70 -0) 📝 `apps/desktop/src-tauri/src/desktoplog.rs` (+1 -1) 📝 `apps/desktop/src-tauri/src/main.rs` (+16 -0) ➕ `apps/desktop/src-tauri/src/window_lifecycle.rs` (+159 -0) 📝 `docs/CLOSING.md` (+29 -0) ➕ `docs/windows-close-to-tray/README.md` (+164 -0) ➕ `docs/windows-close-to-tray/candidate-tray-reopened.jpg` (+0 -0) ➕ `docs/windows-close-to-tray/candidate-web-baseline.jpg` (+0 -0) ➕ `docs/windows-close-to-tray/candidate-web-hidden.jpg` (+0 -0) ➕ `docs/windows-close-to-tray/gui-acceptance.json` (+71 -0) ➕ `docs/windows-close-to-tray/web-background.jpg` (+0 -0) </details> ### 📄 Description ## 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](https://github.com/Niko1221/Strata/issues/2034#issuecomment-6320053297). 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](https://github.com/medking82/Strata/actions/runs/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](https://raw.githubusercontent.com/medking82/Strata/6b8363ad8145220f23cf338d88e28339d89c1130/docs/windows-close-to-tray/candidate-tray-reopened.jpg) ![Submitted Candidate: Completed Web Reply While Hidden](https://raw.githubusercontent.com/medking82/Strata/6b8363ad8145220f23cf338d88e28339d89c1130/docs/windows-close-to-tray/candidate-web-hidden.jpg) 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](https://github.com/medking82/Strata/blob/6b8363ad8145220f23cf338d88e28339d89c1130/docs/windows-close-to-tray/gui-acceptance.json) 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: ```text 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: ```text 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](https://github.com/medking82/Strata/blob/6b8363ad8145220f23cf338d88e28339d89c1130/docs/windows-close-to-tray/README.md). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#4711
No description provided.