@linxin666/dsh-remote-web-ui 0.4.2 → 0.4.3

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 (69) hide show
  1. package/README.i18n.yaml +2 -2
  2. package/README.md +8 -6
  3. package/README.zh.md +8 -6
  4. package/lib/client.js +154 -594
  5. package/lib/client.js.map +1 -1
  6. package/lib/index.js +323 -908
  7. package/lib/types/client/RemoteEntry.d.ts.map +1 -1
  8. package/lib/types/client/RemoteEntry.js +8 -9
  9. package/lib/types/client/RemoteSettingsCard.d.ts.map +1 -1
  10. package/lib/types/client/RemoteSettingsCard.js +1 -1
  11. package/lib/types/client/index.d.ts +32 -3
  12. package/lib/types/client/index.d.ts.map +1 -1
  13. package/lib/types/client/index.js +51 -8
  14. package/lib/types/client/locales.d.ts +0 -84
  15. package/lib/types/client/locales.d.ts.map +1 -1
  16. package/lib/types/client/locales.js +0 -84
  17. package/lib/types/client/settings-entry-form.d.ts +50 -0
  18. package/lib/types/client/settings-entry-form.d.ts.map +1 -0
  19. package/lib/types/client/settings-entry-form.js +98 -0
  20. package/lib/types/index.d.ts +99 -7
  21. package/lib/types/index.d.ts.map +1 -1
  22. package/lib/types/index.js +104 -137
  23. package/lib/types/lan-bind-plan.d.ts +14 -0
  24. package/lib/types/lan-bind-plan.d.ts.map +1 -1
  25. package/lib/types/lan-bind-plan.js +16 -0
  26. package/lib/types/lan-bind.d.ts +1 -1
  27. package/lib/types/lan-bind.js +1 -1
  28. package/lib/types/mount-once.d.ts +38 -7
  29. package/lib/types/mount-once.d.ts.map +1 -1
  30. package/lib/types/mount-once.js +96 -12
  31. package/lib/types/tunnel.d.ts +60 -3
  32. package/lib/types/tunnel.d.ts.map +1 -1
  33. package/lib/types/tunnel.js +136 -3
  34. package/package.json +2 -2
  35. package/src/client/RemoteEntry.tsx +7 -9
  36. package/src/client/RemoteSettingsCard.tsx +0 -2
  37. package/src/client/index.ts +53 -9
  38. package/src/client/locales.ts +0 -84
  39. package/src/client/remote.module.css +50 -200
  40. package/src/client/settings-entry-form.ts +142 -0
  41. package/src/index.ts +156 -152
  42. package/src/lan-bind-plan.ts +22 -0
  43. package/src/lan-bind.ts +1 -1
  44. package/src/mount-once.ts +107 -13
  45. package/src/tunnel.ts +142 -3
  46. package/lib/types/client/UpdateEntry.d.ts +0 -14
  47. package/lib/types/client/UpdateEntry.d.ts.map +0 -1
  48. package/lib/types/client/UpdateEntry.js +0 -112
  49. package/lib/types/client/UpdatePanel.d.ts +0 -42
  50. package/lib/types/client/UpdatePanel.d.ts.map +0 -1
  51. package/lib/types/client/UpdatePanel.js +0 -101
  52. package/lib/types/client/update-api.d.ts +0 -29
  53. package/lib/types/client/update-api.d.ts.map +0 -1
  54. package/lib/types/client/update-api.js +0 -47
  55. package/lib/types/console-output.d.ts +0 -41
  56. package/lib/types/console-output.d.ts.map +0 -1
  57. package/lib/types/console-output.js +0 -89
  58. package/lib/types/update-routes.d.ts +0 -30
  59. package/lib/types/update-routes.d.ts.map +0 -1
  60. package/lib/types/update-routes.js +0 -47
  61. package/lib/types/update.d.ts +0 -282
  62. package/lib/types/update.d.ts.map +0 -1
  63. package/lib/types/update.js +0 -773
  64. package/src/client/UpdateEntry.tsx +0 -144
  65. package/src/client/UpdatePanel.tsx +0 -256
  66. package/src/client/update-api.ts +0 -49
  67. package/src/console-output.ts +0 -97
  68. package/src/update-routes.ts +0 -65
  69. package/src/update.ts +0 -915
@@ -5,38 +5,122 @@
5
5
  * the loader accepts a standalone install of the same package side by side;
6
6
  * without this guard the second instance would still re-register the same
7
7
  * webserver routes, tools, settings namespaces, and system-prompt sections
