cicy-desktop 2.1.301 → 2.1.302

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cicy-desktop",
3
- "version": "2.1.301",
3
+ "version": "2.1.302",
4
4
  "description": "CiCy - AI-powered operating system browser",
5
5
  "main": "src/main.js",
6
6
  "bin": {
@@ -144,10 +144,10 @@
144
144
  "//optionalDependencies": "(2026-06 回调): mac/linux 改回 native cicy-code(:8008,colima 在 16G mac 上压垮内存)→ 重新内置 cicy-code-<plat> / cicy-mihomo-<plat>,localbin.fromBundle 零网络 seed(npm 仅作更新通道,带 npmmirror→npmjs 回退)。这些由 scripts/sync-runtime-deps.cjs 在 tag-push 时同步到最新版。npm 的 os/cpu 字段保证每个平台只装自己那份。Windows 仍走 docker(WSL :8009),它那份 cicy-code-windows 用不到但 bundle 着无害。",
145
145
  "optionalDependencies": {
146
146
  "electron": "41.0.3",
147
- "cicy-code-darwin-x64": "2.3.568",
148
- "cicy-code-darwin-arm64": "2.3.568",
149
- "cicy-code-linux-x64": "2.3.568",
150
- "cicy-code-linux-arm64": "2.3.568",
147
+ "cicy-code-darwin-x64": "2.3.570",
148
+ "cicy-code-darwin-arm64": "2.3.570",
149
+ "cicy-code-linux-x64": "2.3.570",
150
+ "cicy-code-linux-arm64": "2.3.570",
151
151
  "cicy-code-windows-x64": "2.3.193",
152
152
  "cicy-mihomo-darwin-x64": "1.10.4",
153
153
  "cicy-mihomo-darwin-arm64": "1.10.4",
package/src/main.js CHANGED
@@ -298,11 +298,13 @@ electronApp.on("second-instance", (_e, argv) => {
298
298
  const { openHomepage } = require("./backends/homepage-window");
299
299
  openHomepage({ activate: false }); // 再次启动 exe 只把窗口带到前台,不抢走用户正在看的团队 tab
300
300
  } catch {}
301
+ // 绝不抢焦点:second-instance 大多不是用户点的(登录自启重复拉起、deeplink、安装器/自动更新
302
+ // 重开)。只有当一个可见窗口都没有时才把最近的窗口静默显示出来(showInactive),用户正在
303
+ // 别的 app 里时不会被莫名跳到前台;想看 app 的用户点托盘/任务栏即可。
301
304
  const { BrowserWindow } = require("electron");
302
- for (const w of BrowserWindow.getAllWindows()) {
303
- if (w.isMinimized()) w.restore();
304
- w.show();
305
- w.focus();
305
+ const wins = BrowserWindow.getAllWindows();
306
+ if (!wins.some((w) => { try { return w.isVisible() && !w.isMinimized(); } catch { return false; } })) {
307
+ for (const w of wins) { try { if (w.isMinimized()) w.restore(); if (!w.isVisible()) w.showInactive(); } catch {} }
306
308
  }
307
309
  });
308
310
 
@@ -1022,12 +1022,10 @@ function registerTabBrowserTools(registerTool) {
1022
1022
  if (!m) throw new Error(`tab ${webContentsId} not found`);
1023
1023
  const success = m.activate(webContentsId);
1024
1024
  if (success) {
1025
- try {
1026
- if (process.platform === "darwin") app.focus({ steal: true });
1027
- if (m.win.isMinimized()) m.win.restore();
1028
- m.win.show();
1029
- m.win.focus();
1030
- } catch (e) {}
1025
+ // agent 驱动的切标签:只切视图、静默保证窗口可见,绝不从用户当前 app 抢焦点
1026
+ // (之前这里 show()+focus() + mac app.focus({steal:true}) 会让 cicy-desktop 突然跳到前台)。
1027
+ try { if (m.win.isMinimized()) m.win.restore(); } catch (e) {}
1028
+ m.surfaceQuiet();
1031
1029
  }
1032
1030
  return ok({ success, webContentsId });
1033
1031
  } catch (e) { return ok({ error: e.message }, true); }
@@ -0,0 +1,20 @@
1
+ const test = require("node:test");
2
+ const assert = require("node:assert/strict");
3
+ const fs = require("node:fs");
4
+ const path = require("node:path");
5
+ const read = (p) => fs.readFileSync(path.join(__dirname, "..", p), "utf8");
6
+
7
+ test("second-instance never steals focus: only surfaces a window when none is visible", () => {
8
+ const main = read("src/main.js");
9
+ const block = main.slice(main.indexOf('electronApp.on("second-instance"'), main.indexOf('electronApp.on("second-instance"') + 1500);
10
+ assert.doesNotMatch(block, /w\.focus\(\)/);
11
+ assert.match(block, /showInactive\(\)/);
12
+ });
13
+
14
+ test("agent-driven tab activate does not bring the window to front", () => {
15
+ const src = read("src/tools/tab-browser-tools.js");
16
+ const i = src.indexOf("const success = m.activate(webContentsId);");
17
+ const block = src.slice(i, i + 600);
18
+ assert.doesNotMatch(block, /m\.win\.focus\(\)|app\.focus\(\{ steal: true \}\)/);
19
+ assert.match(block, /m\.surfaceQuiet\(\)/);
20
+ });