relay-companion 0.1.37 → 0.1.38

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/overlay/main.cjs +58 -8
  2. package/package.json +1 -1
package/overlay/main.cjs CHANGED
@@ -1066,6 +1066,7 @@ function maybeShow({ force = false, reposition = true } = {}) {
1066
1066
  } else if (win.isVisible()) {
1067
1067
  win.hide();
1068
1068
  }
1069
+ syncTray(); // keep the tray tooltip in step with the pill's actual visibility
1069
1070
  }
1070
1071
 
1071
1072
  function refreshOverlayForActiveSpace({ force = false } = {}) {
@@ -1265,6 +1266,45 @@ function showFromTray() {
1265
1266
  trayForcedVisible = true; // an explicit click always gets the card
1266
1267
  maybeShow({ force: true });
1267
1268
  if (win && !win.isDestroyed()) win.webContents.send("openFull");
1269
+ syncTray();
1270
+ }
1271
+
1272
+ // Whether the pill card is actually on screen right now.
1273
+ function pillIsOnScreen() {
1274
+ return Boolean(win && !win.isDestroyed() && win.isVisible() && !dismissed);
1275
+ }
1276
+
1277
+ // Tray-driven hide: the counterpart to showFromTray, so the menu-bar icon TOGGLES.
1278
+ // Persists the dismissal (like the card's ✕) so it stays hidden until the icon is
1279
+ // clicked again — reachable because the tray exists whenever this runs.
1280
+ function hideFromTray() {
1281
+ setDismissed(true);
1282
+ ghostActive = false;
1283
+ trayForcedVisible = false;
1284
+ if (win && !win.isDestroyed() && win.isVisible()) win.hide();
1285
+ syncTray();
1286
+ }
1287
+
1288
+ let lastTrayToggleAt = 0;
1289
+ function toggleFromTray() {
1290
+ const now = Date.now();
1291
+ if (now - lastTrayToggleAt < 300) return; // collapse a double-click into one toggle
1292
+ lastTrayToggleAt = now;
1293
+ if (pillIsOnScreen()) hideFromTray();
1294
+ else showFromTray();
1295
+ }
1296
+
1297
+ // Keep the tooltip honest about what a click will do, so the menu bar never offers
1298
+ // to "Show Relay" while it is already open.
1299
+ let trayShownState = null;
1300
+ function syncTray() {
1301
+ if (!tray) return;
1302
+ const showing = pillIsOnScreen();
1303
+ if (showing === trayShownState) return;
1304
+ trayShownState = showing;
1305
+ try {
1306
+ tray.setToolTip(showing ? "Relay — click to hide" : "Relay — click to show");
1307
+ } catch {}
1268
1308
  }
1269
1309
 
1270
1310
  function createTray() {
@@ -1277,14 +1317,22 @@ function createTray() {
1277
1317
  }
1278
1318
  tray = new Tray(icon);
1279
1319
  trayAvailable = true;
1280
- tray.setToolTip(`Relay - click to show the pill`);
1281
- tray.setContextMenu(
1282
- Menu.buildFromTemplate([
1283
- { label: "Show Relay", click: showFromTray },
1284
- ]),
1285
- );
1286
- tray.on("click", showFromTray);
1287
- tray.on("double-click", showFromTray);
1320
+ trayShownState = null;
1321
+ syncTray();
1322
+ // NO static context menu: on macOS setting one makes a left-click open the menu
1323
+ // instead of firing 'click', which is what forced the redundant "Show Relay" item
1324
+ // even when the pill was already open. Left-click now TOGGLES directly; right-click
1325
+ // still offers a state-aware menu ("Hide Relay" when open) for discoverability.
1326
+ tray.on("click", toggleFromTray);
1327
+ tray.on("right-click", () => {
1328
+ try {
1329
+ tray.popUpContextMenu(
1330
+ Menu.buildFromTemplate([{ label: pillIsOnScreen() ? "Hide Relay" : "Show Relay", click: toggleFromTray }]),
1331
+ );
1332
+ } catch (error) {
1333
+ console.error("[overlay] tray menu failed:", error && error.message);
1334
+ }
1335
+ });
1288
1336
  }
1289
1337
 
1290
1338
  // ---- ipc -----------------------------------------------------------------
@@ -1417,6 +1465,8 @@ if (!gotSingleInstanceLock) {
1417
1465
  if (process.env.RELAY_OVERLAY_TEST === "1") {
1418
1466
  global.__relayTest = {
1419
1467
  showFromTray,
1468
+ toggleFromTray,
1469
+ pillIsOnScreen,
1420
1470
  maybeShow,
1421
1471
  refreshOverlayForActiveSpace,
1422
1472
  pollHosts,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "relay-companion",
3
- "version": "0.1.37",
3
+ "version": "0.1.38",
4
4
  "description": "Relay companion: connects local coding agents to Relay tasks, approvals, and connector tools.",
5
5
  "type": "module",
6
6
  "bin": {