Add multiple conversation windows support#9
Add multiple conversation windows support#9jasonkneen wants to merge 2 commits intotkattkat:mainfrom
Conversation
jasonkneen
commented
Dec 8, 2025
- 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
There was a problem hiding this comment.
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
mainWindowtomainWindowsarray with window lifecycle management - Added window management IPC handlers (
new-window,get-window-count) and UI controls - Implemented event-based message routing using
event.senderto 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; |
There was a problem hiding this comment.
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.
| return mainWindows.filter(w => !w.isDestroyed()).length; | |
| return mainWindows.length; |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
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 ) |