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
|
@@ -135,8 +135,8 @@ function authenticatedSurface(transport: SessionRuntimeTransport, hostClientId:
|
|
|
135
135
|
export class SessionRuntimeTransportBinding {
|
|
136
136
|
readonly #binder: SessionRuntimeTransportBinder;
|
|
137
137
|
readonly #shared: SharedClient;
|
|
138
|
-
readonly #allowedSourcePaneIds:
|
|
139
|
-
readonly #contributedSourcePaneIds:
|
|
138
|
+
readonly #allowedSourcePaneIds: Set<string>;
|
|
139
|
+
readonly #contributedSourcePaneIds: Set<string>;
|
|
140
140
|
readonly #interactive: boolean;
|
|
141
141
|
readonly #explicitAuthority: boolean;
|
|
142
142
|
readonly #deliverySubscriberId: string;
|
|
@@ -315,6 +315,46 @@ export class SessionRuntimeTransportBinding {
|
|
|
315
315
|
this.#binder.registry.assertExecutionHandle(this.#baseHandle, semanticPaneId);
|
|
316
316
|
}
|
|
317
317
|
|
|
318
|
+
/**
|
|
319
|
+
* The session's pane set changed under this live transport (#723). The
|
|
320
|
+
* caller is the daemon's own stream boundary, and the panes come from its
|
|
321
|
+
* trusted inventory of this binding's session: a client can never name a
|
|
322
|
+
* pane here. The grant stays exact: added panes join it, removed panes leave
|
|
323
|
+
* it, and every execution handle is rebuilt from the amended set.
|
|
324
|
+
* All-or-nothing: an invalid pane id changes nothing.
|
|
325
|
+
*/
|
|
326
|
+
amendPaneGrant(change: {
|
|
327
|
+
readonly added: readonly string[];
|
|
328
|
+
readonly removed: readonly string[];
|
|
329
|
+
}): void {
|
|
330
|
+
this.#assertOpen();
|
|
331
|
+
const added = change.added.map((paneId) =>
|
|
332
|
+
TerminalAttachmentSemanticPaneIdSchemaZ.parse(paneId),
|
|
333
|
+
);
|
|
334
|
+
const removed = change.removed.map((paneId) =>
|
|
335
|
+
TerminalAttachmentSemanticPaneIdSchemaZ.parse(paneId),
|
|
336
|
+
);
|
|
337
|
+
for (const paneId of removed) {
|
|
338
|
+
if (!this.#allowedSourcePaneIds.delete(paneId)) continue;
|
|
339
|
+
if (!this.#contributedSourcePaneIds.delete(paneId)) continue;
|
|
340
|
+
const next = (this.#shared.grantRefs.get(paneId) ?? 0) - 1;
|
|
341
|
+
if (next > 0) this.#shared.grantRefs.set(paneId, next);
|
|
342
|
+
else this.#shared.grantRefs.delete(paneId);
|
|
343
|
+
}
|
|
344
|
+
for (const paneId of added) {
|
|
345
|
+
if (this.#allowedSourcePaneIds.has(paneId)) continue;
|
|
346
|
+
this.#allowedSourcePaneIds.add(paneId);
|
|
347
|
+
// As at bind: only an interactive transport contributes authorship.
|
|
348
|
+
if (!this.#interactive) continue;
|
|
349
|
+
this.#contributedSourcePaneIds.add(paneId);
|
|
350
|
+
this.#shared.grantRefs.set(paneId, (this.#shared.grantRefs.get(paneId) ?? 0) + 1);
|
|
351
|
+
}
|
|
352
|
+
// Handles carry a copy of the grant; the next use rebuilds them.
|
|
353
|
+
this.#baseHandle = null;
|
|
354
|
+
this.#baseHandleLease = null;
|
|
355
|
+
this.#intentHandles.clear();
|
|
356
|
+
}
|
|
357
|
+
|
|
318
358
|
openTerminalDelivery(
|
|
319
359
|
semanticPaneId: string,
|
|
320
360
|
offer: TerminalDeliveryOffer,
|
|
@@ -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
|
-
|
|
43
|
-
|
|
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
|
|
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
|
}
|
|
@@ -20,7 +20,16 @@ import { existsSync, mkdirSync, readFileSync, renameSync, writeFileSync } from "
|
|
|
20
20
|
import { dirname, join } from "node:path";
|
|
21
21
|
import { z } from "zod";
|
|
22
22
|
import { runTmux } from "@tmux-ide/tmux-bridge";
|
|
23
|
-
import {
|
|
23
|
+
import {
|
|
24
|
+
readProcessTable,
|
|
25
|
+
readProcessTableAsync,
|
|
26
|
+
resolveAgentCommand,
|
|
27
|
+
type ProcEntry,
|
|
28
|
+
} from "../detect/process-tree.ts";
|
|
29
|
+
import {
|
|
30
|
+
snapshotIsRestorePoint,
|
|
31
|
+
type CrashSnapshotSource,
|
|
32
|
+
} from "../../lib/daemon-crash-snapshot.ts";
|
|
24
33
|
import { isListableSession } from "../team/sessions.ts";
|
|
25
34
|
|
|
26
35
|
// ---------------------------------------------------------------------------
|
|
@@ -384,12 +393,29 @@ export function snapshotEvery(): number {
|
|
|
384
393
|
return Number.isInteger(n) && n > 0 ? n : SNAPSHOT_EVERY;
|
|
385
394
|
}
|
|
386
395
|
|
|
396
|
+
export { snapshotIsRestorePoint };
|
|
397
|
+
|
|
398
|
+
/**
|
|
399
|
+
* The file and builder the daemon's own writer uses (#783). The process that
|
|
400
|
+
* owns a headless daemon passes this in; the engine may not import it.
|
|
401
|
+
*/
|
|
402
|
+
export const fleetCrashSnapshotSource: CrashSnapshotSource<FleetSnapshot> = {
|
|
403
|
+
sessionFormat: SNAPSHOT_SESSION_FORMAT,
|
|
404
|
+
paneFormat: SNAPSHOT_PANE_FORMAT,
|
|
405
|
+
build: async (panes, sessions) => buildSnapshot(panes, sessions, await readProcessTableAsync()),
|
|
406
|
+
read: () => readSnapshot(),
|
|
407
|
+
write: writeSnapshot,
|
|
408
|
+
fingerprint: snapshotFingerprint,
|
|
409
|
+
};
|
|
410
|
+
|
|
387
411
|
/** Deps for {@link createSnapshotter} — injectable so the throttle is unit-tested. */
|
|
388
412
|
export interface SnapshotterDeps {
|
|
389
413
|
collect: () => FleetSnapshot;
|
|
390
414
|
read: () => FleetSnapshot | null;
|
|
391
415
|
write: (snapshot: FleetSnapshot) => void;
|
|
392
416
|
every: number;
|
|
417
|
+
/** When the running tmux server started. With it, a restore point is not replaced. */
|
|
418
|
+
serverStartMs?: () => number;
|
|
393
419
|
}
|
|
394
420
|
|
|
395
421
|
/**
|
|
@@ -406,6 +432,7 @@ export function createSnapshotter(deps: SnapshotterDeps): Snapshotter {
|
|
|
406
432
|
let ticks = 0;
|
|
407
433
|
let seeded = false;
|
|
408
434
|
let lastFingerprint: string | null = null;
|
|
435
|
+
let held = false;
|
|
409
436
|
return {
|
|
410
437
|
onTick(): void {
|
|
411
438
|
ticks++;
|
|
@@ -416,6 +443,25 @@ export function createSnapshotter(deps: SnapshotterDeps): Snapshotter {
|
|
|
416
443
|
seeded = true;
|
|
417
444
|
}
|
|
418
445
|
const snapshot = deps.collect();
|
|
446
|
+
if (deps.serverStartMs) {
|
|
447
|
+
const existing = deps.read();
|
|
448
|
+
let serverStartMs = Number.NaN;
|
|
449
|
+
try {
|
|
450
|
+
serverStartMs = deps.serverStartMs();
|
|
451
|
+
} catch {
|
|
452
|
+
// Unknown start time: not a restore point.
|
|
453
|
+
}
|
|
454
|
+
const sessions = snapshot.sessions.map((session) => session.name);
|
|
455
|
+
if (snapshotIsRestorePoint(existing, { serverStartMs, sessions })) {
|
|
456
|
+
held = true;
|
|
457
|
+
return;
|
|
458
|
+
}
|
|
459
|
+
if (held) {
|
|
460
|
+
// Released: the file changed hands or is gone. Compare with it afresh.
|
|
461
|
+
held = false;
|
|
462
|
+
lastFingerprint = existing ? snapshotFingerprint(existing) : null;
|
|
463
|
+
}
|
|
464
|
+
}
|
|
419
465
|
const fingerprint = snapshotFingerprint(snapshot);
|
|
420
466
|
if (fingerprint === lastFingerprint) return;
|
|
421
467
|
lastFingerprint = fingerprint;
|
|
@@ -555,10 +555,13 @@ export function unadoptSession(session: string): void {
|
|
|
555
555
|
// fallback if the fleet probe races a tab closing.
|
|
556
556
|
clearPaneChromeWindows([session]);
|
|
557
557
|
for (const argv of unadoptOptionCommands(session)) runTmux(argv);
|
|
558
|
-
//
|
|
559
|
-
// SERVER-wide binds
|
|
560
|
-
//
|
|
558
|
+
// The popup key, the status-click router, the right-click menus and every
|
|
559
|
+
// Alt/prefix key are SERVER-wide binds. Another session on this server that
|
|
560
|
+
// is still adopted keeps using them, so they go only with the last adopted
|
|
561
|
+
// session (this session's marker is already gone above). A probe that fails
|
|
562
|
+
// reads as "none left", as before. Best-effort so a missing bind (already
|
|
561
563
|
// unadopted) doesn't throw. Unbind the SAME configured keys adopt bound.
|
|
564
|
+
if (listAdoptedSessions().length > 0) return;
|
|
562
565
|
const keys = getAppConfig().keys;
|
|
563
566
|
// The mouse binds (status-click router + the two right-click menu openers).
|
|
564
567
|
for (const undo of [
|
|
@@ -600,5 +603,5 @@ export function unadoptSession(session: string): void {
|
|
|
600
603
|
}
|
|
601
604
|
}
|
|
602
605
|
// The updater only needs to run while something is adopted.
|
|
603
|
-
|
|
606
|
+
stopUpdater();
|
|
604
607
|
}
|
|
@@ -754,6 +754,9 @@ export function runUpdaterLoop(): void {
|
|
|
754
754
|
read: readSnapshot,
|
|
755
755
|
write: writeSnapshot,
|
|
756
756
|
every: config.updater.snapshotEvery,
|
|
757
|
+
// A dead server's snapshot is kept until its sessions are restored (#783).
|
|
758
|
+
serverStartMs: () =>
|
|
759
|
+
Number(runTmux(["display-message", "-p", "#{start_time}"]).toString().trim()) * 1000,
|
|
757
760
|
});
|
|
758
761
|
const shouldGiveUp = createUnreachableCounter();
|
|
759
762
|
const tick = () => {
|
|
@@ -5,6 +5,8 @@ import {
|
|
|
5
5
|
TERMINAL_DELIVERY_BINARY_CAPABILITY_VERSION,
|
|
6
6
|
TERMINAL_DELIVERY_BINARY_LOCAL_CAPABILITY_VERSION,
|
|
7
7
|
PANE_STREAM_INPUT_BYTES_CAPABILITY_VERSION,
|
|
8
|
+
PANE_STREAM_READER_TOPOLOGY_BUNDLE_CAPABILITY_VERSION,
|
|
9
|
+
PANE_STREAM_TOPOLOGY_IN_PLACE_CAPABILITY_VERSION,
|
|
8
10
|
PaneStreamInputLifetimeSchemaZ,
|
|
9
11
|
type PaneStreamInputLifetime,
|
|
10
12
|
PANE_STREAM_PROTOCOL_VERSION,
|
|
@@ -292,6 +294,14 @@ export interface OpenPaneStreamClientOptions {
|
|
|
292
294
|
readonly onLayoutSnapshot?: (
|
|
293
295
|
frame: Extract<PaneStreamServerFrame, { type: "layout-snapshot" }>,
|
|
294
296
|
) => void;
|
|
297
|
+
/**
|
|
298
|
+
* Capability 119 (#723): the stream's pane set changed in place. Offer 119
|
|
299
|
+
* in `stream.terminalDelivery.protocolVersions` only together with this
|
|
300
|
+
* handler; without it a `topology` frame fails the stream. The frame was
|
|
301
|
+
* checked against the live pane set. A removed pane gets no further frames;
|
|
302
|
+
* an added pane's `onNegotiated` and deliveries follow the next layout.
|
|
303
|
+
*/
|
|
304
|
+
readonly onTopology?: (frame: Extract<PaneStreamServerFrame, { type: "topology" }>) => void;
|
|
295
305
|
readonly onInputAck?: (event: {
|
|
296
306
|
readonly pane: string;
|
|
297
307
|
readonly sequence: number;
|
|
@@ -335,6 +345,7 @@ export type ConnectIssuedPaneStreamRuntimeClientOptions = Pick<
|
|
|
335
345
|
| "onTerminalGraphics"
|
|
336
346
|
| "onTerminalGraphicsBlob"
|
|
337
347
|
| "onLayoutSnapshot"
|
|
348
|
+
| "onTopology"
|
|
338
349
|
| "onInputAck"
|
|
339
350
|
| "onCausalCellProof"
|
|
340
351
|
| "onCausalCellFailure"
|
|
@@ -483,6 +494,10 @@ export async function connectIssuedPaneStreamRuntimeClient(
|
|
|
483
494
|
let closed = false;
|
|
484
495
|
let verified = false;
|
|
485
496
|
const binaryPanes = new Set<string>();
|
|
497
|
+
// The stream's pane set. It starts as the issued one and changes only by a
|
|
498
|
+
// `topology` frame from a daemon that confirmed capability 119 (#723).
|
|
499
|
+
let livePanes: readonly string[] = [...descriptor.panes];
|
|
500
|
+
let topologyInPlace = false;
|
|
486
501
|
const binaryGraphicsPanes = new Set<string>();
|
|
487
502
|
const offeredBinary = options.stream.terminalDelivery.protocolVersions.some(
|
|
488
503
|
(version) =>
|
|
@@ -1022,7 +1037,7 @@ export async function connectIssuedPaneStreamRuntimeClient(
|
|
|
1022
1037
|
if (input.kind === "bytes" && !supportsInputBytes)
|
|
1023
1038
|
return Promise.reject(new Error("Byte input capability unavailable"));
|
|
1024
1039
|
const pane = target.semanticPaneId;
|
|
1025
|
-
if (!
|
|
1040
|
+
if (!livePanes.includes(pane)) {
|
|
1026
1041
|
return Promise.reject(
|
|
1027
1042
|
new PaneStreamOperationError("invalid-pane", "Terminal input target is outside the lease"),
|
|
1028
1043
|
);
|
|
@@ -1278,7 +1293,7 @@ export async function connectIssuedPaneStreamRuntimeClient(
|
|
|
1278
1293
|
try {
|
|
1279
1294
|
if (data[0] === 84 && data[1] === 68 && data[2] === 67 && data[3] === 49) {
|
|
1280
1295
|
const { header, bytes } = decodeTerminalDeliveryBinaryChunk(data);
|
|
1281
|
-
if (!
|
|
1296
|
+
if (!livePanes.includes(header.pane) || !binaryPanes.has(header.pane))
|
|
1282
1297
|
return fail("Unnegotiated binary terminal delivery");
|
|
1283
1298
|
options.onTerminalDelivery(header.pane, {
|
|
1284
1299
|
type: "terminal.delivery.chunk",
|
|
@@ -1291,7 +1306,7 @@ export async function connectIssuedPaneStreamRuntimeClient(
|
|
|
1291
1306
|
});
|
|
1292
1307
|
} else {
|
|
1293
1308
|
const { header, bytes } = decodeTerminalGraphicsBinary(data);
|
|
1294
|
-
if (!
|
|
1309
|
+
if (!livePanes.includes(header.pane) || !binaryGraphicsPanes.has(header.pane))
|
|
1295
1310
|
return fail("Unnegotiated binary graphics delivery");
|
|
1296
1311
|
options.onTerminalGraphicsBlob?.(header.pane, header.blob, bytes);
|
|
1297
1312
|
}
|
|
@@ -1351,6 +1366,13 @@ export async function connectIssuedPaneStreamRuntimeClient(
|
|
|
1351
1366
|
return fail("Pane-stream peer client identity did not match the redeemed connection");
|
|
1352
1367
|
connectionClientId = frame.connectionClientId ?? null;
|
|
1353
1368
|
supportsInputLifetime = frame.inputLifetime === true;
|
|
1369
|
+
topologyInPlace =
|
|
1370
|
+
frame.topologyInPlace === true &&
|
|
1371
|
+
options.stream.terminalDelivery.protocolVersions.some(
|
|
1372
|
+
(version) =>
|
|
1373
|
+
version === PANE_STREAM_TOPOLOGY_IN_PLACE_CAPABILITY_VERSION ||
|
|
1374
|
+
version === PANE_STREAM_READER_TOPOLOGY_BUNDLE_CAPABILITY_VERSION,
|
|
1375
|
+
);
|
|
1354
1376
|
supportsInputBytes =
|
|
1355
1377
|
frame.inputBytes === true &&
|
|
1356
1378
|
options.stream.terminalDelivery.protocolVersions.includes(
|
|
@@ -1441,13 +1463,33 @@ export async function connectIssuedPaneStreamRuntimeClient(
|
|
|
1441
1463
|
options.onCausalCellFailure?.(frame.failure);
|
|
1442
1464
|
return;
|
|
1443
1465
|
}
|
|
1466
|
+
if (frame.type === "topology") {
|
|
1467
|
+
if (!topologyInPlace || !options.onTopology) return fail("Unsolicited pane-stream topology");
|
|
1468
|
+
const expected = new Set(livePanes.filter((pane) => !frame.removed.includes(pane)));
|
|
1469
|
+
for (const pane of frame.added) expected.add(pane);
|
|
1470
|
+
if (
|
|
1471
|
+
frame.removed.some((pane) => !livePanes.includes(pane)) ||
|
|
1472
|
+
frame.added.some((pane) => livePanes.includes(pane)) ||
|
|
1473
|
+
expected.size !== frame.panes.length ||
|
|
1474
|
+
frame.panes.some((pane) => !expected.has(pane))
|
|
1475
|
+
)
|
|
1476
|
+
return fail("Pane-stream topology did not match the live pane set");
|
|
1477
|
+
livePanes = [...frame.panes];
|
|
1478
|
+
for (const pane of frame.removed) {
|
|
1479
|
+
binaryPanes.delete(pane);
|
|
1480
|
+
binaryGraphicsPanes.delete(pane);
|
|
1481
|
+
negotiatedDeliveries.delete(pane);
|
|
1482
|
+
}
|
|
1483
|
+
options.onTopology(frame);
|
|
1484
|
+
return;
|
|
1485
|
+
}
|
|
1444
1486
|
if (frame.type === "terminal-graphics") {
|
|
1445
|
-
if (!
|
|
1487
|
+
if (!livePanes.includes(frame.pane)) return fail("Unissued graphics pane");
|
|
1446
1488
|
if (frame.state.binaryBlobs === true) binaryGraphicsPanes.add(frame.pane);
|
|
1447
1489
|
else binaryGraphicsPanes.delete(frame.pane);
|
|
1448
1490
|
}
|
|
1449
1491
|
if (frame.type === "terminal-delivery-ready") {
|
|
1450
|
-
if (!
|
|
1492
|
+
if (!livePanes.includes(frame.pane)) return fail("Unissued terminal pane");
|
|
1451
1493
|
binaryPanes.delete(frame.pane);
|
|
1452
1494
|
if (
|
|
1453
1495
|
frame.negotiation.accepted &&
|