@triflux/remote 10.35.1 → 10.35.2

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.
@@ -47,6 +47,8 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSPopoverDelegate {
47
47
  class WebViewController: NSViewController, WKNavigationDelegate, WKScriptMessageHandler {
48
48
  var webView: WKWebView!
49
49
  var port: String = "27888"
50
+ let canonicalPort = "27888"
51
+ var consecutiveFailures = 0
50
52
  var retryWorkItem: DispatchWorkItem?
51
53
  var onFocusComplete: (() -> Void)?
52
54
 
@@ -101,6 +103,14 @@ class WebViewController: NSViewController, WKNavigationDelegate, WKScriptMessage
101
103
 
102
104
  func webView(_ webView: WKWebView, didFailProvisionalNavigation navigation: WKNavigation!, withError error: Error) {
103
105
  logError("Failed to load: \(error.localizedDescription)")
106
+ consecutiveFailures += 1
107
+ if consecutiveFailures >= 3 && port != canonicalPort {
108
+ port = canonicalPort
109
+ consecutiveFailures = 0
110
+ logError("Switching to canonical port \(canonicalPort) after repeated failures")
111
+ loadTray()
112
+ return
113
+ }
104
114
  let retry = DispatchWorkItem { [weak self] in
105
115
  self?.loadTray()
106
116
  }
@@ -111,6 +121,7 @@ class WebViewController: NSViewController, WKNavigationDelegate, WKScriptMessage
111
121
  func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
112
122
  retryWorkItem?.cancel()
113
123
  retryWorkItem = nil
124
+ consecutiveFailures = 0
114
125
  logError("Successfully loaded URL")
115
126
  }
116
127
 
package/hub/tray.mjs CHANGED
@@ -9,12 +9,26 @@ import { existsSync, readFileSync } from "node:fs";
9
9
  import { homedir } from "node:os";
10
10
  import { dirname, join, resolve } from "node:path";
11
11
  import { fileURLToPath } from "node:url";
12
+ import { resolveHubPortForContext } from "./hub-lifecycle.mjs";
12
13
  import { IS_MAC, IS_WINDOWS } from "@triflux/core/hub/platform.mjs";
13
14
  import { ensureHubForTray } from "./tray-lifecycle.mjs";
14
15
 
15
16
  const HUB_PID_FILE = join(homedir(), ".claude", "cache", "tfx-hub", "hub.pid");
16
17
  const DEFAULT_HUB_PORT = "27888";
17
18
 
19
+ export function resolveTrayHubPort({
20
+ env = process.env,
21
+ cwd = process.cwd(),
22
+ } = {}) {
23
+ return String(
24
+ resolveHubPortForContext({
25
+ env,
26
+ cwd,
27
+ defaultPort: Number(DEFAULT_HUB_PORT),
28
+ }),
29
+ );
30
+ }
31
+
18
32
  function sleep(ms) {
19
33
  return new Promise((resolveSleep) => setTimeout(resolveSleep, ms));
20
34
  }
@@ -416,7 +430,7 @@ async function shutdown(reason = "shutdown") {
416
430
  export async function startTray() {
417
431
  if (IS_MAC) {
418
432
  const trayScript = fileURLToPath(import.meta.url);
419
- const port = process.env.TFX_HUB_PORT || DEFAULT_HUB_PORT;
433
+ const port = resolveTrayHubPort();
420
434
  const serverPath = join(dirname(trayScript), "server.mjs");
421
435
  await ensureHubForTray({ port, serverPath });
422
436
  const reaped = reapExistingMacTrayProcesses({ scriptPath: trayScript });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@triflux/remote",
3
- "version": "10.35.1",
3
+ "version": "10.35.2",
4
4
  "description": "triflux remote — team mode, psmux, MCP workers, SQLite store.",
5
5
  "type": "module",
6
6
  "main": "hub/index.mjs",