@tangle-network/sandbox-ui 0.105.1 → 0.105.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.
@@ -37,6 +37,20 @@ function createTerminalConnectionId() {
37
37
  }
38
38
  return `terminal-${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;
39
39
  }
40
+ function interactiveIdentityKey(incarnationId, control) {
41
+ if (incarnationId === void 0 && control === void 0) return "plain";
42
+ if (incarnationId === void 0 || control === void 0) {
43
+ return `incomplete:${incarnationId ?? ""}`;
44
+ }
45
+ return [
46
+ incarnationId,
47
+ control.refDigest,
48
+ String(control.generation),
49
+ control.leaseId,
50
+ control.holderId,
51
+ control.expiresAt
52
+ ].join("\0");
53
+ }
40
54
  function usePtySession({
41
55
  apiUrl,
42
56
  token,
@@ -161,6 +175,7 @@ function usePtySession({
161
175
  }
162
176
  ws.binaryType = "arraybuffer";
163
177
  pendingWsRef.current = ws;
178
+ const isCurrentSocket = () => wsRef.current === ws || pendingWsRef.current === ws;
164
179
  let opened = false;
165
180
  let settled = false;
166
181
  const settle = (ok) => {
@@ -229,7 +244,7 @@ function usePtySession({
229
244
  wsRef.current = ws;
230
245
  };
231
246
  ws.onmessage = (ev) => {
232
- if (!mountedRef.current) return;
247
+ if (!mountedRef.current || !isCurrentSocket()) return;
233
248
  const data = ev.data;
234
249
  let text;
235
250
  if (typeof data === "string") {
@@ -240,7 +255,7 @@ function usePtySession({
240
255
  text = new TextDecoder().decode(data);
241
256
  } else {
242
257
  data.text().then((t) => {
243
- if (mountedRef.current) onDataRef.current(t);
258
+ if (mountedRef.current && isCurrentSocket()) onDataRef.current(t);
244
259
  }).catch(() => {
245
260
  });
246
261
  return;
@@ -419,6 +434,7 @@ function usePtySession({
419
434
  controlRef.current = control;
420
435
  exactAttachRequiredRef.current = incarnationId !== void 0 || control !== void 0;
421
436
  connectStreamRef.current = connectStream;
437
+ const exactIdentityKey = interactiveIdentityKey(incarnationId, control);
422
438
  const connect = useCallback(async () => {
423
439
  cleanup();
424
440
  const myGen = ++connectGenRef.current;
@@ -494,7 +510,14 @@ function usePtySession({
494
510
  setIsConnected(false);
495
511
  }
496
512
  }
497
- }, [apiUrl, providedConnectionId, cleanup, connectWs, connectStream]);
513
+ }, [
514
+ apiUrl,
515
+ providedConnectionId,
516
+ cleanup,
517
+ connectWs,
518
+ connectStream,
519
+ exactIdentityKey
520
+ ]);
498
521
  reconnectRef.current = connect;
499
522
  const resizeTerminal = useCallback(async (cols, rows) => {
500
523
  if (cols > 0) colsRef.current = cols;
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  usePtySession
3
- } from "./chunk-FW77EXKG.js";
3
+ } from "./chunk-F7LNWZQR.js";
4
4
 
5
5
  // src/terminal/terminal-view.tsx
6
6
  import "@xterm/xterm/css/xterm.css";
@@ -6,7 +6,7 @@ import {
6
6
  } from "./chunk-K4Q4E7D7.js";
7
7
  import {
8
8
  TerminalView
9
- } from "./chunk-MXQT46AZ.js";
9
+ } from "./chunk-LWSWKLI5.js";
10
10
  import {
11
11
  cn
12
12
  } from "./chunk-EI44GEQ5.js";
package/dist/hooks.js CHANGED
@@ -26,7 +26,7 @@ import {
26
26
  } from "./chunk-3GX5BSD4.js";
27
27
  import {
28
28
  usePtySession
29
- } from "./chunk-FW77EXKG.js";
29
+ } from "./chunk-F7LNWZQR.js";
30
30
  import "./chunk-CZ7CSFO4.js";
31
31
  export {
32
32
  RealtimeSessionRegistry,
package/dist/index.js CHANGED
@@ -153,7 +153,7 @@ import {
153
153
  buildUnifiedPatch,
154
154
  computeDiffStats,
155
155
  resolveLanguage
156
- } from "./chunk-NT6SCOY2.js";
156
+ } from "./chunk-X24MVW2R.js";
157
157
  import {
158
158
  FileArtifactPane,
159
159
  FilePreview,
@@ -238,10 +238,10 @@ import {
238
238
  UsageChart,
239
239
  formatPrice
240
240
  } from "./chunk-OMUIPJQZ.js";
241
- import "./chunk-MXQT46AZ.js";
241
+ import "./chunk-LWSWKLI5.js";
242
242
  import {
243
243
  usePtySession
244
- } from "./chunk-FW77EXKG.js";
244
+ } from "./chunk-F7LNWZQR.js";
245
245
  import {
246
246
  Avatar,
247
247
  AvatarFallback,
package/dist/terminal.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  DEFAULT_TERMINAL_THEME,
3
3
  TerminalView
4
- } from "./chunk-MXQT46AZ.js";
5
- import "./chunk-FW77EXKG.js";
4
+ } from "./chunk-LWSWKLI5.js";
5
+ import "./chunk-F7LNWZQR.js";
6
6
  import "./chunk-CZ7CSFO4.js";
7
7
  export {
8
8
  DEFAULT_TERMINAL_THEME,
package/dist/workbench.js CHANGED
@@ -12,12 +12,12 @@ import {
12
12
  buildUnifiedPatch,
13
13
  computeDiffStats,
14
14
  resolveLanguage
15
- } from "./chunk-NT6SCOY2.js";
15
+ } from "./chunk-X24MVW2R.js";
16
16
  import "./chunk-PZVUIUUW.js";
17
17
  import "./chunk-K4Q4E7D7.js";
18
18
  import "./chunk-OMUIPJQZ.js";
19
- import "./chunk-MXQT46AZ.js";
20
- import "./chunk-FW77EXKG.js";
19
+ import "./chunk-LWSWKLI5.js";
20
+ import "./chunk-F7LNWZQR.js";
21
21
  import "./chunk-2XPJ2XF7.js";
22
22
  import "./chunk-RQZRXKMR.js";
23
23
  import "./chunk-BGVEHENC.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tangle-network/sandbox-ui",
3
- "version": "0.105.1",
3
+ "version": "0.105.2",
4
4
  "description": "Unified UI component library for Tangle Sandbox — primitives, chat, dashboard, terminal, editor, and workspace components",
5
5
  "repository": {
6
6
  "type": "git",