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
@@ -83,7 +83,13 @@ export interface ApplicationTerminalInteractionController {
83
83
  adoptGeneration(snapshot: OpenTuiGenerationHostSnapshot | null): void;
84
84
  cancelPendingInput(): void;
85
85
  adoptLayout(snapshot: OpenTuiWorkspaceLayoutSnapshot): void;
86
- selectPane(paneId: string): void;
86
+ /**
87
+ * With `admission`, input sent from now on is ordered behind this pane, and
88
+ * the pane is selected only if `admission` resolves true and no later
89
+ * selection replaced it; otherwise that input is dropped, never delivered to
90
+ * another pane. (The app's root sends no input while an agent is opening.)
91
+ */
92
+ selectPane(paneId: string, admission?: Promise<boolean>): void;
87
93
  selectWindowLink(target: WindowLinkTarget): Promise<void>;
88
94
  unlinkWindowLink(target: WindowLinkTarget): Promise<string>;
89
95
  sendInput(
@@ -822,100 +828,118 @@ export function createApplicationTerminalInteractionController(
822
828
  );
823
829
  };
824
830
 
825
- const paneInput = new TerminalPaneInputRouter<{
826
- readonly input: SessionRuntimeTerminalInput;
827
- readonly parserOrigin?: Omit<
828
- TuiTerminalInputOrigin,
829
- "semanticPaneId" | "generation" | "incarnation" | "revision" | "stateHash"
830
- >;
831
- }>({
832
- select: async (paneId): Promise<boolean> => {
833
- finishLinkSelection(false);
834
- const initial = options.generation();
835
- const selectionControl = controlIdentity(initial);
836
- const selectionVersion = paneInput.selectionVersion;
837
- const selectionCurrent = (): boolean =>
838
- paneInput.selectionVersion === selectionVersion &&
839
- sameControl(selectionControl, controlIdentity(selectionGeneration));
840
- const panePresent = () =>
841
- selectionLayout.windows.some((window) => window.panes.some((pane) => pane.pane === paneId));
842
- if (initial?.status === "rebinding") {
843
- // Reserve the optimistic target now, but send its FIRST mutation only
844
- // after this same control connection has a coherent terminal runtime.
845
- const ready = await selectionWaiter.wait(() => {
846
- if (!selectionCurrent()) return false;
847
- const active = selectionGeneration;
848
- if (active?.status !== "live" || observedLayoutEpoch !== active.rendererEpoch)
849
- return "pending";
850
- return panePresent();
851
- });
852
- if (!ready || !selectionCurrent()) return false;
853
- }
854
- const expected = liveSelectionTarget();
855
- let dispatchedRendererEpoch: number | undefined;
856
- const selecting = pendingWindowSwitch;
857
- const operationId = selecting?.traceId;
858
- const selectionFailure: { current: PaneSelectionFailure | null } = { current: null };
859
- const receipt = expected
860
- ? await selectTerminalPane(
861
- expected,
862
- () => {
863
- if (!selectionControl) return liveSelectionTarget();
864
- return sameControl(selectionControl, controlIdentity(options.generation()))
865
- ? expected
866
- : null;
867
- },
868
- paneId,
869
- operationId,
870
- (failure) => {
871
- selectionFailure.current = failure;
872
- },
873
- windowLinkForPane(options.layout(), paneId) ?? undefined,
874
- () => {
875
- dispatchedRendererEpoch = options.generation()?.rendererEpoch;
876
- },
877
- )
878
- : null;
879
- if (
880
- receipt === null &&
881
- selectionFailure.current?.reason === "topology-changed" &&
882
- selectionCurrent()
883
- ) {
884
- // The daemon may have selected the pane before retiring its stream.
885
- // Observe the replacement runtime; never resubmit an uncertain command
886
- // or manufacture an operation receipt. Input still waits on this promise.
887
- const confirmed = await selectionWaiter.wait(() => {
888
- if (!selectionCurrent()) return false;
889
- const active = selectionGeneration;
890
- if (
891
- active?.status !== "live" ||
892
- active.rendererEpoch === dispatchedRendererEpoch ||
893
- observedLayoutEpoch !== active.rendererEpoch
894
- )
895
- return "pending";
896
- if (!panePresent()) return false;
897
- const current = selectionLayout.current;
898
- const activePanes = current?.panes.filter((pane) => pane.active) ?? [];
899
- if (!current?.currentWindow || activePanes.length !== 1) return "pending";
900
- return activePanes[0]?.pane === paneId ? true : "pending";
901
- });
902
- if (selecting && pendingWindowSwitch === selecting) pendingWindowSwitch = null;
903
- return confirmed && selectionCurrent();
904
- }
905
- if (selecting && pendingWindowSwitch === selecting) {
906
- const receiptAtMicros = options.detailedWindowSwitchTiming ? diagnosticNowMicros() : null;
907
- if (selecting.timing) selecting.timing.receiptAtMicros = receiptAtMicros;
908
- selecting.selectionApplied =
909
- receipt?.applied === true &&
910
- receipt.operationId === selecting.traceId &&
911
- receipt.semanticPaneId === selecting.paneId;
912
- diagnose("window-switch-receipt", {
831
+ // The one way a pane selection reaches the runtime (#764: also used once an
832
+ // admitted agent selection settles).
833
+ const selectInRuntime = async (paneId: string): Promise<boolean> => {
834
+ finishLinkSelection(false);
835
+ const initial = options.generation();
836
+ const selectionControl = controlIdentity(initial);
837
+ const selectionVersion = paneInput.selectionVersion;
838
+ const selectionCurrent = (): boolean =>
839
+ paneInput.selectionVersion === selectionVersion &&
840
+ sameControl(selectionControl, controlIdentity(selectionGeneration));
841
+ const panePresent = () =>
842
+ selectionLayout.windows.some((window) => window.panes.some((pane) => pane.pane === paneId));
843
+ if (initial?.status === "rebinding") {
844
+ // Reserve the optimistic target now, but send its FIRST mutation only
845
+ // after this same control connection has a coherent terminal runtime.
846
+ const ready = await selectionWaiter.wait(() => {
847
+ if (!selectionCurrent()) return false;
848
+ const active = selectionGeneration;
849
+ if (active?.status !== "live" || observedLayoutEpoch !== active.rendererEpoch)
850
+ return "pending";
851
+ return panePresent();
852
+ });
853
+ if (!ready || !selectionCurrent()) return false;
854
+ }
855
+ const expected = liveSelectionTarget();
856
+ let dispatchedRendererEpoch: number | undefined;
857
+ const selecting = pendingWindowSwitch;
858
+ const operationId = selecting?.traceId;
859
+ const selectionFailure: { current: PaneSelectionFailure | null } = { current: null };
860
+ const receipt = expected
861
+ ? await selectTerminalPane(
862
+ expected,
863
+ () => {
864
+ if (!selectionControl) return liveSelectionTarget();
865
+ return sameControl(selectionControl, controlIdentity(options.generation()))
866
+ ? expected
867
+ : null;
868
+ },
869
+ paneId,
870
+ operationId,
871
+ (failure) => {
872
+ selectionFailure.current = failure;
873
+ },
874
+ windowLinkForPane(options.layout(), paneId) ?? undefined,
875
+ () => {
876
+ dispatchedRendererEpoch = options.generation()?.rendererEpoch;
877
+ },
878
+ )
879
+ : null;
880
+ if (
881
+ receipt === null &&
882
+ selectionFailure.current?.reason === "topology-changed" &&
883
+ selectionCurrent()
884
+ ) {
885
+ // The daemon may have selected the pane before retiring its stream.
886
+ // Observe the replacement runtime; never resubmit an uncertain command
887
+ // or manufacture an operation receipt. Input still waits on this promise.
888
+ const confirmed = await selectionWaiter.wait(() => {
889
+ if (!selectionCurrent()) return false;
890
+ const active = selectionGeneration;
891
+ if (
892
+ active?.status !== "live" ||
893
+ active.rendererEpoch === dispatchedRendererEpoch ||
894
+ observedLayoutEpoch !== active.rendererEpoch
895
+ )
896
+ return "pending";
897
+ if (!panePresent()) return false;
898
+ const current = selectionLayout.current;
899
+ const activePanes = current?.panes.filter((pane) => pane.active) ?? [];
900
+ if (!current?.currentWindow || activePanes.length !== 1) return "pending";
901
+ return activePanes[0]?.pane === paneId ? true : "pending";
902
+ });
903
+ if (selecting && pendingWindowSwitch === selecting) pendingWindowSwitch = null;
904
+ return confirmed && selectionCurrent();
905
+ }
906
+ if (selecting && pendingWindowSwitch === selecting) {
907
+ const receiptAtMicros = options.detailedWindowSwitchTiming ? diagnosticNowMicros() : null;
908
+ if (selecting.timing) selecting.timing.receiptAtMicros = receiptAtMicros;
909
+ selecting.selectionApplied =
910
+ receipt?.applied === true &&
911
+ receipt.operationId === selecting.traceId &&
912
+ receipt.semanticPaneId === selecting.paneId;
913
+ diagnose("window-switch-receipt", {
914
+ traceId: selecting.traceId,
915
+ target: selecting.target,
916
+ paneId: selecting.paneId,
917
+ operationId: receipt?.operationId ?? null,
918
+ selected: receipt !== null,
919
+ applied: receipt?.applied === true,
920
+ daemonGeneration: selecting.daemonGeneration,
921
+ clientGeneration: selecting.clientGeneration,
922
+ rendererEpoch: selecting.rendererEpoch,
923
+ sourceEpoch: selecting.sourceEpoch,
924
+ generation: selecting.generation,
925
+ incarnation: selecting.incarnation,
926
+ revision: selecting.revision,
927
+ stateHash: selecting.stateHash,
928
+ cols: selecting.cols,
929
+ rows: selecting.rows,
930
+ failureStage: selectionFailure.current?.stage ?? (expected ? null : "pre-dispatch"),
931
+ failureReason:
932
+ selectionFailure.current?.reason ?? (expected ? null : "generation-replaced"),
933
+ failureBackendReason: selectionFailure.current?.backendReason ?? null,
934
+ durationMicros:
935
+ receiptAtMicros === null ? null : receiptAtMicros - selecting.startedAtMicros,
936
+ ...(receiptAtMicros === null ? {} : { phaseAtMicros: receiptAtMicros }),
937
+ });
938
+ if (!selecting.selectionApplied) {
939
+ diagnoseCritical(`window-switch:${selecting.traceId}:failed`, "window-switch-failed", {
913
940
  traceId: selecting.traceId,
914
941
  target: selecting.target,
915
942
  paneId: selecting.paneId,
916
- operationId: receipt?.operationId ?? null,
917
- selected: receipt !== null,
918
- applied: receipt?.applied === true,
919
943
  daemonGeneration: selecting.daemonGeneration,
920
944
  clientGeneration: selecting.clientGeneration,
921
945
  rendererEpoch: selecting.rendererEpoch,
@@ -926,44 +950,29 @@ export function createApplicationTerminalInteractionController(
926
950
  stateHash: selecting.stateHash,
927
951
  cols: selecting.cols,
928
952
  rows: selecting.rows,
929
- failureStage: selectionFailure.current?.stage ?? (expected ? null : "pre-dispatch"),
930
- failureReason:
931
- selectionFailure.current?.reason ?? (expected ? null : "generation-replaced"),
932
- failureBackendReason: selectionFailure.current?.backendReason ?? null,
953
+ stage: selectionFailure.current?.stage ?? (expected ? "receipt" : "pre-dispatch"),
954
+ reason:
955
+ selectionFailure.current?.reason ??
956
+ (expected ? "receipt-invalid" : "generation-replaced"),
957
+ backendReason: selectionFailure.current?.backendReason ?? null,
933
958
  durationMicros:
934
959
  receiptAtMicros === null ? null : receiptAtMicros - selecting.startedAtMicros,
935
- ...(receiptAtMicros === null ? {} : { phaseAtMicros: receiptAtMicros }),
936
960
  });
937
- if (!selecting.selectionApplied) {
938
- diagnoseCritical(`window-switch:${selecting.traceId}:failed`, "window-switch-failed", {
939
- traceId: selecting.traceId,
940
- target: selecting.target,
941
- paneId: selecting.paneId,
942
- daemonGeneration: selecting.daemonGeneration,
943
- clientGeneration: selecting.clientGeneration,
944
- rendererEpoch: selecting.rendererEpoch,
945
- sourceEpoch: selecting.sourceEpoch,
946
- generation: selecting.generation,
947
- incarnation: selecting.incarnation,
948
- revision: selecting.revision,
949
- stateHash: selecting.stateHash,
950
- cols: selecting.cols,
951
- rows: selecting.rows,
952
- stage: selectionFailure.current?.stage ?? (expected ? "receipt" : "pre-dispatch"),
953
- reason:
954
- selectionFailure.current?.reason ??
955
- (expected ? "receipt-invalid" : "generation-replaced"),
956
- backendReason: selectionFailure.current?.backendReason ?? null,
957
- durationMicros:
958
- receiptAtMicros === null ? null : receiptAtMicros - selecting.startedAtMicros,
959
- });
960
- pendingWindowSwitch = null;
961
- return false;
962
- }
963
- maybeRequestWindowSwitchFrame();
961
+ pendingWindowSwitch = null;
962
+ return false;
964
963
  }
965
- return receipt !== null;
966
- },
964
+ maybeRequestWindowSwitchFrame();
965
+ }
966
+ return receipt !== null;
967
+ };
968
+ const paneInput = new TerminalPaneInputRouter<{
969
+ readonly input: SessionRuntimeTerminalInput;
970
+ readonly parserOrigin?: Omit<
971
+ TuiTerminalInputOrigin,
972
+ "semanticPaneId" | "generation" | "incarnation" | "revision" | "stateHash"
973
+ >;
974
+ }>({
975
+ select: (paneId) => selectInRuntime(paneId),
967
976
  send: async (paneId, routed) => {
968
977
  const { input, parserOrigin } = routed;
969
978
  const selectionVersion = paneInput.selectionVersion;
@@ -1229,9 +1238,21 @@ export function createApplicationTerminalInteractionController(
1229
1238
  maybeRequestWindowSwitchFrame();
1230
1239
  maybeRequestPaneResizeFrame();
1231
1240
  },
1232
- selectPane: (paneId) => {
1241
+ selectPane: (paneId, admission) => {
1233
1242
  finishLinkSelection(false);
1234
- paneInput.selectPane(paneId);
1243
+ if (admission)
1244
+ // Ordered now; selected only once admitted, otherwise held input drops.
1245
+ paneInput.selectPane(paneId, {
1246
+ presentOptimistically: false,
1247
+ selection: () => {
1248
+ // A later selection supersedes this one: never select it after all.
1249
+ const version = paneInput.selectionVersion;
1250
+ return admission.then((admitted) =>
1251
+ admitted && paneInput.selectionVersion === version ? selectInRuntime(paneId) : false,
1252
+ );
1253
+ },
1254
+ });
1255
+ else paneInput.selectPane(paneId);
1235
1256
  selectionWaiter.reconcile();
1236
1257
  },
1237
1258
  async unlinkWindowLink(target) {
@@ -1,5 +1,5 @@
1
1
  import { CHROME_ACTIONS } from "./application-action-descriptions.ts";
2
- import type { TmuxServerScope } from "@tmux-ide/contracts";
2
+ import { terminalSafe, type CommandParam, type TmuxServerScope } from "@tmux-ide/contracts";
3
3
  import { fuzzyTermsMatch as commandSearchMatch } from "../../team/fuzzy.ts";
4
4
  export { fuzzyTermsMatch as commandSearchMatch } from "../../team/fuzzy.ts";
5
5
  import { PANE_ACTION_MENU_ITEMS } from "./pane-action-menu-model.ts";
@@ -37,6 +37,30 @@ export interface ApplicationMachinePaletteCommand {
37
37
  readonly fleet: FleetPaletteTarget;
38
38
  }
39
39
 
40
+ /** A command a plugin registered, from the daemon's command catalog. */
41
+ export interface ApplicationPluginPaletteCommand {
42
+ readonly kind: "plugin-command";
43
+ readonly fleet?: undefined;
44
+ /** Catalog id, `plugin.<plugin>.<id>`. */
45
+ readonly id: string;
46
+ readonly label: string;
47
+ readonly category: string;
48
+ readonly plugin: string;
49
+ readonly dangerous: boolean;
50
+ readonly params: readonly CommandParam[];
51
+ }
52
+
53
+ /** One choice in the step-by-step form a plugin command with parameters opens. */
54
+ export interface ApplicationPluginFormPaletteCommand {
55
+ readonly kind: "plugin-form";
56
+ readonly fleet?: undefined;
57
+ /** Unique within the current form step. */
58
+ readonly key: string;
59
+ readonly label: string;
60
+ readonly detail: string;
61
+ readonly disabledReason?: string;
62
+ }
63
+
40
64
  export type ApplicationPaletteCommand =
41
65
  | "hide-sidebar"
42
66
  | "show-sidebar"
@@ -55,7 +79,9 @@ export type ApplicationPaletteCommand =
55
79
  | "close-pane"
56
80
  | ApplicationMachinePaletteCommand
57
81
  | ApplicationAgentPaletteCommand
58
- | ApplicationSessionPaletteCommand;
82
+ | ApplicationSessionPaletteCommand
83
+ | ApplicationPluginPaletteCommand
84
+ | ApplicationPluginFormPaletteCommand;
59
85
 
60
86
  export const PALETTE_REFERENCE_COMMANDS = {
61
87
  shortcuts: { label: "Keyboard shortcuts", shortcut: "Ctrl+K", key: "k", page: "shortcuts" },
@@ -93,6 +119,22 @@ export function applicationCommandDescription(command: ApplicationPaletteCommand
93
119
  };
94
120
  if (command === "shortcuts" || command === "whats-new")
95
121
  return { id: command, ...PALETTE_REFERENCE_COMMANDS[command], detail: "Help and reference" };
122
+ if (typeof command === "object" && command.kind === "plugin-command")
123
+ return {
124
+ id: JSON.stringify([command.kind, command.id]),
125
+ // Plugin text: plain text only, even if something upstream let it through.
126
+ label: terminalSafe(
127
+ command.params.length > 0 || command.dangerous ? `${command.label}…` : command.label,
128
+ 200,
129
+ ),
130
+ detail: terminalSafe(`${command.category} · ${command.plugin} plugin`, 200),
131
+ };
132
+ if (typeof command === "object" && command.kind === "plugin-form")
133
+ return {
134
+ id: JSON.stringify([command.kind, command.key]),
135
+ label: terminalSafe(command.label, 200),
136
+ detail: terminalSafe(command.detail, 500),
137
+ };
96
138
  if (typeof command === "object" && command.kind === "open-machine")
97
139
  return {
98
140
  id: JSON.stringify([
@@ -1,7 +1,11 @@
1
+ import { terminalSafe } from "@tmux-ide/contracts";
1
2
  import type { ApplicationPaletteCommand } from "./application-command-description.ts";
2
3
 
3
4
  export function paletteSection(command: ApplicationPaletteCommand): string {
4
5
  if (command === "switch-session") return "Sessions";
6
+ if (typeof command === "object" && command.kind === "plugin-command")
7
+ return terminalSafe(command.category, 80);
8
+ if (typeof command === "object" && command.kind === "plugin-form") return "Choose";
5
9
  if (typeof command === "object")
6
10
  return command.kind === "jump-agent"
7
11
  ? "Agents"
@@ -64,6 +64,8 @@ type TmuxClientResolver = (
64
64
  ) => {
65
65
  executable: string;
66
66
  environment: NodeJS.ProcessEnv;
67
+ /** Global options put before every command, e.g. `["-S", socket]` to pin one server. */
68
+ globalArgs?: readonly string[];
67
69
  };
68
70
 
69
71
  let clientResolver: TmuxClientResolver | undefined;
@@ -84,7 +86,7 @@ export function runTmux(args: string[], options: ExecFileSyncOptions = {}): stri
84
86
  const resolved = clientResolver?.(options.env ?? process.env, options.cwd);
85
87
  return runTmuxBinary(
86
88
  resolved?.executable ?? "tmux",
87
- args,
89
+ resolved?.globalArgs?.length ? [...resolved.globalArgs, ...args] : args,
88
90
  resolved ? { ...options, env: resolved.environment } : options,
89
91
  );
90
92
  }