aegis-desktop 1.0.20 → 1.0.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -94,7 +94,7 @@ const UNITS = Object.freeze([
94
94
  * (`tools/desktop-seal.mjs` in the source tree, `tools/obfuscate-faces.mjs`
95
95
  * after obfuscation), never by hand.
96
96
  */
97
- const SEALED = '1a861aa90f27252a86d2082280d26e4104832ee92c0cf0768a88ec52dac62347';
97
+ const SEALED = '655b64f305a1248ee6ce9b0e79b27338d13b59b2707737715a873ba8fdc59161';
98
98
 
99
99
  /**
100
100
  * Ask the question. Never throws — a check that can break the program it is
package/main.js CHANGED
@@ -3514,14 +3514,27 @@ function registerUpdateIpc(ipcMain, updateManager) {
3514
3514
  return dispatch;
3515
3515
  }
3516
3516
 
3517
- /** Send a no-payload ping to whichever window currently has focus (falling
3518
- * back to the first open window so a menu click still does something when
3519
- * triggered via a global accelerator with no window focused, e.g. right
3520
- * after 'activate' on mac). Used for the two accelerators that have no
3521
- * built-in Electron role — "new chat" and "search" are renderer state, not
3522
- * something main.js can act on directly. */
3523
- function sendToFocusedWindow(BrowserWindow, channel) {
3524
- const win = BrowserWindow.getFocusedWindow() || BrowserWindow.getAllWindows()[0];
3517
+ /** Resolver for "the window app-level events belong to" — the main window.
3518
+ * Assigned by bootstrap() (it owns mainWindowRef/quickWin), `null` before
3519
+ * that. The menu builder and the 'open-url' handler run outside bootstrap's
3520
+ * closure, so they go through here instead of guessing from focus alone:
3521
+ * the quick launcher is a separate frameless window and DOES take focus, so
3522
+ * `getFocusedWindow()` alone would hand a deep link or a Cmd+N to a window
3523
+ * that doesn't understand the channel. */
3524
+ let resolveTargetWindow = null;
3525
+
3526
+ /** Send a no-payload ping to the app's main window. Used for the menu
3527
+ * accelerators that have no built-in Electron role — "new chat", "search",
3528
+ * export, authorship, Drive backup are renderer state, not something main.js
3529
+ * can act on directly. Falls back to the focused window and then to any
3530
+ * non-launcher window so a menu click still does something when the main
3531
+ * window is momentarily absent. */
3532
+ function sendToAppWindow(BrowserWindow, channel) {
3533
+ const resolved = typeof resolveTargetWindow === 'function' ? resolveTargetWindow() : null;
3534
+ const win =
3535
+ resolved && !resolved.isDestroyed()
3536
+ ? resolved
3537
+ : BrowserWindow.getFocusedWindow() || BrowserWindow.getAllWindows()[0];
3525
3538
  if (win && !win.isDestroyed()) win.webContents.send(channel);
3526
3539
  }
3527
3540
 
@@ -3572,12 +3585,12 @@ function buildAppMenu({ app, Menu, BrowserWindow, updateManager, loggedIn }) {
3572
3585
  const newChatItem = {
3573
3586
  label: 'New Chat',
3574
3587
  accelerator: 'CmdOrCtrl+N',
3575
- click: () => sendToFocusedWindow(BrowserWindow, MENU_NEW_CHAT_CHANNEL),
3588
+ click: () => sendToAppWindow(BrowserWindow, MENU_NEW_CHAT_CHANNEL),
3576
3589
  };
3577
3590
  const searchItem = {
3578
3591
  label: 'Search…',
3579
3592
  accelerator: 'CmdOrCtrl+K',
3580
- click: () => sendToFocusedWindow(BrowserWindow, MENU_SEARCH_CHANNEL),
3593
+ click: () => sendToAppWindow(BrowserWindow, MENU_SEARCH_CHANNEL),
3581
3594
  };
3582
3595
  // Neither item knows the open session id — that's renderer state — so, like
3583
3596
  // newChatItem/searchItem above, the click just pings the renderer, which
@@ -3587,20 +3600,20 @@ function buildAppMenu({ app, Menu, BrowserWindow, updateManager, loggedIn }) {
3587
3600
  const saveAsItem = {
3588
3601
  label: 'Save as…',
3589
3602
  accelerator: 'CmdOrCtrl+S',
3590
- click: () => sendToFocusedWindow(BrowserWindow, MENU_EXPORT_MARKDOWN_CHANNEL),
3603
+ click: () => sendToAppWindow(BrowserWindow, MENU_EXPORT_MARKDOWN_CHANNEL),
3591
3604
  };
3592
3605
  const exportSessionItem = {
3593
3606
  label: 'Export Session…',
3594
- click: () => sendToFocusedWindow(BrowserWindow, MENU_EXPORT_JSON_CHANNEL),
3607
+ click: () => sendToAppWindow(BrowserWindow, MENU_EXPORT_JSON_CHANNEL),
3595
3608
  };
3596
3609
  const fingerprintItem = {
3597
3610
  label: 'Authorship Panel…',
3598
- click: () => sendToFocusedWindow(BrowserWindow, MENU_FINGERPRINT_CHANNEL),
3611
+ click: () => sendToAppWindow(BrowserWindow, MENU_FINGERPRINT_CHANNEL),
3599
3612
  };
3600
3613
  const googleDriveItem = {
3601
3614
  label: 'Google Drive Backup…',
3602
3615
  enabled: Boolean(loggedIn),
3603
- click: () => sendToFocusedWindow(BrowserWindow, MENU_GOOGLE_DRIVE_CHANNEL),
3616
+ click: () => sendToAppWindow(BrowserWindow, MENU_GOOGLE_DRIVE_CHANNEL),
3604
3617
  };
3605
3618
 
3606
3619
  const template = [
@@ -3844,8 +3857,11 @@ function bootstrap() {
3844
3857
  event.preventDefault();
3845
3858
  const parsed = deepLink.parseDeepLinkUrl(url);
3846
3859
  if (!parsed) return;
3847
- const win = BrowserWindow.getFocusedWindow() || BrowserWindow.getAllWindows()[0];
3848
- if (win) sendDeepLinkToWindow(win, parsed);
3860
+ // Always the main window, never whichever window happens to be focused:
3861
+ // a quick-launcher popup can hold focus when the link arrives, and it has
3862
+ // no DEEP_LINK_CHANNEL handler (the deep link would be silently dropped).
3863
+ const win = typeof resolveTargetWindow === 'function' ? resolveTargetWindow() : null;
3864
+ if (win && !win.isDestroyed()) sendDeepLinkToWindow(win, parsed);
3849
3865
  else pendingDeepLink = parsed;
3850
3866
  });
3851
3867
 
@@ -4220,6 +4236,16 @@ function bootstrap() {
4220
4236
  let mainWindowRef = null;
4221
4237
  let quickWin = null;
4222
4238
 
4239
+ // Backs the module-level resolveTargetWindow() above, which the menu builder
4240
+ // and the 'open-url' handler can't otherwise reach. Reads the two refs live
4241
+ // so it keeps working across a createWindow() replacing the main window.
4242
+ resolveTargetWindow = () => {
4243
+ if (mainWindowRef && !mainWindowRef.isDestroyed()) return mainWindowRef;
4244
+ const focused = BrowserWindow.getFocusedWindow();
4245
+ if (focused && !focused.isDestroyed() && focused !== quickWin) return focused;
4246
+ return BrowserWindow.getAllWindows().find((w) => w !== quickWin) || null;
4247
+ };
4248
+
4223
4249
  function getOrCreateQuickLauncherWindow() {
4224
4250
  if (quickWin && !quickWin.isDestroyed()) return quickWin;
4225
4251
  quickWin = new BrowserWindow({
@@ -4270,9 +4296,9 @@ function bootstrap() {
4270
4296
  return quickWin;
4271
4297
  }
4272
4298
 
4273
- /** Show (or re-show) the quick launcher near the cursor. Shared by the
4274
- * toggle shortcut and the cold-launch path in app.whenReady below — both
4275
- * want the exact same placement, just a different reason for calling it. */
4299
+ /** Show (or re-show) the quick launcher near the cursor. Called only by the
4300
+ * toggle shortcut — nothing else opens the launcher (the cold-launch path
4301
+ * in app.whenReady opens the main window). */
4276
4302
  function showQuickLauncherWindow() {
4277
4303
  const win = getOrCreateQuickLauncherWindow();
4278
4304
  const cursor = screen.getCursorScreenPoint();
@@ -4476,11 +4502,12 @@ function bootstrap() {
4476
4502
  ...bounds,
4477
4503
  minWidth: 720,
4478
4504
  minHeight: 480,
4479
- // Cold launch shows the quick launcher, not this window (see
4480
- // app.whenReady below) — so this window is created hidden and shown
4481
- // explicitly by whichever path actually wants it on screen (a pushed
4482
- // quick-launcher result, the dock/'activate' fallback, a deep link).
4483
- show: false,
4505
+ // Launching the app is a request for THIS window. The quick launcher is
4506
+ // a shortcut-only surface (CmdOrCtrl+Shift+Space) and must never stand
4507
+ // in for the app's own window — an earlier cold-launch default that
4508
+ // showed the launcher instead made every plain start-up look like the
4509
+ // app had failed to open.
4510
+ show: true,
4484
4511
  backgroundColor: '#0d1117',
4485
4512
  title: 'AEGIS Desktop',
4486
4513
  icon: iconForPlatform(iconsDir, process.platform),
@@ -4678,22 +4705,14 @@ function bootstrap() {
4678
4705
  // grabs a systemwide hotkey unless the developer opted in from Settings.
4679
4706
  // Must run after 'ready' — globalShortcut throws before then.
4680
4707
  quickLauncherDispatch.setConfig(settings.quickLauncherConfig());
4681
- // Cold launch opens the quick launcher, not the full main window — the
4682
- // main window is still created (hidden; see createWindow's `show: false`)
4683
- // so it exists as a target the moment a push-to-chat, a deep link, or
4684
- // 'activate' needs one, but nothing asked for the big window yet.
4708
+ // A plain launch opens the main window. The quick launcher is armed by
4709
+ // its global shortcut only — never by starting the app.
4685
4710
  const win = createWindow();
4686
4711
  updateManager.start();
4687
4712
  // Cold-launch deep link (Linux/Windows argv, or a pre-ready macOS
4688
4713
  // 'open-url'): the window didn't exist when it was parsed above, so
4689
- // deliver it now that one does. A deep link means the user wants the
4690
- // main window specifically, so it wins over the quick launcher.
4691
- if (pendingDeepLink) {
4692
- win.show();
4693
- sendDeepLinkToWindow(win, pendingDeepLink);
4694
- } else {
4695
- showQuickLauncherWindow();
4696
- }
4714
+ // deliver it now that one does.
4715
+ if (pendingDeepLink) sendDeepLinkToWindow(win, pendingDeepLink);
4697
4716
  });
4698
4717
 
4699
4718
  app.on('window-all-closed', () => {
@@ -4704,13 +4723,15 @@ function bootstrap() {
4704
4723
  const windows = BrowserWindow.getAllWindows();
4705
4724
  if (windows.length === 0) {
4706
4725
  createWindow();
4707
- showQuickLauncherWindow();
4708
4726
  return;
4709
4727
  }
4710
- // The main window can exist but sit hidden (cold-launch default above),
4711
- // so "no window" is the wrong test for "nothing is on screen" — a dock
4712
- // click with everything hidden must still bring the launcher up.
4713
- if (!windows.some((w) => w.isVisible())) showQuickLauncherWindow();
4728
+ // Dock/taskbar activation is a request for the app's window — bring the
4729
+ // main window forward, never the quick launcher (which stays reachable
4730
+ // through its shortcut and is the only thing that should open it).
4731
+ const main = resolveTargetWindow() || windows[0];
4732
+ if (main.isMinimized()) main.restore();
4733
+ if (!main.isVisible()) main.show();
4734
+ main.focus();
4714
4735
  });
4715
4736
 
4716
4737
  // Second launch while already running: focus (and restore/show) the
@@ -4721,7 +4742,9 @@ function bootstrap() {
4721
4742
  // positional entry (the Linux argv quirk deepLink.extractDeepLinkUrl scans
4722
4743
  // for), not a named flag.
4723
4744
  app.on('second-instance', (_event, argv) => {
4724
- const win = BrowserWindow.getAllWindows()[0];
4745
+ // Not getAllWindows()[0]: with the launcher open that can be the popup, and
4746
+ // a relaunch should raise the app's real window.
4747
+ const win = resolveTargetWindow();
4725
4748
  const parsed = deepLink.parseDeepLinkArgv(argv);
4726
4749
  if (!win) {
4727
4750
  const created = createWindow();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "aegis-desktop",
3
3
  "productName": "AEGIS Desktop",
4
- "version": "1.0.20",
4
+ "version": "1.0.22",
5
5
  "description": "Thin Electron host for AEGIS — a local chat UI over the shared client/aegis.js transport. Ships transport + UI only; engine logic stays server-side.",
6
6
  "author": {
7
7
  "name": "AEGIS Code",