tmux-ide 2.9.23 → 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 +285 -36
- package/package.json +1 -1
- package/packages/daemon/dist/command-center/tmux-servers.js +11 -0
- package/packages/daemon/dist/lib/daemon-embed.js +16 -8
- package/packages/daemon/dist/lib/home-agent-observer.js +50 -0
- 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 +32 -9
- package/packages/daemon/dist/lib/tmux-server-owner.js +26 -4
- 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/terminal/attachments/native-runtime.js +17 -2
- package/packages/daemon/dist/terminal/mirror/session-channel.js +2 -1
- package/packages/daemon/dist/terminal/pane-stream/pane-stream-websocket.js +8 -0
- 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/tmux-servers.ts +11 -0
- package/packages/daemon/src/lib/daemon-embed.ts +52 -7
- package/packages/daemon/src/lib/home-agent-observer.ts +53 -0
- 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 +32 -8
- package/packages/daemon/src/lib/tmux-server-owner.ts +28 -3
- package/packages/daemon/src/lib/workspace-promotion.ts +26 -3
- package/packages/daemon/src/terminal/attachments/native-runtime.ts +21 -2
- package/packages/daemon/src/terminal/mirror/session-channel.ts +2 -1
- package/packages/daemon/src/terminal/pane-stream/pane-stream-websocket.ts +8 -0
- 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
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { waitForRosterTarget } from "../../../lib/home-agent-observer.ts";
|
|
2
|
+
import type { HomeAgentNavigationTarget } from "./application-home-agent-navigation.ts";
|
|
3
|
+
import type { AdmittedPaneSelectionOutcome } from "./application-terminal-interaction-controller.ts";
|
|
1
4
|
import { createApplicationNewAgentOwner } from "./application-new-agent-owner.ts";
|
|
2
5
|
import type { ApplicationPaletteCommand } from "./application-palette-input.ts";
|
|
3
6
|
import { createEffect, createSignal, onCleanup, untrack, type Accessor } from "solid-js";
|
|
@@ -142,7 +145,10 @@ export function createApplicationHomeAgentsOwner(options: {
|
|
|
142
145
|
readonly generation: () => OpenTuiGenerationHostSnapshot | null;
|
|
143
146
|
readonly sessionName: () => string | null;
|
|
144
147
|
readonly startGeneration: ReturnType<typeof createApplicationGenerationStarter>;
|
|
145
|
-
readonly selectPane: (
|
|
148
|
+
readonly selectPane: (
|
|
149
|
+
paneId: string,
|
|
150
|
+
admission?: Promise<boolean>,
|
|
151
|
+
) => void | Promise<AdmittedPaneSelectionOutcome>;
|
|
146
152
|
readonly showTerminals: (source: "keyboard" | "mouse") => void;
|
|
147
153
|
readonly restoreHome?: (source: "keyboard" | "mouse") => Promise<void> | void;
|
|
148
154
|
readonly setNote: (note: string | null) => void;
|
|
@@ -154,19 +160,20 @@ export function createApplicationHomeAgentsOwner(options: {
|
|
|
154
160
|
const [selected, setSelected] = createSignal(selection.snapshot());
|
|
155
161
|
const [opening, setOpening] = createSignal(false);
|
|
156
162
|
let request = 0;
|
|
163
|
+
const currentTarget = (target: HomeAgentNavigationTarget): boolean => {
|
|
164
|
+
const catalog = options.catalog();
|
|
165
|
+
return (
|
|
166
|
+
catalog.phase === "live" &&
|
|
167
|
+
catalog.daemonInstanceId === target.daemonInstanceId &&
|
|
168
|
+
catalog.sessions.some(
|
|
169
|
+
(session) =>
|
|
170
|
+
session.name === target.sessionName && session.liveSessionId === target.liveSessionId,
|
|
171
|
+
) &&
|
|
172
|
+
observer.isCurrentTarget(target)
|
|
173
|
+
);
|
|
174
|
+
};
|
|
157
175
|
const navigator = createApplicationHomeAgentNavigator({
|
|
158
|
-
isCurrentTarget
|
|
159
|
-
const catalog = options.catalog();
|
|
160
|
-
return (
|
|
161
|
-
catalog.phase === "live" &&
|
|
162
|
-
catalog.daemonInstanceId === target.daemonInstanceId &&
|
|
163
|
-
catalog.sessions.some(
|
|
164
|
-
(session) =>
|
|
165
|
-
session.name === target.sessionName && session.liveSessionId === target.liveSessionId,
|
|
166
|
-
) &&
|
|
167
|
-
observer.isCurrentTarget(target)
|
|
168
|
-
);
|
|
169
|
-
},
|
|
176
|
+
isCurrentTarget: currentTarget,
|
|
170
177
|
currentGeneration() {
|
|
171
178
|
const generation = options.generation();
|
|
172
179
|
const generationKey = applicationGenerationNavigationKey(generation);
|
|
@@ -181,6 +188,16 @@ export function createApplicationHomeAgentsOwner(options: {
|
|
|
181
188
|
agents: semantic.sidebar.agents,
|
|
182
189
|
};
|
|
183
190
|
},
|
|
191
|
+
waitForCurrentTarget: (target, signal) =>
|
|
192
|
+
waitForRosterTarget({
|
|
193
|
+
isCurrent: () => currentTarget(target),
|
|
194
|
+
refreshing: () => {
|
|
195
|
+
const observed = observer.getSnapshot();
|
|
196
|
+
return observed.refreshingSessionKeys.length > 0 || observed.loadingSessions > 0;
|
|
197
|
+
},
|
|
198
|
+
subscribe: (listener) => observer.subscribe(() => listener()),
|
|
199
|
+
signal,
|
|
200
|
+
}),
|
|
184
201
|
waitForGeneration: (key, signal) => waitForHomeAgentSemantic(options.generation, key, signal),
|
|
185
202
|
waitForAgent: (key, listed, signal) =>
|
|
186
203
|
waitForHomeAgentListed(options.generation, key, listed, signal),
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { AdmittedPaneSelectionOutcome } from "./application-terminal-interaction-controller.ts";
|
|
1
2
|
import { retainsAgentControl } from "./application-retained-agent.ts";
|
|
2
3
|
import {
|
|
3
4
|
createApplicationHomeAgentNavigator,
|
|
@@ -14,9 +15,34 @@ import type { OpenTuiGenerationHostSnapshot } from "./open-tui-generation-host.t
|
|
|
14
15
|
|
|
15
16
|
type HomeNavigatorOptions = Parameters<typeof createApplicationHomeAgentNavigator>[0];
|
|
16
17
|
|
|
18
|
+
/**
|
|
19
|
+
* The two checks the navigator asks of the machines' agent roster: is a row
|
|
20
|
+
* current, and is it current once a re-read in progress has finished.
|
|
21
|
+
*/
|
|
22
|
+
export function machineAgentRosterChecks(roster: {
|
|
23
|
+
isCurrentTarget(machineId: string, row: never): boolean;
|
|
24
|
+
whenCurrentTarget(machineId: string, row: never, signal: AbortSignal): Promise<boolean>;
|
|
25
|
+
}) {
|
|
26
|
+
return {
|
|
27
|
+
isCurrentTarget: (machineId: string, row: HomeAgentNavigationTarget): boolean =>
|
|
28
|
+
roster.isCurrentTarget(machineId, row as never),
|
|
29
|
+
waitForCurrentTarget: (
|
|
30
|
+
machineId: string,
|
|
31
|
+
row: HomeAgentNavigationTarget,
|
|
32
|
+
signal: AbortSignal,
|
|
33
|
+
): Promise<boolean> => roster.whenCurrentTarget(machineId, row as never, signal),
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
17
37
|
/** Machine identity fences the existing exact-agent admission owner. No independent input path. */
|
|
18
38
|
export function createApplicationMachineAgentNavigator(options: {
|
|
19
39
|
readonly isCurrentTarget: (machineId: string, target: HomeAgentNavigationTarget) => boolean;
|
|
40
|
+
/** `isCurrentTarget` once the machine's roster has finished a re-read in progress. */
|
|
41
|
+
readonly waitForCurrentTarget?: (
|
|
42
|
+
machineId: string,
|
|
43
|
+
target: HomeAgentNavigationTarget,
|
|
44
|
+
signal: AbortSignal,
|
|
45
|
+
) => Promise<boolean>;
|
|
20
46
|
readonly selectedMachineId: () => string | null;
|
|
21
47
|
/** Identity of the attached generation, never inferred from the selected machine. */
|
|
22
48
|
readonly generationMachineId: () => string | null;
|
|
@@ -24,7 +50,10 @@ export function createApplicationMachineAgentNavigator(options: {
|
|
|
24
50
|
readonly sessionName: () => string | null;
|
|
25
51
|
readonly startGeneration: HomeNavigatorOptions["startGeneration"];
|
|
26
52
|
/** The interaction controller's selectPane: `admission` must reach it (#764). */
|
|
27
|
-
readonly selectPane: (
|
|
53
|
+
readonly selectPane: (
|
|
54
|
+
paneId: string,
|
|
55
|
+
admission?: Promise<boolean>,
|
|
56
|
+
) => void | Promise<AdmittedPaneSelectionOutcome>;
|
|
28
57
|
readonly showTerminals: HomeNavigatorOptions["showTerminals"];
|
|
29
58
|
readonly setNote: HomeNavigatorOptions["setNote"];
|
|
30
59
|
}) {
|
|
@@ -81,6 +110,14 @@ export function createApplicationMachineAgentNavigator(options: {
|
|
|
81
110
|
agents: semantic.sidebar.agents,
|
|
82
111
|
};
|
|
83
112
|
},
|
|
113
|
+
...(options.waitForCurrentTarget
|
|
114
|
+
? {
|
|
115
|
+
waitForCurrentTarget: (row: HomeAgentNavigationTarget, signal: AbortSignal) =>
|
|
116
|
+
selected()
|
|
117
|
+
? options.waitForCurrentTarget!(machineId, row, signal)
|
|
118
|
+
: Promise.resolve(false),
|
|
119
|
+
}
|
|
120
|
+
: {}),
|
|
84
121
|
waitForGeneration: (key, signal) => waitForHomeAgentSemantic(generation, key, signal),
|
|
85
122
|
waitForAgent: (key, listed, signal) =>
|
|
86
123
|
waitForHomeAgentListed(generation, key, listed, signal),
|
|
@@ -364,7 +364,8 @@ export function createApplicationMachineNavigation(options: {
|
|
|
364
364
|
const row = agentGroups()
|
|
365
365
|
.find((group) => group.machineId === id)
|
|
366
366
|
?.agents.find((agent) => agent.sessionName === sessionName && agent.paneId === paneId);
|
|
367
|
-
|
|
367
|
+
// A row is not current while its roster re-reads; the opener waits for that.
|
|
368
|
+
if (!row || (!agents.isCurrentTarget(id, row) && !agents.isRefreshing(id))) {
|
|
368
369
|
options.setNote(
|
|
369
370
|
"That agent is unavailable or has changed. Wait for its machine to reconnect.",
|
|
370
371
|
);
|
|
@@ -417,7 +418,11 @@ export function createApplicationMachineNavigation(options: {
|
|
|
417
418
|
agents,
|
|
418
419
|
selectedMachineId: () => manager.snapshot().selectedMachineId,
|
|
419
420
|
openHomeAgent: (row: ApplicationMachineAgent, source: "keyboard" | "mouse") => {
|
|
420
|
-
if (
|
|
421
|
+
if (
|
|
422
|
+
(!agents.isCurrentTarget(row.machineId, row) || row.disabled) &&
|
|
423
|
+
!agents.isRefreshing(row.machineId)
|
|
424
|
+
)
|
|
425
|
+
return;
|
|
421
426
|
const session = snapshot()
|
|
422
427
|
.groups.find((group) => group.id === row.machineId)
|
|
423
428
|
?.sessions.find(
|
|
@@ -5,7 +5,7 @@ import { terminalWindowActionCallbacks } from "./application-terminal-workspace-
|
|
|
5
5
|
import { applicationRouteConnection } from "./application-route-connection.ts";
|
|
6
6
|
import { ApplicationMachineOverlays } from "./application-machine-overlays.tsx";
|
|
7
7
|
import { applicationMachineAuthorityManager } from "./application-machine-authority.ts";
|
|
8
|
-
import
|
|
8
|
+
import * as machineAgentNavigation from "./application-machine-agent-navigation.ts";
|
|
9
9
|
import { createApplicationMachineNavigation } from "./application-machine-navigation.ts";
|
|
10
10
|
import { handleFleetShortcut } from "./application-machine-navigation.ts";
|
|
11
11
|
import { disposeApplicationDaemonAuthority } from "./application-daemon-authority.ts";
|
|
@@ -325,7 +325,7 @@ export async function startApplicationRoot(options: StartApplicationRootOptions
|
|
|
325
325
|
);
|
|
326
326
|
const startGeneration = terminalInputIngress.wrapStarter(generationStarter);
|
|
327
327
|
let machineAgentNavigator:
|
|
328
|
-
| ReturnType<typeof createApplicationMachineAgentNavigator>
|
|
328
|
+
| ReturnType<typeof machineAgentNavigation.createApplicationMachineAgentNavigator>
|
|
329
329
|
| undefined;
|
|
330
330
|
const machines = createApplicationMachineNavigation({
|
|
331
331
|
attachedGeneration: generation,
|
|
@@ -360,8 +360,8 @@ export async function startApplicationRoot(options: StartApplicationRootOptions
|
|
|
360
360
|
setNote: appearance.setNote,
|
|
361
361
|
});
|
|
362
362
|
const paneInteractions = createMachinePaneActivity(machines, generationMachineId, shell);
|
|
363
|
-
machineAgentNavigator = createApplicationMachineAgentNavigator({
|
|
364
|
-
|
|
363
|
+
machineAgentNavigator = machineAgentNavigation.createApplicationMachineAgentNavigator({
|
|
364
|
+
...machineAgentNavigation.machineAgentRosterChecks(machines.agents),
|
|
365
365
|
selectedMachineId: machines.selectedMachineId,
|
|
366
366
|
generationMachineId,
|
|
367
367
|
generation,
|
package/packages/daemon/src/tui/mirror/runtime/application-terminal-interaction-controller.ts
CHANGED
|
@@ -51,7 +51,23 @@ interface DiagnosticWindowFrameContext {
|
|
|
51
51
|
readonly rows: number;
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
+
/**
|
|
55
|
+
* How a selection made behind an admission ended. "failed": the daemon did not
|
|
56
|
+
* select the pane. "superseded": a later selection or a new control replaced it.
|
|
57
|
+
*/
|
|
58
|
+
export type AdmittedPaneSelectionOutcome = "selected" | "not-admitted" | "failed" | "superseded";
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Waits between tries of a selection the daemon refused as
|
|
62
|
+
* `pane_inventory_not_ready`: it refuses, before any effect, a pane its
|
|
63
|
+
* inventory has not adopted yet, which is the case for a moment after a pane
|
|
64
|
+
* is created (#764). About 3 s in all.
|
|
65
|
+
*/
|
|
66
|
+
export const PANE_INVENTORY_RETRY_DELAYS_MS: readonly number[] = [100, 200, 400, 800, 1500];
|
|
67
|
+
|
|
54
68
|
export interface ApplicationTerminalInteractionControllerOptions {
|
|
69
|
+
/** Test seam for PANE_INVENTORY_RETRY_DELAYS_MS. */
|
|
70
|
+
readonly selectionRetryDelaysMs?: readonly number[];
|
|
55
71
|
readonly generation: Accessor<OpenTuiGenerationHostSnapshot | null>;
|
|
56
72
|
readonly layout: Accessor<OpenTuiWorkspaceLayoutSnapshot>;
|
|
57
73
|
readonly focusedPane?: Accessor<string | null>;
|
|
@@ -89,7 +105,12 @@ export interface ApplicationTerminalInteractionController {
|
|
|
89
105
|
* selection replaced it; otherwise that input is dropped, never delivered to
|
|
90
106
|
* another pane. (The app's root sends no input while an agent is opening.)
|
|
91
107
|
*/
|
|
92
|
-
selectPane(paneId: string
|
|
108
|
+
selectPane(paneId: string): void;
|
|
109
|
+
selectPane(paneId: string, admission: Promise<boolean>): Promise<AdmittedPaneSelectionOutcome>;
|
|
110
|
+
selectPane(
|
|
111
|
+
paneId: string,
|
|
112
|
+
admission?: Promise<boolean>,
|
|
113
|
+
): void | Promise<AdmittedPaneSelectionOutcome>;
|
|
93
114
|
selectWindowLink(target: WindowLinkTarget): Promise<void>;
|
|
94
115
|
unlinkWindowLink(target: WindowLinkTarget): Promise<string>;
|
|
95
116
|
sendInput(
|
|
@@ -830,7 +851,32 @@ export function createApplicationTerminalInteractionController(
|
|
|
830
851
|
|
|
831
852
|
// The one way a pane selection reaches the runtime (#764: also used once an
|
|
832
853
|
// admitted agent selection settles).
|
|
854
|
+
const selectionRetryDelaysMs = options.selectionRetryDelaysMs ?? PANE_INVENTORY_RETRY_DELAYS_MS;
|
|
855
|
+
/**
|
|
856
|
+
* A refusal for an inventory that is not ready happened before any effect,
|
|
857
|
+
* so the same selection may be sent again while it is still the current one.
|
|
858
|
+
* Any other failure is final.
|
|
859
|
+
*/
|
|
833
860
|
const selectInRuntime = async (paneId: string): Promise<boolean> => {
|
|
861
|
+
const version = paneInput.selectionVersion;
|
|
862
|
+
for (let attempt = 0; ; attempt++) {
|
|
863
|
+
const failure: { current: PaneSelectionFailure | null } = { current: null };
|
|
864
|
+
if (await selectInRuntimeOnce(paneId, failure)) return true;
|
|
865
|
+
const delayMs = selectionRetryDelaysMs[attempt];
|
|
866
|
+
if (
|
|
867
|
+
delayMs === undefined ||
|
|
868
|
+
failure.current?.backendReason !== "pane_inventory_not_ready" ||
|
|
869
|
+
paneInput.selectionVersion !== version
|
|
870
|
+
)
|
|
871
|
+
return false;
|
|
872
|
+
await new Promise<void>((resolve) => setTimeout(resolve, delayMs));
|
|
873
|
+
if (paneInput.selectionVersion !== version) return false;
|
|
874
|
+
}
|
|
875
|
+
};
|
|
876
|
+
const selectInRuntimeOnce = async (
|
|
877
|
+
paneId: string,
|
|
878
|
+
selectionFailure: { current: PaneSelectionFailure | null },
|
|
879
|
+
): Promise<boolean> => {
|
|
834
880
|
finishLinkSelection(false);
|
|
835
881
|
const initial = options.generation();
|
|
836
882
|
const selectionControl = controlIdentity(initial);
|
|
@@ -856,7 +902,6 @@ export function createApplicationTerminalInteractionController(
|
|
|
856
902
|
let dispatchedRendererEpoch: number | undefined;
|
|
857
903
|
const selecting = pendingWindowSwitch;
|
|
858
904
|
const operationId = selecting?.traceId;
|
|
859
|
-
const selectionFailure: { current: PaneSelectionFailure | null } = { current: null };
|
|
860
905
|
const receipt = expected
|
|
861
906
|
? await selectTerminalPane(
|
|
862
907
|
expected,
|
|
@@ -1238,23 +1283,32 @@ export function createApplicationTerminalInteractionController(
|
|
|
1238
1283
|
maybeRequestWindowSwitchFrame();
|
|
1239
1284
|
maybeRequestPaneResizeFrame();
|
|
1240
1285
|
},
|
|
1241
|
-
selectPane: (paneId, admission) => {
|
|
1286
|
+
selectPane: ((paneId: string, admission?: Promise<boolean>) => {
|
|
1242
1287
|
finishLinkSelection(false);
|
|
1243
|
-
if (admission)
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1288
|
+
if (!admission) {
|
|
1289
|
+
paneInput.selectPane(paneId);
|
|
1290
|
+
selectionWaiter.reconcile();
|
|
1291
|
+
return;
|
|
1292
|
+
}
|
|
1293
|
+
let outcome!: Promise<AdmittedPaneSelectionOutcome>;
|
|
1294
|
+
// Ordered now; selected only once admitted, otherwise held input drops.
|
|
1295
|
+
paneInput.selectPane(paneId, {
|
|
1296
|
+
presentOptimistically: false,
|
|
1297
|
+
selection: () => {
|
|
1298
|
+
// A later selection supersedes this one: never select it after all.
|
|
1299
|
+
const version = paneInput.selectionVersion;
|
|
1300
|
+
outcome = admission.then(async (admitted): Promise<AdmittedPaneSelectionOutcome> => {
|
|
1301
|
+
if (!admitted) return "not-admitted";
|
|
1302
|
+
if (paneInput.selectionVersion !== version) return "superseded";
|
|
1303
|
+
if (await selectInRuntime(paneId)) return "selected";
|
|
1304
|
+
return paneInput.selectionVersion === version ? "failed" : "superseded";
|
|
1305
|
+
});
|
|
1306
|
+
return outcome.then((result) => result === "selected");
|
|
1307
|
+
},
|
|
1308
|
+
});
|
|
1256
1309
|
selectionWaiter.reconcile();
|
|
1257
|
-
|
|
1310
|
+
return outcome;
|
|
1311
|
+
}) as ApplicationTerminalInteractionController["selectPane"],
|
|
1258
1312
|
async unlinkWindowLink(target) {
|
|
1259
1313
|
const expected = liveSelectionTarget();
|
|
1260
1314
|
const observed = windowLinkTarget(options.layout(), target.linkId);
|