8
- * and fail the boot. mountOnce makes the second host apply a no-op for the
9
- * lifetime of the first instance (the browser half is already deduped by
10
- * package name in the client module host).
8
+ * and fail the boot. mountOnce makes a mount of an already-mounted package a
9
+ * no-op for as long as the first instance lives (the browser half is already
10
+ * deduped by package name in the client module host).
11
+ *
12
+ * A no-op is only safe while the holder is ALIVE. The holder can be disposed
13
+ * long after the refused mount ran its course: the Host reloads a profile by
14
+ * creating the new loader entries before the old ones are torn down (a
15
+ * plugin-manager enable/disable/install write, a settings-driven row reload,
16
+ * HMR), so the new aggregate shell entry mounts its family plugin while the
17
+ * previous entry still owns the name. Dropping that refused mount lost the
18
+ * plugin for good - the previous entry then disposed its own mount, releasing
19
+ * the name with nobody left to take it, and the family row stayed listed as
20
+ * active while its host routes 404ed (the task-board panel showed
21
+ * "board.hostError.notMounted", no degraded record appeared, and only a Host
22
+ * restart recovered it).
23
+ *
24
+ * The refused mount is therefore QUEUED, not dropped, and replayed the moment
25
+ * the holder releases the name - if the waiting fiber is still alive then. The
26
+ * single-instance guarantee is unchanged: exactly one mount is live per
27
+ * package name, and the replay re-enters the guard so a later mount still
28
+ * dedupes against it.
11
29
  *
12
30
  * The registry rides a global symbol so two module instances of the same
13
- * package (npm copy vs repository link) still share one verdict. cordis
14
- * `ctx.effect` runs its callback immediately and treats the callback's
31
+ * package (npm copy vs repository link) still share one verdict. That symbol
32
+ * is a CROSS-REPOSITORY contract, not this file's private state: the four
33
+ * satellite packages (dsh-skins / dsh-pet / dsh-presets /
34
+ * dsh-community-plugins) are separate repositories carrying their own copy of
35
+ * this guard, rebuilt on their own schedule, so the value under `MOUNTED`
36
+ * must keep the shape every published copy reads (a `Set` of package names
37
+ * with `has`/`add`/`delete`). The wait queues this guard added therefore live
38
+ * under their own additive key, and the registry reads back a `Set` even when
39
+ * some other build left a different value there. Changing `MOUNTED`'s shape
40
+ * in place broke that contract once: a satellite's legacy copy created a
41
+ * `Set`, the family's new copy read it as a `Map`, and every family row
42
+ * mounted after it failed with "claims.get is not a function".
43
+ *
44
+ * cordis `ctx.effect` runs its callback immediately and treats the callback's
15
45
  * return value as the fiber disposer, so the unmarker is returned, not run.
16
46
  */
47
+ /** Published cross-repository contract: package names currently mounted. */
17
48
  const MOUNTED = Symbol.for('dsh-web.mounted-plugins');
49
+ /** Additive key this guard owns: refused mounts waiting for the name. */
50
+ const WAITERS = Symbol.for('dsh-web.mounted-plugins.waiters');
51
+ /**
52
+ * The shared name registry, always a `Set` whatever another build stored here:
53
+ * a foreign value (an interim shape, a hand-written global) must not take every
54
+ * family plugin down with it.
55
+ * @returns the process-wide set of mounted package names.
56
+ */
18
57
  function mountedSet() {
19
58
  const registry = globalThis;
20
- return (registry[MOUNTED] ??= new Set());
59
+ const existing = registry[MOUNTED];
60
+ if (existing instanceof Set)
61
+ return existing;
62
+ const created = new Set();
63
+ registry[MOUNTED] = created;
64
+ return created;
65
+ }
66
+ /** Queue per package name for mounts refused while a holder was alive. */
67
+ function mountWaiters() {
68
+ const registry = globalThis;
69
+ return (registry[WAITERS] ??= new Map());
21
70
  }
22
71
  /**
23
72
  * Wrap a cordis plugin apply so the package runs at most once per process.
24
- * The first mount registers normally and unmarks when its fiber disposes;
25
- * any later mount of the same package name is a no-op.
73
+ * The first mount registers normally and releases the name when its fiber
74
+ * disposes; a mount refused while that name is held waits for the release and
75
+ * then runs, unless its own fiber disposes first.
26
76
  * @param packageName - npm package identity shared by every install source.
27
77
  * @param fn - the original plugin apply.
28
78
  * @returns an apply of the same shape.
29
79
  */
