Skip to content

Add multiple conversation windows support#9

Open
jasonkneen wants to merge 2 commits intotkattkat:mainfrom
jasonkneen:claude/multiple-windows-01WDijWuk2DooQ8GUnK8N4D9
Open

Add multiple conversation windows support#9
jasonkneen wants to merge 2 commits intotkattkat:mainfrom
jasonkneen:claude/multiple-windows-01WDijWuk2DooQ8GUnK8N4D9

Conversation

@jasonkneen
Copy link
Contributor

  • Change from single mainWindow to array of mainWindows
  • Add createMainWindow function that returns new window and tracks in array
  • Add getMainWindow helper to find focused or first window
  • Add IPC handlers for new-window and get-window-count
  • Add New Window button in sidebar header
  • Add Cmd/Ctrl+Shift+N keyboard shortcut for new window
  • Route message streaming to correct sender window
  • Each window operates independently with its own conversation

- Change from single mainWindow to array of mainWindows
- Add createMainWindow function that returns new window and tracks in array
- Add getMainWindow helper to find focused or first window
- Add IPC handlers for new-window and get-window-count
- Add New Window button in sidebar header
- Add Cmd/Ctrl+Shift+N keyboard shortcut for new window
- Route message streaming to correct sender window
- Each window operates independently with its own conversation
@jasonkneen jasonkneen requested a review from tkattkat as a code owner December 8, 2025 09:44
Copilot AI review requested due to automatic review settings December 8, 2025 09:44
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds support for multiple conversation windows, allowing users to have several independent chat sessions open simultaneously. It converts the single mainWindow architecture to a mainWindows array with proper window tracking and message routing.

Key changes:

  • Converted from single mainWindow to mainWindows array with window lifecycle management
  • Added window management IPC handlers (new-window, get-window-count) and UI controls
  • Implemented event-based message routing using event.sender to ensure streaming responses reach the correct window

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
src/main.ts Refactored window management from single to array, added createMainWindow() return value, getMainWindow() helper, window management IPC handlers, and routed message streaming to event.sender
src/preload.ts Exposed newWindow() and getWindowCount() APIs to renderer process
src/renderer/main.ts Added type declarations and event listeners for new window button and Cmd/Ctrl+Shift+N keyboard shortcut
static/index.html Added new window button with icon in sidebar header
Comments suppressed due to low confidence (1)

src/main.ts:614

  • The single instance lock conflicts with the new multiple windows feature. The app.requestSingleInstanceLock() prevents users from opening multiple instances of the application, but this PR adds the ability to create multiple windows within a single instance. When a user tries to launch the app a second time (e.g., from the dock/taskbar), it focuses an existing window instead of creating a new one.

Consider removing the single instance lock if users should be able to have truly independent app instances with their own multiple windows, or document that multiple windows are only available within a single app instance.

// Handle deep link on Windows (single instance)
const gotTheLock = app.requestSingleInstanceLock();
if (!gotTheLock) {
  app.quit();
} else {
  app.on('second-instance', () => {
    const mainWindow = getMainWindow();
    if (mainWindow) {
      if (mainWindow.isMinimized()) mainWindow.restore();
      mainWindow.focus();
    }
  });
}

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

});

ipcMain.handle('get-window-count', async () => {
return mainWindows.filter(w => !w.isDestroyed()).length;
Copy link

Copilot AI Dec 8, 2025

Choose a reason for hiding this comment

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

The filtering logic mainWindows.filter(w => !w.isDestroyed()).length is duplicated from the getMainWindow() helper. This could lead to inconsistencies if the filtering logic needs to change.

Consider using the helper consistently:

ipcMain.handle('get-window-count', async () => {
  return mainWindows.length;
});

Or if you need active windows only:

ipcMain.handle('get-window-count', async () => {
  return mainWindows.filter(w => !w.isDestroyed()).length;
});

Note: Since the closed event handler already removes windows from the array (line 118), the additional isDestroyed() check may be unnecessary.

Suggested change
return mainWindows.filter(w => !w.isDestroyed()).length;
return mainWindows.length;

Copilot uses AI. Check for mistakes.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@tkattkat
Copy link
Owner

tkattkat commented Dec 8, 2025

merge conflict and the shortcut did not seem to work for me? but the rest seems good ( I would fix conflict but going to work soon )

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.

3 participants