Skip to content

Desktop: ask before quitting on top of a running install - #7550

Merged
danielhanchen merged 4 commits into
mainfrom
fix/desktop-confirm-quit-during-install
Jul 29, 2026
Merged

danielhanchen merged 4 commits into
mainfrom
fix/desktop-confirm-quit-during-install

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

What happens today

Quitting the desktop app while it is installing destroys the install silently, with no warning and no way back. From a user's diagnostics:

04:17:57 Stopping installer process group (pid 53801)
         Installation stopped intentionally
         ExitStatus(unix_wait_status(15))

The app relaunched two seconds later and the backend died with:

ModuleNotFoundError: No module named 'structlog'

The kill landed during deps [==========----------] 5/10 studio deps, which is the step that installs studio/backend/requirements/studio.txt, and structlog is declared only there. The tray Quit item calls cleanup_child_processes to stop_install, which SIGTERMs the installer's process group. The user had been installing for minutes and was given no indication that quitting would undo it.

The change

confirm_quit_during_install asks first, offering "Keep installing" or "Quit anyway".

Two deliberate limits:

  • Tray Quit only. That is a deliberate user action with a UI present. The RunEvent::Exit path (OS shutdown, SIGTERM) must never block on a dialog nobody can answer, so it is left alone.
  • Off the main thread. It runs inside the existing std::thread::spawn in the Quit handler, because blocking_show() must not be called on the main thread.

install::is_install_running is a small accessor so main.rs can ask without reaching into InstallState. When no install is running the dialog never appears and quit behaves exactly as before.

Scope

This addresses the trigger. Detecting and repairing an already-damaged venv is #7492 (merged) and #7490, and they are complementary: this stops the damage happening, they handle the installs that were already damaged.

Deliberately kept small and clear of #7490, which rewrites process.rs and use-tauri-backend.ts. This touches main.rs, which #7490 does not, plus a 14-line addition to install.rs.

Verification

cargo check clean and cargo test 101 passed on this branch. The two warnings emitted are both present on main already.

This is the trigger neither #7492 nor #7490 addresses -- both start from a venv
that is already broken. Confirmed: neither PR touches cleanup_child_processes.

Quitting runs cleanup_child_processes -> install::stop_install, which SIGTERMs the
installer's process group. In the reported session that landed at "5/10 studio
deps", so the venv kept the CLI's dependencies and lost the server stack, and the
next launch died on `import structlog`. Three minutes of installing, destroyed
with no warning and no way back.

So ask. Only from the tray Quit item -- a deliberate action with a UI present. The
RunEvent::Exit path (OS shutdown, SIGTERM) is left alone: it must never block on a
dialog nobody can answer. The call already runs off the menu callback thread,
which is also what blocking_show requires.

Closing the window was already safe (it hides to tray); this closes the remaining
way to lose an install by accident.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 83996139d1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +792 to +795
state
.lock()
.map(|install| install.child.is_some())
.unwrap_or(false)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Track elevated package installs before quitting

On Linux, once the installer requests elevation, wait_for_exit clears InstallProcess.child, and install_system_packages subsequently runs apt-get update/install without restoring or otherwise marking that child state. Selecting tray Quit while those elevated commands are active therefore bypasses this confirmation and exits the parent while the package manager's captured pipes are still in use, potentially interrupting apt/dpkg and leaving the installation or package database incomplete. Track the elevated-install phase explicitly rather than treating child.is_some() as the complete definition of an active installation.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

install_system_packages is a sync #[tauri::command] (commands.rs:405), unlike start_install which is async, so it blocks the GTK main thread and the tray Quit event cannot dispatch until apt returns. The state hole is real but unreachable. Worth revisiting if that command ever becomes async.

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Can't wait for the next one!

Reviewed commit: 66358aa6d6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@danielhanchen
danielhanchen merged commit 4f0cbf0 into main Jul 29, 2026
36 of 40 checks passed
@danielhanchen
danielhanchen deleted the fix/desktop-confirm-quit-during-install branch July 29, 2026 01:52
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