tmux-ide 2.9.25 → 2.9.26

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 (36) hide show
  1. package/bin/cli.js +344 -50
  2. package/package.json +2 -1
  3. package/packages/contracts/src/pane-stream.ts +19 -0
  4. package/packages/contracts/src/terminal-delivery.ts +8 -2
  5. package/packages/contracts/src/terminal-runtime-inventory.ts +61 -1
  6. package/packages/contracts/src/tmux-server-scope.ts +18 -0
  7. package/packages/daemon/dist/command-center/resources/terminal-runtime-inventory.js +42 -2
  8. package/packages/daemon/dist/command-center/tmux-servers.js +17 -7
  9. package/packages/daemon/dist/lib/tmux-server-owner.js +4 -2
  10. package/packages/daemon/dist/native/TmuxIdeNotifier.app/Contents/Info.plist +2 -2
  11. package/packages/daemon/dist/native/TmuxIdeNotifier.app/Contents/MacOS/tmux-ide-notifier +0 -0
  12. package/packages/daemon/dist/native/TmuxIdeNotifier.app/Contents/Resources/Assets.car +0 -0
  13. package/packages/daemon/dist/native/TmuxIdeNotifier.app/Contents/_CodeSignature/CodeResources +2 -2
  14. package/packages/daemon/dist/terminal/mirror/session-channel.js +6 -1
  15. package/packages/daemon/dist/terminal/pane-stream/lease-manager.js +1 -0
  16. package/packages/daemon/dist/terminal/pane-stream/pane-stream-websocket.js +98 -22
  17. package/packages/daemon/dist/terminal/protocol/browser-icon.js +1 -1
  18. package/packages/daemon/dist/terminal/protocol/session-descriptor-discovery.js +26 -3
  19. package/packages/daemon/dist/terminal/session-runtime/registry.js +1 -0
  20. package/packages/daemon/dist/terminal/session-runtime/terminal-delivery-hub.js +121 -6
  21. package/packages/daemon/dist/terminal/session-runtime/terminal-replica-interpreter.js +2 -0
  22. package/packages/daemon/dist/terminal/session-runtime/xterm-terminal-interpreter-backend.js +51 -4
  23. package/packages/daemon/src/command-center/resources/terminal-runtime-inventory.ts +48 -1
  24. package/packages/daemon/src/command-center/tmux-servers.ts +19 -6
  25. package/packages/daemon/src/lib/tmux-server-owner.ts +6 -3
  26. package/packages/daemon/src/terminal/mirror/events.ts +2 -0
  27. package/packages/daemon/src/terminal/mirror/session-channel.ts +8 -1
  28. package/packages/daemon/src/terminal/pane-stream/lease-manager.ts +3 -0
  29. package/packages/daemon/src/terminal/pane-stream/pane-stream-websocket.ts +111 -20
  30. package/packages/daemon/src/terminal/protocol/browser-icon.ts +1 -1
  31. package/packages/daemon/src/terminal/protocol/session-descriptor-discovery.ts +32 -2
  32. package/packages/daemon/src/terminal/session-runtime/registry.ts +1 -0
  33. package/packages/daemon/src/terminal/session-runtime/terminal-delivery-hub.ts +136 -6
  34. package/packages/daemon/src/terminal/session-runtime/terminal-interpreter-backend.ts +6 -0
  35. package/packages/daemon/src/terminal/session-runtime/terminal-replica-interpreter.ts +2 -0
  36. package/packages/daemon/src/terminal/session-runtime/xterm-terminal-interpreter-backend.ts +67 -3
@@ -23,6 +23,9 @@ export class XtermTerminalInterpreterBackend implements TerminalInterpreterBacke
23
23
  readonly #terminal: Terminal;
24
24
  readonly #rowCache = new WeakMap<object, CachedRow>();
25
25
  #scrollEpoch = 0;
26
+ readonly #historyLimit: number;
27
+ #collecting = false;
28
+ #lastYbase: number | null = null;
26
29
  #lastScrollEpoch = 0;
27
30
  #lastViewportY = 0;
28
31
  #lastBufferType = "normal";
