Skip to content

Commit

Permalink
add window back in
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelneale committed Jan 15, 2025
1 parent b73ab5b commit 6c906a4
Showing 1 changed file with 35 additions and 3 deletions.
38 changes: 35 additions & 3 deletions ui/desktop/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,6 @@ const createChat = async (app, query?: string, dir?: string, version?: string) =
windowMap.set(windowId, mainWindow);
mainWindow.on('closed', () => {
windowMap.delete(windowId);
});

mainWindow.on('closed', () => {
if (goosedProcess) {
goosedProcess?.kill();
}
Expand All @@ -213,6 +210,7 @@ const createTray = () => {
const tray = new Tray(iconPath);

const contextMenu = Menu.buildFromTemplate([
{ label: 'Show Window', click: showWindow },
{ type: 'separator' },
{ label: 'Quit', click: () => app.quit() }
]);
Expand All @@ -221,6 +219,40 @@ const createTray = () => {
tray.setContextMenu(contextMenu);
};

const showWindow = () => {
const windows = BrowserWindow.getAllWindows();

if (windows.length === 0) {
log.info("No windows are currently open.");
return;
}

// Define the initial offset values
const initialOffsetX = 30;
const initialOffsetY = 30;

// Iterate over all windows
windows.forEach((win, index) => {
const currentBounds = win.getBounds();
const newX = currentBounds.x + initialOffsetX * index;
const newY = currentBounds.y + initialOffsetY * index;

win.setBounds({
x: newX,
y: newY,
width: currentBounds.width,
height: currentBounds.height,
});

if (!win.isVisible()) {
win.show();
}

win.focus();
});
};


const buildRecentFilesMenu = () => {
const recentDirs = loadRecentDirs();
return recentDirs.map(dir => ({
Expand Down

0 comments on commit 6c906a4

Please sign in to comment.