tmux-ide 2.9.22 → 2.9.24
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 +3718 -7603
- package/package.json +3 -3
- package/packages/contracts/src/index.ts +1 -0
- package/packages/contracts/src/websocket-heartbeat.ts +41 -0
- package/packages/daemon/dist/command-center/automation.js +1 -1
- package/packages/daemon/dist/command-center/daemon-fleet-facts-observer.js +37 -5
- package/packages/daemon/dist/command-center/discovery.js +28 -2
- package/packages/daemon/dist/command-center/server.js +8 -2
- package/packages/daemon/dist/command-center/tmux-servers.js +12 -1
- package/packages/daemon/dist/doctor.js +41 -0
- package/packages/daemon/dist/lib/bounded-tmux-read.js +34 -12
- package/packages/daemon/dist/lib/daemon-embed.js +127 -63
- package/packages/daemon/dist/lib/daemon-stop-progress.js +58 -0
- package/packages/daemon/dist/lib/embedded-daemon-lifecycle.js +11 -0
- package/packages/daemon/dist/lib/embedded-tmux-server-owners.js +88 -12
- package/packages/daemon/dist/lib/headless-daemon.js +177 -10
- package/packages/daemon/dist/lib/home-agent-observer.js +50 -0
- package/packages/daemon/dist/lib/log.js +18 -1
- package/packages/daemon/dist/lib/machine-agents.js +18 -1
- package/packages/daemon/dist/lib/orphaned-control-clients.js +162 -0
- package/packages/daemon/dist/lib/tmux-external-interaction-observer.js +172 -28
- package/packages/daemon/dist/lib/tmux-native-browser.js +4 -2
- package/packages/daemon/dist/lib/tmux-pane-reader.js +4 -2
- package/packages/daemon/dist/lib/tmux-server-agent-admission.js +6 -1
- package/packages/daemon/dist/lib/tmux-server-owner-teardown.js +33 -0
- package/packages/daemon/dist/lib/tmux-server-owner.js +55 -41
- package/packages/daemon/dist/lib/tmux-server-owners.js +310 -20
- package/packages/daemon/dist/lib/tmux-server-registration.js +128 -9
- package/packages/daemon/dist/lib/unix-socket-authority.js +58 -3
- package/packages/daemon/dist/lib/workspace-pane-creation.js +10 -1
- package/packages/daemon/dist/lib/workspace-promotion.js +24 -3
- package/packages/daemon/dist/native/TmuxIdeNotifier.app/Contents/Info.plist +2 -2
- package/packages/daemon/dist/native/TmuxIdeNotifier.app/Contents/MacOS/tmux-ide-notifier +0 -0
- package/packages/daemon/dist/native/TmuxIdeNotifier.app/Contents/Resources/Assets.car +0 -0
- package/packages/daemon/dist/native/TmuxIdeNotifier.app/Contents/_CodeSignature/CodeResources +2 -2
- package/packages/daemon/dist/plugins/cli.js +1 -2
- package/packages/daemon/dist/server/pane-stream-upgrade.js +5 -1
- package/packages/daemon/dist/server/websocket-heartbeat.js +103 -0
- package/packages/daemon/dist/terminal/attachments/native-runtime.js +49 -16
- package/packages/daemon/dist/terminal/mirror/layout-content-rows.js +11 -0
- package/packages/daemon/dist/terminal/mirror/mirror-service.js +61 -3
- package/packages/daemon/dist/terminal/mirror/session-channel.js +11 -12
- package/packages/daemon/dist/terminal/pane-stream/pane-stream-websocket.js +119 -22
- package/packages/daemon/dist/terminal/pane-stream/runtime.js +3 -2
- package/packages/daemon/dist/terminal/protocol/session-descriptor-discovery.js +23 -0
- package/packages/daemon/dist/terminal/protocol/stock-split-resize.js +4 -1
- package/packages/daemon/dist/terminal/session-runtime/registry.js +17 -0
- package/packages/daemon/dist/terminal/session-runtime/terminal-replica-interpreter.js +81 -3
- package/packages/daemon/dist/terminal/session-runtime/terminal-replica-owner.js +60 -3
- package/packages/daemon/dist/tui/mirror/runtime/application-home-agent-navigation.js +57 -4
- package/packages/daemon/dist/tui/mirror/runtime/application-home-agents-owner.js +18 -7
- package/packages/daemon/dist/tui/mirror/runtime/application-machine-agent-navigation.js +17 -0
- package/packages/daemon/dist/tui/mirror/runtime/application-machine-navigation.js +4 -2
- package/packages/daemon/dist/tui/mirror/runtime/application-terminal-interaction-controller.js +55 -14
- package/packages/daemon/src/command-center/automation.ts +1 -1
- package/packages/daemon/src/command-center/daemon-fleet-facts-observer.ts +49 -8
- package/packages/daemon/src/command-center/discovery.ts +35 -2
- package/packages/daemon/src/command-center/server.ts +22 -8
- package/packages/daemon/src/command-center/tmux-servers.ts +12 -1
- package/packages/daemon/src/doctor.ts +46 -0
- package/packages/daemon/src/lib/bounded-tmux-read.ts +29 -9
- package/packages/daemon/src/lib/daemon-embed.ts +211 -71
- package/packages/daemon/src/lib/daemon-stop-progress.ts +78 -0
- package/packages/daemon/src/lib/embedded-daemon-lifecycle.ts +12 -0
- package/packages/daemon/src/lib/embedded-tmux-server-owners.ts +115 -11
- package/packages/daemon/src/lib/headless-daemon.ts +205 -12
- package/packages/daemon/src/lib/home-agent-observer.ts +53 -0
- package/packages/daemon/src/lib/log.ts +18 -1
- package/packages/daemon/src/lib/machine-agents.ts +25 -1
- package/packages/daemon/src/lib/orphaned-control-clients.ts +215 -0
- package/packages/daemon/src/lib/tmux-external-interaction-observer.ts +195 -33
- package/packages/daemon/src/lib/tmux-native-browser.ts +4 -3
- package/packages/daemon/src/lib/tmux-pane-reader.ts +4 -3
- package/packages/daemon/src/lib/tmux-server-agent-admission.ts +6 -1
- package/packages/daemon/src/lib/tmux-server-owner-teardown.ts +54 -0
- package/packages/daemon/src/lib/tmux-server-owner.ts +60 -38
- package/packages/daemon/src/lib/tmux-server-owners.ts +427 -22
- package/packages/daemon/src/lib/tmux-server-registration.ts +155 -7
- package/packages/daemon/src/lib/unix-socket-authority.ts +72 -3
- package/packages/daemon/src/lib/workspace-pane-creation.ts +11 -1
- package/packages/daemon/src/lib/workspace-promotion.ts +26 -3
- package/packages/daemon/src/plugins/cli.ts +1 -2
- package/packages/daemon/src/server/pane-stream-upgrade.ts +6 -0
- package/packages/daemon/src/server/websocket-heartbeat.ts +135 -0
- package/packages/daemon/src/terminal/attachments/native-runtime.ts +79 -16
- package/packages/daemon/src/terminal/mirror/layout-content-rows.ts +11 -0
- package/packages/daemon/src/terminal/mirror/mirror-service.ts +61 -2
- package/packages/daemon/src/terminal/mirror/session-channel.ts +11 -14
- package/packages/daemon/src/terminal/pane-stream/pane-stream-websocket.ts +133 -21
- package/packages/daemon/src/terminal/pane-stream/runtime.ts +4 -2
- package/packages/daemon/src/terminal/protocol/session-descriptor-discovery.ts +31 -0
- package/packages/daemon/src/terminal/protocol/stock-split-resize.ts +6 -1
- package/packages/daemon/src/terminal/session-runtime/registry.ts +23 -0
- package/packages/daemon/src/terminal/session-runtime/runtime-observability.ts +2 -0
- package/packages/daemon/src/terminal/session-runtime/terminal-replica-interpreter.ts +100 -3
- package/packages/daemon/src/terminal/session-runtime/terminal-replica-owner.ts +60 -3
- package/packages/daemon/src/tui/mirror/runtime/application-home-agent-navigation.ts +69 -4
- package/packages/daemon/src/tui/mirror/runtime/application-home-agents-owner.ts +30 -13
- package/packages/daemon/src/tui/mirror/runtime/application-machine-agent-navigation.ts +38 -1
- package/packages/daemon/src/tui/mirror/runtime/application-machine-navigation.ts +7 -2
- package/packages/daemon/src/tui/mirror/runtime/application-root-v2.tsx +4 -4
- package/packages/daemon/src/tui/mirror/runtime/application-terminal-interaction-controller.ts +71 -17
- package/packages/daemon-client/src/direct-application-shell-transport.ts +21 -3
- package/packages/daemon-client/src/workspace-event-supervisor.ts +63 -2
|
@@ -34,6 +34,29 @@ export const SESSION_PANE_DESCRIPTOR_FORMAT = [
|
|
|
34
34
|
// The reader option belongs to the pane only when its own process set it.
|
|
35
35
|
"#{pane_pid}",
|
|
36
36
|
].join("\t");
|
|
37
|
+
/**
|
|
38
|
+
* Descriptor fields the program in a pane changes whenever it likes: its
|
|
39
|
+
* command name, the window name tmux derives from it, and its title.
|
|
40
|
+
*/
|
|
41
|
+
const VOLATILE_DESCRIPTOR_FIELDS = new Set([
|
|
42
|
+
4, // pane_current_command
|
|
43
|
+
7, // window_name
|
|
44
|
+
9, // pane_title
|
|
45
|
+
]);
|
|
46
|
+
/**
|
|
47
|
+
* Whether two `list-panes` replies in SESSION_PANE_DESCRIPTOR_FORMAT describe
|
|
48
|
+
* the same panes. A busy pane changes its command and title between any two
|
|
49
|
+
* reads, which is not a pane set that is still changing: those fields are
|
|
50
|
+
* display text, read again on the next refresh (#730).
|
|
51
|
+
*/
|
|
52
|
+
export function sameSessionPaneInventory(before, after) {
|
|
53
|
+
const stable = (line) => line
|
|
54
|
+
.split("\t")
|
|
55
|
+
.map((field, index) => (VOLATILE_DESCRIPTOR_FIELDS.has(index) ? "" : field))
|
|
56
|
+
.join("\t");
|
|
57
|
+
return (before.length === after.length &&
|
|
58
|
+
before.every((line, index) => line === after[index] || stable(line) === stable(after[index])));
|
|
59
|
+
}
|
|
37
60
|
/** Decode the escapes emitted by tmux's `qa` format modifier. */
|
|
38
61
|
export function decodeTmuxArgument(value) {
|
|
39
62
|
const encoded = value.length >= 2 &&
|
|
@@ -119,7 +119,10 @@ export function stockSplitCommand(request, sessionCreated, plan, panes, options,
|
|
|
119
119
|
export const STOCK_SPLIT_OPTIONS_FORMAT = "#{pane-border-status}\t#{pane-scrollbars}\t#{pane-scrollbars-style}";
|
|
120
120
|
export function parseStockSplitOptions(line) {
|
|
121
121
|
const [borderStatus, scrollbars, style] = (line ?? "").split("\t");
|
|
122
|
-
|
|
122
|
+
// The raw value stays: the guarded command compares it with the option. A
|
|
123
|
+
// floating value leaves tiled panes without a status line, like "off".
|
|
124
|
+
if (!/^(off|top|bottom|top-floating|bottom-floating)$/u.test(borderStatus ?? "") ||
|
|
125
|
+
!/^[a-z]+$/u.test(scrollbars ?? ""))
|
|
123
126
|
return null;
|
|
124
127
|
const field = (name) => Number(new RegExp(`\\b${name}=(\\d+)`, "u").exec(style ?? "")?.[1] ?? 0);
|
|
125
128
|
return {
|
|
@@ -71,6 +71,15 @@ export class SessionRuntimeRegistry {
|
|
|
71
71
|
#scheduler;
|
|
72
72
|
#observability;
|
|
73
73
|
#createTraceCorrelator;
|
|
74
|
+
#onInventoryRecovered;
|
|
75
|
+
#announceInventory(session) {
|
|
76
|
+
try {
|
|
77
|
+
this.#onInventoryRecovered?.(session);
|
|
78
|
+
}
|
|
79
|
+
catch {
|
|
80
|
+
// A publication failure never changes qualification.
|
|
81
|
+
}
|
|
82
|
+
}
|
|
74
83
|
#sessions = new Map();
|
|
75
84
|
#listenerDisposal = null;
|
|
76
85
|
#proofPrewarmOwnership = new Map();
|
|
@@ -85,6 +94,7 @@ export class SessionRuntimeRegistry {
|
|
|
85
94
|
this.#observability = options.observability ?? DISABLED_SESSION_RUNTIME_OBSERVABILITY;
|
|
86
95
|
this.#createTraceCorrelator =
|
|
87
96
|
options.createTraceCorrelator ?? ((scheduler) => new RuntimeTraceCorrelator(scheduler));
|
|
97
|
+
this.#onInventoryRecovered = options.onInventoryRecovered ?? null;
|
|
88
98
|
const diagnosticMirrorOptions = {
|
|
89
99
|
onInputAccepted: (session, action, acceptedAtMicros, ok) => {
|
|
90
100
|
for (const traceId of action.traceIds ?? []) {
|
|
@@ -174,6 +184,10 @@ export class SessionRuntimeRegistry {
|
|
|
174
184
|
options.mirror?.onSharedWindowConflict?.(session, conflict);
|
|
175
185
|
if (conflict)
|
|
176
186
|
this.#sessions.get(session)?.invalidateSharedWindowAuthority();
|
|
187
|
+
// A cleared conflict is the trigger an idle client needs: nobody else
|
|
188
|
+
// may read the inventory, and the client's re-read re-qualifies it.
|
|
189
|
+
else if (!this.#mirror.hasSharedWindowConflict(session))
|
|
190
|
+
this.#announceInventory(session);
|
|
177
191
|
},
|
|
178
192
|
onNativeClientActivity: (session) => {
|
|
179
193
|
options.mirror?.onNativeClientActivity?.(session);
|
|
@@ -253,7 +267,10 @@ export class SessionRuntimeRegistry {
|
|
|
253
267
|
}
|
|
254
268
|
signal?.throwIfAborted();
|
|
255
269
|
await abortable(this.#mirror.verifyRegisteredWindows(), signal);
|
|
270
|
+
const wasQualified = runtime.trustedInventoryQualified();
|
|
256
271
|
runtime.qualifyTrustedInventory(runtimeSessionId);
|
|
272
|
+
if (!wasQualified && runtime.trustedInventoryQualified())
|
|
273
|
+
this.#announceInventory(session);
|
|
257
274
|
}
|
|
258
275
|
finally {
|
|
259
276
|
this.#releaseProofPrewarmRuntime(runtime);
|
|
@@ -10,6 +10,31 @@ import { KITTY_PLACEMENT_OSC, KittyApcScanner, KittyImageStore, } from "../graph
|
|
|
10
10
|
// Bound parser work per turn without changing byte-stream semantics. This is a
|
|
11
11
|
// batch bound, not a producer queue cap: upstream pressure must preserve bytes.
|
|
12
12
|
const MAX_INGEST_BATCH_BYTES = 256 * 1024;
|
|
13
|
+
/**
|
|
14
|
+
* Under a flood, publish at most one commit per display interval (daemon perf
|
|
15
|
+
* F1). Each commit projects, diffs and hashes the replica; committing after
|
|
16
|
+
* every parsed chunk kept the daemon off tmux's control pipe, so tmux itself
|
|
17
|
+
* ran about 4× slower while a pane was viewed. Rows that scroll through
|
|
18
|
+
* history between two commits are never projected or hashed. A write with no
|
|
19
|
+
* output queued behind it (a keystroke echo, the end of a burst) still
|
|
20
|
+
* commits at once.
|
|
21
|
+
*/
|
|
22
|
+
export const COALESCED_COMMIT_INTERVAL_MS = 16;
|
|
23
|
+
/**
|
|
24
|
+
* A flood commit costs far more than the display interval (about 35 ms with a
|
|
25
|
+
* full 2,000-row history), so an interval counted from the commit's start
|
|
26
|
+
* alone never skips anything: the next chunk always arrives "late". After a
|
|
27
|
+
* commit the interpreter therefore also reads queued output for this many
|
|
28
|
+
* times the commit's own cost before it commits again, so at most one part in
|
|
29
|
+
* (1 + factor) of a flood goes to commits (half, at 1).
|
|
30
|
+
*/
|
|
31
|
+
export const COALESCED_COMMIT_REST_FACTOR = 1;
|
|
32
|
+
/**
|
|
33
|
+
* Upper bound of that rest. A skipped frame can still wait longer when the
|
|
34
|
+
* queued write behind it opens a synchronized update: then it is published
|
|
35
|
+
* with that update, at its end or by the 250 ms sync recovery.
|
|
36
|
+
*/
|
|
37
|
+
export const COALESCED_COMMIT_MAX_REST_MS = 100;
|
|
13
38
|
/** Daemon-owned, sans-I/O VT interpreter with one FIFO for bytes and geometry. */
|
|
14
39
|
export class TerminalReplicaInterpreter {
|
|
15
40
|
#nativeSeedBackingCandidate;
|
|
@@ -38,6 +63,11 @@ export class TerminalReplicaInterpreter {
|
|
|
38
63
|
#needsSeed = true;
|
|
39
64
|
#closed = false;
|
|
40
65
|
#walkCount = 0;
|
|
66
|
+
#lastCommitAtMs = Number.NEGATIVE_INFINITY;
|
|
67
|
+
#lastCommitEndMs = Number.NEGATIVE_INFINITY;
|
|
68
|
+
#lastCommitCostMs = 0;
|
|
69
|
+
// A coalesced write skipped its commit and counts on a queued write to publish.
|
|
70
|
+
#coalescedCommitOwed = false;
|
|
41
71
|
#pendingWrites = null;
|
|
42
72
|
#widgetGate = false;
|
|
43
73
|
// kitty graphics: images outlive reseeds; the scanner owns split APCs.
|
|
@@ -349,7 +379,7 @@ export class TerminalReplicaInterpreter {
|
|
|
349
379
|
this.#backend.dispose();
|
|
350
380
|
this.#emit(update);
|
|
351
381
|
}
|
|
352
|
-
async #write(data, continuedTrace) {
|
|
382
|
+
async #write(data, continuedTrace, hasBacklog = () => false) {
|
|
353
383
|
if (this.#closed || this.#nativeReseedRequested)
|
|
354
384
|
return;
|
|
355
385
|
// This optional id is only a controlled next-output probe. It is not a
|
|
@@ -370,8 +400,17 @@ export class TerminalReplicaInterpreter {
|
|
|
370
400
|
// see. Skipping it matters: every parser write settles on a later timer
|
|
371
401
|
// turn, so a frame split into dozens of %output chunks would otherwise
|
|
372
402
|
// serialize dozens of turns and fall behind a 30 fps image stream.
|
|
373
|
-
if (scanned.forward.byteLength === 0)
|
|
403
|
+
if (scanned.forward.byteLength === 0) {
|
|
404
|
+
// The queued write a coalesced commit was counting on turned out to be
|
|
405
|
+
// all image payload, and nothing else is queued: publish what it skipped.
|
|
406
|
+
// Not inside a synchronized update: its end, or the sync recovery,
|
|
407
|
+
// publishes the owed commit with the whole frame.
|
|
408
|
+
if (this.#coalescedCommitOwed && !hasBacklog() && !this.#backend.modes().synchronizedOutput) {
|
|
409
|
+
this.#commit(false, this.#pendingWriteDirty ?? undefined, trace);
|
|
410
|
+
this.#publishGraphics();
|
|
411
|
+
}
|
|
374
412
|
return;
|
|
413
|
+
}
|
|
375
414
|
// Scanning can prepend an escape retained from the previous chunk. Bound
|
|
376
415
|
// the actual parser calls too, and union damage across every fragment.
|
|
377
416
|
for (let offset = 0; offset < scanned.forward.length; offset += MAX_INGEST_BATCH_BYTES) {
|
|
@@ -408,6 +447,18 @@ export class TerminalReplicaInterpreter {
|
|
|
408
447
|
this.#commit(false, undefined, trace);
|
|
409
448
|
}
|
|
410
449
|
else {
|
|
450
|
+
// Coalesce under a flood: more output is already queued, the last commit
|
|
451
|
+
// is recent, and nobody is timing this write. The dirty range stays in
|
|
452
|
+
// #pendingWriteDirty and the next commit (the queued write's, or any
|
|
453
|
+
// control operation's) merges it, so nothing is dropped. The bootstrap
|
|
454
|
+
// seed is never held: before it no commit has run, so one is always due.
|
|
455
|
+
if (trace === null &&
|
|
456
|
+
this.#causalCell === null &&
|
|
457
|
+
hasBacklog() &&
|
|
458
|
+
!this.#coalescedCommitIsDue()) {
|
|
459
|
+
this.#coalescedCommitOwed = true;
|
|
460
|
+
return;
|
|
461
|
+
}
|
|
411
462
|
this.#commit(false, this.#backend.dirtyRange(), trace);
|
|
412
463
|
}
|
|
413
464
|
this.#publishGraphics();
|
|
@@ -444,7 +495,26 @@ export class TerminalReplicaInterpreter {
|
|
|
444
495
|
this.#syncRecovery.cancel();
|
|
445
496
|
this.#syncRecovery = null;
|
|
446
497
|
}
|
|
498
|
+
/** True once a queued flood may publish again: see the two constants above. */
|
|
499
|
+
#coalescedCommitIsDue() {
|
|
500
|
+
const now = this.#scheduler.nowMs();
|
|
501
|
+
if (now - this.#lastCommitAtMs < COALESCED_COMMIT_INTERVAL_MS)
|
|
502
|
+
return false;
|
|
503
|
+
const rest = Math.min(COALESCED_COMMIT_MAX_REST_MS, COALESCED_COMMIT_REST_FACTOR * this.#lastCommitCostMs);
|
|
504
|
+
return now - this.#lastCommitEndMs >= rest;
|
|
505
|
+
}
|
|
447
506
|
#commit(forceSeed, dirty, trace = null) {
|
|
507
|
+
this.#lastCommitAtMs = this.#scheduler.nowMs();
|
|
508
|
+
this.#coalescedCommitOwed = false;
|
|
509
|
+
try {
|
|
510
|
+
this.#commitNow(forceSeed, dirty, trace);
|
|
511
|
+
}
|
|
512
|
+
finally {
|
|
513
|
+
this.#lastCommitEndMs = this.#scheduler.nowMs();
|
|
514
|
+
this.#lastCommitCostMs = this.#lastCommitEndMs - this.#lastCommitAtMs;
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
#commitNow(forceSeed, dirty, trace) {
|
|
448
518
|
if (this.#backend.requiresNativeReseed()) {
|
|
449
519
|
if (!this.#nativeReseedRequested) {
|
|
450
520
|
this.#nativeReseedRequested = true;
|
|
@@ -710,7 +780,15 @@ export class TerminalReplicaInterpreter {
|
|
|
710
780
|
group.entries.splice(0, completed.length);
|
|
711
781
|
group.bytes -= length;
|
|
712
782
|
try {
|
|
713
|
-
|
|
783
|
+
// Backlog: bytes still in this group, or a newer untraced group
|
|
784
|
+
// already waiting behind it (a group that has not run yet always
|
|
785
|
+
// holds an entry). A traced group is a boundary: its commit must
|
|
786
|
+
// not carry these external bytes. Checked after parsing, when it
|
|
787
|
+
// is current.
|
|
788
|
+
await this.#write(data, group.trace, () => group.entries.length > 0 ||
|
|
789
|
+
(this.#pendingWrites !== null &&
|
|
790
|
+
this.#pendingWrites !== group &&
|
|
791
|
+
this.#pendingWrites.trace === null));
|
|
714
792
|
}
|
|
715
793
|
catch (error) {
|
|
716
794
|
for (const entry of completed)
|
|
@@ -5,6 +5,11 @@ import { projectNativeGridRow } from "../mirror/native-grid-projection.js";
|
|
|
5
5
|
import { TerminalReplicaInterpreter, } from "./terminal-replica-interpreter.js";
|
|
6
6
|
import { SYSTEM_SESSION_RUNTIME_SCHEDULER, } from "./runtime-scheduler.js";
|
|
7
7
|
import { DISABLED_SESSION_RUNTIME_OBSERVABILITY } from "./runtime-observability.js";
|
|
8
|
+
/**
|
|
9
|
+
* How long a pane may have no listener before it is parked (perf F2). Long
|
|
10
|
+
* enough that switching away and back stays warm.
|
|
11
|
+
*/
|
|
12
|
+
export const PARK_AFTER_MS = 10_000;
|
|
8
13
|
/** One parser/replica owner for one semantic pane inside one SessionRuntime. */
|
|
9
14
|
export class SessionRuntimeTerminalReplicaOwner {
|
|
10
15
|
generation;
|
|
@@ -21,6 +26,11 @@ export class SessionRuntimeTerminalReplicaOwner {
|
|
|
21
26
|
#start;
|
|
22
27
|
#upstream = null;
|
|
23
28
|
#disposed = false;
|
|
29
|
+
#parkTimer = null;
|
|
30
|
+
#parked = false;
|
|
31
|
+
// From the park until the next reseed lands, the replica is older than tmux.
|
|
32
|
+
// Native backing and history anchors must not pair it with current tmux state.
|
|
33
|
+
#stale = false;
|
|
24
34
|
#historyAnchors = new HistoryAnchorOwner();
|
|
25
35
|
#cols = 80;
|
|
26
36
|
#rows = 24;
|
|
@@ -142,12 +152,12 @@ export class SessionRuntimeTerminalReplicaOwner {
|
|
|
142
152
|
this.#interpreter.failCausalCell(reason, traceId);
|
|
143
153
|
}
|
|
144
154
|
captureHistoryAnchor(proof, historyIndex) {
|
|
145
|
-
if (this.#disposed || this.#reseed || this.#waitingForGeometryCapture)
|
|
155
|
+
if (this.#disposed || this.#stale || this.#reseed || this.#waitingForGeometryCapture)
|
|
146
156
|
return { status: "unavailable" };
|
|
147
157
|
return this.#historyAnchors.capture(proof, historyIndex);
|
|
148
158
|
}
|
|
149
159
|
resolveHistoryAnchor(proof, token) {
|
|
150
|
-
if (this.#disposed || this.#reseed || this.#waitingForGeometryCapture)
|
|
160
|
+
if (this.#disposed || this.#stale || this.#reseed || this.#waitingForGeometryCapture)
|
|
151
161
|
return { status: "unavailable" };
|
|
152
162
|
return this.#historyAnchors.resolve(proof, token);
|
|
153
163
|
}
|
|
@@ -183,7 +193,7 @@ export class SessionRuntimeTerminalReplicaOwner {
|
|
|
183
193
|
if (!upstream?.captureNativeBacking)
|
|
184
194
|
return { status: "unsupported" };
|
|
185
195
|
const initial = this.#interpreter.currentSeed();
|
|
186
|
-
if (!initial || this.#reseed || this.#waitingForGeometryCapture)
|
|
196
|
+
if (!initial || this.#stale || this.#reseed || this.#waitingForGeometryCapture)
|
|
187
197
|
return { status: "changed" };
|
|
188
198
|
const epoch = this.#subscriptionEpoch;
|
|
189
199
|
const captured = await upstream.captureNativeBacking();
|
|
@@ -195,6 +205,7 @@ export class SessionRuntimeTerminalReplicaOwner {
|
|
|
195
205
|
return (!this.#disposed &&
|
|
196
206
|
this.#upstream === upstream &&
|
|
197
207
|
this.#subscriptionEpoch === epoch &&
|
|
208
|
+
!this.#stale &&
|
|
198
209
|
!this.#reseed &&
|
|
199
210
|
!this.#waitingForGeometryCapture &&
|
|
200
211
|
captured.isCurrent() &&
|
|
@@ -250,6 +261,8 @@ export class SessionRuntimeTerminalReplicaOwner {
|
|
|
250
261
|
catch {
|
|
251
262
|
// Bootstrap delivery has the same client-isolation rule as live frames.
|
|
252
263
|
}
|
|
264
|
+
// The last frame is out; now ask for the reseed that makes it current.
|
|
265
|
+
this.#unpark();
|
|
253
266
|
}
|
|
254
267
|
catch (error) {
|
|
255
268
|
this.#listeners.delete(listener);
|
|
@@ -264,9 +277,47 @@ export class SessionRuntimeTerminalReplicaOwner {
|
|
|
264
277
|
return;
|
|
265
278
|
closed = true;
|
|
266
279
|
this.#listeners.delete(listener);
|
|
280
|
+
if (this.#listeners.size === 0)
|
|
281
|
+
this.#schedulePark();
|
|
267
282
|
},
|
|
268
283
|
};
|
|
269
284
|
}
|
|
285
|
+
/**
|
|
286
|
+
* Park this pane PARK_AFTER_MS after its last listener leaves (perf F2).
|
|
287
|
+
* The owner is the pane's only channel subscriber, so freezing it pauses the
|
|
288
|
+
* pane's output to the daemon's control client (the channel's all-frozen
|
|
289
|
+
* path). tmux keeps running the pane; nothing here is parsed or hashed. The
|
|
290
|
+
* last committed seed stays, so the next listener sees it at once, and
|
|
291
|
+
* thawing runs the channel's requested-pause recovery, which reseeds.
|
|
292
|
+
* Until that reseed lands the replica is stale: history anchors and native
|
|
293
|
+
* backing answer as they do during any reseed, and the reseed's reset then
|
|
294
|
+
* drops every anchor taken before the park.
|
|
295
|
+
*/
|
|
296
|
+
#schedulePark() {
|
|
297
|
+
if (this.#disposed || this.#parked)
|
|
298
|
+
return;
|
|
299
|
+
this.#parkTimer?.cancel();
|
|
300
|
+
this.#parkTimer = this.#scheduler.timer(() => {
|
|
301
|
+
this.#parkTimer = null;
|
|
302
|
+
if (this.#disposed || this.#parked || this.#listeners.size > 0 || !this.#upstream)
|
|
303
|
+
return;
|
|
304
|
+
this.#parked = true;
|
|
305
|
+
this.#stale = true;
|
|
306
|
+
this.#upstream.freeze();
|
|
307
|
+
}, PARK_AFTER_MS);
|
|
308
|
+
}
|
|
309
|
+
#unpark() {
|
|
310
|
+
this.#parkTimer?.cancel();
|
|
311
|
+
this.#parkTimer = null;
|
|
312
|
+
if (!this.#parked)
|
|
313
|
+
return;
|
|
314
|
+
this.#parked = false;
|
|
315
|
+
this.#upstream?.thaw();
|
|
316
|
+
}
|
|
317
|
+
/** True while the pane is parked (tests and qualification). */
|
|
318
|
+
get parked() {
|
|
319
|
+
return this.#parked;
|
|
320
|
+
}
|
|
270
321
|
/** Kitty graphics side channel: current state now (if any), then every change. */
|
|
271
322
|
subscribeGraphics(listener) {
|
|
272
323
|
const current = this.#interpreter.currentGraphics();
|
|
@@ -301,6 +352,8 @@ export class SessionRuntimeTerminalReplicaOwner {
|
|
|
301
352
|
this.#historyAnchors.invalidate();
|
|
302
353
|
this.#historyTimer?.cancel();
|
|
303
354
|
this.#historyTimer = null;
|
|
355
|
+
this.#parkTimer?.cancel();
|
|
356
|
+
this.#parkTimer = null;
|
|
304
357
|
this.#subscriptionEpoch += 1;
|
|
305
358
|
await this.#interpreter.enqueue({ type: "close", reason });
|
|
306
359
|
await this.#start.catch(() => undefined);
|
|
@@ -335,6 +388,7 @@ export class SessionRuntimeTerminalReplicaOwner {
|
|
|
335
388
|
// Output received during the probe makes its count incomparable with
|
|
336
389
|
// the newer parser state. The dirty flag schedules another check.
|
|
337
390
|
this.#historyDirty ||
|
|
391
|
+
this.#stale ||
|
|
338
392
|
this.#reseed ||
|
|
339
393
|
this.#waitingForGeometryCapture ||
|
|
340
394
|
size === null)
|
|
@@ -398,6 +452,9 @@ export class SessionRuntimeTerminalReplicaOwner {
|
|
|
398
452
|
this.#waitingForGeometryCapture = false;
|
|
399
453
|
const reseed = this.#reseed;
|
|
400
454
|
this.#reseed = null;
|
|
455
|
+
// A completed capture after the park makes the replica current again.
|
|
456
|
+
if (reseed && !this.#parked)
|
|
457
|
+
this.#stale = false;
|
|
401
458
|
const lease = reseed ? this.#qualifyReseed(reseed, event.x, event.y) : null;
|
|
402
459
|
this.#supervise(reseed && lease
|
|
403
460
|
? this.#interpreter.enqueue({
|
|
@@ -14,6 +14,21 @@ export function createApplicationHomeAgentNavigator(options) {
|
|
|
14
14
|
};
|
|
15
15
|
const listed = (current, target) => !!target.paneId &&
|
|
16
16
|
!!current?.agents.some((agent) => agent.id === target.agentId && agent.paneId === target.paneId);
|
|
17
|
+
/** Before a check that would refuse a stale target: let a re-reading roster finish. */
|
|
18
|
+
const settleTarget = async (token, target, signal) => {
|
|
19
|
+
if (!options.waitForCurrentTarget || !active(token) || options.isCurrentTarget(target))
|
|
20
|
+
return;
|
|
21
|
+
if (waitingNote !== token) {
|
|
22
|
+
options.setNote(`Waiting for agent in ${target.sessionName}…`);
|
|
23
|
+
waitingNote = token;
|
|
24
|
+
}
|
|
25
|
+
try {
|
|
26
|
+
await options.waitForCurrentTarget(target, signal);
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
// A failed wait decides nothing; the check that follows does.
|
|
30
|
+
}
|
|
31
|
+
};
|
|
17
32
|
/** Every admission check; null admits. Notes are set only for a refusal. */
|
|
18
33
|
const refusal = (token, target, expectedGeneration) => {
|
|
19
34
|
if (!active(token))
|
|
@@ -56,7 +71,7 @@ export function createApplicationHomeAgentNavigator(options) {
|
|
|
56
71
|
const admission = new Promise((resolve) => {
|
|
57
72
|
settle = resolve;
|
|
58
73
|
});
|
|
59
|
-
options.selectPane(target.paneId, source, admission);
|
|
74
|
+
const selection = options.selectPane(target.paneId, source, admission);
|
|
60
75
|
// The cold path's "Opening agent in …" note, for the warm wait.
|
|
61
76
|
options.setNote(`Waiting for agent in ${target.sessionName}…`);
|
|
62
77
|
waitingNote = token;
|
|
@@ -66,13 +81,36 @@ export function createApplicationHomeAgentNavigator(options) {
|
|
|
66
81
|
catch {
|
|
67
82
|
// A failed wait is a refusal below, never an admission.
|
|
68
83
|
}
|
|
69
|
-
if (
|
|
70
|
-
|
|
84
|
+
if (options.waitForCurrentTarget && !options.isCurrentTarget(target))
|
|
85
|
+
await settleTarget(token, target, signal);
|
|
71
86
|
// A refusal replaces the note; an admission clears it below.
|
|
72
87
|
const refused = refusal(token, target, generationKey);
|
|
73
88
|
settle(refused === null);
|
|
74
|
-
if (refused)
|
|
89
|
+
if (refused) {
|
|
90
|
+
if (waitingNote === token)
|
|
91
|
+
waitingNote = null;
|
|
75
92
|
return refused;
|
|
93
|
+
}
|
|
94
|
+
// Admitted is not selected: the runtime may still refuse the pane, or take
|
|
95
|
+
// a moment for a pane that was just created. The wait note stays until it
|
|
96
|
+
// answers, and the terminals are shown only for a pane that was selected.
|
|
97
|
+
let selected;
|
|
98
|
+
try {
|
|
99
|
+
selected = (await selection) ?? "selected";
|
|
100
|
+
}
|
|
101
|
+
catch {
|
|
102
|
+
selected = "failed";
|
|
103
|
+
}
|
|
104
|
+
if (waitingNote === token)
|
|
105
|
+
waitingNote = null;
|
|
106
|
+
if (!active(token))
|
|
107
|
+
return { opened: false, failure: "superseded" };
|
|
108
|
+
if (selected === "superseded" || selected === "not-admitted") {
|
|
109
|
+
options.setNote(null);
|
|
110
|
+
return { opened: false, failure: "superseded" };
|
|
111
|
+
}
|
|
112
|
+
if (selected === "failed")
|
|
113
|
+
return failure(token, "selection-failed", "That agent's terminal could not be selected yet. Select the agent again.");
|
|
76
114
|
options.showTerminals(source);
|
|
77
115
|
options.setNote(null);
|
|
78
116
|
return { opened: true };
|
|
@@ -90,6 +128,14 @@ export function createApplicationHomeAgentNavigator(options) {
|
|
|
90
128
|
try {
|
|
91
129
|
if (!target.paneId)
|
|
92
130
|
return failure(token, "unavailable", "This agent has no available terminal to open.");
|
|
131
|
+
// Only when it is needed: a warm open of a current target stays synchronous.
|
|
132
|
+
if (options.waitForCurrentTarget && !options.isCurrentTarget(target)) {
|
|
133
|
+
await settleTarget(token, target, controller.signal);
|
|
134
|
+
if (!active(token))
|
|
135
|
+
return { opened: false, failure: "superseded" };
|
|
136
|
+
if (waitingNote === token)
|
|
137
|
+
waitingNote = null;
|
|
138
|
+
}
|
|
93
139
|
if (!options.isCurrentTarget(target))
|
|
94
140
|
return failure(token, "stale-target", "That agent changed or disappeared. Select it again on Home.");
|
|
95
141
|
const attached = options.currentGeneration();
|
|
@@ -122,6 +168,13 @@ export function createApplicationHomeAgentNavigator(options) {
|
|
|
122
168
|
if (!ready)
|
|
123
169
|
return failure(token, "attach-failed", "The session opened, but agent details are not ready. Return Home and retry.");
|
|
124
170
|
}
|
|
171
|
+
if (options.waitForCurrentTarget && !options.isCurrentTarget(target)) {
|
|
172
|
+
await settleTarget(token, target, controller.signal);
|
|
173
|
+
if (!active(token))
|
|
174
|
+
return { opened: false, failure: "superseded" };
|
|
175
|
+
if (waitingNote === token)
|
|
176
|
+
waitingNote = null;
|
|
177
|
+
}
|
|
125
178
|
return admit(token, target, source, opened.generationKey);
|
|
126
179
|
}
|
|
127
180
|
catch {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { waitForRosterTarget } from "../../../lib/home-agent-observer.js";
|
|
1
2
|
import { createApplicationNewAgentOwner } from "./application-new-agent-owner.js";
|
|
2
3
|
import { createEffect, createSignal, onCleanup, untrack } from "solid-js";
|
|
3
4
|
import { createApplicationHomeAgentObserver, } from "./application-home-agent-observer.js";
|
|
@@ -86,14 +87,15 @@ export function createApplicationHomeAgentsOwner(options) {
|
|
|
86
87
|
const [selected, setSelected] = createSignal(selection.snapshot());
|
|
87
88
|
const [opening, setOpening] = createSignal(false);
|
|
88
89
|
let request = 0;
|
|
90
|
+
const currentTarget = (target) => {
|
|
91
|
+
const catalog = options.catalog();
|
|
92
|
+
return (catalog.phase === "live" &&
|
|
93
|
+
catalog.daemonInstanceId === target.daemonInstanceId &&
|
|
94
|
+
catalog.sessions.some((session) => session.name === target.sessionName && session.liveSessionId === target.liveSessionId) &&
|
|
95
|
+
observer.isCurrentTarget(target));
|
|
96
|
+
};
|
|
89
97
|
const navigator = createApplicationHomeAgentNavigator({
|
|
90
|
-
isCurrentTarget
|
|
91
|
-
const catalog = options.catalog();
|
|
92
|
-
return (catalog.phase === "live" &&
|
|
93
|
-
catalog.daemonInstanceId === target.daemonInstanceId &&
|
|
94
|
-
catalog.sessions.some((session) => session.name === target.sessionName && session.liveSessionId === target.liveSessionId) &&
|
|
95
|
-
observer.isCurrentTarget(target));
|
|
96
|
-
},
|
|
98
|
+
isCurrentTarget: currentTarget,
|
|
97
99
|
currentGeneration() {
|
|
98
100
|
const generation = options.generation();
|
|
99
101
|
const generationKey = applicationGenerationNavigationKey(generation);
|
|
@@ -109,6 +111,15 @@ export function createApplicationHomeAgentsOwner(options) {
|
|
|
109
111
|
agents: semantic.sidebar.agents,
|
|
110
112
|
};
|
|
111
113
|
},
|
|
114
|
+
waitForCurrentTarget: (target, signal) => waitForRosterTarget({
|
|
115
|
+
isCurrent: () => currentTarget(target),
|
|
116
|
+
refreshing: () => {
|
|
117
|
+
const observed = observer.getSnapshot();
|
|
118
|
+
return observed.refreshingSessionKeys.length > 0 || observed.loadingSessions > 0;
|
|
119
|
+
},
|
|
120
|
+
subscribe: (listener) => observer.subscribe(() => listener()),
|
|
121
|
+
signal,
|
|
122
|
+
}),
|
|
112
123
|
waitForGeneration: (key, signal) => waitForHomeAgentSemantic(options.generation, key, signal),
|
|
113
124
|
waitForAgent: (key, listed, signal) => waitForHomeAgentListed(options.generation, key, listed, signal),
|
|
114
125
|
startGeneration: options.startGeneration,
|
|
@@ -2,6 +2,16 @@ import { retainsAgentControl } from "./application-retained-agent.js";
|
|
|
2
2
|
import { createApplicationHomeAgentNavigator, } from "./application-home-agent-navigation.js";
|
|
3
3
|
import { applicationGenerationNavigationKey } from "./application-generation-starter.js";
|
|
4
4
|
import { agentOpeningOwnsKey, waitForHomeAgentListed, waitForHomeAgentSemantic, } from "./application-home-agents-owner.js";
|
|
5
|
+
/**
|
|
6
|
+
* The two checks the navigator asks of the machines' agent roster: is a row
|
|
7
|
+
* current, and is it current once a re-read in progress has finished.
|
|
8
|
+
*/
|
|
9
|
+
export function machineAgentRosterChecks(roster) {
|
|
10
|
+
return {
|
|
11
|
+
isCurrentTarget: (machineId, row) => roster.isCurrentTarget(machineId, row),
|
|
12
|
+
waitForCurrentTarget: (machineId, row, signal) => roster.whenCurrentTarget(machineId, row, signal),
|
|
13
|
+
};
|
|
14
|
+
}
|
|
5
15
|
/** Machine identity fences the existing exact-agent admission owner. No independent input path. */
|
|
6
16
|
export function createApplicationMachineAgentNavigator(options) {
|
|
7
17
|
let current = null;
|
|
@@ -51,6 +61,13 @@ export function createApplicationMachineAgentNavigator(options) {
|
|
|
51
61
|
agents: semantic.sidebar.agents,
|
|
52
62
|
};
|
|
53
63
|
},
|
|
64
|
+
...(options.waitForCurrentTarget
|
|
65
|
+
? {
|
|
66
|
+
waitForCurrentTarget: (row, signal) => selected()
|
|
67
|
+
? options.waitForCurrentTarget(machineId, row, signal)
|
|
68
|
+
: Promise.resolve(false),
|
|
69
|
+
}
|
|
70
|
+
: {}),
|
|
54
71
|
waitForGeneration: (key, signal) => waitForHomeAgentSemantic(generation, key, signal),
|
|
55
72
|
waitForAgent: (key, listed, signal) => waitForHomeAgentListed(generation, key, listed, signal),
|
|
56
73
|
startGeneration: (session, prepared, origin, focus, admission) => options.startGeneration(session, prepared, origin, focus, () => selected() && options.isCurrentTarget(machineId, target) && (admission?.() ?? true)),
|
|
@@ -305,7 +305,8 @@ export function createApplicationMachineNavigation(options) {
|
|
|
305
305
|
const row = agentGroups()
|
|
306
306
|
.find((group) => group.machineId === id)
|
|
307
307
|
?.agents.find((agent) => agent.sessionName === sessionName && agent.paneId === paneId);
|
|
308
|
-
|
|
308
|
+
// A row is not current while its roster re-reads; the opener waits for that.
|
|
309
|
+
if (!row || (!agents.isCurrentTarget(id, row) && !agents.isRefreshing(id))) {
|
|
309
310
|
options.setNote("That agent is unavailable or has changed. Wait for its machine to reconnect.");
|
|
310
311
|
return;
|
|
311
312
|
}
|
|
@@ -358,7 +359,8 @@ export function createApplicationMachineNavigation(options) {
|
|
|
358
359
|
agents,
|
|
359
360
|
selectedMachineId: () => manager.snapshot().selectedMachineId,
|
|
360
361
|
openHomeAgent: (row, source) => {
|
|
361
|
-
if (!agents.isCurrentTarget(row.machineId, row) || row.disabled)
|
|
362
|
+
if ((!agents.isCurrentTarget(row.machineId, row) || row.disabled) &&
|
|
363
|
+
!agents.isRefreshing(row.machineId))
|
|
362
364
|
return;
|
|
363
365
|
const session = snapshot()
|
|
364
366
|
.groups.find((group) => group.id === row.machineId)
|
package/packages/daemon/dist/tui/mirror/runtime/application-terminal-interaction-controller.js
CHANGED
|
@@ -10,6 +10,13 @@ import { TerminalPaneInputRouter } from "./terminal-pane-input-router.js";
|
|
|
10
10
|
import { resizeTerminalPane, } from "./resize-terminal-pane.js";
|
|
11
11
|
import { ResizeTransactionController } from "@tmux-ide/core";
|
|
12
12
|
import { nativePaneResizeCells } from "./pane-resize-geometry.js";
|
|
13
|
+
/**
|
|
14
|
+
* Waits between tries of a selection the daemon refused as
|
|
15
|
+
* `pane_inventory_not_ready`: it refuses, before any effect, a pane its
|
|
16
|
+
* inventory has not adopted yet, which is the case for a moment after a pane
|
|
17
|
+
* is created (#764). About 3 s in all.
|
|
18
|
+
*/
|
|
19
|
+
export const PANE_INVENTORY_RETRY_DELAYS_MS = [100, 200, 400, 800, 1500];
|
|
13
20
|
function paneForWindow(layout) {
|
|
14
21
|
return (layout.panes.find((pane) => pane.active && pane.pane)?.pane ??
|
|
15
22
|
layout.panes.find((pane) => pane.pane)?.pane ??
|
|
@@ -527,7 +534,29 @@ export function createApplicationTerminalInteractionController(options) {
|
|
|
527
534
|
};
|
|
528
535
|
// The one way a pane selection reaches the runtime (#764: also used once an
|
|
529
536
|
// admitted agent selection settles).
|
|
537
|
+
const selectionRetryDelaysMs = options.selectionRetryDelaysMs ?? PANE_INVENTORY_RETRY_DELAYS_MS;
|
|
538
|
+
/**
|
|
539
|
+
* A refusal for an inventory that is not ready happened before any effect,
|
|
540
|
+
* so the same selection may be sent again while it is still the current one.
|
|
541
|
+
* Any other failure is final.
|
|
542
|
+
*/
|
|
530
543
|
const selectInRuntime = async (paneId) => {
|
|
544
|
+
const version = paneInput.selectionVersion;
|
|
545
|
+
for (let attempt = 0;; attempt++) {
|
|
546
|
+
const failure = { current: null };
|
|
547
|
+
if (await selectInRuntimeOnce(paneId, failure))
|
|
548
|
+
return true;
|
|
549
|
+
const delayMs = selectionRetryDelaysMs[attempt];
|
|
550
|
+
if (delayMs === undefined ||
|
|
551
|
+
failure.current?.backendReason !== "pane_inventory_not_ready" ||
|
|
552
|
+
paneInput.selectionVersion !== version)
|
|
553
|
+
return false;
|
|
554
|
+
await new Promise((resolve) => setTimeout(resolve, delayMs));
|
|
555
|
+
if (paneInput.selectionVersion !== version)
|
|
556
|
+
return false;
|
|
557
|
+
}
|
|
558
|
+
};
|
|
559
|
+
const selectInRuntimeOnce = async (paneId, selectionFailure) => {
|
|
531
560
|
finishLinkSelection(false);
|
|
532
561
|
const initial = options.generation();
|
|
533
562
|
const selectionControl = controlIdentity(initial);
|
|
@@ -553,7 +582,6 @@ export function createApplicationTerminalInteractionController(options) {
|
|
|
553
582
|
let dispatchedRendererEpoch;
|
|
554
583
|
const selecting = pendingWindowSwitch;
|
|
555
584
|
const operationId = selecting?.traceId;
|
|
556
|
-
const selectionFailure = { current: null };
|
|
557
585
|
const receipt = expected
|
|
558
586
|
? await selectTerminalPane(expected, () => {
|
|
559
587
|
if (!selectionControl)
|
|
@@ -916,22 +944,35 @@ export function createApplicationTerminalInteractionController(options) {
|
|
|
916
944
|
maybeRequestWindowSwitchFrame();
|
|
917
945
|
maybeRequestPaneResizeFrame();
|
|
918
946
|
},
|
|
919
|
-
selectPane: (paneId, admission) => {
|
|
947
|
+
selectPane: ((paneId, admission) => {
|
|
920
948
|
finishLinkSelection(false);
|
|
921
|
-
if (admission)
|
|
922
|
-
// Ordered now; selected only once admitted, otherwise held input drops.
|
|
923
|
-
paneInput.selectPane(paneId, {
|
|
924
|
-
presentOptimistically: false,
|
|
925
|
-
selection: () => {
|
|
926
|
-
// A later selection supersedes this one: never select it after all.
|
|
927
|
-
const version = paneInput.selectionVersion;
|
|
928
|
-
return admission.then((admitted) => admitted && paneInput.selectionVersion === version ? selectInRuntime(paneId) : false);
|
|
929
|
-
},
|
|
930
|
-
});
|
|
931
|
-
else
|
|
949
|
+
if (!admission) {
|
|
932
950
|
paneInput.selectPane(paneId);
|
|
951
|
+
selectionWaiter.reconcile();
|
|
952
|
+
return;
|
|
953
|
+
}
|
|
954
|
+
let outcome;
|
|
955
|
+
// Ordered now; selected only once admitted, otherwise held input drops.
|
|
956
|
+
paneInput.selectPane(paneId, {
|
|
957
|
+
presentOptimistically: false,
|
|
958
|
+
selection: () => {
|
|
959
|
+
// A later selection supersedes this one: never select it after all.
|
|
960
|
+
const version = paneInput.selectionVersion;
|
|
961
|
+
outcome = admission.then(async (admitted) => {
|
|
962
|
+
if (!admitted)
|
|
963
|
+
return "not-admitted";
|
|
964
|
+
if (paneInput.selectionVersion !== version)
|
|
965
|
+
return "superseded";
|
|
966
|
+
if (await selectInRuntime(paneId))
|
|
967
|
+
return "selected";
|
|
968
|
+
return paneInput.selectionVersion === version ? "failed" : "superseded";
|
|
969
|
+
});
|
|
970
|
+
return outcome.then((result) => result === "selected");
|
|
971
|
+
},
|
|
972
|
+
});
|
|
933
973
|
selectionWaiter.reconcile();
|
|
934
|
-
|
|
974
|
+
return outcome;
|
|
975
|
+
}),
|
|
935
976
|
async unlinkWindowLink(target) {
|
|
936
977
|
const expected = liveSelectionTarget();
|
|
937
978
|
const observed = windowLinkTarget(options.layout(), target.linkId);
|