@@ -36,11 +39,17 @@ export class XtermTerminalInterpreterBackend implements TerminalInterpreterBacke
36
39
  #scrollOnClear: boolean | undefined;
37
40
 
38
41
  constructor(options: TerminalInterpreterBackendFactoryOptions) {
42
+ const historyLimit = options.historyLimit ?? options.scrollback;
43
+ this.#historyLimit = historyLimit;
39
44
  this.#terminal = new Terminal({
40
45
  cols: options.cols,
41
46
  rows: options.rows,
42
- scrollback: options.scrollback,
43
- tmuxHistoryLimit: options.historyLimit ?? options.scrollback,
47
+ // One row of headroom over what the replica may hold (the limit, or a
48
+ // larger captured history): xterm must not recycle the row a scroll
49
+ // adds before #collectHistory sees it.
50
+ scrollback:
51
+ historyLimit > 0 ? Math.max(options.scrollback, historyLimit) + 1 : options.scrollback,
52
+ tmuxHistoryLimit: historyLimit,
44
53
  allowProposedApi: true,
45
54
  });
46
55
  this.#terminal.loadAddon(new Unicode11Addon());
@@ -81,7 +90,9 @@ export class XtermTerminalInterpreterBackend implements TerminalInterpreterBacke
81
90
  this.#terminal.onScroll(() => {
82
91
  // tmux retains normal history while alternate rows scroll independently.
83
92
  // Neither captured nor live alternate scrolling may trim that history.
84
- if (this.#terminal.buffer.active.type === "normal") this.#scrollEpoch += 1;
93
+ if (this.#terminal.buffer.active.type !== "normal") return;
94
+ this.#scrollEpoch += 1;
95
+ this.#collectHistory();
85
96
  });
86
97
  const core = (
87
98
  this.#terminal as unknown as {
@@ -94,6 +105,59 @@ export class XtermTerminalInterpreterBackend implements TerminalInterpreterBacke
94
105
  }
95
106
  }
96
107
 
108
+ /**
109
+ * tmux at its history-limit collects the oldest tenth of history before a
110
+ * scroll would pass it (grid_collect_history), so its history_size moves
111
+ * between 0.9 and 1.0 of the limit. Recycling one row at a time instead kept
112
+ * the replica at the limit, and the owner's history-size check then reseeded
113
+ * the whole pane each time its output paused. The projection reports the
114
+ * collection as an ordinary history trim.
115
+ */
116
+ startHistoryCollection(): void {
117
+ this.#collecting = true;
118
+ this.#lastYbase = this.#normalBuffer()?.ybase ?? null;
119
+ }
120
+
121
+ #normalBuffer() {
122
+ return (
123
+ this.#terminal as unknown as {
124
+ _core?: {
125
+ buffers?: {
126
+ normal?: {
127
+ ybase: number;
128
+ ydisp: number;
129
+ lines: { trimStart(count: number): void };
130
+ };
131
+ };
132
+ };
133
+ }
134
+ )._core?.buffers?.normal;
135
+ }
136
+
137
+ #collectHistory(): void {
138
+ const buffer = this.#normalBuffer();
139
+ if (!buffer) return;
140
+ const before = this.#lastYbase;
141
+ const limit = this.#historyLimit;
142
+ // Only a plain one-row scroll from at or above the limit is collected
143
+ // here. ED2 collects before its own scrolls (one-column.patch), and any
144
+ // other change (reset, resize, a capped ring) is left alone: a history
145
+ // that still differs from tmux is caught by the owner's size check.
146
+ if (
147
+ this.#collecting &&
148
+ limit > 0 &&
149
+ before !== null &&
150
+ before >= limit &&
151
+ buffer.ybase === before + 1
152
+ ) {
153
+ const trim = Math.min(buffer.ybase, Math.max(1, Math.floor(limit / 10)));
154
+ buffer.lines.trimStart(trim);
155
+ buffer.ybase -= trim;
156
+ buffer.ydisp = Math.max(0, buffer.ydisp - trim);
157
+ }
158
+ this.#lastYbase = buffer.ybase;
159
+ }
160
+
97
161
  get cols(): number {
98
162
  return this.#terminal.cols;
99
163
  }