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
package/bin/cli.js
CHANGED
|
@@ -8019,7 +8019,10 @@ var init_terminal_graphics = __esm({
|
|
|
8019
8019
|
|
|
8020
8020
|
// packages/contracts/src/pane-stream.ts
|
|
8021
8021
|
import { z as z52 } from "zod";
|
|
8022
|
-
|
|
8022
|
+
function paneHeldCloseReason(hold) {
|
|
8023
|
+
return `pane-held:${Math.max(1, Math.ceil(hold.retryInMs))}:${hold.why}`;
|
|
8024
|
+
}
|
|
8025
|
+
var PANE_STREAM_CLOCK_BOUNDS_CAPABILITY_V1, PaneStreamDiagnosticCapabilitySchemaZ, PANE_STREAM_PROTOCOL_VERSION, PANE_STREAM_ISSUE_PATH, PANE_STREAM_REDEEM_PATH, PANE_STREAM_WEBSOCKET_SUBPROTOCOL, PANE_STREAM_MAX_PANES, PANE_STREAM_MAX_OUTPUT_BYTES, PANE_STREAM_MAX_OUTPUT_BASE64_CHARS, PANE_STREAM_MAX_SEED_BYTES, PANE_STREAM_MAX_SEED_BASE64_CHARS, PANE_STREAM_MAX_HELD_DELTAS, PANE_STREAM_MAX_LAYOUT_PANES, PANE_STREAM_MAX_GRID_CELLS, PANE_STREAM_MAX_INPUT_SEQUENCE, PaneStreamSemanticPaneIdSchemaZ, PaneStreamViewerModeSchemaZ, PaneSetSchemaZ, PaneStreamLeaseRequestSchemaZ, PANE_STREAM_PANE_HELD_CLOSE_CODE, PaneStreamRedemptionTicketSchemaZ, PaneStreamLoopbackWebSocketUrlSchemaZ, PaneStreamIssueDescriptorSchemaZ, PaneStreamIssueErrorSchemaZ, PaneStreamIssueResultSchemaZ, PaneStreamIssueMutationRequestSchemaZ, BoundedIdentitySchemaZ, PaneStreamRedeemFrameSchemaZ, 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_TOPOLOGY_IN_PLACE_CAPABILITY_VERSION, PANE_STREAM_READER_TOPOLOGY_BUNDLE_CAPABILITY_VERSION, PaneStreamInputLifetimeSchemaZ, PaneStreamInputFrameMetadataShape, PaneStreamInputFrameSchemaZ, PaneStreamConsumedFrameSchemaZ, PaneStreamTerminalDeliveryAckFrameSchemaZ, PaneStreamTerminalProjectionReceiptFrameSchemaZ, PaneStreamTerminalProjectionMaterializeFrameSchemaZ, PaneStreamTerminalDeliveryHistoryRequestFrameSchemaZ, PaneStreamTerminalDeliveryNackFrameSchemaZ, PaneStreamTerminalDeliveryVisibilityFrameSchemaZ, PaneStreamSemanticIntentFrameSchemaZ, PaneStreamViewportFrameSchemaZ, PaneStreamAuthorityRequestIdSchemaZ, PaneStreamAuthorityGenerationSchemaZ, PaneStreamPresenceFrameSchemaZ, PaneStreamActivityFrameSchemaZ, PaneStreamAuthorityRequestFrameSchemaZ, PaneStreamAuthorityReleaseFrameSchemaZ, SharedMonotonicMicrosSchemaZ, PaneStreamClockProbeFrameSchemaZ, PaneStreamTerminalGraphicsRequestFrameSchemaZ, PaneStreamTerminalGraphicsLocalReleaseFrameSchemaZ, PaneStreamTerminalCellPixelsFrameSchemaZ, PaneStreamClientFrameSchemaZ, Base64SchemaZ, ServerSeqSchemaZ, GridCellSchemaZ, CellCoordinateSchemaZ, PaneStreamReadyFrameSchemaZ, PaneStreamSeedBatchFrameSchemaZ, PaneStreamOutputFrameSchemaZ, PaneStreamCursorFrameSchemaZ, BoundedDisplayNameSchemaZ, PaneDisplayNameSourceSchemaZ, PaneStreamLayoutFrameSchemaZ, PaneStreamLayoutSnapshotV1FrameSchemaZ, PaneStreamLayoutSnapshotV2FrameSchemaZ, PaneStreamLayoutSnapshotFrameSchemaZ, PaneStreamFlowFrameSchemaZ, PaneStreamTopologyFrameSchemaZ, PaneStreamClosedFrameSchemaZ, PaneStreamInputAckFrameSchemaZ, PaneStreamClockProbeAckFrameSchemaZ, PaneStreamCausalCellProofFrameSchemaZ, PaneStreamCausalCellFailureFrameSchemaZ, PaneStreamTerminalDeliveryReadyFrameSchemaZ, PaneStreamTerminalDeliveryEnvelopeFrameSchemaZ, PaneStreamTerminalProjectionEnvelopeFrameSchemaZ, PaneStreamTerminalDeliveryChunkFrameSchemaZ, PaneStreamTerminalDeliveryFaultFrameSchemaZ, PaneStreamTerminalGraphicsFrameSchemaZ, PaneStreamTerminalGraphicsBlobFrameSchemaZ, PaneStreamTerminalGraphicsLocalFrameSchemaZ, PaneStreamSemanticIntentAckFrameSchemaZ, PaneStreamViewportAckFrameSchemaZ, PaneStreamAuthoritySnapshotFrameSchemaZ, PaneStreamAuthorityReceiptFrameSchemaZ, PaneStreamErrorFrameCodeSchemaZ, PaneStreamErrorFrameSchemaZ, PaneStreamServerFrameSchemaZ;
|
|
8023
8026
|
var init_pane_stream = __esm({
|
|
8024
8027
|
"packages/contracts/src/pane-stream.ts"() {
|
|
8025
8028
|
"use strict";
|
|
@@ -8073,8 +8076,15 @@ var init_pane_stream = __esm({
|
|
|
8073
8076
|
* follows that window's pane set in place; other windows never enter.
|
|
8074
8077
|
* Released daemons refuse the field: send it only to a daemon that has it.
|
|
8075
8078
|
*/
|
|
8076
|
-
semanticWindowId: TerminalAttachmentSemanticWindowIdSchemaZ.optional()
|
|
8079
|
+
semanticWindowId: TerminalAttachmentSemanticWindowIdSchemaZ.optional(),
|
|
8080
|
+
/**
|
|
8081
|
+
* #872: a person asked to retry now. The daemon asks tmux for the
|
|
8082
|
+
* stream's panes even inside a hold after failed recoveries. Released
|
|
8083
|
+
* daemons refuse the field: send it only to 2.9.28 or newer.
|
|
8084
|
+
*/
|
|
8085
|
+
retryAskedByPerson: z52.literal(true).optional()
|
|
8077
8086
|
}).strict())();
|
|
8087
|
+
PANE_STREAM_PANE_HELD_CLOSE_CODE = /* @__PURE__ */ (() => 1013)();
|
|
8078
8088
|
PaneStreamRedemptionTicketSchemaZ = /* @__PURE__ */ (() => z52.string().regex(/^ps2_[A-Za-z0-9_-]{43}$/u))();
|
|
8079
8089
|
PaneStreamLoopbackWebSocketUrlSchemaZ = /* @__PURE__ */ (() => z52.url().max(2048).refine((value) => {
|
|
8080
8090
|
const url = new URL(value);
|
|
@@ -15516,7 +15526,7 @@ var require_package = __commonJS({
|
|
|
15516
15526
|
"package.json"(exports, module) {
|
|
15517
15527
|
module.exports = {
|
|
15518
15528
|
name: "tmux-ide",
|
|
15519
|
-
version: "2.9.
|
|
15529
|
+
version: "2.9.28",
|
|
15520
15530
|
description: "The open-source workspace for coding agents: run Claude Code, Codex and other agents in tmux with live status",
|
|
15521
15531
|
type: "module",
|
|
15522
15532
|
bin: {
|
|
@@ -28496,7 +28506,7 @@ function parseSessionPaneDescriptorReply(lines) {
|
|
|
28496
28506
|
continue;
|
|
28497
28507
|
}
|
|
28498
28508
|
const encoded = utf8Line.split(" ");
|
|
28499
|
-
if (encoded.length < 21 || encoded.length >
|
|
28509
|
+
if (encoded.length < 21 || encoded.length > 27) continue;
|
|
28500
28510
|
const [
|
|
28501
28511
|
runtimePaneId = "",
|
|
28502
28512
|
semanticPaneId3 = "",
|
|
@@ -28523,7 +28533,8 @@ function parseSessionPaneDescriptorReply(lines) {
|
|
|
28523
28533
|
browserIconRaw = "",
|
|
28524
28534
|
readerRaw = "",
|
|
28525
28535
|
panePidRaw = "",
|
|
28526
|
-
browserControl = ""
|
|
28536
|
+
browserControl = "",
|
|
28537
|
+
floatingRaw = ""
|
|
28527
28538
|
] = encoded.map(decodeTmuxArgument);
|
|
28528
28539
|
if (!/^%(?:0|[1-9][0-9]*)$/u.test(runtimePaneId) || runtimePaneId.length > 32) continue;
|
|
28529
28540
|
if (!/^\$(?:0|[1-9][0-9]*)$/u.test(runtimeSessionId) || runtimeSessionId.length > 32) continue;
|
|
@@ -28567,7 +28578,8 @@ function parseSessionPaneDescriptorReply(lines) {
|
|
|
28567
28578
|
paneActive: paneActiveRaw === "1",
|
|
28568
28579
|
windowActive: windowActiveRaw === "1",
|
|
28569
28580
|
windowPaneCount,
|
|
28570
|
-
sessionWindowCount
|
|
28581
|
+
sessionWindowCount,
|
|
28582
|
+
floating: floatingRaw === "1"
|
|
28571
28583
|
});
|
|
28572
28584
|
}
|
|
28573
28585
|
return { descriptors, malformedUtf8Records };
|
|
@@ -28630,7 +28642,9 @@ var init_session_descriptor_discovery = __esm({
|
|
|
28630
28642
|
// The reader option belongs to the pane only when its own process set it.
|
|
28631
28643
|
"#{pane_pid}",
|
|
28632
28644
|
// Set only by a terminal browser that has tmux-ide's native controls (#718).
|
|
28633
|
-
"#{qa:@tmux_ide_browser_control}"
|
|
28645
|
+
"#{qa:@tmux_ide_browser_control}",
|
|
28646
|
+
// #882: tmux 3.7+ floating panes have no cell in the tiled layout.
|
|
28647
|
+
"#{pane_floating_flag}"
|
|
28634
28648
|
].join(" ");
|
|
28635
28649
|
VOLATILE_DESCRIPTOR_FIELDS = /* @__PURE__ */ new Set([
|
|
28636
28650
|
4,
|
|
@@ -29631,23 +29645,71 @@ var init_native_surface_provider = __esm({
|
|
|
29631
29645
|
});
|
|
29632
29646
|
|
|
29633
29647
|
// packages/daemon/src/terminal/protocol/layout-parse.ts
|
|
29648
|
+
function splitFloating(s) {
|
|
29649
|
+
if (!s.endsWith(">")) return { tiled: s, floating: [] };
|
|
29650
|
+
const open5 = s.lastIndexOf("<");
|
|
29651
|
+
if (open5 <= 0) return null;
|
|
29652
|
+
const section = s.slice(open5 + 1, -1);
|
|
29653
|
+
const floating = [];
|
|
29654
|
+
let pos = 0;
|
|
29655
|
+
while (pos < section.length) {
|
|
29656
|
+
const dims = readDims(section, pos);
|
|
29657
|
+
if (!dims || section[dims.pos] !== ",") return null;
|
|
29658
|
+
const id2 = readInt(section, dims.pos + 1);
|
|
29659
|
+
if (!id2) return null;
|
|
29660
|
+
floating.push({
|
|
29661
|
+
id: `%${id2.value}`,
|
|
29662
|
+
left: dims.left,
|
|
29663
|
+
top: dims.top,
|
|
29664
|
+
width: dims.width,
|
|
29665
|
+
height: dims.height
|
|
29666
|
+
});
|
|
29667
|
+
pos = id2.pos;
|
|
29668
|
+
if (pos === section.length) break;
|
|
29669
|
+
if (section[pos] !== ",") return null;
|
|
29670
|
+
pos += 1;
|
|
29671
|
+
if (pos === section.length) return null;
|
|
29672
|
+
}
|
|
29673
|
+
if (floating.length === 0) return null;
|
|
29674
|
+
if (new Set(floating.map((leaf) => leaf.id)).size !== floating.length) return null;
|
|
29675
|
+
return { tiled: s.slice(0, open5), floating };
|
|
29676
|
+
}
|
|
29634
29677
|
function parseLayoutTree(layout) {
|
|
29635
29678
|
if (layout.length > 64 * 1024 || !/^[0-9a-fA-F]{4},/.test(layout)) return null;
|
|
29636
|
-
const
|
|
29637
|
-
|
|
29638
|
-
|
|
29679
|
+
const split = splitFloating(layout.slice(5));
|
|
29680
|
+
if (!split) return null;
|
|
29681
|
+
const s = split.tiled;
|
|
29682
|
+
const skip = floatingIds(split.floating);
|
|
29683
|
+
const root = parseCell(s, 0, [], { nodes: 0, ids: /* @__PURE__ */ new Set() }, 1, skip);
|
|
29684
|
+
if (!root?.node || root.pos !== s.length || root.node.left !== 0 || root.node.top !== 0 || !skip.allSeenOnce())
|
|
29639
29685
|
return null;
|
|
29640
29686
|
return root.node;
|
|
29641
29687
|
}
|
|
29688
|
+
function floatingIds(floating) {
|
|
29689
|
+
const seen = new Map(floating.map((leaf) => [leaf.id, 0]));
|
|
29690
|
+
return {
|
|
29691
|
+
has: (id2) => seen.has(id2),
|
|
29692
|
+
see: (id2) => seen.set(id2, (seen.get(id2) ?? 0) + 1),
|
|
29693
|
+
allSeenOnce: () => [...seen.values()].every((count) => count === 1)
|
|
29694
|
+
};
|
|
29695
|
+
}
|
|
29642
29696
|
function parseLayout(layout) {
|
|
29643
29697
|
if (!/^[0-9a-fA-F]{4},/.test(layout)) return null;
|
|
29644
|
-
const
|
|
29698
|
+
const split = splitFloating(layout.slice(5));
|
|
29699
|
+
if (!split) return null;
|
|
29700
|
+
const s = split.tiled;
|
|
29701
|
+
const skip = floatingIds(split.floating);
|
|
29645
29702
|
const leaves = [];
|
|
29646
|
-
const root = parseCell(s, 0, leaves);
|
|
29647
|
-
if (!root || root.pos !== s.length) return null;
|
|
29648
|
-
return {
|
|
29703
|
+
const root = parseCell(s, 0, leaves, void 0, 1, skip);
|
|
29704
|
+
if (!root || root.pos !== s.length || !skip.allSeenOnce() || leaves.length === 0) return null;
|
|
29705
|
+
return {
|
|
29706
|
+
width: root.width,
|
|
29707
|
+
height: root.height,
|
|
29708
|
+
leaves,
|
|
29709
|
+
...split.floating.length > 0 ? { floating: split.floating } : {}
|
|
29710
|
+
};
|
|
29649
29711
|
}
|
|
29650
|
-
function parseCell(s, pos, leaves, tree, depth = 1) {
|
|
29712
|
+
function parseCell(s, pos, leaves, tree, depth = 1, skip) {
|
|
29651
29713
|
if (tree && (depth > 64 || ++tree.nodes > MAX_TREE_LEAVES * 2 - 1)) return null;
|
|
29652
29714
|
const dims = readDims(s, pos);
|
|
29653
29715
|
if (!dims) return null;
|
|
@@ -29660,6 +29722,10 @@ function parseCell(s, pos, leaves, tree, depth = 1) {
|
|
|
29660
29722
|
const id2 = readInt(s, pos + 1);
|
|
29661
29723
|
if (!id2) return null;
|
|
29662
29724
|
const leaf = { id: `%${id2.value}`, left, top, width, height };
|
|
29725
|
+
if (skip?.has(leaf.id)) {
|
|
29726
|
+
skip.see(leaf.id);
|
|
29727
|
+
return { width, height, pos: id2.pos, floating: true };
|
|
29728
|
+
}
|
|
29663
29729
|
if (tree) {
|
|
29664
29730
|
if (!Number.isSafeInteger(id2.value) || tree.ids.has(leaf.id) || tree.ids.size >= MAX_TREE_LEAVES)
|
|
29665
29731
|
return null;
|
|
@@ -29676,11 +29742,13 @@ function parseCell(s, pos, leaves, tree, depth = 1) {
|
|
|
29676
29742
|
if (ch === "{" || ch === "[") {
|
|
29677
29743
|
const close2 = ch === "{" ? "}" : "]";
|
|
29678
29744
|
const children = [];
|
|
29745
|
+
let droppedFloating = 0;
|
|
29679
29746
|
pos++;
|
|
29680
29747
|
for (; ; ) {
|
|
29681
|
-
const child = parseCell(s, pos, leaves, tree, depth + 1);
|
|
29748
|
+
const child = parseCell(s, pos, leaves, tree, depth + 1, skip);
|
|
29682
29749
|
if (!child) return null;
|
|
29683
|
-
if (
|
|
29750
|
+
if (child.floating) droppedFloating += 1;
|
|
29751
|
+
else if (tree && child.node) children.push(child.node);
|
|
29684
29752
|
pos = child.pos;
|
|
29685
29753
|
if (s[pos] === ",") {
|
|
29686
29754
|
pos++;
|
|
@@ -29688,6 +29756,9 @@ function parseCell(s, pos, leaves, tree, depth = 1) {
|
|
|
29688
29756
|
}
|
|
29689
29757
|
if (s[pos] === close2) {
|
|
29690
29758
|
if (!tree) return { width, height, pos: pos + 1 };
|
|
29759
|
+
const lone = children.length === 1 ? children[0] : null;
|
|
29760
|
+
if (droppedFloating > 0 && lone && lone.left === left && lone.top === top && lone.width === width && lone.height === height)
|
|
29761
|
+
return { width, height, pos: pos + 1, node: lone };
|
|
29691
29762
|
const axis = ch === "{" ? "cols" : "rows";
|
|
29692
29763
|
const node = { kind: "split", axis, left, top, width, height, children };
|
|
29693
29764
|
if (!tilesParent(node)) return null;
|
|
@@ -33234,6 +33305,29 @@ var init_layout_content_rows = __esm({
|
|
|
33234
33305
|
function isStockRawGridCapture(lines) {
|
|
33235
33306
|
return /^G [1-9][0-9]*x[1-9][0-9]* \([0-9]+\/[0-9]+\)$/.test(lines[0] ?? "") && /^\tL 0 \((?:-|0)\) flags=/.test(lines[1] ?? "");
|
|
33236
33307
|
}
|
|
33308
|
+
function readNativeBootstrapProbe(ok2, lines) {
|
|
33309
|
+
if (!ok2)
|
|
33310
|
+
return lines.some(
|
|
33311
|
+
(line) => /^(?:parse error: )?(?:command capture-pane: )?unknown flag -V$/.test(line.trim())
|
|
33312
|
+
) ? "unsupported" : "unknown";
|
|
33313
|
+
if (isStockRawGridCapture(lines)) return "unsupported";
|
|
33314
|
+
let header;
|
|
33315
|
+
try {
|
|
33316
|
+
header = JSON.parse(lines[0] ?? "");
|
|
33317
|
+
} catch {
|
|
33318
|
+
return "unknown";
|
|
33319
|
+
}
|
|
33320
|
+
if (header === null || typeof header !== "object" || !("cols" in header)) return "unknown";
|
|
33321
|
+
return "version" in header && header.version === 2 && "currentAttributes" in header ? "native" : "unsupported";
|
|
33322
|
+
}
|
|
33323
|
+
function nativeSeedHistoryRows(cols, rows) {
|
|
33324
|
+
if (!Number.isSafeInteger(cols) || cols < 1 || !Number.isSafeInteger(rows) || rows < 1) return 0;
|
|
33325
|
+
return Math.max(0, Math.floor(NATIVE_SEED_CELL_BUDGET / cols) - rows);
|
|
33326
|
+
}
|
|
33327
|
+
function nativeHistoryPieceRows(cols) {
|
|
33328
|
+
if (!Number.isSafeInteger(cols) || cols < 1) return 1;
|
|
33329
|
+
return Math.max(1, Math.floor(NATIVE_HISTORY_PIECE_CELL_BUDGET / cols));
|
|
33330
|
+
}
|
|
33237
33331
|
function isNativeBootstrapCapture(snapshot3) {
|
|
33238
33332
|
return uint(snapshot3.cols, 16384) && snapshot3.cols > 0 && uint(snapshot3.rows, MAX_ROWS) && snapshot3.rows > 0 && uint(snapshot3.history, MAX_ROWS) && snapshot3.version === 2 && snapshot3.currentAttributes !== void 0 && snapshot3.cols * (snapshot3.history + snapshot3.rows) <= MAX_CELLS;
|
|
33239
33333
|
}
|
|
@@ -33275,7 +33369,7 @@ function encodeNativeGridCapture(source) {
|
|
|
33275
33369
|
}
|
|
33276
33370
|
return records.join("");
|
|
33277
33371
|
}
|
|
33278
|
-
function decodeNativeGridCapture(text2) {
|
|
33372
|
+
function decodeNativeGridCapture(text2, options = {}) {
|
|
33279
33373
|
if (text2.length > MAX_BYTES || Buffer.byteLength(text2, "utf8") > MAX_BYTES) return null;
|
|
33280
33374
|
let offset = 0;
|
|
33281
33375
|
const next = () => {
|
|
@@ -33288,7 +33382,7 @@ function decodeNativeGridCapture(text2) {
|
|
|
33288
33382
|
};
|
|
33289
33383
|
try {
|
|
33290
33384
|
const header = next();
|
|
33291
|
-
if (!object2(header) || header.version !== 1 && header.version !== 2 || !uint(header.cols, MAX_CELLS) || header.cols === 0 || !uint(header.rows, MAX_ROWS) || header.rows === 0 || !uint(header.history, MAX_ROWS) || header.history + header.rows > MAX_ROWS || !uint(header.hscrolled, header.history) || !uint(header.limit) || !Array.isArray(header.cursor) || header.cursor.length !== 2 || // screen_resize_cursor preserves x after a non-reflow (alternate)
|
|
33385
|
+
if (!object2(header) || header.version !== 1 && header.version !== 2 || !uint(header.cols, MAX_CELLS) || header.cols === 0 || !uint(header.rows, MAX_ROWS) || header.rows === 0 || !uint(header.history, options.tail ? 4294967295 : MAX_ROWS) || !options.tail && header.history + header.rows > MAX_ROWS || !uint(header.hscrolled, header.history) || !uint(header.limit) || !Array.isArray(header.cursor) || header.cursor.length !== 2 || // screen_resize_cursor preserves x after a non-reflow (alternate)
|
|
33292
33386
|
// shrink. Bound the source coordinate independently of current columns.
|
|
33293
33387
|
!uint(header.cursor[0], MAX_CELLS) || !uint(header.cursor[1], header.rows - 1))
|
|
33294
33388
|
return null;
|
|
@@ -33297,7 +33391,12 @@ function decodeNativeGridCapture(text2) {
|
|
|
33297
33391
|
return null;
|
|
33298
33392
|
const grid = [];
|
|
33299
33393
|
let count = 0;
|
|
33300
|
-
|
|
33394
|
+
const savedOffset = offset;
|
|
33395
|
+
const first = options.tail ? next() : null;
|
|
33396
|
+
offset = savedOffset;
|
|
33397
|
+
const omitted = options.tail && object2(first) && uint(first.row, header.history) ? first.row : 0;
|
|
33398
|
+
if (header.history - omitted + header.rows > MAX_ROWS) return null;
|
|
33399
|
+
for (let index = omitted; index < header.history + header.rows; index++) {
|
|
33301
33400
|
const row = next();
|
|
33302
33401
|
if (!object2(row) || row.row !== index || !uint(row.flags) || !uint(row.used, MAX_CELLS - count) || !Array.isArray(row.cells) || row.cells.length > MAX_CELLS - count || (header.version === 1 ? row.cells.length !== row.used : row.cells.length < row.used))
|
|
33303
33402
|
return null;
|
|
@@ -33337,7 +33436,8 @@ function decodeNativeGridCapture(text2) {
|
|
|
33337
33436
|
} : {},
|
|
33338
33437
|
cols: header.cols,
|
|
33339
33438
|
rows: header.rows,
|
|
33340
|
-
history: header.history,
|
|
33439
|
+
history: header.history - omitted,
|
|
33440
|
+
...omitted > 0 ? { omittedHistory: omitted } : {},
|
|
33341
33441
|
hscrolled: header.hscrolled,
|
|
33342
33442
|
limit: header.limit,
|
|
33343
33443
|
cursor: Object.freeze([header.cursor[0], header.cursor[1]]),
|
|
@@ -33347,13 +33447,59 @@ function decodeNativeGridCapture(text2) {
|
|
|
33347
33447
|
return null;
|
|
33348
33448
|
}
|
|
33349
33449
|
}
|
|
33350
|
-
|
|
33450
|
+
function decodeNativeHistoryPiece(text2) {
|
|
33451
|
+
const newline = text2.indexOf("\n");
|
|
33452
|
+
if (newline < 0) return null;
|
|
33453
|
+
let header;
|
|
33454
|
+
let first;
|
|
33455
|
+
try {
|
|
33456
|
+
header = JSON.parse(text2.slice(0, newline));
|
|
33457
|
+
const second = text2.indexOf("\n", newline + 1);
|
|
33458
|
+
first = JSON.parse(text2.slice(newline + 1, second < 0 ? text2.length : second));
|
|
33459
|
+
} catch {
|
|
33460
|
+
return null;
|
|
33461
|
+
}
|
|
33462
|
+
if (!object2(header) || !object2(first) || !uint(first.row) || !uint(header.history)) return null;
|
|
33463
|
+
const firstRow = first.row;
|
|
33464
|
+
const lines = text2.endsWith("\n") ? text2.slice(0, -1).split("\n") : text2.split("\n");
|
|
33465
|
+
const count = lines.length - 1;
|
|
33466
|
+
if (firstRow + count > header.history) return null;
|
|
33467
|
+
const renumbered = [];
|
|
33468
|
+
for (let index = 0; index < count; index++) {
|
|
33469
|
+
const line = lines[index + 1];
|
|
33470
|
+
const prefix = `{"row":${firstRow + index},`;
|
|
33471
|
+
if (!line.startsWith(prefix)) return null;
|
|
33472
|
+
renumbered.push(`{"row":${index},` + line.slice(prefix.length));
|
|
33473
|
+
}
|
|
33474
|
+
const synthetic = {
|
|
33475
|
+
...header,
|
|
33476
|
+
history: count - 1,
|
|
33477
|
+
rows: 1,
|
|
33478
|
+
hscrolled: 0,
|
|
33479
|
+
cursor: [0, 0]
|
|
33480
|
+
};
|
|
33481
|
+
const capture = decodeNativeGridCapture(
|
|
33482
|
+
JSON.stringify(synthetic) + "\n" + renumbered.join("\n") + "\n"
|
|
33483
|
+
);
|
|
33484
|
+
if (!capture || capture.version !== 2) return null;
|
|
33485
|
+
return Object.freeze({
|
|
33486
|
+
cols: capture.cols,
|
|
33487
|
+
historySize: header.history,
|
|
33488
|
+
firstRow,
|
|
33489
|
+
rows: capture.grid
|
|
33490
|
+
});
|
|
33491
|
+
}
|
|
33492
|
+
var NATIVE_BOOTSTRAP_PROBE_FLAGS, NATIVE_BOOTSTRAP_PROBE_LIMITS, MAX_BYTES, MAX_ROWS, MAX_CELLS, NATIVE_SEED_CELL_BUDGET, NATIVE_HISTORY_PIECE_CELL_BUDGET, utf8, uint, signed, object2;
|
|
33351
33493
|
var init_native_grid_capture = __esm({
|
|
33352
33494
|
"packages/daemon/src/terminal/mirror/native-grid-capture.ts"() {
|
|
33353
33495
|
"use strict";
|
|
33496
|
+
NATIVE_BOOTSTRAP_PROBE_FLAGS = ["-V", "-R", "-S", "0", "-E", "0"];
|
|
33497
|
+
NATIVE_BOOTSTRAP_PROBE_LIMITS = { maxBytes: 1024 * 1024, maxLines: 4 };
|
|
33354
33498
|
MAX_BYTES = 16 * 1024 * 1024;
|
|
33355
33499
|
MAX_ROWS = MAX_BYTES / 64;
|
|
33356
33500
|
MAX_CELLS = 1e6;
|
|
33501
|
+
NATIVE_SEED_CELL_BUDGET = 262144;
|
|
33502
|
+
NATIVE_HISTORY_PIECE_CELL_BUDGET = 262144;
|
|
33357
33503
|
utf8 = new TextDecoder("utf-8", { fatal: true, ignoreBOM: true });
|
|
33358
33504
|
uint = (value, max = 4294967295) => typeof value === "number" && Number.isSafeInteger(value) && value >= 0 && value <= max;
|
|
33359
33505
|
signed = (value) => typeof value === "number" && Number.isSafeInteger(value) && value >= -2147483648 && value <= 2147483647;
|
|
@@ -33366,7 +33512,7 @@ import { z as z103 } from "zod";
|
|
|
33366
33512
|
function validLimit(limit) {
|
|
33367
33513
|
return Number.isSafeInteger(limit) && limit > 0 && limit <= NATIVE_ATOMIC_SNAPSHOT_MAX_BYTES;
|
|
33368
33514
|
}
|
|
33369
|
-
function nativeAtomicSnapshotPlan(target, maxBytes = NATIVE_ATOMIC_SNAPSHOT_MAX_BYTES) {
|
|
33515
|
+
function nativeAtomicSnapshotPlan(target, maxBytes = NATIVE_ATOMIC_SNAPSHOT_MAX_BYTES, historyRows) {
|
|
33370
33516
|
const validated = TargetSchema.parse(target);
|
|
33371
33517
|
const continuationBytes = `%continue ${validated.paneId}
|
|
33372
33518
|
`.length;
|
|
@@ -33385,7 +33531,7 @@ function nativeAtomicSnapshotPlan(target, maxBytes = NATIVE_ATOMIC_SNAPSHOT_MAX_
|
|
|
33385
33531
|
"-U",
|
|
33386
33532
|
String(maxBytes - continuationBytes),
|
|
33387
33533
|
"-S",
|
|
33388
|
-
|
|
33534
|
+
historyStart(historyRows),
|
|
33389
33535
|
"-t",
|
|
33390
33536
|
validated.paneId
|
|
33391
33537
|
]
|
|
@@ -33394,12 +33540,18 @@ function nativeAtomicSnapshotPlan(target, maxBytes = NATIVE_ATOMIC_SNAPSHOT_MAX_
|
|
|
33394
33540
|
limits: { maxBytes, maxLines: MAX_LINES }
|
|
33395
33541
|
};
|
|
33396
33542
|
}
|
|
33543
|
+
function historyStart(historyRows) {
|
|
33544
|
+
if (historyRows === void 0) return "-";
|
|
33545
|
+
if (!Number.isSafeInteger(historyRows) || historyRows < 0 || historyRows > 1e6)
|
|
33546
|
+
throw new TypeError("Invalid atomic snapshot history rows");
|
|
33547
|
+
return `-${historyRows}`;
|
|
33548
|
+
}
|
|
33397
33549
|
function validModes(line, capture) {
|
|
33398
33550
|
const fields = line.split(" ");
|
|
33399
33551
|
if (fields.length !== 23) return false;
|
|
33400
33552
|
const numeric = [0, 1, 2, 3, 14, 15].map((index) => decimal(fields[index]));
|
|
33401
33553
|
if (numeric.some((value) => value === null)) return false;
|
|
33402
|
-
if (numeric[0] !== capture.cursor[0] || numeric[1] !== capture.cursor[1] || numeric[2] !== capture.cols || numeric[3] !== capture.rows || numeric[4] !== capture.history || numeric[5] !== capture.limit)
|
|
33554
|
+
if (numeric[0] !== capture.cursor[0] || numeric[1] !== capture.cursor[1] || numeric[2] !== capture.cols || numeric[3] !== capture.rows || numeric[4] !== capture.history + (capture.omittedHistory ?? 0) || numeric[5] !== capture.limit)
|
|
33403
33555
|
return false;
|
|
33404
33556
|
for (const index of [4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 16, 17, 18, 19])
|
|
33405
33557
|
if (!["0", "1", "unknown"].includes(fields[index])) return false;
|
|
@@ -33427,7 +33579,9 @@ function decodeNativeAtomicSnapshot(reply, expected, maxBytes = NATIVE_ATOMIC_SN
|
|
|
33427
33579
|
if (metadata.serverEpoch !== expected.serverEpoch || metadata.paneId !== expected.paneId || metadata.paneBirthId !== expected.paneBirthId)
|
|
33428
33580
|
return unknown;
|
|
33429
33581
|
if (reply.lines.at(-1) !== `%continue ${expected.paneId}`) return unknown;
|
|
33430
|
-
const capture = decodeNativeGridCapture(reply.lines.slice(1, -1).join("\n") + "\n"
|
|
33582
|
+
const capture = decodeNativeGridCapture(reply.lines.slice(1, -1).join("\n") + "\n", {
|
|
33583
|
+
tail: true
|
|
33584
|
+
});
|
|
33431
33585
|
if (!capture || !isNativeBootstrapCapture(capture) || !validModes(metadata.cursor, capture))
|
|
33432
33586
|
return unknown;
|
|
33433
33587
|
return {
|
|
@@ -33441,8 +33595,8 @@ function decodeNativeAtomicSnapshot(reply, expected, maxBytes = NATIVE_ATOMIC_SN
|
|
|
33441
33595
|
return unknown;
|
|
33442
33596
|
}
|
|
33443
33597
|
}
|
|
33444
|
-
function nativeAtomicDualSnapshotPlan(target, maxBytes = NATIVE_ATOMIC_SNAPSHOT_MAX_BYTES) {
|
|
33445
|
-
const plan = nativeAtomicSnapshotPlan(target, maxBytes);
|
|
33598
|
+
function nativeAtomicDualSnapshotPlan(target, maxBytes = NATIVE_ATOMIC_SNAPSHOT_MAX_BYTES, historyRows) {
|
|
33599
|
+
const plan = nativeAtomicSnapshotPlan(target, maxBytes, historyRows);
|
|
33446
33600
|
return {
|
|
33447
33601
|
...plan,
|
|
33448
33602
|
commands: [
|
|
@@ -33455,7 +33609,7 @@ function nativeAtomicDualSnapshotPlan(target, maxBytes = NATIVE_ATOMIC_SNAPSHOT_
|
|
|
33455
33609
|
"-U",
|
|
33456
33610
|
String(maxBytes),
|
|
33457
33611
|
"-S",
|
|
33458
|
-
|
|
33612
|
+
historyStart(historyRows),
|
|
33459
33613
|
"-t",
|
|
33460
33614
|
target.paneId
|
|
33461
33615
|
]
|
|
@@ -34179,6 +34333,10 @@ var init_pane_feed = __esm({
|
|
|
34179
34333
|
currentState() {
|
|
34180
34334
|
return this.state;
|
|
34181
34335
|
}
|
|
34336
|
+
/** Changes with every `beginReseed`; a reply read under another value is stale. */
|
|
34337
|
+
reseedEpoch() {
|
|
34338
|
+
return this.epoch;
|
|
34339
|
+
}
|
|
34182
34340
|
/** Arm a reseed. Returns the epoch token the two reply hooks must present;
|
|
34183
34341
|
* an in-flight older reseed is invalidated wholesale. */
|
|
34184
34342
|
beginReseed() {
|
|
@@ -34482,12 +34640,8 @@ var init_stock_pane_snapshot = __esm({
|
|
|
34482
34640
|
// packages/daemon/src/terminal/mirror/session-channel.ts
|
|
34483
34641
|
import { randomBytes as randomBytes3 } from "node:crypto";
|
|
34484
34642
|
import { hostname } from "node:os";
|
|
34485
|
-
function nativeBootstrapUnsupported(
|
|
34486
|
-
|
|
34487
|
-
return isStockRawGridCapture(lines) || native2 !== null && (native2.version !== 2 || native2.currentAttributes === void 0);
|
|
34488
|
-
return lines.some(
|
|
34489
|
-
(line) => /^(?:parse error: )?(?:command capture-pane: )?unknown flag -R$/.test(line.trim())
|
|
34490
|
-
);
|
|
34643
|
+
function nativeBootstrapUnsupported(lines, native2) {
|
|
34644
|
+
return isStockRawGridCapture(lines) || native2 !== null && (native2.version !== 2 || native2.currentAttributes === void 0);
|
|
34491
34645
|
}
|
|
34492
34646
|
function tmuxSingleQuote(value) {
|
|
34493
34647
|
return `'${value.replaceAll("'", "'\\''")}'`;
|
|
@@ -34502,7 +34656,7 @@ function defaultMirrorPaneId() {
|
|
|
34502
34656
|
function defaultMirrorWindowId() {
|
|
34503
34657
|
return `window.mirror.${randomBytes3(8).toString("hex")}`;
|
|
34504
34658
|
}
|
|
34505
|
-
var TMUX_SERVER_HOSTNAME, STRUCTURAL_NOTIFICATIONS, NATIVE_CLIENT_NOTIFICATIONS, NATIVE_CLIENT_SUBSCRIPTION, SYNC_DEBOUNCE_MS, DISPLAY_NAME_SYNC_INTERVAL_MS, RECOVERY_COMMAND_DEADLINE_MS, RECOVERY_NO_PROGRESS_DEADLINE_MS, RECOVERY_ABSOLUTE_DEADLINE_MS, RECOVERY_MAX_ATTEMPTS, MAX_QUEUED_SNAPSHOTS, RECOVERY_CAPTURE_MAX_BYTES, RECOVERY_CAPTURE_MAX_LINES, RECOVERY_CURSOR_MAX_BYTES, RECOVERY_CURSOR_PROBE_FORMAT, FAILED_RESEED_RESULT, SplitLayoutPublicationPending, SessionChannel;
|
|
34659
|
+
var TMUX_SERVER_HOSTNAME, STRUCTURAL_NOTIFICATIONS, NATIVE_CLIENT_NOTIFICATIONS, NATIVE_CLIENT_SUBSCRIPTION, SYNC_DEBOUNCE_MS, DISPLAY_NAME_SYNC_INTERVAL_MS, RECOVERY_COMMAND_DEADLINE_MS, RECOVERY_NO_PROGRESS_DEADLINE_MS, RECOVERY_ABSOLUTE_DEADLINE_MS, RECOVERY_MAX_ATTEMPTS, RECOVERY_HOLD_AFTER_FAILURES, RECOVERY_HOLD_BASE_MS, RECOVERY_HOLD_MAX_MS, MAX_QUEUED_SNAPSHOTS, RECOVERY_CAPTURE_MAX_BYTES, RECOVERY_CAPTURE_MAX_LINES, RECOVERY_CURSOR_MAX_BYTES, NATIVE_SEED_FALLBACK_COLS, NATIVE_HISTORY_PIECE_LIMITS, RECOVERY_CURSOR_PROBE_FORMAT, FAILED_RESEED_RESULT, SplitLayoutPublicationPending, SessionChannel;
|
|
34506
34660
|
var init_session_channel = __esm({
|
|
34507
34661
|
"packages/daemon/src/terminal/mirror/session-channel.ts"() {
|
|
34508
34662
|
"use strict";
|
|
@@ -34550,10 +34704,18 @@ var init_session_channel = __esm({
|
|
|
34550
34704
|
RECOVERY_NO_PROGRESS_DEADLINE_MS = 3e3;
|
|
34551
34705
|
RECOVERY_ABSOLUTE_DEADLINE_MS = 5e3;
|
|
34552
34706
|
RECOVERY_MAX_ATTEMPTS = 4;
|
|
34707
|
+
RECOVERY_HOLD_AFTER_FAILURES = 2;
|
|
34708
|
+
RECOVERY_HOLD_BASE_MS = 2e3;
|
|
34709
|
+
RECOVERY_HOLD_MAX_MS = 3e4;
|
|
34553
34710
|
MAX_QUEUED_SNAPSHOTS = 64;
|
|
34554
34711
|
RECOVERY_CAPTURE_MAX_BYTES = 16 * 1024 * 1024;
|
|
34555
34712
|
RECOVERY_CAPTURE_MAX_LINES = RECOVERY_CAPTURE_MAX_BYTES / 64;
|
|
34556
34713
|
RECOVERY_CURSOR_MAX_BYTES = 1024;
|
|
34714
|
+
NATIVE_SEED_FALLBACK_COLS = 512;
|
|
34715
|
+
NATIVE_HISTORY_PIECE_LIMITS = {
|
|
34716
|
+
maxBytes: RECOVERY_CAPTURE_MAX_BYTES,
|
|
34717
|
+
maxLines: RECOVERY_CAPTURE_MAX_LINES
|
|
34718
|
+
};
|
|
34557
34719
|
RECOVERY_CURSOR_PROBE_FORMAT = [
|
|
34558
34720
|
"#{cursor_x}",
|
|
34559
34721
|
"#{cursor_y}",
|
|
@@ -34842,7 +35004,8 @@ var init_session_channel = __esm({
|
|
|
34842
35004
|
displayName: display.name,
|
|
34843
35005
|
displayNameSource: display.source,
|
|
34844
35006
|
windowName: pane.descriptor?.windowName ?? null,
|
|
34845
|
-
active: pane.active
|
|
35007
|
+
active: pane.active,
|
|
35008
|
+
...pane.descriptor?.floating ? { floating: true } : {}
|
|
34846
35009
|
};
|
|
34847
35010
|
});
|
|
34848
35011
|
return {
|
|
@@ -35077,6 +35240,15 @@ var init_session_channel = __esm({
|
|
|
35077
35240
|
() => (this.outputOrdinals.get(runtimeId) ?? 0) === outputOrdinal && this.layoutTopologyEpoch === topologyEpoch && this.windowAuthorityOrdinal === authorityOrdinal
|
|
35078
35241
|
);
|
|
35079
35242
|
}
|
|
35243
|
+
/**
|
|
35244
|
+
* A person asked to retry (#872): the pane's next recovery asks tmux even
|
|
35245
|
+
* inside its hold. The failure count is kept, so a failure holds it for the
|
|
35246
|
+
* next, longer time. Nothing for a pane that is not held or not known.
|
|
35247
|
+
*/
|
|
35248
|
+
liftRecoveryHold(semanticPaneId3) {
|
|
35249
|
+
const pane = this.panesBySemantic.get(semanticPaneId3);
|
|
35250
|
+
if (pane) pane.recoveryHoldUntilMs = 0;
|
|
35251
|
+
}
|
|
35080
35252
|
subscribePane(semanticPaneId3, onEvent, onLayout, nativeBootstrap = false) {
|
|
35081
35253
|
const pane = this.panesBySemantic.get(semanticPaneId3);
|
|
35082
35254
|
if (!pane) {
|
|
@@ -35103,6 +35275,7 @@ var init_session_channel = __esm({
|
|
|
35103
35275
|
semanticPaneId3,
|
|
35104
35276
|
() => !sub.closed && sub.pane === pane && this.panesBySemantic.get(semanticPaneId3) === pane
|
|
35105
35277
|
),
|
|
35278
|
+
requestNativeHistory: (request3) => this.requestNativeHistory(sub, request3),
|
|
35106
35279
|
readHistorySize: () => new Promise((resolve47) => {
|
|
35107
35280
|
const current = () => !this.disposed && !sub.closed && !sub.frozen && this.panesByRuntime.get(pane.runtimeId) === pane;
|
|
35108
35281
|
if (!current()) {
|
|
@@ -35167,15 +35340,16 @@ var init_session_channel = __esm({
|
|
|
35167
35340
|
const identity4 = await this.attachedSessionIdentity();
|
|
35168
35341
|
const inventory = await this.describeTrustedInventory(identity4.runtimeSessionId);
|
|
35169
35342
|
if (this.disposed) throw new Error(`mirror session ${this.opts.session} is disposed`);
|
|
35343
|
+
const tiled = inventory.panes.filter((pane) => pane.floating !== true);
|
|
35170
35344
|
const expectedByWindow = /* @__PURE__ */ new Map();
|
|
35171
|
-
for (const pane of
|
|
35345
|
+
for (const pane of tiled) {
|
|
35172
35346
|
const expected = expectedByWindow.get(pane.runtimeWindowId) ?? /* @__PURE__ */ new Set();
|
|
35173
35347
|
expected.add(pane.semanticPaneId);
|
|
35174
35348
|
expectedByWindow.set(pane.runtimeWindowId, expected);
|
|
35175
35349
|
}
|
|
35176
35350
|
if (expectedSemanticPaneIds) {
|
|
35177
35351
|
const requested = [...expectedSemanticPaneIds].sort();
|
|
35178
|
-
const authoritative =
|
|
35352
|
+
const authoritative = tiled.map(({ semanticPaneId: semanticPaneId3 }) => semanticPaneId3).sort();
|
|
35179
35353
|
if (requested.length === 0 || new Set(requested).size !== requested.length || requested.length !== authoritative.length || requested.some((pane, index) => pane !== authoritative[index])) {
|
|
35180
35354
|
const error = new Error(`authoritative layout for ${this.opts.session} changed topology`);
|
|
35181
35355
|
error.name = "MirrorTopologyChangedError";
|
|
@@ -35506,6 +35680,67 @@ var init_session_channel = __esm({
|
|
|
35506
35680
|
rows: layoutContentRows(pane.top, pane.height, event.rows, event.paneBorderStatus)
|
|
35507
35681
|
};
|
|
35508
35682
|
}
|
|
35683
|
+
/**
|
|
35684
|
+
* #873: history rows a native first-open capture reads: the newest that fit
|
|
35685
|
+
* the seed budget at the pane's tmux size. Older rows are read later in
|
|
35686
|
+
* pieces (`requestNativeHistory`), so the open does not depend on the
|
|
35687
|
+
* history's length. Without a known size, assume a 512-column pane.
|
|
35688
|
+
*/
|
|
35689
|
+
nativeSeedHistoryRowsFor(pane) {
|
|
35690
|
+
const size = this.layoutSizeFor(pane.runtimeId);
|
|
35691
|
+
const rows = size ? nativeSeedHistoryRows(size.cols, size.rows) : nativeSeedHistoryRows(NATIVE_SEED_FALLBACK_COLS, 1);
|
|
35692
|
+
const limit = this.opts.historyLines;
|
|
35693
|
+
return limit === void 0 ? rows : Math.min(limit, rows);
|
|
35694
|
+
}
|
|
35695
|
+
/**
|
|
35696
|
+
* #873: read history rows `endRow - rows .. endRow - 1` (tmux's numbers,
|
|
35697
|
+
* from its oldest row) for this subscriber. The answer is one `history`
|
|
35698
|
+
* event, sent from the reply callback so it keeps its place among the
|
|
35699
|
+
* deltas. It is null unless the read stayed clear of every output, layout
|
|
35700
|
+
* and reseed crossing: then the subscriber's parser, having applied every
|
|
35701
|
+
* earlier delta, holds exactly the state tmux read the rows from.
|
|
35702
|
+
*/
|
|
35703
|
+
requestNativeHistory(sub, request3) {
|
|
35704
|
+
const pane = sub.pane;
|
|
35705
|
+
const { endRow, rows, historySize } = request3;
|
|
35706
|
+
if (this.disposed || sub.closed || sub.frozen || !sub.nativeBootstrap || this.nativeBootstrapUnavailable || sub.feed.currentState() !== "live" || ![endRow, rows, historySize].every((value) => Number.isSafeInteger(value)) || endRow < 1 || rows < 1 || historySize < endRow)
|
|
35707
|
+
return false;
|
|
35708
|
+
const runtimeId = pane.runtimeId;
|
|
35709
|
+
const size = this.layoutSizeFor(runtimeId);
|
|
35710
|
+
const cols = size?.cols ?? NATIVE_SEED_FALLBACK_COLS;
|
|
35711
|
+
const wanted = Math.min(
|
|
35712
|
+
rows,
|
|
35713
|
+
endRow,
|
|
35714
|
+
Math.max(1, Math.floor(NATIVE_HISTORY_PIECE_CELL_BUDGET / cols))
|
|
35715
|
+
);
|
|
35716
|
+
const start3 = endRow - wanted - historySize;
|
|
35717
|
+
const end = endRow - 1 - historySize;
|
|
35718
|
+
this.input.flush();
|
|
35719
|
+
const outputOrdinal = this.outputOrdinals.get(runtimeId) ?? 0;
|
|
35720
|
+
const feedEpoch = sub.feed.reseedEpoch();
|
|
35721
|
+
const incarnation = pane.incarnation;
|
|
35722
|
+
let marker = null;
|
|
35723
|
+
this.captureWithViewer(
|
|
35724
|
+
runtimeId,
|
|
35725
|
+
["-R", "-S", String(start3), "-E", String(end)],
|
|
35726
|
+
(value) => {
|
|
35727
|
+
marker = value;
|
|
35728
|
+
},
|
|
35729
|
+
(reply) => {
|
|
35730
|
+
if (marker) {
|
|
35731
|
+
if (reply.ok) this.clearInternalReadMarkerOption(runtimeId, marker);
|
|
35732
|
+
else this.retireInternalReadMarker(runtimeId, marker);
|
|
35733
|
+
}
|
|
35734
|
+
if (sub.closed || this.disposed) return;
|
|
35735
|
+
const windowId = pane.windowRuntimeId;
|
|
35736
|
+
const current = !sub.frozen && sub.pane === pane && this.panesByRuntime.get(runtimeId) === pane && pane.incarnation === incarnation && sub.feed.currentState() === "live" && sub.feed.reseedEpoch() === feedEpoch && (this.outputOrdinals.get(runtimeId) ?? 0) === outputOrdinal && !(windowId !== null && this.pendingLayoutOutput.has(windowId));
|
|
35737
|
+
const piece = current && reply.ok ? decodeNativeHistoryPiece(reply.lines.join("\n") + "\n") : null;
|
|
35738
|
+
sub.onEvent({ type: "history", piece });
|
|
35739
|
+
},
|
|
35740
|
+
NATIVE_HISTORY_PIECE_LIMITS
|
|
35741
|
+
);
|
|
35742
|
+
return true;
|
|
35743
|
+
}
|
|
35509
35744
|
layoutSizeFor(runtime) {
|
|
35510
35745
|
for (const layout of this.layoutByWindow.values()) {
|
|
35511
35746
|
const leaf = layout.leaves.find((candidate) => candidate.id === runtime);
|
|
@@ -35643,8 +35878,12 @@ var init_session_channel = __esm({
|
|
|
35643
35878
|
cancelAbsoluteDeadline: null
|
|
35644
35879
|
};
|
|
35645
35880
|
this.recoveries.set(pane.runtimeId, recovery);
|
|
35646
|
-
|
|
35647
|
-
|
|
35881
|
+
if (recovery.startedAtMs < pane.recoveryHoldUntilMs)
|
|
35882
|
+
this.failRecovery(recovery, "held-after-failures");
|
|
35883
|
+
else {
|
|
35884
|
+
this.snapshotQueue.set(pane.runtimeId, recovery);
|
|
35885
|
+
this.drainSnapshots();
|
|
35886
|
+
}
|
|
35648
35887
|
}
|
|
35649
35888
|
beginLocalOverflowRecovery(pane) {
|
|
35650
35889
|
this.beginRecovery(pane, "backpressure");
|
|
@@ -35807,7 +36046,7 @@ var init_session_channel = __esm({
|
|
|
35807
36046
|
}, RECOVERY_COMMAND_DEADLINE_MS);
|
|
35808
36047
|
this.captureWithViewer(
|
|
35809
36048
|
pane.runtimeId,
|
|
35810
|
-
|
|
36049
|
+
NATIVE_BOOTSTRAP_PROBE_FLAGS,
|
|
35811
36050
|
(value) => {
|
|
35812
36051
|
marker = value;
|
|
35813
36052
|
},
|
|
@@ -35817,9 +36056,9 @@ var init_session_channel = __esm({
|
|
|
35817
36056
|
probeSettled = true;
|
|
35818
36057
|
recovery.cancelCommandDeadline?.();
|
|
35819
36058
|
recovery.cancelCommandDeadline = null;
|
|
35820
|
-
const
|
|
35821
|
-
if (
|
|
35822
|
-
else if (
|
|
36059
|
+
const probe = readNativeBootstrapProbe(reply.ok, reply.lines);
|
|
36060
|
+
if (probe === "native") this.nativeBootstrapConfirmed = true;
|
|
36061
|
+
else if (probe === "unsupported") {
|
|
35823
36062
|
this.nativeBootstrapUnavailable = true;
|
|
35824
36063
|
for (const current of this.panesByRuntime.values())
|
|
35825
36064
|
for (const sub of current.subs) sub.nativeBootstrap = false;
|
|
@@ -35830,7 +36069,7 @@ var init_session_channel = __esm({
|
|
|
35830
36069
|
}
|
|
35831
36070
|
this.startStockSnapshot(pane, recovery, lease);
|
|
35832
36071
|
},
|
|
35833
|
-
|
|
36072
|
+
NATIVE_BOOTSTRAP_PROBE_LIMITS
|
|
35834
36073
|
);
|
|
35835
36074
|
return;
|
|
35836
36075
|
}
|
|
@@ -36014,15 +36253,23 @@ var init_session_channel = __esm({
|
|
|
36014
36253
|
recovery.cancelCommandDeadline = this.scheduleRecovery(failed, RECOVERY_COMMAND_DEADLINE_MS);
|
|
36015
36254
|
const accepted = this.opts.ownedViewer.tryDispatch(
|
|
36016
36255
|
this.io,
|
|
36017
|
-
target.representation === "dual" ? nativeAtomicDualSnapshotPlan(
|
|
36018
|
-
|
|
36019
|
-
|
|
36020
|
-
|
|
36021
|
-
|
|
36022
|
-
|
|
36023
|
-
|
|
36024
|
-
|
|
36025
|
-
|
|
36256
|
+
target.representation === "dual" ? nativeAtomicDualSnapshotPlan(
|
|
36257
|
+
{
|
|
36258
|
+
serverEpoch: target.serverEpoch,
|
|
36259
|
+
paneId: target.paneId,
|
|
36260
|
+
paneBirthId: target.paneBirthId
|
|
36261
|
+
},
|
|
36262
|
+
void 0,
|
|
36263
|
+
this.nativeSeedHistoryRowsFor(pane)
|
|
36264
|
+
) : nativeAtomicSnapshotPlan(
|
|
36265
|
+
{
|
|
36266
|
+
serverEpoch: target.serverEpoch,
|
|
36267
|
+
paneId: target.paneId,
|
|
36268
|
+
paneBirthId: target.paneBirthId
|
|
36269
|
+
},
|
|
36270
|
+
void 0,
|
|
36271
|
+
this.nativeSeedHistoryRowsFor(pane)
|
|
36272
|
+
),
|
|
36026
36273
|
(reply) => {
|
|
36027
36274
|
if (settled || !exact()) {
|
|
36028
36275
|
failed();
|
|
@@ -36231,7 +36478,7 @@ var init_session_channel = __esm({
|
|
|
36231
36478
|
}
|
|
36232
36479
|
const sentinel = (kind) => `display-message -p -l -t ${pane.runtimeId} "%tmux-ide-atomic-v1 ${nonce} ${kind}"`;
|
|
36233
36480
|
const observerCommands = safeObserver ? ` ; ${boundedTmuxInteractionAppendCommand(observer.bufferName, observer.record)} ; wait-for -S ${observer.signalChannel}` : "";
|
|
36234
|
-
const body = `set-option -po -t ${pane.runtimeId} ${INTERNAL_READ_OPERATION_OPTION} ${internalReadMarker} ; ${sentinel("start")} ; capture-pane -p ${nativeCapture ? "-R" : "-e -J"} -S -${this.opts.historyLines ?? ""} -t ${pane.runtimeId} ; ${sentinel("capture-end")}` + (dualCapture ? ` ; capture-pane -p -e -J -S -${this.opts.historyLines ?? ""} -t ${pane.runtimeId} ; ${sentinel("ansi-capture-end")}` : "") + ` ; display-message -p -t ${pane.runtimeId} "${RECOVERY_CURSOR_PROBE_FORMAT}" ; ${sentinel("cursor-end")} ; refresh-client -A ${tmuxSingleQuote(`${pane.runtimeId}:continue`)}` + observerCommands + ` ; if-shell -t ${pane.runtimeId} -F "#{==:#{${INTERNAL_READ_OPERATION_OPTION}},${internalReadMarker}}" ` + tmuxSingleQuote(`set-option -pu -t ${pane.runtimeId} ${INTERNAL_READ_OPERATION_OPTION}`) + ` ${tmuxSingleQuote(`${sentinel("marker-rejected")}`)} ; ${sentinel("status-ok")} ; set-option -pu -t ${pane.runtimeId} ${hookName} ; ${sentinel("complete")}`;
|
|
36481
|
+
const body = `set-option -po -t ${pane.runtimeId} ${INTERNAL_READ_OPERATION_OPTION} ${internalReadMarker} ; ${sentinel("start")} ; capture-pane -p ${nativeCapture ? "-R" : "-e -J"} -S -${nativeCapture ? this.nativeSeedHistoryRowsFor(pane) : this.opts.historyLines ?? ""} -t ${pane.runtimeId} ; ${sentinel("capture-end")}` + (dualCapture ? ` ; capture-pane -p -e -J -S -${this.opts.historyLines ?? ""} -t ${pane.runtimeId} ; ${sentinel("ansi-capture-end")}` : "") + ` ; display-message -p -t ${pane.runtimeId} "${RECOVERY_CURSOR_PROBE_FORMAT}" ; ${sentinel("cursor-end")} ; refresh-client -A ${tmuxSingleQuote(`${pane.runtimeId}:continue`)}` + observerCommands + ` ; if-shell -t ${pane.runtimeId} -F "#{==:#{${INTERNAL_READ_OPERATION_OPTION}},${internalReadMarker}}" ` + tmuxSingleQuote(`set-option -pu -t ${pane.runtimeId} ${INTERNAL_READ_OPERATION_OPTION}`) + ` ${tmuxSingleQuote(`${sentinel("marker-rejected")}`)} ; ${sentinel("status-ok")} ; set-option -pu -t ${pane.runtimeId} ${hookName} ; ${sentinel("complete")}`;
|
|
36235
36482
|
this.input.flush();
|
|
36236
36483
|
const invoke = (reply) => {
|
|
36237
36484
|
if (settled || !this.snapshotLeaseCurrent(lease)) {
|
|
@@ -36296,9 +36543,9 @@ var init_session_channel = __esm({
|
|
|
36296
36543
|
return;
|
|
36297
36544
|
}
|
|
36298
36545
|
const captureLines = Object.freeze([...result2.captureLines]);
|
|
36299
|
-
const native2 = nativeCapture ? decodeNativeGridCapture(captureLines.join("\n")) : null;
|
|
36546
|
+
const native2 = nativeCapture ? decodeNativeGridCapture(captureLines.join("\n"), { tail: true }) : null;
|
|
36300
36547
|
if (nativeCapture && (!native2 || !isNativeBootstrapCapture(native2))) {
|
|
36301
|
-
if (nativeBootstrapUnsupported(
|
|
36548
|
+
if (nativeBootstrapUnsupported(captureLines, native2)) {
|
|
36302
36549
|
this.nativeBootstrapUnavailable = true;
|
|
36303
36550
|
for (const { sub } of participants) sub.nativeBootstrap = false;
|
|
36304
36551
|
}
|
|
@@ -36427,6 +36674,7 @@ var init_session_channel = __esm({
|
|
|
36427
36674
|
recovery.cancelAbsoluteDeadline = null;
|
|
36428
36675
|
this.recoveries.delete(recovery.runtimeId);
|
|
36429
36676
|
recovery.retired = true;
|
|
36677
|
+
pane.failedRecoveries = 0;
|
|
36430
36678
|
this.ledger.noteContinued(recovery.runtimeId);
|
|
36431
36679
|
if (recovery.reason === "requested") this.ledger.clearRequest(recovery.runtimeId);
|
|
36432
36680
|
for (const sub of pane.subs) {
|
|
@@ -36449,6 +36697,13 @@ var init_session_channel = __esm({
|
|
|
36449
36697
|
failRecovery(recovery, failureReason) {
|
|
36450
36698
|
const pane = this.recoveryPane(recovery);
|
|
36451
36699
|
if (!pane) return;
|
|
36700
|
+
if (failureReason !== "held-after-failures") {
|
|
36701
|
+
pane.failedRecoveries += 1;
|
|
36702
|
+
pane.heldWhy = recovery.collectorFailureReason === "capture-byte-cap" ? "too-large" : "failed";
|
|
36703
|
+
const repeats = pane.failedRecoveries - RECOVERY_HOLD_AFTER_FAILURES;
|
|
36704
|
+
if (repeats >= 0)
|
|
36705
|
+
pane.recoveryHoldUntilMs = this.recoveryNowMs() + Math.min(RECOVERY_HOLD_MAX_MS, RECOVERY_HOLD_BASE_MS * 2 ** repeats);
|
|
36706
|
+
}
|
|
36452
36707
|
recovery.cancelCommandDeadline?.();
|
|
36453
36708
|
recovery.cancelCommandDeadline = null;
|
|
36454
36709
|
recovery.cancelNoProgressDeadline?.();
|
|
@@ -36464,11 +36719,18 @@ var init_session_channel = __esm({
|
|
|
36464
36719
|
recovery.atomicCollectorNonce = null;
|
|
36465
36720
|
if (collectorNonce) this.io.retireAtomicPaneSnapshotCollector?.(collectorNonce, "retired");
|
|
36466
36721
|
this.observeRecovery(pane, recovery, "nonconverged", failureReason);
|
|
36722
|
+
const hold = failureReason === "held-after-failures" ? {
|
|
36723
|
+
// Positive: a refusal starts before the hold ends.
|
|
36724
|
+
retryInMs: Math.ceil(pane.recoveryHoldUntilMs - this.recoveryNowMs()),
|
|
36725
|
+
why: pane.heldWhy
|
|
36726
|
+
} : null;
|
|
36467
36727
|
for (const sub of pane.subs) {
|
|
36468
36728
|
sub.cancelCapture?.();
|
|
36469
36729
|
if (sub.closed || sub.frozen) continue;
|
|
36470
36730
|
try {
|
|
36471
|
-
sub.onEvent(
|
|
36731
|
+
sub.onEvent(
|
|
36732
|
+
hold ? { type: "fault", reason: "native-recovery-failed", hold } : { type: "fault", reason: "native-recovery-failed" }
|
|
36733
|
+
);
|
|
36472
36734
|
} catch {
|
|
36473
36735
|
}
|
|
36474
36736
|
}
|
|
@@ -36539,6 +36801,10 @@ var init_session_channel = __esm({
|
|
|
36539
36801
|
if (pane && Number.isSafeInteger(size)) {
|
|
36540
36802
|
const cleared = size === 0 && (pane.historySize ?? 0) > 0;
|
|
36541
36803
|
pane.historySize = size;
|
|
36804
|
+
if (cleared) {
|
|
36805
|
+
pane.failedRecoveries = 0;
|
|
36806
|
+
pane.recoveryHoldUntilMs = 0;
|
|
36807
|
+
}
|
|
36542
36808
|
if (cleared && !this.recoveries.has(pane.runtimeId)) {
|
|
36543
36809
|
for (const sub of pane.subs) if (!sub.closed && !sub.frozen) this.reseedPlain(sub);
|
|
36544
36810
|
}
|
|
@@ -36643,8 +36909,9 @@ var init_session_channel = __esm({
|
|
|
36643
36909
|
return;
|
|
36644
36910
|
}
|
|
36645
36911
|
const leafIds = new Set(membership.leaves.map((leaf) => leaf.id));
|
|
36912
|
+
const floatingIds2 = new Set((membership.floating ?? []).map((leaf) => leaf.id));
|
|
36646
36913
|
const knownPaneVanished = [...this.panesByRuntime.values()].some(
|
|
36647
|
-
(pane) => pane.windowRuntimeId === change.windowId && !leafIds.has(pane.runtimeId)
|
|
36914
|
+
(pane) => pane.windowRuntimeId === change.windowId && !leafIds.has(pane.runtimeId) && !floatingIds2.has(pane.runtimeId)
|
|
36648
36915
|
);
|
|
36649
36916
|
if (membership.leaves.some((leaf) => !this.panesByRuntime.has(leaf.id)) || knownPaneVanished) {
|
|
36650
36917
|
this.scheduleSync();
|
|
@@ -37013,15 +37280,25 @@ var init_session_channel = __esm({
|
|
|
37013
37280
|
const stagedPaneIds = /* @__PURE__ */ new Set();
|
|
37014
37281
|
let stagedPaneCount = 0;
|
|
37015
37282
|
let stagedPaneMembershipExact = true;
|
|
37283
|
+
const floatingByWindow = /* @__PURE__ */ new Map();
|
|
37284
|
+
for (const descriptor of descriptors) {
|
|
37285
|
+
if (!descriptor.floating) continue;
|
|
37286
|
+
const floating = floatingByWindow.get(descriptor.windowId) ?? /* @__PURE__ */ new Set();
|
|
37287
|
+
floating.add(descriptor.runtimePaneId);
|
|
37288
|
+
floatingByWindow.set(descriptor.windowId, floating);
|
|
37289
|
+
}
|
|
37290
|
+
let floatingPaneCount = 0;
|
|
37016
37291
|
for (const [runtimeWindowId, layout] of confirmedWindowStage.layouts) {
|
|
37017
37292
|
const membership = layout.zoomed ? layout.unzoomed : layout;
|
|
37018
|
-
|
|
37293
|
+
const floating = floatingByWindow.get(runtimeWindowId) ?? /* @__PURE__ */ new Set();
|
|
37294
|
+
if (!membership || membership.leaves.length + floating.size !== computedWindowCounts.get(runtimeWindowId) || (membership.floating ?? []).some((leaf) => !floating.has(leaf.id))) {
|
|
37019
37295
|
stagedPaneMembershipExact = false;
|
|
37020
37296
|
break;
|
|
37021
37297
|
}
|
|
37298
|
+
floatingPaneCount += floating.size;
|
|
37022
37299
|
for (const leaf of membership.leaves) {
|
|
37023
37300
|
stagedPaneCount += 1;
|
|
37024
|
-
if (stagedPaneIds.has(leaf.id) || descriptorWindowByPane.get(leaf.id) !== runtimeWindowId) {
|
|
37301
|
+
if (stagedPaneIds.has(leaf.id) || floating.has(leaf.id) || descriptorWindowByPane.get(leaf.id) !== runtimeWindowId) {
|
|
37025
37302
|
stagedPaneMembershipExact = false;
|
|
37026
37303
|
break;
|
|
37027
37304
|
}
|
|
@@ -37029,7 +37306,7 @@ var init_session_channel = __esm({
|
|
|
37029
37306
|
}
|
|
37030
37307
|
if (!stagedPaneMembershipExact) break;
|
|
37031
37308
|
}
|
|
37032
|
-
if (confirmedWindowStage.currentWindow !== activeWindowId || confirmedWindowStage.links.length !== descriptors[0].sessionWindowCount || confirmedWindowStage.windows.size !== computedWindowCounts.size || !stagedPaneMembershipExact || stagedPaneCount !== descriptors.length || stagedPaneIds.size !== descriptors.length || [...computedWindowCounts.keys()].some(
|
|
37309
|
+
if (confirmedWindowStage.currentWindow !== activeWindowId || confirmedWindowStage.links.length !== descriptors[0].sessionWindowCount || confirmedWindowStage.windows.size !== computedWindowCounts.size || !stagedPaneMembershipExact || stagedPaneCount + floatingPaneCount !== descriptors.length || stagedPaneIds.size + floatingPaneCount !== descriptors.length || [...computedWindowCounts.keys()].some(
|
|
37033
37310
|
(runtimeWindowId) => !confirmedWindowStage.windows.has(runtimeWindowId)
|
|
37034
37311
|
))
|
|
37035
37312
|
throw new Error(`trusted inventory for ${this.opts.session} lacks verified identity`);
|
|
@@ -37100,7 +37377,8 @@ var init_session_channel = __esm({
|
|
|
37100
37377
|
type: descriptor.type,
|
|
37101
37378
|
missionStamp: descriptor.missionStamp,
|
|
37102
37379
|
nativePaneBirthId: descriptor.nativePaneBirthId ?? null,
|
|
37103
|
-
dir: descriptor.cwd ?? ""
|
|
37380
|
+
dir: descriptor.cwd ?? "",
|
|
37381
|
+
...descriptor.floating ? { floating: true } : {}
|
|
37104
37382
|
});
|
|
37105
37383
|
});
|
|
37106
37384
|
return Object.freeze({
|
|
@@ -37451,7 +37729,10 @@ var init_session_channel = __esm({
|
|
|
37451
37729
|
windowRuntimeId,
|
|
37452
37730
|
subs: /* @__PURE__ */ new Set(),
|
|
37453
37731
|
incarnation: ++this.paneIncarnation,
|
|
37454
|
-
snapshotLayoutGeneration: 0
|
|
37732
|
+
snapshotLayoutGeneration: 0,
|
|
37733
|
+
failedRecoveries: 0,
|
|
37734
|
+
recoveryHoldUntilMs: 0,
|
|
37735
|
+
heldWhy: "failed"
|
|
37455
37736
|
};
|
|
37456
37737
|
this.panesByRuntime.set(record2.runtimeId, record2);
|
|
37457
37738
|
this.panesBySemantic.set(record2.semanticId, record2);
|
|
@@ -45133,6 +45414,16 @@ var init_mirror_service = __esm({
|
|
|
45133
45414
|
if (this.channels.get(session) !== entry || entry.retired) return null;
|
|
45134
45415
|
return identity4;
|
|
45135
45416
|
}
|
|
45417
|
+
/**
|
|
45418
|
+
* #872: a person asked to retry these panes now. Each one's next recovery
|
|
45419
|
+
* asks tmux even inside a hold after failed recoveries. A session without a
|
|
45420
|
+
* channel has no hold to lift.
|
|
45421
|
+
*/
|
|
45422
|
+
liftRecoveryHolds(session, semanticPaneIds2) {
|
|
45423
|
+
const entry = this.channels.get(session);
|
|
45424
|
+
if (!entry || entry.retired) return;
|
|
45425
|
+
for (const semanticPaneId3 of semanticPaneIds2) entry.channel.liftRecoveryHold(semanticPaneId3);
|
|
45426
|
+
}
|
|
45136
45427
|
async subscribe(request3) {
|
|
45137
45428
|
const entry = await this.acquire(request3.session);
|
|
45138
45429
|
let handle;
|
|
@@ -45155,6 +45446,7 @@ var init_mirror_service = __esm({
|
|
|
45155
45446
|
thaw: () => handle.thaw(),
|
|
45156
45447
|
reseed: () => handle.reseed(),
|
|
45157
45448
|
readHistorySize: () => handle.readHistorySize(),
|
|
45449
|
+
requestNativeHistory: (historyRequest) => handle.requestNativeHistory(historyRequest),
|
|
45158
45450
|
captureNativeBacking: () => handle.captureNativeBacking(),
|
|
45159
45451
|
sendText: (text2) => {
|
|
45160
45452
|
this.assertWindowOwnership(request3.session);
|
|
@@ -46402,6 +46694,22 @@ var init_semantic_mutation_executor = __esm({
|
|
|
46402
46694
|
}
|
|
46403
46695
|
});
|
|
46404
46696
|
|
|
46697
|
+
// packages/daemon/src/terminal/mirror/pane-hold.ts
|
|
46698
|
+
var MirrorPaneHeldError;
|
|
46699
|
+
var init_pane_hold = __esm({
|
|
46700
|
+
"packages/daemon/src/terminal/mirror/pane-hold.ts"() {
|
|
46701
|
+
"use strict";
|
|
46702
|
+
MirrorPaneHeldError = class extends Error {
|
|
46703
|
+
hold;
|
|
46704
|
+
constructor(hold) {
|
|
46705
|
+
super("Native terminal recovery held after failed recoveries");
|
|
46706
|
+
this.name = "MirrorPaneHeldError";
|
|
46707
|
+
this.hold = hold;
|
|
46708
|
+
}
|
|
46709
|
+
};
|
|
46710
|
+
}
|
|
46711
|
+
});
|
|
46712
|
+
|
|
46405
46713
|
// packages/daemon/src/terminal/session-runtime/history-anchor-owner.ts
|
|
46406
46714
|
import { randomUUID as randomUUID29 } from "node:crypto";
|
|
46407
46715
|
var MAX_TOKENS, PROOF_TTL_MS, HistoryAnchorOwner;
|
|
@@ -50490,6 +50798,15 @@ var init_native_seed_backing = __esm({
|
|
|
50490
50798
|
}
|
|
50491
50799
|
});
|
|
50492
50800
|
|
|
50801
|
+
// packages/daemon/src/terminal/session-runtime/terminal-interpreter-backend.ts
|
|
50802
|
+
var DAEMON_HISTORY_ROW_CAP;
|
|
50803
|
+
var init_terminal_interpreter_backend = __esm({
|
|
50804
|
+
"packages/daemon/src/terminal/session-runtime/terminal-interpreter-backend.ts"() {
|
|
50805
|
+
"use strict";
|
|
50806
|
+
DAEMON_HISTORY_ROW_CAP = 1e4;
|
|
50807
|
+
}
|
|
50808
|
+
});
|
|
50809
|
+
|
|
50493
50810
|
// node_modules/.pnpm/@tmux-ide+xterm-headless@file+packages+daemon+native+xterm+tmux-ide-xterm-headless-6.0.0-tmuxide.3-local.5.tgz/node_modules/@tmux-ide/xterm-headless/lib-headless/xterm-headless.mjs
|
|
50494
50811
|
function stringFromCodePoint(codePoint) {
|
|
50495
50812
|
if (codePoint > 65535) {
|
|
@@ -63279,6 +63596,7 @@ var init_xterm_terminal_interpreter_backend = __esm({
|
|
|
63279
63596
|
init_xterm_headless();
|
|
63280
63597
|
import_addon_unicode11 = __toESM(require_addon_unicode11(), 1);
|
|
63281
63598
|
init_src3();
|
|
63599
|
+
init_terminal_interpreter_backend();
|
|
63282
63600
|
XtermTerminalInterpreterBackend = class {
|
|
63283
63601
|
kind = "xterm";
|
|
63284
63602
|
#terminal;
|
|
@@ -63298,9 +63616,14 @@ var init_xterm_terminal_interpreter_backend = __esm({
|
|
|
63298
63616
|
#nativeModesObserved = false;
|
|
63299
63617
|
#historyProjectionInvalidated = false;
|
|
63300
63618
|
#scrollOnClear;
|
|
63619
|
+
/** #873: tmux history rows older than the oldest row held (see omittedHistory). */
|
|
63620
|
+
#omittedHistory = 0;
|
|
63621
|
+
/** #873: the most history rows held; rows pushed past it count as left out. */
|
|
63622
|
+
#historyRowCap;
|
|
63301
63623
|
constructor(options) {
|
|
63302
63624
|
const historyLimit = options.historyLimit ?? options.scrollback;
|
|
63303
63625
|
this.#historyLimit = historyLimit;
|
|
63626
|
+
this.#historyRowCap = options.historyRowCap ?? DAEMON_HISTORY_ROW_CAP;
|
|
63304
63627
|
this.#terminal = new Terminal2({
|
|
63305
63628
|
cols: options.cols,
|
|
63306
63629
|
rows: options.rows,
|
|
@@ -63358,22 +63681,60 @@ var init_xterm_terminal_interpreter_backend = __esm({
|
|
|
63358
63681
|
*/
|
|
63359
63682
|
startHistoryCollection() {
|
|
63360
63683
|
this.#collecting = true;
|
|
63684
|
+
this.#enforceRowCap();
|
|
63361
63685
|
this.#lastYbase = this.#normalBuffer()?.ybase ?? null;
|
|
63362
63686
|
}
|
|
63687
|
+
historyRowCap() {
|
|
63688
|
+
return this.#historyRowCap;
|
|
63689
|
+
}
|
|
63690
|
+
/**
|
|
63691
|
+
* #873: hold at most #historyRowCap history rows. The oldest rows past it
|
|
63692
|
+
* are dropped here and counted as left out, so tmux's history size is still
|
|
63693
|
+
* the rows held plus the rows left out. tmux itself keeps them.
|
|
63694
|
+
*/
|
|
63695
|
+
#enforceRowCap() {
|
|
63696
|
+
const buffer = this.#normalBuffer();
|
|
63697
|
+
if (!buffer || buffer.ybase <= this.#historyRowCap) return;
|
|
63698
|
+
const extra = buffer.ybase - this.#historyRowCap;
|
|
63699
|
+
buffer.lines.trimStart(extra);
|
|
63700
|
+
buffer.ybase -= extra;
|
|
63701
|
+
buffer.ydisp = Math.max(0, buffer.ydisp - extra);
|
|
63702
|
+
this.#setOmittedHistory(this.#omittedHistory + extra);
|
|
63703
|
+
}
|
|
63363
63704
|
#normalBuffer() {
|
|
63364
63705
|
return this.#terminal._core?.buffers?.normal;
|
|
63365
63706
|
}
|
|
63707
|
+
omittedHistory() {
|
|
63708
|
+
return this.#omittedHistory;
|
|
63709
|
+
}
|
|
63710
|
+
/**
|
|
63711
|
+
* The parser's own erase-in-display collection counts only the rows held.
|
|
63712
|
+
* While tmux holds older rows than these, turn it off: #collectHistory then
|
|
63713
|
+
* collects after each of the erase's scrolls instead, which leaves the same
|
|
63714
|
+
* rows as tmux's collection before it.
|
|
63715
|
+
*/
|
|
63716
|
+
#setOmittedHistory(count) {
|
|
63717
|
+
this.#omittedHistory = count;
|
|
63718
|
+
this.#terminal.options.tmuxHistoryLimit = count > 0 ? Number.MAX_SAFE_INTEGER : this.#historyLimit;
|
|
63719
|
+
}
|
|
63366
63720
|
#collectHistory() {
|
|
63367
63721
|
const buffer = this.#normalBuffer();
|
|
63368
63722
|
if (!buffer) return;
|
|
63369
63723
|
const before = this.#lastYbase;
|
|
63370
63724
|
const limit = this.#historyLimit;
|
|
63371
|
-
|
|
63372
|
-
|
|
63373
|
-
buffer.
|
|
63374
|
-
|
|
63375
|
-
|
|
63376
|
-
|
|
63725
|
+
const omitted = this.#omittedHistory;
|
|
63726
|
+
if (this.#collecting && limit > 0 && before !== null && omitted + before >= limit && buffer.ybase === before + 1) {
|
|
63727
|
+
const collected = Math.min(omitted + buffer.ybase, Math.max(1, Math.floor(limit / 10)));
|
|
63728
|
+
const fromOmitted = Math.min(omitted, collected);
|
|
63729
|
+
if (fromOmitted > 0) this.#setOmittedHistory(omitted - fromOmitted);
|
|
63730
|
+
const trim = collected - fromOmitted;
|
|
63731
|
+
if (trim > 0) {
|
|
63732
|
+
buffer.lines.trimStart(trim);
|
|
63733
|
+
buffer.ybase -= trim;
|
|
63734
|
+
buffer.ydisp = Math.max(0, buffer.ydisp - trim);
|
|
63735
|
+
}
|
|
63736
|
+
}
|
|
63737
|
+
if (this.#collecting) this.#enforceRowCap();
|
|
63377
63738
|
this.#lastYbase = buffer.ybase;
|
|
63378
63739
|
}
|
|
63379
63740
|
get cols() {
|
|
@@ -63411,6 +63772,8 @@ var init_xterm_terminal_interpreter_backend = __esm({
|
|
|
63411
63772
|
const cell = this.#terminal.buffer.active.getNullCell();
|
|
63412
63773
|
if (typeof cell.setFromCharData !== "function")
|
|
63413
63774
|
throw new Error("Unsupported @tmux-ide/xterm-headless 6 native cell shape");
|
|
63775
|
+
const omitted = snapshot3.omittedHistory ?? 0;
|
|
63776
|
+
if (!Number.isSafeInteger(omitted) || omitted < 0) return false;
|
|
63414
63777
|
if (buffer.lines.maxLength < snapshot3.grid.length) return false;
|
|
63415
63778
|
buffer.lines.length = 0;
|
|
63416
63779
|
for (let index = 0; index < snapshot3.grid.length; index++) {
|
|
@@ -63458,9 +63821,46 @@ var init_xterm_terminal_interpreter_backend = __esm({
|
|
|
63458
63821
|
1
|
|
63459
63822
|
).cells[0];
|
|
63460
63823
|
[handler._curAttrData.fg, handler._curAttrData.bg] = nativeImportAttributes(current);
|
|
63824
|
+
this.#setOmittedHistory(omitted);
|
|
63825
|
+
this.#historyProjectionInvalidated = true;
|
|
63826
|
+
return true;
|
|
63827
|
+
}
|
|
63828
|
+
prependNativeHistory(piece) {
|
|
63829
|
+
const omitted = this.#omittedHistory;
|
|
63830
|
+
const buffer = this.#normalBuffer();
|
|
63831
|
+
if (!buffer || omitted <= 0 || this.#terminal.buffer.active.type !== "normal" || piece.cols !== this.cols || piece.historySize !== omitted + buffer.ybase || !Number.isSafeInteger(piece.firstRow) || piece.firstRow < 0 || piece.firstRow >= omitted || piece.firstRow + piece.rows.length < omitted || !this.canImportNativeGrid())
|
|
63832
|
+
return false;
|
|
63833
|
+
const count = omitted - piece.firstRow;
|
|
63834
|
+
if (buffer.lines.length + count > buffer.lines.maxLength) return false;
|
|
63835
|
+
const lines = piece.rows.slice(0, count).map(
|
|
63836
|
+
(row, index) => this.#nativeLine(row, index > 0 && (piece.rows[index - 1].flags & 1) !== 0)
|
|
63837
|
+
);
|
|
63838
|
+
for (let offset = 0; offset < lines.length; offset += 4096)
|
|
63839
|
+
buffer.lines.splice(offset, 0, ...lines.slice(offset, offset + 4096));
|
|
63840
|
+
const boundary2 = buffer.lines.get(count);
|
|
63841
|
+
if (boundary2) boundary2.isWrapped = (piece.rows[count - 1].flags & 1) !== 0;
|
|
63842
|
+
buffer.ybase += count;
|
|
63843
|
+
buffer.ydisp += count;
|
|
63844
|
+
if (this.#lastYbase !== null) this.#lastYbase += count;
|
|
63845
|
+
this.#setOmittedHistory(piece.firstRow);
|
|
63846
|
+
this.#enforceRowCap();
|
|
63461
63847
|
this.#historyProjectionInvalidated = true;
|
|
63462
63848
|
return true;
|
|
63463
63849
|
}
|
|
63850
|
+
/** One native row as a parser line, as importNativeGrid writes it. */
|
|
63851
|
+
#nativeLine(source, wrapped) {
|
|
63852
|
+
const buffer = this.#terminal.buffer.active._buffer;
|
|
63853
|
+
const cell = this.#terminal.buffer.active.getNullCell();
|
|
63854
|
+
const row = projectNativeGridRow(source, this.cols, 0, wrapped);
|
|
63855
|
+
const line = buffer.getBlankLine(void 0, row.wrapped);
|
|
63856
|
+
for (let column = 0; column < row.cells.length; column++) {
|
|
63857
|
+
const projected = row.cells[column];
|
|
63858
|
+
cell.setFromCharData([0, projected.grapheme, projected.width, 0]);
|
|
63859
|
+
[cell.fg, cell.bg] = nativeImportAttributes(projected);
|
|
63860
|
+
line.setCell(column, cell);
|
|
63861
|
+
}
|
|
63862
|
+
return line;
|
|
63863
|
+
}
|
|
63464
63864
|
prioritizeNextWrite() {
|
|
63465
63865
|
this.#terminal.prioritizeNextWrite();
|
|
63466
63866
|
}
|
|
@@ -64527,6 +64927,7 @@ var init_terminal_replica_interpreter = __esm({
|
|
|
64527
64927
|
init_src3();
|
|
64528
64928
|
init_runtime_scheduler();
|
|
64529
64929
|
init_runtime_observability();
|
|
64930
|
+
init_terminal_interpreter_backend();
|
|
64530
64931
|
init_xterm_terminal_interpreter_backend();
|
|
64531
64932
|
init_causal_cell_ledger();
|
|
64532
64933
|
init_kitty_graphics();
|
|
@@ -64544,6 +64945,7 @@ var init_terminal_replica_interpreter = __esm({
|
|
|
64544
64945
|
#semanticPaneId;
|
|
64545
64946
|
#incarnation;
|
|
64546
64947
|
#scrollback;
|
|
64948
|
+
#historyRowCap;
|
|
64547
64949
|
#listeners = /* @__PURE__ */ new Set();
|
|
64548
64950
|
#onRawCommit;
|
|
64549
64951
|
#scheduler;
|
|
@@ -64610,6 +65012,7 @@ var init_terminal_replica_interpreter = __esm({
|
|
|
64610
65012
|
this.#incarnation = options.incarnation;
|
|
64611
65013
|
this.#revision = options.initialRevision ?? 0;
|
|
64612
65014
|
this.#scrollback = options.scrollback ?? 5e3;
|
|
65015
|
+
this.#historyRowCap = options.historyRowCap ?? DAEMON_HISTORY_ROW_CAP;
|
|
64613
65016
|
this.#onRawCommit = options.onRawCommit;
|
|
64614
65017
|
this.#onNativeReseedRequired = options.onNativeReseedRequired;
|
|
64615
65018
|
this.#scheduler = options.scheduler ?? SYSTEM_SESSION_RUNTIME_SCHEDULER;
|
|
@@ -64618,7 +65021,8 @@ var init_terminal_replica_interpreter = __esm({
|
|
|
64618
65021
|
this.#backend = this.#backendFactory({
|
|
64619
65022
|
cols: options.cols,
|
|
64620
65023
|
rows: options.rows,
|
|
64621
|
-
scrollback: this.#scrollback
|
|
65024
|
+
scrollback: this.#scrollback,
|
|
65025
|
+
historyRowCap: this.#historyRowCap
|
|
64622
65026
|
});
|
|
64623
65027
|
this.#backend.startHistoryCollection?.();
|
|
64624
65028
|
this.#kitty = new KittyImageStore(
|
|
@@ -64668,6 +65072,33 @@ var init_terminal_replica_interpreter = __esm({
|
|
|
64668
65072
|
} : operation;
|
|
64669
65073
|
return this.#append(admitted);
|
|
64670
65074
|
}
|
|
65075
|
+
/**
|
|
65076
|
+
* #873: prepend the older history rows of a piece read from tmux, in order
|
|
65077
|
+
* with the writes queued before it. True when the rows were prepended and a
|
|
65078
|
+
* new revision published; false when the piece does not fit the replica as
|
|
65079
|
+
* it is at that point of the stream (see the backend's prependNativeHistory).
|
|
65080
|
+
*/
|
|
65081
|
+
prependNativeHistory(piece) {
|
|
65082
|
+
this.#flushWrites();
|
|
65083
|
+
const run = this.#tail.then(() => this.#applyHistoryPiece(piece));
|
|
65084
|
+
this.#tail = run.then(
|
|
65085
|
+
() => void 0,
|
|
65086
|
+
() => void 0
|
|
65087
|
+
);
|
|
65088
|
+
return run;
|
|
65089
|
+
}
|
|
65090
|
+
/**
|
|
65091
|
+
* #873: tmux history rows older than the replica's oldest history row; tmux's
|
|
65092
|
+
* history size is this plus the replica's history rows. Set by a native seed
|
|
65093
|
+
* that left them out, zero after any other seed.
|
|
65094
|
+
*/
|
|
65095
|
+
omittedHistory() {
|
|
65096
|
+
return this.#backend.omittedHistory?.() ?? 0;
|
|
65097
|
+
}
|
|
65098
|
+
/** #873: the most history rows the replica holds; the backfill stops there. */
|
|
65099
|
+
historyRowCap() {
|
|
65100
|
+
return this.#historyRowCap;
|
|
65101
|
+
}
|
|
64671
65102
|
whenIdle() {
|
|
64672
65103
|
this.#flushWrites();
|
|
64673
65104
|
return this.#tail;
|
|
@@ -64756,13 +65187,14 @@ var init_terminal_replica_interpreter = __esm({
|
|
|
64756
65187
|
const scrollback = Math.max(
|
|
64757
65188
|
operation.historyLimit ?? this.#scrollback,
|
|
64758
65189
|
operation.historySize ?? 0,
|
|
64759
|
-
operation.native?.history ?? 0
|
|
65190
|
+
(operation.native?.history ?? 0) + (operation.native?.omittedHistory ?? 0)
|
|
64760
65191
|
);
|
|
64761
65192
|
const replacement = this.#backendFactory({
|
|
64762
65193
|
cols: nativeCols,
|
|
64763
65194
|
rows: nativeRows,
|
|
64764
65195
|
scrollback,
|
|
64765
|
-
historyLimit: operation.historyLimit ?? scrollback
|
|
65196
|
+
historyLimit: operation.historyLimit ?? scrollback,
|
|
65197
|
+
historyRowCap: this.#historyRowCap
|
|
64766
65198
|
});
|
|
64767
65199
|
try {
|
|
64768
65200
|
if (operation.native && !replacement.importNativeGrid?.(operation.native))
|
|
@@ -64874,6 +65306,15 @@ var init_terminal_replica_interpreter = __esm({
|
|
|
64874
65306
|
this.#backend.dispose();
|
|
64875
65307
|
this.#emit(update);
|
|
64876
65308
|
}
|
|
65309
|
+
#applyHistoryPiece(piece) {
|
|
65310
|
+
if (this.#closed || this.#needsSeed || this.#nativeReseedRequested || this.#pendingResize !== null || this.#backend.requiresNativeReseed() || // A synchronized update publishes nothing until it ends.
|
|
65311
|
+
this.#backend.modes().synchronizedOutput || !this.#backend.prependNativeHistory?.(piece))
|
|
65312
|
+
return false;
|
|
65313
|
+
this.#kitty.dropCursorPlacements();
|
|
65314
|
+
this.#commit(false);
|
|
65315
|
+
this.#publishGraphics();
|
|
65316
|
+
return true;
|
|
65317
|
+
}
|
|
64877
65318
|
async #write(data, continuedTrace, hasBacklog = () => false) {
|
|
64878
65319
|
if (this.#closed || this.#nativeReseedRequested) return;
|
|
64879
65320
|
const trace = continuedTrace;
|
|
@@ -65315,18 +65756,24 @@ function layoutLeaseEqual(left, right) {
|
|
|
65315
65756
|
function diagnosticInteger(value) {
|
|
65316
65757
|
return typeof value === "number" && Number.isSafeInteger(value) && value >= 0 ? value : null;
|
|
65317
65758
|
}
|
|
65318
|
-
var PARK_AFTER_MS, SessionRuntimeTerminalReplicaOwner;
|
|
65759
|
+
var PARK_AFTER_MS, BACKFILL_FIRST_RETRY_MS, BACKFILL_MAX_RETRY_MS, BACKFILL_MAX_FAILURES, BACKFILL_ALTERNATE_WAIT_MS, SessionRuntimeTerminalReplicaOwner;
|
|
65319
65760
|
var init_terminal_replica_owner = __esm({
|
|
65320
65761
|
"packages/daemon/src/terminal/session-runtime/terminal-replica-owner.ts"() {
|
|
65321
65762
|
"use strict";
|
|
65763
|
+
init_pane_hold();
|
|
65322
65764
|
init_history_anchor_owner();
|
|
65323
65765
|
init_layout_content_rows();
|
|
65766
|
+
init_native_grid_capture();
|
|
65324
65767
|
init_src3();
|
|
65325
65768
|
init_native_grid_projection();
|
|
65326
65769
|
init_terminal_replica_interpreter();
|
|
65327
65770
|
init_runtime_scheduler();
|
|
65328
65771
|
init_runtime_observability();
|
|
65329
65772
|
PARK_AFTER_MS = 1e4;
|
|
65773
|
+
BACKFILL_FIRST_RETRY_MS = 250;
|
|
65774
|
+
BACKFILL_MAX_RETRY_MS = 4e3;
|
|
65775
|
+
BACKFILL_MAX_FAILURES = 16;
|
|
65776
|
+
BACKFILL_ALTERNATE_WAIT_MS = 1e3;
|
|
65330
65777
|
SessionRuntimeTerminalReplicaOwner = class {
|
|
65331
65778
|
constructor(generation, session, semanticPaneId3, mirror, options) {
|
|
65332
65779
|
this.generation = generation;
|
|
@@ -65347,10 +65794,12 @@ var init_terminal_replica_owner = __esm({
|
|
|
65347
65794
|
rows: this.#rows,
|
|
65348
65795
|
scheduler: options.scheduler,
|
|
65349
65796
|
observability: options.observability,
|
|
65797
|
+
...options.historyRowCap !== void 0 ? { historyRowCap: options.historyRowCap } : {},
|
|
65350
65798
|
onNativeReseedRequired: () => {
|
|
65351
65799
|
if (this.#disposed || this.#reseed || this.#waitingForGeometryCapture) return;
|
|
65352
65800
|
this.#waitingForGeometryCapture = true;
|
|
65353
65801
|
this.#historyAnchors.invalidate();
|
|
65802
|
+
this.#cancelBackfill();
|
|
65354
65803
|
this.#supervise(
|
|
65355
65804
|
this.#start.then(() => {
|
|
65356
65805
|
if (!this.#disposed && this.#waitingForGeometryCapture) this.#upstream?.reseed();
|
|
@@ -65441,6 +65890,14 @@ var init_terminal_replica_owner = __esm({
|
|
|
65441
65890
|
#historyChecking = false;
|
|
65442
65891
|
#historyDirty = false;
|
|
65443
65892
|
#reconstructedHistoryGap = null;
|
|
65893
|
+
// #873 backfill. A new seed, resize, park or disposal starts a new token;
|
|
65894
|
+
// anything from an older token is ignored.
|
|
65895
|
+
#backfillToken = 0;
|
|
65896
|
+
// The token of each history request sent and not yet answered, oldest first.
|
|
65897
|
+
// Answers arrive in request order, so each one belongs to the first entry.
|
|
65898
|
+
#backfillAsked = [];
|
|
65899
|
+
#backfillFailures = 0;
|
|
65900
|
+
#backfillTimer = null;
|
|
65444
65901
|
installOutputTraceReader(reader) {
|
|
65445
65902
|
this.#takeOutputTrace ??= reader;
|
|
65446
65903
|
}
|
|
@@ -65498,6 +65955,7 @@ var init_terminal_replica_owner = __esm({
|
|
|
65498
65955
|
const initial = this.#interpreter.currentSeed();
|
|
65499
65956
|
if (!initial || this.#stale || this.#reseed || this.#waitingForGeometryCapture)
|
|
65500
65957
|
return { status: "changed" };
|
|
65958
|
+
if (this.#interpreter.omittedHistory() > 0) return { status: "mismatch" };
|
|
65501
65959
|
const epoch = this.#subscriptionEpoch;
|
|
65502
65960
|
const captured = await upstream.captureNativeBacking();
|
|
65503
65961
|
if (captured.status !== "captured") return captured;
|
|
@@ -65584,6 +66042,7 @@ var init_terminal_replica_owner = __esm({
|
|
|
65584
66042
|
if (this.#disposed || this.#parked || this.#listeners.size > 0 || !this.#upstream) return;
|
|
65585
66043
|
this.#parked = true;
|
|
65586
66044
|
this.#stale = true;
|
|
66045
|
+
this.#cancelBackfill();
|
|
65587
66046
|
this.#upstream.freeze();
|
|
65588
66047
|
}, PARK_AFTER_MS);
|
|
65589
66048
|
}
|
|
@@ -65635,6 +66094,7 @@ var init_terminal_replica_owner = __esm({
|
|
|
65635
66094
|
this.#historyTimer = null;
|
|
65636
66095
|
this.#parkTimer?.cancel();
|
|
65637
66096
|
this.#parkTimer = null;
|
|
66097
|
+
this.#cancelBackfill();
|
|
65638
66098
|
this.#subscriptionEpoch += 1;
|
|
65639
66099
|
await this.#interpreter.enqueue({ type: "close", reason });
|
|
65640
66100
|
await this.#start.catch(() => void 0);
|
|
@@ -65675,7 +66135,7 @@ var init_terminal_replica_owner = __esm({
|
|
|
65675
66135
|
return;
|
|
65676
66136
|
}
|
|
65677
66137
|
if (this.#reconstructedHistoryGap.gap === gap) return;
|
|
65678
|
-
} else if (gap ===
|
|
66138
|
+
} else if (gap === this.#interpreter.omittedHistory()) return;
|
|
65679
66139
|
upstream.reseed();
|
|
65680
66140
|
} catch {
|
|
65681
66141
|
} finally {
|
|
@@ -65684,12 +66144,17 @@ var init_terminal_replica_owner = __esm({
|
|
|
65684
66144
|
}
|
|
65685
66145
|
}
|
|
65686
66146
|
#observePane(event) {
|
|
66147
|
+
if (event.type === "history") {
|
|
66148
|
+
this.#observeHistoryPiece(event.piece);
|
|
66149
|
+
return;
|
|
66150
|
+
}
|
|
65687
66151
|
if (event.type === "delta") {
|
|
65688
66152
|
this.#historyDirty = true;
|
|
65689
66153
|
this.#scheduleHistoryCheck();
|
|
65690
66154
|
}
|
|
65691
66155
|
if (event.type === "reset") {
|
|
65692
66156
|
this.#historyAnchors.invalidate();
|
|
66157
|
+
this.#cancelBackfill();
|
|
65693
66158
|
this.#reseed = {
|
|
65694
66159
|
nativeCols: event.cols,
|
|
65695
66160
|
nativeRows: event.rows,
|
|
@@ -65752,7 +66217,7 @@ var init_terminal_replica_owner = __esm({
|
|
|
65752
66217
|
"before-commit",
|
|
65753
66218
|
"lease-crossed"
|
|
65754
66219
|
)
|
|
65755
|
-
}) : reseed ? (this.#retryReseedOrFault(
|
|
66220
|
+
}).then(() => this.#startBackfill()) : reseed ? (this.#retryReseedOrFault(
|
|
65756
66221
|
`terminal reseed geometry is incompatible: capture ${reseed.nativeCols}x${reseed.nativeRows}, layout ${reseed.layoutLease?.pane.width}x${reseed.layoutLease?.pane.height}, border ${reseed.layoutLease?.paneBorderStatus}`,
|
|
65757
66222
|
reseed,
|
|
65758
66223
|
"capture-qualification",
|
|
@@ -65767,7 +66232,7 @@ var init_terminal_replica_owner = __esm({
|
|
|
65767
66232
|
);
|
|
65768
66233
|
} else if (event.type === "fault") {
|
|
65769
66234
|
this.#noteLifecycle("upstream-fault");
|
|
65770
|
-
const error = new Error("Native terminal recovery failed");
|
|
66235
|
+
const error = event.hold ? new MirrorPaneHeldError(event.hold) : new Error("Native terminal recovery failed");
|
|
65771
66236
|
this.#interpreter.abort(error);
|
|
65772
66237
|
this.#onFault?.(error);
|
|
65773
66238
|
} else if (event.type === "closed") {
|
|
@@ -65783,6 +66248,73 @@ var init_terminal_replica_owner = __esm({
|
|
|
65783
66248
|
);
|
|
65784
66249
|
}
|
|
65785
66250
|
}
|
|
66251
|
+
#cancelBackfill() {
|
|
66252
|
+
this.#backfillToken += 1;
|
|
66253
|
+
this.#backfillFailures = 0;
|
|
66254
|
+
this.#backfillTimer?.cancel();
|
|
66255
|
+
this.#backfillTimer = null;
|
|
66256
|
+
}
|
|
66257
|
+
/** After a seed commits: ask for the rows it left out, if any. */
|
|
66258
|
+
#startBackfill() {
|
|
66259
|
+
this.#cancelBackfill();
|
|
66260
|
+
void this.#askForHistory(this.#backfillToken);
|
|
66261
|
+
}
|
|
66262
|
+
async #askForHistory(token2) {
|
|
66263
|
+
await this.#interpreter.whenIdle();
|
|
66264
|
+
if (token2 !== this.#backfillToken || this.#disposed || this.#parked || this.#stale || this.#reseed || this.#waitingForGeometryCapture)
|
|
66265
|
+
return;
|
|
66266
|
+
const omitted = this.#interpreter.omittedHistory();
|
|
66267
|
+
const upstream = this.#upstream;
|
|
66268
|
+
if (omitted <= 0 || !upstream?.requestNativeHistory) return;
|
|
66269
|
+
const snapshot3 = this.#interpreter.currentSnapshot();
|
|
66270
|
+
if (snapshot3.modes.alternateScreen) {
|
|
66271
|
+
this.#retryBackfill(token2, false);
|
|
66272
|
+
return;
|
|
66273
|
+
}
|
|
66274
|
+
const room = this.#interpreter.historyRowCap() - snapshot3.history.length;
|
|
66275
|
+
if (room <= 0) return;
|
|
66276
|
+
const sent = upstream.requestNativeHistory({
|
|
66277
|
+
endRow: omitted,
|
|
66278
|
+
rows: Math.min(room, nativeHistoryPieceRows(snapshot3.cols)),
|
|
66279
|
+
historySize: omitted + snapshot3.history.length
|
|
66280
|
+
});
|
|
66281
|
+
if (sent) this.#backfillAsked.push(token2);
|
|
66282
|
+
else this.#retryBackfill(token2, true);
|
|
66283
|
+
}
|
|
66284
|
+
#observeHistoryPiece(piece) {
|
|
66285
|
+
const token2 = this.#backfillAsked.shift();
|
|
66286
|
+
if (token2 === void 0 || token2 !== this.#backfillToken || this.#disposed) return;
|
|
66287
|
+
if (!piece) {
|
|
66288
|
+
this.#retryBackfill(token2, true);
|
|
66289
|
+
return;
|
|
66290
|
+
}
|
|
66291
|
+
this.#supervise(
|
|
66292
|
+
this.#interpreter.prependNativeHistory(piece).then((applied) => {
|
|
66293
|
+
if (token2 !== this.#backfillToken) return;
|
|
66294
|
+
if (applied) {
|
|
66295
|
+
this.#backfillFailures = 0;
|
|
66296
|
+
void this.#askForHistory(token2);
|
|
66297
|
+
} else this.#retryBackfill(token2, true);
|
|
66298
|
+
})
|
|
66299
|
+
);
|
|
66300
|
+
}
|
|
66301
|
+
#retryBackfill(token2, failed) {
|
|
66302
|
+
if (token2 !== this.#backfillToken || this.#disposed) return;
|
|
66303
|
+
let delay5 = BACKFILL_ALTERNATE_WAIT_MS;
|
|
66304
|
+
if (failed) {
|
|
66305
|
+
this.#backfillFailures += 1;
|
|
66306
|
+
if (this.#backfillFailures >= BACKFILL_MAX_FAILURES) return;
|
|
66307
|
+
delay5 = Math.min(
|
|
66308
|
+
BACKFILL_MAX_RETRY_MS,
|
|
66309
|
+
BACKFILL_FIRST_RETRY_MS * 2 ** (this.#backfillFailures - 1)
|
|
66310
|
+
);
|
|
66311
|
+
}
|
|
66312
|
+
this.#backfillTimer?.cancel();
|
|
66313
|
+
this.#backfillTimer = this.#scheduler.timer(() => {
|
|
66314
|
+
this.#backfillTimer = null;
|
|
66315
|
+
void this.#askForHistory(token2);
|
|
66316
|
+
}, delay5);
|
|
66317
|
+
}
|
|
65786
66318
|
#observeLayout(event) {
|
|
65787
66319
|
const observed = this.#readLayoutLease(event);
|
|
65788
66320
|
if (observed.kind === "irrelevant") return;
|
|
@@ -65801,6 +66333,7 @@ var init_terminal_replica_owner = __esm({
|
|
|
65801
66333
|
this.#rows = nativeRowsForLease(lease);
|
|
65802
66334
|
if (priorCols === this.#cols && priorRows === this.#rows) return;
|
|
65803
66335
|
this.#reseedRetryCount = 0;
|
|
66336
|
+
this.#cancelBackfill();
|
|
65804
66337
|
if (!this.#bootstrapped || this.#reseed || this.#waitingForGeometryCapture) return;
|
|
65805
66338
|
this.#waitingForGeometryCapture = true;
|
|
65806
66339
|
this.#historyAnchors.invalidate();
|
|
@@ -65888,6 +66421,7 @@ var init_terminal_replica_owner = __esm({
|
|
|
65888
66421
|
this.#noteLifecycle("reseed-retry", diagnostic4);
|
|
65889
66422
|
this.#reseedRetryCount += 1;
|
|
65890
66423
|
this.#waitingForGeometryCapture = true;
|
|
66424
|
+
this.#cancelBackfill();
|
|
65891
66425
|
this.#historyAnchors.invalidate();
|
|
65892
66426
|
void this.#start.then(() => {
|
|
65893
66427
|
if (!this.#disposed) this.#upstream?.reseed();
|
|
@@ -74876,7 +75410,8 @@ function projectTrustedMirrorInventory(trusted2, workspaceName, expectedSessionN
|
|
|
74876
75410
|
...pane.nameSource ? { nameSource: nullable2(pane.nameSource) } : {},
|
|
74877
75411
|
type: nullable2(pane.type),
|
|
74878
75412
|
missionStamp: nullable2(pane.missionStamp),
|
|
74879
|
-
dir: boundedWireValue(pane.dir, 4096)
|
|
75413
|
+
dir: boundedWireValue(pane.dir, 4096),
|
|
75414
|
+
...pane.floating === true ? { floating: true } : {}
|
|
74880
75415
|
});
|
|
74881
75416
|
});
|
|
74882
75417
|
if (activeCount !== 1 || panes.some(
|
|
@@ -74904,6 +75439,7 @@ function analyzeInventoryPanes(panes) {
|
|
|
74904
75439
|
interactionEndpoint: _interactionEndpoint,
|
|
74905
75440
|
nativeIdentity: _nativeIdentity,
|
|
74906
75441
|
nativePaneBirthId: _nativePaneBirthId,
|
|
75442
|
+
floating: _floating,
|
|
74907
75443
|
...row
|
|
74908
75444
|
}) => row
|
|
74909
75445
|
)
|
|
@@ -74990,7 +75526,7 @@ function parsePaneSnapshot(stdout, expected) {
|
|
|
74990
75526
|
const links = /* @__PURE__ */ new Map();
|
|
74991
75527
|
for (const line of strictLines2(stdout, MAX_DISCOVERED_PANES)) {
|
|
74992
75528
|
const fields = line.split(WIRE_SEPARATOR);
|
|
74993
|
-
if (fields.length !==
|
|
75529
|
+
if (fields.length !== 22 || fields[21] !== PANE_WIRE_SENTINEL) {
|
|
74994
75530
|
throw new NativeTerminalAttachmentRuntimeError("invalid-tmux-output");
|
|
74995
75531
|
}
|
|
74996
75532
|
const [
|
|
@@ -75013,7 +75549,8 @@ function parsePaneSnapshot(stdout, expected) {
|
|
|
75013
75549
|
dir,
|
|
75014
75550
|
windowStampValue,
|
|
75015
75551
|
windowIndexValue,
|
|
75016
|
-
nativePaneBirthId
|
|
75552
|
+
nativePaneBirthId,
|
|
75553
|
+
floating
|
|
75017
75554
|
] = fields;
|
|
75018
75555
|
if (sessionName !== expected.name || sessionId !== expected.id || !RUNTIME_WINDOW_ID.test(windowId) || !RUNTIME_PANE_ID2.test(runtimePaneId) || !["0", "1"].includes(windowActive) || !["0", "1"].includes(paneActive)) {
|
|
75019
75556
|
throw new NativeTerminalAttachmentRuntimeError("invalid-tmux-output");
|
|
@@ -75041,7 +75578,8 @@ function parsePaneSnapshot(stdout, expected) {
|
|
|
75041
75578
|
// foreground pipeline after its process-group leader exits. The
|
|
75042
75579
|
// registered workspace remains the trusted application-shell root, so
|
|
75043
75580
|
// keep discovery available and carry the empty presentation value.
|
|
75044
|
-
dir: boundedWireValue(dir, 4096)
|
|
75581
|
+
dir: boundedWireValue(dir, 4096),
|
|
75582
|
+
...floating === "1" ? { floating: true } : {}
|
|
75045
75583
|
};
|
|
75046
75584
|
const windowIndex = nonnegativeInteger(windowIndexValue);
|
|
75047
75585
|
const link3 = links.get(windowIndex) ?? {
|
|
@@ -75160,6 +75698,7 @@ async function discoverWorkspaceRegistryTerminalInventory(registry, runner, sign
|
|
|
75160
75698
|
interactionEndpoint: _interactionEndpoint,
|
|
75161
75699
|
nativeIdentity: _nativeIdentity,
|
|
75162
75700
|
nativePaneBirthId: _nativePaneBirthId,
|
|
75701
|
+
floating: _floating,
|
|
75163
75702
|
...row
|
|
75164
75703
|
}) => row
|
|
75165
75704
|
)
|
|
@@ -75280,6 +75819,8 @@ var init_native_runtime = __esm({
|
|
|
75280
75819
|
"#{@tmux_ide_window_id}",
|
|
75281
75820
|
"#{window_index}",
|
|
75282
75821
|
"#{pane_birth_id}",
|
|
75822
|
+
// #882: a floating pane (tmux 3.7+) has no tiled cell; older tmux prints "".
|
|
75823
|
+
"#{pane_floating_flag}",
|
|
75283
75824
|
PANE_WIRE_SENTINEL
|
|
75284
75825
|
].join(WIRE_SEPARATOR);
|
|
75285
75826
|
INVENTORY_FENCE_ATTEMPTS = 4;
|
|
@@ -75430,6 +75971,7 @@ var init_native_runtime = __esm({
|
|
|
75430
75971
|
interactionEndpoint: _interactionEndpoint,
|
|
75431
75972
|
nativeIdentity: _nativeIdentity,
|
|
75432
75973
|
nativePaneBirthId: _nativePaneBirthId,
|
|
75974
|
+
floating: _floating,
|
|
75433
75975
|
...row
|
|
75434
75976
|
}) => row
|
|
75435
75977
|
);
|
|
@@ -75992,6 +76534,7 @@ var init_native_runtime = __esm({
|
|
|
75992
76534
|
interactionEndpoint: _interactionEndpoint,
|
|
75993
76535
|
nativeIdentity: _nativeIdentity,
|
|
75994
76536
|
nativePaneBirthId: _nativePaneBirthId,
|
|
76537
|
+
floating: _floating,
|
|
75995
76538
|
...row
|
|
75996
76539
|
}) => row
|
|
75997
76540
|
);
|
|
@@ -76220,6 +76763,7 @@ var init_native_runtime = __esm({
|
|
|
76220
76763
|
interactionEndpoint: _interactionEndpoint,
|
|
76221
76764
|
nativeIdentity: _nativeIdentity,
|
|
76222
76765
|
nativePaneBirthId: _nativePaneBirthId,
|
|
76766
|
+
floating: _floating,
|
|
76223
76767
|
...row
|
|
76224
76768
|
}) => row
|
|
76225
76769
|
)
|
|
@@ -76853,6 +77397,7 @@ var init_lease_manager2 = __esm({
|
|
|
76853
77397
|
runtimeSessionId: state.runtimeSessionId,
|
|
76854
77398
|
panes: [...state.request.panes],
|
|
76855
77399
|
semanticWindowId: state.request.semanticWindowId ?? null,
|
|
77400
|
+
retryAskedByPerson: state.request.retryAskedByPerson === true,
|
|
76856
77401
|
viewerMode: state.request.viewerMode,
|
|
76857
77402
|
terminalDelivery: state.request.terminalDelivery ?? null,
|
|
76858
77403
|
status: state.status,
|
|
@@ -77167,6 +77712,9 @@ function semanticBackendRefusal(error) {
|
|
|
77167
77712
|
}
|
|
77168
77713
|
return null;
|
|
77169
77714
|
}
|
|
77715
|
+
function tiledPanes(described) {
|
|
77716
|
+
return described.panes.filter((pane) => pane.floating !== true);
|
|
77717
|
+
}
|
|
77170
77718
|
function startsWithBuffer(raw, prefix) {
|
|
77171
77719
|
return raw.length >= prefix.length && raw.compare(prefix, 0, prefix.length, 0, prefix.length) === 0;
|
|
77172
77720
|
}
|
|
@@ -77193,6 +77741,24 @@ function sendControl2(socket, frame) {
|
|
|
77193
77741
|
}
|
|
77194
77742
|
socket.send(encoded, { binary: false });
|
|
77195
77743
|
}
|
|
77744
|
+
function heldOnly(settled) {
|
|
77745
|
+
let retryInMs = 0;
|
|
77746
|
+
let tooLarge = false;
|
|
77747
|
+
for (const result2 of settled) {
|
|
77748
|
+
if (result2.status === "fulfilled") {
|
|
77749
|
+
if (!result2.value.delivery.negotiation.accepted) return null;
|
|
77750
|
+
continue;
|
|
77751
|
+
}
|
|
77752
|
+
const reason = result2.reason;
|
|
77753
|
+
if (!(reason instanceof MirrorPaneHeldError)) return null;
|
|
77754
|
+
retryInMs = Math.max(retryInMs, reason.hold.retryInMs);
|
|
77755
|
+
tooLarge ||= reason.hold.why === "too-large";
|
|
77756
|
+
}
|
|
77757
|
+
return { retryInMs, why: tooLarge ? "too-large" : "failed" };
|
|
77758
|
+
}
|
|
77759
|
+
function errorText(error) {
|
|
77760
|
+
return (error instanceof Error ? error.message : String(error)).slice(0, 300);
|
|
77761
|
+
}
|
|
77196
77762
|
function errorFrameCode(error) {
|
|
77197
77763
|
if (error instanceof PaneStreamLeaseError && error.code === "ticket-expired") {
|
|
77198
77764
|
return "ticket-expired";
|
|
@@ -77268,7 +77834,7 @@ function chunkBytes(data, maxChunk) {
|
|
|
77268
77834
|
}
|
|
77269
77835
|
return chunks;
|
|
77270
77836
|
}
|
|
77271
|
-
var PANE_STREAM_MAX_REDEMPTION_BYTES, PANE_STREAM_MAX_CONTROL_BYTES, PANE_STREAM_DAEMON_SHUTDOWN_CLOSE, PANE_STREAM_OWNER_RETIRED_CLOSE, PANE_STREAM_DAEMON_RESTARTING_CLOSE, PANE_STREAM_MAX_REDEMPTION_MS, WS_OPEN3, CANONICAL_KEY_INPUT_FRAME_PREFIX, CANONICAL_TEXT_INPUT_FRAME_PREFIX, SEMANTIC_BACKEND_REFUSALS, TYPE_FIRST_INPUT_FRAME_PREFIX, TicketPattern3, BindingIdSchemaZ4, PaneStreamAdmissionError, PaneStreamAdmissionCoordinator, PreAuthAdmission2, PANE_STREAM_TOPOLOGY_SETTLE_MS, PANE_STREAM_OPEN_RETRY_DELAYS_MS, PANE_STREAM_OWNERSHIP_WAIT_MS, PANE_STREAM_OWNERSHIP_HELD_FRAMES, GRAPHICS_MAX_QUEUED_DIGESTS, GRAPHICS_SEND_WINDOW_BYTES, PaneStreamLiveConnection;
|
|
77837
|
+
var PANE_STREAM_MAX_REDEMPTION_BYTES, PANE_STREAM_MAX_CONTROL_BYTES, PANE_STREAM_DAEMON_SHUTDOWN_CLOSE, PANE_STREAM_OWNER_RETIRED_CLOSE, PANE_STREAM_DAEMON_RESTARTING_CLOSE, PANE_STREAM_MAX_REDEMPTION_MS, WS_OPEN3, CANONICAL_KEY_INPUT_FRAME_PREFIX, CANONICAL_TEXT_INPUT_FRAME_PREFIX, SEMANTIC_BACKEND_REFUSALS, TYPE_FIRST_INPUT_FRAME_PREFIX, TicketPattern3, BindingIdSchemaZ4, PaneStreamAdmissionError, PaneStreamAdmissionCoordinator, PreAuthAdmission2, PANE_STREAM_TOPOLOGY_SETTLE_MS, PANE_STREAM_OPEN_RETRY_DELAYS_MS, PANE_STREAM_DEFERRED_PANE_RETRY_DELAYS_MS, PANE_STREAM_OWNERSHIP_WAIT_MS, PANE_STREAM_OWNERSHIP_HELD_FRAMES, GRAPHICS_MAX_QUEUED_DIGESTS, GRAPHICS_SEND_WINDOW_BYTES, PaneStreamLiveConnection;
|
|
77272
77838
|
var init_pane_stream_websocket = __esm({
|
|
77273
77839
|
"packages/daemon/src/terminal/pane-stream/pane-stream-websocket.ts"() {
|
|
77274
77840
|
"use strict";
|
|
@@ -77277,6 +77843,7 @@ var init_pane_stream_websocket = __esm({
|
|
|
77277
77843
|
init_compress_chunk();
|
|
77278
77844
|
init_src2();
|
|
77279
77845
|
init_src2();
|
|
77846
|
+
init_pane_hold();
|
|
77280
77847
|
init_src2();
|
|
77281
77848
|
init_log();
|
|
77282
77849
|
init_src2();
|
|
@@ -77334,6 +77901,7 @@ var init_pane_stream_websocket = __esm({
|
|
|
77334
77901
|
#flowBudgets;
|
|
77335
77902
|
#drainTickMs;
|
|
77336
77903
|
#openRetryDelaysMs;
|
|
77904
|
+
#deferredPaneRetryDelaysMs;
|
|
77337
77905
|
#ownershipWaitMs;
|
|
77338
77906
|
#maxSocketBufferedBytes;
|
|
77339
77907
|
#maxInputFrames;
|
|
@@ -77375,6 +77943,7 @@ var init_pane_stream_websocket = __esm({
|
|
|
77375
77943
|
this.#ledger = new PaneStreamWireLedger(this.#flowBudgets);
|
|
77376
77944
|
this.#drainTickMs = boundedInteger2(options.drainTickMs, 15, 1e3);
|
|
77377
77945
|
this.#openRetryDelaysMs = options.openRetryDelaysMs ?? PANE_STREAM_OPEN_RETRY_DELAYS_MS;
|
|
77946
|
+
this.#deferredPaneRetryDelaysMs = options.deferredPaneRetryDelaysMs ?? PANE_STREAM_DEFERRED_PANE_RETRY_DELAYS_MS;
|
|
77378
77947
|
this.#ownershipWaitMs = options.ownershipWaitMs ?? PANE_STREAM_OWNERSHIP_WAIT_MS;
|
|
77379
77948
|
this.#maxSocketBufferedBytes = boundedInteger2(
|
|
77380
77949
|
options.maxSocketBufferedBytes,
|
|
@@ -77447,13 +78016,19 @@ var init_pane_stream_websocket = __esm({
|
|
|
77447
78016
|
this.#observability.nowMicros(),
|
|
77448
78017
|
trace
|
|
77449
78018
|
);
|
|
77450
|
-
} catch {
|
|
78019
|
+
} catch (error) {
|
|
78020
|
+
logger.info("pane-stream", "stream refused", {
|
|
78021
|
+
step: "issue",
|
|
78022
|
+
cause: "describe-session-failed",
|
|
78023
|
+
session: context.sessionName,
|
|
78024
|
+
error: errorText(error)
|
|
78025
|
+
});
|
|
77451
78026
|
throw new PaneStreamAdmissionError(
|
|
77452
78027
|
"stream-unavailable",
|
|
77453
78028
|
"The workspace session could not be described."
|
|
77454
78029
|
);
|
|
77455
78030
|
}
|
|
77456
|
-
const known = new Set(described.
|
|
78031
|
+
const known = new Set(tiledPanes(described).map((pane) => pane.semanticPaneId));
|
|
77457
78032
|
for (const pane of request3.panes) {
|
|
77458
78033
|
if (!known.has(pane)) {
|
|
77459
78034
|
throw new PaneStreamAdmissionError(
|
|
@@ -77464,7 +78039,7 @@ var init_pane_stream_websocket = __esm({
|
|
|
77464
78039
|
}
|
|
77465
78040
|
if (request3.semanticWindowId !== void 0) {
|
|
77466
78041
|
const windowPanes = new Set(
|
|
77467
|
-
described.
|
|
78042
|
+
tiledPanes(described).filter((pane) => pane.semanticWindowId === request3.semanticWindowId).map((pane) => pane.semanticPaneId)
|
|
77468
78043
|
);
|
|
77469
78044
|
if (windowPanes.size !== request3.panes.length || request3.panes.some((pane) => !windowPanes.has(pane)))
|
|
77470
78045
|
throw new PaneStreamAdmissionError(
|
|
@@ -77711,6 +78286,7 @@ var init_pane_stream_websocket = __esm({
|
|
|
77711
78286
|
ledger: this.#ledger,
|
|
77712
78287
|
drainTickMs: this.#drainTickMs,
|
|
77713
78288
|
openRetryDelaysMs: this.#openRetryDelaysMs,
|
|
78289
|
+
deferredPaneRetryDelaysMs: this.#deferredPaneRetryDelaysMs,
|
|
77714
78290
|
ownershipWaitMs: this.#ownershipWaitMs,
|
|
77715
78291
|
maxSocketBufferedBytes: this.#maxSocketBufferedBytes,
|
|
77716
78292
|
maxInputFrames: this.#maxInputFrames,
|
|
@@ -77866,6 +78442,11 @@ var init_pane_stream_websocket = __esm({
|
|
|
77866
78442
|
void this.#onRedeem(this, frame, socket).catch((error) => {
|
|
77867
78443
|
if (!this.#open) return;
|
|
77868
78444
|
const code2 = errorFrameCode(error);
|
|
78445
|
+
logger.info("pane-stream", "stream refused", {
|
|
78446
|
+
step: "redeem",
|
|
78447
|
+
code: code2,
|
|
78448
|
+
error: errorText(error)
|
|
78449
|
+
});
|
|
77869
78450
|
try {
|
|
77870
78451
|
sendControl2(socket, {
|
|
77871
78452
|
type: "error",
|
|
@@ -77890,6 +78471,7 @@ var init_pane_stream_websocket = __esm({
|
|
|
77890
78471
|
};
|
|
77891
78472
|
PANE_STREAM_TOPOLOGY_SETTLE_MS = 500;
|
|
77892
78473
|
PANE_STREAM_OPEN_RETRY_DELAYS_MS = [150, 400];
|
|
78474
|
+
PANE_STREAM_DEFERRED_PANE_RETRY_DELAYS_MS = [1e3, 2e3, 4e3];
|
|
77893
78475
|
PANE_STREAM_OWNERSHIP_WAIT_MS = 2e3;
|
|
77894
78476
|
PANE_STREAM_OWNERSHIP_HELD_FRAMES = 256;
|
|
77895
78477
|
GRAPHICS_MAX_QUEUED_DIGESTS = 256;
|
|
@@ -77917,6 +78499,9 @@ var init_pane_stream_websocket = __esm({
|
|
|
77917
78499
|
#ledger;
|
|
77918
78500
|
#drainTickMs;
|
|
77919
78501
|
#openRetryDelaysMs;
|
|
78502
|
+
/** Waits of `#deferPane`; a close ends them at once (#585). */
|
|
78503
|
+
#deferralWaits = /* @__PURE__ */ new Set();
|
|
78504
|
+
#deferredPaneRetryDelaysMs;
|
|
77920
78505
|
#ownershipWaitMs;
|
|
77921
78506
|
#maxSocketBufferedBytes;
|
|
77922
78507
|
#maxInputFrames;
|
|
@@ -78029,6 +78614,7 @@ var init_pane_stream_websocket = __esm({
|
|
|
78029
78614
|
this.#ledger = options.ledger;
|
|
78030
78615
|
this.#drainTickMs = options.drainTickMs;
|
|
78031
78616
|
this.#openRetryDelaysMs = options.openRetryDelaysMs;
|
|
78617
|
+
this.#deferredPaneRetryDelaysMs = options.deferredPaneRetryDelaysMs;
|
|
78032
78618
|
this.#ownershipWaitMs = options.ownershipWaitMs ?? PANE_STREAM_OWNERSHIP_WAIT_MS;
|
|
78033
78619
|
this.#maxSocketBufferedBytes = options.maxSocketBufferedBytes;
|
|
78034
78620
|
this.#maxInputFrames = options.maxInputFrames;
|
|
@@ -78096,14 +78682,25 @@ var init_pane_stream_websocket = __esm({
|
|
|
78096
78682
|
* none of them. The log says which one, with the error text, so a stream
|
|
78097
78683
|
* that "just closed" can be traced without a reproduction.
|
|
78098
78684
|
*/
|
|
78099
|
-
#fail(cause, error) {
|
|
78685
|
+
#fail(cause, error, pane) {
|
|
78100
78686
|
if (this.#closed) return;
|
|
78101
78687
|
this.#closeCause = {
|
|
78102
78688
|
cause,
|
|
78689
|
+
...pane === void 0 ? {} : { pane },
|
|
78103
78690
|
...error === void 0 ? {} : { error: (error instanceof Error ? error.message : String(error)).slice(0, 300) }
|
|
78104
78691
|
};
|
|
78105
78692
|
this.close(1011, "stream-unavailable");
|
|
78106
78693
|
}
|
|
78694
|
+
/**
|
|
78695
|
+
* #872: every pane that did not open is held back after failed recoveries.
|
|
78696
|
+
* "Try again later", with the time left and why, so a client can say so
|
|
78697
|
+
* instead of counting attempts. The client reconnects as for any close.
|
|
78698
|
+
*/
|
|
78699
|
+
#closeHeld(hold, pane) {
|
|
78700
|
+
if (this.#closed) return;
|
|
78701
|
+
this.#closeCause = { cause: "pane-held", ...pane === void 0 ? {} : { pane } };
|
|
78702
|
+
this.close(PANE_STREAM_PANE_HELD_CLOSE_CODE, paneHeldCloseReason(hold));
|
|
78703
|
+
}
|
|
78107
78704
|
close(code2 = 1e3, reason = "stream-closed") {
|
|
78108
78705
|
if (this.#closed) return;
|
|
78109
78706
|
this.#recordDiagnosticLifecycle("pane-stream-terminal", code2, reason);
|
|
@@ -78120,6 +78717,11 @@ var init_pane_stream_websocket = __esm({
|
|
|
78120
78717
|
...this.#inputLifetimeEndedDropped > 0 ? { droppedEndedLifetimeInputs: this.#inputLifetimeEndedDropped } : {}
|
|
78121
78718
|
});
|
|
78122
78719
|
this.#closed = true;
|
|
78720
|
+
for (const { timer, wake } of this.#deferralWaits) {
|
|
78721
|
+
clearTimeout(timer);
|
|
78722
|
+
wake();
|
|
78723
|
+
}
|
|
78724
|
+
this.#deferralWaits.clear();
|
|
78123
78725
|
this.#ownershipHeld.length = 0;
|
|
78124
78726
|
this.#ownershipWake?.();
|
|
78125
78727
|
for (const demand of this.#surfaceDemands.values()) demand.close();
|
|
@@ -78190,7 +78792,7 @@ var init_pane_stream_websocket = __esm({
|
|
|
78190
78792
|
return;
|
|
78191
78793
|
}
|
|
78192
78794
|
if (this.#closed) return;
|
|
78193
|
-
const known = new Set(described.
|
|
78795
|
+
const known = new Set(tiledPanes(described).map((pane) => pane.semanticPaneId));
|
|
78194
78796
|
if (this.#descriptor.terminalDelivery) {
|
|
78195
78797
|
await this.#subscribeSemantic(known);
|
|
78196
78798
|
return;
|
|
@@ -78338,17 +78940,36 @@ var init_pane_stream_websocket = __esm({
|
|
|
78338
78940
|
channels.sort(
|
|
78339
78941
|
(left, right) => Number(visibleAtOpen.has(right.semanticPaneId)) - Number(visibleAtOpen.has(left.semanticPaneId))
|
|
78340
78942
|
);
|
|
78943
|
+
if (this.#descriptor.retryAskedByPerson)
|
|
78944
|
+
this.#mirror.liftRecoveryHolds?.(
|
|
78945
|
+
this.#descriptor.sessionName,
|
|
78946
|
+
channels.map((channel) => channel.semanticPaneId)
|
|
78947
|
+
);
|
|
78341
78948
|
const openings = channels.map((channel) => this.#openPaneDelivery(binding, offer, channel));
|
|
78342
78949
|
const settled = await Promise.allSettled(openings);
|
|
78343
78950
|
const opened = settled.flatMap(
|
|
78344
78951
|
(result2) => result2.status === "fulfilled" ? [result2.value] : []
|
|
78345
78952
|
);
|
|
78346
|
-
|
|
78953
|
+
const deferred = channels.flatMap((channel, index) => {
|
|
78954
|
+
const result2 = settled[index];
|
|
78955
|
+
return result2.status === "rejected" ? [{ channel, error: result2.reason }] : [];
|
|
78956
|
+
});
|
|
78957
|
+
const deferrable = deferred.length > 0 && deferred.length < channels.length && this.#deferredPaneRetryDelaysMs.length > 0 && opened.every(({ delivery }) => delivery.negotiation.accepted) && // A held pane is refused until its hold ends: deferred tries only
|
|
78958
|
+
// repeat the refusal, so it closes at once with its hold (#872).
|
|
78959
|
+
deferred.every(
|
|
78960
|
+
({ error }) => !(error instanceof SessionRuntimeControllerLeaseError) && !(error instanceof MirrorPaneHeldError)
|
|
78961
|
+
);
|
|
78962
|
+
if (this.#closed || !deferrable && settled.some(
|
|
78347
78963
|
(result2) => result2.status === "rejected" || !result2.value.delivery.negotiation.accepted
|
|
78348
78964
|
)) {
|
|
78349
78965
|
await Promise.all(opened.map(({ delivery }) => delivery.close().catch(() => void 0)));
|
|
78350
78966
|
if (!this.#closed) {
|
|
78351
78967
|
const rejected = settled.find((result2) => result2.status === "rejected");
|
|
78968
|
+
const hold = heldOnly(settled);
|
|
78969
|
+
if (hold) {
|
|
78970
|
+
this.#closeHeld(hold);
|
|
78971
|
+
return;
|
|
78972
|
+
}
|
|
78352
78973
|
this.#fail(
|
|
78353
78974
|
"delivery-negotiation-failed",
|
|
78354
78975
|
rejected?.status === "rejected" ? rejected.reason : "a pane's delivery offer was refused"
|
|
@@ -78399,14 +79020,75 @@ var init_pane_stream_websocket = __esm({
|
|
|
78399
79020
|
(left, right) => Number(visibleAtDelivery.has(right.channel.semanticPaneId)) - Number(visibleAtDelivery.has(left.channel.semanticPaneId))
|
|
78400
79021
|
);
|
|
78401
79022
|
await this.#publishOpenedDeliveries(opened);
|
|
79023
|
+
if (deferrable)
|
|
79024
|
+
for (const { channel, error } of deferred)
|
|
79025
|
+
void this.#deferPane(binding, offer, channel, error);
|
|
78402
79026
|
this.#closeIfAllPanesGone();
|
|
78403
79027
|
}
|
|
79028
|
+
/**
|
|
79029
|
+
* A pane left out of the opening (#585): try its delivery again after each
|
|
79030
|
+
* deferred delay and announce it like a pane added in place. Only when
|
|
79031
|
+
* every try failed does the stream close, naming the pane.
|
|
79032
|
+
*/
|
|
79033
|
+
async #deferPane(binding, offer, channel, firstError) {
|
|
79034
|
+
const gone = () => this.#closed || channel.closed || this.#panes.get(channel.semanticPaneId) !== channel;
|
|
79035
|
+
let error = firstError;
|
|
79036
|
+
for (const [index, delayMs] of this.#deferredPaneRetryDelaysMs.entries()) {
|
|
79037
|
+
if (gone()) return;
|
|
79038
|
+
logger.info("pane-stream", "pane delivery deferred", {
|
|
79039
|
+
session: this.#descriptor.sessionName,
|
|
79040
|
+
clientId: this.#clientId,
|
|
79041
|
+
pane: channel.semanticPaneId,
|
|
79042
|
+
attempt: index + 1,
|
|
79043
|
+
error: errorText(error)
|
|
79044
|
+
});
|
|
79045
|
+
await new Promise((resolve47) => {
|
|
79046
|
+
const wait = {
|
|
79047
|
+
timer: setTimeout(() => {
|
|
79048
|
+
this.#deferralWaits.delete(wait);
|
|
79049
|
+
resolve47();
|
|
79050
|
+
}, delayMs),
|
|
79051
|
+
wake: resolve47
|
|
79052
|
+
};
|
|
79053
|
+
wait.timer.unref?.();
|
|
79054
|
+
this.#deferralWaits.add(wait);
|
|
79055
|
+
});
|
|
79056
|
+
if (gone()) return;
|
|
79057
|
+
let entry;
|
|
79058
|
+
try {
|
|
79059
|
+
entry = await this.#openPaneDelivery(binding, offer, channel, false);
|
|
79060
|
+
} catch (cause) {
|
|
79061
|
+
if (cause instanceof SessionRuntimeControllerLeaseError) {
|
|
79062
|
+
this.#fail("pane-delivery-open-failed", cause, channel.semanticPaneId);
|
|
79063
|
+
return;
|
|
79064
|
+
}
|
|
79065
|
+
if (cause instanceof MirrorPaneHeldError) {
|
|
79066
|
+
if (!gone()) this.#closeHeld(cause.hold, channel.semanticPaneId);
|
|
79067
|
+
return;
|
|
79068
|
+
}
|
|
79069
|
+
error = cause;
|
|
79070
|
+
continue;
|
|
79071
|
+
}
|
|
79072
|
+
if (gone()) {
|
|
79073
|
+
await entry.delivery.close().catch(() => void 0);
|
|
79074
|
+
return;
|
|
79075
|
+
}
|
|
79076
|
+
if (!entry.delivery.negotiation.accepted || this.#deliveryIdentityChanged(entry)) {
|
|
79077
|
+
await entry.delivery.close().catch(() => void 0);
|
|
79078
|
+
this.#failTopologyChanged();
|
|
79079
|
+
return;
|
|
79080
|
+
}
|
|
79081
|
+
await this.#publishOpenedDeliveries([entry]);
|
|
79082
|
+
return;
|
|
79083
|
+
}
|
|
79084
|
+
if (!gone()) this.#fail("pane-delivery-open-failed", error, channel.semanticPaneId);
|
|
79085
|
+
}
|
|
78404
79086
|
/** Open one pane's delivery; its messages wait until the pane is announced. */
|
|
78405
|
-
async #openPaneDelivery(binding, offer, channel) {
|
|
79087
|
+
async #openPaneDelivery(binding, offer, channel, retry = true) {
|
|
78406
79088
|
const pending = [];
|
|
78407
79089
|
let ready = false;
|
|
78408
79090
|
let negotiated = false;
|
|
78409
|
-
const
|
|
79091
|
+
const open5 = () => {
|
|
78410
79092
|
pending.length = 0;
|
|
78411
79093
|
return binding.openTerminalDelivery(
|
|
78412
79094
|
channel.semanticPaneId,
|
|
@@ -78418,7 +79100,12 @@ var init_pane_stream_websocket = __esm({
|
|
|
78418
79100
|
},
|
|
78419
79101
|
this.#descriptor.workspaceName
|
|
78420
79102
|
);
|
|
78421
|
-
}
|
|
79103
|
+
};
|
|
79104
|
+
const delivery = retry ? await this.#retryOpenStep(
|
|
79105
|
+
"pane-delivery-open",
|
|
79106
|
+
open5,
|
|
79107
|
+
(error) => error instanceof MirrorPaneHeldError
|
|
79108
|
+
) : await open5();
|
|
78422
79109
|
return {
|
|
78423
79110
|
channel,
|
|
78424
79111
|
delivery,
|
|
@@ -79127,7 +79814,7 @@ var init_pane_stream_websocket = __esm({
|
|
|
79127
79814
|
return this.#topologyFailed("session inventory unavailable", error);
|
|
79128
79815
|
}
|
|
79129
79816
|
if (this.#closed) return this.#topologyFailed("closed");
|
|
79130
|
-
const next = [...new Set(described.
|
|
79817
|
+
const next = [...new Set(tiledPanes(described).map((pane) => pane.semanticPaneId))].sort();
|
|
79131
79818
|
if (next.length === 0) return this.#topologyFailed("session has no panes");
|
|
79132
79819
|
const frames = this.#validateInitialLayout(snapshot3.layouts, next);
|
|
79133
79820
|
if (!frames) return "stale";
|
|
@@ -79143,7 +79830,7 @@ var init_pane_stream_websocket = __esm({
|
|
|
79143
79830
|
if (window2 !== null) {
|
|
79144
79831
|
windowPanes = [
|
|
79145
79832
|
...new Set(
|
|
79146
|
-
described.
|
|
79833
|
+
tiledPanes(described).filter((pane) => pane.semanticWindowId === window2).map((pane) => pane.semanticPaneId)
|
|
79147
79834
|
)
|
|
79148
79835
|
].sort();
|
|
79149
79836
|
if (windowPanes.length === 0) return this.#topologyFailed("the stream's window is gone");
|
|
@@ -93232,8 +93919,16 @@ var init_tmux_server_attach = __esm({
|
|
|
93232
93919
|
});
|
|
93233
93920
|
|
|
93234
93921
|
// packages/daemon/src/command-center/resources/terminal-runtime-inventory.ts
|
|
93922
|
+
function floatingPaneIds(session) {
|
|
93923
|
+
return new Set(
|
|
93924
|
+
session.panes.flatMap(
|
|
93925
|
+
(pane) => pane.floating === true && pane.semanticPaneId !== null ? [pane.semanticPaneId] : []
|
|
93926
|
+
)
|
|
93927
|
+
);
|
|
93928
|
+
}
|
|
93235
93929
|
function projectTerminalRuntimeInventory(session, resourceRevision) {
|
|
93236
93930
|
const shell = projectApplicationShellResource(session);
|
|
93931
|
+
const floating = floatingPaneIds(session);
|
|
93237
93932
|
return TerminalRuntimeInventoryProjectionV1SchemaZ.parse({
|
|
93238
93933
|
workspaceName: session.workspaceName,
|
|
93239
93934
|
workspaceId: shell.workspace.id,
|
|
@@ -93242,7 +93937,7 @@ function projectTerminalRuntimeInventory(session, resourceRevision) {
|
|
|
93242
93937
|
semanticPaneIds: [
|
|
93243
93938
|
...new Set(
|
|
93244
93939
|
shell.terminalInventory.resources.flatMap(
|
|
93245
|
-
(resource3) => resource3.attachability.status === "available" ? [resource3.attachability.semanticPaneId] : []
|
|
93940
|
+
(resource3) => resource3.attachability.status === "available" && !floating.has(resource3.attachability.semanticPaneId) ? [resource3.attachability.semanticPaneId] : []
|
|
93246
93941
|
)
|
|
93247
93942
|
)
|
|
93248
93943
|
].sort()
|
|
@@ -93261,10 +93956,11 @@ function projectTerminalRuntimeInventoryV2(session, resourceRevision) {
|
|
|
93261
93956
|
complete: true
|
|
93262
93957
|
};
|
|
93263
93958
|
windows.set(pane.windowId, entry);
|
|
93959
|
+
if (pane.active) entry.active = true;
|
|
93960
|
+
if (pane.floating === true) return;
|
|
93264
93961
|
const attachability = identities[index].attachability;
|
|
93265
93962
|
if (attachability.status === "available") entry.panes.push(attachability.semanticPaneId);
|
|
93266
93963
|
else entry.complete = false;
|
|
93267
|
-
if (pane.active) entry.active = true;
|
|
93268
93964
|
});
|
|
93269
93965
|
return TerminalRuntimeInventoryProjectionV2SchemaZ.parse({
|
|
93270
93966
|
...projectTerminalRuntimeInventory(session, resourceRevision),
|
|
@@ -93781,7 +94477,10 @@ function mountTmuxServerRoutes(app, options) {
|
|
|
93781
94477
|
() => void 0,
|
|
93782
94478
|
{
|
|
93783
94479
|
expectedRuntimeSessionId: identity4.runtimeSessionId,
|
|
93784
|
-
|
|
94480
|
+
// #882: a floating pane has no tiled cell; the layout fence leaves it out.
|
|
94481
|
+
expectedSemanticPaneIds: identity4.description.panes.flatMap(
|
|
94482
|
+
(pane) => pane.floating === true ? [] : [pane.semanticPaneId]
|
|
94483
|
+
),
|
|
93785
94484
|
onAuthority(snapshot3) {
|
|
93786
94485
|
if (snapshot3.windowLinks.liveSessionId !== c.req.query("liveSessionId")) {
|
|
93787
94486
|
sessionReplaced = true;
|