Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Sep 12, 2025

This PR implements a new "Clone Window" feature in the File menu that allows users to open another window displaying the currently opened project.

Changes Made

Backend (Rust)

  • Menu System: Added "Clone Window" menu item to the File menu with keyboard shortcut Cmd+Shift+N (or Ctrl+Shift+N on Windows/Linux)
  • New Tauri Command: Created get_current_project_id command to safely retrieve the current project ID from a window's state
  • Window State Management: Added get_project_for_window method to WindowState for thread-safe project ID access
  • Event Handling: Added menu event handler that emits the appropriate shortcut event

Frontend (TypeScript)

  • API Integration: Added getCurrentProjectId query endpoint to the projects service
  • Shortcut Handler: Implemented handler for the 'clone-window' shortcut that:
    • Gets the current project ID from the active window
    • Opens a new window with the same project if one exists
    • Gracefully does nothing if no project is currently open

Behavior

The menu item appears between "Clone Repository..." and the existing separator in the File menu. When activated:

  • With an open project: Creates a new window displaying the same project
  • Without a project: Fails silently (no error messages or dialogs)

This implementation reuses the existing open_project_in_window infrastructure, ensuring consistency with the current window management system.

Testing

The feature can be tested by:

  1. Opening a project in GitButler
  2. Using either the File menu → "Clone Window" or the keyboard shortcut Cmd+Shift+N
  3. Verifying that a new window opens with the same project
  4. Testing the edge case where no project is open (should do nothing)

Fixes the request to add window cloning functionality to the File menu while maintaining the application's existing patterns and error handling approach.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

@Copilot Copilot AI assigned Copilot and Byron Sep 12, 2025
Copy link

vercel bot commented Sep 12, 2025

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

1 Skipped Deployment
Project Deployment Preview Comments Updated (UTC)
gitbutler-web Skipped Skipped Sep 12, 2025 7:53am

@Copilot Copilot AI changed the title [WIP] In the File menu, add a Clone Window menu item that opens another Window on the currently opened project. It's OK if that fails if there is no project available yet. Add "Clone Window" menu item to File menu Sep 12, 2025
@Copilot Copilot AI requested a review from Byron September 12, 2025 06:10
Copilot finished work on behalf of Byron September 12, 2025 06:10
@github-actions github-actions bot added rust Pull requests that update Rust code @gitbutler/desktop labels Sep 12, 2025
@Byron Byron force-pushed the copilot/fix-787f4637-292c-4776-af52-91488a113bc4 branch from 46896bd to 5fef8bc Compare September 12, 2025 06:54
@Byron Byron marked this pull request as ready for review September 12, 2025 06:54
@Byron Byron requested a review from krlvi September 12, 2025 06:54
@Byron
Copy link
Collaborator

Byron commented Sep 12, 2025

Screen.Recording.2025-09-12.at.08.54.05.mov

The feature originated on Discord where it was requested that we make the multi-window feature more accessible. I thought the idea of having a menu item for that is nice (also `Cmd+Shift+N). This might also force us to cleanup FS event handling, right now GB doesn't respond to many changes that it needs to respond to, particularly in single-branch mode.

Handing it off to @krlvi and @PavelLaptev to see if this feature fits at all.

@Byron Byron force-pushed the copilot/fix-787f4637-292c-4776-af52-91488a113bc4 branch from 5fef8bc to 88e7da6 Compare September 12, 2025 07:53
@nshcr
Copy link
Contributor

nshcr commented Sep 12, 2025

@Byron Thanks for turning my Discord suggestion into a PR!

I think once this PR makes multi-window support more visible, it would also be useful if the macOS Dock could show the open windows when right-clicking the app icon.

I did a quick check though, and it looks like Tauri doesn't currently provide a macOS Dock API similar to Electron's (https://www.electronjs.org/docs/latest/tutorial/macos-dock). I even saw Pavel in the related issue here (tauri-apps/tauri#2358)...
So I guess this feature might have to wait for upstream support.

Another thing I wanted to mention is window title. Right now GitButler doesn't update the window title with the current project, so when switching between windows with something like alt-tab (https://github.com/lwouis/alt-tab-macos), they all just show up as "GitButler - GitButler" (App name - Window title).
It might be worth supporting dynamic updates to the title when switching projects, though that also raises the question of how to distinguish between multiple windows of the same project.

This isn't directly tied to the PR, since even without multi-window support, having proper window title would already be useful. I think it could be worth its own PR.

@Byron
Copy link
Collaborator

Byron commented Sep 12, 2025

So I guess this feature might have to wait for upstream support.

We are planning on also creating an Electron release :) - that should be able to have all the features eventually.

This isn't directly tied to the PR, since even without multi-window support, having proper window title would already be useful. I think it could be worth its own PR.

I see, thanks again. My guess is that we will tackle this naturally once we moved to Electron and work on this specifically. For now it's nothing more than a useful hack for convenience.

@Byron Byron requested a review from PavelLaptev September 17, 2025 03:15
@Byron
Copy link
Collaborator

Byron commented Sep 17, 2025

I invited @PavelLaptev as well to see if this or something like it is viable for inclusion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@gitbutler/desktop rust Pull requests that update Rust code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants