tmux-ide 2.9.26 → 2.9.27

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 (47) hide show
  1. package/README.md +1 -1
  2. package/bin/cli.js +1252 -528
  3. package/package.json +2 -2
  4. package/packages/contracts/src/pane-stream.ts +9 -0
  5. package/packages/contracts/src/terminal-delivery.ts +114 -3
  6. package/packages/core/src/index.ts +1 -0
  7. package/packages/core/src/terminal-delivery-binary.ts +8 -7
  8. package/packages/core/src/terminal-delivery.ts +174 -3
  9. package/packages/core/src/terminal-partial-history.ts +152 -0
  10. package/packages/core/src/terminal-replica.ts +70 -1
  11. package/packages/daemon/dist/command-center/owner-keep-alive.js +30 -0
  12. package/packages/daemon/dist/command-center/server.js +3 -0
  13. package/packages/daemon/dist/command-center/tmux-server-attach.js +51 -0
  14. package/packages/daemon/dist/command-center/tmux-servers.js +78 -0
  15. package/packages/daemon/dist/doctor.js +4 -4
  16. package/packages/daemon/dist/lib/app-config.js +7 -0
  17. package/packages/daemon/dist/lib/node-requirement.js +20 -0
  18. package/packages/daemon/dist/lib/require-supported-node.js +8 -0
  19. package/packages/daemon/dist/lib/tmux-server-session-open.js +38 -12
  20. package/packages/daemon/dist/lib/workspace-promotion.js +4 -4
  21. package/packages/daemon/dist/native/TmuxIdeNotifier.app/Contents/Info.plist +2 -2
  22. package/packages/daemon/dist/native/TmuxIdeNotifier.app/Contents/MacOS/tmux-ide-notifier +0 -0
  23. package/packages/daemon/dist/native/TmuxIdeNotifier.app/Contents/Resources/Assets.car +0 -0
  24. package/packages/daemon/dist/native/TmuxIdeNotifier.app/Contents/_CodeSignature/CodeResources +2 -2
  25. package/packages/daemon/dist/server/pane-stream-upgrade.js +39 -1
  26. package/packages/daemon/dist/terminal/pane-stream/pane-stream-websocket.js +14 -0
  27. package/packages/daemon/dist/terminal/session-runtime/registry.js +1 -0
  28. package/packages/daemon/dist/terminal/session-runtime/terminal-delivery-hub.js +465 -42
  29. package/packages/daemon/dist/tui/mirror/open-tui-workspace-runtime-port.js +76 -2
  30. package/packages/daemon/dist/tui/mirror/theme.js +8 -1
  31. package/packages/daemon/src/command-center/attach-window-rule.cases.json +84 -0
  32. package/packages/daemon/src/command-center/owner-keep-alive.ts +38 -0
  33. package/packages/daemon/src/command-center/server.ts +3 -0
  34. package/packages/daemon/src/command-center/tmux-server-attach.ts +75 -0
  35. package/packages/daemon/src/command-center/tmux-servers.ts +84 -0
  36. package/packages/daemon/src/doctor.ts +4 -4
  37. package/packages/daemon/src/lib/app-config.ts +15 -0
  38. package/packages/daemon/src/lib/node-requirement.ts +22 -0
  39. package/packages/daemon/src/lib/require-supported-node.ts +9 -0
  40. package/packages/daemon/src/lib/tmux-server-session-open.ts +53 -15
  41. package/packages/daemon/src/lib/workspace-promotion.ts +4 -4
  42. package/packages/daemon/src/server/pane-stream-upgrade.ts +41 -1
  43. package/packages/daemon/src/terminal/pane-stream/pane-stream-websocket.ts +25 -0
  44. package/packages/daemon/src/terminal/session-runtime/registry.ts +1 -0
  45. package/packages/daemon/src/terminal/session-runtime/terminal-delivery-hub.ts +575 -39
  46. package/packages/daemon/src/tui/mirror/open-tui-workspace-runtime-port.ts +82 -2
  47. package/packages/daemon/src/tui/mirror/theme.ts +13 -1