30
80
  export function mountOnce(packageName, fn) {
31
- return ((...args) => {
81
+ const mount = (...args) => {
32
82
  const mounted = mountedSet();
33
- if (mounted.has(packageName))
83
+ const ctx = args[0];
84
+ if (mounted.has(packageName)) {
85
+ // Another fiber (the aggregate row, a standalone install, or a copy built
86
+ // from an older revision of this guard) owns the name. Queue instead of
87
+ // dropping: dropping lost the plugin for the rest of the process when the
88
+ // holder was disposed by a reload.
89
+ const waiters = mountWaiters();
90
+ const queue = waiters.get(packageName) ?? [];
91
+ let alive = true;
92
+ const pending = {
93
+ run: () => {
94
+ if (alive)
95
+ mount(...args);
96
+ },
97
+ };
98
+ // A fiber that dies while it waits must not be replayed afterwards: its
99
+ // context is disposed and registering effects on it would throw.
100
+ ctx?.effect?.(() => () => {
101
+ alive = false;
102
+ const index = queue.indexOf(pending);
103
+ if (index >= 0)
104
+ queue.splice(index, 1);
105
+ });
106
+ queue.push(pending);
107
+ waiters.set(packageName, queue);
34
108
  return;
109
+ }
35
110
  mounted.add(packageName);
36
- const ctx = args[0];
37
111
  ctx?.effect?.(() => () => {
38
112
  mounted.delete(packageName);
113
+ const waiters = mountWaiters();
114
+ const queue = waiters.get(packageName);
115
+ if (queue === undefined)
116
+ return;
117
+ waiters.delete(packageName);
118
+ // Defer the handover one microtask so the disposing mount's own effects
119
+ // (routes, ledger, timers) are torn down before the next one registers.
120
+ for (const waiter of queue.splice(0))
121
+ queueMicrotask(() => { waiter.run(); });
39
122
  });
40
123
  return fn(...args);
41
- });
124
+ };
125
+ return mount;
42
126
  }
@@ -12,9 +12,16 @@
12
12
  *
13
13
  * The cloudflared package's Tunnel is a thin spawn wrapper; this manager
