Skip to content

Add New Window to Dock menu - #2340

Merged
austinywang merged 2 commits into
mainfrom
issue-2240-dock-new-window
Mar 30, 2026
Merged

austinywang merged 2 commits into
mainfrom
issue-2240-dock-new-window

Conversation

@austinywang

@austinywang austinywang commented Mar 30, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • add a Dock-menu New Window item via applicationDockMenu(_:) in AppDelegate
  • route the Dock menu item to the existing openNewMainWindow(_:) path so it matches the app's normal window creation flow
  • add a regression test covering Dock menu selection creating a new main window

Fixes #2240.

Testing

  • did not run local tests per repo policy
  • ./scripts/reload.sh --tag dock-new-window --launch
  • ./scripts/reload.sh --tag dock-new-window

Summary by cubic

Adds a "New Window" item to the macOS Dock menu that opens a new main window using the same flow as the app’s normal window creation. Fixes #2240.

  • New Features
    • Adds Dock menu via applicationDockMenu in AppDelegate with a localized “New Window” item that calls openNewMainWindow(_:).
    • Adds a regression test to ensure the Dock menu item creates exactly one new main window.

Written for commit ea551e0. Summary will update on new commits.

Summary by CodeRabbit

  • New Features
    • Added a dock menu with a "New Window" option, enabling users to quickly create new main windows directly from the app's dock icon.

@vercel

vercel Bot commented Mar 30, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
cmux Ready Ready Preview, Comment Mar 30, 2026 4:43am

@coderabbitai

coderabbitai Bot commented Mar 30, 2026 •

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 7e1efe2a-24b8-4962-a954-43e0396fcd1f

📥 Commits

Reviewing files that changed from the base of the PR and between 35cb42f and ea551e0.

📒 Files selected for processing (2)
  • Sources/AppDelegate.swift
  • cmuxTests/AppDelegateShortcutRoutingTests.swift

📝 Walkthrough

Walkthrough

Adds a dock menu to the application with a "New Window" option. When users right-click the app icon in the dock, they can select this menu item to create a new main window via the existing window-creation mechanism. Includes test coverage validating the dock menu item creation and functionality.

Changes

Cohort / File(s) Summary
Dock Menu Implementation
Sources/AppDelegate.swift
Implements applicationDockMenu(_:) delegate method that constructs and returns an NSMenu containing a single "New Window" menu item wired to the existing openNewMainWindow(_:) selector.
Dock Menu Tests
cmuxTests/AppDelegateShortcutRoutingTests.swift
Adds testDockMenuNewWindowItemCreatesMainWindow test that verifies the dock menu is created, contains the correct "New Window" item with proper localization, and successfully creates a new main window when invoked.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 A dock menu blooms, so neat and fine,
Right-click the icon, new windows shine,
The workspace beckons, fresh and new,
No dragging needed—what a view! ✨
The rabbit approves this change so true!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Add New Window to Dock menu' directly and clearly summarizes the main change—adding a dock menu feature with a new window option.
Description check ✅ Passed The PR description covers what changed, why, and testing approach, but lacks a demo video and the review trigger checklist items are incomplete.
Linked Issues check ✅ Passed The PR fully implements the requested feature from #2240: adds a 'New Window' option to the Dock menu using applicationDockMenu(), routes to the existing window-creation flow, and includes a regression test.
Out of Scope Changes check ✅ Passed All changes are directly scoped to implementing the Dock menu feature and its test; no extraneous modifications are present.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch issue-2240-dock-new-window

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@cubic-dev-ai cubic-dev-ai 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.

No issues found across 2 files

@greptile-apps

greptile-apps Bot commented Mar 30, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds a "New Window" item to the macOS Dock context menu by implementing applicationDockMenu(_:) in AppDelegate, routing the action through the existing openNewMainWindow(_:) → createMainWindow() path so it is fully consistent with the keyboard-shortcut and menu-bar flows.

Key changes:

  • Sources/AppDelegate.swift: New applicationDockMenu(_:) delegate method builds a single-item NSMenu, reuses the already-translated menu.file.newWindow localization key, and explicitly sets target = self so the action resolves to AppDelegate even when no key window exists.
  • cmuxTests/AppDelegateShortcutRoutingTests.swift: Regression test calls the delegate method, fires the action via NSApp.sendAction, and asserts exactly one new main window appears — following the file's established RunLoop.main.run(until:) drain pattern. The two-commit structure (test first, fix second) is correctly observed per the repo policy in CLAUDE.md.

Confidence Score: 5/5

Safe to merge — small, well-scoped change with a passing regression test and no modifications to existing behavior.

No P0 or P1 issues found. The implementation correctly reuses the existing window-creation path and localization key, sets an explicit action target, and is covered by a behavioral test that follows the repo's established patterns and two-commit policy.

No files require special attention.

Important Files Changed

Filename Overview
Sources/AppDelegate.swift Adds applicationDockMenu(_:) returning an NSMenu with a "New Window" item wired to the existing openNewMainWindow(_:) path; implementation is clean, explicit target is set, and reuses the pre-existing menu.file.newWindow localization key.
cmuxTests/AppDelegateShortcutRoutingTests.swift Adds testDockMenuNewWindowItemCreatesMainWindow which calls the delegate method, fires the action via NSApp.sendAction, and asserts exactly one new main window is created; follows the existing RunLoop.main.run(until:) pattern and is paired correctly with the two-commit structure.

Sequence Diagram

sequenceDiagram
    participant User
    participant Dock
    participant AppKit
    participant AppDelegate
    participant createMainWindow

    User->>Dock: Right-click / long-press Dock icon
    Dock->>AppKit: Request Dock menu
    AppKit->>AppDelegate: applicationDockMenu(_ sender:)
    AppDelegate-->>AppKit: NSMenu { "New Window" → openNewMainWindow(_:) }
    AppKit-->>Dock: Display menu
    User->>Dock: Click "New Window"
    Dock->>AppDelegate: openNewMainWindow(_ sender:)
    AppDelegate->>createMainWindow: createMainWindow()
    createMainWindow-->>AppDelegate: UUID (new window ID)
    AppDelegate-->>User: New main window appears
Loading

Reviews (1): Last reviewed commit: "Add New Window to Dock menu" | Re-trigger Greptile

@austinywang
austinywang merged commit 29c0f52 into main Mar 30, 2026
16 checks passed
bn-l pushed a commit to bn-l/cmux that referenced this pull request Apr 3, 2026
* Add Dock menu new-window regression test

* Add New Window to Dock menu

This branch was successfully deployed

1 active deployment
Preview — ea551e06 Deployed Mar 30, 2026 by vercel[bot]
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.

Open New Window in Workspace with Right Click

1 participant