@celljs/ta-web 4.37.0 → 4.39.0

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 (237) hide show
  1. package/README.en.md +1 -1
  2. package/README.md +1 -1
  3. package/esm/browser/assistant/assistant-thread.d.ts +1 -1
  4. package/esm/browser/assistant/chat-task-source.js +2 -1
  5. package/esm/browser/components/app-contexts.js +11 -9
  6. package/esm/browser/components/chat-asks.d.ts +4 -1
  7. package/esm/browser/components/chat-asks.js +10 -0
  8. package/esm/browser/components/chat-list-row.js +5 -3
  9. package/esm/browser/components/cloud-network.d.ts +17 -0
  10. package/esm/browser/components/cloud-network.js +105 -0
  11. package/esm/browser/components/cloud-sign-in-view.d.ts +1 -1
  12. package/esm/browser/components/composer-box-protocol.d.ts +5 -0
  13. package/esm/browser/components/composer-box.js +11 -14
  14. package/esm/browser/components/composer-media.d.ts +26 -0
  15. package/esm/browser/components/composer-media.js +37 -0
  16. package/esm/browser/components/composer-target.d.ts +2 -2
  17. package/esm/browser/components/composer-target.js +3 -3
  18. package/esm/browser/components/composer.js +1 -0
  19. package/esm/browser/components/folder-picker.d.ts +3 -3
  20. package/esm/browser/components/folder-picker.js +5 -15
  21. package/esm/browser/components/host-view.d.ts +1 -1
  22. package/esm/browser/components/link.d.ts +7 -1
  23. package/esm/browser/components/link.js +24 -5
  24. package/esm/browser/components/markdown.d.ts +2 -2
  25. package/esm/browser/components/markdown.js +77 -5
  26. package/esm/browser/components/relay-services.d.ts +0 -2
  27. package/esm/browser/components/relay-services.js +1 -11
  28. package/esm/browser/components/remote-hosts.d.ts +11 -7
  29. package/esm/browser/components/remote-hosts.js +94 -50
  30. package/esm/browser/components/remote-machines.d.ts +21 -0
  31. package/esm/browser/components/remote-machines.js +56 -0
  32. package/esm/browser/components/remote-prompts.d.ts +2 -3
  33. package/esm/browser/components/remote-prompts.js +3 -15
  34. package/esm/browser/components/remote-steps.d.ts +19 -0
  35. package/esm/browser/components/remote-steps.js +26 -0
  36. package/esm/browser/components/session-view.js +10 -6
  37. package/esm/browser/components/settings-controls.d.ts +3 -1
  38. package/esm/browser/components/settings-controls.js +2 -2
  39. package/esm/browser/components/web-composer.d.ts +1 -1
  40. package/esm/browser/components/web-composer.js +12 -3
  41. package/esm/browser/device/photo-picker.d.ts +11 -3
  42. package/esm/browser/device/photo-picker.js +26 -9
  43. package/esm/browser/device/video-picks.d.ts +24 -0
  44. package/esm/browser/device/video-picks.js +104 -0
  45. package/esm/browser/extension/icons.js +3 -1
  46. package/esm/browser/extension/web-access.js +4 -1
  47. package/esm/browser/extension/web-api-code.d.ts +36 -0
  48. package/esm/browser/extension/web-api-code.js +3 -0
  49. package/esm/browser/extension/web-api-components.d.ts +22 -0
  50. package/esm/browser/extension/web-api-contributions.d.ts +0 -31
  51. package/esm/browser/extension/web-api-menus.d.ts +29 -3
  52. package/esm/browser/extension/web-api-play.d.ts +29 -0
  53. package/esm/browser/extension/web-api-play.js +2 -0
  54. package/esm/browser/extension/web-api-services.d.ts +6 -0
  55. package/esm/browser/extension/web-api-spec.js +5 -0
  56. package/esm/browser/extension/web-api-terminal.d.ts +20 -0
  57. package/esm/browser/extension/web-extension-api.d.ts +12 -17
  58. package/esm/browser/extension/web-extension-context.d.ts +1 -1
  59. package/esm/browser/extension/web-extension-context.js +6 -3
  60. package/esm/browser/extension/web-extension-protocol.d.ts +5 -1
  61. package/esm/browser/extension/web-extension-protocol.js +2 -0
  62. package/esm/browser/extension/web-extension-run.d.ts +6 -4
  63. package/esm/browser/extension/web-extension-run.js +18 -9
  64. package/esm/browser/extension/web-extensions-running.js +38 -7
  65. package/esm/browser/extension/web-on-demand.d.ts +5 -0
  66. package/esm/browser/extension/web-on-demand.js +11 -0
  67. package/esm/browser/i18n/en/assistant.d.ts +3 -0
  68. package/esm/browser/i18n/en/assistant.js +3 -0
  69. package/esm/browser/i18n/en/chat.d.ts +1 -0
  70. package/esm/browser/i18n/en/chat.js +1 -0
  71. package/esm/browser/i18n/en/common.d.ts +1 -0
  72. package/esm/browser/i18n/en/common.js +1 -0
  73. package/esm/browser/i18n/en/discover.d.ts +2 -0
  74. package/esm/browser/i18n/en/discover.js +2 -0
  75. package/esm/browser/i18n/en/service.d.ts +26 -2
  76. package/esm/browser/i18n/en/service.js +34 -10
  77. package/esm/browser/i18n/ja/assistant.js +3 -0
  78. package/esm/browser/i18n/ja/chat.js +1 -0
  79. package/esm/browser/i18n/ja/common.js +1 -0
  80. package/esm/browser/i18n/ja/discover.js +2 -0
  81. package/esm/browser/i18n/ja/service.js +34 -10
  82. package/esm/browser/i18n/locales.d.ts +34 -3
  83. package/esm/browser/i18n/messages.d.ts +33 -2
  84. package/esm/browser/i18n/zh/assistant.js +3 -0
  85. package/esm/browser/i18n/zh/chat.js +1 -0
  86. package/esm/browser/i18n/zh/common.js +1 -0
  87. package/esm/browser/i18n/zh/discover.js +2 -0
  88. package/esm/browser/i18n/zh/service.js +34 -10
  89. package/esm/browser/i18n/zh-tw/assistant.js +3 -0
  90. package/esm/browser/i18n/zh-tw/chat.js +1 -0
  91. package/esm/browser/i18n/zh-tw/common.js +1 -0
  92. package/esm/browser/i18n/zh-tw/discover.js +2 -0
  93. package/esm/browser/i18n/zh-tw/service.js +34 -10
  94. package/esm/browser/markdown/code-renderers.d.ts +6 -1
  95. package/esm/browser/markdown/code-renderers.js +4 -0
  96. package/esm/browser/sandbox/sandbox-runtime-code.js +1 -1
  97. package/esm/browser/sandbox/work/work-api.d.ts +113 -0
  98. package/esm/browser/sandbox/work/work-api.js +95 -0
  99. package/esm/browser/sandbox/work/work-docs.d.ts +18 -0
  100. package/esm/browser/sandbox/work/work-docs.js +66 -0
  101. package/esm/browser/sandbox/work/work-frame.d.ts +27 -0
  102. package/esm/browser/sandbox/work/work-frame.js +124 -0
  103. package/esm/browser/share/shared-extensions.d.ts +2 -1
  104. package/esm/browser/style/conversation.d.ts +1 -1
  105. package/esm/browser/style/conversation.js +10 -0
  106. package/esm/browser/style/dialogs.d.ts +1 -1
  107. package/esm/browser/style/dialogs.js +1 -4
  108. package/esm/browser/style/pages.d.ts +1 -1
  109. package/esm/browser/style/pages.js +10 -1
  110. package/esm/browser/terminal/terminal-osc.d.ts +15 -0
  111. package/esm/browser/terminal/terminal-osc.js +91 -0
  112. package/esm/browser/terminal/web-terminal.d.ts +4 -7
  113. package/esm/browser/terminal/web-terminal.js +22 -26
  114. package/esm/browser/util/link.d.ts +6 -1
  115. package/esm/browser/util/link.js +11 -0
  116. package/esm/browser/workbench-protocol.d.ts +2 -0
  117. package/esm/browser/workbench-services.d.ts +2 -0
  118. package/esm/browser/workbench-services.js +5 -0
  119. package/esm/browser/workbench.js +3 -0
  120. package/lib/browser/assistant/assistant-thread.d.ts +1 -1
  121. package/lib/browser/assistant/chat-task-source.js +2 -1
  122. package/lib/browser/components/app-contexts.js +10 -8
  123. package/lib/browser/components/chat-asks.d.ts +4 -1
  124. package/lib/browser/components/chat-asks.js +10 -0
  125. package/lib/browser/components/chat-list-row.js +5 -3
  126. package/lib/browser/components/cloud-network.d.ts +18 -0
  127. package/lib/browser/components/cloud-network.js +142 -0
  128. package/lib/browser/components/cloud-sign-in-view.d.ts +1 -1
  129. package/lib/browser/components/composer-box-protocol.d.ts +5 -0
  130. package/lib/browser/components/composer-box.js +9 -12
  131. package/lib/browser/components/composer-media.d.ts +27 -0
  132. package/lib/browser/components/composer-media.js +74 -0
  133. package/lib/browser/components/composer-target.d.ts +2 -2
  134. package/lib/browser/components/composer-target.js +3 -3
  135. package/lib/browser/components/composer.js +1 -0
  136. package/lib/browser/components/folder-picker.d.ts +3 -3
  137. package/lib/browser/components/folder-picker.js +5 -15
  138. package/lib/browser/components/host-view.d.ts +1 -1
  139. package/lib/browser/components/link.d.ts +7 -1
  140. package/lib/browser/components/link.js +25 -6
  141. package/lib/browser/components/markdown.d.ts +2 -2
  142. package/lib/browser/components/markdown.js +75 -3
  143. package/lib/browser/components/relay-services.d.ts +0 -2
  144. package/lib/browser/components/relay-services.js +1 -11
  145. package/lib/browser/components/remote-hosts.d.ts +11 -7
  146. package/lib/browser/components/remote-hosts.js +92 -48
  147. package/lib/browser/components/remote-machines.d.ts +22 -0
  148. package/lib/browser/components/remote-machines.js +59 -0
  149. package/lib/browser/components/remote-prompts.d.ts +2 -3
  150. package/lib/browser/components/remote-prompts.js +3 -15
  151. package/lib/browser/components/remote-steps.d.ts +20 -0
  152. package/lib/browser/components/remote-steps.js +63 -0
  153. package/lib/browser/components/session-view.js +8 -4
  154. package/lib/browser/components/settings-controls.d.ts +3 -1
  155. package/lib/browser/components/settings-controls.js +2 -2
  156. package/lib/browser/components/web-composer.d.ts +1 -1
  157. package/lib/browser/components/web-composer.js +12 -3
  158. package/lib/browser/device/photo-picker.d.ts +11 -3
  159. package/lib/browser/device/photo-picker.js +26 -9
  160. package/lib/browser/device/video-picks.d.ts +25 -0
  161. package/lib/browser/device/video-picks.js +107 -0
  162. package/lib/browser/extension/icons.js +2 -0
  163. package/lib/browser/extension/web-access.js +4 -1
  164. package/lib/browser/extension/web-api-code.d.ts +37 -0
  165. package/lib/browser/extension/web-api-code.js +4 -0
  166. package/lib/browser/extension/web-api-components.d.ts +22 -0
  167. package/lib/browser/extension/web-api-contributions.d.ts +0 -31
  168. package/lib/browser/extension/web-api-menus.d.ts +29 -3
  169. package/lib/browser/extension/web-api-play.d.ts +30 -0
  170. package/lib/browser/extension/web-api-play.js +3 -0
  171. package/lib/browser/extension/web-api-services.d.ts +6 -0
  172. package/lib/browser/extension/web-api-spec.js +5 -0
  173. package/lib/browser/extension/web-api-terminal.d.ts +20 -0
  174. package/lib/browser/extension/web-extension-api.d.ts +12 -17
  175. package/lib/browser/extension/web-extension-context.d.ts +1 -1
  176. package/lib/browser/extension/web-extension-context.js +6 -3
  177. package/lib/browser/extension/web-extension-protocol.d.ts +5 -1
  178. package/lib/browser/extension/web-extension-protocol.js +2 -0
  179. package/lib/browser/extension/web-extension-run.d.ts +6 -4
  180. package/lib/browser/extension/web-extension-run.js +18 -9
  181. package/lib/browser/extension/web-extensions-running.js +38 -7
  182. package/lib/browser/extension/web-on-demand.d.ts +5 -0
  183. package/lib/browser/extension/web-on-demand.js +11 -0
  184. package/lib/browser/i18n/en/assistant.d.ts +3 -0
  185. package/lib/browser/i18n/en/assistant.js +3 -0
  186. package/lib/browser/i18n/en/chat.d.ts +1 -0
  187. package/lib/browser/i18n/en/chat.js +1 -0
  188. package/lib/browser/i18n/en/common.d.ts +1 -0
  189. package/lib/browser/i18n/en/common.js +1 -0
  190. package/lib/browser/i18n/en/discover.d.ts +2 -0
  191. package/lib/browser/i18n/en/discover.js +2 -0
  192. package/lib/browser/i18n/en/service.d.ts +26 -2
  193. package/lib/browser/i18n/en/service.js +34 -10
  194. package/lib/browser/i18n/ja/assistant.js +3 -0
  195. package/lib/browser/i18n/ja/chat.js +1 -0
  196. package/lib/browser/i18n/ja/common.js +1 -0
  197. package/lib/browser/i18n/ja/discover.js +2 -0
  198. package/lib/browser/i18n/ja/service.js +34 -10
  199. package/lib/browser/i18n/locales.d.ts +34 -3
  200. package/lib/browser/i18n/messages.d.ts +33 -2
  201. package/lib/browser/i18n/zh/assistant.js +3 -0
  202. package/lib/browser/i18n/zh/chat.js +1 -0
  203. package/lib/browser/i18n/zh/common.js +1 -0
  204. package/lib/browser/i18n/zh/discover.js +2 -0
  205. package/lib/browser/i18n/zh/service.js +34 -10
  206. package/lib/browser/i18n/zh-tw/assistant.js +3 -0
  207. package/lib/browser/i18n/zh-tw/chat.js +1 -0
  208. package/lib/browser/i18n/zh-tw/common.js +1 -0
  209. package/lib/browser/i18n/zh-tw/discover.js +2 -0
  210. package/lib/browser/i18n/zh-tw/service.js +34 -10
  211. package/lib/browser/markdown/code-renderers.d.ts +6 -1
  212. package/lib/browser/markdown/code-renderers.js +5 -1
  213. package/lib/browser/sandbox/sandbox-runtime-code.js +1 -1
  214. package/lib/browser/sandbox/work/work-api.d.ts +114 -0
  215. package/lib/browser/sandbox/work/work-api.js +99 -0
  216. package/lib/browser/sandbox/work/work-docs.d.ts +19 -0
  217. package/lib/browser/sandbox/work/work-docs.js +69 -0
  218. package/lib/browser/sandbox/work/work-frame.d.ts +28 -0
  219. package/lib/browser/sandbox/work/work-frame.js +160 -0
  220. package/lib/browser/share/shared-extensions.d.ts +2 -1
  221. package/lib/browser/style/conversation.d.ts +1 -1
  222. package/lib/browser/style/conversation.js +10 -0
  223. package/lib/browser/style/dialogs.d.ts +1 -1
  224. package/lib/browser/style/dialogs.js +1 -4
  225. package/lib/browser/style/pages.d.ts +1 -1
  226. package/lib/browser/style/pages.js +10 -1
  227. package/lib/browser/terminal/terminal-osc.d.ts +16 -0
  228. package/lib/browser/terminal/terminal-osc.js +94 -0
  229. package/lib/browser/terminal/web-terminal.d.ts +4 -7
  230. package/lib/browser/terminal/web-terminal.js +25 -29
  231. package/lib/browser/util/link.d.ts +6 -1
  232. package/lib/browser/util/link.js +11 -0
  233. package/lib/browser/workbench-protocol.d.ts +2 -0
  234. package/lib/browser/workbench-services.d.ts +2 -0
  235. package/lib/browser/workbench-services.js +5 -0
  236. package/lib/browser/workbench.js +3 -0
  237. package/package.json +12 -12
