tmux-ide 2.9.27 → 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/bin/cli.js +796 -97
- package/package.json +1 -1
- package/packages/contracts/src/pane-stream.ts +36 -0
- package/packages/daemon/dist/command-center/resources/terminal-runtime-inventory.js +17 -3
- package/packages/daemon/dist/command-center/tmux-servers.js +2 -1
- 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 +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 +184 -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/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 +19 -1
- package/packages/daemon/dist/tui/mirror/runtime/open-tui-generation-host.js +9 -1
- package/packages/daemon/dist/tui/mirror/workspace/connection-feedback.js +8 -0
- package/packages/daemon/src/command-center/resources/terminal-runtime-inventory.ts +20 -2
- package/packages/daemon/src/command-center/tmux-servers.ts +4 -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 +215 -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/runtime-observability.ts +2 -1
- 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 +19 -0
- package/packages/daemon/src/tui/mirror/runtime/open-tui-generation-host.ts +13 -0
- 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,8 @@ import { TERMINAL_SURFACE_MAX_CONTROL_BYTES, TERMINAL_SURFACE_CAPABILITY_VERSION
|
|
|
2
2
|
import { NativeSurfaceViewer } from "../graphics/native-surface-viewer.js";
|
|
3
3
|
import { compressGraphicsChunk } from "../graphics/compress-chunk.js";
|
|
4
4
|
import { TERMINAL_GRAPHICS_COMPRESSED_CAPABILITY_VERSION, TERMINAL_GRAPHICS_COMPRESSED_LOCAL_CAPABILITY_VERSION, TERMINAL_PROJECTION_CAPABILITY_VERSION, TERMINAL_PROJECTION_LOCAL_CAPABILITY_VERSION, } from "@tmux-ide/contracts";
|
|
5
|
-
import { PANE_STREAM_INPUT_LIFETIME_CAPABILITY_VERSION, PANE_STREAM_INPUT_BYTES_CAPABILITY_VERSION, PANE_STREAM_BROWSER_ICON_CAPABILITY_VERSION, PANE_STREAM_READER_CAPABILITY_VERSION, PANE_STREAM_BROWSER_KIND_CAPABILITY_VERSION, PANE_STREAM_READER_TOPOLOGY_BUNDLE_CAPABILITY_VERSION, PANE_STREAM_TOPOLOGY_IN_PLACE_CAPABILITY_VERSION, } from "@tmux-ide/contracts";
|
|
5
|
+
import { PANE_STREAM_INPUT_LIFETIME_CAPABILITY_VERSION, PANE_STREAM_INPUT_BYTES_CAPABILITY_VERSION, PANE_STREAM_BROWSER_ICON_CAPABILITY_VERSION, PANE_STREAM_READER_CAPABILITY_VERSION, PANE_STREAM_BROWSER_KIND_CAPABILITY_VERSION, PANE_STREAM_READER_TOPOLOGY_BUNDLE_CAPABILITY_VERSION, PANE_STREAM_TOPOLOGY_IN_PLACE_CAPABILITY_VERSION, PANE_STREAM_PANE_HELD_CLOSE_CODE, paneHeldCloseReason, } from "@tmux-ide/contracts";
|
|
6
|
+
import { MirrorPaneHeldError } from "../mirror/pane-hold.js";
|
|
6
7
|
import { inflateSync } from "node:zlib";
|
|
7
8
|
import { PaneStreamLayoutSnapshotFrameSchemaZ } from "@tmux-ide/contracts";
|
|
8
9
|
import { z } from "zod";
|
|
@@ -86,6 +87,13 @@ function semanticBackendRefusal(error) {
|
|
|
86
87
|
return null;
|
|
87
88
|
}
|
|
88
89
|
const TYPE_FIRST_INPUT_FRAME_PREFIX = Buffer.from('{"type":"input",', "utf8");
|
|
90
|
+
/**
|
|
91
|
+
* #882: the panes a stream can attach to and the layout covers. A floating
|
|
92
|
+
* pane is listed by the description but has no tiled cell, so it is left out.
|
|
93
|
+
*/
|
|
94
|
+
function tiledPanes(described) {
|
|
95
|
+
return described.panes.filter((pane) => pane.floating !== true);
|
|
96
|
+
}
|
|
89
97
|
function startsWithBuffer(raw, prefix) {
|
|
90
98
|
return (raw.length >= prefix.length && raw.compare(prefix, 0, prefix.length, 0, prefix.length) === 0);
|
|
91
99
|
}
|
|
@@ -129,6 +137,32 @@ function sendControl(socket, frame) {
|
|
|
129
137
|
}
|
|
130
138
|
socket.send(encoded, { binary: false });
|
|
131
139
|
}
|
|
140
|
+
/**
|
|
141
|
+
* The hold to close with when every pane that failed to open was held (#872):
|
|
142
|
+
* the longest wait, and too large if any held pane was. Null when any failure
|
|
143
|
+
* was something else.
|
|
144
|
+
*/
|
|
145
|
+
function heldOnly(settled) {
|
|
146
|
+
let retryInMs = 0;
|
|
147
|
+
let tooLarge = false;
|
|
148
|
+
for (const result of settled) {
|
|
149
|
+
if (result.status === "fulfilled") {
|
|
150
|
+
if (!result.value.delivery.negotiation.accepted)
|
|
151
|
+
return null;
|
|
152
|
+
continue;
|
|
153
|
+
}
|
|
154
|
+
const reason = result.reason;
|
|
155
|
+
if (!(reason instanceof MirrorPaneHeldError))
|
|
156
|
+
return null;
|
|
157
|
+
retryInMs = Math.max(retryInMs, reason.hold.retryInMs);
|
|
158
|
+
tooLarge ||= reason.hold.why === "too-large";
|
|
159
|
+
}
|
|
160
|
+
// Called only when a pane did not open, so at least one was held here.
|
|
161
|
+
return { retryInMs, why: tooLarge ? "too-large" : "failed" };
|
|
162
|
+
}
|
|
163
|
+
function errorText(error) {
|
|
164
|
+
return (error instanceof Error ? error.message : String(error)).slice(0, 300);
|
|
165
|
+
}
|
|
132
166
|
function errorFrameCode(error) {
|
|
133
167
|
if (error instanceof PaneStreamLeaseError && error.code === "ticket-expired") {
|
|
134
168
|
return "ticket-expired";
|
|
@@ -165,6 +199,7 @@ export class PaneStreamAdmissionCoordinator {
|
|
|
165
199
|
#flowBudgets;
|
|
166
200
|
#drainTickMs;
|
|
167
201
|
#openRetryDelaysMs;
|
|
202
|
+
#deferredPaneRetryDelaysMs;
|
|
168
203
|
#ownershipWaitMs;
|
|
169
204
|
#maxSocketBufferedBytes;
|
|
170
205
|
#maxInputFrames;
|
|
@@ -202,6 +237,8 @@ export class PaneStreamAdmissionCoordinator {
|
|
|
202
237
|
this.#ledger = new PaneStreamWireLedger(this.#flowBudgets);
|
|
203
238
|
this.#drainTickMs = boundedInteger(options.drainTickMs, 15, 1_000);
|
|
204
239
|
this.#openRetryDelaysMs = options.openRetryDelaysMs ?? PANE_STREAM_OPEN_RETRY_DELAYS_MS;
|
|
240
|
+
this.#deferredPaneRetryDelaysMs =
|
|
241
|
+
options.deferredPaneRetryDelaysMs ?? PANE_STREAM_DEFERRED_PANE_RETRY_DELAYS_MS;
|
|
205
242
|
this.#ownershipWaitMs = options.ownershipWaitMs ?? PANE_STREAM_OWNERSHIP_WAIT_MS;
|
|
206
243
|
this.#maxSocketBufferedBytes = boundedInteger(options.maxSocketBufferedBytes, 32 << 20, 256 << 20);
|
|
207
244
|
this.#maxInputFrames = boundedInteger(options.maxInputFramesPerWindow, 16_384, 1 << 20);
|
|
@@ -250,10 +287,17 @@ export class PaneStreamAdmissionCoordinator {
|
|
|
250
287
|
if (trace)
|
|
251
288
|
this.#observability.recordSpan("transport", "pane-stream-describe-session", describeStartedAtMicros, this.#observability.nowMicros(), trace);
|
|
252
289
|
}
|
|
253
|
-
catch {
|
|
290
|
+
catch (error) {
|
|
291
|
+
// #585: the client is told only "stream-unavailable"; the log keeps why.
|
|
292
|
+
logger.info("pane-stream", "stream refused", {
|
|
293
|
+
step: "issue",
|
|
294
|
+
cause: "describe-session-failed",
|
|
295
|
+
session: context.sessionName,
|
|
296
|
+
error: errorText(error),
|
|
297
|
+
});
|
|
254
298
|
throw new PaneStreamAdmissionError("stream-unavailable", "The workspace session could not be described.");
|
|
255
299
|
}
|
|
256
|
-
const known = new Set(described.
|
|
300
|
+
const known = new Set(tiledPanes(described).map((pane) => pane.semanticPaneId));
|
|
257
301
|
for (const pane of request.panes) {
|
|
258
302
|
if (!known.has(pane)) {
|
|
259
303
|
throw new PaneStreamAdmissionError("pane-not-found", `The pane ${pane} is not present in the workspace session.`);
|
|
@@ -262,7 +306,7 @@ export class PaneStreamAdmissionCoordinator {
|
|
|
262
306
|
// #806: a stream for one window is issued for exactly that window's
|
|
263
307
|
// panes, as the trusted inventory places them now.
|
|
264
308
|
if (request.semanticWindowId !== undefined) {
|
|
265
|
-
const windowPanes = new Set(described
|
|
309
|
+
const windowPanes = new Set(tiledPanes(described)
|
|
266
310
|
.filter((pane) => pane.semanticWindowId === request.semanticWindowId)
|
|
267
311
|
.map((pane) => pane.semanticPaneId));
|
|
268
312
|
if (windowPanes.size !== request.panes.length ||
|
|
@@ -495,6 +539,7 @@ export class PaneStreamAdmissionCoordinator {
|
|
|
495
539
|
ledger: this.#ledger,
|
|
496
540
|
drainTickMs: this.#drainTickMs,
|
|
497
541
|
openRetryDelaysMs: this.#openRetryDelaysMs,
|
|
542
|
+
deferredPaneRetryDelaysMs: this.#deferredPaneRetryDelaysMs,
|
|
498
543
|
ownershipWaitMs: this.#ownershipWaitMs,
|
|
499
544
|
maxSocketBufferedBytes: this.#maxSocketBufferedBytes,
|
|
500
545
|
maxInputFrames: this.#maxInputFrames,
|
|
@@ -652,6 +697,11 @@ class PreAuthAdmission {
|
|
|
652
697
|
if (!this.#open)
|
|
653
698
|
return;
|
|
654
699
|
const code = errorFrameCode(error);
|
|
700
|
+
logger.info("pane-stream", "stream refused", {
|
|
701
|
+
step: "redeem",
|
|
702
|
+
code,
|
|
703
|
+
error: errorText(error),
|
|
704
|
+
});
|
|
655
705
|
try {
|
|
656
706
|
sendControl(socket, {
|
|
657
707
|
type: "error",
|
|
@@ -686,6 +736,12 @@ class PreAuthAdmission {
|
|
|
686
736
|
export const PANE_STREAM_TOPOLOGY_SETTLE_MS = 500;
|
|
687
737
|
/** About half a second in all: long enough for one slow tmux answer, short for a user. */
|
|
688
738
|
export const PANE_STREAM_OPEN_RETRY_DELAYS_MS = [150, 400];
|
|
739
|
+
/**
|
|
740
|
+
* A pane whose delivery still fails after those is tried again this long
|
|
741
|
+
* after the stream opened without it (about 7 s in all, inside the terminal
|
|
742
|
+
* app's 15 s wait for a hidden pane's state). Then the stream closes (#585).
|
|
743
|
+
*/
|
|
744
|
+
export const PANE_STREAM_DEFERRED_PANE_RETRY_DELAYS_MS = [1_000, 2_000, 4_000];
|
|
689
745
|
/** Input waits this long for ownership to be read again before the stream closes. */
|
|
690
746
|
export const PANE_STREAM_OWNERSHIP_WAIT_MS = 2_000;
|
|
691
747
|
/** At most this many input and geometry frames wait for it. */
|
|
@@ -732,6 +788,9 @@ export class PaneStreamLiveConnection {
|
|
|
732
788
|
#ledger;
|
|
733
789
|
#drainTickMs;
|
|
734
790
|
#openRetryDelaysMs;
|
|
791
|
+
/** Waits of `#deferPane`; a close ends them at once (#585). */
|
|
792
|
+
#deferralWaits = new Set();
|
|
793
|
+
#deferredPaneRetryDelaysMs;
|
|
735
794
|
#ownershipWaitMs;
|
|
736
795
|
#maxSocketBufferedBytes;
|
|
737
796
|
#maxInputFrames;
|
|
@@ -838,6 +897,7 @@ export class PaneStreamLiveConnection {
|
|
|
838
897
|
this.#ledger = options.ledger;
|
|
839
898
|
this.#drainTickMs = options.drainTickMs;
|
|
840
899
|
this.#openRetryDelaysMs = options.openRetryDelaysMs;
|
|
900
|
+
this.#deferredPaneRetryDelaysMs = options.deferredPaneRetryDelaysMs;
|
|
841
901
|
this.#ownershipWaitMs = options.ownershipWaitMs ?? PANE_STREAM_OWNERSHIP_WAIT_MS;
|
|
842
902
|
this.#maxSocketBufferedBytes = options.maxSocketBufferedBytes;
|
|
843
903
|
this.#maxInputFrames = options.maxInputFrames;
|
|
@@ -916,17 +976,29 @@ export class PaneStreamLiveConnection {
|
|
|
916
976
|
* none of them. The log says which one, with the error text, so a stream
|
|
917
977
|
* that "just closed" can be traced without a reproduction.
|
|
918
978
|
*/
|
|
919
|
-
#fail(cause, error) {
|
|
979
|
+
#fail(cause, error, pane) {
|
|
920
980
|
if (this.#closed)
|
|
921
981
|
return;
|
|
922
982
|
this.#closeCause = {
|
|
923
983
|
cause,
|
|
984
|
+
...(pane === undefined ? {} : { pane }),
|
|
924
985
|
...(error === undefined
|
|
925
986
|
? {}
|
|
926
987
|
: { error: (error instanceof Error ? error.message : String(error)).slice(0, 300) }),
|
|
927
988
|
};
|
|
928
989
|
this.close(1011, "stream-unavailable");
|
|
929
990
|
}
|
|
991
|
+
/**
|
|
992
|
+
* #872: every pane that did not open is held back after failed recoveries.
|
|
993
|
+
* "Try again later", with the time left and why, so a client can say so
|
|
994
|
+
* instead of counting attempts. The client reconnects as for any close.
|
|
995
|
+
*/
|
|
996
|
+
#closeHeld(hold, pane) {
|
|
997
|
+
if (this.#closed)
|
|
998
|
+
return;
|
|
999
|
+
this.#closeCause = { cause: "pane-held", ...(pane === undefined ? {} : { pane }) };
|
|
1000
|
+
this.close(PANE_STREAM_PANE_HELD_CLOSE_CODE, paneHeldCloseReason(hold));
|
|
1001
|
+
}
|
|
930
1002
|
close(code = 1000, reason = "stream-closed") {
|
|
931
1003
|
if (this.#closed)
|
|
932
1004
|
return;
|
|
@@ -946,6 +1018,11 @@ export class PaneStreamLiveConnection {
|
|
|
946
1018
|
: {}),
|
|
947
1019
|
});
|
|
948
1020
|
this.#closed = true;
|
|
1021
|
+
for (const { timer, wake } of this.#deferralWaits) {
|
|
1022
|
+
clearTimeout(timer);
|
|
1023
|
+
wake();
|
|
1024
|
+
}
|
|
1025
|
+
this.#deferralWaits.clear();
|
|
949
1026
|
this.#ownershipHeld.length = 0;
|
|
950
1027
|
this.#ownershipWake?.();
|
|
951
1028
|
for (const demand of this.#surfaceDemands.values())
|
|
@@ -1022,7 +1099,7 @@ export class PaneStreamLiveConnection {
|
|
|
1022
1099
|
}
|
|
1023
1100
|
if (this.#closed)
|
|
1024
1101
|
return;
|
|
1025
|
-
const known = new Set(described.
|
|
1102
|
+
const known = new Set(tiledPanes(described).map((pane) => pane.semanticPaneId));
|
|
1026
1103
|
if (this.#descriptor.terminalDelivery) {
|
|
1027
1104
|
await this.#subscribeSemantic(known);
|
|
1028
1105
|
return;
|
|
@@ -1200,14 +1277,37 @@ export class PaneStreamLiveConnection {
|
|
|
1200
1277
|
// removes N x attachment latency without allowing a fast pane to make the
|
|
1201
1278
|
// session look ready while a sibling is still missing. allSettled is
|
|
1202
1279
|
// deliberate: partial success is always closed before the socket retires.
|
|
1280
|
+
if (this.#descriptor.retryAskedByPerson)
|
|
1281
|
+
this.#mirror.liftRecoveryHolds?.(this.#descriptor.sessionName, channels.map((channel) => channel.semanticPaneId));
|
|
1203
1282
|
const openings = channels.map((channel) => this.#openPaneDelivery(binding, offer, channel));
|
|
1204
1283
|
const settled = await Promise.allSettled(openings);
|
|
1205
1284
|
const opened = settled.flatMap((result) => result.status === "fulfilled" ? [result.value] : []);
|
|
1285
|
+
// #585: one pane that still fails no longer takes the others down. The
|
|
1286
|
+
// stream opens without it and the pane is tried again (`#deferPane`). A
|
|
1287
|
+
// refusal (authority, or a delivery offer not accepted) still closes it.
|
|
1288
|
+
const deferred = channels.flatMap((channel, index) => {
|
|
1289
|
+
const result = settled[index];
|
|
1290
|
+
return result.status === "rejected" ? [{ channel, error: result.reason }] : [];
|
|
1291
|
+
});
|
|
1292
|
+
const deferrable = deferred.length > 0 &&
|
|
1293
|
+
deferred.length < channels.length &&
|
|
1294
|
+
this.#deferredPaneRetryDelaysMs.length > 0 &&
|
|
1295
|
+
opened.every(({ delivery }) => delivery.negotiation.accepted) &&
|
|
1296
|
+
// A held pane is refused until its hold ends: deferred tries only
|
|
1297
|
+
// repeat the refusal, so it closes at once with its hold (#872).
|
|
1298
|
+
deferred.every(({ error }) => !(error instanceof SessionRuntimeControllerLeaseError) &&
|
|
1299
|
+
!(error instanceof MirrorPaneHeldError));
|
|
1206
1300
|
if (this.#closed ||
|
|
1207
|
-
|
|
1301
|
+
(!deferrable &&
|
|
1302
|
+
settled.some((result) => result.status === "rejected" || !result.value.delivery.negotiation.accepted))) {
|
|
1208
1303
|
await Promise.all(opened.map(({ delivery }) => delivery.close().catch(() => undefined)));
|
|
1209
1304
|
if (!this.#closed) {
|
|
1210
1305
|
const rejected = settled.find((result) => result.status === "rejected");
|
|
1306
|
+
const hold = heldOnly(settled);
|
|
1307
|
+
if (hold) {
|
|
1308
|
+
this.#closeHeld(hold);
|
|
1309
|
+
return;
|
|
1310
|
+
}
|
|
1211
1311
|
this.#fail("delivery-negotiation-failed", rejected?.status === "rejected" ? rejected.reason : "a pane's delivery offer was refused");
|
|
1212
1312
|
}
|
|
1213
1313
|
return;
|
|
@@ -1261,16 +1361,83 @@ export class PaneStreamLiveConnection {
|
|
|
1261
1361
|
opened.sort((left, right) => Number(visibleAtDelivery.has(right.channel.semanticPaneId)) -
|
|
1262
1362
|
Number(visibleAtDelivery.has(left.channel.semanticPaneId)));
|
|
1263
1363
|
await this.#publishOpenedDeliveries(opened);
|
|
1364
|
+
if (deferrable)
|
|
1365
|
+
for (const { channel, error } of deferred)
|
|
1366
|
+
void this.#deferPane(binding, offer, channel, error);
|
|
1264
1367
|
this.#closeIfAllPanesGone();
|
|
1265
1368
|
}
|
|
1369
|
+
/**
|
|
1370
|
+
* A pane left out of the opening (#585): try its delivery again after each
|
|
1371
|
+
* deferred delay and announce it like a pane added in place. Only when
|
|
1372
|
+
* every try failed does the stream close, naming the pane.
|
|
1373
|
+
*/
|
|
1374
|
+
async #deferPane(binding, offer, channel, firstError) {
|
|
1375
|
+
const gone = () => this.#closed || channel.closed || this.#panes.get(channel.semanticPaneId) !== channel;
|
|
1376
|
+
let error = firstError;
|
|
1377
|
+
for (const [index, delayMs] of this.#deferredPaneRetryDelaysMs.entries()) {
|
|
1378
|
+
if (gone())
|
|
1379
|
+
return;
|
|
1380
|
+
logger.info("pane-stream", "pane delivery deferred", {
|
|
1381
|
+
session: this.#descriptor.sessionName,
|
|
1382
|
+
clientId: this.#clientId,
|
|
1383
|
+
pane: channel.semanticPaneId,
|
|
1384
|
+
attempt: index + 1,
|
|
1385
|
+
error: errorText(error),
|
|
1386
|
+
});
|
|
1387
|
+
await new Promise((resolve) => {
|
|
1388
|
+
const wait = {
|
|
1389
|
+
timer: setTimeout(() => {
|
|
1390
|
+
this.#deferralWaits.delete(wait);
|
|
1391
|
+
resolve();
|
|
1392
|
+
}, delayMs),
|
|
1393
|
+
wake: resolve,
|
|
1394
|
+
};
|
|
1395
|
+
wait.timer.unref?.();
|
|
1396
|
+
this.#deferralWaits.add(wait);
|
|
1397
|
+
});
|
|
1398
|
+
if (gone())
|
|
1399
|
+
return;
|
|
1400
|
+
let entry;
|
|
1401
|
+
try {
|
|
1402
|
+
entry = await this.#openPaneDelivery(binding, offer, channel, false);
|
|
1403
|
+
}
|
|
1404
|
+
catch (cause) {
|
|
1405
|
+
if (cause instanceof SessionRuntimeControllerLeaseError) {
|
|
1406
|
+
this.#fail("pane-delivery-open-failed", cause, channel.semanticPaneId);
|
|
1407
|
+
return;
|
|
1408
|
+
}
|
|
1409
|
+
// The pane became held during its deferred tries (#872).
|
|
1410
|
+
if (cause instanceof MirrorPaneHeldError) {
|
|
1411
|
+
if (!gone())
|
|
1412
|
+
this.#closeHeld(cause.hold, channel.semanticPaneId);
|
|
1413
|
+
return;
|
|
1414
|
+
}
|
|
1415
|
+
error = cause;
|
|
1416
|
+
continue;
|
|
1417
|
+
}
|
|
1418
|
+
if (gone()) {
|
|
1419
|
+
await entry.delivery.close().catch(() => undefined);
|
|
1420
|
+
return;
|
|
1421
|
+
}
|
|
1422
|
+
if (!entry.delivery.negotiation.accepted || this.#deliveryIdentityChanged(entry)) {
|
|
1423
|
+
await entry.delivery.close().catch(() => undefined);
|
|
1424
|
+
this.#failTopologyChanged();
|
|
1425
|
+
return;
|
|
1426
|
+
}
|
|
1427
|
+
await this.#publishOpenedDeliveries([entry]);
|
|
1428
|
+
return;
|
|
1429
|
+
}
|
|
1430
|
+
if (!gone())
|
|
1431
|
+
this.#fail("pane-delivery-open-failed", error, channel.semanticPaneId);
|
|
1432
|
+
}
|
|
1266
1433
|
/** Open one pane's delivery; its messages wait until the pane is announced. */
|
|
1267
|
-
async #openPaneDelivery(binding, offer, channel) {
|
|
1434
|
+
async #openPaneDelivery(binding, offer, channel, retry = true) {
|
|
1268
1435
|
const pending = [];
|
|
1269
1436
|
let ready = false;
|
|
1270
1437
|
let negotiated = false;
|
|
1271
1438
|
// #585: a failed open is tried again (150 ms, 400 ms) before the stream
|
|
1272
1439
|
// closes; this applies to a pane added in place too.
|
|
1273
|
-
const
|
|
1440
|
+
const open = () => {
|
|
1274
1441
|
// A try that failed may have delivered something; start clean.
|
|
1275
1442
|
pending.length = 0;
|
|
1276
1443
|
return binding.openTerminalDelivery(channel.semanticPaneId, offer, (message) => {
|
|
@@ -1279,7 +1446,12 @@ export class PaneStreamLiveConnection {
|
|
|
1279
1446
|
else
|
|
1280
1447
|
return this.#sendTerminalDelivery(channel.semanticPaneId, message);
|
|
1281
1448
|
}, this.#descriptor.workspaceName);
|
|
1282
|
-
}
|
|
1449
|
+
};
|
|
1450
|
+
// A held pane is refused without asking tmux until its hold ends: trying
|
|
1451
|
+
// again inside the same stream only repeats the refusal (#872).
|
|
1452
|
+
const delivery = retry
|
|
1453
|
+
? await this.#retryOpenStep("pane-delivery-open", open, (error) => error instanceof MirrorPaneHeldError)
|
|
1454
|
+
: await open();
|
|
1283
1455
|
return {
|
|
1284
1456
|
channel,
|
|
1285
1457
|
delivery,
|
|
@@ -2110,7 +2282,7 @@ export class PaneStreamLiveConnection {
|
|
|
2110
2282
|
}
|
|
2111
2283
|
if (this.#closed)
|
|
2112
2284
|
return this.#topologyFailed("closed");
|
|
2113
|
-
const next = [...new Set(described.
|
|
2285
|
+
const next = [...new Set(tiledPanes(described).map((pane) => pane.semanticPaneId))].sort();
|
|
2114
2286
|
if (next.length === 0)
|
|
2115
2287
|
return this.#topologyFailed("session has no panes");
|
|
2116
2288
|
const frames = this.#validateInitialLayout(snapshot.layouts, next);
|
|
@@ -2130,7 +2302,7 @@ export class PaneStreamLiveConnection {
|
|
|
2130
2302
|
let windowPanes = null;
|
|
2131
2303
|
if (window !== null) {
|
|
2132
2304
|
windowPanes = [
|
|
2133
|
-
...new Set(described
|
|
2305
|
+
...new Set(tiledPanes(described)
|
|
2134
2306
|
.filter((pane) => pane.semanticWindowId === window)
|
|
2135
2307
|
.map((pane) => pane.semanticPaneId)),
|
|
2136
2308
|
].sort();
|
|
@@ -22,6 +22,51 @@
|
|
|
22
22
|
// Internal parsing bound, matching fleet catalog capacity. This is NOT the
|
|
23
23
|
// smaller pane-stream publication limit; future wire callers must enforce that.
|
|
24
24
|
const MAX_TREE_LEAVES = 512;
|
|
25
|
+
/**
|
|
26
|
+
* #882: the bundled build appends `<cell,cell…>`, one leaf cell per floating
|
|
27
|
+
* pane, and also lists each one as an extra child of the root split, where it
|
|
28
|
+
* overlaps the tiled panes. Split the string into the tiled part and the
|
|
29
|
+
* floating leaves; each floating id must occur exactly once in the tiled part
|
|
30
|
+
* and once in the section. Null when the section is malformed.
|
|
31
|
+
*/
|
|
32
|
+
function splitFloating(s) {
|
|
33
|
+
if (!s.endsWith(">"))
|
|
34
|
+
return { tiled: s, floating: [] };
|
|
35
|
+
const open = s.lastIndexOf("<");
|
|
36
|
+
if (open <= 0)
|
|
37
|
+
return null;
|
|
38
|
+
const section = s.slice(open + 1, -1);
|
|
39
|
+
const floating = [];
|
|
40
|
+
let pos = 0;
|
|
41
|
+
while (pos < section.length) {
|
|
42
|
+
const dims = readDims(section, pos);
|
|
43
|
+
if (!dims || section[dims.pos] !== ",")
|
|
44
|
+
return null;
|
|
45
|
+
const id = readInt(section, dims.pos + 1);
|
|
46
|
+
if (!id)
|
|
47
|
+
return null;
|
|
48
|
+
floating.push({
|
|
49
|
+
id: `%${id.value}`,
|
|
50
|
+
left: dims.left,
|
|
51
|
+
top: dims.top,
|
|
52
|
+
width: dims.width,
|
|
53
|
+
height: dims.height,
|
|
54
|
+
});
|
|
55
|
+
pos = id.pos;
|
|
56
|
+
if (pos === section.length)
|
|
57
|
+
break;
|
|
58
|
+
if (section[pos] !== ",")
|
|
59
|
+
return null;
|
|
60
|
+
pos += 1;
|
|
61
|
+
if (pos === section.length)
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
if (floating.length === 0)
|
|
65
|
+
return null;
|
|
66
|
+
if (new Set(floating.map((leaf) => leaf.id)).size !== floating.length)
|
|
67
|
+
return null;
|
|
68
|
+
return { tiled: s.slice(0, open), floating };
|
|
69
|
+
}
|
|
25
70
|
/**
|
|
26
71
|
* Bounded ancestry parser, deliberately stricter than the legacy flat parser.
|
|
27
72
|
* Up to 512 leaves (fleet catalog bound), 1023 nodes, depth 64 and 64 KiB.
|
|
@@ -31,26 +76,52 @@ const MAX_TREE_LEAVES = 512;
|
|
|
31
76
|
export function parseLayoutTree(layout) {
|
|
32
77
|
if (layout.length > 64 * 1024 || !/^[0-9a-fA-F]{4},/.test(layout))
|
|
33
78
|
return null;
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
79
|
+
const split = splitFloating(layout.slice(5));
|
|
80
|
+
if (!split)
|
|
81
|
+
return null;
|
|
82
|
+
const s = split.tiled;
|
|
83
|
+
const skip = floatingIds(split.floating);
|
|
84
|
+
const root = parseCell(s, 0, [], { nodes: 0, ids: new Set() }, 1, skip);
|
|
85
|
+
if (!root?.node ||
|
|
86
|
+
root.pos !== s.length ||
|
|
87
|
+
root.node.left !== 0 ||
|
|
88
|
+
root.node.top !== 0 ||
|
|
89
|
+
!skip.allSeenOnce())
|
|
37
90
|
return null;
|
|
38
91
|
return root.node;
|
|
39
92
|
}
|
|
93
|
+
/** The floating ids to leave out of the tiled tree, each to be seen once. */
|
|
94
|
+
function floatingIds(floating) {
|
|
95
|
+
const seen = new Map(floating.map((leaf) => [leaf.id, 0]));
|
|
96
|
+
return {
|
|
97
|
+
has: (id) => seen.has(id),
|
|
98
|
+
see: (id) => seen.set(id, (seen.get(id) ?? 0) + 1),
|
|
99
|
+
allSeenOnce: () => [...seen.values()].every((count) => count === 1),
|
|
100
|
+
};
|
|
101
|
+
}
|
|
40
102
|
/** Parse a tmux layout string (`csum,WxH,X,Y…`). Null on any malformed input
|
|
41
103
|
* (the caller falls back to the slow list-panes path — never throw here). */
|
|
42
104
|
export function parseLayout(layout) {
|
|
43
105
|
if (!/^[0-9a-fA-F]{4},/.test(layout))
|
|
44
106
|
return null;
|
|
45
|
-
const
|
|
107
|
+
const split = splitFloating(layout.slice(5));
|
|
108
|
+
if (!split)
|
|
109
|
+
return null;
|
|
110
|
+
const s = split.tiled;
|
|
111
|
+
const skip = floatingIds(split.floating);
|
|
46
112
|
const leaves = [];
|
|
47
|
-
const root = parseCell(s, 0, leaves);
|
|
48
|
-
if (!root || root.pos !== s.length)
|
|
113
|
+
const root = parseCell(s, 0, leaves, undefined, 1, skip);
|
|
114
|
+
if (!root || root.pos !== s.length || !skip.allSeenOnce() || leaves.length === 0)
|
|
49
115
|
return null;
|
|
50
|
-
return {
|
|
116
|
+
return {
|
|
117
|
+
width: root.width,
|
|
118
|
+
height: root.height,
|
|
119
|
+
leaves,
|
|
120
|
+
...(split.floating.length > 0 ? { floating: split.floating } : {}),
|
|
121
|
+
};
|
|
51
122
|
}
|
|
52
123
|
/** Recursive-descent cell parse from `pos`; appends leaves in layout order. */
|
|
53
|
-
function parseCell(s, pos, leaves, tree, depth = 1) {
|
|
124
|
+
function parseCell(s, pos, leaves, tree, depth = 1, skip) {
|
|
54
125
|
if (tree && (depth > 64 || ++tree.nodes > MAX_TREE_LEAVES * 2 - 1))
|
|
55
126
|
return null;
|
|
56
127
|
const dims = readDims(s, pos);
|
|
@@ -72,6 +143,10 @@ function parseCell(s, pos, leaves, tree, depth = 1) {
|
|
|
72
143
|
if (!id)
|
|
73
144
|
return null;
|
|
74
145
|
const leaf = { id: `%${id.value}`, left, top, width, height };
|
|
146
|
+
if (skip?.has(leaf.id)) {
|
|
147
|
+
skip.see(leaf.id);
|
|
148
|
+
return { width, height, pos: id.pos, floating: true };
|
|
149
|
+
}
|
|
75
150
|
if (tree) {
|
|
76
151
|
if (!Number.isSafeInteger(id.value) ||
|
|
77
152
|
tree.ids.has(leaf.id) ||
|
|
@@ -90,12 +165,15 @@ function parseCell(s, pos, leaves, tree, depth = 1) {
|
|
|
90
165
|
if (ch === "{" || ch === "[") {
|
|
91
166
|
const close = ch === "{" ? "}" : "]";
|
|
92
167
|
const children = [];
|
|
168
|
+
let droppedFloating = 0;
|
|
93
169
|
pos++;
|
|
94
170
|
for (;;) {
|
|
95
|
-
const child = parseCell(s, pos, leaves, tree, depth + 1);
|
|
171
|
+
const child = parseCell(s, pos, leaves, tree, depth + 1, skip);
|
|
96
172
|
if (!child)
|
|
97
173
|
return null;
|
|
98
|
-
if (
|
|
174
|
+
if (child.floating)
|
|
175
|
+
droppedFloating += 1;
|
|
176
|
+
else if (tree && child.node)
|
|
99
177
|
children.push(child.node);
|
|
100
178
|
pos = child.pos;
|
|
101
179
|
if (s[pos] === ",") {
|
|
@@ -105,6 +183,17 @@ function parseCell(s, pos, leaves, tree, depth = 1) {
|
|
|
105
183
|
if (s[pos] === close) {
|
|
106
184
|
if (!tree)
|
|
107
185
|
return { width, height, pos: pos + 1 };
|
|
186
|
+
// A split left with one tiled child once its floats are dropped is
|
|
187
|
+
// that child (the bundled build wraps a lone pane and its floats).
|
|
188
|
+
// It must fill the split exactly; otherwise tilesParent refuses it.
|
|
189
|
+
const lone = children.length === 1 ? children[0] : null;
|
|
190
|
+
if (droppedFloating > 0 &&
|
|
191
|
+
lone &&
|
|
192
|
+
lone.left === left &&
|
|
193
|
+
lone.top === top &&
|
|
194
|
+
lone.width === width &&
|
|
195
|
+
lone.height === height)
|
|
196
|
+
return { width, height, pos: pos + 1, node: lone };
|
|
108
197
|
const axis = ch === "{" ? "cols" : "rows";
|
|
109
198
|
const node = { kind: "split", axis, left, top, width, height, children };
|
|
110
199
|
if (!tilesParent(node))
|
|
@@ -35,6 +35,8 @@ export const SESSION_PANE_DESCRIPTOR_FORMAT = [
|
|
|
35
35
|
"#{pane_pid}",
|
|
36
36
|
// Set only by a terminal browser that has tmux-ide's native controls (#718).
|
|
37
37
|
"#{qa:@tmux_ide_browser_control}",
|
|
38
|
+
// #882: tmux 3.7+ floating panes have no cell in the tiled layout.
|
|
39
|
+
"#{pane_floating_flag}",
|
|
38
40
|
].join("\t");
|
|
39
41
|
/**
|
|
40
42
|
* Descriptor fields the program in a pane changes whenever it likes: its
|
|
@@ -131,9 +133,9 @@ export function parseSessionPaneDescriptorReply(lines) {
|
|
|
131
133
|
continue;
|
|
132
134
|
}
|
|
133
135
|
const encoded = utf8Line.split("\t");
|
|
134
|
-
if (encoded.length < 21 || encoded.length >
|
|
136
|
+
if (encoded.length < 21 || encoded.length > 27)
|
|
135
137
|
continue;
|
|
136
|
-
const [runtimePaneId = "", semanticPaneId = "", role = "", type = "", currentCommand = "", cwd = "", windowIndexRaw = "", windowName = "", windowId = "", title = "", runtimeSessionId = "", paneIndexRaw = "", name = "", missionStamp = "", paneActiveRaw = "", windowActiveRaw = "", semanticWindowId = "", sessionName = "", windowPaneCountRaw = "", sessionWindowCountRaw = "", nativePaneBirthId = "", nameSource = "", browserIconRaw = "", readerRaw = "", panePidRaw = "", browserControl = "",] = encoded.map(decodeTmuxArgument);
|
|
138
|
+
const [runtimePaneId = "", semanticPaneId = "", role = "", type = "", currentCommand = "", cwd = "", windowIndexRaw = "", windowName = "", windowId = "", title = "", runtimeSessionId = "", paneIndexRaw = "", name = "", missionStamp = "", paneActiveRaw = "", windowActiveRaw = "", semanticWindowId = "", sessionName = "", windowPaneCountRaw = "", sessionWindowCountRaw = "", nativePaneBirthId = "", nameSource = "", browserIconRaw = "", readerRaw = "", panePidRaw = "", browserControl = "", floatingRaw = "",] = encoded.map(decodeTmuxArgument);
|
|
137
139
|
if (!/^%(?:0|[1-9][0-9]*)$/u.test(runtimePaneId) || runtimePaneId.length > 32)
|
|
138
140
|
continue;
|
|
139
141
|
if (!/^\$(?:0|[1-9][0-9]*)$/u.test(runtimeSessionId) || runtimeSessionId.length > 32)
|
|
@@ -197,6 +199,7 @@ export function parseSessionPaneDescriptorReply(lines) {
|
|
|
197
199
|
windowActive: windowActiveRaw === "1",
|
|
198
200
|
windowPaneCount,
|
|
199
201
|
sessionWindowCount,
|
|
202
|
+
floating: floatingRaw === "1",
|
|
200
203
|
});
|
|
201
204
|
}
|
|
202
205
|
return { descriptors, malformedUtf8Records };
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
/** #873, owner decision of 25 Nov 2026: the daemon holds at most this many history rows per pane. */
|
|
2
|
+
export const DAEMON_HISTORY_ROW_CAP = 10_000;
|
|
@@ -5,6 +5,7 @@ import { detectWidgetMarkerFromReplicaRows, } from "@tmux-ide/contracts";
|
|
|
5
5
|
import { applyTerminalReplicaPatch, assembleTerminalReplicaSnapshot, blankTerminalReplicaSnapshot, hashTerminalReplicaSnapshot, hashTerminalReplicaTombstone, hashTerminalWidgetContent, terminalReplicaRowsEqual, } from "@tmux-ide/core";
|
|
6
6
|
import { SYSTEM_SESSION_RUNTIME_SCHEDULER, } from "./runtime-scheduler.js";
|
|
7
7
|
import { DISABLED_SESSION_RUNTIME_OBSERVABILITY, } from "./runtime-observability.js";
|
|
8
|
+
import { DAEMON_HISTORY_ROW_CAP, } from "./terminal-interpreter-backend.js";
|
|
8
9
|
import { createXtermTerminalInterpreterBackend } from "./xterm-terminal-interpreter-backend.js";
|
|
9
10
|
import { CAUSAL_CELL_OSC, CausalCellLedger, cellsEqual, } from "./causal-cell-ledger.js";
|
|
10
11
|
import { KITTY_PLACEMENT_OSC, KittyApcScanner, KittyImageStore, } from "../graphics/kitty-graphics.js";
|
|
@@ -47,6 +48,7 @@ export class TerminalReplicaInterpreter {
|
|
|
47
48
|
#semanticPaneId;
|
|
48
49
|
#incarnation;
|
|
49
50
|
#scrollback;
|
|
51
|
+
#historyRowCap;
|
|
50
52
|
#listeners = new Set();
|
|
51
53
|
#onRawCommit;
|
|
52
54
|
#scheduler;
|
|
@@ -113,6 +115,7 @@ export class TerminalReplicaInterpreter {
|
|
|
113
115
|
this.#incarnation = options.incarnation;
|
|
114
116
|
this.#revision = options.initialRevision ?? 0;
|
|
115
117
|
this.#scrollback = options.scrollback ?? 5000;
|
|
118
|
+
this.#historyRowCap = options.historyRowCap ?? DAEMON_HISTORY_ROW_CAP;
|
|
116
119
|
this.#onRawCommit = options.onRawCommit;
|
|
117
120
|
this.#onNativeReseedRequired = options.onNativeReseedRequired;
|
|
118
121
|
this.#scheduler = options.scheduler ?? SYSTEM_SESSION_RUNTIME_SCHEDULER;
|
|
@@ -122,6 +125,7 @@ export class TerminalReplicaInterpreter {
|
|
|
122
125
|
cols: options.cols,
|
|
123
126
|
rows: options.rows,
|
|
124
127
|
scrollback: this.#scrollback,
|
|
128
|
+
historyRowCap: this.#historyRowCap,
|
|
125
129
|
});
|
|
126
130
|
this.#backend.startHistoryCollection?.();
|
|
127
131
|
this.#kitty = new KittyImageStore(options.kittyImageBudget ? { budget: options.kittyImageBudget } : {});
|
|
@@ -177,6 +181,30 @@ export class TerminalReplicaInterpreter {
|
|
|
177
181
|
: operation;
|
|
178
182
|
return this.#append(admitted);
|
|
179
183
|
}
|
|
184
|
+
/**
|
|
185
|
+
* #873: prepend the older history rows of a piece read from tmux, in order
|
|
186
|
+
* with the writes queued before it. True when the rows were prepended and a
|
|
187
|
+
* new revision published; false when the piece does not fit the replica as
|
|
188
|
+
* it is at that point of the stream (see the backend's prependNativeHistory).
|
|
189
|
+
*/
|
|
190
|
+
prependNativeHistory(piece) {
|
|
191
|
+
this.#flushWrites();
|
|
192
|
+
const run = this.#tail.then(() => this.#applyHistoryPiece(piece));
|
|
193
|
+
this.#tail = run.then(() => undefined, () => undefined);
|
|
194
|
+
return run;
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* #873: tmux history rows older than the replica's oldest history row; tmux's
|
|
198
|
+
* history size is this plus the replica's history rows. Set by a native seed
|
|
199
|
+
* that left them out, zero after any other seed.
|
|
200
|
+
*/
|
|
201
|
+
omittedHistory() {
|
|
202
|
+
return this.#backend.omittedHistory?.() ?? 0;
|
|
203
|
+
}
|
|
204
|
+
/** #873: the most history rows the replica holds; the backfill stops there. */
|
|
205
|
+
historyRowCap() {
|
|
206
|
+
return this.#historyRowCap;
|
|
207
|
+
}
|
|
180
208
|
whenIdle() {
|
|
181
209
|
this.#flushWrites();
|
|
182
210
|
return this.#tail;
|
|
@@ -272,12 +300,13 @@ export class TerminalReplicaInterpreter {
|
|
|
272
300
|
this.#causalCell?.fail("reseeded");
|
|
273
301
|
const nativeCols = operation.nativeCols ?? operation.cols;
|
|
274
302
|
const nativeRows = operation.nativeRows ?? operation.rows;
|
|
275
|
-
const scrollback = Math.max(operation.historyLimit ?? this.#scrollback, operation.historySize ?? 0, operation.native?.history ?? 0);
|
|
303
|
+
const scrollback = Math.max(operation.historyLimit ?? this.#scrollback, operation.historySize ?? 0, (operation.native?.history ?? 0) + (operation.native?.omittedHistory ?? 0));
|
|
276
304
|
const replacement = this.#backendFactory({
|
|
277
305
|
cols: nativeCols,
|
|
278
306
|
rows: nativeRows,
|
|
279
307
|
scrollback,
|
|
280
308
|
historyLimit: operation.historyLimit ?? scrollback,
|
|
309
|
+
historyRowCap: this.#historyRowCap,
|
|
281
310
|
});
|
|
282
311
|
try {
|
|
283
312
|
if (operation.native && !replacement.importNativeGrid?.(operation.native))
|
|
@@ -416,6 +445,22 @@ export class TerminalReplicaInterpreter {
|
|
|
416
445
|
this.#backend.dispose();
|
|
417
446
|
this.#emit(update);
|
|
418
447
|
}
|
|
448
|
+
#applyHistoryPiece(piece) {
|
|
449
|
+
if (this.#closed ||
|
|
450
|
+
this.#needsSeed ||
|
|
451
|
+
this.#nativeReseedRequested ||
|
|
452
|
+
this.#pendingResize !== null ||
|
|
453
|
+
this.#backend.requiresNativeReseed() ||
|
|
454
|
+
// A synchronized update publishes nothing until it ends.
|
|
455
|
+
this.#backend.modes().synchronizedOutput ||
|
|
456
|
+
!this.#backend.prependNativeHistory?.(piece))
|
|
457
|
+
return false;
|
|
458
|
+
// Image anchors are absolute buffer lines; prepended rows moved them all.
|
|
459
|
+
this.#kitty.dropCursorPlacements();
|
|
460
|
+
this.#commit(false);
|
|
461
|
+
this.#publishGraphics();
|
|
462
|
+
return true;
|
|
463
|
+
}
|
|
419
464
|
async #write(data, continuedTrace, hasBacklog = () => false) {
|
|
420
465
|
if (this.#closed || this.#nativeReseedRequested)
|
|
421
466
|
return;
|