Skip to content

Hide macOS windows instead of closing sessions#9371

Open
creeveliu wants to merge 1 commit intowarpdotdev:masterfrom
creeveliu:codex/cmd-w-close-window
Open

Hide macOS windows instead of closing sessions#9371
creeveliu wants to merge 1 commit intowarpdotdev:masterfrom
creeveliu:codex/cmd-w-close-window

Conversation

@creeveliu
Copy link
Copy Markdown

Description

Make macOS window close actions hide the window instead of closing the underlying Warp session. This updates Cmd-W / Close Window bindings, the explicit close window actions, and the native macOS window close callback so clicking the red close button also hides the window. Reopening Warp from the Dock restores an existing hidden window before creating a new one.

Testing

  • cargo fmt
  • cargo test -p warp cmd_w --lib
  • cargo clippy -p warp --lib --tests -- -D warnings
  • TERM=xterm-256color NO_COLOR=1 ./script/run --dont-open
  • Manual local verification with /Users/cl/Projects/warp/target/debug/bundle/osx/WarpOss.app: Cmd-W and the red close button hide the window; clicking the Dock icon restores the session

Co-Authored-By: Warp agent@warp.dev

@cla-bot cla-bot Bot added the cla-signed label Apr 29, 2026
@creeveliu creeveliu changed the title Make Cmd-W hide macOS windows Hide macOS windows instead of closing sessions Apr 29, 2026
@oz-for-oss
Copy link
Copy Markdown
Contributor

oz-for-oss Bot commented Apr 29, 2026

@creeveliu

I'm checking this implementation PR for association with a likely matching ready issue.

Powered by Oz

@creeveliu creeveliu marked this pull request as ready for review April 29, 2026 05:58
@oz-for-oss
Copy link
Copy Markdown
Contributor

oz-for-oss Bot commented Apr 29, 2026

@creeveliu

I'm starting a first review of this pull request.

I requested changes on this pull request and posted feedback.

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

I'm re-reviewing this pull request in response to a review request.

I requested changes on this pull request and posted feedback.

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

You can view the conversation on Warp.

I approved this pull request. No matching stakeholder was found for the changed files, so no human reviewers were requested.

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

Copy link
Copy Markdown
Contributor

@oz-for-oss oz-for-oss Bot left a comment

Choose a reason for hiding this comment

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

Overview

This PR changes macOS window close actions and the native close callback to hide windows instead of terminating Warp sessions, and updates the Dock reopen path to restore an existing hidden window.

Concerns

  • The macOS native close callback now bypasses the existing quit_on_last_window_closed preference, so users who opted into quitting when closing the final window will instead keep Warp running with the window hidden.
  • Security pass: no security-specific issues identified in the inlined diff.

Verdict

Found: 0 critical, 1 important, 0 suggestions

Request changes

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

Comment thread app/src/lib.rs Outdated
ApproveTerminateResult::Cancel
#[cfg(target_os = "macos")]
{
ctx.windows().hide_window(window_id);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ [IMPORTANT] This bypasses quit_on_last_window_closed on macOS, so users who enabled the existing setting to quit when closing the final window will now get a hidden running app instead; preserve the last-window quit path before hiding.

@creeveliu creeveliu force-pushed the codex/cmd-w-close-window branch from 0bf005a to 63119af Compare April 29, 2026 06:09
@creeveliu
Copy link
Copy Markdown
Author

/oz-review

Copy link
Copy Markdown
Contributor

@oz-for-oss oz-for-oss Bot left a comment

Choose a reason for hiding this comment

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

Overview

This PR changes macOS close-window paths so Cmd-W, close-window actions, and the native close callback hide windows instead of closing sessions, and attempts to restore a hidden window when the Dock requests a reopen.

Concerns

  • The macOS quit_on_last_window_closed behavior is broken for multiple windows because hidden windows remain in ctx.window_ids(), so the app can end up with no visible windows and still not quit.
  • Supplemental security pass: no security issues found in the changed lines.

Verdict

Found: 0 critical, 1 important, 0 suggestions

Request changes

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

Comment thread app/src/lib.rs Outdated

#[cfg(target_os = "macos")]
{
if ctx.window_ids().count() == 1 && *general_settings.quit_on_last_window_closed {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ [IMPORTANT] ctx.window_ids().count() includes windows hidden by this new path, so with quit_on_last_window_closed enabled a two-window workflow can hide the first window, then hide the second without ever terminating; base this check on visible windows or track hidden state before deciding to hide.

Co-Authored-By: Warp <agent@warp.dev>
@creeveliu creeveliu force-pushed the codex/cmd-w-close-window branch from 63119af to c4bd213 Compare April 29, 2026 06:36
@creeveliu
Copy link
Copy Markdown
Author

/oz-review

Copy link
Copy Markdown
Contributor

@oz-for-oss oz-for-oss Bot left a comment

Choose a reason for hiding this comment

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

Overview

This PR changes macOS window close behavior so Cmd-W, the Close Window action, and the native red close button hide windows instead of closing their sessions, while adding visibility tracking and Dock reopen behavior to restore an existing window.

Concerns

  • No blocking correctness or security concerns found in the changed lines.

Verdict

Found: 0 critical, 0 important, 0 suggestions

Approve

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant