tmux-ide 2.9.24 → 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.
- package/bin/cli.js +1689 -393
- package/package.json +5 -2
- package/packages/contracts/src/pane-stream.ts +72 -0
- package/packages/contracts/src/terminal-delivery.ts +8 -2
- package/packages/contracts/src/terminal-runtime-inventory.ts +61 -1
- package/packages/contracts/src/tmux-server-scope.ts +18 -0
- package/packages/daemon/dist/command-center/discovery.js +24 -5
- package/packages/daemon/dist/command-center/resources/terminal-runtime-inventory.js +42 -2
- package/packages/daemon/dist/command-center/server.js +81 -75
- package/packages/daemon/dist/command-center/tmux-servers.js +17 -7
- package/packages/daemon/dist/doctor.js +46 -10
- package/packages/daemon/dist/lib/canonical-daemon-bootstrap.js +20 -2
- package/packages/daemon/dist/lib/daemon-crash-snapshot.js +118 -0
- package/packages/daemon/dist/lib/daemon-embed.js +6 -0
- package/packages/daemon/dist/lib/headless-daemon.js +63 -6
- package/packages/daemon/dist/lib/invocation-directory.js +20 -0
- package/packages/daemon/dist/lib/runtime-namespace.js +22 -6
- package/packages/daemon/dist/lib/tmux-client-execution.js +12 -3
- package/packages/daemon/dist/lib/tmux-server-owner.js +4 -2
- package/packages/daemon/dist/lib/update-check.js +18 -0
- package/packages/daemon/dist/lib/update-daemon-outcome.js +31 -0
- package/packages/daemon/dist/lib/update.js +39 -14
- package/packages/daemon/dist/native/TmuxIdeNotifier.app/Contents/Info.plist +2 -2
- package/packages/daemon/dist/native/TmuxIdeNotifier.app/Contents/MacOS/tmux-ide-notifier +0 -0
- package/packages/daemon/dist/native/TmuxIdeNotifier.app/Contents/Resources/Assets.car +0 -0
- package/packages/daemon/dist/native/TmuxIdeNotifier.app/Contents/_CodeSignature/CodeResources +2 -2
- package/packages/daemon/dist/terminal/graphics/kitty-graphics.js +16 -4
- package/packages/daemon/dist/terminal/mirror/mirror-service.js +26 -0
- package/packages/daemon/dist/terminal/mirror/session-channel.js +31 -2
- package/packages/daemon/dist/terminal/pane-stream/lease-manager.js +1 -0
- package/packages/daemon/dist/terminal/pane-stream/pane-stream-websocket.js +831 -222
- package/packages/daemon/dist/terminal/protocol/browser-icon.js +1 -1
- package/packages/daemon/dist/terminal/protocol/session-descriptor-discovery.js +26 -3
- package/packages/daemon/dist/terminal/session-runtime/registry.js +25 -2
- package/packages/daemon/dist/terminal/session-runtime/terminal-delivery-hub.js +121 -6
- package/packages/daemon/dist/terminal/session-runtime/terminal-replica-interpreter.js +79 -2
- package/packages/daemon/dist/terminal/session-runtime/terminal-replica-owner.js +24 -2
- package/packages/daemon/dist/terminal/session-runtime/transport-binding.js +38 -0
- package/packages/daemon/dist/terminal/session-runtime/xterm-terminal-interpreter-backend.js +51 -4
- package/packages/daemon/dist/tui/chrome/snapshot.js +36 -1
- package/packages/daemon/dist/tui/chrome/statusline.js +8 -5
- package/packages/daemon/dist/tui/chrome/updater.js +2 -0
- package/packages/daemon/src/command-center/discovery.ts +24 -4
- package/packages/daemon/src/command-center/resources/terminal-runtime-inventory.ts +48 -1
- package/packages/daemon/src/command-center/server.ts +67 -67
- package/packages/daemon/src/command-center/tmux-servers.ts +19 -6
- package/packages/daemon/src/doctor.ts +50 -9
- package/packages/daemon/src/lib/canonical-daemon-bootstrap.ts +31 -5
- package/packages/daemon/src/lib/daemon-crash-snapshot.ts +175 -0
- package/packages/daemon/src/lib/daemon-embed.ts +22 -0
- package/packages/daemon/src/lib/headless-daemon.ts +88 -7
- package/packages/daemon/src/lib/invocation-directory.ts +21 -0
- package/packages/daemon/src/lib/runtime-namespace.ts +25 -7
- package/packages/daemon/src/lib/tmux-client-execution.ts +14 -5
- package/packages/daemon/src/lib/tmux-server-owner.ts +6 -3
- package/packages/daemon/src/lib/update-check.ts +34 -0
- package/packages/daemon/src/lib/update-daemon-outcome.ts +42 -0
- package/packages/daemon/src/lib/update.ts +58 -16
- package/packages/daemon/src/terminal/graphics/kitty-graphics.ts +22 -6
- package/packages/daemon/src/terminal/mirror/events.ts +2 -0
- package/packages/daemon/src/terminal/mirror/mirror-service.ts +27 -0
- package/packages/daemon/src/terminal/mirror/session-channel.ts +38 -2
- package/packages/daemon/src/terminal/pane-stream/lease-manager.ts +3 -0
- package/packages/daemon/src/terminal/pane-stream/pane-stream-websocket.ts +915 -236
- package/packages/daemon/src/terminal/protocol/browser-icon.ts +1 -1
- package/packages/daemon/src/terminal/protocol/session-descriptor-discovery.ts +32 -2
- package/packages/daemon/src/terminal/session-runtime/registry.ts +36 -2
- package/packages/daemon/src/terminal/session-runtime/terminal-delivery-hub.ts +136 -6
- package/packages/daemon/src/terminal/session-runtime/terminal-interpreter-backend.ts +6 -0
- package/packages/daemon/src/terminal/session-runtime/terminal-replica-interpreter.ts +76 -2
- package/packages/daemon/src/terminal/session-runtime/terminal-replica-owner.ts +21 -1
- package/packages/daemon/src/terminal/session-runtime/transport-binding.ts +42 -2
- package/packages/daemon/src/terminal/session-runtime/xterm-terminal-interpreter-backend.ts +67 -3
- package/packages/daemon/src/tui/chrome/snapshot.ts +47 -1
- package/packages/daemon/src/tui/chrome/statusline.ts +7 -4
- package/packages/daemon/src/tui/chrome/updater.ts +3 -0
- package/packages/daemon-client/src/pane-stream-client.ts +47 -5
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { browserIcon } from "./browser-icon.js";
|
|
1
|
+
import { browserIcon, processAlive } from "./browser-icon.js";
|
|
2
2
|
import { readerOption } from "./reader-option.js";
|
|
3
3
|
/**
|
|
4
4
|
* `qa` asks tmux to escape each value as a command argument. In particular,
|
|
@@ -33,6 +33,8 @@ export const SESSION_PANE_DESCRIPTOR_FORMAT = [
|
|
|
33
33
|
"#{qa:@tmux_ide_reader}",
|
|
34
34
|
// The reader option belongs to the pane only when its own process set it.
|
|
35
35
|
"#{pane_pid}",
|
|
36
|
+
// Set only by a terminal browser that has tmux-ide's native controls (#718).
|
|
37
|
+
"#{qa:@tmux_ide_browser_control}",
|
|
36
38
|
].join("\t");
|
|
37
39
|
/**
|
|
38
40
|
* Descriptor fields the program in a pane changes whenever it likes: its
|
|
@@ -129,9 +131,9 @@ export function parseSessionPaneDescriptorReply(lines) {
|
|
|
129
131
|
continue;
|
|
130
132
|
}
|
|
131
133
|
const encoded = utf8Line.split("\t");
|
|
132
|
-
if (encoded.length < 21 || encoded.length >
|
|
134
|
+
if (encoded.length < 21 || encoded.length > 26)
|
|
133
135
|
continue;
|
|
134
|
-
const [runtimePaneId = "", semanticPaneId = "", role = "", type = "", currentCommand = "", cwd = "", windowIndexRaw = "", windowName = "", windowId = "", title = "", runtimeSessionId = "", paneIndexRaw = "", name = "", missionStamp = "", paneActiveRaw = "", windowActiveRaw = "", semanticWindowId = "", sessionName = "", windowPaneCountRaw = "", sessionWindowCountRaw = "", nativePaneBirthId = "", nameSource = "", browserIconRaw = "", readerRaw = "", panePidRaw = "",] = encoded.map(decodeTmuxArgument);
|
|
136
|
+
const [runtimePaneId = "", semanticPaneId = "", role = "", type = "", currentCommand = "", cwd = "", windowIndexRaw = "", windowName = "", windowId = "", title = "", runtimeSessionId = "", paneIndexRaw = "", name = "", missionStamp = "", paneActiveRaw = "", windowActiveRaw = "", semanticWindowId = "", sessionName = "", windowPaneCountRaw = "", sessionWindowCountRaw = "", nativePaneBirthId = "", nameSource = "", browserIconRaw = "", readerRaw = "", panePidRaw = "", browserControl = "",] = encoded.map(decodeTmuxArgument);
|
|
135
137
|
if (!/^%(?:0|[1-9][0-9]*)$/u.test(runtimePaneId) || runtimePaneId.length > 32)
|
|
136
138
|
continue;
|
|
137
139
|
if (!/^\$(?:0|[1-9][0-9]*)$/u.test(runtimeSessionId) || runtimeSessionId.length > 32)
|
|
@@ -169,6 +171,7 @@ export function parseSessionPaneDescriptorReply(lines) {
|
|
|
169
171
|
}
|
|
170
172
|
descriptors.push({
|
|
171
173
|
browserIcon: browserIcon(browserIconRaw),
|
|
174
|
+
browserKind: terminalBrowserKind(browserControl, currentCommand),
|
|
172
175
|
reader: readerOption(readerRaw, panePidRaw),
|
|
173
176
|
sessionName,
|
|
174
177
|
runtimePaneId,
|
|
@@ -325,3 +328,23 @@ export function decodeControlReplyUtf8(value) {
|
|
|
325
328
|
function positiveInteger(value, fallback) {
|
|
326
329
|
return Number.isSafeInteger(value) && value > 0 ? value : fallback;
|
|
327
330
|
}
|
|
331
|
+
/**
|
|
332
|
+
* #718: a pane runs a terminal browser with tmux-ide's native controls while
|
|
333
|
+
* the browser that published @tmux_ide_browser_control is alive: the browser
|
|
334
|
+
* never clears the option, so a pane that outlives it (remain-on-exit,
|
|
335
|
+
* respawn-pane) is judged by what runs there now. A plain terminal browser
|
|
336
|
+
* is known by its process name (tmux cuts it to 15 characters on macOS).
|
|
337
|
+
*/
|
|
338
|
+
export function terminalBrowserKind(control, currentCommand, alive = processAlive) {
|
|
339
|
+
if (control.length > 0 && control.length <= 4096) {
|
|
340
|
+
try {
|
|
341
|
+
const pid = JSON.parse(control)?.pid;
|
|
342
|
+
if (typeof pid === "number" && Number.isSafeInteger(pid) && pid > 0 && alive(pid))
|
|
343
|
+
return "native";
|
|
344
|
+
}
|
|
345
|
+
catch {
|
|
346
|
+
// Not an endpoint: judged by the process name below.
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
return /^terminal-browser?$/u.test(currentCommand) ? "plain" : null;
|
|
350
|
+
}
|
|
@@ -52,6 +52,17 @@ export class SessionRuntimeControllerLeaseError extends Error {
|
|
|
52
52
|
this.name = "SessionRuntimeControllerLeaseError";
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
|
+
/**
|
|
56
|
+
* An input fenced to a pane lifetime (capability 105) whose lifetime has
|
|
57
|
+
* ended: its owner is gone or was replaced. The input must not reach another
|
|
58
|
+
* lifetime; the pane's delivery tells the client that its lifetime ended.
|
|
59
|
+
*/
|
|
60
|
+
export class SessionRuntimeInputLifetimeEndedError extends Error {
|
|
61
|
+
constructor(message) {
|
|
62
|
+
super(message);
|
|
63
|
+
this.name = "SessionRuntimeInputLifetimeEndedError";
|
|
64
|
+
}
|
|
65
|
+
}
|
|
55
66
|
/**
|
|
56
67
|
* One daemon-generation lifecycle owner for every discovered tmux session.
|
|
57
68
|
*
|
|
@@ -344,6 +355,10 @@ export class SessionRuntimeRegistry {
|
|
|
344
355
|
async verifyWindowOwnership() {
|
|
345
356
|
await this.#mirror.verifyRegisteredWindows();
|
|
346
357
|
}
|
|
358
|
+
/** Ownership is being read again: input and geometry wait, they are not refused for good. */
|
|
359
|
+
windowOwnershipPending() {
|
|
360
|
+
return !this.#disposed && this.#mirror.windowOwnershipPending();
|
|
361
|
+
}
|
|
347
362
|
/** Install the bounded registered-session membership reader. */
|
|
348
363
|
setRegisteredWindowReader(reader) {
|
|
349
364
|
return this.#mirror.setRegisteredWindowReader(reader);
|
|
@@ -767,6 +782,8 @@ class SessionRuntime {
|
|
|
767
782
|
#consumersByClientId = new Map();
|
|
768
783
|
#terminalReplicas = new Map();
|
|
769
784
|
#terminalReplicaClocks = new Map();
|
|
785
|
+
/** The renderer's last reported cell size; every pane's image placements use it. */
|
|
786
|
+
#cellPixels = null;
|
|
770
787
|
#outputTraces;
|
|
771
788
|
#outputObservations = new Map();
|
|
772
789
|
#createTraceCorrelator;
|
|
@@ -1058,7 +1075,7 @@ class SessionRuntime {
|
|
|
1058
1075
|
? this.#terminalReplicas.get(semanticPaneId)
|
|
1059
1076
|
: this.#terminalReplicaOwner(semanticPaneId);
|
|
1060
1077
|
if (!replicaOwner)
|
|
1061
|
-
throw new
|
|
1078
|
+
throw new SessionRuntimeInputLifetimeEndedError("Input target lifetime unavailable");
|
|
1062
1079
|
if (causalProbe) {
|
|
1063
1080
|
this.#activeCausalCellProbes += 1;
|
|
1064
1081
|
let settled = false;
|
|
@@ -1088,7 +1105,7 @@ class SessionRuntime {
|
|
|
1088
1105
|
(expectedLifetime.generation !== this.generation ||
|
|
1089
1106
|
this.#terminalReplicas.get(semanticPaneId) !== replicaOwner ||
|
|
1090
1107
|
replicaOwner.inputAdmissionIncarnation() !== expectedLifetime.incarnation))
|
|
1091
|
-
throw new
|
|
1108
|
+
throw new SessionRuntimeInputLifetimeEndedError("Input target lifetime changed");
|
|
1092
1109
|
if (input.kind === "text")
|
|
1093
1110
|
this.#mirror.sendText(this.session, semanticPaneId, input.data, performanceTraceId, causalProbe !== null);
|
|
1094
1111
|
else if (input.kind === "bytes")
|
|
@@ -1165,6 +1182,9 @@ class SessionRuntime {
|
|
|
1165
1182
|
setCellPixels(clientId, width, height, precise) {
|
|
1166
1183
|
this.#assertConnected(clientId);
|
|
1167
1184
|
this.#mirror.setCellPixels?.(this.session, width, height, precise);
|
|
1185
|
+
this.#cellPixels = { width, height, ...(precise ? { precise } : {}) };
|
|
1186
|
+
for (const owner of this.#terminalReplicas.values())
|
|
1187
|
+
owner.setCellPixels(width, height, precise);
|
|
1168
1188
|
}
|
|
1169
1189
|
fitViewportWithAuthority(clientId, lease, cols, rows, semanticWindowId) {
|
|
1170
1190
|
this.assertGeometryAuthority(clientId, lease);
|
|
@@ -1340,6 +1360,8 @@ class SessionRuntime {
|
|
|
1340
1360
|
: {}),
|
|
1341
1361
|
});
|
|
1342
1362
|
owner = candidate;
|
|
1363
|
+
if (this.#cellPixels)
|
|
1364
|
+
owner.setCellPixels(this.#cellPixels.width, this.#cellPixels.height, this.#cellPixels.precise);
|
|
1343
1365
|
this.#terminalReplicas.set(semanticPaneId, owner);
|
|
1344
1366
|
}
|
|
1345
1367
|
return owner;
|
|
@@ -1672,6 +1694,7 @@ class SessionRuntimeConsumerImpl {
|
|
|
1672
1694
|
ack: (ack) => upstream.ack(ack),
|
|
1673
1695
|
...(upstream.projectionReceipt ? { projectionReceipt: upstream.projectionReceipt } : {}),
|
|
1674
1696
|
...(upstream.materialize ? { materialize: upstream.materialize } : {}),
|
|
1697
|
+
...(upstream.prioritize ? { prioritize: upstream.prioritize } : {}),
|
|
1675
1698
|
nack: (nack) => upstream.nack(nack),
|
|
1676
1699
|
setVisibility: (visibility) => upstream.setVisibility(visibility),
|
|
1677
1700
|
close: async () => {
|
|
@@ -19,6 +19,21 @@ const MAX_PANES = 32;
|
|
|
19
19
|
const MAX_PENDING_CANONICAL_CELLS = 1_000_000;
|
|
20
20
|
const MAX_CONNECTIONS = MAX_CLIENTS * MAX_PANES;
|
|
21
21
|
const BACKGROUND_CADENCE_MS = 100;
|
|
22
|
+
/**
|
|
23
|
+
* One connection's unacknowledged delivery bytes, across its panes, before a
|
|
24
|
+
* pane other than the one it types into waits. A remote link (SSH) queues
|
|
25
|
+
* every sent byte ahead of the next input-ack and echo; this bounds that queue
|
|
26
|
+
* to about this much plus one delivery. Daemon policy only: nothing on the wire.
|
|
27
|
+
*/
|
|
28
|
+
export const TERMINAL_DELIVERY_CONNECTION_UNACKED_BYTES = 256 * 1024;
|
|
29
|
+
/** No pane is held longer than this: it is then sent behind whatever is in flight. */
|
|
30
|
+
export const TERMINAL_DELIVERY_CONNECTION_HOLD_MS = 250;
|
|
31
|
+
/**
|
|
32
|
+
* A pane is held only once some delivery of its connection has gone this long
|
|
33
|
+
* unacknowledged: a fast link acks bulk within a few round trips, and holding
|
|
34
|
+
* there only bunches panes up behind each other.
|
|
35
|
+
*/
|
|
36
|
+
export const TERMINAL_DELIVERY_CONNECTION_CONGESTED_MS = 30;
|
|
22
37
|
class DeferredProjectionEncoding extends Error {
|
|
23
38
|
payload;
|
|
24
39
|
constructor(payload) {
|
|
@@ -76,6 +91,8 @@ export class SessionRuntimeTerminalDeliveryHub {
|
|
|
76
91
|
#observability;
|
|
77
92
|
#panes = new Map();
|
|
78
93
|
#clients = new Map();
|
|
94
|
+
/** Per connection: the pane it last typed into. */
|
|
95
|
+
#priority = new Map();
|
|
79
96
|
#sourceCloseFailures = 0;
|
|
80
97
|
#pendingSourceCloses = 0;
|
|
81
98
|
/** Synchronous reservations held while an async pane source is starting. */
|
|
@@ -93,10 +110,14 @@ export class SessionRuntimeTerminalDeliveryHub {
|
|
|
93
110
|
#deliveryLifecycleOrdinal = 0;
|
|
94
111
|
#deliveryStatusOrdinal = 0;
|
|
95
112
|
#closed = false;
|
|
113
|
+
#holdMs;
|
|
114
|
+
#congestedMs;
|
|
96
115
|
constructor(generation, workspaceName, ownerForPane, options = {}) {
|
|
97
116
|
this.generation = generation;
|
|
98
117
|
this.workspaceName = workspaceName;
|
|
99
118
|
this.#ownerForPane = ownerForPane;
|
|
119
|
+
this.#holdMs = options.connectionHoldMs ?? TERMINAL_DELIVERY_CONNECTION_HOLD_MS;
|
|
120
|
+
this.#congestedMs = options.connectionCongestedMs ?? TERMINAL_DELIVERY_CONNECTION_CONGESTED_MS;
|
|
100
121
|
this.#scheduler = options.scheduler ?? SYSTEM_SESSION_RUNTIME_SCHEDULER;
|
|
101
122
|
this.#observability = options.observability ?? DISABLED_SESSION_RUNTIME_OBSERVABILITY;
|
|
102
123
|
}
|
|
@@ -165,6 +186,9 @@ export class SessionRuntimeTerminalDeliveryHub {
|
|
|
165
186
|
lastAck: null,
|
|
166
187
|
sourceClosedFlight: null,
|
|
167
188
|
backgroundTimer: null,
|
|
189
|
+
budgetHeld: false,
|
|
190
|
+
budgetHeldSince: null,
|
|
191
|
+
budgetTimer: null,
|
|
168
192
|
};
|
|
169
193
|
this.#clients.set(key, client);
|
|
170
194
|
client.lifecycleOpenRecorded = this.#recordDeliveryLifecycle(client, pane, "open");
|
|
@@ -177,6 +201,12 @@ export class SessionRuntimeTerminalDeliveryHub {
|
|
|
177
201
|
projectionReceipt: (receipt) => this.#projectionReceipt(client, receipt),
|
|
178
202
|
materialize: (request) => this.#materialize(client, request),
|
|
179
203
|
nack: (nack) => this.#nack(client, nack),
|
|
204
|
+
prioritize: () => {
|
|
205
|
+
if (client.closed)
|
|
206
|
+
return;
|
|
207
|
+
this.#priority.set(client.clientId, client.paneId);
|
|
208
|
+
this.#releaseBudget(client.clientId);
|
|
209
|
+
},
|
|
180
210
|
setVisibility: (visibilityInput) => {
|
|
181
211
|
if (client.closed)
|
|
182
212
|
return;
|
|
@@ -352,6 +382,7 @@ export class SessionRuntimeTerminalDeliveryHub {
|
|
|
352
382
|
this.#cancelEncoding(client);
|
|
353
383
|
client.outgoing.length = 0;
|
|
354
384
|
client.inFlight = null;
|
|
385
|
+
client.budgetHeld = false;
|
|
355
386
|
logDeliveryFault(client, "source-closed", "source-restarted");
|
|
356
387
|
this.#enqueue(client, {
|
|
357
388
|
type: "terminal.delivery.fault",
|
|
@@ -673,6 +704,32 @@ export class SessionRuntimeTerminalDeliveryHub {
|
|
|
673
704
|
pane.rawFloorRevision = Math.max(pane.rawFloorRevision, first[0] + 1);
|
|
674
705
|
}
|
|
675
706
|
}
|
|
707
|
+
#overBudget(client) {
|
|
708
|
+
if (this.#priority.get(client.clientId) === client.paneId)
|
|
709
|
+
return false;
|
|
710
|
+
if (client.budgetHeldSince !== null &&
|
|
711
|
+
this.#scheduler.nowMs() - client.budgetHeldSince >= this.#holdMs)
|
|
712
|
+
return false;
|
|
713
|
+
const now = this.#scheduler.nowMs();
|
|
714
|
+
let bytes = 0;
|
|
715
|
+
let oldest = now;
|
|
716
|
+
for (const other of this.#clients.values())
|
|
717
|
+
if (other !== client && other.clientId === client.clientId && other.inFlight) {
|
|
718
|
+
bytes += other.inFlight.envelope.representationBytes;
|
|
719
|
+
oldest = Math.min(oldest, other.inFlight.sentAt);
|
|
720
|
+
}
|
|
721
|
+
return bytes >= TERMINAL_DELIVERY_CONNECTION_UNACKED_BYTES && now - oldest >= this.#congestedMs;
|
|
722
|
+
}
|
|
723
|
+
/** A pane's delivery settled or left: held panes of its connection try again, typed-into pane first. */
|
|
724
|
+
#releaseBudget(clientId) {
|
|
725
|
+
const held = [...this.#clients.values()].filter((other) => other.clientId === clientId && other.budgetHeld);
|
|
726
|
+
const priority = this.#priority.get(clientId);
|
|
727
|
+
held.sort((a, b) => Number(b.paneId === priority) - Number(a.paneId === priority));
|
|
728
|
+
for (const other of held) {
|
|
729
|
+
other.budgetHeld = false;
|
|
730
|
+
this.#schedule(other);
|
|
731
|
+
}
|
|
732
|
+
}
|
|
676
733
|
#schedule(client) {
|
|
677
734
|
if (client.closed ||
|
|
678
735
|
client.captureUnavailable ||
|
|
@@ -715,6 +772,21 @@ export class SessionRuntimeTerminalDeliveryHub {
|
|
|
715
772
|
client.visibility === "frozen" ||
|
|
716
773
|
(!completed && target.update.revision !== client.latestRevision))
|
|
717
774
|
return;
|
|
775
|
+
if (!completed && this.#overBudget(client)) {
|
|
776
|
+
client.budgetHeld = true;
|
|
777
|
+
client.budgetHeldSince ??= this.#scheduler.nowMs();
|
|
778
|
+
client.budgetTimer ??= this.#scheduler.timer(() => {
|
|
779
|
+
client.budgetTimer = null;
|
|
780
|
+
if (client.closed || !client.budgetHeld)
|
|
781
|
+
return;
|
|
782
|
+
client.budgetHeld = false;
|
|
783
|
+
this.#schedule(client);
|
|
784
|
+
}, this.#holdMs);
|
|
785
|
+
return;
|
|
786
|
+
}
|
|
787
|
+
client.budgetHeldSince = null;
|
|
788
|
+
client.budgetTimer?.cancel();
|
|
789
|
+
client.budgetTimer = null;
|
|
718
790
|
const traceStarted = completed?.traceStarted ??
|
|
719
791
|
(this.#observability.enabled ? this.#observability.nowMicros() : 0);
|
|
720
792
|
let deferred = false;
|
|
@@ -1302,6 +1374,7 @@ export class SessionRuntimeTerminalDeliveryHub {
|
|
|
1302
1374
|
client.baselineHash = ack.canonicalStateHash;
|
|
1303
1375
|
client.reseedRequired = false;
|
|
1304
1376
|
client.inFlight = null;
|
|
1377
|
+
this.#releaseBudget(client.clientId);
|
|
1305
1378
|
client.lastAck = ack;
|
|
1306
1379
|
if (client.latestRevision === ack.canonicalRevision)
|
|
1307
1380
|
client.latestRevision = null;
|
|
@@ -1376,6 +1449,7 @@ export class SessionRuntimeTerminalDeliveryHub {
|
|
|
1376
1449
|
client.lastProjectionReceipt = receipt;
|
|
1377
1450
|
client.reseedRequired = false;
|
|
1378
1451
|
client.inFlight = null;
|
|
1452
|
+
this.#releaseBudget(client.clientId);
|
|
1379
1453
|
if (client.latestRevision === receipt.canonicalRevision)
|
|
1380
1454
|
client.latestRevision = null;
|
|
1381
1455
|
if (client.materializeRequested)
|
|
@@ -1440,6 +1514,7 @@ export class SessionRuntimeTerminalDeliveryHub {
|
|
|
1440
1514
|
this.#nacks += 1;
|
|
1441
1515
|
client.reseedRequired = true;
|
|
1442
1516
|
client.inFlight = null;
|
|
1517
|
+
this.#releaseBudget(client.clientId);
|
|
1443
1518
|
this.#pruneCanonicalRevisions(client.paneId);
|
|
1444
1519
|
this.#schedule(client);
|
|
1445
1520
|
this.#recordDeliveryStatus(client, this.#panes.get(client.paneId));
|
|
@@ -1482,6 +1557,7 @@ export class SessionRuntimeTerminalDeliveryHub {
|
|
|
1482
1557
|
if (reason === "source-closed")
|
|
1483
1558
|
client.sourceClosedFlight = client.inFlight?.envelope ?? null;
|
|
1484
1559
|
client.inFlight = null;
|
|
1560
|
+
this.#releaseBudget(client.clientId);
|
|
1485
1561
|
const fault = {
|
|
1486
1562
|
type: "terminal.delivery.fault",
|
|
1487
1563
|
reason,
|
|
@@ -1557,8 +1633,14 @@ export class SessionRuntimeTerminalDeliveryHub {
|
|
|
1557
1633
|
if (client.lifecycleOpenRecorded)
|
|
1558
1634
|
this.#recordDeliveryLifecycle(client, this.#panes.get(client.paneId), "close");
|
|
1559
1635
|
client.backgroundTimer?.cancel();
|
|
1636
|
+
client.budgetTimer?.cancel();
|
|
1637
|
+
client.budgetTimer = null;
|
|
1560
1638
|
client.outgoing.length = 0;
|
|
1561
1639
|
this.#clients.delete(client.key);
|
|
1640
|
+
if (![...this.#clients.values()].some((other) => other.clientId === client.clientId))
|
|
1641
|
+
this.#priority.delete(client.clientId);
|
|
1642
|
+
else
|
|
1643
|
+
this.#releaseBudget(client.clientId);
|
|
1562
1644
|
this.#pruneCanonicalRevisions(client.paneId);
|
|
1563
1645
|
if ([...this.#clients.values()].some((candidate) => candidate.paneId === client.paneId))
|
|
1564
1646
|
return;
|
|
@@ -1937,11 +2019,12 @@ function semanticPayload(baselineRevision, baseline, target, baselineIncarnation
|
|
|
1937
2019
|
// append-only history is proved here; trim/reflow and changed dimensions
|
|
1938
2020
|
// retain the full seed boundary. Equality includes wrapped and all cells.
|
|
1939
2021
|
const snapshot = target.state.snapshot;
|
|
2022
|
+
const trim = baseline ? historyTrim(baseline.history, snapshot.history) : 0;
|
|
1940
2023
|
if (baseline &&
|
|
1941
2024
|
baselineIncarnation === update.incarnation &&
|
|
1942
2025
|
baseline.cols === snapshot.cols &&
|
|
1943
2026
|
baseline.rows === snapshot.rows &&
|
|
1944
|
-
baseline.history.length <= snapshot.history.length) {
|
|
2027
|
+
baseline.history.length - trim <= snapshot.history.length) {
|
|
1945
2028
|
// Identity reuse is cheap, but detached equal histories must not turn a
|
|
1946
2029
|
// cooperative seed into an unbounded synchronous cell comparison.
|
|
1947
2030
|
let comparisonCells = 0;
|
|
@@ -1953,8 +2036,8 @@ function semanticPayload(baselineRevision, baseline, target, baselineIncarnation
|
|
|
1953
2036
|
? terminalReplicaRowsEqual(left, right)
|
|
1954
2037
|
: null;
|
|
1955
2038
|
};
|
|
1956
|
-
for (let index =
|
|
1957
|
-
if (equal(baseline.history[index], snapshot.history[index]) !== true)
|
|
2039
|
+
for (let index = trim; index < baseline.history.length; index++)
|
|
2040
|
+
if (equal(baseline.history[index], snapshot.history[index - trim]) !== true)
|
|
1958
2041
|
return semanticSeed(target);
|
|
1959
2042
|
const rows = [];
|
|
1960
2043
|
for (let index = 0; index < snapshot.grid.length; index++) {
|
|
@@ -1964,19 +2047,20 @@ function semanticPayload(baselineRevision, baseline, target, baselineIncarnation
|
|
|
1964
2047
|
if (!same)
|
|
1965
2048
|
rows.push({ index, row: snapshot.grid[index] });
|
|
1966
2049
|
}
|
|
1967
|
-
const
|
|
2050
|
+
const retained = baseline.history.length - trim;
|
|
2051
|
+
const appendedRows = snapshot.history.length - retained;
|
|
1968
2052
|
// Compact patches serialize synchronously. Do not move a large appended
|
|
1969
2053
|
// suffix or repaint across the seed-only cooperative encoding boundary.
|
|
1970
2054
|
if ((rows.length + appendedRows) * snapshot.cols >= TERMINAL_COMPACT_COOPERATIVE_SEED_CELLS)
|
|
1971
2055
|
return semanticSeed(target);
|
|
1972
|
-
const append = snapshot.history.slice(
|
|
2056
|
+
const append = snapshot.history.slice(retained);
|
|
1973
2057
|
return {
|
|
1974
2058
|
frame: "patch",
|
|
1975
2059
|
baseRevision: baselineRevision,
|
|
1976
2060
|
revision: update.revision,
|
|
1977
2061
|
patch: {
|
|
1978
2062
|
rows,
|
|
1979
|
-
...(append.length ? { historyDelta: { trim
|
|
2063
|
+
...(append.length || trim ? { historyDelta: { trim, append } } : {}),
|
|
1980
2064
|
cursor: snapshot.cursor,
|
|
1981
2065
|
modes: snapshot.modes,
|
|
1982
2066
|
placements: snapshot.placements,
|
|
@@ -1986,6 +2070,37 @@ function semanticPayload(baselineRevision, baseline, target, baselineIncarnation
|
|
|
1986
2070
|
}
|
|
1987
2071
|
return semanticSeed(target);
|
|
1988
2072
|
}
|
|
2073
|
+
/**
|
|
2074
|
+
* How many of the baseline's oldest history rows the target dropped, proved by
|
|
2075
|
+
* row identity only: the replica keeps each surviving row object when tmux
|
|
2076
|
+
* trims at its history-limit. Zero when nothing was trimmed or no shift is
|
|
2077
|
+
* proved; the caller still checks every retained row exactly.
|
|
2078
|
+
*/
|
|
2079
|
+
function historyTrim(baseline, target) {
|
|
2080
|
+
const first = target[0];
|
|
2081
|
+
if (first === undefined || baseline[0] === first)
|
|
2082
|
+
return 0;
|
|
2083
|
+
// A shared row object (a blank row) can recur; prove at most a few shifts.
|
|
2084
|
+
let candidates = 0;
|
|
2085
|
+
for (let trim = 1; trim < baseline.length; trim++) {
|
|
2086
|
+
if (baseline[trim] !== first)
|
|
2087
|
+
continue;
|
|
2088
|
+
if (++candidates > 4)
|
|
2089
|
+
return 0;
|
|
2090
|
+
const retained = baseline.length - trim;
|
|
2091
|
+
if (retained > target.length)
|
|
2092
|
+
continue;
|
|
2093
|
+
let same = true;
|
|
2094
|
+
for (let index = 0; index < retained; index++)
|
|
2095
|
+
if (baseline[trim + index] !== target[index]) {
|
|
2096
|
+
same = false;
|
|
2097
|
+
break;
|
|
2098
|
+
}
|
|
2099
|
+
if (same)
|
|
2100
|
+
return trim;
|
|
2101
|
+
}
|
|
2102
|
+
return 0;
|
|
2103
|
+
}
|
|
1989
2104
|
/** Account represented cells without traversing/serializing the snapshot. */
|
|
1990
2105
|
function canonicalUpdateCellCost(update) {
|
|
1991
2106
|
if (update.type === "terminal.tombstone")
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { assertStockCaptureRepresentable } from "./stock-capture-fidelity.js";
|
|
2
|
+
import { logger } from "../../lib/log.js";
|
|
2
3
|
import { rememberNativeSeedBacking } from "./native-seed-backing.js";
|
|
3
4
|
import { detectWidgetMarkerFromReplicaRows, } from "@tmux-ide/contracts";
|
|
4
5
|
import { applyTerminalReplicaPatch, assembleTerminalReplicaSnapshot, blankTerminalReplicaSnapshot, hashTerminalReplicaSnapshot, hashTerminalReplicaTombstone, hashTerminalWidgetContent, terminalReplicaRowsEqual, } from "@tmux-ide/core";
|
|
@@ -40,6 +41,9 @@ export class TerminalReplicaInterpreter {
|
|
|
40
41
|
#nativeSeedBackingCandidate;
|
|
41
42
|
#generation;
|
|
42
43
|
#workspaceName;
|
|
44
|
+
#stockTabsNoted = false;
|
|
45
|
+
#seedOrdinal = 0;
|
|
46
|
+
#reconstructedSeed = null;
|
|
43
47
|
#semanticPaneId;
|
|
44
48
|
#incarnation;
|
|
45
49
|
#scrollback;
|
|
@@ -119,6 +123,7 @@ export class TerminalReplicaInterpreter {
|
|
|
119
123
|
rows: options.rows,
|
|
120
124
|
scrollback: this.#scrollback,
|
|
121
125
|
});
|
|
126
|
+
this.#backend.startHistoryCollection?.();
|
|
122
127
|
this.#kitty = new KittyImageStore(options.kittyImageBudget ? { budget: options.kittyImageBudget } : {});
|
|
123
128
|
this.#attachKitty(this.#backend);
|
|
124
129
|
this.#snapshot = blankTerminalReplicaSnapshot(options.cols, options.rows);
|
|
@@ -182,6 +187,14 @@ export class TerminalReplicaInterpreter {
|
|
|
182
187
|
currentSeed() {
|
|
183
188
|
return this.#needsSeed ? null : this.#seed();
|
|
184
189
|
}
|
|
190
|
+
/**
|
|
191
|
+
* Names the current seed when its tab cells were reconstructed from a stock
|
|
192
|
+
* capture; null otherwise. Such a seed can wrap a reflowed line at other
|
|
193
|
+
* places than tmux does, so its history can differ from tmux's in length.
|
|
194
|
+
*/
|
|
195
|
+
reconstructedSeed() {
|
|
196
|
+
return this.#reconstructedSeed;
|
|
197
|
+
}
|
|
185
198
|
/** Prioritize one future parser admission, independent of diagnostic tracing. */
|
|
186
199
|
prioritizeNextWrite() {
|
|
187
200
|
if (!this.#closed)
|
|
@@ -249,7 +262,12 @@ export class TerminalReplicaInterpreter {
|
|
|
249
262
|
if (this.#closed)
|
|
250
263
|
return;
|
|
251
264
|
if (operation.type === "reseed") {
|
|
252
|
-
|
|
265
|
+
// A stock capture prints a saved tab cell as one HT and drops its width.
|
|
266
|
+
// Paint it to the next tab stop; refuse only when the parser cannot say
|
|
267
|
+
// where its cursor is.
|
|
268
|
+
const paintCapturedTabs = operation.bootstrap === "painted-capture" && !operation.native;
|
|
269
|
+
let seedReconstructed;
|
|
270
|
+
if (paintCapturedTabs && !this.#backend.graphicsCursor)
|
|
253
271
|
assertStockCaptureRepresentable(operation.captureChunks ?? operation.chunks);
|
|
254
272
|
this.#causalCell?.fail("reseeded");
|
|
255
273
|
const nativeCols = operation.nativeCols ?? operation.cols;
|
|
@@ -264,9 +282,25 @@ export class TerminalReplicaInterpreter {
|
|
|
264
282
|
try {
|
|
265
283
|
if (operation.native && !replacement.importNativeGrid?.(operation.native))
|
|
266
284
|
throw new Error("Native bootstrap requires a compatible interpreter");
|
|
285
|
+
// Capture chunks come first and in order; anything else is live output,
|
|
286
|
+
// where HT stays cursor motion.
|
|
287
|
+
const captured = operation.captureChunks ?? operation.chunks;
|
|
288
|
+
let nextCaptured = 0;
|
|
289
|
+
let reconstructed = false;
|
|
267
290
|
for (const chunk of operation.chunks) {
|
|
268
|
-
|
|
291
|
+
const fromCapture = paintCapturedTabs &&
|
|
292
|
+
nextCaptured < captured.length &&
|
|
293
|
+
Buffer.compare(chunk, captured[nextCaptured]) === 0;
|
|
294
|
+
if (fromCapture)
|
|
295
|
+
nextCaptured += 1;
|
|
296
|
+
if (fromCapture && chunk.includes(9)) {
|
|
297
|
+
reconstructed = true;
|
|
298
|
+
await this.#writeStockCapture(replacement, chunk);
|
|
299
|
+
}
|
|
300
|
+
else
|
|
301
|
+
await this.#writeToBackend(replacement, chunk);
|
|
269
302
|
}
|
|
303
|
+
seedReconstructed = reconstructed;
|
|
270
304
|
if (operation.wraparound !== undefined)
|
|
271
305
|
replacement.setAuthoritativeWraparound(operation.wraparound);
|
|
272
306
|
if (operation.observedModes)
|
|
@@ -288,6 +322,7 @@ export class TerminalReplicaInterpreter {
|
|
|
288
322
|
this.#admitRaw(chunk);
|
|
289
323
|
this.#observeMarkerBytes(chunk);
|
|
290
324
|
}
|
|
325
|
+
replacement.startHistoryCollection?.();
|
|
291
326
|
const previous = this.#backend;
|
|
292
327
|
this.#backend = replacement;
|
|
293
328
|
this.#attachKitty(replacement);
|
|
@@ -303,6 +338,8 @@ export class TerminalReplicaInterpreter {
|
|
|
303
338
|
if (!sameGraphicsBasis)
|
|
304
339
|
this.#kitty.dropCursorPlacements();
|
|
305
340
|
this.#nativeReseedRequested = false;
|
|
341
|
+
this.#seedOrdinal += 1;
|
|
342
|
+
this.#reconstructedSeed = seedReconstructed ? this.#seedOrdinal : null;
|
|
306
343
|
this.#scrollback = scrollback;
|
|
307
344
|
this.#bootstrap = {
|
|
308
345
|
kind: operation.bootstrap,
|
|
@@ -482,6 +519,46 @@ export class TerminalReplicaInterpreter {
|
|
|
482
519
|
this.#tail = run.catch(() => undefined);
|
|
483
520
|
}, 250);
|
|
484
521
|
}
|
|
522
|
+
/**
|
|
523
|
+
* Replay one stock `capture-pane -e` chunk. tmux stores a tab as one wide
|
|
524
|
+
* cell and prints it as a single HT, without its width. Blank the cells up
|
|
525
|
+
* to the next default tab stop instead (ECH, then CUF): that is the cell tmux
|
|
526
|
+
* made when the tab was written at this column, and erased cells take the
|
|
527
|
+
* rendition the capture set for it, as tmux's blank tab cell does. tmux never
|
|
528
|
+
* tabs into the last column (`input_c0_dispatch`).
|
|
529
|
+
* Where this differs from tmux: a row edited after its tab was written
|
|
530
|
+
* (insert or delete character) or written under custom tab stops is columns
|
|
531
|
+
* off in that row. A line reflowed by a resize is worse: tmux keeps the tab
|
|
532
|
+
* cell's width, this measures it again from the new column, so the line can
|
|
533
|
+
* wrap at other places and the pane can hold other rows than tmux shows,
|
|
534
|
+
* until that output scrolls away or is redrawn. The owner accepts the
|
|
535
|
+
* resulting difference in history length (`reconstructedSeed`).
|
|
536
|
+
*/
|
|
537
|
+
async #writeStockCapture(backend, chunk) {
|
|
538
|
+
let start = 0;
|
|
539
|
+
for (;;) {
|
|
540
|
+
const tab = chunk.indexOf(9, start);
|
|
541
|
+
if (tab < 0)
|
|
542
|
+
break;
|
|
543
|
+
if (tab > start)
|
|
544
|
+
await this.#writeToBackend(backend, chunk.subarray(start, tab));
|
|
545
|
+
const column = backend.graphicsCursor().x;
|
|
546
|
+
const stop = Math.min(backend.cols - 1, (Math.floor(column / 8) + 1) * 8);
|
|
547
|
+
if (stop > column)
|
|
548
|
+
await this.#writeToBackend(backend, `\x1b[${stop - column}X\x1b[${stop - column}C`);
|
|
549
|
+
start = tab + 1;
|
|
550
|
+
}
|
|
551
|
+
if (!this.#stockTabsNoted) {
|
|
552
|
+
this.#stockTabsNoted = true;
|
|
553
|
+
// Once per pane: its saved rows are not tmux's exact cells on this server.
|
|
554
|
+
logger.info("terminal-replica", "stock capture: tab positions reconstructed", {
|
|
555
|
+
pane: this.#semanticPaneId,
|
|
556
|
+
workspace: this.#workspaceName,
|
|
557
|
+
});
|
|
558
|
+
}
|
|
559
|
+
if (start < chunk.length)
|
|
560
|
+
await this.#writeToBackend(backend, chunk.subarray(start));
|
|
561
|
+
}
|
|
485
562
|
#writeToBackend(backend, data) {
|
|
486
563
|
if (this.#prioritizeNextWrite) {
|
|
487
564
|
this.#prioritizeNextWrite = false;
|
|
@@ -45,6 +45,7 @@ export class SessionRuntimeTerminalReplicaOwner {
|
|
|
45
45
|
#historyTimer = null;
|
|
46
46
|
#historyChecking = false;
|
|
47
47
|
#historyDirty = false;
|
|
48
|
+
#reconstructedHistoryGap = null;
|
|
48
49
|
constructor(generation, session, semanticPaneId, mirror, options) {
|
|
49
50
|
this.generation = generation;
|
|
50
51
|
this.session = session;
|
|
@@ -325,6 +326,10 @@ export class SessionRuntimeTerminalReplicaOwner {
|
|
|
325
326
|
listener(current);
|
|
326
327
|
return this.#interpreter.onGraphics(listener);
|
|
327
328
|
}
|
|
329
|
+
/** The renderer's cell size, for image placements that give no `c`/`r` (group H). */
|
|
330
|
+
setCellPixels(width, height, precise) {
|
|
331
|
+
this.#interpreter.kittyImages().setCellPixels(width, height, precise);
|
|
332
|
+
}
|
|
328
333
|
/** Image bytes by content digest, while the pane's store still holds them. */
|
|
329
334
|
graphicsImage(digest) {
|
|
330
335
|
return this.#interpreter.kittyImages().imageByDigest(digest) ?? null;
|
|
@@ -394,8 +399,25 @@ export class SessionRuntimeTerminalReplicaOwner {
|
|
|
394
399
|
size === null)
|
|
395
400
|
return;
|
|
396
401
|
const seed = this.#interpreter.currentSeed();
|
|
397
|
-
if (seed
|
|
398
|
-
|
|
402
|
+
if (!seed)
|
|
403
|
+
return;
|
|
404
|
+
const gap = size - seed.snapshot.history.length;
|
|
405
|
+
// A seed with reconstructed tabs can differ from tmux in row count, and
|
|
406
|
+
// a new capture would paint the same rows again. Accept the difference
|
|
407
|
+
// that seed has at its first check, zero included, and reseed only when
|
|
408
|
+
// the difference changes.
|
|
409
|
+
const reconstructed = this.#interpreter.reconstructedSeed();
|
|
410
|
+
if (reconstructed !== null) {
|
|
411
|
+
if (this.#reconstructedHistoryGap?.seed !== reconstructed) {
|
|
412
|
+
this.#reconstructedHistoryGap = { seed: reconstructed, gap };
|
|
413
|
+
return;
|
|
414
|
+
}
|
|
415
|
+
if (this.#reconstructedHistoryGap.gap === gap)
|
|
416
|
+
return;
|
|
417
|
+
}
|
|
418
|
+
else if (gap === 0)
|
|
419
|
+
return;
|
|
420
|
+
upstream.reseed();
|
|
399
421
|
}
|
|
400
422
|
catch {
|
|
401
423
|
// Unavailable metadata is not evidence that history disappeared.
|
|
@@ -207,6 +207,44 @@ export class SessionRuntimeTransportBinding {
|
|
|
207
207
|
throw new SessionRuntimeControllerLeaseError("stale-controller-lease", "The interactive transport does not own input authority.");
|
|
208
208
|
this.#binder.registry.assertExecutionHandle(this.#baseHandle, semanticPaneId);
|
|
209
209
|
}
|
|
210
|
+
/**
|
|
211
|
+
* The session's pane set changed under this live transport (#723). The
|
|
212
|
+
* caller is the daemon's own stream boundary, and the panes come from its
|
|
213
|
+
* trusted inventory of this binding's session: a client can never name a
|
|
214
|
+
* pane here. The grant stays exact: added panes join it, removed panes leave
|
|
215
|
+
* it, and every execution handle is rebuilt from the amended set.
|
|
216
|
+
* All-or-nothing: an invalid pane id changes nothing.
|
|
217
|
+
*/
|
|
218
|
+
amendPaneGrant(change) {
|
|
219
|
+
this.#assertOpen();
|
|
220
|
+
const added = change.added.map((paneId) => TerminalAttachmentSemanticPaneIdSchemaZ.parse(paneId));
|
|
221
|
+
const removed = change.removed.map((paneId) => TerminalAttachmentSemanticPaneIdSchemaZ.parse(paneId));
|
|
222
|
+
for (const paneId of removed) {
|
|
223
|
+
if (!this.#allowedSourcePaneIds.delete(paneId))
|
|
224
|
+
continue;
|
|
225
|
+
if (!this.#contributedSourcePaneIds.delete(paneId))
|
|
226
|
+
continue;
|
|
227
|
+
const next = (this.#shared.grantRefs.get(paneId) ?? 0) - 1;
|
|
228
|
+
if (next > 0)
|
|
229
|
+
this.#shared.grantRefs.set(paneId, next);
|
|
230
|
+
else
|
|
231
|
+
this.#shared.grantRefs.delete(paneId);
|
|
232
|
+
}
|
|
233
|
+
for (const paneId of added) {
|
|
234
|
+
if (this.#allowedSourcePaneIds.has(paneId))
|
|
235
|
+
continue;
|
|
236
|
+
this.#allowedSourcePaneIds.add(paneId);
|
|
237
|
+
// As at bind: only an interactive transport contributes authorship.
|
|
238
|
+
if (!this.#interactive)
|
|
239
|
+
continue;
|
|
240
|
+
this.#contributedSourcePaneIds.add(paneId);
|
|
241
|
+
this.#shared.grantRefs.set(paneId, (this.#shared.grantRefs.get(paneId) ?? 0) + 1);
|
|
242
|
+
}
|
|
243
|
+
// Handles carry a copy of the grant; the next use rebuilds them.
|
|
244
|
+
this.#baseHandle = null;
|
|
245
|
+
this.#baseHandleLease = null;
|
|
246
|
+
this.#intentHandles.clear();
|
|
247
|
+
}
|
|
210
248
|
openTerminalDelivery(semanticPaneId, offer, onMessage, deliveryWorkspaceName) {
|
|
211
249
|
const address = WorkspaceIdSchemaZ.parse(deliveryWorkspaceName ?? this.session);
|
|
212
250
|
this.#assertOpen();
|