tmux-ide 2.9.23 → 2.9.25
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 +1636 -385
- package/package.json +4 -2
- package/packages/contracts/src/pane-stream.ts +53 -0
- package/packages/daemon/dist/command-center/discovery.js +24 -5
- package/packages/daemon/dist/command-center/server.js +81 -75
- package/packages/daemon/dist/command-center/tmux-servers.js +11 -0
- 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 +22 -8
- package/packages/daemon/dist/lib/headless-daemon.js +63 -6
- package/packages/daemon/dist/lib/home-agent-observer.js +50 -0
- package/packages/daemon/dist/lib/invocation-directory.js +20 -0
- package/packages/daemon/dist/lib/machine-agents.js +18 -1
- package/packages/daemon/dist/lib/orphaned-control-clients.js +162 -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-external-interaction-observer.js +32 -9
- package/packages/daemon/dist/lib/tmux-server-owner.js +26 -4
- 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/lib/workspace-promotion.js +24 -3
- 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/attachments/native-runtime.js +17 -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 +27 -2
- package/packages/daemon/dist/terminal/pane-stream/pane-stream-websocket.js +749 -208
- package/packages/daemon/dist/terminal/session-runtime/registry.js +24 -2
- package/packages/daemon/dist/terminal/session-runtime/terminal-replica-interpreter.js +77 -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/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/dist/tui/mirror/runtime/application-home-agent-navigation.js +57 -4
- package/packages/daemon/dist/tui/mirror/runtime/application-home-agents-owner.js +18 -7
- package/packages/daemon/dist/tui/mirror/runtime/application-machine-agent-navigation.js +17 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-machine-navigation.js +4 -2
- package/packages/daemon/dist/tui/mirror/runtime/application-terminal-interaction-controller.js +55 -14
- package/packages/daemon/src/command-center/discovery.ts +24 -4
- package/packages/daemon/src/command-center/server.ts +67 -67
- package/packages/daemon/src/command-center/tmux-servers.ts +11 -0
- 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 +74 -7
- package/packages/daemon/src/lib/headless-daemon.ts +88 -7
- package/packages/daemon/src/lib/home-agent-observer.ts +53 -0
- package/packages/daemon/src/lib/invocation-directory.ts +21 -0
- package/packages/daemon/src/lib/machine-agents.ts +25 -1
- package/packages/daemon/src/lib/orphaned-control-clients.ts +215 -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-external-interaction-observer.ts +32 -8
- package/packages/daemon/src/lib/tmux-server-owner.ts +28 -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/lib/workspace-promotion.ts +26 -3
- package/packages/daemon/src/terminal/attachments/native-runtime.ts +21 -2
- package/packages/daemon/src/terminal/graphics/kitty-graphics.ts +22 -6
- package/packages/daemon/src/terminal/mirror/mirror-service.ts +27 -0
- package/packages/daemon/src/terminal/mirror/session-channel.ts +32 -2
- package/packages/daemon/src/terminal/pane-stream/pane-stream-websocket.ts +819 -223
- package/packages/daemon/src/terminal/session-runtime/registry.ts +35 -2
- package/packages/daemon/src/terminal/session-runtime/terminal-replica-interpreter.ts +74 -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/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/src/tui/mirror/runtime/application-home-agent-navigation.ts +69 -4
- package/packages/daemon/src/tui/mirror/runtime/application-home-agents-owner.ts +30 -13
- package/packages/daemon/src/tui/mirror/runtime/application-machine-agent-navigation.ts +38 -1
- package/packages/daemon/src/tui/mirror/runtime/application-machine-navigation.ts +7 -2
- package/packages/daemon/src/tui/mirror/runtime/application-root-v2.tsx +4 -4
- package/packages/daemon/src/tui/mirror/runtime/application-terminal-interaction-controller.ts +71 -17
- package/packages/daemon-client/src/pane-stream-client.ts +47 -5
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { AdmittedPaneSelectionOutcome } from "./application-terminal-interaction-controller.ts";
|
|
1
2
|
import { retainsAgentControl } from "./application-retained-agent.ts";
|
|
2
3
|
import {
|
|
3
4
|
createApplicationHomeAgentNavigator,
|
|
@@ -14,9 +15,34 @@ import type { OpenTuiGenerationHostSnapshot } from "./open-tui-generation-host.t
|
|
|
14
15
|
|
|
15
16
|
type HomeNavigatorOptions = Parameters<typeof createApplicationHomeAgentNavigator>[0];
|
|
16
17
|
|
|
18
|
+
/**
|
|
19
|
+
* The two checks the navigator asks of the machines' agent roster: is a row
|
|
20
|
+
* current, and is it current once a re-read in progress has finished.
|
|
21
|
+
*/
|
|
22
|
+
export function machineAgentRosterChecks(roster: {
|
|
23
|
+
isCurrentTarget(machineId: string, row: never): boolean;
|
|
24
|
+
whenCurrentTarget(machineId: string, row: never, signal: AbortSignal): Promise<boolean>;
|
|
25
|
+
}) {
|
|
26
|
+
return {
|
|
27
|
+
isCurrentTarget: (machineId: string, row: HomeAgentNavigationTarget): boolean =>
|
|
28
|
+
roster.isCurrentTarget(machineId, row as never),
|
|
29
|
+
waitForCurrentTarget: (
|
|
30
|
+
machineId: string,
|
|
31
|
+
row: HomeAgentNavigationTarget,
|
|
32
|
+
signal: AbortSignal,
|
|
33
|
+
): Promise<boolean> => roster.whenCurrentTarget(machineId, row as never, signal),
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
17
37
|
/** Machine identity fences the existing exact-agent admission owner. No independent input path. */
|
|
18
38
|
export function createApplicationMachineAgentNavigator(options: {
|
|
19
39
|
readonly isCurrentTarget: (machineId: string, target: HomeAgentNavigationTarget) => boolean;
|
|
40
|
+
/** `isCurrentTarget` once the machine's roster has finished a re-read in progress. */
|
|
41
|
+
readonly waitForCurrentTarget?: (
|
|
42
|
+
machineId: string,
|
|
43
|
+
target: HomeAgentNavigationTarget,
|
|
44
|
+
signal: AbortSignal,
|
|
45
|
+
) => Promise<boolean>;
|
|
20
46
|
readonly selectedMachineId: () => string | null;
|
|
21
47
|
/** Identity of the attached generation, never inferred from the selected machine. */
|
|
22
48
|
readonly generationMachineId: () => string | null;
|
|
@@ -24,7 +50,10 @@ export function createApplicationMachineAgentNavigator(options: {
|
|
|
24
50
|
readonly sessionName: () => string | null;
|
|
25
51
|
readonly startGeneration: HomeNavigatorOptions["startGeneration"];
|
|
26
52
|
/** The interaction controller's selectPane: `admission` must reach it (#764). */
|
|
27
|
-
readonly selectPane: (
|
|
53
|
+
readonly selectPane: (
|
|
54
|
+
paneId: string,
|
|
55
|
+
admission?: Promise<boolean>,
|
|
56
|
+
) => void | Promise<AdmittedPaneSelectionOutcome>;
|
|
28
57
|
readonly showTerminals: HomeNavigatorOptions["showTerminals"];
|
|
29
58
|
readonly setNote: HomeNavigatorOptions["setNote"];
|
|
30
59
|
}) {
|
|
@@ -81,6 +110,14 @@ export function createApplicationMachineAgentNavigator(options: {
|
|
|
81
110
|
agents: semantic.sidebar.agents,
|
|
82
111
|
};
|
|
83
112
|
},
|
|
113
|
+
...(options.waitForCurrentTarget
|
|
114
|
+
? {
|
|
115
|
+
waitForCurrentTarget: (row: HomeAgentNavigationTarget, signal: AbortSignal) =>
|
|
116
|
+
selected()
|
|
117
|
+
? options.waitForCurrentTarget!(machineId, row, signal)
|
|
118
|
+
: Promise.resolve(false),
|
|
119
|
+
}
|
|
120
|
+
: {}),
|
|
84
121
|
waitForGeneration: (key, signal) => waitForHomeAgentSemantic(generation, key, signal),
|
|
85
122
|
waitForAgent: (key, listed, signal) =>
|
|
86
123
|
waitForHomeAgentListed(generation, key, listed, signal),
|
|
@@ -364,7 +364,8 @@ export function createApplicationMachineNavigation(options: {
|
|
|
364
364
|
const row = agentGroups()
|
|
365
365
|
.find((group) => group.machineId === id)
|
|
366
366
|
?.agents.find((agent) => agent.sessionName === sessionName && agent.paneId === paneId);
|
|
367
|
-
|
|
367
|
+
// A row is not current while its roster re-reads; the opener waits for that.
|
|
368
|
+
if (!row || (!agents.isCurrentTarget(id, row) && !agents.isRefreshing(id))) {
|
|
368
369
|
options.setNote(
|
|
369
370
|
"That agent is unavailable or has changed. Wait for its machine to reconnect.",
|
|
370
371
|
);
|
|
@@ -417,7 +418,11 @@ export function createApplicationMachineNavigation(options: {
|
|
|
417
418
|
agents,
|
|
418
419
|
selectedMachineId: () => manager.snapshot().selectedMachineId,
|
|
419
420
|
openHomeAgent: (row: ApplicationMachineAgent, source: "keyboard" | "mouse") => {
|
|
420
|
-
if (
|
|
421
|
+
if (
|
|
422
|
+
(!agents.isCurrentTarget(row.machineId, row) || row.disabled) &&
|
|
423
|
+
!agents.isRefreshing(row.machineId)
|
|
424
|
+
)
|
|
425
|
+
return;
|
|
421
426
|
const session = snapshot()
|
|
422
427
|
.groups.find((group) => group.id === row.machineId)
|
|
423
428
|
?.sessions.find(
|
|
@@ -5,7 +5,7 @@ import { terminalWindowActionCallbacks } from "./application-terminal-workspace-
|
|
|
5
5
|
import { applicationRouteConnection } from "./application-route-connection.ts";
|
|
6
6
|
import { ApplicationMachineOverlays } from "./application-machine-overlays.tsx";
|
|
7
7
|
import { applicationMachineAuthorityManager } from "./application-machine-authority.ts";
|
|
8
|
-
import
|
|
8
|
+
import * as machineAgentNavigation from "./application-machine-agent-navigation.ts";
|
|
9
9
|
import { createApplicationMachineNavigation } from "./application-machine-navigation.ts";
|
|
10
10
|
import { handleFleetShortcut } from "./application-machine-navigation.ts";
|
|
11
11
|
import { disposeApplicationDaemonAuthority } from "./application-daemon-authority.ts";
|
|
@@ -325,7 +325,7 @@ export async function startApplicationRoot(options: StartApplicationRootOptions
|
|
|
325
325
|
);
|
|
326
326
|
const startGeneration = terminalInputIngress.wrapStarter(generationStarter);
|
|
327
327
|
let machineAgentNavigator:
|
|
328
|
-
| ReturnType<typeof createApplicationMachineAgentNavigator>
|
|
328
|
+
| ReturnType<typeof machineAgentNavigation.createApplicationMachineAgentNavigator>
|
|
329
329
|
| undefined;
|
|
330
330
|
const machines = createApplicationMachineNavigation({
|
|
331
331
|
attachedGeneration: generation,
|
|
@@ -360,8 +360,8 @@ export async function startApplicationRoot(options: StartApplicationRootOptions
|
|
|
360
360
|
setNote: appearance.setNote,
|
|
361
361
|
});
|
|
362
362
|
const paneInteractions = createMachinePaneActivity(machines, generationMachineId, shell);
|
|
363
|
-
machineAgentNavigator = createApplicationMachineAgentNavigator({
|
|
364
|
-
|
|
363
|
+
machineAgentNavigator = machineAgentNavigation.createApplicationMachineAgentNavigator({
|
|
364
|
+
...machineAgentNavigation.machineAgentRosterChecks(machines.agents),
|
|
365
365
|
selectedMachineId: machines.selectedMachineId,
|
|
366
366
|
generationMachineId,
|
|
367
367
|
generation,
|
package/packages/daemon/src/tui/mirror/runtime/application-terminal-interaction-controller.ts
CHANGED
|
@@ -51,7 +51,23 @@ interface DiagnosticWindowFrameContext {
|
|
|
51
51
|
readonly rows: number;
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
+
/**
|
|
55
|
+
* How a selection made behind an admission ended. "failed": the daemon did not
|
|
56
|
+
* select the pane. "superseded": a later selection or a new control replaced it.
|
|
57
|
+
*/
|
|
58
|
+
export type AdmittedPaneSelectionOutcome = "selected" | "not-admitted" | "failed" | "superseded";
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Waits between tries of a selection the daemon refused as
|
|
62
|
+
* `pane_inventory_not_ready`: it refuses, before any effect, a pane its
|
|
63
|
+
* inventory has not adopted yet, which is the case for a moment after a pane
|
|
64
|
+
* is created (#764). About 3 s in all.
|
|
65
|
+
*/
|
|
66
|
+
export const PANE_INVENTORY_RETRY_DELAYS_MS: readonly number[] = [100, 200, 400, 800, 1500];
|
|
67
|
+
|
|
54
68
|
export interface ApplicationTerminalInteractionControllerOptions {
|
|
69
|
+
/** Test seam for PANE_INVENTORY_RETRY_DELAYS_MS. */
|
|
70
|
+
readonly selectionRetryDelaysMs?: readonly number[];
|
|
55
71
|
readonly generation: Accessor<OpenTuiGenerationHostSnapshot | null>;
|
|
56
72
|
readonly layout: Accessor<OpenTuiWorkspaceLayoutSnapshot>;
|
|
57
73
|
readonly focusedPane?: Accessor<string | null>;
|
|
@@ -89,7 +105,12 @@ export interface ApplicationTerminalInteractionController {
|
|
|
89
105
|
* selection replaced it; otherwise that input is dropped, never delivered to
|
|
90
106
|
* another pane. (The app's root sends no input while an agent is opening.)
|
|
91
107
|
*/
|
|
92
|
-
selectPane(paneId: string
|
|
108
|
+
selectPane(paneId: string): void;
|
|
109
|
+
selectPane(paneId: string, admission: Promise<boolean>): Promise<AdmittedPaneSelectionOutcome>;
|
|
110
|
+
selectPane(
|
|
111
|
+
paneId: string,
|
|
112
|
+
admission?: Promise<boolean>,
|
|
113
|
+
): void | Promise<AdmittedPaneSelectionOutcome>;
|
|
93
114
|
selectWindowLink(target: WindowLinkTarget): Promise<void>;
|
|
94
115
|
unlinkWindowLink(target: WindowLinkTarget): Promise<string>;
|
|
95
116
|
sendInput(
|
|
@@ -830,7 +851,32 @@ export function createApplicationTerminalInteractionController(
|
|
|
830
851
|
|
|
831
852
|
// The one way a pane selection reaches the runtime (#764: also used once an
|
|
832
853
|
// admitted agent selection settles).
|
|
854
|
+
const selectionRetryDelaysMs = options.selectionRetryDelaysMs ?? PANE_INVENTORY_RETRY_DELAYS_MS;
|
|
855
|
+
/**
|
|
856
|
+
* A refusal for an inventory that is not ready happened before any effect,
|
|
857
|
+
* so the same selection may be sent again while it is still the current one.
|
|
858
|
+
* Any other failure is final.
|
|
859
|
+
*/
|
|
833
860
|
const selectInRuntime = async (paneId: string): Promise<boolean> => {
|
|
861
|
+
const version = paneInput.selectionVersion;
|
|
862
|
+
for (let attempt = 0; ; attempt++) {
|
|
863
|
+
const failure: { current: PaneSelectionFailure | null } = { current: null };
|
|
864
|
+
if (await selectInRuntimeOnce(paneId, failure)) return true;
|
|
865
|
+
const delayMs = selectionRetryDelaysMs[attempt];
|
|
866
|
+
if (
|
|
867
|
+
delayMs === undefined ||
|
|
868
|
+
failure.current?.backendReason !== "pane_inventory_not_ready" ||
|
|
869
|
+
paneInput.selectionVersion !== version
|
|
870
|
+
)
|
|
871
|
+
return false;
|
|
872
|
+
await new Promise<void>((resolve) => setTimeout(resolve, delayMs));
|
|
873
|
+
if (paneInput.selectionVersion !== version) return false;
|
|
874
|
+
}
|
|
875
|
+
};
|
|
876
|
+
const selectInRuntimeOnce = async (
|
|
877
|
+
paneId: string,
|
|
878
|
+
selectionFailure: { current: PaneSelectionFailure | null },
|
|
879
|
+
): Promise<boolean> => {
|
|
834
880
|
finishLinkSelection(false);
|
|
835
881
|
const initial = options.generation();
|
|
836
882
|
const selectionControl = controlIdentity(initial);
|
|
@@ -856,7 +902,6 @@ export function createApplicationTerminalInteractionController(
|
|
|
856
902
|
let dispatchedRendererEpoch: number | undefined;
|
|
857
903
|
const selecting = pendingWindowSwitch;
|
|
858
904
|
const operationId = selecting?.traceId;
|
|
859
|
-
const selectionFailure: { current: PaneSelectionFailure | null } = { current: null };
|
|
860
905
|
const receipt = expected
|
|
861
906
|
? await selectTerminalPane(
|
|
862
907
|
expected,
|
|
@@ -1238,23 +1283,32 @@ export function createApplicationTerminalInteractionController(
|
|
|
1238
1283
|
maybeRequestWindowSwitchFrame();
|
|
1239
1284
|
maybeRequestPaneResizeFrame();
|
|
1240
1285
|
},
|
|
1241
|
-
selectPane: (paneId, admission) => {
|
|
1286
|
+
selectPane: ((paneId: string, admission?: Promise<boolean>) => {
|
|
1242
1287
|
finishLinkSelection(false);
|
|
1243
|
-
if (admission)
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1288
|
+
if (!admission) {
|
|
1289
|
+
paneInput.selectPane(paneId);
|
|
1290
|
+
selectionWaiter.reconcile();
|
|
1291
|
+
return;
|
|
1292
|
+
}
|
|
1293
|
+
let outcome!: Promise<AdmittedPaneSelectionOutcome>;
|
|
1294
|
+
// Ordered now; selected only once admitted, otherwise held input drops.
|
|
1295
|
+
paneInput.selectPane(paneId, {
|
|
1296
|
+
presentOptimistically: false,
|
|
1297
|
+
selection: () => {
|
|
1298
|
+
// A later selection supersedes this one: never select it after all.
|
|
1299
|
+
const version = paneInput.selectionVersion;
|
|
1300
|
+
outcome = admission.then(async (admitted): Promise<AdmittedPaneSelectionOutcome> => {
|
|
1301
|
+
if (!admitted) return "not-admitted";
|
|
1302
|
+
if (paneInput.selectionVersion !== version) return "superseded";
|
|
1303
|
+
if (await selectInRuntime(paneId)) return "selected";
|
|
1304
|
+
return paneInput.selectionVersion === version ? "failed" : "superseded";
|
|
1305
|
+
});
|
|
1306
|
+
return outcome.then((result) => result === "selected");
|
|
1307
|
+
},
|
|
1308
|
+
});
|
|
1256
1309
|
selectionWaiter.reconcile();
|
|
1257
|
-
|
|
1310
|
+
return outcome;
|
|
1311
|
+
}) as ApplicationTerminalInteractionController["selectPane"],
|
|
1258
1312
|
async unlinkWindowLink(target) {
|
|
1259
1313
|
const expected = liveSelectionTarget();
|
|
1260
1314
|
const observed = windowLinkTarget(options.layout(), target.linkId);
|
|
@@ -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 &&
|