tmux-ide 2.9.26 → 2.9.28
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/README.md +1 -1
- package/bin/cli.js +2046 -623
- package/package.json +2 -2
- package/packages/contracts/src/pane-stream.ts +45 -0
- package/packages/contracts/src/terminal-delivery.ts +114 -3
- package/packages/core/src/index.ts +1 -0
- package/packages/core/src/terminal-delivery-binary.ts +8 -7
- package/packages/core/src/terminal-delivery.ts +174 -3
- package/packages/core/src/terminal-partial-history.ts +152 -0
- package/packages/core/src/terminal-replica.ts +70 -1
- package/packages/daemon/dist/command-center/owner-keep-alive.js +30 -0
- package/packages/daemon/dist/command-center/resources/terminal-runtime-inventory.js +17 -3
- package/packages/daemon/dist/command-center/server.js +3 -0
- package/packages/daemon/dist/command-center/tmux-server-attach.js +51 -0
- package/packages/daemon/dist/command-center/tmux-servers.js +80 -1
- package/packages/daemon/dist/doctor.js +4 -4
- package/packages/daemon/dist/lib/app-config.js +7 -0
- package/packages/daemon/dist/lib/node-requirement.js +20 -0
- package/packages/daemon/dist/lib/require-supported-node.js +8 -0
- package/packages/daemon/dist/lib/tmux-server-session-open.js +38 -12
- package/packages/daemon/dist/lib/workspace-promotion.js +4 -4
- 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/server/pane-stream-upgrade.js +39 -1
- package/packages/daemon/dist/terminal/attachments/native-runtime.js +12 -8
- package/packages/daemon/dist/terminal/mirror/mirror-service.js +13 -0
- package/packages/daemon/dist/terminal/mirror/native-atomic-snapshot.js +17 -7
- package/packages/daemon/dist/terminal/mirror/native-grid-capture.js +129 -5
- package/packages/daemon/dist/terminal/mirror/pane-feed.js +4 -0
- package/packages/daemon/dist/terminal/mirror/pane-hold.js +13 -0
- package/packages/daemon/dist/terminal/mirror/session-channel.js +198 -27
- package/packages/daemon/dist/terminal/pane-stream/lease-manager.js +1 -0
- package/packages/daemon/dist/terminal/pane-stream/pane-stream-websocket.js +198 -12
- package/packages/daemon/dist/terminal/protocol/layout-parse.js +99 -10
- package/packages/daemon/dist/terminal/protocol/session-descriptor-discovery.js +5 -2
- package/packages/daemon/dist/terminal/session-runtime/registry.js +1 -0
- package/packages/daemon/dist/terminal/session-runtime/terminal-delivery-hub.js +465 -42
- package/packages/daemon/dist/terminal/session-runtime/terminal-interpreter-backend.js +2 -1
- package/packages/daemon/dist/terminal/session-runtime/terminal-replica-interpreter.js +46 -1
- package/packages/daemon/dist/terminal/session-runtime/terminal-replica-owner.js +128 -3
- package/packages/daemon/dist/terminal/session-runtime/xterm-terminal-interpreter-backend.js +115 -6
- package/packages/daemon/dist/tui/mirror/open-tui-workspace-runtime-port.js +94 -2
- package/packages/daemon/dist/tui/mirror/runtime/open-tui-generation-host.js +9 -1
- package/packages/daemon/dist/tui/mirror/theme.js +8 -1
- package/packages/daemon/dist/tui/mirror/workspace/connection-feedback.js +8 -0
- package/packages/daemon/src/command-center/attach-window-rule.cases.json +84 -0
- package/packages/daemon/src/command-center/owner-keep-alive.ts +38 -0
- package/packages/daemon/src/command-center/resources/terminal-runtime-inventory.ts +20 -2
- package/packages/daemon/src/command-center/server.ts +3 -0
- package/packages/daemon/src/command-center/tmux-server-attach.ts +75 -0
- package/packages/daemon/src/command-center/tmux-servers.ts +88 -1
- package/packages/daemon/src/doctor.ts +4 -4
- package/packages/daemon/src/lib/app-config.ts +15 -0
- package/packages/daemon/src/lib/node-requirement.ts +22 -0
- package/packages/daemon/src/lib/require-supported-node.ts +9 -0
- package/packages/daemon/src/lib/tmux-server-session-open.ts +53 -15
- package/packages/daemon/src/lib/workspace-promotion.ts +4 -4
- package/packages/daemon/src/server/pane-stream-upgrade.ts +41 -1
- package/packages/daemon/src/terminal/attachments/native-runtime.ts +15 -1
- package/packages/daemon/src/terminal/mirror/events.ts +31 -1
- package/packages/daemon/src/terminal/mirror/mirror-service.ts +19 -0
- package/packages/daemon/src/terminal/mirror/native-atomic-snapshot.ts +16 -5
- package/packages/daemon/src/terminal/mirror/native-grid-capture.ts +164 -5
- package/packages/daemon/src/terminal/mirror/pane-feed.ts +5 -0
- package/packages/daemon/src/terminal/mirror/pane-hold.ts +16 -0
- package/packages/daemon/src/terminal/mirror/session-channel.ts +253 -38
- package/packages/daemon/src/terminal/mirror/trusted-inventory.ts +2 -0
- package/packages/daemon/src/terminal/pane-stream/lease-manager.ts +3 -0
- package/packages/daemon/src/terminal/pane-stream/pane-stream-websocket.ts +240 -12
- package/packages/daemon/src/terminal/protocol/layout-parse.ts +109 -10
- package/packages/daemon/src/terminal/protocol/session-descriptor-discovery.ts +10 -1
- package/packages/daemon/src/terminal/session-runtime/registry.ts +1 -0
- package/packages/daemon/src/terminal/session-runtime/runtime-observability.ts +2 -1
- package/packages/daemon/src/terminal/session-runtime/terminal-delivery-hub.ts +575 -39
- package/packages/daemon/src/terminal/session-runtime/terminal-interpreter-backend.ts +24 -1
- package/packages/daemon/src/terminal/session-runtime/terminal-replica-interpreter.ts +61 -5
- package/packages/daemon/src/terminal/session-runtime/terminal-replica-owner.ts +159 -32
- package/packages/daemon/src/terminal/session-runtime/xterm-terminal-interpreter-backend.ts +134 -11
- package/packages/daemon/src/tui/mirror/open-tui-workspace-runtime-port.ts +101 -2
- package/packages/daemon/src/tui/mirror/runtime/open-tui-generation-host.ts +13 -0
- package/packages/daemon/src/tui/mirror/theme.ts +13 -1
- package/packages/daemon/src/tui/mirror/workspace/connection-feedback.ts +13 -1
- package/packages/daemon-client/src/direct-application-shell-transport.ts +6 -2
- package/packages/daemon-client/src/pane-stream-client.ts +24 -6
- package/packages/daemon-client/src/workspace-client-types.ts +6 -0
- package/packages/daemon-client/src/workspace-client.ts +15 -9
- package/packages/daemon-client/src/workspace-event-supervisor.ts +3 -1
|
@@ -18,12 +18,12 @@ const MAX_TMUX_OUTPUT_BYTES = 128 * 1024;
|
|
|
18
18
|
// is proven, immediately before registry admission. The promotion marker is
|
|
19
19
|
// DELIBERATELY distinct from the m32 open marker so a promoted session is a
|
|
20
20
|
// separate provenance.
|
|
21
|
-
const ADOPTED_OPTION = "@tmux_ide_adopted";
|
|
21
|
+
export const ADOPTED_OPTION = "@tmux_ide_adopted";
|
|
22
22
|
const SESSION_PROMOTED_MARKER_OPTION = "@tmux_ide_workspace_promoted_v1";
|
|
23
23
|
const SESSION_WORKSPACE_OPTION = "@tmux_ide_workspace_name";
|
|
24
24
|
const SESSION_OPERATION_OPTION = "@tmux_ide_workspace_promote_operation";
|
|
25
|
-
const SEMANTIC_PANE_OPTION = "@tmux_ide_pane_id";
|
|
26
|
-
const SEMANTIC_WINDOW_OPTION = "@tmux_ide_window_id";
|
|
25
|
+
export const SEMANTIC_PANE_OPTION = "@tmux_ide_pane_id";
|
|
26
|
+
export const SEMANTIC_WINDOW_OPTION = "@tmux_ide_window_id";
|
|
27
27
|
// Distinctive multi-char field/line delimiters — collision-resistant against
|
|
28
28
|
// arbitrary pane paths, window names and user-controlled `@agent_*` values,
|
|
29
29
|
// matching the fleet-discovery idiom. A value carrying a newline splits into a
|
|
@@ -142,7 +142,7 @@ function isInternalSession(name) {
|
|
|
142
142
|
}
|
|
143
143
|
const VALID_SEMANTIC_PANE_ID = /^[A-Za-z0-9][A-Za-z0-9._-]*$/u;
|
|
144
144
|
const RESERVED_DISCOVERED_PREFIX = "terminal.discovered.";
|
|
145
|
-
function hasValidPaneStamp(value) {
|
|
145
|
+
export function hasValidPaneStamp(value) {
|
|
146
146
|
return (value.length > 0 &&
|
|
147
147
|
value.length <= 128 &&
|
|
148
148
|
VALID_SEMANTIC_PANE_ID.test(value) &&
|
|
@@ -21,9 +21,9 @@
|
|
|
21
21
|
<key>CFBundlePackageType</key>
|
|
22
22
|
<string>APPL</string>
|
|
23
23
|
<key>CFBundleShortVersionString</key>
|
|
24
|
-
<string>2.9.
|
|
24
|
+
<string>2.9.28</string>
|
|
25
25
|
<key>CFBundleVersion</key>
|
|
26
|
-
<string>2.9.
|
|
26
|
+
<string>2.9.28</string>
|
|
27
27
|
<key>LSMinimumSystemVersion</key>
|
|
28
28
|
<string>11.0</string>
|
|
29
29
|
<key>LSUIElement</key>
|
|
Binary file
|
|
Binary file
|
package/packages/daemon/dist/native/TmuxIdeNotifier.app/Contents/_CodeSignature/CodeResources
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
</data>
|
|
11
11
|
<key>Resources/Assets.car</key>
|
|
12
12
|
<data>
|
|
13
|
-
|
|
13
|
+
RP7qh+buOFIHWTXCC8Ce4QEUV4A=
|
|
14
14
|
</data>
|
|
15
15
|
</dict>
|
|
16
16
|
<key>files2</key>
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
<dict>
|
|
27
27
|
<key>hash2</key>
|
|
28
28
|
<data>
|
|
29
|
-
|
|
29
|
+
zct9eeYLwHf/RR6FjRX5S/gPsvyLch7dr664mnX4Z2I=
|
|
30
30
|
</data>
|
|
31
31
|
</dict>
|
|
32
32
|
</dict>
|
|
@@ -16,6 +16,30 @@ function rawHeaderValues(request, expectedName) {
|
|
|
16
16
|
}
|
|
17
17
|
return values;
|
|
18
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* attach-rtt: the client may carry its redeem frame in the upgrade request
|
|
21
|
+
* (base64url of the frame's JSON text), so the daemon answers the 101 and the
|
|
22
|
+
* seed without waiting a round trip for the frame. The 101 says so with
|
|
23
|
+
* `X-Tmux-Ide-Redeem: accepted`; a client that sees no such header sends the
|
|
24
|
+
* frame as before. Absent, the upgrade is exactly as it was.
|
|
25
|
+
*/
|
|
26
|
+
export const PANE_STREAM_REDEEM_HEADER = "x-tmux-ide-redeem";
|
|
27
|
+
/** The frame a redeem header carries, `null` for none, or "invalid". */
|
|
28
|
+
function upgradeRedeemFrame(request) {
|
|
29
|
+
const values = rawHeaderValues(request, PANE_STREAM_REDEEM_HEADER);
|
|
30
|
+
if (values.length === 0)
|
|
31
|
+
return null;
|
|
32
|
+
const value = values[0];
|
|
33
|
+
if (values.length > 1 ||
|
|
34
|
+
value.length === 0 ||
|
|
35
|
+
value.length > Math.ceil((PANE_STREAM_MAX_REDEMPTION_BYTES * 4) / 3) ||
|
|
36
|
+
!/^[A-Za-z0-9_-]+$/u.test(value))
|
|
37
|
+
return "invalid";
|
|
38
|
+
const frame = Buffer.from(value, "base64url");
|
|
39
|
+
return frame.byteLength === 0 || frame.byteLength > PANE_STREAM_MAX_REDEMPTION_BYTES
|
|
40
|
+
? "invalid"
|
|
41
|
+
: frame;
|
|
42
|
+
}
|
|
19
43
|
function rejectUpgrade(socket, status) {
|
|
20
44
|
const phrase = status === 403
|
|
21
45
|
? "Forbidden"
|
|
@@ -53,7 +77,12 @@ export function attachPaneStreamWebSocket(server, coordinator, redemptionPath =
|
|
|
53
77
|
},
|
|
54
78
|
});
|
|
55
79
|
// Old clients ignore the header and answer the pings by protocol.
|
|
56
|
-
|
|
80
|
+
const redeemed = new WeakSet();
|
|
81
|
+
wss.on("headers", (headers, request) => {
|
|
82
|
+
heartbeat.advertise(headers);
|
|
83
|
+
if (redeemed.has(request))
|
|
84
|
+
headers.push("X-Tmux-Ide-Redeem: accepted");
|
|
85
|
+
});
|
|
57
86
|
const upgrade = (request, socket, head) => {
|
|
58
87
|
const rawPath = request.url ?? "";
|
|
59
88
|
const pathname = rawPath.split("?", 1)[0] ?? "";
|
|
@@ -91,6 +120,11 @@ export function attachPaneStreamWebSocket(server, coordinator, redemptionPath =
|
|
|
91
120
|
rejectUpgrade(socket, 403);
|
|
92
121
|
return;
|
|
93
122
|
}
|
|
123
|
+
const redeemFrame = upgradeRedeemFrame(request);
|
|
124
|
+
if (redeemFrame === "invalid") {
|
|
125
|
+
rejectUpgrade(socket, 403);
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
94
128
|
if (!isCurrent()) {
|
|
95
129
|
rejectUpgrade(socket, 410);
|
|
96
130
|
return;
|
|
@@ -109,12 +143,16 @@ export function attachPaneStreamWebSocket(server, coordinator, redemptionPath =
|
|
|
109
143
|
const cancelUnbound = () => decision.admission.cancelBeforeBind();
|
|
110
144
|
socket.once("close", cancelUnbound);
|
|
111
145
|
socket.once("error", cancelUnbound);
|
|
146
|
+
if (redeemFrame)
|
|
147
|
+
redeemed.add(request);
|
|
112
148
|
try {
|
|
113
149
|
wss.handleUpgrade(request, socket, head, (ws) => {
|
|
114
150
|
socket.off("close", cancelUnbound);
|
|
115
151
|
socket.off("error", cancelUnbound);
|
|
116
152
|
heartbeat.watch(ws, `pane-stream ${redemptionPath}`);
|
|
117
153
|
decision.admission.bind(ws);
|
|
154
|
+
if (redeemFrame)
|
|
155
|
+
decision.admission.redeemFromUpgrade(redeemFrame);
|
|
118
156
|
});
|
|
119
157
|
}
|
|
120
158
|
catch {
|
|
@@ -374,6 +374,7 @@ function projectTrustedMirrorInventory(trusted, workspaceName, expectedSessionNa
|
|
|
374
374
|
type: nullable(pane.type),
|
|
375
375
|
missionStamp: nullable(pane.missionStamp),
|
|
376
376
|
dir: boundedWireValue(pane.dir, 4_096),
|
|
377
|
+
...(pane.floating === true ? { floating: true } : {}),
|
|
377
378
|
});
|
|
378
379
|
});
|
|
379
380
|
if (activeCount !== 1 ||
|
|
@@ -384,7 +385,7 @@ function projectTrustedMirrorInventory(trusted, workspaceName, expectedSessionNa
|
|
|
384
385
|
return Object.freeze(panes);
|
|
385
386
|
}
|
|
386
387
|
function analyzeInventoryPanes(panes) {
|
|
387
|
-
return analyzeTrustedSemanticPaneCatalog(panes.map(({ sessionName: _sessionName, index: _index, title: _title, currentCommand: _currentCommand, active: _active, role: _role, name: _name, nameSource: _nameSource, type: _type, missionStamp: _missionStamp, dir: _dir, interactionEndpoint: _interactionEndpoint, nativeIdentity: _nativeIdentity, nativePaneBirthId: _nativePaneBirthId, ...row }) => row));
|
|
388
|
+
return analyzeTrustedSemanticPaneCatalog(panes.map(({ sessionName: _sessionName, index: _index, title: _title, currentCommand: _currentCommand, active: _active, role: _role, name: _name, nameSource: _nameSource, type: _type, missionStamp: _missionStamp, dir: _dir, interactionEndpoint: _interactionEndpoint, nativeIdentity: _nativeIdentity, nativePaneBirthId: _nativePaneBirthId, floating: _floating, ...row }) => row));
|
|
388
389
|
}
|
|
389
390
|
function hasWindowStampCollision(rows) {
|
|
390
391
|
const windows = new Map();
|
|
@@ -462,6 +463,8 @@ const PANE_FORMAT = [
|
|
|
462
463
|
"#{@tmux_ide_window_id}",
|
|
463
464
|
"#{window_index}",
|
|
464
465
|
"#{pane_birth_id}",
|
|
466
|
+
// #882: a floating pane (tmux 3.7+) has no tiled cell; older tmux prints "".
|
|
467
|
+
"#{pane_floating_flag}",
|
|
465
468
|
PANE_WIRE_SENTINEL,
|
|
466
469
|
].join(WIRE_SEPARATOR);
|
|
467
470
|
async function requiredTmuxResult(runner, argv, signal) {
|
|
@@ -502,10 +505,10 @@ function parsePaneSnapshot(stdout, expected) {
|
|
|
502
505
|
const links = new Map();
|
|
503
506
|
for (const line of strictLines(stdout, MAX_DISCOVERED_PANES)) {
|
|
504
507
|
const fields = line.split(WIRE_SEPARATOR);
|
|
505
|
-
if (fields.length !==
|
|
508
|
+
if (fields.length !== 22 || fields[21] !== PANE_WIRE_SENTINEL) {
|
|
506
509
|
throw new NativeTerminalAttachmentRuntimeError("invalid-tmux-output");
|
|
507
510
|
}
|
|
508
|
-
const [sessionName, sessionId, windowId, runtimePaneId, paneCountValue, windowCountValue, stamp, indexValue, title, currentCommand, windowActive, paneActive, role, name, type, missionStamp, dir, windowStampValue, windowIndexValue, nativePaneBirthId,] = fields;
|
|
511
|
+
const [sessionName, sessionId, windowId, runtimePaneId, paneCountValue, windowCountValue, stamp, indexValue, title, currentCommand, windowActive, paneActive, role, name, type, missionStamp, dir, windowStampValue, windowIndexValue, nativePaneBirthId, floating,] = fields;
|
|
509
512
|
if (sessionName !== expected.name ||
|
|
510
513
|
sessionId !== expected.id ||
|
|
511
514
|
!RUNTIME_WINDOW_ID.test(windowId) ||
|
|
@@ -538,6 +541,7 @@ function parsePaneSnapshot(stdout, expected) {
|
|
|
538
541
|
// registered workspace remains the trusted application-shell root, so
|
|
539
542
|
// keep discovery available and carry the empty presentation value.
|
|
540
543
|
dir: boundedWireValue(dir, 4_096),
|
|
544
|
+
...(floating === "1" ? { floating: true } : {}),
|
|
541
545
|
};
|
|
542
546
|
const windowIndex = nonnegativeInteger(windowIndexValue);
|
|
543
547
|
const link = links.get(windowIndex) ?? {
|
|
@@ -672,13 +676,13 @@ export async function discoverWorkspaceRegistryTerminalInventory(registry, runne
|
|
|
672
676
|
}
|
|
673
677
|
}
|
|
674
678
|
}
|
|
675
|
-
const catalog = analyzeTrustedSemanticPaneCatalog(panes.map(({ sessionName: _sessionName, index: _index, title: _title, currentCommand: _currentCommand, active: _active, role: _role, name: _name, nameSource: _nameSource, type: _type, missionStamp: _missionStamp, dir: _dir, interactionEndpoint: _interactionEndpoint, nativeIdentity: _nativeIdentity, nativePaneBirthId: _nativePaneBirthId, ...row }) => row));
|
|
679
|
+
const catalog = analyzeTrustedSemanticPaneCatalog(panes.map(({ sessionName: _sessionName, index: _index, title: _title, currentCommand: _currentCommand, active: _active, role: _role, name: _name, nameSource: _nameSource, type: _type, missionStamp: _missionStamp, dir: _dir, interactionEndpoint: _interactionEndpoint, nativeIdentity: _nativeIdentity, nativePaneBirthId: _nativePaneBirthId, floating: _floating, ...row }) => row));
|
|
676
680
|
return Object.freeze({ panes: Object.freeze(panes), catalog });
|
|
677
681
|
}
|
|
678
682
|
/** Internal raw-id discovery; callers expose only SemanticPaneCatalog resolution. */
|
|
679
683
|
export async function discoverWorkspaceRegistrySemanticPanes(registry, runner, signal) {
|
|
680
684
|
const inventory = await discoverWorkspaceRegistryTerminalInventory(registry, runner, signal);
|
|
681
|
-
return inventory.panes.map(({ sessionName: _sessionName, index: _index, title: _title, currentCommand: _currentCommand, active: _active, role: _role, name: _name, nameSource: _nameSource, type: _type, missionStamp: _missionStamp, dir: _dir, interactionEndpoint: _interactionEndpoint, nativeIdentity: _nativeIdentity, nativePaneBirthId: _nativePaneBirthId, ...row }) => row);
|
|
685
|
+
return inventory.panes.map(({ sessionName: _sessionName, index: _index, title: _title, currentCommand: _currentCommand, active: _active, role: _role, name: _name, nameSource: _nameSource, type: _type, missionStamp: _missionStamp, dir: _dir, interactionEndpoint: _interactionEndpoint, nativeIdentity: _nativeIdentity, nativePaneBirthId: _nativePaneBirthId, floating: _floating, ...row }) => row);
|
|
682
686
|
}
|
|
683
687
|
function quoteArgument(value) {
|
|
684
688
|
if (/\0|\r|\n/u.test(value)) {
|
|
@@ -878,7 +882,7 @@ export class WorkspaceTerminalInventoryRuntime {
|
|
|
878
882
|
new SemanticPaneCatalog({
|
|
879
883
|
discover: async () => {
|
|
880
884
|
const inventory = await this.#discoverTerminalInventory();
|
|
881
|
-
return inventory.panes.map(({ sessionName: _sessionName, index: _index, title: _title, currentCommand: _currentCommand, active: _active, role: _role, name: _name, nameSource: _nameSource, type: _type, missionStamp: _missionStamp, dir: _dir, interactionEndpoint: _interactionEndpoint, nativeIdentity: _nativeIdentity, nativePaneBirthId: _nativePaneBirthId, ...row }) => row);
|
|
885
|
+
return inventory.panes.map(({ sessionName: _sessionName, index: _index, title: _title, currentCommand: _currentCommand, active: _active, role: _role, name: _name, nameSource: _nameSource, type: _type, missionStamp: _missionStamp, dir: _dir, interactionEndpoint: _interactionEndpoint, nativeIdentity: _nativeIdentity, nativePaneBirthId: _nativePaneBirthId, floating: _floating, ...row }) => row);
|
|
882
886
|
},
|
|
883
887
|
});
|
|
884
888
|
const orphanExecutor = new TmuxAttachmentViewExecutor({ runner: this.runner });
|
|
@@ -1445,7 +1449,7 @@ export class NativeTerminalAttachmentRuntime {
|
|
|
1445
1449
|
new SemanticPaneCatalog({
|
|
1446
1450
|
discover: async () => {
|
|
1447
1451
|
const inventory = await discoverTerminalInventory();
|
|
1448
|
-
return inventory.panes.map(({ sessionName: _sessionName, index: _index, title: _title, currentCommand: _currentCommand, active: _active, role: _role, name: _name, nameSource: _nameSource, type: _type, missionStamp: _missionStamp, dir: _dir, interactionEndpoint: _interactionEndpoint, nativeIdentity: _nativeIdentity, nativePaneBirthId: _nativePaneBirthId, ...row }) => row);
|
|
1452
|
+
return inventory.panes.map(({ sessionName: _sessionName, index: _index, title: _title, currentCommand: _currentCommand, active: _active, role: _role, name: _name, nameSource: _nameSource, type: _type, missionStamp: _missionStamp, dir: _dir, interactionEndpoint: _interactionEndpoint, nativeIdentity: _nativeIdentity, nativePaneBirthId: _nativePaneBirthId, floating: _floating, ...row }) => row);
|
|
1449
1453
|
},
|
|
1450
1454
|
});
|
|
1451
1455
|
const launcher = new PtyTmuxAttachmentLauncher({
|
|
@@ -1689,7 +1693,7 @@ export class NativeTerminalAttachmentRuntime {
|
|
|
1689
1693
|
if (panes.length === 0)
|
|
1690
1694
|
return null;
|
|
1691
1695
|
const active = panes.find((pane) => pane.active) ?? panes[0];
|
|
1692
|
-
const sessionCatalog = analyzeTrustedSemanticPaneCatalog(panes.map(({ sessionName: _sessionName, index: _index, title: _title, currentCommand: _currentCommand, active: _active, role: _role, name: _name, nameSource: _nameSource, type: _type, missionStamp: _missionStamp, dir: _dir, interactionEndpoint: _interactionEndpoint, nativeIdentity: _nativeIdentity, nativePaneBirthId: _nativePaneBirthId, ...row }) => row));
|
|
1696
|
+
const sessionCatalog = analyzeTrustedSemanticPaneCatalog(panes.map(({ sessionName: _sessionName, index: _index, title: _title, currentCommand: _currentCommand, active: _active, role: _role, name: _name, nameSource: _nameSource, type: _type, missionStamp: _missionStamp, dir: _dir, interactionEndpoint: _interactionEndpoint, nativeIdentity: _nativeIdentity, nativePaneBirthId: _nativePaneBirthId, floating: _floating, ...row }) => row));
|
|
1693
1697
|
const windowStamps = new Map();
|
|
1694
1698
|
let windowIdentityReady = true;
|
|
1695
1699
|
for (const pane of sessionCatalog.rows) {
|
|
@@ -210,6 +210,18 @@ export class MirrorService {
|
|
|
210
210
|
return null;
|
|
211
211
|
return identity;
|
|
212
212
|
}
|
|
213
|
+
/**
|
|
214
|
+
* #872: a person asked to retry these panes now. Each one's next recovery
|
|
215
|
+
* asks tmux even inside a hold after failed recoveries. A session without a
|
|
216
|
+
* channel has no hold to lift.
|
|
217
|
+
*/
|
|
218
|
+
liftRecoveryHolds(session, semanticPaneIds) {
|
|
219
|
+
const entry = this.channels.get(session);
|
|
220
|
+
if (!entry || entry.retired)
|
|
221
|
+
return;
|
|
222
|
+
for (const semanticPaneId of semanticPaneIds)
|
|
223
|
+
entry.channel.liftRecoveryHold(semanticPaneId);
|
|
224
|
+
}
|
|
213
225
|
async subscribe(request) {
|
|
214
226
|
const entry = await this.acquire(request.session);
|
|
215
227
|
let handle;
|
|
@@ -228,6 +240,7 @@ export class MirrorService {
|
|
|
228
240
|
thaw: () => handle.thaw(),
|
|
229
241
|
reseed: () => handle.reseed(),
|
|
230
242
|
readHistorySize: () => handle.readHistorySize(),
|
|
243
|
+
requestNativeHistory: (historyRequest) => handle.requestNativeHistory(historyRequest),
|
|
231
244
|
captureNativeBacking: () => handle.captureNativeBacking(),
|
|
232
245
|
sendText: (text) => {
|
|
233
246
|
this.assertWindowOwnership(request.session);
|
|
@@ -23,7 +23,7 @@ function validLimit(limit) {
|
|
|
23
23
|
return Number.isSafeInteger(limit) && limit > 0 && limit <= NATIVE_ATOMIC_SNAPSHOT_MAX_BYTES;
|
|
24
24
|
}
|
|
25
25
|
/** One direct child is our admission policy; native Q itself permits other wrapper siblings. */
|
|
26
|
-
export function nativeAtomicSnapshotPlan(target, maxBytes = NATIVE_ATOMIC_SNAPSHOT_MAX_BYTES) {
|
|
26
|
+
export function nativeAtomicSnapshotPlan(target, maxBytes = NATIVE_ATOMIC_SNAPSHOT_MAX_BYTES, historyRows) {
|
|
27
27
|
const validated = TargetSchema.parse(target);
|
|
28
28
|
const continuationBytes = `%continue ${validated.paneId}\n`.length;
|
|
29
29
|
if (!validLimit(maxBytes) || maxBytes <= continuationBytes)
|
|
@@ -41,7 +41,7 @@ export function nativeAtomicSnapshotPlan(target, maxBytes = NATIVE_ATOMIC_SNAPSH
|
|
|
41
41
|
"-U",
|
|
42
42
|
String(maxBytes - continuationBytes),
|
|
43
43
|
"-S",
|
|
44
|
-
|
|
44
|
+
historyStart(historyRows),
|
|
45
45
|
"-t",
|
|
46
46
|
validated.paneId,
|
|
47
47
|
],
|
|
@@ -50,6 +50,14 @@ export function nativeAtomicSnapshotPlan(target, maxBytes = NATIVE_ATOMIC_SNAPSH
|
|
|
50
50
|
limits: { maxBytes, maxLines: MAX_LINES },
|
|
51
51
|
};
|
|
52
52
|
}
|
|
53
|
+
/** #873: `-S -` reads all history; `-S -N` the newest N rows. */
|
|
54
|
+
function historyStart(historyRows) {
|
|
55
|
+
if (historyRows === undefined)
|
|
56
|
+
return "-";
|
|
57
|
+
if (!Number.isSafeInteger(historyRows) || historyRows < 0 || historyRows > 1_000_000)
|
|
58
|
+
throw new TypeError("Invalid atomic snapshot history rows");
|
|
59
|
+
return `-${historyRows}`;
|
|
60
|
+
}
|
|
53
61
|
const decimal = (value) => value !== undefined && /^(0|[1-9][0-9]*)$/u.test(value) && Number.isSafeInteger(Number(value))
|
|
54
62
|
? Number(value)
|
|
55
63
|
: null;
|
|
@@ -64,7 +72,7 @@ function validModes(line, capture) {
|
|
|
64
72
|
numeric[1] !== capture.cursor[1] ||
|
|
65
73
|
numeric[2] !== capture.cols ||
|
|
66
74
|
numeric[3] !== capture.rows ||
|
|
67
|
-
numeric[4] !== capture.history ||
|
|
75
|
+
numeric[4] !== capture.history + (capture.omittedHistory ?? 0) ||
|
|
68
76
|
numeric[5] !== capture.limit)
|
|
69
77
|
return false;
|
|
70
78
|
for (const index of [4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 16, 17, 18, 19])
|
|
@@ -109,7 +117,9 @@ export function decodeNativeAtomicSnapshot(reply, expected, maxBytes = NATIVE_AT
|
|
|
109
117
|
// terminal and exact; a separate asynchronous notification proves nothing here.
|
|
110
118
|
if (reply.lines.at(-1) !== `%continue ${expected.paneId}`)
|
|
111
119
|
return unknown;
|
|
112
|
-
const capture = decodeNativeGridCapture(reply.lines.slice(1, -1).join("\n") + "\n"
|
|
120
|
+
const capture = decodeNativeGridCapture(reply.lines.slice(1, -1).join("\n") + "\n", {
|
|
121
|
+
tail: true,
|
|
122
|
+
});
|
|
113
123
|
if (!capture || !isNativeBootstrapCapture(capture) || !validModes(metadata.cursor, capture))
|
|
114
124
|
return unknown;
|
|
115
125
|
return {
|
|
@@ -143,8 +153,8 @@ const AnsiEndSchema = z
|
|
|
143
153
|
})
|
|
144
154
|
.strict();
|
|
145
155
|
/** V2's -U includes the continuation; v1's existing budget semantics stay unchanged. */
|
|
146
|
-
export function nativeAtomicDualSnapshotPlan(target, maxBytes = NATIVE_ATOMIC_SNAPSHOT_MAX_BYTES) {
|
|
147
|
-
const plan = nativeAtomicSnapshotPlan(target, maxBytes);
|
|
156
|
+
export function nativeAtomicDualSnapshotPlan(target, maxBytes = NATIVE_ATOMIC_SNAPSHOT_MAX_BYTES, historyRows) {
|
|
157
|
+
const plan = nativeAtomicSnapshotPlan(target, maxBytes, historyRows);
|
|
148
158
|
return {
|
|
149
159
|
...plan,
|
|
150
160
|
commands: [
|
|
@@ -157,7 +167,7 @@ export function nativeAtomicDualSnapshotPlan(target, maxBytes = NATIVE_ATOMIC_SN
|
|
|
157
167
|
"-U",
|
|
158
168
|
String(maxBytes),
|
|
159
169
|
"-S",
|
|
160
|
-
|
|
170
|
+
historyStart(historyRows),
|
|
161
171
|
"-t",
|
|
162
172
|
target.paneId,
|
|
163
173
|
],
|
|
@@ -6,9 +6,69 @@ export function isStockRawGridCapture(lines) {
|
|
|
6
6
|
return (/^G [1-9][0-9]*x[1-9][0-9]* \([0-9]+\/[0-9]+\)$/.test(lines[0] ?? "") &&
|
|
7
7
|
/^\tL 0 \((?:-|0)\) flags=/.test(lines[1] ?? ""));
|
|
8
8
|
}
|
|
9
|
+
/**
|
|
10
|
+
* The capability question, asked without reading the pane's history (#869).
|
|
11
|
+
* `-V` exists only in tmux-ide's build, in every revision of the patch that
|
|
12
|
+
* adds its `-R`, and tmux rejects an unknown flag while it parses the command.
|
|
13
|
+
* `-V` comes first, so an upstream server refuses the command at once whatever
|
|
14
|
+
* the pane holds: 3.7 and older lack both flags, and 3.8 has an `-R` of its own
|
|
15
|
+
* that dumps the whole grid as text and ignores `-S` (28 MB for 2,000 lines at
|
|
16
|
+
* 120 columns). tmux-ide's build honours `-S 0 -E 0` and answers with the
|
|
17
|
+
* header and one row.
|
|
18
|
+
*/
|
|
19
|
+
export const NATIVE_BOOTSTRAP_PROBE_FLAGS = ["-V", "-R", "-S", "0", "-E", "0"];
|
|
20
|
+
/** A header and one row; the row has at most one cell per column. */
|
|
21
|
+
export const NATIVE_BOOTSTRAP_PROBE_LIMITS = { maxBytes: 1024 * 1024, maxLines: 4 };
|
|
22
|
+
/**
|
|
23
|
+
* Read the probe's reply. Only a proven answer is "native" or "unsupported";
|
|
24
|
+
* a failed or malformed reply stays "unknown" so the caller can ask again
|
|
25
|
+
* instead of settling the server's capability on a bad read.
|
|
26
|
+
*/
|
|
27
|
+
export function readNativeBootstrapProbe(ok, lines) {
|
|
28
|
+
if (!ok)
|
|
29
|
+
return lines.some((line) => /^(?:parse error: )?(?:command capture-pane: )?unknown flag -V$/.test(line.trim()))
|
|
30
|
+
? "unsupported"
|
|
31
|
+
: "unknown";
|
|
32
|
+
if (isStockRawGridCapture(lines))
|
|
33
|
+
return "unsupported";
|
|
34
|
+
let header;
|
|
35
|
+
try {
|
|
36
|
+
header = JSON.parse(lines[0] ?? "");
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
return "unknown";
|
|
40
|
+
}
|
|
41
|
+
// Every revision's header names the grid's width; a row record does not.
|
|
42
|
+
if (header === null || typeof header !== "object" || !("cols" in header))
|
|
43
|
+
return "unknown";
|
|
44
|
+
// With -V a pane in a mode reports that mode's screen, whose current
|
|
45
|
+
// rendition is null. A build that predates the field omits the key.
|
|
46
|
+
return "version" in header && header.version === 2 && "currentAttributes" in header
|
|
47
|
+
? "native"
|
|
48
|
+
: "unsupported";
|
|
49
|
+
}
|
|
9
50
|
const MAX_BYTES = 16 * 1024 * 1024;
|
|
10
51
|
const MAX_ROWS = MAX_BYTES / 64;
|
|
11
52
|
const MAX_CELLS = 1_000_000;
|
|
53
|
+
/**
|
|
54
|
+
* #873: the first open reads the screen and the newest history that fits this
|
|
55
|
+
* many cells; older rows follow in pieces of the same size. A cell is 25 to 45
|
|
56
|
+
* bytes of the native JSON, so a piece stays well under the 16 MiB reply cap.
|
|
57
|
+
*/
|
|
58
|
+
export const NATIVE_SEED_CELL_BUDGET = 262_144;
|
|
59
|
+
export const NATIVE_HISTORY_PIECE_CELL_BUDGET = 262_144;
|
|
60
|
+
/** History rows a first-open capture asks for at this pane size; never below zero. */
|
|
61
|
+
export function nativeSeedHistoryRows(cols, rows) {
|
|
62
|
+
if (!Number.isSafeInteger(cols) || cols < 1 || !Number.isSafeInteger(rows) || rows < 1)
|
|
63
|
+
return 0;
|
|
64
|
+
return Math.max(0, Math.floor(NATIVE_SEED_CELL_BUDGET / cols) - rows);
|
|
65
|
+
}
|
|
66
|
+
/** Rows one history piece holds at this width; at least one. */
|
|
67
|
+
export function nativeHistoryPieceRows(cols) {
|
|
68
|
+
if (!Number.isSafeInteger(cols) || cols < 1)
|
|
69
|
+
return 1;
|
|
70
|
+
return Math.max(1, Math.floor(NATIVE_HISTORY_PIECE_CELL_BUDGET / cols));
|
|
71
|
+
}
|
|
12
72
|
/** Dense parser import must also fit the cell budget, even for sparse exports. */
|
|
13
73
|
export function isNativeBootstrapCapture(snapshot) {
|
|
14
74
|
return (uint(snapshot.cols, 16384) &&
|
|
@@ -72,7 +132,7 @@ const object = (value) => value !== null && typeof value === "object" && !Array.
|
|
|
72
132
|
* captures and oversized payloads produce no state. Iterate NDJSON records
|
|
73
133
|
* without first allocating an unbounded array of lines.
|
|
74
134
|
*/
|
|
75
|
-
export function decodeNativeGridCapture(text) {
|
|
135
|
+
export function decodeNativeGridCapture(text, options = {}) {
|
|
76
136
|
if (text.length > MAX_BYTES || Buffer.byteLength(text, "utf8") > MAX_BYTES)
|
|
77
137
|
return null;
|
|
78
138
|
let offset = 0;
|
|
@@ -93,8 +153,8 @@ export function decodeNativeGridCapture(text) {
|
|
|
93
153
|
header.cols === 0 ||
|
|
94
154
|
!uint(header.rows, MAX_ROWS) ||
|
|
95
155
|
header.rows === 0 ||
|
|
96
|
-
!uint(header.history, MAX_ROWS) ||
|
|
97
|
-
header.history + header.rows > MAX_ROWS ||
|
|
156
|
+
!uint(header.history, options.tail ? 0xffffffff : MAX_ROWS) ||
|
|
157
|
+
(!options.tail && header.history + header.rows > MAX_ROWS) ||
|
|
98
158
|
!uint(header.hscrolled, header.history) ||
|
|
99
159
|
!uint(header.limit) ||
|
|
100
160
|
!Array.isArray(header.cursor) ||
|
|
@@ -116,7 +176,16 @@ export function decodeNativeGridCapture(text) {
|
|
|
116
176
|
return null;
|
|
117
177
|
const grid = [];
|
|
118
178
|
let count = 0;
|
|
119
|
-
|
|
179
|
+
// #873: a tail capture (`-S -N`) starts at the oldest row it read. tmux
|
|
180
|
+
// numbers rows from its oldest history row, so the first row's number is
|
|
181
|
+
// how many older rows the capture left out.
|
|
182
|
+
const savedOffset = offset;
|
|
183
|
+
const first = options.tail ? next() : null;
|
|
184
|
+
offset = savedOffset;
|
|
185
|
+
const omitted = options.tail && object(first) && uint(first.row, header.history) ? first.row : 0;
|
|
186
|
+
if (header.history - omitted + header.rows > MAX_ROWS)
|
|
187
|
+
return null;
|
|
188
|
+
for (let index = omitted; index < header.history + header.rows; index++) {
|
|
120
189
|
const row = next();
|
|
121
190
|
if (!object(row) ||
|
|
122
191
|
row.row !== index ||
|
|
@@ -174,7 +243,8 @@ export function decodeNativeGridCapture(text) {
|
|
|
174
243
|
: {}),
|
|
175
244
|
cols: header.cols,
|
|
176
245
|
rows: header.rows,
|
|
177
|
-
history: header.history,
|
|
246
|
+
history: header.history - omitted,
|
|
247
|
+
...(omitted > 0 ? { omittedHistory: omitted } : {}),
|
|
178
248
|
hscrolled: header.hscrolled,
|
|
179
249
|
limit: header.limit,
|
|
180
250
|
cursor: Object.freeze([header.cursor[0], header.cursor[1]]),
|
|
@@ -185,3 +255,57 @@ export function decodeNativeGridCapture(text) {
|
|
|
185
255
|
return null;
|
|
186
256
|
}
|
|
187
257
|
}
|
|
258
|
+
/**
|
|
259
|
+
* #873: decode a `capture-pane -R -S <a> -E <b>` reply that holds history rows
|
|
260
|
+
* only. Rows must be contiguous and older than the screen. A malformed reply,
|
|
261
|
+
* an empty one or one with a screen row is null.
|
|
262
|
+
*/
|
|
263
|
+
export function decodeNativeHistoryPiece(text) {
|
|
264
|
+
const newline = text.indexOf("\n");
|
|
265
|
+
if (newline < 0)
|
|
266
|
+
return null;
|
|
267
|
+
let header;
|
|
268
|
+
let first;
|
|
269
|
+
try {
|
|
270
|
+
header = JSON.parse(text.slice(0, newline));
|
|
271
|
+
const second = text.indexOf("\n", newline + 1);
|
|
272
|
+
first = JSON.parse(text.slice(newline + 1, second < 0 ? text.length : second));
|
|
273
|
+
}
|
|
274
|
+
catch {
|
|
275
|
+
return null;
|
|
276
|
+
}
|
|
277
|
+
if (!object(header) || !object(first) || !uint(first.row) || !uint(header.history))
|
|
278
|
+
return null;
|
|
279
|
+
const firstRow = first.row;
|
|
280
|
+
// Rewrite the header as a capture whose history ends at the piece's last row
|
|
281
|
+
// and whose screen is empty, then reuse the full decoder's checks: re-number
|
|
282
|
+
// the rows from zero so its contiguity check applies to the piece.
|
|
283
|
+
const lines = text.endsWith("\n") ? text.slice(0, -1).split("\n") : text.split("\n");
|
|
284
|
+
const count = lines.length - 1;
|
|
285
|
+
if (firstRow + count > header.history)
|
|
286
|
+
return null;
|
|
287
|
+
const renumbered = [];
|
|
288
|
+
for (let index = 0; index < count; index++) {
|
|
289
|
+
const line = lines[index + 1];
|
|
290
|
+
const prefix = `{"row":${firstRow + index},`;
|
|
291
|
+
if (!line.startsWith(prefix))
|
|
292
|
+
return null;
|
|
293
|
+
renumbered.push(`{"row":${index},` + line.slice(prefix.length));
|
|
294
|
+
}
|
|
295
|
+
const synthetic = {
|
|
296
|
+
...header,
|
|
297
|
+
history: count - 1,
|
|
298
|
+
rows: 1,
|
|
299
|
+
hscrolled: 0,
|
|
300
|
+
cursor: [0, 0],
|
|
301
|
+
};
|
|
302
|
+
const capture = decodeNativeGridCapture(JSON.stringify(synthetic) + "\n" + renumbered.join("\n") + "\n");
|
|
303
|
+
if (!capture || capture.version !== 2)
|
|
304
|
+
return null;
|
|
305
|
+
return Object.freeze({
|
|
306
|
+
cols: capture.cols,
|
|
307
|
+
historySize: header.history,
|
|
308
|
+
firstRow,
|
|
309
|
+
rows: capture.grid,
|
|
310
|
+
});
|
|
311
|
+
}
|
|
@@ -37,6 +37,10 @@ export class PaneFeed {
|
|
|
37
37
|
currentState() {
|
|
38
38
|
return this.state;
|
|
39
39
|
}
|
|
40
|
+
/** Changes with every `beginReseed`; a reply read under another value is stale. */
|
|
41
|
+
reseedEpoch() {
|
|
42
|
+
return this.epoch;
|
|
43
|
+
}
|
|
40
44
|
/** Arm a reseed. Returns the epoch token the two reply hooks must present;
|
|
41
45
|
* an in-flight older reseed is invalidated wholesale. */
|
|
42
46
|
beginReseed() {
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A pane's open refused because its recoveries failed in a row (#869, #872):
|
|
3
|
+
* not a try that failed. It carries the time until tmux is asked again and
|
|
4
|
+
* why the last try failed, so the stream can close with both.
|
|
5
|
+
*/
|
|
6
|
+
export class MirrorPaneHeldError extends Error {
|
|
7
|
+
hold;
|
|
8
|
+
constructor(hold) {
|
|
9
|
+
super("Native terminal recovery held after failed recoveries");
|
|
10
|
+
this.name = "MirrorPaneHeldError";
|
|
11
|
+
this.hold = hold;
|
|
12
|
+
}
|
|
13
|
+
}
|