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
|
@@ -2,7 +2,7 @@ import { STOCK_SPLIT_OPTIONS_FORMAT } from "../protocol/stock-split-resize.js";
|
|
|
2
2
|
import { layoutContentRows, tiledPaneBorderStatus } from "./layout-content-rows.js";
|
|
3
3
|
import { decodeNativeAtomicSnapshot, decodeNativeAtomicDualSnapshot, nativeAtomicDualSnapshotPlan, nativeAtomicSnapshotPlan, } from "./native-atomic-snapshot.js";
|
|
4
4
|
import { boundedTmuxInteractionAppendCommand } from "../../lib/tmux-interaction-retention.js";
|
|
5
|
-
import { decodeNativeGridCapture, isStockRawGridCapture, isNativeBootstrapCapture, } from "./native-grid-capture.js";
|
|
5
|
+
import { decodeNativeGridCapture, isStockRawGridCapture, isNativeBootstrapCapture, decodeNativeHistoryPiece, nativeSeedHistoryRows, NATIVE_HISTORY_PIECE_CELL_BUDGET, NATIVE_BOOTSTRAP_PROBE_FLAGS, NATIVE_BOOTSTRAP_PROBE_LIMITS, readNativeBootstrapProbe, } from "./native-grid-capture.js";
|
|
6
6
|
/**
|
|
7
7
|
* SessionChannel — one control-mode channel serving every pane subscription
|
|
8
8
|
* of one tmux session (m43 card 1).
|
|
@@ -75,6 +75,14 @@ const RECOVERY_COMMAND_DEADLINE_MS = 500;
|
|
|
75
75
|
const RECOVERY_NO_PROGRESS_DEADLINE_MS = 3_000;
|
|
76
76
|
const RECOVERY_ABSOLUTE_DEADLINE_MS = 5_000;
|
|
77
77
|
const RECOVERY_MAX_ATTEMPTS = 4;
|
|
78
|
+
// A pane whose recoveries keep failing is not asked again at once (#869). Each
|
|
79
|
+
// recovery makes tmux build a whole capture, and a client that lost its stream
|
|
80
|
+
// opens a new one every few seconds for as long as its window is open. From
|
|
81
|
+
// the second failure in a row the pane refuses a new recovery, without a tmux
|
|
82
|
+
// command, for 2 s doubling to 30 s. A recovery that converges ends it.
|
|
83
|
+
const RECOVERY_HOLD_AFTER_FAILURES = 2;
|
|
84
|
+
const RECOVERY_HOLD_BASE_MS = 2_000;
|
|
85
|
+
const RECOVERY_HOLD_MAX_MS = 30_000;
|
|
78
86
|
const MAX_QUEUED_SNAPSHOTS = 64;
|
|
79
87
|
const RECOVERY_CAPTURE_MAX_BYTES = 16 * 1024 * 1024;
|
|
80
88
|
// Budget row bookkeeping separately from wire bytes (64 bytes per retained
|
|
@@ -82,6 +90,12 @@ const RECOVERY_CAPTURE_MAX_BYTES = 16 * 1024 * 1024;
|
|
|
82
90
|
// Both the wire-byte cap and this finite allocation bound remain enforced.
|
|
83
91
|
const RECOVERY_CAPTURE_MAX_LINES = RECOVERY_CAPTURE_MAX_BYTES / 64;
|
|
84
92
|
const RECOVERY_CURSOR_MAX_BYTES = 1_024;
|
|
93
|
+
/** #873: a seed's width when the layout does not know the pane yet. */
|
|
94
|
+
const NATIVE_SEED_FALLBACK_COLS = 512;
|
|
95
|
+
const NATIVE_HISTORY_PIECE_LIMITS = {
|
|
96
|
+
maxBytes: RECOVERY_CAPTURE_MAX_BYTES,
|
|
97
|
+
maxLines: RECOVERY_CAPTURE_MAX_LINES,
|
|
98
|
+
};
|
|
85
99
|
const RECOVERY_CURSOR_PROBE_FORMAT = [
|
|
86
100
|
"#{cursor_x}",
|
|
87
101
|
"#{cursor_y}",
|
|
@@ -112,12 +126,13 @@ const RECOVERY_CURSOR_PROBE_FORMAT = [
|
|
|
112
126
|
// collapsing an empty field shifts every later observation to the wrong key.
|
|
113
127
|
.map((field) => `#{?#{==:${field},},unknown,${field}}`)
|
|
114
128
|
.join(" ");
|
|
115
|
-
/**
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
return
|
|
129
|
+
/**
|
|
130
|
+
* A complete native capture that proves the server cannot bootstrap a replica.
|
|
131
|
+
* Cache only proven server capability; malformed reads can recover.
|
|
132
|
+
*/
|
|
133
|
+
function nativeBootstrapUnsupported(lines, native) {
|
|
134
|
+
return (isStockRawGridCapture(lines) ||
|
|
135
|
+
(native !== null && (native.version !== 2 || native.currentAttributes === undefined)));
|
|
121
136
|
}
|
|
122
137
|
const FAILED_RESEED_RESULT = Object.freeze({
|
|
123
138
|
ok: false,
|
|
@@ -412,6 +427,7 @@ export class SessionChannel {
|
|
|
412
427
|
displayNameSource: display.source,
|
|
413
428
|
windowName: pane.descriptor?.windowName ?? null,
|
|
414
429
|
active: pane.active,
|
|
430
|
+
...(pane.descriptor?.floating ? { floating: true } : {}),
|
|
415
431
|
};
|
|
416
432
|
});
|
|
417
433
|
return {
|
|
@@ -706,6 +722,16 @@ export class SessionChannel {
|
|
|
706
722
|
this.layoutTopologyEpoch === topologyEpoch &&
|
|
707
723
|
this.windowAuthorityOrdinal === authorityOrdinal);
|
|
708
724
|
}
|
|
725
|
+
/**
|
|
726
|
+
* A person asked to retry (#872): the pane's next recovery asks tmux even
|
|
727
|
+
* inside its hold. The failure count is kept, so a failure holds it for the
|
|
728
|
+
* next, longer time. Nothing for a pane that is not held or not known.
|
|
729
|
+
*/
|
|
730
|
+
liftRecoveryHold(semanticPaneId) {
|
|
731
|
+
const pane = this.panesBySemantic.get(semanticPaneId);
|
|
732
|
+
if (pane)
|
|
733
|
+
pane.recoveryHoldUntilMs = 0;
|
|
734
|
+
}
|
|
709
735
|
subscribePane(semanticPaneId, onEvent, onLayout, nativeBootstrap = false) {
|
|
710
736
|
const pane = this.panesBySemantic.get(semanticPaneId);
|
|
711
737
|
if (!pane) {
|
|
@@ -737,6 +763,7 @@ export class SessionChannel {
|
|
|
737
763
|
return {
|
|
738
764
|
semanticPaneId,
|
|
739
765
|
captureNativeBacking: () => this.captureNativeBacking(semanticPaneId, () => !sub.closed && sub.pane === pane && this.panesBySemantic.get(semanticPaneId) === pane),
|
|
766
|
+
requestNativeHistory: (request) => this.requestNativeHistory(sub, request),
|
|
740
767
|
readHistorySize: () => new Promise((resolve) => {
|
|
741
768
|
const current = () => !this.disposed &&
|
|
742
769
|
!sub.closed &&
|
|
@@ -808,15 +835,18 @@ export class SessionChannel {
|
|
|
808
835
|
const inventory = await this.describeTrustedInventory(identity.runtimeSessionId);
|
|
809
836
|
if (this.disposed)
|
|
810
837
|
throw new Error(`mirror session ${this.opts.session} is disposed`);
|
|
838
|
+
// #882: a floating pane has no cell in the tiled layout, so neither the
|
|
839
|
+
// pane set a stream expects nor the layout coverage includes it.
|
|
840
|
+
const tiled = inventory.panes.filter((pane) => pane.floating !== true);
|
|
811
841
|
const expectedByWindow = new Map();
|
|
812
|
-
for (const pane of
|
|
842
|
+
for (const pane of tiled) {
|
|
813
843
|
const expected = expectedByWindow.get(pane.runtimeWindowId) ?? new Set();
|
|
814
844
|
expected.add(pane.semanticPaneId);
|
|
815
845
|
expectedByWindow.set(pane.runtimeWindowId, expected);
|
|
816
846
|
}
|
|
817
847
|
if (expectedSemanticPaneIds) {
|
|
818
848
|
const requested = [...expectedSemanticPaneIds].sort();
|
|
819
|
-
const authoritative =
|
|
849
|
+
const authoritative = tiled.map(({ semanticPaneId }) => semanticPaneId).sort();
|
|
820
850
|
if (requested.length === 0 ||
|
|
821
851
|
new Set(requested).size !== requested.length ||
|
|
822
852
|
requested.length !== authoritative.length ||
|
|
@@ -1198,6 +1228,78 @@ export class SessionChannel {
|
|
|
1198
1228
|
rows: layoutContentRows(pane.top, pane.height, event.rows, event.paneBorderStatus),
|
|
1199
1229
|
};
|
|
1200
1230
|
}
|
|
1231
|
+
/**
|
|
1232
|
+
* #873: history rows a native first-open capture reads: the newest that fit
|
|
1233
|
+
* the seed budget at the pane's tmux size. Older rows are read later in
|
|
1234
|
+
* pieces (`requestNativeHistory`), so the open does not depend on the
|
|
1235
|
+
* history's length. Without a known size, assume a 512-column pane.
|
|
1236
|
+
*/
|
|
1237
|
+
nativeSeedHistoryRowsFor(pane) {
|
|
1238
|
+
const size = this.layoutSizeFor(pane.runtimeId);
|
|
1239
|
+
const rows = size
|
|
1240
|
+
? nativeSeedHistoryRows(size.cols, size.rows)
|
|
1241
|
+
: nativeSeedHistoryRows(NATIVE_SEED_FALLBACK_COLS, 1);
|
|
1242
|
+
const limit = this.opts.historyLines;
|
|
1243
|
+
return limit === undefined ? rows : Math.min(limit, rows);
|
|
1244
|
+
}
|
|
1245
|
+
/**
|
|
1246
|
+
* #873: read history rows `endRow - rows .. endRow - 1` (tmux's numbers,
|
|
1247
|
+
* from its oldest row) for this subscriber. The answer is one `history`
|
|
1248
|
+
* event, sent from the reply callback so it keeps its place among the
|
|
1249
|
+
* deltas. It is null unless the read stayed clear of every output, layout
|
|
1250
|
+
* and reseed crossing: then the subscriber's parser, having applied every
|
|
1251
|
+
* earlier delta, holds exactly the state tmux read the rows from.
|
|
1252
|
+
*/
|
|
1253
|
+
requestNativeHistory(sub, request) {
|
|
1254
|
+
const pane = sub.pane;
|
|
1255
|
+
const { endRow, rows, historySize } = request;
|
|
1256
|
+
if (this.disposed ||
|
|
1257
|
+
sub.closed ||
|
|
1258
|
+
sub.frozen ||
|
|
1259
|
+
!sub.nativeBootstrap ||
|
|
1260
|
+
this.nativeBootstrapUnavailable ||
|
|
1261
|
+
sub.feed.currentState() !== "live" ||
|
|
1262
|
+
![endRow, rows, historySize].every((value) => Number.isSafeInteger(value)) ||
|
|
1263
|
+
endRow < 1 ||
|
|
1264
|
+
rows < 1 ||
|
|
1265
|
+
historySize < endRow)
|
|
1266
|
+
return false;
|
|
1267
|
+
const runtimeId = pane.runtimeId;
|
|
1268
|
+
const size = this.layoutSizeFor(runtimeId);
|
|
1269
|
+
const cols = size?.cols ?? NATIVE_SEED_FALLBACK_COLS;
|
|
1270
|
+
const wanted = Math.min(rows, endRow, Math.max(1, Math.floor(NATIVE_HISTORY_PIECE_CELL_BUDGET / cols)));
|
|
1271
|
+
const start = endRow - wanted - historySize;
|
|
1272
|
+
const end = endRow - 1 - historySize;
|
|
1273
|
+
this.input.flush();
|
|
1274
|
+
const outputOrdinal = this.outputOrdinals.get(runtimeId) ?? 0;
|
|
1275
|
+
const feedEpoch = sub.feed.reseedEpoch();
|
|
1276
|
+
const incarnation = pane.incarnation;
|
|
1277
|
+
let marker = null;
|
|
1278
|
+
this.captureWithViewer(runtimeId, ["-R", "-S", String(start), "-E", String(end)], (value) => {
|
|
1279
|
+
marker = value;
|
|
1280
|
+
}, (reply) => {
|
|
1281
|
+
if (marker) {
|
|
1282
|
+
if (reply.ok)
|
|
1283
|
+
this.clearInternalReadMarkerOption(runtimeId, marker);
|
|
1284
|
+
else
|
|
1285
|
+
this.retireInternalReadMarker(runtimeId, marker);
|
|
1286
|
+
}
|
|
1287
|
+
if (sub.closed || this.disposed)
|
|
1288
|
+
return;
|
|
1289
|
+
const windowId = pane.windowRuntimeId;
|
|
1290
|
+
const current = !sub.frozen &&
|
|
1291
|
+
sub.pane === pane &&
|
|
1292
|
+
this.panesByRuntime.get(runtimeId) === pane &&
|
|
1293
|
+
pane.incarnation === incarnation &&
|
|
1294
|
+
sub.feed.currentState() === "live" &&
|
|
1295
|
+
sub.feed.reseedEpoch() === feedEpoch &&
|
|
1296
|
+
(this.outputOrdinals.get(runtimeId) ?? 0) === outputOrdinal &&
|
|
1297
|
+
!(windowId !== null && this.pendingLayoutOutput.has(windowId));
|
|
1298
|
+
const piece = current && reply.ok ? decodeNativeHistoryPiece(reply.lines.join("\n") + "\n") : null;
|
|
1299
|
+
sub.onEvent({ type: "history", piece });
|
|
1300
|
+
}, NATIVE_HISTORY_PIECE_LIMITS);
|
|
1301
|
+
return true;
|
|
1302
|
+
}
|
|
1201
1303
|
layoutSizeFor(runtime) {
|
|
1202
1304
|
for (const layout of this.layoutByWindow.values()) {
|
|
1203
1305
|
const leaf = layout.leaves.find((candidate) => candidate.id === runtime);
|
|
@@ -1349,8 +1451,12 @@ export class SessionChannel {
|
|
|
1349
1451
|
cancelAbsoluteDeadline: null,
|
|
1350
1452
|
};
|
|
1351
1453
|
this.recoveries.set(pane.runtimeId, recovery);
|
|
1352
|
-
|
|
1353
|
-
|
|
1454
|
+
if (recovery.startedAtMs < pane.recoveryHoldUntilMs)
|
|
1455
|
+
this.failRecovery(recovery, "held-after-failures");
|
|
1456
|
+
else {
|
|
1457
|
+
this.snapshotQueue.set(pane.runtimeId, recovery);
|
|
1458
|
+
this.drainSnapshots();
|
|
1459
|
+
}
|
|
1354
1460
|
}
|
|
1355
1461
|
beginLocalOverflowRecovery(pane) {
|
|
1356
1462
|
this.beginRecovery(pane, "backpressure");
|
|
@@ -1529,6 +1635,8 @@ export class SessionChannel {
|
|
|
1529
1635
|
[...pane.subs].some((sub) => !sub.closed && !sub.frozen && sub.nativeBootstrap)) {
|
|
1530
1636
|
// Negotiate the live server before placing -R in a NOHOOKS transaction:
|
|
1531
1637
|
// an unsupported flag aborts that hook before its completion sentinel.
|
|
1638
|
+
// The probe reads one row, never the history (#869): it has to answer
|
|
1639
|
+
// inside a command deadline whatever the pane holds.
|
|
1532
1640
|
recovery.nativeProbeAttempts = (recovery.nativeProbeAttempts ?? 0) + 1;
|
|
1533
1641
|
let marker = null;
|
|
1534
1642
|
let probeSettled = false;
|
|
@@ -1541,7 +1649,7 @@ export class SessionChannel {
|
|
|
1541
1649
|
else
|
|
1542
1650
|
this.failRecovery(recovery, "command-timeout");
|
|
1543
1651
|
}, RECOVERY_COMMAND_DEADLINE_MS);
|
|
1544
|
-
this.captureWithViewer(pane.runtimeId,
|
|
1652
|
+
this.captureWithViewer(pane.runtimeId, NATIVE_BOOTSTRAP_PROBE_FLAGS, (value) => {
|
|
1545
1653
|
marker = value;
|
|
1546
1654
|
}, (reply) => {
|
|
1547
1655
|
if (marker)
|
|
@@ -1551,10 +1659,10 @@ export class SessionChannel {
|
|
|
1551
1659
|
probeSettled = true;
|
|
1552
1660
|
recovery.cancelCommandDeadline?.();
|
|
1553
1661
|
recovery.cancelCommandDeadline = null;
|
|
1554
|
-
const
|
|
1555
|
-
if (
|
|
1662
|
+
const probe = readNativeBootstrapProbe(reply.ok, reply.lines);
|
|
1663
|
+
if (probe === "native")
|
|
1556
1664
|
this.nativeBootstrapConfirmed = true;
|
|
1557
|
-
else if (
|
|
1665
|
+
else if (probe === "unsupported") {
|
|
1558
1666
|
this.nativeBootstrapUnavailable = true;
|
|
1559
1667
|
for (const current of this.panesByRuntime.values())
|
|
1560
1668
|
for (const sub of current.subs)
|
|
@@ -1568,7 +1676,7 @@ export class SessionChannel {
|
|
|
1568
1676
|
return;
|
|
1569
1677
|
}
|
|
1570
1678
|
this.startStockSnapshot(pane, recovery, lease);
|
|
1571
|
-
},
|
|
1679
|
+
}, NATIVE_BOOTSTRAP_PROBE_LIMITS);
|
|
1572
1680
|
return;
|
|
1573
1681
|
}
|
|
1574
1682
|
recovery.attempts += 1;
|
|
@@ -1773,12 +1881,12 @@ export class SessionChannel {
|
|
|
1773
1881
|
serverEpoch: target.serverEpoch,
|
|
1774
1882
|
paneId: target.paneId,
|
|
1775
1883
|
paneBirthId: target.paneBirthId,
|
|
1776
|
-
})
|
|
1884
|
+
}, undefined, this.nativeSeedHistoryRowsFor(pane))
|
|
1777
1885
|
: nativeAtomicSnapshotPlan({
|
|
1778
1886
|
serverEpoch: target.serverEpoch,
|
|
1779
1887
|
paneId: target.paneId,
|
|
1780
1888
|
paneBirthId: target.paneBirthId,
|
|
1781
|
-
}), (reply) => {
|
|
1889
|
+
}, undefined, this.nativeSeedHistoryRowsFor(pane)), (reply) => {
|
|
1782
1890
|
if (settled || !exact()) {
|
|
1783
1891
|
failed();
|
|
1784
1892
|
return;
|
|
@@ -1988,7 +2096,7 @@ export class SessionChannel {
|
|
|
1988
2096
|
: "";
|
|
1989
2097
|
const body = `set-option -po -t ${pane.runtimeId} ${INTERNAL_READ_OPERATION_OPTION} ${internalReadMarker}` +
|
|
1990
2098
|
` ; ${sentinel("start")}` +
|
|
1991
|
-
` ; capture-pane -p ${nativeCapture ? "-R" : "-e -J"} -S -${this.opts.historyLines ?? ""} -t ${pane.runtimeId}` +
|
|
2099
|
+
` ; capture-pane -p ${nativeCapture ? "-R" : "-e -J"} -S -${nativeCapture ? this.nativeSeedHistoryRowsFor(pane) : (this.opts.historyLines ?? "")} -t ${pane.runtimeId}` +
|
|
1992
2100
|
` ; ${sentinel("capture-end")}` +
|
|
1993
2101
|
(dualCapture
|
|
1994
2102
|
? ` ; capture-pane -p -e -J -S -${this.opts.historyLines ?? ""} -t ${pane.runtimeId} ; ${sentinel("ansi-capture-end")}`
|
|
@@ -2059,9 +2167,11 @@ export class SessionChannel {
|
|
|
2059
2167
|
return;
|
|
2060
2168
|
}
|
|
2061
2169
|
const captureLines = Object.freeze([...result.captureLines]);
|
|
2062
|
-
const native = nativeCapture
|
|
2170
|
+
const native = nativeCapture
|
|
2171
|
+
? decodeNativeGridCapture(captureLines.join("\n"), { tail: true })
|
|
2172
|
+
: null;
|
|
2063
2173
|
if (nativeCapture && (!native || !isNativeBootstrapCapture(native))) {
|
|
2064
|
-
if (nativeBootstrapUnsupported(
|
|
2174
|
+
if (nativeBootstrapUnsupported(captureLines, native)) {
|
|
2065
2175
|
this.nativeBootstrapUnavailable = true;
|
|
2066
2176
|
for (const { sub } of participants)
|
|
2067
2177
|
sub.nativeBootstrap = false;
|
|
@@ -2186,6 +2296,8 @@ export class SessionChannel {
|
|
|
2186
2296
|
recovery.cancelAbsoluteDeadline = null;
|
|
2187
2297
|
this.recoveries.delete(recovery.runtimeId);
|
|
2188
2298
|
recovery.retired = true;
|
|
2299
|
+
// Its hold, if it had one, ended before this recovery could start.
|
|
2300
|
+
pane.failedRecoveries = 0;
|
|
2189
2301
|
this.ledger.noteContinued(recovery.runtimeId);
|
|
2190
2302
|
if (recovery.reason === "requested")
|
|
2191
2303
|
this.ledger.clearRequest(recovery.runtimeId);
|
|
@@ -2215,6 +2327,17 @@ export class SessionChannel {
|
|
|
2215
2327
|
const pane = this.recoveryPane(recovery);
|
|
2216
2328
|
if (!pane)
|
|
2217
2329
|
return;
|
|
2330
|
+
// A refusal is not another failure: it must not lengthen its own hold.
|
|
2331
|
+
if (failureReason !== "held-after-failures") {
|
|
2332
|
+
pane.failedRecoveries += 1;
|
|
2333
|
+
pane.heldWhy =
|
|
2334
|
+
recovery.collectorFailureReason === "capture-byte-cap" ? "too-large" : "failed";
|
|
2335
|
+
const repeats = pane.failedRecoveries - RECOVERY_HOLD_AFTER_FAILURES;
|
|
2336
|
+
if (repeats >= 0)
|
|
2337
|
+
pane.recoveryHoldUntilMs =
|
|
2338
|
+
this.recoveryNowMs() +
|
|
2339
|
+
Math.min(RECOVERY_HOLD_MAX_MS, RECOVERY_HOLD_BASE_MS * 2 ** repeats);
|
|
2340
|
+
}
|
|
2218
2341
|
recovery.cancelCommandDeadline?.();
|
|
2219
2342
|
recovery.cancelCommandDeadline = null;
|
|
2220
2343
|
recovery.cancelNoProgressDeadline?.();
|
|
@@ -2233,12 +2356,23 @@ export class SessionChannel {
|
|
|
2233
2356
|
if (collectorNonce)
|
|
2234
2357
|
this.io.retireAtomicPaneSnapshotCollector?.(collectorNonce, "retired");
|
|
2235
2358
|
this.observeRecovery(pane, recovery, "nonconverged", failureReason);
|
|
2359
|
+
// A refusal says so, with the time left and the last failure's cause, so
|
|
2360
|
+
// the client can tell it from a try and say why the pane does not open.
|
|
2361
|
+
const hold = failureReason === "held-after-failures"
|
|
2362
|
+
? {
|
|
2363
|
+
// Positive: a refusal starts before the hold ends.
|
|
2364
|
+
retryInMs: Math.ceil(pane.recoveryHoldUntilMs - this.recoveryNowMs()),
|
|
2365
|
+
why: pane.heldWhy,
|
|
2366
|
+
}
|
|
2367
|
+
: null;
|
|
2236
2368
|
for (const sub of pane.subs) {
|
|
2237
2369
|
sub.cancelCapture?.();
|
|
2238
2370
|
if (sub.closed || sub.frozen)
|
|
2239
2371
|
continue;
|
|
2240
2372
|
try {
|
|
2241
|
-
sub.onEvent(
|
|
2373
|
+
sub.onEvent(hold
|
|
2374
|
+
? { type: "fault", reason: "native-recovery-failed", hold }
|
|
2375
|
+
: { type: "fault", reason: "native-recovery-failed" });
|
|
2242
2376
|
}
|
|
2243
2377
|
catch {
|
|
2244
2378
|
// A consumer must not prevent sibling subscribers from retiring.
|
|
@@ -2325,6 +2459,13 @@ export class SessionChannel {
|
|
|
2325
2459
|
if (pane && Number.isSafeInteger(size)) {
|
|
2326
2460
|
const cleared = size === 0 && (pane.historySize ?? 0) > 0;
|
|
2327
2461
|
pane.historySize = size;
|
|
2462
|
+
// A cleared history is a new pane to capture: what made its
|
|
2463
|
+
// recoveries fail may be gone, so it is asked again at once (#872).
|
|
2464
|
+
// tmux trimming a full history drops only a tenth and keeps the hold.
|
|
2465
|
+
if (cleared) {
|
|
2466
|
+
pane.failedRecoveries = 0;
|
|
2467
|
+
pane.recoveryHoldUntilMs = 0;
|
|
2468
|
+
}
|
|
2328
2469
|
// A quiet native clear writes no PTY bytes. Reuse the ordered seed path.
|
|
2329
2470
|
if (cleared && !this.recoveries.has(pane.runtimeId)) {
|
|
2330
2471
|
for (const sub of pane.subs)
|
|
@@ -2458,7 +2599,15 @@ export class SessionChannel {
|
|
|
2458
2599
|
return;
|
|
2459
2600
|
}
|
|
2460
2601
|
const leafIds = new Set(membership.leaves.map((leaf) => leaf.id));
|
|
2461
|
-
|
|
2602
|
+
// #882: a floating pane is never a leaf. The bundled build lists it in
|
|
2603
|
+
// the layout's floating section, so its absence there means it closed.
|
|
2604
|
+
// tmux 3.8 leaves it out of a control client's layout altogether, so a
|
|
2605
|
+
// known float there always reads as possibly gone: tmux's pane list
|
|
2606
|
+
// decides. Without that read a closed float stayed listed.
|
|
2607
|
+
const floatingIds = new Set((membership.floating ?? []).map((leaf) => leaf.id));
|
|
2608
|
+
const knownPaneVanished = [...this.panesByRuntime.values()].some((pane) => pane.windowRuntimeId === change.windowId &&
|
|
2609
|
+
!leafIds.has(pane.runtimeId) &&
|
|
2610
|
+
!floatingIds.has(pane.runtimeId));
|
|
2462
2611
|
if (membership.leaves.some((leaf) => !this.panesByRuntime.has(leaf.id)) ||
|
|
2463
2612
|
knownPaneVanished) {
|
|
2464
2613
|
this.scheduleSync();
|
|
@@ -2891,15 +3040,33 @@ export class SessionChannel {
|
|
|
2891
3040
|
const stagedPaneIds = new Set();
|
|
2892
3041
|
let stagedPaneCount = 0;
|
|
2893
3042
|
let stagedPaneMembershipExact = true;
|
|
3043
|
+
// #882: a floating pane (tmux 3.7+) has no cell in the tiled layout. It
|
|
3044
|
+
// belongs to its window by tmux's own pane list; every other pane must be
|
|
3045
|
+
// exactly one tiled leaf, as before.
|
|
3046
|
+
const floatingByWindow = new Map();
|
|
3047
|
+
for (const descriptor of descriptors) {
|
|
3048
|
+
if (!descriptor.floating)
|
|
3049
|
+
continue;
|
|
3050
|
+
const floating = floatingByWindow.get(descriptor.windowId) ?? new Set();
|
|
3051
|
+
floating.add(descriptor.runtimePaneId);
|
|
3052
|
+
floatingByWindow.set(descriptor.windowId, floating);
|
|
3053
|
+
}
|
|
3054
|
+
let floatingPaneCount = 0;
|
|
2894
3055
|
for (const [runtimeWindowId, layout] of confirmedWindowStage.layouts) {
|
|
2895
3056
|
const membership = layout.zoomed ? layout.unzoomed : layout;
|
|
2896
|
-
|
|
3057
|
+
const floating = floatingByWindow.get(runtimeWindowId) ?? new Set();
|
|
3058
|
+
if (!membership ||
|
|
3059
|
+
membership.leaves.length + floating.size !== computedWindowCounts.get(runtimeWindowId) ||
|
|
3060
|
+
(membership.floating ?? []).some((leaf) => !floating.has(leaf.id))) {
|
|
2897
3061
|
stagedPaneMembershipExact = false;
|
|
2898
3062
|
break;
|
|
2899
3063
|
}
|
|
3064
|
+
floatingPaneCount += floating.size;
|
|
2900
3065
|
for (const leaf of membership.leaves) {
|
|
2901
3066
|
stagedPaneCount += 1;
|
|
2902
|
-
if (stagedPaneIds.has(leaf.id) ||
|
|
3067
|
+
if (stagedPaneIds.has(leaf.id) ||
|
|
3068
|
+
floating.has(leaf.id) ||
|
|
3069
|
+
descriptorWindowByPane.get(leaf.id) !== runtimeWindowId) {
|
|
2903
3070
|
stagedPaneMembershipExact = false;
|
|
2904
3071
|
break;
|
|
2905
3072
|
}
|
|
@@ -2912,8 +3079,8 @@ export class SessionChannel {
|
|
|
2912
3079
|
confirmedWindowStage.links.length !== descriptors[0].sessionWindowCount ||
|
|
2913
3080
|
confirmedWindowStage.windows.size !== computedWindowCounts.size ||
|
|
2914
3081
|
!stagedPaneMembershipExact ||
|
|
2915
|
-
stagedPaneCount !== descriptors.length ||
|
|
2916
|
-
stagedPaneIds.size !== descriptors.length ||
|
|
3082
|
+
stagedPaneCount + floatingPaneCount !== descriptors.length ||
|
|
3083
|
+
stagedPaneIds.size + floatingPaneCount !== descriptors.length ||
|
|
2917
3084
|
[...computedWindowCounts.keys()].some((runtimeWindowId) => !confirmedWindowStage.windows.has(runtimeWindowId)))
|
|
2918
3085
|
throw new Error(`trusted inventory for ${this.opts.session} lacks verified identity`);
|
|
2919
3086
|
// Fresh native inventory can beat background discovery after window creation.
|
|
@@ -2990,6 +3157,7 @@ export class SessionChannel {
|
|
|
2990
3157
|
missionStamp: descriptor.missionStamp,
|
|
2991
3158
|
nativePaneBirthId: descriptor.nativePaneBirthId ?? null,
|
|
2992
3159
|
dir: descriptor.cwd ?? "",
|
|
3160
|
+
...(descriptor.floating ? { floating: true } : {}),
|
|
2993
3161
|
});
|
|
2994
3162
|
});
|
|
2995
3163
|
return Object.freeze({
|
|
@@ -3382,6 +3550,9 @@ export class SessionChannel {
|
|
|
3382
3550
|
subs: new Set(),
|
|
3383
3551
|
incarnation: ++this.paneIncarnation,
|
|
3384
3552
|
snapshotLayoutGeneration: 0,
|
|
3553
|
+
failedRecoveries: 0,
|
|
3554
|
+
recoveryHoldUntilMs: 0,
|
|
3555
|
+
heldWhy: "failed",
|
|
3385
3556
|
};
|
|
3386
3557
|
this.panesByRuntime.set(record.runtimeId, record);
|
|
3387
3558
|
this.panesBySemantic.set(record.semanticId, record);
|
|
@@ -236,6 +236,7 @@ export class PaneStreamLeaseManager {
|
|
|
236
236
|
runtimeSessionId: state.runtimeSessionId,
|
|
237
237
|
panes: [...state.request.panes],
|
|
238
238
|
semanticWindowId: state.request.semanticWindowId ?? null,
|
|
239
|
+
retryAskedByPerson: state.request.retryAskedByPerson === true,
|
|
239
240
|
viewerMode: state.request.viewerMode,
|
|
240
241
|
terminalDelivery: state.request.terminalDelivery ?? null,
|
|
241
242
|
status: state.status,
|