@@ -33,13 +33,14 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.OpenLink = void 0;
36
+ exports.FileMenu = exports.OpenLink = void 0;
37
37
  exports.LinkView = LinkView;
38
38
  exports.CodeLink = CodeLink;
39
39
  exports.FileLink = FileLink;
40
40
  const React = __importStar(require("react"));
41
41
  const use_t_1 = require("../i18n/use-t");
42
42
  const link_1 = require("../util/link");
43
+ const context_menu_1 = require("./context-menu");
43
44
  /**
44
45
  * Opens what a link of a reply points to (TaLinks.open, with the directory of the conversation it is in);
45
46
  * `external` for Cmd or Ctrl + click. Without it, as in tests, only pages of the web are links.
@@ -86,21 +87,39 @@ function CodeLink({ text }) {
86
87
  return (React.createElement(PathButton, { target: target, code: true },
87
88
  React.createElement("code", null, text)));
88
89
  }
89
- /** A file a turn changed, by its name: a link to it where links open, else the name. */
90
+ /**
91
+ * What extensions add to the menu of a file a turn changed (registerFileMenu: share it, send it to friends), the file
92
+ * as the agent named it, of the directory of the conversation: as the explorer's menu of a file has them.
93
+ */
94
+ exports.FileMenu = React.createContext(undefined);
95
+ /** A file a turn changed, by its name: a link to it where links open, else the name; its menu under a right click or a held finger. */
90
96
  function FileLink({ path }) {
97
+ const t = (0, use_t_1.useT)();
91
98
  const open = React.useContext(exports.OpenLink);
99
+ const fileMenu = React.useContext(exports.FileMenu);
100
+ const [menu, openMenu] = (0, context_menu_1.useContextMenu)();
92
101
  const target = React.useMemo(() => { var _a; return (open ? ((_a = link_1.LinkUtil.codeReference(path)) !== null && _a !== void 0 ? _a : link_1.LinkUtil.parse(path)) : undefined); }, [open, path]);
93
102
  const label = path.replace(/\/+$/, '').split('/').pop() || path;
94
103
  if ((target === null || target === void 0 ? void 0 : target.type) !== 'path') {
95
104
  return (React.createElement("code", { className: "ta-file-chip", title: path }, label));
96
105
  }
97
- return (React.createElement(PathButton, { target: target, code: true },
98
- React.createElement("code", { className: "ta-file-chip" }, label)));
106
+ const onMenu = fileMenu && !target.directory
107
+ ? (event) => {
108
+ const added = fileMenu(target.path).map(({ label, run, disabled, danger }) => ({ label, run, disabled, danger }));
109
+ if (added.length) {
110
+ openMenu(event, [{ label: t('ta.chat.open'), run: () => open === null || open === void 0 ? void 0 : open(target, false) }, '-', ...added]);
111
+ }
112
+ }
113
+ : undefined;
114
+ return (React.createElement(React.Fragment, null,
115
+ React.createElement(PathButton, { target: target, code: true, onContextMenu: onMenu },
116
+ React.createElement("code", { className: "ta-file-chip" }, label)),
117
+ menu));
99
118
  }
