@livedesk/client 0.1.87 → 0.1.89

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/README.md CHANGED
@@ -13,9 +13,11 @@ aligned.
13
13
 
14
14
  The default flow opens Google sign-in, waits for the active LiveDesk Hub
15
15
  published by the same account, and connects locally. If the Hub is not
16
- ready yet, the client keeps checking every 5 seconds instead of exiting. Omit the
17
- number for first-available placement, or pass `1` to `999` to pin this machine
18
- to a screen wall slot.
16
+ ready yet, the client keeps checking every 5 seconds instead of exiting. If a
17
+ connected Hub is replaced, the launcher also leaves the stale endpoint and
18
+ discovers the newly published Hub without another Google login. Omit the number
19
+ for first-available placement, or pass `1` to `999` to pin this machine to a
20
+ screen wall slot.
19
21
 
20
22
  On Windows, check **Start with Windows** on the connection page to reconnect this
21
23
  client automatically after reboot. The startup entry reuses the saved Google
@@ -1765,8 +1765,8 @@ async function resolveManagerFromPin(supabase, pin) {
1765
1765
  throw new Error('Enter a 6-digit LiveDesk PIN.');
1766
1766
  }
1767
1767
 
1768
- const { data, error } = await supabase.rpc('resolve_livedesk_remote_host_pin', {
1769
- p_pairing_pin: normalizedPin
1768
+ const { data, error } = await supabase.functions.invoke('livedesk-resolve-remote-host', {
1769
+ body: { pin: normalizedPin }
1770
1770
  });
1771
1771
  if (error) {
1772
1772
  throw error;
@@ -2307,7 +2307,7 @@ async function waitForManagerFromSupabase(supabase, options = {}) {
2307
2307
  }
2308
2308
  }
2309
2309
 
2310
- async function prepareLoginConnection(parsed) {
2310
+ async function prepareLoginConnection(parsed, existingConnectionPage = null) {
2311
2311
  if (parsed.logout) {
2312
2312
  rmSync(CLIENT_AUTH_PATH, { force: true });
2313
2313
  }
@@ -2331,9 +2331,9 @@ async function prepareLoginConnection(parsed) {
2331
2331
  }
2332
2332
  const savedPin = readSavedPin();
2333
2333
  let choice = null;
2334
- if (parsed.startupRun && savedSession?.access_token) {
2334
+ if ((parsed.startupRun || existingConnectionPage) && savedSession?.access_token) {
2335
2335
  choice = { type: 'google', session: savedSession };
2336
- } else if (parsed.startupRun && savedPin) {
2336
+ } else if ((parsed.startupRun || existingConnectionPage) && savedPin) {
2337
2337
  const resolved = await waitForManagerFromSavedPin(supabase, savedPin);
2338
2338
  choice = { type: 'pin', ...resolved };
2339
2339
  }
@@ -2348,7 +2348,7 @@ async function prepareLoginConnection(parsed) {
2348
2348
  savedPin
2349
2349
  });
2350
2350
  }
2351
- connectionPage = choice.connectionPage || null;
2351
+ connectionPage = existingConnectionPage || choice.connectionPage || null;
2352
2352
  if (choice.type === 'pin') {
2353
2353
  manager = choice.manager;
2354
2354
  pair = choice.pair;
@@ -2385,6 +2385,7 @@ async function prepareLoginConnection(parsed) {
2385
2385
  forwarded = upsertForwardedOption(forwarded, '--slot', slot);
2386
2386
  }
2387
2387
  if (shouldLogin) {
2388
+ forwarded = appendForwardedFlag(forwarded, '--exit-on-disconnect');
2388
2389
  forwarded = appendForwardedFlag(forwarded, '--exit-on-invalid-pair');
2389
2390
  }
2390
2391
  return {
@@ -2394,6 +2395,7 @@ async function prepareLoginConnection(parsed) {
2394
2395
  slot,
2395
2396
  connectionPage,
2396
2397
  forwarded,
2398
+ rediscoverOnDisconnect: shouldLogin,
2397
2399
  rediscoverOnInvalidPair: shouldLogin
2398
2400
  };
2399
2401
  }
@@ -2723,8 +2725,10 @@ async function main() {
2723
2725
  return;
2724
2726
  }
2725
2727
 
2728
+ let connectionPage = null;
2726
2729
  while (true) {
2727
- const prepared = await prepareLoginConnection(parsed);
2730
+ const prepared = await prepareLoginConnection(parsed, connectionPage);
2731
+ connectionPage = prepared.connectionPage || connectionPage;
2728
2732
  const fastRuntime = getFastRuntime();
2729
2733
  const useFast = shouldTryFast(prepared, fastRuntime);
2730
2734
  const updateAgentDashboard = (patch = {}) => {
@@ -2810,16 +2814,28 @@ async function main() {
2810
2814
  });
2811
2815
  });
2812
2816
  }
2813
- prepared.connectionPage?.close?.();
2814
2817
  if (result?.signal) {
2818
+ connectionPage?.close?.();
2815
2819
  process.kill(process.pid, result.signal);
2816
2820
  return;
2817
2821
  }
2818
- if (prepared.rediscoverOnInvalidPair && result?.code === EXIT_INVALID_PAIR_TOKEN) {
2819
- console.error(`LiveDesk Hub pair token changed. Refreshing Hub discovery in ${DISCOVERY_RETRY_MS}ms.`);
2822
+ if (prepared.rediscoverOnDisconnect) {
2823
+ const pairChanged = prepared.rediscoverOnInvalidPair && result?.code === EXIT_INVALID_PAIR_TOKEN;
2824
+ console.error(pairChanged
2825
+ ? `LiveDesk Hub pair token changed. Refreshing Hub discovery in ${DISCOVERY_RETRY_MS}ms.`
2826
+ : `LiveDesk Hub connection ended. Looking for the current Hub in ${DISCOVERY_RETRY_MS}ms.`);
2827
+ connectionPage?.update({
2828
+ agent: {
2829
+ requestedEngine: prepared.engine,
2830
+ state: 'reconnecting'
2831
+ },
2832
+ manager: '',
2833
+ message: 'The previous Hub is unavailable. LiveDesk is finding the current Hub automatically.'
2834
+ });
2820
2835
  await sleep(DISCOVERY_RETRY_MS);
2821
2836
  continue;
2822
2837
  }
2838
+ connectionPage?.close?.();
2823
2839
  process.exit(result?.code ?? 0);
2824
2840
  }
2825
2841
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@livedesk/client",
3
- "version": "0.1.87",
3
+ "version": "0.1.89",
4
4
  "description": "LiveDesk local remote client",
5
5
  "type": "module",
6
6
  "bin": {