Skip to content

fix(desktop): add close window on cmd+shift+w to the macos window menu - #31403

Merged
bolichen97 merged 1 commit into
mainfrom
fix/11393-mac-close-window
Nov 6, 2026
Merged

bolichen97 merged 1 commit into
mainfrom
fix/11393-mac-close-window

Conversation

@bolichen97

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: On macOS, Cmd+Shift+W closes the focused dashboard window from a Close Window item in the Window menu, while Cmd+W keeps closing the current session.

On macOS nothing on the keyboard closes the main dashboard window (#11393). Cmd+W is "close session" on every platform by design (#9555), and the stock macOS Window menu has no Close item, so the only way to close the window is the red traffic-light button. Windows and Linux already close the window with Ctrl+Shift+W.

Why it matters

A macOS user who reaches for a close-window shortcut gets nothing and has to use the mouse. A maintainer asked for exactly this follow-up when closing #11399: a Close Window item on Cmd+Shift+W in the macOS Window menu, matching Ctrl+Shift+W on Windows/Linux.

Not a goal

What changed (motivation → approach → change)

On macOS, Cmd+Shift+W closes the focused window, and the Window menu shows it as Close Window. Cmd+W still closes the session.

The macOS branch of website/electron/app-menu.js used Electron's stock windowMenu role. That menu has Minimize, Zoom and Bring All to Front but no Close, and Cmd+W belongs to the renderer, so no key closed the window.

The macOS Window menu is written out: the stock items plus { role: "close", accelerator: "Cmd+Shift+W" }, the same chord Windows/Linux use. It keeps role: "windowMenu", which is what makes AppKit list the open windows at the bottom. The close role fires the window's own close event, the same one the red button fires, so the existing close handler decides what happens. The renderer's shortcut registry has nothing on Cmd+Shift+W, since it matches Shift exactly. The Menus table in website/electron/README.md gains the row.

Backwards compatibility

Compatible: the macOS Window menu keeps its role and every stock item, and gains one item on Cmd+Shift+W. One page listener also reacts to that chord: File Explorer closes its active file or folder tab on Cmd+W without checking Shift, so on that page Cmd+Shift+W now meets both that listener and the new menu item. Ctrl+Shift+W has the same overlap on Windows/Linux today.

Removes nothing: the menu only gains an item; Cmd+W, the renderer registry, the File Explorer listener and the close handler are untouched.

Tests

  • website/electron/test/app-menu.test.js: the macOS Window menu test pins role: "windowMenu", the minimize, zoom, front and close roles, Close on Cmd+Shift+W, and no click on Close (Electron owns the close). The shared "no menu item claims CmdOrCtrl+N or CmdOrCtrl+W" test is unchanged and green, which keeps Cmd+W with the renderer.
  • Revert check by hand: with app-menu.js from main and the new test, 1 of 33 tests fails (the new one); with the fix, 33 of 33 pass.
  • Determinism: 20 repeats pass 20 of 20; node --test --test-randomize with 10 seeds passes 10 of 10.
  • npm run test:electron on macOS: 3243 pass, 0 fail, 12 skipped. CI runs the Electron job on Linux only, so this is the macOS run.

Proof: not provable -- frontend test (prove.py runs Python only)

Manual verification

macOS 26.7.2 (25G332) on Apple silicon, Electron 44.9.1 (electron ~44.9.1). The dev shell ran from this branch with its own user-data dir, against an isolated gateway on a scratch data home. Keys were real key presses sent to the app.

Check Result
Window menu, read through the Accessibility API Minimize, Zoom, the macOS 26 window items, Bring All to Front, Close Window ⇧⌘W, then the open-window list (Kiro Crew [:<port>]). The same menu on main has no Close item.
Cmd+W in the main window, idle session open the session closes, the window stays open
Cmd+Shift+W in the main window hides to the tray; the shell logs close: hiding to tray (fullScreen=false), the same line the red button logs
Cmd+Shift+W in native fullscreen close: hiding to tray (fullScreen=true), then fullscreen: exit transition started and fullscreen: left; the app hides and none of its windows stay on screen
Cmd+Shift+W with the close action set to quit the app quits (exit 0) after close: quitting (closeAction=quit)
Second window (Connection > New Window, ⌘⇧N), Cmd+W closes that window's session; both windows stay
Second window, Cmd+Shift+W closes only that window; the main window stays visible with its session
Cmd+Shift+W while typing in the chat box the window hides and the draft is unchanged: nothing typed

AppKit adds its usual Option alternate, Close All (⌥⇧⌘W), under Close Window. No renderer shortcut uses that chord.

Not exercised: the Cmd+W confirm prompt on a busy session, since no chat turn ran, and Cmd+Shift+W on the File Explorer page. Both are renderer code this PR does not change.

Screenshots / video

The macOS Window menu with this change, captured from the app's own menu window, is attached at the end of this description: Close Window on ⇧⌘W sits above the open-window list.

Related Issues

Closes #11393

Follows the maintainer's request on #11399. Cmd+W as "close session": #9555.

Sibling sweep

Swept: git grep -n -e 'role: "windowMenu"' -e 'role: "close"' -e 'Shift+W' -- website/electron/
Swept: git grep -nE "key(\.toLowerCase\(\))? ?={2,3} ?'[wW]'|key: '[wW]'" -- website/src
Sibling: website/electron/app-menu.js -- changed here
Sibling: website/src/apps/file-explorer/FileExplorerPage.tsx:432 -- not affected -- it closes a file or folder tab, not the window, so it has no missing window close

The first search finds one other window close: the Windows/Linux branch of the same template, which already puts Close on Ctrl+Shift+W. No other menu carries one. The second finds the renderer's W listeners: the shortcut registry's close-chat and File Explorer's tab close, which Backwards compatibility names.

Pattern harvest

Not generalizable: one platform's menu missed one item that the other platform's menu had, and app-menu.test.js now pins the Window menu on both platforms.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

Contribution License Agreement

Contributed under the project's Apache-2.0 license (see the Licensing section of CONTRIBUTING.md).

macOS Window menu with Close Window on Shift+Cmd+W above the open-window list

On macOS the main dashboard window had no keyboard way to close it.
Cmd+W is "close session" in the renderer on every platform, and the
stock macOS Window menu has no Close entry, so nothing closed the
window from the keyboard.

Write the macOS Window menu out as the stock items plus Close Window
on Cmd+Shift+W, matching Ctrl+Shift+W on Windows/Linux. The menu keeps
the windowMenu role, so AppKit still lists the open windows. Close is
the native role: it fires the same close event as the red button, so
the main window hides to the tray (leaving fullscreen first) or quits
when set to, and a second window just closes. Cmd+W still reaches the
renderer.

Closes #11393
@bolichen97
bolichen97 requested review from a team and KiroCrewCaptain as code owners November 6, 2026 12:11
@bolichen97
bolichen97 requested a review from Zedmor November 6, 2026 12:11
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Nov 6, 2026
@bolichen97
bolichen97 enabled auto-merge (squash) November 6, 2026 12:13
@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of 769ade93b83b269f7804ffd421caa8c349e27326 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

Nothing blocks. This is a small, reversible menu addition that uses Electron's own close role, so the existing close handler still decides what closing does. Cmd+W stays with the renderer.

Notes

  • On the File Explorer page, Cmd+Shift+W will also close the active file tab, because that listener ignores Shift. This is already listed and matches Ctrl+Shift+W on Windows/Linux. Making the listener check !shiftKey belongs in a follow-up PR, not this one.

[DESIGN-REVIEWED] 769ade9

Description read

[DESCRIPTION-READ] 60b0ff0eb5bcf2b445367662a90a91cce32f03e0ed0c2f12b274c12b06b7f37f

That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 769ade93b83b269f7804ffd421caa8c349e27326 — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

First-Principles-Verdict: PASS

Nothing blocks. The fix adds one menu item for a linked defect (#11393). The old test said "no Close entry, so Cmd+W reaches the page", and its reason still holds because Close now uses the Shift chord.

What this change ships

Inventory (3 items) — 3 justified

Intent: let a macOS user close the focused dashboard window from the keyboard while Cmd+W keeps closing the session. FIX.

  1. The macOS Window menu gains a Close Window item on ⌘⇧W, which hides to the tray or quits through the existing close handler — justified
  2. The macOS Window menu is now listed out item by item (Minimize, Zoom, Bring All to Front) but keeps the windowMenu role, so the open-window list stays — justified
  3. The README Menus table gains a row for Close Window (⌘⇧W) — justified

[FIRST-PRINCIPLES-REVIEWED] 769ade9

Description read

[DESCRIPTION-READ] ec15fd0f86f1c2d5857a3ed2c7bc0cf124eff4996f84652f2e02083b7ef1d108

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ✅ PASS

UX-level review of 769ade93b83b269f7804ffd421caa8c349e27326 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

UX-Verdict: PASS

Nothing blocks. The screenshot shows the one added item, "Close Window ⇧⌘W". The blind reader read it correctly ("closes this window") and said they would use it.

Notes

  • The blind reader hesitated on Close Window because they couldn't tell "whether closing it also ends my chat or quits the app". With the default setting, the app hides to the tray. AppKit owns the menu label, so the only place to answer that question is the user docs. The README row is the place to say that the default setting hides the window to the tray.

[UX-REVIEWED] 769ade9

Description read

[DESCRIPTION-READ] 0d68956dfa4e57ceb62ebc3e0dd07daf682ae7210a77cfa37d43e587e122ebe5

That sha256 names everything this verdict read: the PR description, plus the 4 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed 769ade93b83b269f7804ffd421caa8c349e27326 — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 769ade9

Verdict parsed from the review's SHA-scoped output markers for commit 769ade93b83b269f7804ffd421caa8c349e27326.

False positive or not applicable? A repository writer can comment:
/ai-review override fable 769ade93b83b269f7804ffd421caa8c349e27326 false-positive: <reason, 20 to 500 characters>

@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of 769ade93b83b269f7804ffd421caa8c349e27326 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 769ade9

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 769ade93b83b269f7804ffd421caa8c349e27326 false-positive: <reason, 20 to 500 characters>

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Nov 6, 2026

@buluoray buluoray left a comment

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.

🤖 Kiro Crew Auto-Pipeline [operator: buluoray]:

APPROVE. Reviewed at 769ade9.

What it does for users: on macOS, Cmd+Shift+W now closes the focused dashboard window through a Close Window item in the Window menu, the same chord Windows and Linux already use. Cmd+W stays "close session". Before this, the red traffic-light button was the only way to close the window on macOS (#11393).

Evidence

  • website/electron/app-menu.js:169-181: the macOS branch keeps role windowMenu (so AppKit still lists open windows) and writes out minimize, zoom, front and close, with close on Cmd+Shift+W. The close role fires the window's own close event, which the existing handler at website/electron/window-lifecycle.js:934 handles, so hide-to-tray and quit behave as they do for the red button.
  • Shortcut collisions: I searched website/src and website/electron for every W chord. The renderer registry claims Cmd/Ctrl+W (close-chat) and its Option/Alt+Shift+W alias (website/src/lib/shortcutRegistry.ts:171-172). Its matcher requires Shift to match exactly (website/src/lib/shortcutRegistry.ts:422), so Cmd+Shift+W never matches close-chat. No other registry entry and no other menu item uses Cmd+Shift+W. The one overlap is File Explorer's tab-close listener (website/src/apps/file-explorer/FileExplorerPage.tsx:432), which ignores Shift. The PR body names it, and Ctrl+Shift+W on Windows/Linux has the same overlap today.
  • Spec: the owning spec for the desktop shell is website/electron/README.md. Its Menus table gains the row in the same commit.
  • Tests: website/electron/test/app-menu.test.js passes 33 of 33.
  • Mutation: with the macOS Close item removed from app-menu.js, the test "mac: Window menu keeps the stock role and adds Close on Cmd+Shift+W (Cmd+W reaches the page)" goes red (32 pass, 1 fail). The tree was restored and is clean.
  • CI: 77 success and 17 skipped check runs, with no failures. PR Readiness and both CodeBuild statuses are green. Every bot lane (Design, First Principles, UX, Opus, GPT) passes at this head. The PR merges cleanly into main.

Source-only: everything on macOS. This review ran on Linux, so AppKit's menu rendering, the Close All alternate, fullscreen and second-window behaviour were not exercised here. The PR body's manual macOS table is the author's evidence, and I did not reproduce it. One point is open on that basis. In Electron the page sees a key press before the menu does, so on the File Explorer page the listener's preventDefault may keep the menu's Close from firing at all. In that case Cmd+Shift+W would close only the file tab, while the body says the chord reaches "both that listener and the new menu item". I could not check which of the two happens. Neither outcome loses data.

Follow-ups (non-blocking)

  • Make the File Explorer tab-close listener require that Shift is not held, so Cmd/Ctrl+Shift+W always means "close window" on every page. The Design lane suggested this too.
  • The comment at website/src/lib/shortcutRegistry.ts:169-170 still says only Windows/Linux move the window close to the Shift chord. That is still true for those platforms, but it now applies to macOS as well and can say so.

@bolichen97
bolichen97 merged commit c318773 into main Nov 6, 2026
98 checks passed
@bolichen97
bolichen97 deleted the fix/11393-mac-close-window branch November 6, 2026 17:29
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Nov 6, 2026
buluoray pushed a commit that referenced this pull request Nov 9, 2026
#31403)

On macOS the main dashboard window had no keyboard way to close it.
Cmd+W is "close session" in the renderer on every platform, and the
stock macOS Window menu has no Close entry, so nothing closed the
window from the keyboard.

Write the macOS Window menu out as the stock items plus Close Window
on Cmd+Shift+W, matching Ctrl+Shift+W on Windows/Linux. The menu keeps
the windowMenu role, so AppKit still lists the open windows. Close is
the native role: it fires the same close event as the red button, so
the main window hides to the tray (leaving fullscreen first) or quits
when set to, and a second window just closes. Cmd+W still reaches the
renderer.

Closes #11393

(cherry picked from commit c318773)
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.

Cmd+W does not close the main dashboard window on macOS

2 participants