@jixoai/gh-runner 0.2.5 → 0.2.6

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.
Files changed (2) hide show
  1. package/dist/main.mjs +41 -8
  2. package/package.json +1 -1
package/dist/main.mjs CHANGED
@@ -1273,7 +1273,7 @@ var TrayProjection = class {
1273
1273
  }
1274
1274
  };
1275
1275
  // src/version.ts
1276
- const APP_VERSION = "0.2.5";
1276
+ const APP_VERSION = "0.2.6";
1277
1277
  // src/window.ts
1278
1278
  const DRAIN_INTERVAL_MS = 150;
1279
1279
  const PUSH_DEBOUNCE_MS = 120;
@@ -1300,6 +1300,8 @@ var UiHost = class {
1300
1300
  #pushInFlight = false;
1301
1301
  #pushPending = false;
1302
1302
  #visible = true;
1303
+ /** 隐藏期间 isVisible 慢轮询的分频计数(150ms 滴答 ×7 ≈ 1s)。 */
1304
+ #tick = 0;
1303
1305
  constructor(fleet, webviewTray, onOpenDiag, pickPackageFile, pickRunnerDir, openExternal) {
1304
1306
  this.fleet = fleet;
1305
1307
  this.webviewTray = webviewTray;
@@ -1309,9 +1311,13 @@ var UiHost = class {
1309
1311
  this.openExternal = openExternal;
1310
1312
  }
1311
1313
  async open() {
1312
- if (this.#window) {
1314
+ if (this.#window) try {
1313
1315
  await this.#window.show();
1314
1316
  await this.#window.focus();
1317
+ } catch {
1318
+ this.#window = null;
1319
+ }
1320
+ if (this.#window) {
1315
1321
  this.#visible = true;
1316
1322
  this.#logOffsets.clear();
1317
1323
  this.#doPush();
@@ -1341,15 +1347,20 @@ var UiHost = class {
1341
1347
  await win.show();
1342
1348
  await win.setMinimumSize(720, 520);
1343
1349
  win.listen("visibleChange", (event) => {
1344
- const visible = event.payload.visible ?? true;
1345
- this.#visible = visible;
1350
+ const visible = event.payload.visible;
1351
+ this.#visible = typeof visible === "boolean" ? visible : true;
1346
1352
  if (visible) {
1347
1353
  this.#logOffsets.clear();
1348
1354
  this.#doPush();
1349
1355
  }
1350
1356
  });
1351
- this.#drainTimer = setInterval(() => void this.#drain(), DRAIN_INTERVAL_MS);
1352
- this.#drainTimer.unref?.();
1357
+ win.listen("closed", () => {
1358
+ this.#visible = false;
1359
+ });
1360
+ if (!this.#drainTimer) {
1361
+ this.#drainTimer = setInterval(() => void this.#drain(), DRAIN_INTERVAL_MS);
1362
+ this.#drainTimer.unref?.();
1363
+ }
1353
1364
  this.#flush();
1354
1365
  }
1355
1366
  push(snapshot) {
@@ -1391,7 +1402,13 @@ var UiHost = class {
1391
1402
  async #doPush() {
1392
1403
  const win = this.#window;
1393
1404
  const snap = this.#lastSnapshot;
1394
- if (!win || !snap || win.connectionDead || !this.#visible) return;
1405
+ if (!win || !snap || win.connectionDead) return;
1406
+ if (this.#visible) try {
1407
+ this.#visible = await win.isVisible();
1408
+ } catch {
1409
+ this.#visible = false;
1410
+ }
1411
+ if (!this.#visible) return;
1395
1412
  if (this.#pushInFlight) {
1396
1413
  this.#pushPending = true;
1397
1414
  return;
@@ -1413,7 +1430,10 @@ var UiHost = class {
1413
1430
  download: snap.download
1414
1431
  };
1415
1432
  await this.#evaluate(JSON.stringify(summary));
1416
- for (const inst of snap.instances) await this.#pushLogDelta(win, inst.id);
1433
+ for (const inst of snap.instances) {
1434
+ if (!this.#visible) return;
1435
+ await this.#pushLogDelta(win, inst.id);
1436
+ }
1417
1437
  } finally {
1418
1438
  this.#pushInFlight = false;
1419
1439
  if (this.#pushPending && this.#window) {
@@ -1448,6 +1468,7 @@ var UiHost = class {
1448
1468
  if (cur.length > 0) chunks.push(cur);
1449
1469
  let offset = total - allLines.length;
1450
1470
  for (const lines of chunks) {
1471
+ if (!this.#visible) return;
1451
1472
  const msg = {
1452
1473
  kind: "log",
1453
1474
  seq: ++this.#seq,
@@ -1477,6 +1498,18 @@ var UiHost = class {
1477
1498
  async #drain() {
1478
1499
  const win = this.#window;
1479
1500
  if (!win || win.connectionDead) return;
1501
+ if (!this.#visible) {
1502
+ if (++this.#tick % 7 !== 0) return;
1503
+ try {
1504
+ if (!await win.isVisible()) return;
1505
+ } catch {
1506
+ return;
1507
+ }
1508
+ this.#visible = true;
1509
+ this.#logOffsets.clear();
1510
+ this.#doPush();
1511
+ return;
1512
+ }
1480
1513
  let messages;
1481
1514
  try {
1482
1515
  messages = await win.drainIpcMessages();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jixoai/gh-runner",
3
- "version": "0.2.5",
3
+ "version": "0.2.6",
4
4
  "description": "Menu-bar (tray) manager for multiple GitHub Actions self-hosted runners: discover, register from downloaded/imported packages, start/stop, and live job-result analysis. macOS & Windows.",
5
5
  "type": "module",
6
6
  "license": "MIT",