Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 36 additions & 2 deletions ui/desktop/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions ui/desktop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@
"dotenv": "^16.4.5",
"electron-log": "^5.2.2",
"electron-squirrel-startup": "^1.0.1",
"electron-window-state": "^5.0.3",
"express": "^4.21.1",
"framer-motion": "^11.11.11",
"lodash": "^4.17.21",
Expand Down
26 changes: 14 additions & 12 deletions ui/desktop/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import {
import * as crypto from 'crypto';
import * as electron from 'electron';
import * as yaml from 'yaml';
import windowStateKeeper from 'electron-window-state';

// Define temp directory for pasted images
const gooseTempDir = path.join(app.getPath('temp'), 'goose-pasted-images');
Expand Down Expand Up @@ -414,13 +415,21 @@ const createChat = async (
goosedProcess = newGoosedProcess;
}

// Load and manage window state
const mainWindowState = windowStateKeeper({
defaultWidth: 750,
defaultHeight: 800,
});

const mainWindow = new BrowserWindow({
titleBarStyle: process.platform === 'darwin' ? 'hidden' : 'default',
trafficLightPosition: process.platform === 'darwin' ? { x: 16, y: 20 } : undefined,
vibrancy: process.platform === 'darwin' ? 'window' : undefined,
frame: process.platform === 'darwin' ? false : true,
width: 750,
height: 800,
x: mainWindowState.x,
y: mainWindowState.y,
width: mainWindowState.width,
height: mainWindowState.height,
minWidth: 650,
resizable: true,
transparent: false,
Expand All @@ -444,6 +453,9 @@ const createChat = async (
},
});

// Let windowStateKeeper manage the window
mainWindowState.manage(mainWindow);

// Enable spellcheck / right and ctrl + click on mispelled word
//
// NOTE: We could use webContents.session.availableSpellCheckerLanguages to include
Expand Down Expand Up @@ -531,18 +543,8 @@ const createChat = async (
: `?view=${encodeURIComponent(viewType)}`;
}

const primaryDisplay = electron.screen.getPrimaryDisplay();
const { width } = primaryDisplay.workAreaSize;

// Increment window counter to track number of windows
const windowId = ++windowCounter;
const direction = windowId % 2 === 0 ? 1 : -1; // Alternate direction
const initialOffset = 50;

// Set window position with alternating offset strategy
const baseXPosition = Math.round(width / 2 - mainWindow.getSize()[0] / 2);
const xOffset = direction * initialOffset * Math.floor(windowId / 2);
mainWindow.setPosition(baseXPosition + xOffset, 100);

if (MAIN_WINDOW_VITE_DEV_SERVER_URL) {
mainWindow.loadURL(`${MAIN_WINDOW_VITE_DEV_SERVER_URL}${queryParams}`);
Expand Down
Loading