tmux-ide 2.9.20 → 2.9.22

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.
Files changed (145) hide show
  1. package/bin/cli.js +16998 -4283
  2. package/package.json +3 -2
  3. package/packages/contracts/src/command-catalog.ts +116 -0
  4. package/packages/contracts/src/commands.ts +5 -4
  5. package/packages/contracts/src/daemon-events.ts +2 -1
  6. package/packages/contracts/src/index.ts +3 -0
  7. package/packages/contracts/src/pane-reader.ts +121 -0
  8. package/packages/contracts/src/pane-stream.ts +18 -0
  9. package/packages/contracts/src/plain-text.ts +61 -0
  10. package/packages/contracts/src/visual-theme-presets.ts +58 -2
  11. package/packages/daemon/dist/command-center/command-catalog-routes.js +78 -0
  12. package/packages/daemon/dist/command-center/plugin-routes.js +84 -0
  13. package/packages/daemon/dist/command-center/server.js +13 -0
  14. package/packages/daemon/dist/command-center/tmux-server-reader.js +41 -0
  15. package/packages/daemon/dist/command-center/tmux-servers.js +6 -0
  16. package/packages/daemon/dist/doctor.js +106 -43
  17. package/packages/daemon/dist/lib/cli-action-bridge.js +15 -0
  18. package/packages/daemon/dist/lib/cli-command.js +13 -0
  19. package/packages/daemon/dist/lib/daemon-embed.js +39 -1
  20. package/packages/daemon/dist/lib/headless-daemon.js +1 -0
  21. package/packages/daemon/dist/lib/pane-reader-files.js +226 -0
  22. package/packages/daemon/dist/lib/remote-tmux-command.js +8 -5
  23. package/packages/daemon/dist/lib/tmux-client-execution.js +73 -7
  24. package/packages/daemon/dist/lib/tmux-pane-reader.js +105 -0
  25. package/packages/daemon/dist/lib/tmux-server-features.js +38 -0
  26. package/packages/daemon/dist/lib/tmux-server-owner.js +9 -0
  27. package/packages/daemon/dist/lib/worktree.js +18 -0
  28. package/packages/daemon/dist/native/TmuxIdeNotifier.app/Contents/Info.plist +2 -2
  29. package/packages/daemon/dist/native/TmuxIdeNotifier.app/Contents/MacOS/tmux-ide-notifier +0 -0
  30. package/packages/daemon/dist/native/TmuxIdeNotifier.app/Contents/Resources/Assets.car +0 -0
  31. package/packages/daemon/dist/native/TmuxIdeNotifier.app/Contents/_CodeSignature/CodeResources +2 -2
  32. package/packages/daemon/dist/open-browser.js +26 -12
  33. package/packages/daemon/dist/open-reader.js +84 -0
  34. package/packages/daemon/dist/plugins/action-catalog.js +129 -0
  35. package/packages/daemon/dist/plugins/action-cli.js +212 -0
  36. package/packages/daemon/dist/plugins/api-table.js +303 -0
  37. package/packages/daemon/dist/plugins/cli.js +556 -0
  38. package/packages/daemon/dist/plugins/consent.js +107 -0
  39. package/packages/daemon/dist/plugins/daemon-plugins.js +124 -0
  40. package/packages/daemon/dist/plugins/discovery.js +142 -0
  41. package/packages/daemon/dist/plugins/examples/worktree-tasks.js +115 -0
  42. package/packages/daemon/dist/plugins/exec-sandbox.js +202 -0
  43. package/packages/daemon/dist/plugins/host/actions-prelude.js +279 -0
  44. package/packages/daemon/dist/plugins/host/entry.js +4 -0
  45. package/packages/daemon/dist/plugins/host/host-api-prelude.js +232 -0
  46. package/packages/daemon/dist/plugins/host/lua-state.js +493 -0
  47. package/packages/daemon/dist/plugins/host/main.js +322 -0
  48. package/packages/daemon/dist/plugins/host/sandbox.js +299 -0
  49. package/packages/daemon/dist/plugins/host-calls.js +279 -0
  50. package/packages/daemon/dist/plugins/manifest.js +69 -0
  51. package/packages/daemon/dist/plugins/plugin-exec.js +261 -0
  52. package/packages/daemon/dist/plugins/plugin-log.js +54 -0
  53. package/packages/daemon/dist/plugins/plugin-store.js +74 -0
  54. package/packages/daemon/dist/plugins/protocol.js +252 -0
  55. package/packages/daemon/dist/plugins/safe-files.js +97 -0
  56. package/packages/daemon/dist/plugins/supervisor.js +790 -0
  57. package/packages/daemon/dist/plugins/worktree-calls.js +154 -0
  58. package/packages/daemon/dist/restore.js +57 -40
  59. package/packages/daemon/dist/terminal/mirror/session-channel.js +4 -1
  60. package/packages/daemon/dist/terminal/pane-stream/pane-stream-websocket.js +12 -3
  61. package/packages/daemon/dist/terminal/protocol/reader-option.js +66 -0
  62. package/packages/daemon/dist/terminal/protocol/session-descriptor-discovery.js +7 -2
  63. package/packages/daemon/dist/tmux-upgrade/cli.js +106 -0
  64. package/packages/daemon/dist/tmux-upgrade/io.js +540 -0
  65. package/packages/daemon/dist/tmux-upgrade/plan.js +238 -0
  66. package/packages/daemon/dist/tmux-upgrade/run.js +199 -0
  67. package/packages/daemon/dist/tui/chrome/snapshot.js +3 -4
  68. package/packages/daemon/dist/tui/mirror/runtime/application-home-agent-navigation.js +64 -4
  69. package/packages/daemon/dist/tui/mirror/runtime/application-home-agents-owner.js +62 -5
  70. package/packages/daemon/dist/tui/mirror/runtime/application-home-experience.js +2 -0
  71. package/packages/daemon/dist/tui/mirror/runtime/application-machine-agent-navigation.js +12 -8
  72. package/packages/daemon/dist/tui/mirror/runtime/application-palette-command-owner.js +30 -2
  73. package/packages/daemon/dist/tui/mirror/runtime/application-plugin-commands.js +152 -0
  74. package/packages/daemon/dist/tui/mirror/runtime/application-plugin-form.js +251 -0
  75. package/packages/daemon/dist/tui/mirror/runtime/application-terminal-interaction-controller.js +125 -111
  76. package/packages/daemon/dist/tui/mirror/workspace/application-command-description.js +14 -0
  77. package/packages/daemon/dist/tui/mirror/workspace/palette-list-layout.js +5 -0
  78. package/packages/daemon/src/command-center/command-catalog-routes.ts +116 -0
  79. package/packages/daemon/src/command-center/plugin-routes.ts +110 -0
  80. package/packages/daemon/src/command-center/server.ts +15 -0
  81. package/packages/daemon/src/command-center/tmux-server-reader.ts +62 -0
  82. package/packages/daemon/src/command-center/tmux-servers.ts +6 -0
  83. package/packages/daemon/src/doctor.ts +118 -45
  84. package/packages/daemon/src/lib/cli-action-bridge.ts +19 -0
  85. package/packages/daemon/src/lib/cli-command.ts +16 -0
  86. package/packages/daemon/src/lib/daemon-embed.ts +59 -0
  87. package/packages/daemon/src/lib/headless-daemon.ts +1 -0
  88. package/packages/daemon/src/lib/pane-reader-files.ts +294 -0
  89. package/packages/daemon/src/lib/remote-tmux-command.ts +13 -6
  90. package/packages/daemon/src/lib/tmux-client-execution.ts +79 -7
  91. package/packages/daemon/src/lib/tmux-pane-reader.ts +144 -0
  92. package/packages/daemon/src/lib/tmux-server-features.ts +43 -0
  93. package/packages/daemon/src/lib/tmux-server-owner.ts +9 -0
  94. package/packages/daemon/src/lib/worktree.ts +16 -0
  95. package/packages/daemon/src/open-browser.ts +59 -18
  96. package/packages/daemon/src/open-reader.ts +148 -0
  97. package/packages/daemon/src/plugins/action-catalog.ts +141 -0
  98. package/packages/daemon/src/plugins/action-cli.ts +248 -0
  99. package/packages/daemon/src/plugins/api-table.ts +346 -0
  100. package/packages/daemon/src/plugins/cli.ts +630 -0
  101. package/packages/daemon/src/plugins/consent.ts +125 -0
  102. package/packages/daemon/src/plugins/daemon-plugins.ts +172 -0
  103. package/packages/daemon/src/plugins/discovery.ts +176 -0
  104. package/packages/daemon/src/plugins/examples/worktree-tasks.ts +120 -0
  105. package/packages/daemon/src/plugins/exec-sandbox.ts +264 -0
  106. package/packages/daemon/src/plugins/host/actions-prelude.ts +280 -0
  107. package/packages/daemon/src/plugins/host/entry.ts +5 -0
  108. package/packages/daemon/src/plugins/host/host-api-prelude.ts +233 -0
  109. package/packages/daemon/src/plugins/host/lua-state.ts +557 -0
  110. package/packages/daemon/src/plugins/host/main.ts +359 -0
  111. package/packages/daemon/src/plugins/host/sandbox.ts +301 -0
  112. package/packages/daemon/src/plugins/host-calls.ts +343 -0
  113. package/packages/daemon/src/plugins/manifest.ts +74 -0
  114. package/packages/daemon/src/plugins/plugin-exec.ts +326 -0
  115. package/packages/daemon/src/plugins/plugin-log.ts +63 -0
  116. package/packages/daemon/src/plugins/plugin-store.ts +80 -0
  117. package/packages/daemon/src/plugins/protocol.ts +275 -0
  118. package/packages/daemon/src/plugins/safe-files.ts +105 -0
  119. package/packages/daemon/src/plugins/supervisor.ts +954 -0
  120. package/packages/daemon/src/plugins/worktree-calls.ts +183 -0
  121. package/packages/daemon/src/restore.ts +80 -44
  122. package/packages/daemon/src/terminal/mirror/events.ts +2 -0
  123. package/packages/daemon/src/terminal/mirror/session-channel.ts +6 -1
  124. package/packages/daemon/src/terminal/pane-stream/pane-stream-websocket.ts +15 -2
  125. package/packages/daemon/src/terminal/protocol/reader-option.ts +77 -0
  126. package/packages/daemon/src/terminal/protocol/session-descriptor-discovery.ts +10 -1
  127. package/packages/daemon/src/tmux-upgrade/cli.ts +118 -0
  128. package/packages/daemon/src/tmux-upgrade/io.ts +596 -0
  129. package/packages/daemon/src/tmux-upgrade/plan.ts +353 -0
  130. package/packages/daemon/src/tmux-upgrade/run.ts +325 -0
  131. package/packages/daemon/src/tui/chrome/snapshot.ts +3 -4
  132. package/packages/daemon/src/tui/mirror/runtime/application-fleet-switcher.tsx +3 -1
  133. package/packages/daemon/src/tui/mirror/runtime/application-home-agent-navigation.ts +110 -10
  134. package/packages/daemon/src/tui/mirror/runtime/application-home-agents-owner.ts +90 -6
  135. package/packages/daemon/src/tui/mirror/runtime/application-home-experience.ts +2 -0
  136. package/packages/daemon/src/tui/mirror/runtime/application-machine-agent-navigation.ts +20 -9
  137. package/packages/daemon/src/tui/mirror/runtime/application-palette-command-owner.ts +42 -2
  138. package/packages/daemon/src/tui/mirror/runtime/application-palette-preview.tsx +7 -1
  139. package/packages/daemon/src/tui/mirror/runtime/application-plugin-commands.ts +229 -0
  140. package/packages/daemon/src/tui/mirror/runtime/application-plugin-form.ts +312 -0
  141. package/packages/daemon/src/tui/mirror/runtime/application-root-v2.tsx +2 -2
  142. package/packages/daemon/src/tui/mirror/runtime/application-terminal-interaction-controller.ts +149 -128
  143. package/packages/daemon/src/tui/mirror/workspace/application-command-description.ts +44 -2
  144. package/packages/daemon/src/tui/mirror/workspace/palette-list-layout.ts +4 -0
  145. package/packages/tmux-bridge/src/runner.ts +3 -1
