tmux-ide 2.9.21 → 2.9.23
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 +6235 -8473
- package/package.json +3 -3
- package/packages/contracts/src/index.ts +2 -0
- package/packages/contracts/src/pane-reader.ts +121 -0
- package/packages/contracts/src/pane-stream.ts +18 -0
- package/packages/contracts/src/visual-theme-presets.ts +58 -2
- 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-server-reader.js +41 -0
- package/packages/daemon/dist/command-center/tmux-servers.js +7 -1
- package/packages/daemon/dist/doctor.js +147 -43
- package/packages/daemon/dist/lib/bounded-tmux-read.js +34 -12
- package/packages/daemon/dist/lib/cli-command.js +13 -0
- package/packages/daemon/dist/lib/daemon-embed.js +126 -55
- 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/log.js +18 -1
- package/packages/daemon/dist/lib/pane-reader-files.js +226 -0
- package/packages/daemon/dist/lib/remote-tmux-command.js +8 -5
- package/packages/daemon/dist/lib/tmux-client-execution.js +73 -7
- package/packages/daemon/dist/lib/tmux-external-interaction-observer.js +140 -19
- package/packages/daemon/dist/lib/tmux-native-browser.js +4 -2
- package/packages/daemon/dist/lib/tmux-pane-reader.js +107 -0
- package/packages/daemon/dist/lib/tmux-server-agent-admission.js +6 -1
- package/packages/daemon/dist/lib/tmux-server-features.js +38 -0
- package/packages/daemon/dist/lib/tmux-server-owner-teardown.js +33 -0
- package/packages/daemon/dist/lib/tmux-server-owner.js +38 -37
- 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/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/open-browser.js +26 -12
- package/packages/daemon/dist/open-reader.js +84 -0
- package/packages/daemon/dist/plugins/cli.js +1 -2
- package/packages/daemon/dist/plugins/daemon-plugins.js +2 -10
- package/packages/daemon/dist/restore.js +57 -40
- 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 +32 -14
- 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 +13 -12
- package/packages/daemon/dist/terminal/pane-stream/pane-stream-websocket.js +123 -25
- package/packages/daemon/dist/terminal/pane-stream/runtime.js +3 -2
- package/packages/daemon/dist/terminal/protocol/reader-option.js +66 -0
- package/packages/daemon/dist/terminal/protocol/session-descriptor-discovery.js +30 -2
- 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/tmux-upgrade/cli.js +106 -0
- package/packages/daemon/dist/tmux-upgrade/io.js +540 -0
- package/packages/daemon/dist/tmux-upgrade/plan.js +238 -0
- package/packages/daemon/dist/tmux-upgrade/run.js +199 -0
- package/packages/daemon/dist/tui/chrome/snapshot.js +3 -4
- package/packages/daemon/dist/tui/mirror/runtime/application-home-agent-navigation.js +64 -4
- package/packages/daemon/dist/tui/mirror/runtime/application-home-agents-owner.js +35 -5
- package/packages/daemon/dist/tui/mirror/runtime/application-machine-agent-navigation.js +12 -8
- package/packages/daemon/dist/tui/mirror/runtime/application-terminal-interaction-controller.js +125 -111
- 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-server-reader.ts +62 -0
- package/packages/daemon/src/command-center/tmux-servers.ts +7 -1
- package/packages/daemon/src/doctor.ts +164 -45
- package/packages/daemon/src/lib/bounded-tmux-read.ts +29 -9
- package/packages/daemon/src/lib/cli-command.ts +16 -0
- package/packages/daemon/src/lib/daemon-embed.ts +176 -64
- 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/log.ts +18 -1
- package/packages/daemon/src/lib/pane-reader-files.ts +294 -0
- package/packages/daemon/src/lib/remote-tmux-command.ts +13 -6
- package/packages/daemon/src/lib/tmux-client-execution.ts +79 -7
- package/packages/daemon/src/lib/tmux-external-interaction-observer.ts +163 -25
- package/packages/daemon/src/lib/tmux-native-browser.ts +4 -3
- package/packages/daemon/src/lib/tmux-pane-reader.ts +145 -0
- package/packages/daemon/src/lib/tmux-server-agent-admission.ts +6 -1
- package/packages/daemon/src/lib/tmux-server-features.ts +43 -0
- package/packages/daemon/src/lib/tmux-server-owner-teardown.ts +54 -0
- package/packages/daemon/src/lib/tmux-server-owner.ts +41 -35
- 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/open-browser.ts +59 -18
- package/packages/daemon/src/open-reader.ts +148 -0
- package/packages/daemon/src/plugins/cli.ts +1 -2
- package/packages/daemon/src/plugins/daemon-plugins.ts +2 -12
- package/packages/daemon/src/restore.ts +80 -44
- 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 +58 -14
- package/packages/daemon/src/terminal/mirror/events.ts +2 -0
- 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 +15 -14
- package/packages/daemon/src/terminal/pane-stream/pane-stream-websocket.ts +140 -23
- package/packages/daemon/src/terminal/pane-stream/runtime.ts +4 -2
- package/packages/daemon/src/terminal/protocol/reader-option.ts +77 -0
- package/packages/daemon/src/terminal/protocol/session-descriptor-discovery.ts +41 -1
- 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/tmux-upgrade/cli.ts +118 -0
- package/packages/daemon/src/tmux-upgrade/io.ts +596 -0
- package/packages/daemon/src/tmux-upgrade/plan.ts +353 -0
- package/packages/daemon/src/tmux-upgrade/run.ts +325 -0
- package/packages/daemon/src/tui/chrome/snapshot.ts +3 -4
- package/packages/daemon/src/tui/mirror/runtime/application-home-agent-navigation.ts +110 -10
- package/packages/daemon/src/tui/mirror/runtime/application-home-agents-owner.ts +58 -6
- package/packages/daemon/src/tui/mirror/runtime/application-machine-agent-navigation.ts +20 -9
- package/packages/daemon/src/tui/mirror/runtime/application-root-v2.tsx +2 -2
- package/packages/daemon/src/tui/mirror/runtime/application-terminal-interaction-controller.ts +149 -128
- package/packages/daemon-client/src/direct-application-shell-transport.ts +21 -3
- package/packages/daemon-client/src/workspace-event-supervisor.ts +63 -2
- package/packages/tmux-bridge/src/runner.ts +3 -1
|
@@ -43,13 +43,35 @@ export function createApplicationHomeAgentNavigator(options: {
|
|
|
43
43
|
focusFirstPane: boolean,
|
|
44
44
|
admission?: () => boolean,
|
|
45
45
|
) => Promise<ApplicationGenerationStartResult>;
|
|
46
|
-
|
|
46
|
+
/**
|
|
47
|
+
* With `admission`, the selection is registered now and sent to the runtime
|
|
48
|
+
* only if `admission` resolves true. The controller drops input it holds for
|
|
49
|
+
* a refused pane, never delivering it to another pane; in the app the root
|
|
50
|
+
* routes no keys or paste while an agent is opening, so none is held.
|
|
51
|
+
*/
|
|
52
|
+
readonly selectPane: (
|
|
53
|
+
paneId: string,
|
|
54
|
+
source: HomeAgentNavigationSource,
|
|
55
|
+
admission?: Promise<boolean>,
|
|
56
|
+
) => void;
|
|
57
|
+
/**
|
|
58
|
+
* Home's roster can list an agent a moment before the attached session does.
|
|
59
|
+
* Resolves true once `listed()` holds, false on the bound, abort or a
|
|
60
|
+
* different generation (the navigator then refuses as before).
|
|
61
|
+
*/
|
|
62
|
+
readonly waitForAgent?: (
|
|
63
|
+
generationKey: string,
|
|
64
|
+
listed: () => boolean,
|
|
65
|
+
signal: AbortSignal,
|
|
66
|
+
) => Promise<boolean>;
|
|
47
67
|
readonly showTerminals: (source: HomeAgentNavigationSource) => void;
|
|
48
68
|
readonly setNote: (note: string | null) => void;
|
|
49
69
|
}) {
|
|
50
70
|
let navigationToken = 0;
|
|
51
71
|
let disposed = false;
|
|
52
72
|
let admissionController: AbortController | null = null;
|
|
73
|
+
/** The token whose wait note is on screen; cleared with the wait (#764). */
|
|
74
|
+
let waitingNote: number | null = null;
|
|
53
75
|
const active = (token: number) => !disposed && token === navigationToken;
|
|
54
76
|
const failure = (
|
|
55
77
|
token: number,
|
|
@@ -60,12 +82,20 @@ export function createApplicationHomeAgentNavigator(options: {
|
|
|
60
82
|
options.setNote(note);
|
|
61
83
|
return { opened: false, failure: reason };
|
|
62
84
|
};
|
|
63
|
-
const
|
|
85
|
+
const listed = (
|
|
86
|
+
current: HomeAgentNavigationGeneration | null,
|
|
87
|
+
target: HomeAgentNavigationTarget,
|
|
88
|
+
): boolean =>
|
|
89
|
+
!!target.paneId &&
|
|
90
|
+
!!current?.agents.some(
|
|
91
|
+
(agent) => agent.id === target.agentId && agent.paneId === target.paneId,
|
|
92
|
+
);
|
|
93
|
+
/** Every admission check; null admits. Notes are set only for a refusal. */
|
|
94
|
+
const refusal = (
|
|
64
95
|
token: number,
|
|
65
96
|
target: HomeAgentNavigationTarget,
|
|
66
|
-
source: HomeAgentNavigationSource,
|
|
67
97
|
expectedGeneration?: string,
|
|
68
|
-
): HomeAgentNavigationResult => {
|
|
98
|
+
): HomeAgentNavigationResult | null => {
|
|
69
99
|
if (!active(token)) return { opened: false, failure: "superseded" };
|
|
70
100
|
if (!options.isCurrentTarget(target))
|
|
71
101
|
return failure(
|
|
@@ -87,18 +117,63 @@ export function createApplicationHomeAgentNavigator(options: {
|
|
|
87
117
|
"The session changed while opening that agent. Return Home and retry.",
|
|
88
118
|
);
|
|
89
119
|
}
|
|
90
|
-
if (
|
|
91
|
-
!target.paneId ||
|
|
92
|
-
!current.agents.some((agent) => agent.id === target.agentId && agent.paneId === target.paneId)
|
|
93
|
-
)
|
|
120
|
+
if (!listed(current, target))
|
|
94
121
|
return failure(
|
|
95
122
|
token,
|
|
96
123
|
"pane-removed",
|
|
97
124
|
"That exact agent terminal is no longer available. Return Home and select another agent.",
|
|
98
125
|
);
|
|
126
|
+
return null;
|
|
127
|
+
};
|
|
128
|
+
const admit = (
|
|
129
|
+
token: number,
|
|
130
|
+
target: HomeAgentNavigationTarget,
|
|
131
|
+
source: HomeAgentNavigationSource,
|
|
132
|
+
expectedGeneration?: string,
|
|
133
|
+
): HomeAgentNavigationResult => {
|
|
134
|
+
const refused = refusal(token, target, expectedGeneration);
|
|
135
|
+
if (refused) return refused;
|
|
99
136
|
// Synchronous on the warm path: selection precedes surface visibility and
|
|
100
137
|
// the next input event. The existing terminal owner remains the only input path.
|
|
101
|
-
options.selectPane(target.paneId
|
|
138
|
+
options.selectPane(target.paneId!, source);
|
|
139
|
+
options.showTerminals(source);
|
|
140
|
+
options.setNote(null);
|
|
141
|
+
return { opened: true };
|
|
142
|
+
};
|
|
143
|
+
/**
|
|
144
|
+
* The warm path when Home lists an agent the attached session doesn't yet
|
|
145
|
+
* (#764): register the selection now, wait (bounded) for the session to list
|
|
146
|
+
* exactly this agent on this pane, then run every admission check again.
|
|
147
|
+
* The selection reaches the runtime only if this admits. The root ignores
|
|
148
|
+
* keys and paste while an agent is opening, so input typed during the wait
|
|
149
|
+
* is dropped; the note says why nothing happens yet.
|
|
150
|
+
*/
|
|
151
|
+
const admitWhenListed = async (
|
|
152
|
+
token: number,
|
|
153
|
+
target: HomeAgentNavigationTarget,
|
|
154
|
+
source: HomeAgentNavigationSource,
|
|
155
|
+
generationKey: string,
|
|
156
|
+
waitForAgent: NonNullable<typeof options.waitForAgent>,
|
|
157
|
+
signal: AbortSignal,
|
|
158
|
+
): Promise<HomeAgentNavigationResult> => {
|
|
159
|
+
let settle!: (admitted: boolean) => void;
|
|
160
|
+
const admission = new Promise<boolean>((resolve) => {
|
|
161
|
+
settle = resolve;
|
|
162
|
+
});
|
|
163
|
+
options.selectPane(target.paneId!, source, admission);
|
|
164
|
+
// The cold path's "Opening agent in …" note, for the warm wait.
|
|
165
|
+
options.setNote(`Waiting for agent in ${target.sessionName}…`);
|
|
166
|
+
waitingNote = token;
|
|
167
|
+
try {
|
|
168
|
+
await waitForAgent(generationKey, () => listed(options.currentGeneration(), target), signal);
|
|
169
|
+
} catch {
|
|
170
|
+
// A failed wait is a refusal below, never an admission.
|
|
171
|
+
}
|
|
172
|
+
if (waitingNote === token) waitingNote = null;
|
|
173
|
+
// A refusal replaces the note; an admission clears it below.
|
|
174
|
+
const refused = refusal(token, target, generationKey);
|
|
175
|
+
settle(refused === null);
|
|
176
|
+
if (refused) return refused;
|
|
102
177
|
options.showTerminals(source);
|
|
103
178
|
options.setNote(null);
|
|
104
179
|
return { opened: true };
|
|
@@ -112,6 +187,8 @@ export function createApplicationHomeAgentNavigator(options: {
|
|
|
112
187
|
admissionController?.abort();
|
|
113
188
|
const controller = new AbortController();
|
|
114
189
|
admissionController = controller;
|
|
190
|
+
// This navigation sets its own note.
|
|
191
|
+
waitingNote = null;
|
|
115
192
|
const token = ++navigationToken;
|
|
116
193
|
try {
|
|
117
194
|
if (!target.paneId)
|
|
@@ -122,8 +199,27 @@ export function createApplicationHomeAgentNavigator(options: {
|
|
|
122
199
|
"stale-target",
|
|
123
200
|
"That agent changed or disappeared. Select it again on Home.",
|
|
124
201
|
);
|
|
125
|
-
|
|
202
|
+
const attached = options.currentGeneration();
|
|
203
|
+
if (attached?.sessionName === target.sessionName) {
|
|
204
|
+
if (
|
|
205
|
+
options.waitForAgent &&
|
|
206
|
+
attached.daemonInstanceId === target.daemonInstanceId &&
|
|
207
|
+
attached.liveSessionId === target.liveSessionId &&
|
|
208
|
+
!listed(attached, target)
|
|
209
|
+
) {
|
|
210
|
+
// The same session, just not listing this agent yet: possibly a
|
|
211
|
+
// moment behind Home. Refused as before if the wait ends without it.
|
|
212
|
+
return admitWhenListed(
|
|
213
|
+
token,
|
|
214
|
+
target,
|
|
215
|
+
source,
|
|
216
|
+
attached.generationKey,
|
|
217
|
+
options.waitForAgent,
|
|
218
|
+
controller.signal,
|
|
219
|
+
);
|
|
220
|
+
}
|
|
126
221
|
return admit(token, target, source);
|
|
222
|
+
}
|
|
127
223
|
options.setNote(`Opening agent in ${target.sessionName}…`);
|
|
128
224
|
// Never briefly focus the first pane of the newly opened session.
|
|
129
225
|
const opened = await options.startGeneration(target.sessionName, false, source, false, () =>
|
|
@@ -164,6 +260,10 @@ export function createApplicationHomeAgentNavigator(options: {
|
|
|
164
260
|
cancel() {
|
|
165
261
|
navigationToken += 1;
|
|
166
262
|
admissionController?.abort();
|
|
263
|
+
if (waitingNote !== null) {
|
|
264
|
+
waitingNote = null;
|
|
265
|
+
options.setNote(null);
|
|
266
|
+
}
|
|
167
267
|
},
|
|
168
268
|
dispose() {
|
|
169
269
|
disposed = true;
|
|
@@ -53,12 +53,43 @@ export function waitForHomeAgentSemantic(
|
|
|
53
53
|
generation: () => OpenTuiGenerationHostSnapshot | null,
|
|
54
54
|
expectedKey: string,
|
|
55
55
|
signal: AbortSignal,
|
|
56
|
+
): Promise<boolean> {
|
|
57
|
+
const client = generation()?.client;
|
|
58
|
+
return waitForHomeAgentGeneration(
|
|
59
|
+
generation,
|
|
60
|
+
expectedKey,
|
|
61
|
+
() => Boolean(client?.getSnapshot().semantic),
|
|
62
|
+
signal,
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Waits, bounded, until the attached generation `expectedKey` lists an agent
|
|
68
|
+
* (`listed`), or until the generation changes, the bound passes or `signal`
|
|
69
|
+
* aborts (#764: Home can list an agent before the attached session does).
|
|
70
|
+
*/
|
|
71
|
+
export function waitForHomeAgentListed(
|
|
72
|
+
generation: () => OpenTuiGenerationHostSnapshot | null,
|
|
73
|
+
expectedKey: string,
|
|
74
|
+
listed: () => boolean,
|
|
75
|
+
signal: AbortSignal,
|
|
76
|
+
): Promise<boolean> {
|
|
77
|
+
return waitForHomeAgentGeneration(generation, expectedKey, listed, signal);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** The bound both waits share: the cold path's own 5 s. */
|
|
81
|
+
export const HOME_AGENT_WAIT_MS = 5_000;
|
|
82
|
+
|
|
83
|
+
function waitForHomeAgentGeneration(
|
|
84
|
+
generation: () => OpenTuiGenerationHostSnapshot | null,
|
|
85
|
+
expectedKey: string,
|
|
86
|
+
satisfied: () => boolean,
|
|
87
|
+
signal: AbortSignal,
|
|
56
88
|
): Promise<boolean> {
|
|
57
89
|
const client = generation()?.client;
|
|
58
90
|
if (!client || signal.aborted) return Promise.resolve(false);
|
|
59
91
|
const ready = () =>
|
|
60
|
-
applicationGenerationNavigationKey(generation()) !== expectedKey ||
|
|
61
|
-
Boolean(client.getSnapshot().semantic);
|
|
92
|
+
applicationGenerationNavigationKey(generation()) !== expectedKey || satisfied();
|
|
62
93
|
// A changed generation is settled, not admitted: the navigator revalidates it.
|
|
63
94
|
if (ready()) return Promise.resolve(true);
|
|
64
95
|
return new Promise((resolve) => {
|
|
@@ -76,7 +107,7 @@ export function waitForHomeAgentSemantic(
|
|
|
76
107
|
const check = () => {
|
|
77
108
|
if (ready()) finish(true);
|
|
78
109
|
};
|
|
79
|
-
const timeout = setTimeout(() => finish(false),
|
|
110
|
+
const timeout = setTimeout(() => finish(false), HOME_AGENT_WAIT_MS);
|
|
80
111
|
signal.addEventListener("abort", abort, { once: true });
|
|
81
112
|
// subscribe may synchronously deliver its current projection.
|
|
82
113
|
for (const scope of ["semantic", "lifecycle"] as const) {
|
|
@@ -90,6 +121,19 @@ export function waitForHomeAgentSemantic(
|
|
|
90
121
|
});
|
|
91
122
|
}
|
|
92
123
|
|
|
124
|
+
/**
|
|
125
|
+
* While an agent opens, it owns the keyboard: other keys are ignored and Esc
|
|
126
|
+
* cancels the open (#764: the warm wait can last 5 s). True when it owns `name`.
|
|
127
|
+
*/
|
|
128
|
+
export function agentOpeningOwnsKey(
|
|
129
|
+
name: string,
|
|
130
|
+
opener: { opening(): boolean; cancel(): void },
|
|
131
|
+
): boolean {
|
|
132
|
+
if (!opener.opening()) return false;
|
|
133
|
+
if (name === "escape") opener.cancel();
|
|
134
|
+
return true;
|
|
135
|
+
}
|
|
136
|
+
|
|
93
137
|
/** Resident feature composition: observation, selection, and navigation have separate owners. */
|
|
94
138
|
export function createApplicationHomeAgentsOwner(options: {
|
|
95
139
|
readonly catalog: Accessor<ApplicationHomeCatalogSnapshot>;
|
|
@@ -98,7 +142,7 @@ export function createApplicationHomeAgentsOwner(options: {
|
|
|
98
142
|
readonly generation: () => OpenTuiGenerationHostSnapshot | null;
|
|
99
143
|
readonly sessionName: () => string | null;
|
|
100
144
|
readonly startGeneration: ReturnType<typeof createApplicationGenerationStarter>;
|
|
101
|
-
readonly selectPane: (paneId: string) => void;
|
|
145
|
+
readonly selectPane: (paneId: string, admission?: Promise<boolean>) => void;
|
|
102
146
|
readonly showTerminals: (source: "keyboard" | "mouse") => void;
|
|
103
147
|
readonly restoreHome?: (source: "keyboard" | "mouse") => Promise<void> | void;
|
|
104
148
|
readonly setNote: (note: string | null) => void;
|
|
@@ -138,10 +182,13 @@ export function createApplicationHomeAgentsOwner(options: {
|
|
|
138
182
|
};
|
|
139
183
|
},
|
|
140
184
|
waitForGeneration: (key, signal) => waitForHomeAgentSemantic(options.generation, key, signal),
|
|
185
|
+
waitForAgent: (key, listed, signal) =>
|
|
186
|
+
waitForHomeAgentListed(options.generation, key, listed, signal),
|
|
141
187
|
startGeneration: options.startGeneration,
|
|
142
188
|
// The existing pane input router is source-neutral. Session/surface intents
|
|
143
189
|
// above retain keyboard vs pointer provenance without inventing a second router.
|
|
144
|
-
selectPane: (paneId) =>
|
|
190
|
+
selectPane: (paneId, _source, admission) =>
|
|
191
|
+
admission ? options.selectPane(paneId, admission) : options.selectPane(paneId),
|
|
145
192
|
showTerminals: options.showTerminals,
|
|
146
193
|
setNote: options.setNote,
|
|
147
194
|
});
|
|
@@ -202,7 +249,12 @@ export function createApplicationHomeAgentsOwner(options: {
|
|
|
202
249
|
observer.dispose();
|
|
203
250
|
selection.dispose();
|
|
204
251
|
});
|
|
205
|
-
return {
|
|
252
|
+
return {
|
|
253
|
+
presentation,
|
|
254
|
+
opening,
|
|
255
|
+
cancel,
|
|
256
|
+
ownsKey: (name: string) => agentOpeningOwnsKey(name, { opening, cancel }),
|
|
257
|
+
};
|
|
206
258
|
}
|
|
207
259
|
|
|
208
260
|
/** Compose Home navigation with competing chrome intents; physical input stays in the root. */
|
|
@@ -5,7 +5,11 @@ import {
|
|
|
5
5
|
type HomeAgentNavigationTarget,
|
|
6
6
|
} from "./application-home-agent-navigation.ts";
|
|
7
7
|
import { applicationGenerationNavigationKey } from "./application-generation-starter.ts";
|
|
8
|
-
import {
|
|
8
|
+
import {
|
|
9
|
+
agentOpeningOwnsKey,
|
|
10
|
+
waitForHomeAgentListed,
|
|
11
|
+
waitForHomeAgentSemantic,
|
|
12
|
+
} from "./application-home-agents-owner.ts";
|
|
9
13
|
import type { OpenTuiGenerationHostSnapshot } from "./open-tui-generation-host.ts";
|
|
10
14
|
|
|
11
15
|
type HomeNavigatorOptions = Parameters<typeof createApplicationHomeAgentNavigator>[0];
|
|
@@ -19,7 +23,8 @@ export function createApplicationMachineAgentNavigator(options: {
|
|
|
19
23
|
readonly generation: () => OpenTuiGenerationHostSnapshot | null;
|
|
20
24
|
readonly sessionName: () => string | null;
|
|
21
25
|
readonly startGeneration: HomeNavigatorOptions["startGeneration"];
|
|
22
|
-
|
|
26
|
+
/** The interaction controller's selectPane: `admission` must reach it (#764). */
|
|
27
|
+
readonly selectPane: (paneId: string, admission?: Promise<boolean>) => void;
|
|
23
28
|
readonly showTerminals: HomeNavigatorOptions["showTerminals"];
|
|
24
29
|
readonly setNote: HomeNavigatorOptions["setNote"];
|
|
25
30
|
}) {
|
|
@@ -27,6 +32,11 @@ export function createApplicationMachineAgentNavigator(options: {
|
|
|
27
32
|
let disposed = false;
|
|
28
33
|
let opening = false;
|
|
29
34
|
let request = 0;
|
|
35
|
+
const cancel = () => {
|
|
36
|
+
request++;
|
|
37
|
+
opening = false;
|
|
38
|
+
current?.cancel();
|
|
39
|
+
};
|
|
30
40
|
return {
|
|
31
41
|
open(
|
|
32
42
|
machineId: string,
|
|
@@ -48,7 +58,7 @@ export function createApplicationMachineAgentNavigator(options: {
|
|
|
48
58
|
) {
|
|
49
59
|
// Reserve before the next key; the terminal controller waits for a fresh
|
|
50
60
|
// coherent runtime and remains the only owner of physical input.
|
|
51
|
-
options.selectPane(target.paneId
|
|
61
|
+
options.selectPane(target.paneId!);
|
|
52
62
|
options.showTerminals(source);
|
|
53
63
|
options.setNote(null);
|
|
54
64
|
opening = false;
|
|
@@ -72,6 +82,8 @@ export function createApplicationMachineAgentNavigator(options: {
|
|
|
72
82
|
};
|
|
73
83
|
},
|
|
74
84
|
waitForGeneration: (key, signal) => waitForHomeAgentSemantic(generation, key, signal),
|
|
85
|
+
waitForAgent: (key, listed, signal) =>
|
|
86
|
+
waitForHomeAgentListed(generation, key, listed, signal),
|
|
75
87
|
startGeneration: (session, prepared, origin, focus, admission) =>
|
|
76
88
|
options.startGeneration(
|
|
77
89
|
session,
|
|
@@ -81,7 +93,8 @@ export function createApplicationMachineAgentNavigator(options: {
|
|
|
81
93
|
() =>
|
|
82
94
|
selected() && options.isCurrentTarget(machineId, target) && (admission?.() ?? true),
|
|
83
95
|
),
|
|
84
|
-
selectPane:
|
|
96
|
+
selectPane: (paneId, _source, admission) =>
|
|
97
|
+
admission ? options.selectPane(paneId, admission) : options.selectPane(paneId),
|
|
85
98
|
showTerminals: options.showTerminals,
|
|
86
99
|
setNote: options.setNote,
|
|
87
100
|
});
|
|
@@ -90,11 +103,9 @@ export function createApplicationMachineAgentNavigator(options: {
|
|
|
90
103
|
});
|
|
91
104
|
},
|
|
92
105
|
opening: () => opening,
|
|
93
|
-
cancel
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
current?.cancel();
|
|
97
|
-
},
|
|
106
|
+
cancel,
|
|
107
|
+
/** Esc cancels an open in progress; other keys are ignored meanwhile. */
|
|
108
|
+
ownsKey: (name: string) => agentOpeningOwnsKey(name, { opening: () => opening, cancel }),
|
|
98
109
|
dispose() {
|
|
99
110
|
disposed = true;
|
|
100
111
|
request++;
|
|
@@ -367,7 +367,7 @@ export async function startApplicationRoot(options: StartApplicationRootOptions
|
|
|
367
367
|
generation,
|
|
368
368
|
sessionName: () => sessionOwner?.sessionName() ?? null,
|
|
369
369
|
startGeneration,
|
|
370
|
-
selectPane:
|
|
370
|
+
selectPane: interaction.selectPane,
|
|
371
371
|
showTerminals: () => setSurface("terminals"),
|
|
372
372
|
setNote: setTransientNote,
|
|
373
373
|
});
|
|
@@ -484,7 +484,7 @@ export async function startApplicationRoot(options: StartApplicationRootOptions
|
|
|
484
484
|
else paletteCommands.setOpen(chromeAction === "palette-open", "keyboard");
|
|
485
485
|
return;
|
|
486
486
|
}
|
|
487
|
-
if (homeAgents?.
|
|
487
|
+
if (homeAgents?.ownsKey(name) || machineAgentNavigator?.ownsKey(name)) return;
|
|
488
488
|
if (
|
|
489
489
|
activeSurface() === "terminals" &&
|
|
490
490
|
shell().semantic === null &&
|