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
71 changes: 30 additions & 41 deletions app/src/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Browser modules (tabs, bookmarks, history, downloads, extensions,
* permissions, profiles, etc.) have been removed in the nuclear pivot.
* Only the core infrastructure remains: shell window, pill, HL engine,
* OAuth/identity, settings window, updater, hotkeys.
* OAuth/identity, settings page routing, updater, hotkeys.
*/

import { config as loadDotEnv } from 'dotenv';
Expand Down Expand Up @@ -72,13 +72,13 @@
import { createShellWindow } from './window';
import { createTray, refreshTrayMenu } from './tray';
// Track B — Pill + hotkeys
import { createPillWindow, togglePill, showPill, hidePill, sendToPill, setPillHeight, PILL_HEIGHT_COLLAPSED, PILL_HEIGHT_EXPANDED } from './pill';

Check warning on line 75 in app/src/main/index.ts

View workflow job for this annotation

GitHub Actions / Lint (TS)

'./pill' imported multiple times

Check warning on line 75 in app/src/main/index.ts

View workflow job for this annotation

GitHub Actions / Lint (TS)

'showPill' is defined but never used. Allowed unused vars must match /^_/u
import { createLogsWindow, attachToHub as attachLogsToHub, toggleLogs, hideLogs, getLogsWindow, showLogs, setLogsMode, updateLogsAnchor, focusLogsFollowUp } from './logsPill';
import * as takeoverOverlay from './takeoverOverlay';
import { sendSessionNotification } from './notifications';
import { registerHotkeys, unregisterHotkeys, getGlobalCmdbarAccelerator, setGlobalCmdbarAccelerator } from './hotkeys';
import { makeRequest, PROTOCOL_VERSION } from '../shared/types';

Check warning on line 80 in app/src/main/index.ts

View workflow job for this annotation

GitHub Actions / Lint (TS)

'PROTOCOL_VERSION' is defined but never used. Allowed unused vars must match /^_/u

Check warning on line 80 in app/src/main/index.ts

View workflow job for this annotation

GitHub Actions / Lint (TS)

'makeRequest' is defined but never used. Allowed unused vars must match /^_/u
import type { AgentEvent } from '../shared/types';

Check warning on line 81 in app/src/main/index.ts

View workflow job for this annotation

GitHub Actions / Lint (TS)

'AgentEvent' is defined but never used. Allowed unused vars must match /^_/u
// Identity
import { AccountStore } from './identity/AccountStore';
import { createOnboardingWindow } from './identity/onboardingWindow';
Expand All @@ -103,12 +103,10 @@
import { bootstrapHarness, harnessDir } from './hl/harness';
import { runEngine, DEFAULT_ENGINE_ID } from './hl/engines';
import { getEngine, setEngine, type EngineId } from './hl/engine';
import { forwardAgentEvent } from './pill';

Check warning on line 106 in app/src/main/index.ts

View workflow job for this annotation

GitHub Actions / Lint (TS)

'./pill' imported multiple times

Check warning on line 106 in app/src/main/index.ts

View workflow job for this annotation

GitHub Actions / Lint (TS)

'forwardAgentEvent' is defined but never used. Allowed unused vars must match /^_/u
// Session management
import { SessionManager } from './sessions/SessionManager';
import { BrowserPool } from './sessions/BrowserPool';
// Settings window (no browser-feature IPC handlers)
import { openSettingsWindow, closeSettingsWindow, getSettingsWindow } from './settings/SettingsWindow';
// Channels (WhatsApp)
import { WhatsAppAdapter } from './channels/WhatsAppAdapter';
import { ChannelRouter } from './channels/ChannelRouter';
Expand Down Expand Up @@ -205,6 +203,27 @@
const whatsAppAdapter = new WhatsAppAdapter();
const channelRouter = new ChannelRouter(sessionManager, whatsAppAdapter);

type SettingsOpenPayload = {
focusBrowserCodeProvider?: string;
};