@@ -45,7 +45,9 @@ export function ApplicationFleetSwitcher(props: {
45
45
  }),
46
46
  );
47
47
  const fallbackRow = (c: ApplicationPaletteCommand) =>
48
- typeof c === "object" ? props.rows.find((r) => r.key === c.sessionName) : undefined;
48
+ typeof c === "object" && "sessionName" in c
49
+ ? props.rows.find((r) => r.key === c.sessionName)
50
+ : undefined;
49
51
  const commands = () =>
50
52
  source().filter(
51
53
  (c) =>
@@ -43,13 +43,35 @@ export function createApplicationHomeAgentNavigator(options: {
43
43
  focusFirstPane: boolean,
44
44
  admission?: () => boolean,
45
45
  ) => Promise<ApplicationGenerationStartResult>;
46
- readonly selectPane: (paneId: string, source: HomeAgentNavigationSource) => void;
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 admit = (
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, source);
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
- if (options.currentGeneration()?.sessionName === target.sessionName)
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;
@@ -20,6 +20,8 @@ import type { OpenTuiSessionOwner } from "./open-tui-session-owner.ts";
20
20
  import type { ApplicationShellBinding } from "./application-shell-binding.ts";
21
21
  import type { createApplicationTerminalInteractionController } from "./application-terminal-interaction-controller.ts";
22
22
  import { createApplicationPaletteCommandOwner } from "./application-palette-command-owner.ts";
23
+ import type { ApplicationPluginCommands } from "./application-plugin-commands.ts";
24
+ import { createApplicationPluginForm, pluginPaletteContext } from "./application-plugin-form.ts";
23
25
  import { createApplicationPaneRenameOwner } from "./application-pane-rename-owner.ts";
24
26
  import {
25
27
  applicationPaletteCommands,
@@ -51,12 +53,43 @@ export function waitForHomeAgentSemantic(
51
53
  generation: () => OpenTuiGenerationHostSnapshot | null,
52
54
  expectedKey: string,
53
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,
54
88
  ): Promise<boolean> {
55
89
  const client = generation()?.client;
56
90
  if (!client || signal.aborted) return Promise.resolve(false);
57
91
  const ready = () =>
58
- applicationGenerationNavigationKey(generation()) !== expectedKey ||
59
- Boolean(client.getSnapshot().semantic);
92
+ applicationGenerationNavigationKey(generation()) !== expectedKey || satisfied();
60
93
  // A changed generation is settled, not admitted: the navigator revalidates it.
61
94
  if (ready()) return Promise.resolve(true);
62
95
  return new Promise((resolve) => {
@@ -74,7 +107,7 @@ export function waitForHomeAgentSemantic(
74
107
  const check = () => {
75
108
  if (ready()) finish(true);
76
109
  };
77
- const timeout = setTimeout(() => finish(false), 5_000);
110
+ const timeout = setTimeout(() => finish(false), HOME_AGENT_WAIT_MS);
78
111
  signal.addEventListener("abort", abort, { once: true });
79
112
  // subscribe may synchronously deliver its current projection.
80
113
  for (const scope of ["semantic", "lifecycle"] as const) {
@@ -88,6 +121,19 @@ export function waitForHomeAgentSemantic(
88
121
  });
89
122
  }
90
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
+
91
137
  /** Resident feature composition: observation, selection, and navigation have separate owners. */
92
138
  export function createApplicationHomeAgentsOwner(options: {
93
139
  readonly catalog: Accessor<ApplicationHomeCatalogSnapshot>;
@@ -96,7 +142,7 @@ export function createApplicationHomeAgentsOwner(options: {
96
142
  readonly generation: () => OpenTuiGenerationHostSnapshot | null;
97
143
  readonly sessionName: () => string | null;
98
144
  readonly startGeneration: ReturnType<typeof createApplicationGenerationStarter>;
99
- readonly selectPane: (paneId: string) => void;
145
+ readonly selectPane: (paneId: string, admission?: Promise<boolean>) => void;
100
146
  readonly showTerminals: (source: "keyboard" | "mouse") => void;
101
147
  readonly restoreHome?: (source: "keyboard" | "mouse") => Promise<void> | void;
102
148
  readonly setNote: (note: string | null) => void;
@@ -136,10 +182,13 @@ export function createApplicationHomeAgentsOwner(options: {
136
182
  };
137
183
  },
138
184
  waitForGeneration: (key, signal) => waitForHomeAgentSemantic(options.generation, key, signal),
185
+ waitForAgent: (key, listed, signal) =>
186
+ waitForHomeAgentListed(options.generation, key, listed, signal),
139
187
  startGeneration: options.startGeneration,
140
188
  // The existing pane input router is source-neutral. Session/surface intents
141
189
  // above retain keyboard vs pointer provenance without inventing a second router.
142
- selectPane: (paneId) => options.selectPane(paneId),
190
+ selectPane: (paneId, _source, admission) =>
191
+ admission ? options.selectPane(paneId, admission) : options.selectPane(paneId),
143
192
  showTerminals: options.showTerminals,
144
193
  setNote: options.setNote,
145
194
  });
@@ -200,7 +249,12 @@ export function createApplicationHomeAgentsOwner(options: {
200
249
  observer.dispose();
201
250
  selection.dispose();
202
251
  });
203
- return { presentation, opening, cancel };
252
+ return {
253
+ presentation,
254
+ opening,
255
+ cancel,
256
+ ownsKey: (name: string) => agentOpeningOwnsKey(name, { opening, cancel }),
257
+ };
204
258
  }
205
259
 
206
260
  /** Compose Home navigation with competing chrome intents; physical input stays in the root. */
@@ -212,6 +266,8 @@ export function createApplicationHomeNavigationOwner(options: {
212
266
  source: "keyboard" | "mouse",
213
267
  ) => Promise<unknown> | void;
214
268
  readonly focusedPane: Accessor<string | null>;
269
+ /** Plugin command source (the local daemon in production); absent means no plugin commands. */
270
+ readonly pluginCommands?: ApplicationPluginCommands;
215
271
  readonly catalog: {
216
272
  readonly snapshot: Accessor<ApplicationHomeCatalogSnapshot>;
217
273
  readonly sessionNames: Accessor<string[]>;
@@ -288,7 +344,31 @@ export function createApplicationHomeNavigationOwner(options: {
288
344
  setNote: options.setNote,
289
345
  observer: options.observer,
290
346
  });
347
+ // Plugin commands come from the local daemon's command catalog; a command
348
+ // with parameters opens a step-by-step form inside the palette.
349
+ const pluginCommands = options.pluginCommands;
350
+ let paletteOwner: ReturnType<typeof createApplicationPaletteCommandOwner> | null = null;
351
+ const pluginForm =
352
+ pluginCommands &&
353
+ createApplicationPluginForm({
354
+ service: pluginCommands,
355
+ context: () =>
356
+ pluginPaletteContext(options.sessionOwner()?.sessionName() ?? null, options.focusedPane()),
357
+ query: () => paletteOwner?.query() ?? "",
358
+ setNote: options.setNote,
359
+ close: () => paletteOwner?.setOpen(false, "keyboard"),
360
+ stepChanged: () => paletteOwner?.resetForStep(),
361
+ });
291
362
  const paletteCommands = createApplicationPaletteCommandOwner({
363
+ ...(pluginCommands && pluginForm
364
+ ? {
365
+ plugins: {
366
+ form: pluginForm,
367
+ refresh: () => void pluginCommands.refresh(),
368
+ watch: () => pluginCommands.watch(),
369
+ },
370
+ }
371
+ : {}),
292
372
  commands: () => [
293
373
  ...(options.fleetCommands
294
374
  ? [
@@ -305,12 +385,15 @@ export function createApplicationHomeNavigationOwner(options: {
305
385
  : ("hide-sidebar" as const),
306
386
  ]
307
387
  : []),
388
+ ...(pluginCommands?.commands() ?? []),
308
389
  ],
309
390
  isOpen: () =>
310
391
  Boolean(options.shell().semantic?.focus.palette.open ?? options.shell().localPaletteOpen),
311
392
  targetKey: () =>
312
393
  `${applicationGenerationNavigationKey(options.sessionOwner()?.snapshot() ?? null)}:${options.focusedPane()}`,
313
394
  disabledReason: (command) => {
395
+ if (typeof command === "object" && command.kind === "plugin-form")
396
+ return command.disabledReason ?? null;
314
397
  if (typeof command === "object" && command.fleet?.disabled)
315
398
  return "Machine or session unavailable";
316
399
  if (
@@ -354,6 +437,7 @@ export function createApplicationHomeNavigationOwner(options: {
354
437
  openSession: (name, source) => options.startGeneration(name, false, source),
355
438
  onNavigationIntent: homeAgents.cancel,
356
439
  });
440
+ paletteOwner = paletteCommands;
357
441
  const paletteCommandList = paletteCommands.commands;
358
442
  return {
359
443
  homeAgents: options.fleetHome ? { ...homeAgents, presentation: options.fleetHome } : homeAgents,
@@ -1,3 +1,4 @@
1
+ import { createApplicationPluginCommands } from "./application-plugin-commands.ts";
1
2
  import { createEffect, type Accessor } from "solid-js";
2
3
  import { createApplicationHomeFleetOwner } from "./application-home-fleet.ts";
3
4
  import { createApplicationHomeNavigationOwner } from "./application-home-agents-owner.ts";
@@ -63,6 +64,7 @@ export function createApplicationHomeExperience(
63
64
  fleetCommands: machines.paletteCommands,
64
65
  openFleet: machines.openPalette,
65
66
  openSessions: () => machines.showSwitcher(false),
67
+ pluginCommands: createApplicationPluginCommands(),
66
68
  });
67
69
  const tour = createLazyApplicationGuidedTour(
68
70
  {
@@ -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 { waitForHomeAgentSemantic } from "./application-home-agents-owner.ts";
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
- readonly selectPane: HomeNavigatorOptions["selectPane"];
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!, source);
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: options.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
- request++;
95
- opening = false;
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++;
@@ -5,6 +5,7 @@ import type { ApplicationPaletteCommand } from "./application-palette-input.ts";
5
5
  import type { ApplicationShellBinding } from "./application-shell-binding.ts";
6
6
  import { applicationPaletteCommands } from "./application-palette-input.ts";
7
7
  import { createApplicationPaletteSearchOwner } from "./application-palette-search-owner.ts";
8
+ import type { ApplicationPluginForm } from "./application-plugin-form.ts";
8
9
 
9
10
  type Source = "keyboard" | "mouse";
10
11
 
@@ -39,14 +40,26 @@ export function createApplicationPaletteCommandOwner(options: {
39
40
  readonly isOpen?: () => boolean;
40
41
  readonly disabledReason?: (command: ApplicationPaletteCommand) => string | null;
41
42
  readonly targetKey?: () => string;
43
+ /** Plugin commands and their parameter form; absent when plugins are unavailable. */
44
+ readonly plugins?: {
45
+ readonly form: ApplicationPluginForm;
46
+ /** Refresh the plugin command list; called whenever the palette opens. */
47
+ readonly refresh: () => void;
48
+ /** Follow catalog changes while the palette is open; returns a stop function. */
49
+ readonly watch?: () => () => void;
50
+ };
42
51
  }) {
43
52
  const [referencePage, setReferencePage] = createSignal<"shortcuts" | "changes" | "help">();
44
53
  const [closeArmed, setCloseArmed] = createSignal(false);
45
54
  const [busy, setBusy] = createSignal(false);
46
55
  let armedTarget: string | undefined;
56
+ let stopWatch: (() => void) | null = null;
47
57
  let openRevision = 0;
58
+ const baseCommands = options.commands ?? (() => applicationPaletteCommands(null));
48
59
  const search = createApplicationPaletteSearchOwner({
49
- commands: options.commands ?? (() => applicationPaletteCommands(null)),
60
+ // While a plugin form is open the list is the current step's entries.
61
+ commands: () =>
62
+ options.plugins?.form.active() ? options.plugins.form.entries() : baseCommands(),
50
63
  open: options.isOpen ?? (() => false),
51
64
  activate: (command, source) => activate(command, source),
52
65
  close: () => setOpen(false, "keyboard"),
@@ -56,7 +69,14 @@ export function createApplicationPaletteCommandOwner(options: {
56
69
  setReferencePage(undefined);
57
70
  openRevision += 1;
58
71
  setCloseArmed(false);
59
- if (open) search.reset(options.activeSurface() === "home" ? 0 : 1);
72
+ options.plugins?.form.cancel();
73
+ stopWatch?.();
74
+ stopWatch = null;
75
+ if (open) {
76
+ options.plugins?.refresh();
77
+ stopWatch = options.plugins?.watch?.() ?? null;
78
+ search.reset(options.activeSurface() === "home" ? 0 : 1);
79
+ }
60
80
  void options.binding
61
81
  .setPaletteOpen(open, options.commandSource(source, "command-palette"))
62
82
  .catch(() => options.setNote("Commands could not be updated. Try again."));
@@ -74,6 +94,22 @@ export function createApplicationPaletteCommandOwner(options: {
74
94
  );
75
95
  return;
76
96
  }
97
+ if (typeof command === "object" && command.kind === "plugin-form") {
98
+ if (command.disabledReason) {
99
+ options.setNote(command.disabledReason);
100
+ return;
101
+ }
102
+ options.plugins?.form.choose(command);
103
+ return;
104
+ }
105
+ if (typeof command === "object" && command.kind === "plugin-command") {
106
+ if (!options.plugins) {
107
+ options.setNote("Plugin commands are unavailable.");
108
+ return;
109
+ }
110
+ options.plugins.form.start(command);
111
+ return;
112
+ }
77
113
  if (command === "switch-session") {
78
114
  if (!options.openSessions) {
79
115
  options.setNote("Session switching is unavailable.");
@@ -192,6 +228,10 @@ export function createApplicationPaletteCommandOwner(options: {
192
228
  };
193
229
  return {
194
230
  ...search,
231
+ keyboardHint: () =>
232
+ options.plugins?.form.active() ? options.plugins.form.hint() : search.keyboardHint(),
233
+ /** Clear the search line and selection for a new form step. */
234
+ resetForStep: () => search.reset(0),
195
235
  referencePage,
196
236
  setReferencePage,
197
237
  busy,
@@ -25,6 +25,12 @@ const rememberWindow = (key: string, window: string) => {
25
25
  };
26
26
 
27
27
  /** F5 browsing is passive and pinned to the highlighted command's exact authority. */
28
+
29
+ const sessionNameOf = (command: unknown): string | undefined =>
30
+ command && typeof command === "object" && "sessionName" in command
31
+ ? String((command as { sessionName: unknown }).sessionName)
32
+ : undefined;
33
+
28
34
  export function ApplicationPalettePreview(props: {
29
35
  command: ApplicationPaletteCommand | undefined;
30
36
  width: number;
@@ -148,7 +154,7 @@ export function ApplicationPalettePreview(props: {
148
154
  const heading = () => {
149
155
  const snapshot = state().snapshot;
150
156
  const window = snapshot?.windows.find((w) => w.id === snapshot.selectedWindowId);
151
- return `${paneId() ? command()?.label + " · " : ""}${target()?.hostLabel ?? "Session preview"} · ${command()?.sessionName ?? "Select a session"}${window ? ` · ${window.index}: ${window.name}` : ""}`;
157
+ return `${paneId() ? command()?.label + " · " : ""}${target()?.hostLabel ?? "Session preview"} · ${sessionNameOf(command()) ?? "Select a session"}${window ? ` · ${window.index}: ${window.name}` : ""}`;
152
158
  };
153
159
  const hostColor = () => {
154
160
  revision();