100
- function PathButton({ target, code, children }) {
119
+ function PathButton({ target, code, onContextMenu, children, }) {
101
120
  const t = (0, use_t_1.useT)();
102
121
  const open = React.useContext(exports.OpenLink);
103
122
  const directory = target.type === 'path' && target.directory;
104
- return (React.createElement("button", { type: "button", className: `ta-link-path ${code ? 'ta-link-code' : ''}`, title: `${link_1.LinkUtil.label(target)}\n${t(directory ? 'ta.link.openFolder' : 'ta.link.openFile')}`, onClick: () => open === null || open === void 0 ? void 0 : open(target, false) }, children));
123
+ return (React.createElement("button", { type: "button", className: `ta-link-path ${code ? 'ta-link-code' : ''}`, title: `${link_1.LinkUtil.label(target)}\n${t(directory ? 'ta.link.openFolder' : 'ta.link.openFile')}`, onClick: () => open === null || open === void 0 ? void 0 : open(target, false), onContextMenu: onContextMenu }, children));
105
124
  }
106
125
  //# sourceMappingURL=link.js.map
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
- import type { WebCodeRendererProps } from '../extension/web-api-contributions';
3
- export declare function CodeBlock({ code }: {
2
+ import type { WebCodeRendererProps } from '../extension/web-api-code';
3
+ export declare function CodeBlock({ code, language }: {
4
4
  code: string;
5
5
  language?: string;
6
6
  }): React.JSX.Element;
@@ -35,6 +35,7 @@ var __importStar = (this && this.__importStar) || (function () {
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.CodeBlock = CodeBlock;
37
37
  exports.Markdown = Markdown;
38
+ const ta_protocol_1 = require("@celljs/ta-protocol");
38
39
  const lucide_react_1 = require("lucide-react");
39
40
  const React = __importStar(require("react"));
40
41
  const use_t_1 = require("../i18n/use-t");
@@ -76,9 +77,14 @@ function Inline({ nodes }) {
76
77
  const Text = React.memo(function Text({ text }) {
77
78
  return React.createElement(Inline, { nodes: markdown_1.MarkdownUtil.inline(text) });
78
79
  });
79
- function CodeBlock({ code }) {
80
+ function CodeBlock({ code, language = '' }) {
80
81
  const t = (0, use_t_1.useT)();
82
+ const menus = React.useContext(code_renderers_1.CodeMenus);
81
83
  const [copied, setCopied] = React.useState(false);
84
+ // What extensions do with it (put a command in a terminal): a button each, by its icon.
85
+ const actions = menus.length
86
+ ? menus.flatMap(menu => menu({ language: language.trim().toLowerCase(), code })).filter(item => item.icon && !item.disabled)
87
+ : [];
82
88
  const copy = () => {
83
89
  var _a;
84
90
  void ((_a = navigator.clipboard) === null || _a === void 0 ? void 0 : _a.writeText(code).then(() => {
@@ -88,10 +94,29 @@ function CodeBlock({ code }) {
88
94
  };
89
95
  return (React.createElement("div", { className: "ta-code" },
90
96
  React.createElement("span", { className: "ta-code-actions ta-code-float" },
97
+ actions.map(item => item.icon && React.createElement(icon_1.IconButton, { key: item.key, icon: item.icon, label: item.label, onClick: () => item.run() })),
91
98
  React.createElement(icon_1.IconButton, { icon: copied ? lucide_react_1.Check : lucide_react_1.Copy, label: t(copied ? 'ta.copied' : 'ta.copy'), onClick: copy })),
92
99
  React.createElement("pre", null,
93
100
  React.createElement("code", null, code))));
94
101
  }
102
+ /**
103
+ * What extensions do with a block a renderer drew (registerCodeMenu, `drawn`): a row of buttons under it, each with
104
+ * its words, as a card has them. None while it streams, nor in the card of another.
105
+ */
106
+ function DrawnActions({ code, language, conversation, point, }) {
107
+ const menus = React.useContext(code_renderers_1.CodeMenus);
108
+ const block = { language: language.trim().toLowerCase(), code, drawn: true, ...(conversation ? { conversation } : {}), ...(point ? { point } : {}) };
109
+ const actions = menus.flatMap(menu => menu(block)).filter(item => !item.disabled);
110
+ if (actions.length === 0) {
111
+ return null;
112
+ }
113
+ return (React.createElement("div", { className: "ta-code-drawn-actions" }, actions.map(item => {
114
+ const Icon = item.icon;
115
+ return (React.createElement("button", { key: item.key, type: "button", className: "ta-code-drawn-action", onClick: () => item.run() },
116
+ Icon && React.createElement(Icon, { size: 14 }),
117
+ React.createElement("span", null, item.label)));
118
+ })));
119
+ }
95
120
  /** What a code renderer draws: when it throws, the code itself. */
96
121
  class CodeBoundary extends React.Component {
97
122
  constructor() {
@@ -113,9 +138,54 @@ class CodeBoundary extends React.Component {
113
138
  return this.state.failed ? this.props.fallback : this.props.children;
114
139
  }
115
140
  }
141
+ /**
142
+ * The user pointing at a part of a block (WebCodeRef.point): `begin` lets them, the renderer gets `point` until a part
143
+ * is tapped (`end` with it) or they give up (`end` with none: Cancel, Escape, the block gone).
144
+ */
145
+ function usePointing() {
146
+ const waiting = React.useRef(undefined);
147
+ const [pointing, setPointing] = React.useState(false);
148
+ const end = React.useCallback((point) => {
149
+ const done = waiting.current;
150
+ waiting.current = undefined;
151
+ setPointing(false);
152
+ done === null || done === void 0 ? void 0 : done(point === undefined ? undefined : ta_protocol_1.TaWorkPoint.check(point));
153
+ }, []);
154
+ const begin = React.useCallback(() => new Promise(resolve => {
155
+ var _a;
156
+ (_a = waiting.current) === null || _a === void 0 ? void 0 : _a.call(waiting, undefined);
157
+ waiting.current = resolve;
158
+ setPointing(true);
159
+ }), []);
160
+ React.useEffect(() => () => { var _a; return (_a = waiting.current) === null || _a === void 0 ? void 0 : _a.call(waiting, undefined); }, []);
161
+ React.useEffect(() => {
162
+ if (!pointing) {
163
+ return;
164
+ }
165
+ const key = (event) => {
166
+ if (event.key === 'Escape') {
167
+ end();
168
+ }
169
+ };
170
+ window.addEventListener('keydown', key);
171
+ return () => window.removeEventListener('keydown', key);
172
+ }, [pointing, end]);
173
+ return { pointing, begin, end };
174
+ }
175
+ /** Above a block the user points at: what to do, and Cancel. */
176
+ function PointHint({ onCancel }) {
177
+ const t = (0, use_t_1.useT)();
178
+ return (React.createElement("div", { className: "ta-code-point-hint", role: "status" },
179
+ React.createElement(lucide_react_1.MousePointerClick, { size: 14 }),
180
+ React.createElement("span", null, t('ta.point.hint')),
181
+ React.createElement("button", { type: "button", onClick: onCancel }, t('ta.cancel'))));
182
+ }
116
183
  /** A fenced block: as a web extension draws its language, a Mermaid diagram, or code. */
117
184
  function CodeView({ language, code, closed }) {
118
- const Renderer = React.useContext(code_renderers_1.CodeRenderers)[language.trim().toLowerCase()];
185
+ const key = language.trim().toLowerCase();
186
+ const Renderer = React.useContext(code_renderers_1.CodeRenderers)[key];
187
+ const pointable = React.useContext(code_renderers_1.CodePointable)[key] === true;
188
+ const { pointing, begin, end } = usePointing();
119
189
  const send = React.useContext(code_renderers_1.CodeReply);
120
190
  const answer = React.useContext(code_renderers_1.CodeAnswer);
121
191
  const conversation = React.useContext(code_renderers_1.CodeConversation);
@@ -127,8 +197,10 @@ function CodeView({ language, code, closed }) {
127
197
  const plain = React.createElement(CodeBlock, { code: code, language: language });
128
198
  if (Renderer) {
129
199
  return (React.createElement(CodeBoundary, { retry: closed, fallback: plain },
200
+ pointing && React.createElement(PointHint, { onCancel: () => end() }),
130
201
  React.createElement(code_renderers_1.CodeEmbedded.Provider, { value: true }, embedded ? (React.createElement("div", { className: "ta-code-embedded" },
131
- React.createElement(Renderer, { code: code, language: language, closed: closed, send: send, answer: answer, conversation: conversation, embedded: true }))) : (React.createElement(Renderer, { code: code, language: language, closed: closed, send: send, answer: answer, conversation: conversation })))));
202
+ React.createElement(Renderer, { code: code, language: language, closed: closed, send: send, answer: answer, conversation: conversation, embedded: true }))) : (React.createElement(Renderer, { code: code, language: language, closed: closed, send: send, answer: answer, conversation: conversation, ...(pointing ? { point: end } : {}) }))),
203
+ closed && !embedded && !pointing && (React.createElement(DrawnActions, { code: code, language: language, conversation: conversation, ...(pointable ? { point: begin } : {}) }))));
132
204
  }
133
205
  if (mermaid_1.MermaidUtil.isDiagram(language, code)) {
134
206
  return React.createElement(mermaid_view_1.MermaidView, { code: code, fallback: plain });
@@ -20,8 +20,6 @@ export declare namespace RelayServicesUtil {
20
20
  /** What a deployment is called: its name, else the host of the address it was joined by. */
21
21
  function deploymentName(deployment: TaJoinedDeployment): string;
22
22
  function host(url: string): string;
23
- /** A name for the cloud workspace of a deployment's gateway (ta://<name>): its first label, as TaLocation takes it. */
24
- function cloudName(gateway: string): string;
25
23
  function iconNamed(name: string | undefined): LucideIcon;
26
24
  /** Where a relay is and whether it answers, short enough for a phone beside its controls. */
27
25
  function brief(service: TaRelayService, probe: TaRelayProbe | undefined, t: ReturnType<typeof useT>): string;
@@ -127,16 +127,6 @@ var RelayServicesUtil;
127
127
  }
128
128
  }
129
129
  RelayServicesUtil.host = host;
130
- /** A name for the cloud workspace of a deployment's gateway (ta://<name>): its first label, as TaLocation takes it. */
131
- function cloudName(gateway) {
132
- var _a;
133
- const first = ((_a = host(gateway).split(/[.:]/)[0]) !== null && _a !== void 0 ? _a : '')
134
- .toLowerCase()
135
- .replace(/[^a-z0-9-]+/g, '-')
136
- .replace(/^-+|-+$/g, '');
137
- return /^[a-z0-9]/.test(first) ? first.slice(0, 40) : 'cloud';
138
- }
139
- RelayServicesUtil.cloudName = cloudName;
140
130
  function iconNamed(name) {
141
131
  return name === 'Database' ? lucide_react_1.Database : name === 'GitBranch' ? lucide_react_1.GitBranch : name === 'HardDrive' ? lucide_react_1.HardDrive : name === 'Server' ? lucide_react_1.Server : lucide_react_1.Cloud;
142
132
  }
@@ -346,6 +336,6 @@ function Deployment({ relays, changed }) {
346
336
  React.createElement(icon_1.Icon, { icon: lucide_react_1.ExternalLink, size: 14 }),
347
337
  " ",
348
338
  t('ta.deploy.open')),
349
- clouds && !added && React.createElement(remote_hosts_1.AddCloudHost, { url: gateway, name: RelayServicesUtil.cloudName(gateway), onAdded: readClouds }))))));
339
+ clouds && !added && React.createElement(remote_hosts_1.AddCloudHost, { url: gateway, onAdded: readClouds }))))));
350
340
  }
