[PR #3927] [MERGED] Launcher: moving a world to the trash no longer closes it on Windows #5296

Closed
opened 2026-11-03 05:11:36 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/3927
Author: @DenisHumen
Created: 10/29/2026
Status: ✅ Merged
Merged: 10/30/2026
Merged by: @rdbtCVS

Base: main ← Head: fix/launcher-trash-com


📝 Commits (1)

  • 6774e47 Launcher: moving a world to the trash no longer closes it on Windows

📊 Changes

1 file changed (+38 additions, -10 deletions)

View changed files

📝 launcher/src/desktop_seams.rs (+38 -10)

📄 Description

🤖 Opened by DenisHumen's AI agent (Claude Code, Opus 5.5), not by DenisHumen personally.

What

On Windows, Delete → Move to trash on a world closed the launcher, and the world stayed. Now the world goes to the Recycle Bin and the launcher stays open.

Fixes #3784

Why

The trash crate (default feature coinit_multithreaded) calls CoInitializeEx(MULTITHREADED) on the calling thread and panics when that thread already runs COM in the other mode. World deletion runs in cx.background_executor(), which on Windows is GPUI's thread pool (dispatch_on_threadpool), and a pool worker can already be in that state. A panic inside the pool callback can't unwind, so the process aborted. The log from a debug build of main:

panicked at trash-5.2.9\src\windows.rs:344:13:
Call to CoInitializeEx failed. HRESULT: HRESULT(0x80010106). Consider using `trash` with the feature `coinit_multithreaded`
...
panic in a function that cannot unwind ... gpui::platform::windows::dispatcher::dispatch_on_threadpool
thread caused non-unwinding panic. aborting.

0x80010106 is RPC_E_CHANGED_MODE. Screenshots delete on the window thread, so they weren't affected.

Fix

desktop_seams::system_trash now calls the trash crate on a scoped thread of its own, which starts with no COM, and waits for it. If that thread panics anyway, the panic comes back as the error the page already shows, instead of taking the launcher down. Only the real trash path changes. HORIZON_LAUNCHER_TRASH test runs still move files into their folder.

Checked

  • Reproduced and verified by hand in a debug build on Windows 11, with a scratch HORIZON_HOME and the real Recycle Bin:
    • on main, deleting a world aborted the launcher with the log above;
    • on this branch, the page says "TrashTest moved to the trash.", the folder is gone from saves/ and the launcher stays open.
  • New unit test the_trash_runs_on_a_thread_of_its_own_and_its_panic_is_an_error. It checks that the call runs off the caller's thread and that a panic there becomes an Err. It doesn't touch the real trash.
  • In pr_ready, Parity fails only because tools/parity.py imports fcntl, which Windows doesn't have. This PR touches only the launcher, which the parity harnesses don't cover.

pr_ready (tools/pr_ready.py --base upstream/main on DenisPC, against upstream/main at baa379d71, 1 min 25 s)

Check Result
Scope ✅ 1 files, +38 −10
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 423 passed (1 min 12 s)
rustfmt ➖ no Rust change
clippy ➖ no Rust change
tests ➖ no crate touched
doc tests ➖ no crate touched
content root tests ➖ content root untouched
tokens.css up to date ➖ theme untouched
launcher rustfmt ✅ (1 s)
launcher clippy ✅ (1 s)
launcher tests ✅ 269 passed (7 s)
Parity ❌ 361 affected,
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

🤖 Generated with Claude Code


🔄 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/horizon-rust/horizon/pull/3927 **Author:** [@DenisHumen](https://github.com/DenisHumen) **Created:** 10/29/2026 **Status:** ✅ Merged **Merged:** 10/30/2026 **Merged by:** [@rdbtCVS](https://github.com/rdbtCVS) **Base:** `main` ← **Head:** `fix/launcher-trash-com` --- ### 📝 Commits (1) - [`6774e47`](https://github.com/horizon-rust/horizon/commit/6774e47aaebe4e91663b70e403c57771ae6d9079) Launcher: moving a world to the trash no longer closes it on Windows ### 📊 Changes **1 file changed** (+38 additions, -10 deletions) <details> <summary>View changed files</summary> 📝 `launcher/src/desktop_seams.rs` (+38 -10) </details> ### 📄 Description > 🤖 Opened by DenisHumen's AI agent (Claude Code, Opus 5.5), not by DenisHumen personally. ## What On Windows, Delete → Move to trash on a world closed the launcher, and the world stayed. Now the world goes to the Recycle Bin and the launcher stays open. Fixes #3784 ## Why The `trash` crate (default feature `coinit_multithreaded`) calls `CoInitializeEx(MULTITHREADED)` on the calling thread and panics when that thread already runs COM in the other mode. World deletion runs in `cx.background_executor()`, which on Windows is GPUI's thread pool (`dispatch_on_threadpool`), and a pool worker can already be in that state. A panic inside the pool callback can't unwind, so the process aborted. The log from a debug build of `main`: ``` panicked at trash-5.2.9\src\windows.rs:344:13: Call to CoInitializeEx failed. HRESULT: HRESULT(0x80010106). Consider using `trash` with the feature `coinit_multithreaded` ... panic in a function that cannot unwind ... gpui::platform::windows::dispatcher::dispatch_on_threadpool thread caused non-unwinding panic. aborting. ``` `0x80010106` is `RPC_E_CHANGED_MODE`. Screenshots delete on the window thread, so they weren't affected. ## Fix `desktop_seams::system_trash` now calls the trash crate on a scoped thread of its own, which starts with no COM, and waits for it. If that thread panics anyway, the panic comes back as the error the page already shows, instead of taking the launcher down. Only the real trash path changes. `HORIZON_LAUNCHER_TRASH` test runs still move files into their folder. ## Checked - Reproduced and verified by hand in a debug build on Windows 11, with a scratch `HORIZON_HOME` and the real Recycle Bin: - on `main`, deleting a world aborted the launcher with the log above; - on this branch, the page says "TrashTest moved to the trash.", the folder is gone from `saves/` and the launcher stays open. - New unit test `the_trash_runs_on_a_thread_of_its_own_and_its_panic_is_an_error`. It checks that the call runs off the caller's thread and that a panic there becomes an `Err`. It doesn't touch the real trash. - In pr_ready, Parity fails only because `tools/parity.py` imports `fcntl`, which Windows doesn't have. This PR touches only the launcher, which the parity harnesses don't cover. **pr_ready** (`tools/pr_ready.py --base upstream/main` on DenisPC, against upstream/main at baa379d71, 1 min 25 s) | Check | Result | | --- | --- | | Scope | ✅ 1 files, +38 −10 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 423 passed (1 min 12 s) | | rustfmt | ➖ no Rust change | | clippy | ➖ no Rust change | | tests | ➖ no crate touched | | doc tests | ➖ no crate touched | | content root tests | ➖ content root untouched | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ✅ (1 s) | | launcher clippy | ✅ (1 s) | | launcher tests | ✅ 269 passed (7 s) | | Parity | ❌ 361 affected, | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 05:11:36 +07:00
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
horizon-rust/horizon#5296
No description provided.