14
14
  * owns the lifecycle policy (binary readiness, URL timeout, restart
15
- * backoff) around it. All seams — the tunnel factory, binary readiness,
16
- * timers — are injectable so the whole lifecycle is unit-testable without
17
- * a real binary or network.
15
+ * backoff, and the public-URL readiness watchdog) around it. All seams — the
16
+ * tunnel factory, binary readiness, the URL probe, timers — are injectable
17
+ * so the whole lifecycle is unit-testable without a real binary or network.
18
+ *
19
+ * 'running' is not a terminal state: the connector can lose its edge
20
+ * registration while the process keeps living, which leaves a hostname that
21
+ * no longer resolves. The watchdog below probes the public URL of a running
22
+ * tunnel and reuses the crash-restart path when it stops answering, so the
23
+ * relay is re-registered against a freshly minted URL instead of proxying a
24
+ * dead one (issue #1723).
18
25
  */
19
26
  /** The observable tunnel lifecycle the settings/panel surfaces render. */
20
27
  export type TunnelPhase = 'stopped' | 'starting' | 'running' | 'failed';
@@ -68,6 +75,21 @@ export interface TunnelHandle {
68
75
  off(event: string, listener: (...args: any[]) => void): unknown;
69
76
  stop(): boolean;
70
77
  }
78
+ /**
79
+ * Probe one public tunnel URL from the host. Resolves true when the URL is
80
+ * served (any HTTP answer below 500 — a harness without credentials answers
81
+ * 401/403, which is a healthy round trip), false for a DNS failure, a refused
82
+ * connection, a timeout, or a Cloudflare 5xx (530 "Origin DNS error" / 1033)
83
+ * — the shapes a tunnel that lost its edge registration produces.
84
+ *
85
+ * The probe must never reject: the watchdog reads a rejection as a dead
86
+ * tunnel and restarts on it, so a local programming error would otherwise
87
+ * recycle working tunnels forever.
88
+ * @param url - the tunnel's public URL.
89
+ * @param timeoutMs - how long one probe may take.
90
+ * @returns whether the URL answered as a live origin.
91
+ */
92
+ export declare function probeTunnelUrl(url: string, timeoutMs: number): Promise<boolean>;
71
93
  /** Injectable seams (defaults are the real cloudflared package + node timers). */
72
94
  export interface TunnelManagerOptions {
73
95
  /** Spawn one tunnel process for the target (quick or named). */
@@ -85,6 +107,14 @@ export interface TunnelManagerOptions {
85
107
  setTimeout(fn: () => void, ms: number): unknown;
86
108
  clearTimeout(t: unknown): void;
87
109
  };
110
+ /** Probe one public URL; false means the tunnel stopped answering. */
111
+ probe?: (url: string, timeoutMs: number) => Promise<boolean>;
112
+ /** How often to probe the public URL of a running tunnel (0 disables it). */
113
+ healthCheckIntervalMs?: number;
114
+ /** Consecutive probe failures after which the tunnel is restarted. */
115
+ healthCheckFailures?: number;
116
+ /** How long one probe may take. */
117
+ probeTimeoutMs?: number;
88
118
  }
89
119
  /**
90
120
  * Probe whether the binary at `path` actually executes on this machine. The
@@ -109,6 +139,12 @@ export interface BinaryReadinessSeams {
109
139
  export declare function createBinaryReadiness(executable: string, seams?: BinaryReadinessSeams): () => Promise<void>;
110
140
  /** How many archive downloads one process may attempt before giving up. */
111
141
  export declare const MAX_BINARY_INSTALL_ATTEMPTS = 3;
142
+ /** How often a running tunnel's public URL is probed (issue #1723). */
143
+ export declare const DEFAULT_HEALTH_CHECK_INTERVAL_MS = 60000;
144
+ /** Consecutive failed probes before the tunnel is declared dead. */
145
+ export declare const DEFAULT_HEALTH_CHECK_FAILURES = 2;
146
+ /** How long one public-URL probe may take. */
147
+ export declare const DEFAULT_PROBE_TIMEOUT_MS = 10000;
112
148
  /**
113
149
  * Spawn flags for one quick target. `originHostHeader` stamps the Host the
114
150
  * local webserver sees: the plugin's phone-facing fence trusts the configured
@@ -150,6 +186,10 @@ export declare class TunnelManager {
150
186
  private readonly restartBaseMs;
151
187
  private readonly restartMaxMs;
152
188
  private readonly timer;
189
+ private readonly probe;
190
+ private readonly healthCheckIntervalMs;
191
+ private readonly healthCheckFailures;
192
+ private readonly probeTimeoutMs;
153
193
  private phase;
154
194
  private url;
155
195
  private error;
@@ -157,6 +197,8 @@ export declare class TunnelManager {
157
197
  private handle;
158
198
  private urlTimer;
159
199
  private restartTimer;
200
+ private healthTimer;
201
+ private healthFailures;
160
202
  private attempts;
161
203
  private generation;
162
204
  private stopping;
@@ -189,6 +231,21 @@ export declare class TunnelManager {
189
231
  onPhase(listener: (info: TunnelInfo) => void): () => void;
190
232
  private attempt;
191
233
  private handleUrl;
234
+ /**
235
+ * Watch the readiness of a running tunnel. cloudflared can keep its process
236
+ * (and its metrics port) alive while every edge connection is gone, leaving
237
+ * a minted hostname that no longer resolves: the manager used to report
238
+ * 'running' forever and the relay kept forwarding to that dead address, so
239
+ * the phone hit Cloudflare 1016 instead of the relay's offline page
240
+ * (issue #1723). A bounded number of consecutive probe failures ends the
241
+ * attempt through the ordinary fail/backoff path, which mints a new URL and
242
+ * re-announces the relay.
243
+ */
244
+ private startHealthWatch;
245
+ /** One probe round of the running tunnel's public URL. */
246
+ private healthCheck;
247
+ /** Cancel the readiness watchdog (teardown, restart, stop). */
248
+ private stopHealthWatch;
192
249
  private handleExit;
193
250
  private fail;
194
251
  /** Stop the current process and cancel every pending timer (no phase change). */
@@ -1 +1 @@
1
- {"version":3,"file":"tunnel.d.ts","sourceRoot":"","sources":["../../src/tunnel.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAOH,0EAA0E;AAC1E,MAAM,MAAM,WAAW,GAAG,SAAS,GAAG,UAAU,GAAG,SAAS,GAAG,QAAQ,CAAA;AAEvE;;;;;;GAMG;AACH,MAAM,MA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IAC1B,OAAO,CAAC,QAAQ,CAAI;IAGpB,OAAO,CAAC,UAAU,CAAI;IACtB,OAAO,CAAC,QAAQ,CAAQ;IACxB,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAmC;IAChE,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAwC;IAEvE;;OAEG;gBACS,OAAO,GAAE,oBAAyB;IAa9C,gCAAgC;IAChC,IAAI,IAAI,IAAI,UAAU,CAMrB;IAED;;;;;;;;;OASG;IACH,KAAK,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM,GAAG,IAAI;IAW1C,uDAAuD;IACvD,IAAI,IAAI,IAAI;IAOZ,wDAAwD;IACxD,OAAO,IAAI,IAAI;IAIf,4EAA4E;IAC5E,KAAK,CAAC,QAAQ,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,GAAG,MAAM,IAAI;IAKlD,uCAAuC;IACvC,OAAO,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,IAAI,GAAG,MAAM,IAAI;IAKzD,OAAO,CAAC,OAAO;IAqCf,OAAO,CAAC,SAAS;IAqBjB;;;;;;;;;OASG;IACH,OAAO,CAAC,gBAAgB;IAgBxB,0DAA0D;YAC5C,WAAW;IA2BzB,+DAA+D;IAC/D,OAAO,CAAC,eAAe;IAQvB,OAAO,CAAC,UAAU;IAOlB,OAAO,CAAC,IAAI;IAsBZ,iFAAiF;IACjF,OAAO,CAAC,QAAQ;IAiBhB,OAAO,CAAC,QAAQ;CAWjB"}
@@ -12,9 +12,16 @@
12
12
  *
13
13
  * The cloudflared package's Tunnel is a thin spawn wrapper; this manager
14
14
  * owns the lifecycle policy (binary readiness, URL timeout, restart
15
- * backoff) around it. All seams — the tunnel factory, binary readiness,
16
- * timers — are injectable so the whole lifecycle is unit-testable without
17
- * a real binary or network.
15
+ * backoff, and the public-URL readiness watchdog) around it. All seams — the
16
+ * tunnel factory, binary readiness, the URL probe, timers — are injectable
17
+ * so the whole lifecycle is unit-testable without a real binary or network.
18
+ *
19
+ * 'running' is not a terminal state: the connector can lose its edge
20
+ * registration while the process keeps living, which leaves a hostname that
21
+ * no longer resolves. The watchdog below probes the public URL of a running
22
+ * tunnel and reuses the crash-restart path when it stops answering, so the
23
+ * relay is re-registered against a freshly minted URL instead of proxying a
24
+ * dead one (issue #1723).
18
25
  */
19
26
  import { existsSync } from 'node:fs';
20
27
  import { spawn } from 'node:child_process';
@@ -65,6 +72,45 @@ export function namedTunnelHandle(inner, publicUrl) {
65
72
  };
66
73
  return handle;
67
74
  }
75
+ /**
76
+ * Probe one public tunnel URL from the host. Resolves true when the URL is
77
+ * served (any HTTP answer below 500 — a harness without credentials answers
78
+ * 401/403, which is a healthy round trip), false for a DNS failure, a refused
79
+ * connection, a timeout, or a Cloudflare 5xx (530 "Origin DNS error" / 1033)
80
+ * — the shapes a tunnel that lost its edge registration produces.
81
+ *
82
+ * The probe must never reject: the watchdog reads a rejection as a dead
83
+ * tunnel and restarts on it, so a local programming error would otherwise
84
+ * recycle working tunnels forever.
85
+ * @param url - the tunnel's public URL.
86
+ * @param timeoutMs - how long one probe may take.
87
+ * @returns whether the URL answered as a live origin.
88
+ */
89
+ export async function probeTunnelUrl(url, timeoutMs) {
90
+ const controller = new AbortController();
91
+ const timer = setTimeout(() => { controller.abort(); }, timeoutMs);
92
+ try {
93
+ const response = await fetch(url, {
94
+ method: 'GET',
95
+ redirect: 'manual',
96
+ cache: 'no-store',
97
+ signal: controller.signal,
98
+ });
99
+ // Drain so the connection is reusable instead of half-read.
100
+ await response.body?.cancel().catch(() => undefined);
101
+ return response.status < 500;
102
+ }
103
+ catch {
104
+ return false;
105
+ }
106
+ finally {
107
+ clearTimeout(timer);
108
+ }
109
+ }
110
+ /** Default probe: the real network round trip. */
111
+ async function defaultProbe(url, timeoutMs) {
112
+ return await probeTunnelUrl(url, timeoutMs);
113
+ }
68
114
  /** Time box for the `--version` probe that validates a staged binary. */
69
115
  const BINARY_PROBE_TIMEOUT_MS = 10_000;
70
116
  /**
@@ -128,6 +174,12 @@ export function createBinaryReadiness(executable, seams = {}) {
128
174
  }
129
175
  /** How many archive downloads one process may attempt before giving up. */
130
176
  export const MAX_BINARY_INSTALL_ATTEMPTS = 3;
177
+ /** How often a running tunnel's public URL is probed (issue #1723). */
178
+ export const DEFAULT_HEALTH_CHECK_INTERVAL_MS = 60_000;
179
+ /** Consecutive failed probes before the tunnel is declared dead. */
180
+ export const DEFAULT_HEALTH_CHECK_FAILURES = 2;
181
+ /** How long one public-URL probe may take. */
182
+ export const DEFAULT_PROBE_TIMEOUT_MS = 10_000;
131
183
  /** The readiness policy the manager uses by default: the package's real binary path. */
132
184
  const defaultBinaryReadiness = createBinaryReadiness(bin);
133
185
  /** Default binary readiness: keep a working platform binary at `bin`. */
@@ -216,6 +268,10 @@ export class TunnelManager {
216
268
  restartBaseMs;
217
269
  restartMaxMs;
218
270
  timer;
271
+ probe;
272
+ healthCheckIntervalMs;
273
+ healthCheckFailures;
274
+ probeTimeoutMs;
219
275
  phase = 'stopped';
220
276
  url;
221
277
  error;
@@ -223,6 +279,8 @@ export class TunnelManager {
223
279
  handle;
224
280
  urlTimer;
225
281
  restartTimer;
282
+ healthTimer;
283
+ healthFailures = 0;
226
284
  attempts = 0;
227
285
  // Generation counter: a stale ensureBinary resolution from an earlier
228
286
  // start() must not spawn a second handle after a stop/start cycle.
@@ -240,6 +298,10 @@ export class TunnelManager {
240
298
  this.restartBaseMs = options.restartBaseMs ?? 5_000;
241
299
  this.restartMaxMs = options.restartMaxMs ?? 60_000;
242
300
  this.timer = options.timer ?? nodeTimer;
301
+ this.probe = options.probe ?? defaultProbe;
302
+ this.healthCheckIntervalMs = options.healthCheckIntervalMs ?? DEFAULT_HEALTH_CHECK_INTERVAL_MS;
303
+ this.healthCheckFailures = options.healthCheckFailures ?? DEFAULT_HEALTH_CHECK_FAILURES;
304
+ this.probeTimeoutMs = options.probeTimeoutMs ?? DEFAULT_PROBE_TIMEOUT_MS;
243
305
  }
244
306
  /** The current status frame. */
245
307
  get info() {
@@ -342,6 +404,9 @@ export class TunnelManager {
342
404
  this.error = undefined;
343
405
  this.attempts = 0;
344
406
  this.setPhase('running');
407
+ // The URL is out; from here the connector can still lose its edge
408
+ // registration without the process exiting, so readiness is supervised.
409
+ this.startHealthWatch(value);
345
410
  for (const listener of this.urlListeners) {
346
411
  try {
347
412
  listener(value);
@@ -351,6 +416,72 @@ export class TunnelManager {
351
416
  }
352
417
  }
353
418
  }
419
+ /**
420
+ * Watch the readiness of a running tunnel. cloudflared can keep its process
421
+ * (and its metrics port) alive while every edge connection is gone, leaving
422
+ * a minted hostname that no longer resolves: the manager used to report
423
+ * 'running' forever and the relay kept forwarding to that dead address, so
424
+ * the phone hit Cloudflare 1016 instead of the relay's offline page
425
+ * (issue #1723). A bounded number of consecutive probe failures ends the
426
+ * attempt through the ordinary fail/backoff path, which mints a new URL and
427
+ * re-announces the relay.
428
+ */
429
+ startHealthWatch(url) {
430
+ this.stopHealthWatch();
431
+ // A phase listener may have stopped the tunnel or replaced its target
432
+ // while this URL was being announced; only a live running phase schedules.
433
+ if (this.stopping || this.phase !== 'running')
434
+ return;
435
+ if (this.healthCheckIntervalMs <= 0 || this.healthCheckFailures <= 0)
436
+ return;
437
+ this.healthFailures = 0;
438
+ const schedule = () => {
439
+ this.healthTimer = this.timer.setTimeout(() => {
440
+ this.healthTimer = undefined;
441
+ void this.healthCheck(url);
442
+ }, this.healthCheckIntervalMs);
443
+ };
444
+ schedule();
445
+ }
446
+ /** One probe round of the running tunnel's public URL. */
447
+ async healthCheck(url) {
448
+ // The tunnel may have been stopped, failed, or replaced while the probe
449
+ // was in flight; only a still-running tunnel toward this same URL is
450
+ // judged by the result.
451
+ if (this.stopping || this.phase !== 'running' || this.url !== url)
452
+ return;
453
+ let alive = false;
454
+ try {
455
+ alive = await this.probe(url, this.probeTimeoutMs);
456
+ }
457
+ catch {
458
+ alive = false;
459
+ }
460
+ if (this.stopping || this.phase !== 'running' || this.url !== url)
461
+ return;
462
+ if (alive) {
463
+ this.healthFailures = 0;
464
+ }
465
+ else {
466
+ this.healthFailures += 1;
467
+ if (this.healthFailures >= this.healthCheckFailures) {
468
+ this.fail('the tunnel stopped answering on its public URL');
469
+ return;
470
+ }
471
+ }
472
+ this.healthTimer = this.timer.setTimeout(() => {
473
+ this.healthTimer = undefined;
474
+ void this.healthCheck(url);
475
+ }, this.healthCheckIntervalMs);
476
+ }
477
+ /** Cancel the readiness watchdog (teardown, restart, stop). */
478
+ stopHealthWatch() {
479
+ if (this.healthTimer !== undefined) {
480
+ this.timer.clearTimeout(this.healthTimer);
481
+ this.healthTimer = undefined;
482
+ }
483
+ this.healthFailures = 0;
484
+ }
354
485
  handleExit() {
355
486
  // The exit handler is detached during teardown, so reaching this point
356
487
  // means an unexpected death: fail the current phase and schedule a retry.
@@ -371,6 +502,7 @@ export class TunnelManager {
371
502
  this.timer.clearTimeout(this.urlTimer);
372
503
  this.urlTimer = undefined;
373
504
  }
505
+ this.stopHealthWatch();
374
506
  this.setPhase('failed');
375
507
  this.attempts += 1;
376
508
  const delay = Math.min(this.restartBaseMs * 2 ** (this.attempts - 1), this.restartMaxMs);
@@ -382,6 +514,7 @@ export class TunnelManager {
382
514
  /** Stop the current process and cancel every pending timer (no phase change). */
383
515
  teardown() {
384
516
  this.stopping = true;
517
+ this.stopHealthWatch();
385
518
  if (this.urlTimer !== undefined) {
386
519
  this.timer.clearTimeout(this.urlTimer);
387
520
  this.urlTimer = undefined;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@linxin666/dsh-remote-web-ui",
3
3
  "description": "Scan-to-pair remote access for the dsh web GUI that shares one official interface: a QR beside the settings button pairs phones and PCs into the same Web GUI (a portrait-touch adaptation layer for phones, full desktop on PCs) through one-time tokens and revocable device sessions, with a LAN bind toggle, optional Cloudflare tunnel, and one-click family self-update",
4
- "version": "0.4.2",
4
+ "version": "0.4.3",
5
5
  "icon": "icon.svg",
6
6
  "type": "module",
7
7
  "engines": {
@@ -53,10 +53,10 @@
53
53
  }
54
54
  },
55
55
  "dependencies": {
56
+ "@deepseek-ai/schemastery": "^3.18.4",
56
57
  "cloudflared": "^0.7.3",
57
58
  "clsx": "^2.1.1",
58
59
  "qrcode.react": "^4.2.0",
59
- "schemastery": "^3.18.0",
60
60
  "yaml": "^2.8.2",
61
61
  "zod": "^4.4.3"
62
62
  },
@@ -1,11 +1,11 @@
1
1
  /**
2
- * The sidebar remote-control seat: the update trigger plus the phone-icon
3
- * trigger beside the settings button, and the pairing panel modal. Owns the
4
- * panel behavior — token minting on open, the status SSE subscription,
5
- * stop/refresh/copy — and renders the pure {@link RemotePanel} body. The
6
- * update seat (the dsh-web self-update flow) rides the same footer row,
7
- * rendered by {@link UpdateEntry}. Component-local state per the client
8
- * stack rules: nothing here survives remounts or crosses entries.
2
+ * The sidebar remote-control seat: the phone-icon trigger beside the
3
+ * settings button, and the pairing panel modal. Owns the panel behavior —
4
+ * token minting on open, the status SSE subscription, stop/refresh/copy — and
5
+ * renders the pure {@link RemotePanel} body. The family self-update seat is
6
+ * its own plugin (dsh-update) and no longer rides this row. Component-local
7
+ * state per the client stack rules: nothing here survives remounts or crosses
8
+ * entries.
9
9
  */
10
10
  import { useCallback, useEffect, useRef, useState } from 'react'
11
11
  import { createPortal } from 'react-dom'
@@ -14,7 +14,6 @@ import type { PairingPhase } from '../pairing.ts'
14
14
  import { RemotePanel, type PanelState } from './RemotePanel.tsx'
15
15
  import { copyText, issuePair, revokePair, stopPair, type DeviceFrame, type IssueResponse, type PairStateFrame, type RelayStatusFrame, type TunnelStatusFrame } from './pair-api.ts'
16
16
  import { PhoneIcon } from './PhoneIcon.tsx'
17
- import { UpdateEntry } from './UpdateEntry.tsx'
18
17
  import css from './remote.module.css'
19
18
 
20
19
  /** Entry props: the sidebar column state and the standard locale seat. */
@@ -233,7 +232,6 @@ export function RemoteEntry({ wide, t }: RemoteEntryProps) {
233
232
  return (
234
233
  <>
235
234
  <div className={css.entryRow} data-rail={wide ? undefined : 'rail'}>
236
- <UpdateEntry wide={wide} t={t} />
237
235
  <TooltipAnchor wide={wide} label={t('entry.label')} onClick={openPanel} expanded={open} />
238
236
  </div>
239
237
  {open && createPortal((
@@ -175,8 +175,6 @@ export function RemoteSettingsCard(props: RemoteSettingsCardProps) {
175
175
  descriptionKey="settings.description"
176
176
  defaultOpen={false}
177
177
  state={state}
178
- renderChildrenWhenNotExposed
179
- hideNotExposedNotice
180
178
  onSave={props.save}
181
179
  onDiscard={props.discard}
182
180
  >
@@ -41,6 +41,7 @@ import { FenceNotice } from './FenceNotice.tsx'
41
41
  import { reportDailyHeartbeat } from './telemetry.ts'
42
42
  import { startMobileAdapt, type RemoteAdaptGlobal } from './mobile-adapt.ts'
43
43
  import { installPluginCard } from './plugin-card-seat.ts'
44
+ import { createServedEntryForm } from './settings-entry-form.ts'
44
45
 
45
46
  // Portrait-touch adaptation of the official UI: installed under the plugin
46
47
  // lifecycle (apply) so disabling the plugin in cordis patch (disabled: true)
@@ -51,8 +52,6 @@ export type { PanelState, RemotePanelProps } from './RemotePanel.tsx'
51
52
  export type { PairFailedNoticeProps } from './PairFailedNotice.tsx'
52
53
  export type { RemoteKey } from './locales.ts'
53
54
  export type { RemoteSettingsCardFace, RemoteSettingsCardState } from './RemoteSettingsCard.tsx'
54
- export type { UpdateEntryProps } from './UpdateEntry.tsx'
55
- export type { UpdatePanelProps, UpdateView } from './UpdatePanel.tsx'
56
55
 
57
56
  declare module '@deepseek-ai/dsh-client-ui-slots' {
58
57
  interface LocaleNamespaceMap {
@@ -110,22 +109,70 @@ declare module '@deepseek-ai/cordis' {
110
109
  /** Dictionary namespace owned by this plugin. */
111
110
  const NS = 'remote'
112
111
 
113
- /** Settings namespace the remote-control card edits (the Host plugin registers it). */
112
+ /**
113
+ * Settings namespace the remote-control card edits: the family identity of
114
+ * this plugin's own settings form, and the row id a standalone bundle install
115
+ * carries.
116
+ */
114
117
  const REMOTE_WEB_UI_NS = 'remote-web-ui'
118
+
119
+ /** Profile entry id the family aggregate's generated row carries. */
115
120
  const AGGREGATE_ENTRY_ID = 'web-ui-remote-web-ui'
121
+
122
+ /** Profile entry ids this package's patch rows carry, most specific first. */
116
123
  const REMOTE_WEB_UI_ENTRY_IDS: readonly string[] = [AGGREGATE_ENTRY_ID, 'ui-remote-web-ui', REMOTE_WEB_UI_NS]
117
124
 
118
- function servedEntryId(forms: ConfigForms): string {
125
+ /**
126
+ * The profile entry id this package's own row carries, for a page that serves
127
+ * no family binder.
128
+ *
129
+ * The shared describe mirror answers asynchronously, so at plugin activation it
130
+ * usually holds nothing yet — and an unanswered or empty mirror is not evidence
131
+ * of absence. Binding the bare namespace there left the card bound to an entry
132
+ * the Host does not serve, and the form is bound once per session, so the card
133
+ * never recovered (every save answered `No configurable plugin entry`). The
134
+ * aggregate row id matches nearly every deployment; only a mirror that answers
135
+ * with OTHER plugins' rows falls back to the namespace itself (the pre-0.1.7
136
+ * keying shape), because that answer is the one that actually proves this
137
+ * package's own row is not served.
138
+ * @param forms - the shared configuration forms service.
139
+ * @returns the entry id to bind.
140
+ */
141
+ export function servedEntryId(forms: ConfigForms): string {
119
142
  let served: readonly string[] | undefined
120
143
  try {
121
144
  served = forms.describe().getSnapshot().view?.namespaces.map(view => view.ns)
122
145
  } catch {
146
+ // A mirror that refuses the read is unanswered too, not absent.
123
147
  served = undefined
124
148
  }
125
- if (!served || served.length === 0) return REMOTE_WEB_UI_NS
149
+ if (served === undefined || served.length === 0) return AGGREGATE_ENTRY_ID
126
150
  return REMOTE_WEB_UI_ENTRY_IDS.find(id => served.includes(id)) ?? REMOTE_WEB_UI_NS
127
151
  }
128
152
 
153
+ /**
154
+ * Bind the settings form the remote-control card reads and writes.
155
+ *
156
+ * The family binder comes first: it resolves this package's family namespace
157
+ * onto the profile entry id the Host serves the form under, and keeps the
158
+ * loopback bridge as its own fallback. A page without that group (or one where
159
+ * its client half has not applied yet) binds through the shared forms service,
160
+ * on the entry id the describe mirror justifies and rebound as soon as the
161
+ * mirror answers — see {@link createServedEntryForm}.
162
+ * @param ctx - client context carrying the family binder and/or the shared forms service.
163
+ * @returns the form the card stages and saves through.
164
+ */
165
+ export function bindSettingsForm(ctx: ClientContext): ConfigForm<RemoteSettings> {
166
+ const family = ctx.get('webUiSettings')
167
+ if (family !== undefined && typeof family.bind === 'function') {
168
+ return family.bind<RemoteSettings>({ namespace: REMOTE_WEB_UI_NS })
169
+ }
170
+ return createServedEntryForm<RemoteSettings>({
171
+ forms: ctx.configForms,
172
+ entryIds: REMOTE_WEB_UI_ENTRY_IDS,
173
+ })
174
+ }
175
+
129
176
  /** Heartbeat cadence from a paired phone (presence + revocation liveness). */
130
177
  const HEARTBEAT_INTERVAL_MS = 10_000
131
178
 
@@ -204,10 +251,7 @@ export function apply(ctx: ClientContext): void {
204
251
  // shared form (natively, or over its loopback bridge); without that group the
205
252
  // namespace IS the owning entry id, so the official service is addressed
206
253
  // directly.
207
- const family = ctx.get('webUiSettings')
208
- const settingsForm: ConfigForm<RemoteSettings> = family !== undefined && typeof family.bind === 'function'
209
- ? family.bind<RemoteSettings>({ namespace: REMOTE_WEB_UI_NS })
210
- : ctx.configForms.get<RemoteSettings>(servedEntryId(ctx.configForms))
254
+ const settingsForm: ConfigForm<RemoteSettings> = bindSettingsForm(ctx)
211
255
  const enabled = (): boolean => {
212
256
  const snapshot = settingsForm.getSnapshot()
213
257
  return snapshot.status === 'ready'