@@ -1,4 +1,8 @@
1
- import { STOCK_CAPTURE_TAB_UNAVAILABLE } from "@tmux-ide/contracts";
1
+ import {
2
+ STOCK_CAPTURE_TAB_UNAVAILABLE,
3
+ TERMINAL_DELIVERY_MAX_PIPELINED,
4
+ TERMINAL_DELIVERY_PIPELINING_CAPABILITY_VERSION,
5
+ } from "@tmux-ide/contracts";
2
6
  import { randomUUID } from "node:crypto";
3
7
  import type {
4
8
  WindowLinkTopology,
@@ -413,6 +417,13 @@ class WireTerminalEndpoint {
413
417
  #pending: PendingDelivery | null = null;
414
418
  #rejectedTransactionId: string | null = null;
415
419
  #decodeToken: object | null = null;
420
+ /**
421
+ * Capability 124: patches the daemon pipelined behind the delivery that is
422
+ * still decoding or unsettled, each with its chunks, in arrival order. Each
423
+ * names the one before as its base; they are admitted once that one is ACKed.
424
+ */
425
+ #queued: TerminalDeliveryServerMessage[] = [];
426
+ #draining = false;
416
427
  #closed = false;
417
428
  readonly #ready: Promise<boolean>;
418
429
  #resolveReady!: (ready: boolean) => void;
@@ -505,6 +516,7 @@ class WireTerminalEndpoint {
505
516
  return;
506
517
  }
507
518
  if (message.type === "terminal.delivery.fault") {
519
+ this.#queued.length = 0;
508
520
  if (message.deliveryNonce !== this.#negotiated.deliveryNonce) {
509
521
  this.#failConnection(new Error("Terminal fault nonce does not match negotiation"));
510
522
  return;
@@ -532,6 +544,15 @@ class WireTerminalEndpoint {
532
544
  return;
533
545
  }
534
546
  if (this.#unavailable) return;
547
+ if ((this.#queued.length > 0 || this.#busy()) && this.#mayQueue(message)) {
548
+ this.#queued.push(message);
549
+ return;
550
+ }
551
+ return this.#acceptNow(message);
552
+ }
553
+
554
+ #acceptNow(message: TerminalDeliveryServerMessage): void | { readonly consumedOwnedChunk: true } {
555
+ if (message.type === "terminal.delivery.fault") return;
535
556
  if (message.type === "terminal.projection") {
536
557
  this.#failConnection(new Error("Unsolicited alternate-screen projection"));
537
558
  return;
@@ -543,9 +564,62 @@ class WireTerminalEndpoint {
543
564
  return this.#acceptChunk(message);
544
565
  }
545
566
 
567
+ /** A flight is decoding or waiting for its subscriber: it has not been ACKed. */
568
+ #busy(): boolean {
569
+ return this.#decodeToken !== null || this.#pending !== null;
570
+ }
571
+
572
+ /**
573
+ * Capability 124: only a patch based on the newest flight (decoding,
574
+ * unsettled or queued), within TERMINAL_DELIVERY_MAX_PIPELINED, and the
575
+ * chunks of the newest queued patch. Anything else overlapping a flight is
576
+ * still a protocol violation and takes the ordinary path.
577
+ */
578
+ #mayQueue(message: TerminalDeliveryServerMessage): boolean {
579
+ let newest: TerminalDeliveryEnvelope | null = this.#pending?.envelope ?? this.#envelope;
580
+ let envelopes = 1;
581
+ let chunks = 0;
582
+ for (const queued of this.#queued)
583
+ if (queued.type === "terminal.delivery") {
584
+ newest = queued;
585
+ envelopes += 1;
586
+ chunks = 0;
587
+ } else if (queued.type === "terminal.delivery.chunk") chunks += 1;
588
+ if (!newest) return false;
589
+ if (message.type === "terminal.delivery.chunk")
590
+ return (
591
+ envelopes > 1 &&
592
+ message.transactionId === newest.transactionId &&
593
+ chunks < newest.chunkCount
594
+ );
595
+ return (
596
+ message.type === "terminal.delivery" &&
597
+ message.frame === "patch" &&
598
+ message.baseRevision === newest.canonicalRevision &&
599
+ message.incarnation === newest.incarnation &&
600
+ envelopes < TERMINAL_DELIVERY_MAX_PIPELINED &&
601
+ (envelopes === 1 || chunks === newest.chunkCount)
602
+ );
603
+ }
604
+
605
+ /** Admit queued deliveries in order until one is decoding or unsettled again. */
606
+ #drain(): void {
607
+ if (this.#draining) return;
608
+ this.#draining = true;
609
+ try {
610
+ while (this.#queued.length > 0 && !this.#busy() && !this.#closed) {
611
+ const message = this.#queued.shift()!;
612
+ this.#acceptNow(message);
613
+ }
614
+ } finally {
615
+ this.#draining = false;
616
+ }
617
+ }
618
+
546
619
  close(): void {
547
620
  if (this.#closed) return;
548
621
  this.#closed = true;
622
+ this.#queued.length = 0;
549
623
  this.#assembler = null;
550
624
  this.#assemblyStorage = null;
551
625
  this.#envelope = null;
@@ -847,7 +921,9 @@ class WireTerminalEndpoint {
847
921
  });
848
922
  } catch (error) {
849
923
  this.#failConnection(error instanceof Error ? error : new Error(String(error)));
924
+ return;
850
925
  }
926
+ this.#drain();
851
927
  }
852
928
 
853
929
  #reject(
@@ -882,6 +958,9 @@ class WireTerminalEndpoint {
882
958
  this.#decodeToken = null;
883
959
  this.#rejectedTransactionId = attempted?.transactionId ?? transactionId;
884
960
  this.#reseedRequired = true;
961
+ // Patches queued behind the rejected flight are NACKed in turn ("gap");
962
+ // the daemon dropped them with the first NACK.
963
+ this.#drain();
885
964
  }
886
965
  }
887
966
 
@@ -1227,7 +1306,8 @@ export async function connectOpenTuiWorkspaceRuntimePort(
1227
1306
  panes: [...panes],
1228
1307
  viewerMode: "interactive",
1229
1308
  terminalDelivery: {
1230
- protocolVersions: [1],
1309
+ // 124: this endpoint holds patches pipelined behind a decoding one.
1310
+ protocolVersions: [1, TERMINAL_DELIVERY_PIPELINING_CAPABILITY_VERSION],
1231
1311
  encodings: ["semantic-compact-v1", "semantic-v1"],
1232
1312
  richPlacements: true,
1233
1313
  },
@@ -139,6 +139,9 @@ export interface SemanticThemeSnapshot extends SemanticThemeTokens {
139
139
  export interface ThemeConfigInput {
140
140
  mode?: ThemeModeSetting;
141
141
  preset?: string;
142
+ /** System mode's preset when the host is light, and when it is dark. */
143
+ light?: string;
144
+ dark?: string;
142
145
  userTheme?: unknown;
143
146
  projectTheme?: unknown;
144
147
  accessibility?: Partial<ThemeAccessibilityPreferences>;
@@ -900,10 +903,19 @@ export function createSemanticThemeSnapshot(
900
903
  config?.accessibility?.increasedContrast ?? DEFAULT_ACCESSIBILITY.increasedContrast,
901
904
  };
902
905
  const mode = resolvedMode(setting, rendererMode, hostDefaults);
906
+ // System mode with a chosen preset for each side (the Mac app's Match
907
+ // macOS writes theme.light / theme.dark): the side the host is on.
908
+ const side =
909
+ setting === "system"
910
+ ? findVisualThemePreset(mode === "light" ? config?.light : config?.dark)
911
+ : undefined;
903
912
  const resolved = resolveVisualTheme({
904
913
  appearance: mode,
905
914
  hostDefaults: setting === "system" ? (hostDefaults ?? undefined) : undefined,
906
- userTheme: config?.userTheme ?? findVisualThemePreset(config?.preset),
915
+ userTheme:
916
+ config?.userTheme ??
917
+ findVisualThemePreset(config?.preset) ??
918
+ (side?.appearance === mode ? side : undefined),
907
919
  projectTheme: config?.projectTheme,
908
920
  accessibility,
909
921
  });