function normalizeSettingsOpenPayload(payload: unknown): SettingsOpenPayload | undefined {
if (!payload || typeof payload !== 'object') return undefined;
const rawProvider = (payload as { focusBrowserCodeProvider?: unknown }).focusBrowserCodeProvider;
if (typeof rawProvider !== 'string') return undefined;
const providerId = rawProvider.trim();
if (!providerId || providerId.length > 80) return undefined;
return { focusBrowserCodeProvider: providerId };
}

function openSettingsInShell(payload?: SettingsOpenPayload): void {
if (!shellWindow || shellWindow.isDestroyed()) return;
shellWindow.show();
shellWindow.focus();
shellWindow.webContents.send('open-settings', payload);
}


// ---------------------------------------------------------------------------
// Shell window factory
// ---------------------------------------------------------------------------
Expand Down Expand Up @@ -1377,23 +1396,12 @@
});

// ---------------------------------------------------------------------------
// Settings window IPC
// Settings page IPC
// ---------------------------------------------------------------------------
ipcMain.handle('settings:open', (_e, payload?: { focusBrowserCodeProvider?: string }) => {
ipcMain.handle('settings:open', (_e, rawPayload?: unknown) => {
const payload = normalizeSettingsOpenPayload(rawPayload);
mainLogger.info('main.settings:open', { focusBrowserCodeProvider: payload?.focusBrowserCodeProvider });
if (shellWindow && !shellWindow.isDestroyed()) {
shellWindow.show();
shellWindow.focus();
shellWindow.webContents.send('open-settings');
if (payload?.focusBrowserCodeProvider) {
const providerId = payload.focusBrowserCodeProvider;
setTimeout(() => {
if (shellWindow && !shellWindow.isDestroyed()) {
shellWindow.webContents.send('settings:browsercode:focus-provider', { providerId });
}
}, 150);
}
}
openSettingsInShell(payload);
});

ipcMain.handle('settings:app:get-info', () => {
Expand Down Expand Up @@ -1438,29 +1446,13 @@
hidePill();
});

ipcMain.handle('pill:open-settings', (_e, payload?: { focusBrowserCodeProvider?: string }) => {
ipcMain.handle('pill:open-settings', (_e, rawPayload?: unknown) => {
const payload = normalizeSettingsOpenPayload(rawPayload);
mainLogger.info('main.pill:open-settings', { focusBrowserCodeProvider: payload?.focusBrowserCodeProvider });
if (shellWindow && !shellWindow.isDestroyed()) {
shellWindow.show();
shellWindow.focus();
shellWindow.webContents.send('open-settings');
if (payload?.focusBrowserCodeProvider) {
const providerId = payload.focusBrowserCodeProvider;
setTimeout(() => {
if (shellWindow && !shellWindow.isDestroyed()) {
shellWindow.webContents.send('settings:browsercode:focus-provider', { providerId });
}
}, 150);
}
}
openSettingsInShell(payload);
hidePill();
});

ipcMain.handle('settings:close', () => {
mainLogger.info('main.settings:close');
closeSettingsWindow();
});

// ---------------------------------------------------------------------------
// Application menu
// ---------------------------------------------------------------------------
Expand Down Expand Up @@ -1583,10 +1575,7 @@
accelerator: 'CmdOrCtrl+,',
click: () => {
mainLogger.debug('menu.openSettings');
if (shellWindow && !shellWindow.isDestroyed()) {
shellWindow.webContents.send('open-settings');
shellWindow.focus();
}
openSettingsInShell();
},
},
{ type: 'separator' },
Expand Down
146 changes: 0 additions & 146 deletions app/src/main/settings/SettingsWindow.ts

This file was deleted.

7 changes: 1 addition & 6 deletions app/src/preload/pill.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ contextBridge.exposeInMainWorld('pillAPI', {
},

/**
* Open the settings window.
* Open the settings page in the hub window.
*/
openSettings: (): void => {
log.info('preload.pill.openSettings', { message: 'Invoking pill:open-settings' });
Expand Down Expand Up @@ -266,11 +266,6 @@ contextBridge.exposeInMainWorld('electronAPI', {
log.info('preload.pill.electronAPI.settings.open', { focusBrowserCodeProvider: payload?.focusBrowserCodeProvider });
return ipcRenderer.invoke('pill:open-settings', payload);
},
onFocusBrowserCodeProvider: (handler: (providerId: string) => void): (() => void) => {
const listener = (_e: unknown, payload: { providerId: string }) => handler(payload.providerId);
ipcRenderer.on('settings:browsercode:focus-provider', listener);
return () => ipcRenderer.removeListener('settings:browsercode:focus-provider', listener);
},
browserCode: {
getStatus: (): Promise<{
keys: Record<string, { masked: string; lastModel?: string }>;
Expand Down
20 changes: 13 additions & 7 deletions app/src/preload/shell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,17 @@ import {
} from '../shared/session-schemas';
import type { AgentSession, HlEvent, TabInfo, BrowserPoolStats } from '../shared/session-schemas';

type SettingsOpenPayload = { focusBrowserCodeProvider?: string };

function normalizeSettingsOpenPayload(raw: unknown): SettingsOpenPayload | undefined {
if (!raw || typeof raw !== 'object') return undefined;
const rawProvider = (raw as { focusBrowserCodeProvider?: unknown }).focusBrowserCodeProvider;
const providerId = typeof rawProvider === 'string' ? rawProvider.trim() : '';
return providerId.length > 0 && providerId.length <= 80
? { focusBrowserCodeProvider: providerId }
: undefined;
}

contextBridge.exposeInMainWorld('electronAPI', {
shell: {
platform: process.platform,
Expand Down Expand Up @@ -50,11 +61,6 @@ contextBridge.exposeInMainWorld('electronAPI', {
},
settings: {
open: (payload?: { focusBrowserCodeProvider?: string }): Promise<void> => ipcRenderer.invoke('settings:open', payload),
onFocusBrowserCodeProvider: (handler: (providerId: string) => void): (() => void) => {
const listener = (_e: unknown, payload: { providerId: string }) => handler(payload.providerId);
ipcRenderer.on('settings:browsercode:focus-provider', listener);
return () => ipcRenderer.removeListener('settings:browsercode:focus-provider', listener);
},
apiKey: {
getMasked: (): Promise<{ present: boolean; masked: string | null }> =>
ipcRenderer.invoke('settings:api-key:get-masked'),
Expand Down Expand Up @@ -365,8 +371,8 @@ contextBridge.exposeInMainWorld('electronAPI', {
ipcRenderer.on('session-output-term', handler);
return () => ipcRenderer.removeListener('session-output-term', handler);
},
openSettings: (cb: () => void): (() => void) => {
const handler = () => cb();
openSettings: (cb: (payload?: SettingsOpenPayload) => void): (() => void) => {
const handler = (_event: unknown, rawPayload?: unknown) => cb(normalizeSettingsOpenPayload(rawPayload));
ipcRenderer.on('open-settings', handler);
return () => ipcRenderer.removeListener('open-settings', handler);
},
Expand Down
3 changes: 1 addition & 2 deletions app/src/renderer/globals.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ interface ElectronOnAPI {
sessionBrowserGone: (cb: (id: string) => void) => () => void;
sessionOutput: (cb: (id: string, event: import('./hub/types').HlEvent) => void) => () => void;
sessionOutputTerm: (cb: (id: string, bytes: string) => void) => () => void;
openSettings?: (cb: () => void) => () => void;
openSettings?: (cb: (payload?: { focusBrowserCodeProvider?: string }) => void) => () => void;
zoomChanged?: (cb: (factor: number) => void) => () => void;
whatsappQr?: (cb: (dataUrl: string) => void) => () => void;
channelStatus?: (cb: (channelId: string, status: string, detail?: string) => void) => () => void;
Expand Down Expand Up @@ -294,7 +294,6 @@ interface ElectronSettingsAppAPI {

interface ElectronSettingsAPI {
open?: (payload?: { focusBrowserCodeProvider?: string }) => Promise<void>;
onFocusBrowserCodeProvider?: (handler: (providerId: string) => void) => () => void;
apiKey: ElectronSettingsApiKeyAPI;
claudeCode?: ElectronSettingsClaudeCodeAPI;
openaiKey?: ElectronSettingsOpenAiKeyAPI;
Expand Down
Loading
Loading