Skip to content
Merged
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
32 changes: 21 additions & 11 deletions ui/desktop/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -499,14 +499,20 @@ if (process.platform !== 'darwin') {
handleProtocolUrl(protocolUrl, parsedUrl);
}

// Only focus existing windows for non-bot/recipe URLs
const existingWindows = BrowserWindow.getAllWindows();
if (existingWindows.length > 0) {
const mainWindow = existingWindows[0];
// Only focus existing regular windows for non-bot/recipe URLs
const regularWindows = getRegularWindows();
if (regularWindows.length > 0) {
Comment thread
Abhijay007 marked this conversation as resolved.
const mainWindow = regularWindows[0];
if (mainWindow.isMinimized()) {
mainWindow.restore();
}
mainWindow.focus();
} else if (!protocolUrl) {
app.whenReady().then(async () => {
const recentDirs = loadRecentDirs();
const openDir = recentDirs.length > 0 ? recentDirs[0] : null;
await createChat(app, { dir: openDir || undefined });
});
}
});
}
Expand Down Expand Up @@ -644,10 +650,10 @@ async function handleProtocolUrl(url: string, parsedUrl: URL) {
if (!targetWindow) return;
await processProtocolUrl(url, parsedUrl, targetWindow);
} else {
const existingWindows = BrowserWindow.getAllWindows();
const regularWindows = getRegularWindows();
let targetWindow: BrowserWindow | undefined;
if (existingWindows.length > 0) {
targetWindow = existingWindows[0];
if (regularWindows.length > 0) {
targetWindow = regularWindows[0];
if (targetWindow.isMinimized()) {
targetWindow.restore();
}
Expand Down Expand Up @@ -742,10 +748,10 @@ app.on('open-url', async (_event, url) => {
return;
}

// For extension/session URLs, send to existing window or store pending for new one
const existingWindows = BrowserWindow.getAllWindows();
if (existingWindows.length > 0) {
const targetWindow = existingWindows[0];
// For extension/session URLs, send to an existing regular window or open one
const regularWindows = getRegularWindows();
if (regularWindows.length > 0) {
const targetWindow = regularWindows[0];
if (targetWindow.isMinimized()) targetWindow.restore();
targetWindow.focus();
if (parsedUrl.hostname === 'extension' || parsedUrl.hostname === 'sessions') {
Expand Down Expand Up @@ -980,6 +986,10 @@ let appConfig = {
const windowMap = new Map<number, BrowserWindow>();
const appWindows = new Map<string, BrowserWindow>();

function getRegularWindows(): BrowserWindow[] {
return [...windowMap.values()].filter((w) => !w.isDestroyed());
}

const gooseServeLeases = new GooseServeLeaseRegistry(log);

const windowPowerSaveBlockers = new Map<number, number>(); // windowId -> blockerId
Expand Down