351
341
  //# sourceMappingURL=relay-services.js.map
@@ -1,18 +1,22 @@
1
1
  import * as React from 'react';
2
2
  /**
3
- * A cloud workspace to add: the address of a Ta gateway (or Ta service), a token of one's account there, and a name for
4
- * its directories, `ta://<name>/…`. Checked by connecting before it is kept. A deployment joined (RelayServices) opens
5
- * it with the address of its gateway and a name filled in.
3
+ * A cloud workspace of a Ta gateway to add: the address of the gateway and a token of one's account there; its name,
4
+ * for its directories (`ta://<name>/…`), from the address. Checked by connecting before it is kept. A deployment
5
+ * joined (RelayServices) opens it with the address of its gateway and a name filled in.
6
6
  */
7
- export declare function AddCloudHost({ onAdded, url: givenUrl, name: givenName }: {
7
+ export declare function AddCloudHost({ onAdded, url: givenUrl, name: givenName, taken, onOpenChange, }: {
8
8
  onAdded(): Promise<unknown>;
9
9
  url?: string;
10
10
  name?: string;
11
+ taken?: readonly string[];
12
+ /** The form opened or closed, for a row that lays it out under its words rather than beside them. */
13
+ onOpenChange?(open: boolean): void;
11
14
  }): React.JSX.Element;
12
15
  /**
13
- * The machines conversations can work on (`ssh://` directories): those of ~/.ssh/config and those added,
14
- * whether Ta is connected to each, and the ports forwarded from them. Connecting checks a host the way a
15
- * conversation would: ssh signs in, Ta installs what it needs there.
16
+ * The machines conversations can work on (`ssh://` directories) and go on on while this computer is away (cloud
17
+ * workspaces), one row each with what belongs to it under it: whether conversations go on there (a cloud workspace
18
+ * made on it), how far its commands reach, the ports forwarded from it. Connecting checks a host the way a
19
+ * conversation would: ssh signs in, Ta installs what it needs there. A Ta gateway, which few have, comes last.
16
20
  */
17
21
  export declare function RemoteHosts(): React.JSX.Element;
18
22
  //# sourceMappingURL=remote-hosts.d.ts.map
@@ -40,9 +40,12 @@ const lucide_react_1 = require("lucide-react");
40
40
  const React = __importStar(require("react"));
41
41
  const hooks_1 = require("../hooks");
42
42
  const use_t_1 = require("../i18n/use-t");
43
+ const cloud_network_1 = require("./cloud-network");
43
44
  const empty_pictures_1 = require("./empty-pictures");
44
45
  const folder_picker_1 = require("./folder-picker");
45
46
  const icon_1 = require("./icon");
47
+ const remote_machines_1 = require("./remote-machines");
48
+ const remote_steps_1 = require("./remote-steps");
46
49
  const settings_controls_1 = require("./settings-controls");
47
50
  /** The hosts and forwarded ports of TaRemoteServer, read again when a host connects or disconnects. */
48
51
  function useRemote() {
@@ -61,23 +64,25 @@ function useRemote() {
61
64
  read().catch(() => undefined);
62
65
  return bench.onRemoteEvent(event => event.type === 'connection' && void read().catch(() => undefined));
63
66
  }, [workbench.status, bench, read]);
64
- return { bench, hosts, ports, read };
67
+ return { bench, hosts, ports, read, steps: (0, remote_steps_1.useRemoteSteps)(bench) };
65
68
  }
66
69
  /**
67
- * A cloud workspace to add: the address of a Ta gateway (or Ta service), a token of one's account there, and a name for
68
- * its directories, `ta://<name>/…`. Checked by connecting before it is kept. A deployment joined (RelayServices) opens
69
- * it with the address of its gateway and a name filled in.
70
+ * A cloud workspace of a Ta gateway to add: the address of the gateway and a token of one's account there; its name,
71
+ * for its directories (`ta://<name>/…`), from the address. Checked by connecting before it is kept. A deployment
72
+ * joined (RelayServices) opens it with the address of its gateway and a name filled in.
70
73
  */
71
- function AddCloudHost({ onAdded, url: givenUrl = '', name: givenName = '' }) {
74
+ function AddCloudHost({ onAdded, url: givenUrl = '', name: givenName, taken = [], onOpenChange, }) {
72
75
  const t = (0, use_t_1.useT)();
73
76
  const [, bench] = (0, hooks_1.useWorkbench)();
74
77
  const [, notices] = (0, hooks_1.useNotices)();
75
- const [open, setOpen] = React.useState(false);
76
- const [name, setName] = React.useState(givenName);
78
+ const [open, setOpenState] = React.useState(false);
79
+ const setOpen = (value) => {
80
+ setOpenState(value);
81
+ onOpenChange === null || onOpenChange === void 0 ? void 0 : onOpenChange(value);
82
+ };
77
83
  const [url, setUrl] = React.useState(givenUrl);
78
84
  const [token, setToken] = React.useState('');
79
85
  const [busy, setBusy] = React.useState(false);
80
- const nameOk = ta_protocol_1.TaLocation.isCloudName(name.trim());
81
86
  if (!open) {
82
87
  return (React.createElement("button", { type: "button", className: "ta-button", onClick: () => setOpen(true) },
83
88
  React.createElement(icon_1.Icon, { icon: lucide_react_1.Cloud, size: 14 }),
@@ -88,10 +93,10 @@ function AddCloudHost({ onAdded, url: givenUrl = '', name: givenName = '' }) {
88
93
  event.preventDefault();
89
94
  setBusy(true);
90
95
  try {
91
- const added = await bench.remote.addCloudHost(name.trim(), url.trim(), token.trim());
96
+ const name = givenName || remote_machines_1.RemoteMachinesUtil.cloudName(url, taken);
97
+ const added = await bench.remote.addCloudHost(name, url.trim(), token.trim());
92
98
  notices.notify(t('ta.remote.cloudAdded', { name: ta_protocol_1.TaLocation.hostLabel(added.host) }), { level: 'success' });
93
99
  setOpen(false);
94
- setName(givenName);
95
100
  setUrl(givenUrl);
96
101
  setToken('');
97
102
  await onAdded();
@@ -109,25 +114,31 @@ function AddCloudHost({ onAdded, url: givenUrl = '', name: givenName = '' }) {
109
114
  React.createElement("label", { className: "ta-field" },
110
115
  React.createElement(icon_1.Icon, { icon: lucide_react_1.KeyRound, size: 16 }),
111
116
  React.createElement("input", { type: "password", value: token, placeholder: t('ta.remote.cloudToken'), "aria-label": t('ta.remote.cloudToken'), autoComplete: "off", onChange: event => setToken(event.target.value) })),
112
- React.createElement("label", { className: "ta-field" },
113
- React.createElement(icon_1.Icon, { icon: lucide_react_1.Tag, size: 16 }),
114
- React.createElement("input", { value: name, placeholder: t('ta.remote.cloudName'), "aria-label": t('ta.remote.cloudName'), "aria-invalid": name.trim() && !nameOk ? true : undefined, spellCheck: false, autoCapitalize: "off", onChange: event => setName(event.target.value.toLowerCase()) })),
115
117
  React.createElement("p", { className: "ta-environment-hint" }, t('ta.remote.cloudHint')),
116
118
  React.createElement("div", { className: "ta-auth-actions" },
117
119
  React.createElement("button", { type: "button", className: "ta-button", onClick: () => setOpen(false) }, t('ta.cancel')),
118
- React.createElement("button", { type: "submit", className: "ta-button ta-primary", disabled: busy || !nameOk || !url.trim() || !token.trim() }, busy ? React.createElement("span", { className: "ta-spinner" }) : t('ta.remote.cloudConnect')))));
120
+ React.createElement("button", { type: "submit", className: "ta-button ta-primary", disabled: busy || !url.trim() || !token.trim() }, busy ? React.createElement("span", { className: "ta-spinner" }) : t('ta.remote.cloudConnect')))));
121
+ }
122
+ /** Whether a host is connected, or the step it is at, with its light. */
123
+ function HostState({ host, step, extra }) {
124
+ const t = (0, use_t_1.useT)();
125
+ return (React.createElement("span", { className: "ta-remote-state" },
126
+ step ? React.createElement("span", { className: "ta-spinner" }) : React.createElement("span", { className: `ta-remote-light${host.connected ? ' ta-on' : ''}` }),
127
+ [remote_machines_1.RemoteMachinesUtil.state(host, step, t), extra].filter(Boolean).join(' · ')));
119
128
  }
120
129
  /**
121
- * The machines conversations can work on (`ssh://` directories): those of ~/.ssh/config and those added,
122
- * whether Ta is connected to each, and the ports forwarded from them. Connecting checks a host the way a
123
- * conversation would: ssh signs in, Ta installs what it needs there.
130
+ * The machines conversations can work on (`ssh://` directories) and go on on while this computer is away (cloud
131
+ * workspaces), one row each with what belongs to it under it: whether conversations go on there (a cloud workspace
132
+ * made on it), how far its commands reach, the ports forwarded from it. Connecting checks a host the way a
133
+ * conversation would: ssh signs in, Ta installs what it needs there. A Ta gateway, which few have, comes last.
124
134
  */
125
135
  function RemoteHosts() {
126
136
  const t = (0, use_t_1.useT)();
127
137
  const [, notices] = (0, hooks_1.useNotices)();
128
- const { bench, hosts, ports, read } = useRemote();
138
+ const { bench, hosts, ports, read, steps } = useRemote();
129
139
  const [text, setText] = React.useState('');
130
140
  const [busy, setBusy] = React.useState();
141
+ const [gateway, setGateway] = React.useState(false);
131
142
  const run = async (host, action) => {
132
143
  setBusy(host);
133
144
  try {
@@ -150,6 +161,42 @@ function RemoteHosts() {
150
161
  setText('');
151
162
  void run(read.host, () => bench.remote.addHost(read.host));
152
163
  };
164
+ const relay = async (host, on, current) => {
165
+ try {
166
+ if (on) {
167
+ await bench.remote.addSshCloudHost('', host.host);
168
+ notices.notify(t('ta.remote.madeCloud', { host: ta_protocol_1.TaLocation.hostLabel(host.host) }), { level: 'success' });
169
+ }
170
+ else if (current) {
171
+ const sure = await notices.confirm({
172
+ title: t('ta.remote.relay.stopTitle', { host: ta_protocol_1.TaLocation.hostLabel(host.host) }),
173
+ message: t('ta.remote.relay.stopHint'),
174
+ confirmLabel: t('ta.remote.relay.stop'),
175
+ });
176
+ if (sure) {
177
+ await bench.remote.removeHost(current.host);
178
+ }
179
+ }
180
+ }
181
+ catch (error) {
182
+ notices.error(error);
183
+ }
184
+ finally {
185
+ await read().catch(() => undefined);
186
+ }
187
+ };
188
+ const connection = (host) => host.connected ? (React.createElement("button", { type: "button", className: "ta-button", disabled: busy === host.host, onClick: () => run(host.host, () => bench.remote.disconnect(host.host)) },
189
+ React.createElement(icon_1.Icon, { icon: lucide_react_1.Unplug, size: 14 }),
190
+ " ",
191
+ t('ta.remote.disconnect'))) : (React.createElement("button", { type: "button", className: "ta-button", disabled: busy === host.host, onClick: () => run(host.host, async () => {
192
+ await bench.remote.resolveLocation(ta_protocol_1.TaLocation.ssh(host.host));
193
+ notices.notify(t('ta.remote.connectedTo', { host: ta_protocol_1.TaLocation.hostLabel(host.host) }), { level: 'success' });
194
+ }) },
195
+ busy === host.host ? React.createElement("span", { className: "ta-spinner" }) : React.createElement(icon_1.Icon, { icon: lucide_react_1.Plug, size: 14 }),
196
+ " ",
197
+ t('ta.remote.connect')));
198
+ const machines = remote_machines_1.RemoteMachinesUtil.machines(hosts);
199
+ const taken = hosts.flatMap(host => { var _a; return (_a = ta_protocol_1.TaLocation.cloudName(host.host)) !== null && _a !== void 0 ? _a : []; });
153
200
  return (React.createElement(React.Fragment, null,
154
201
  React.createElement(settings_controls_1.Row, { label: t('ta.remote.add'), description: t('ta.remote.description'), stacked: true },
155
202
  React.createElement("form", { className: "ta-trusted-add", onSubmit: event => {
@@ -160,35 +207,32 @@ function RemoteHosts() {
160
207
  React.createElement("button", { type: "submit", className: "ta-button", disabled: !text.trim() },
161
208
  React.createElement(icon_1.Icon, { icon: lucide_react_1.Plus, size: 14 }),
162
209
  " ",
163
- t('ta.remote.add')))),
164
- React.createElement(settings_controls_1.Row, { label: t('ta.remote.cloudTitle'), description: t('ta.remote.cloudDescription'), stacked: true },
165
- React.createElement(AddCloudHost, { onAdded: read })),
166
- hosts.length === 0 && React.createElement(settings_controls_1.EmptyRow, { picture: React.createElement(empty_pictures_1.RemotePicture, null), title: t('ta.remote.none'), hint: t('ta.remote.noneHint') }),
167
- hosts.map(host => { var _a; return (React.createElement(settings_controls_1.Row, { key: host.host, icon: host.source === 'cloud' ? lucide_react_1.Cloud : undefined, label: host.source === 'cloud' ? ta_protocol_1.TaLocation.hostLabel(host.host) : folder_picker_1.RemoteHostsUtil.breakable(host.host), description: React.createElement("span", { className: "ta-remote-state" },
168
- React.createElement("span", { className: `ta-remote-light${host.connected ? ' ta-on' : ''}` }),
169
- [
170
- t(host.connected ? 'ta.remote.connected' : 'ta.remote.disconnected'),
171
- host.source === 'cloud'
172
- ? ((_a = host.url) !== null && _a !== void 0 ? _a : '').replace(/^https?:\/\//, '')
173
- : t(host.source === 'config' ? 'ta.remote.fromConfig' : 'ta.remote.added'),
174
- ].join(' · ')) },
175
- host.source === 'cloud' && host.url && (React.createElement("a", { className: "ta-button", href: host.url, target: "_blank", rel: "noreferrer noopener", title: t('ta.remote.openCloudHint') },
176
- React.createElement(icon_1.Icon, { icon: lucide_react_1.ExternalLink, size: 14 }),
177
- " ",
178
- t('ta.remote.openCloud'))),
179
- host.connected ? (React.createElement("button", { type: "button", className: "ta-button", disabled: busy === host.host, onClick: () => run(host.host, () => bench.remote.disconnect(host.host)) },
180
- React.createElement(icon_1.Icon, { icon: lucide_react_1.Unplug, size: 14 }),
181
- " ",
182
- t('ta.remote.disconnect'))) : (React.createElement("button", { type: "button", className: "ta-button", disabled: busy === host.host, onClick: () => run(host.host, async () => {
183
- await bench.remote.resolveLocation(ta_protocol_1.TaLocation.ssh(host.host));
184
- notices.notify(t('ta.remote.connectedTo', { host: ta_protocol_1.TaLocation.hostLabel(host.host) }), { level: 'success' });
185
- }) },
186
- busy === host.host ? React.createElement("span", { className: "ta-spinner" }) : React.createElement(icon_1.Icon, { icon: lucide_react_1.Plug, size: 14 }),
187
- " ",
188
- t('ta.remote.connect'))),
189
- host.source !== 'config' && (React.createElement(icon_1.IconButton, { icon: lucide_react_1.Trash2, label: t('ta.remote.remove', { host: host.host }), disabled: busy === host.host, onClick: () => run(host.host, () => bench.remote.removeHost(host.host)) })))); }),
190
- ports.map(port => (React.createElement(settings_controls_1.Row, { key: `${port.host}:${port.remotePort}`, label: t('ta.remote.port', { host: port.host, port: port.remotePort }), description: `localhost:${port.localPort}` },
191
- React.createElement(icon_1.Icon, { icon: lucide_react_1.Server, size: 14, className: "ta-muted" }),
192
- React.createElement(icon_1.IconButton, { icon: lucide_react_1.X, label: t('ta.remote.closePort'), onClick: () => run(port.host, () => bench.remote.closeForwardedPort(port.host, port.remotePort)) }))))));
210
+ t('ta.remote.addConfirm')))),
211
+ machines.length === 0 && React.createElement(settings_controls_1.EmptyRow, { picture: React.createElement(empty_pictures_1.RemotePicture, null), title: t('ta.remote.none'), hint: t('ta.remote.noneHint') }),
212
+ machines.map(({ host, relay: current }) => { var _a, _b; return host.source === 'cloud' ? (React.createElement(React.Fragment, { key: host.host },
213
+ React.createElement(settings_controls_1.Row, { icon: lucide_react_1.Cloud, label: ta_protocol_1.TaLocation.hostLabel(host.host), description: React.createElement(HostState, { host: host, step: steps[host.host], extra: ((_a = host.url) !== null && _a !== void 0 ? _a : '').replace(/^https?:\/\//, '') }) },
214
+ /^https?:/.test((_b = host.url) !== null && _b !== void 0 ? _b : '') && (React.createElement("a", { className: "ta-button", href: host.url, target: "_blank", rel: "noreferrer noopener", title: t('ta.remote.openCloudHint') },
215
+ React.createElement(icon_1.Icon, { icon: lucide_react_1.ExternalLink, size: 14 }),
216
+ " ",
217
+ t('ta.remote.openCloud'))),
218
+ connection(host),
219
+ React.createElement(icon_1.IconButton, { icon: lucide_react_1.Trash2, label: t('ta.remote.remove', { host: host.host }), disabled: busy === host.host, onClick: () => run(host.host, () => bench.remote.removeHost(host.host)) })),
220
+ React.createElement(cloud_network_1.CloudNetworkRow, { host: host, onChanged: read }))) : (React.createElement(React.Fragment, { key: host.host },
221
+ React.createElement(settings_controls_1.Row, { icon: current ? lucide_react_1.Cloud : lucide_react_1.Server, label: folder_picker_1.RemoteHostsUtil.breakable(host.host), description: React.createElement(HostState, { host: host, step: remote_machines_1.RemoteMachinesUtil.relayStep(steps[host.host]) ? undefined : steps[host.host], extra: host.source === 'config' ? t('ta.remote.fromConfig') : undefined }) },
222
+ connection(host),
223
+ host.source !== 'config' && !current && (React.createElement(icon_1.IconButton, { icon: lucide_react_1.Trash2, label: t('ta.remote.remove', { host: host.host }), disabled: busy === host.host, onClick: () => run(host.host, () => bench.remote.removeHost(host.host)) }))),
224
+ React.createElement(settings_controls_1.Row, { inset: true, label: t('ta.remote.relay'), description: remote_machines_1.RemoteMachinesUtil.relayStep(steps[host.host]) ? (React.createElement(HostState, { host: host, step: steps[host.host] })) : (t(current ? 'ta.remote.relay.on' : 'ta.remote.relay.off')) },
225
+ React.createElement(settings_controls_1.Switch, { label: t('ta.remote.relay'), checked: !!current, onChange: on => relay(host, on, current) })),
226
+ current && React.createElement(cloud_network_1.CloudNetworkRow, { host: current, onChanged: read }),
227
+ ports
228
+ .filter(port => port.host === host.host)
229
+ .map(port => (React.createElement(settings_controls_1.Row, { inset: true, key: `${port.host}:${port.remotePort}`, label: t('ta.remote.port', { port: port.remotePort }), description: t('ta.remote.portLocal', { port: port.localPort }) },
230
+ React.createElement(icon_1.IconButton, { icon: lucide_react_1.X, label: t('ta.remote.closePort'), onClick: () => run(port.host, () => bench.remote.closeForwardedPort(port.host, port.remotePort)) })))))); }),
231
+ ports
232
+ .filter(port => !machines.some(machine => machine.host.host === port.host))
233
+ .map(port => (React.createElement(settings_controls_1.Row, { key: `${port.host}:${port.remotePort}`, label: `${ta_protocol_1.TaLocation.hostLabel(port.host)} · ${t('ta.remote.port', { port: port.remotePort })}`, description: t('ta.remote.portLocal', { port: port.localPort }) },
234
+ React.createElement(icon_1.IconButton, { icon: lucide_react_1.X, label: t('ta.remote.closePort'), onClick: () => run(port.host, () => bench.remote.closeForwardedPort(port.host, port.remotePort)) })))),
235
+ React.createElement(settings_controls_1.Row, { label: t('ta.remote.cloudTitle'), description: t('ta.remote.cloudDescription'), stacked: gateway },
236
+ React.createElement(AddCloudHost, { onAdded: read, taken: taken, onOpenChange: setGateway }))));
193
237
  }
194
238
  //# sourceMappingURL=remote-hosts.js.map
@@ -0,0 +1,22 @@
1
+ import { type TaRemoteHost } from '@celljs/ta-protocol';
2
+ import type { Translate } from '../i18n/use-t';
3
+ import type { RemoteStepInfo } from './remote-steps';
4
+ /** A machine of the list: a host of ssh with the cloud workspace made on it (`relay`), or a cloud workspace of a gateway. */
5
+ export interface RemoteMachine {
6
+ host: TaRemoteHost;
7
+ relay?: TaRemoteHost;
8
+ }
9
+ export declare namespace RemoteMachinesUtil {
10
+ /**
11
+ * The machines of the list, each once: a cloud workspace on a host of ssh is that host's `relay` (the host made
12
+ * up, not connected, when it is no longer listed); those of gateways after the hosts.
13
+ */
14
+ function machines(hosts: readonly TaRemoteHost[]): RemoteMachine[];
15
+ /** The name of the cloud workspace of a gateway, from its address: its first label, free among `taken`. */
16
+ function cloudName(gateway: string, taken?: readonly string[]): string;
17
+ /** Whether a step is of making a host of ssh a cloud workspace, which the row of its handover shows, not that of the host. */
18
+ function relayStep(step: RemoteStepInfo | undefined): boolean;
19
+ /** What a host does now, in words: the step it is at, connected or not. */
20
+ function state(host: TaRemoteHost, step: RemoteStepInfo | undefined, t: Translate): string;
21
+ }
22
+ //# sourceMappingURL=remote-machines.d.ts.map
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RemoteMachinesUtil = void 0;
4
+ const ta_protocol_1 = require("@celljs/ta-protocol");
5
+ var RemoteMachinesUtil;
6
+ (function (RemoteMachinesUtil) {
7
+ /**
8
+ * The machines of the list, each once: a cloud workspace on a host of ssh is that host's `relay` (the host made
9
+ * up, not connected, when it is no longer listed); those of gateways after the hosts.
10
+ */
11
+ function machines(hosts) {
12
+ const relays = new Map(hosts.filter(host => host.source === 'cloud' && host.via).map(host => [host.via, host]));
13
+ const ssh = hosts.filter(host => host.source !== 'cloud');
14
+ const missing = [...relays.keys()].filter(via => !ssh.some(host => host.host === via));
15
+ return [
16
+ ...ssh.map(host => ({ host, relay: relays.get(host.host) })),
17
+ ...missing.map(via => ({ host: { host: via, source: 'recent', connected: false }, relay: relays.get(via) })),
18
+ ...hosts.filter(host => host.source === 'cloud' && !host.via).map(host => ({ host })),
19
+ ];
20
+ }
21
+ RemoteMachinesUtil.machines = machines;
22
+ /** The name of the cloud workspace of a gateway, from its address: its first label, free among `taken`. */
23
+ function cloudName(gateway, taken = []) {
24
+ var _a;
25
+ let host = gateway.trim();
26
+ try {
27
+ host = new URL(/^[a-z]+:\/\//i.test(host) ? host : `https://${host}`).hostname;
28
+ }
29
+ catch (_b) {
30
+ // What the user is typing: its first word is enough.
31
+ }
32
+ const first = ((_a = host.split(/[.:/]/)[0]) !== null && _a !== void 0 ? _a : '')
33
+ .toLowerCase()
34
+ .replace(/[^a-z0-9-]+/g, '-')
35
+ .replace(/^-+|-+$/g, '')
36
+ .slice(0, 36);
37
+ const base = /^[a-z0-9]/.test(first) ? first : 'cloud';
38
+ let name = base;
39
+ for (let n = 2; taken.includes(name); n++) {
40
+ name = `${base}-${n}`;
41
+ }
42
+ return name;
43
+ }
44
+ RemoteMachinesUtil.cloudName = cloudName;
45
+ /** Whether a step is of making a host of ssh a cloud workspace, which the row of its handover shows, not that of the host. */
46
+ function relayStep(step) {
47
+ return (step === null || step === void 0 ? void 0 : step.step) === 'installing-ta' || (step === null || step === void 0 ? void 0 : step.step) === 'starting-ta';
48
+ }
49
+ RemoteMachinesUtil.relayStep = relayStep;
50
+ /** What a host does now, in words: the step it is at, connected or not. */
51
+ function state(host, step, t) {
52
+ var _a;
53
+ return step
54
+ ? t(`ta.remote.step.${step.step}`, { host: ta_protocol_1.TaLocation.hostLabel(host.host), detail: (_a = step.detail) !== null && _a !== void 0 ? _a : '' })
55
+ : t(host.connected ? 'ta.remote.connected' : 'ta.remote.disconnected');
56
+ }
57
+ RemoteMachinesUtil.state = state;
58
+ })(RemoteMachinesUtil || (exports.RemoteMachinesUtil = RemoteMachinesUtil = {}));
59
+ //# sourceMappingURL=remote-machines.js.map
@@ -1,8 +1,7 @@
1
1
  import * as React from 'react';
2
2
  /**
3
3
  * What ssh asks while ta serve connects to a host, one question at a time, in every page that is open (the
4
- * first answer counts); a line at the bottom while a host connects, which may take a while the first
5
- * time (it installs Node.js there); and a notice when a connection is lost.
4
+ * first answer counts); and a notice when a connection is lost.
6
5
  */
7
- export declare function RemotePrompts(): React.JSX.Element;
6
+ export declare function RemotePrompts(): React.JSX.Element | null;
8
7
  //# sourceMappingURL=remote-prompts.d.ts.map
@@ -65,15 +65,13 @@ function PromptDialog({ prompt, onAnswer }) {
65
65
  }
66
66
  /**
67
67
  * What ssh asks while ta serve connects to a host, one question at a time, in every page that is open (the
68
- * first answer counts); a line at the bottom while a host connects, which may take a while the first
69
- * time (it installs Node.js there); and a notice when a connection is lost.
68
+ * first answer counts); and a notice when a connection is lost.
70
69
  */
71
70
  function RemotePrompts() {
72
71
  const t = (0, use_t_1.useT)();
73
72
  const [, bench] = (0, hooks_1.useWorkbench)();
74
73
  const [, notices] = (0, hooks_1.useNotices)();
75
74
  const [prompts, setPrompts] = React.useState([]);
76
- const [steps, setSteps] = React.useState({});
77
75
  const connected = React.useRef(new Set());
78
76
  React.useEffect(() => bench.onRemoteEvent((event) => {
79
77
  if (event.type === 'prompt') {
@@ -82,11 +80,7 @@ function RemotePrompts() {
82
80
  else if (event.type === 'prompt_closed') {
83
81
  setPrompts(shown => shown.filter(prompt => prompt.promptId !== event.promptId));
84
82
  }
85
- else if (event.type === 'progress') {
86
- setSteps(shown => { var _a; return ({ ...shown, [event.host]: t(`ta.remote.step.${event.step}`, { host: event.host, detail: (_a = event.detail) !== null && _a !== void 0 ? _a : '' }) }); });
87
- }
88
- else {
89
- setSteps(({ [event.host]: _gone, ...rest }) => rest);
83
+ else if (event.type === 'connection') {
90
84
  // Lost, not closed on purpose; a connection that failed is the caller's to tell.
91
85
  if (!event.connected && event.error && connected.current.has(event.host)) {
92
86
  notices.notify(t('ta.remote.lost', { host: event.host }), { level: 'warning', detail: event.error });
@@ -99,12 +93,6 @@ function RemotePrompts() {
99
93
  setPrompts(shown => shown.slice(1));
100
94
  void bench.remote.answer(prompt.promptId, value).catch(() => undefined);
101
95
  };
102
- const lines = Object.values(steps);
103
- return (React.createElement(React.Fragment, null,
104
- prompt && React.createElement(PromptDialog, { key: prompt.promptId, prompt: prompt, onAnswer: answer }),
105
- lines.length > 0 &&
106
- (0, react_dom_1.createPortal)(React.createElement("div", { className: "ta-remote-status", role: "status" },
107
- React.createElement("span", { className: "ta-spinner" }),
108
- lines.join(' · ')), document.body)));
96
+ return prompt ? React.createElement(PromptDialog, { key: prompt.promptId, prompt: prompt, onAnswer: answer }) : null;
109
97
  }
110
98
  //# sourceMappingURL=remote-prompts.js.map