@celljs/ta-web 4.15.0 → 4.15.1

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 (89) hide show
  1. package/esm/browser/components/account-menu.js +8 -1
  2. package/esm/browser/components/app-view.js +4 -1
  3. package/esm/browser/components/face.js +7 -2
  4. package/esm/browser/components/gallery.d.ts +9 -0
  5. package/esm/browser/components/gallery.js +57 -0
  6. package/esm/browser/components/host-view.d.ts +1 -1
  7. package/esm/browser/components/lightbox.d.ts +8 -1
  8. package/esm/browser/components/lightbox.js +4 -1
  9. package/esm/browser/components/markdown.js +6 -1
  10. package/esm/browser/components/media.d.ts +12 -2
  11. package/esm/browser/components/media.js +55 -13
  12. package/esm/browser/components/message-list.js +3 -2
  13. package/esm/browser/components/notice-center.js +6 -2
  14. package/esm/browser/components/serve-restart.d.ts +26 -0
  15. package/esm/browser/components/serve-restart.js +91 -0
  16. package/esm/browser/components/session-view.js +19 -11
  17. package/esm/browser/components/settings-parts.js +14 -5
  18. package/esm/browser/extension/icons.js +3 -1
  19. package/esm/browser/i18n/locales.d.ts +15 -3
  20. package/esm/browser/i18n/messages-ja.js +12 -0
  21. package/esm/browser/i18n/messages-zh-tw.js +12 -0
  22. package/esm/browser/i18n/messages.d.ts +12 -0
  23. package/esm/browser/i18n/messages.js +24 -0
  24. package/esm/browser/style/conversation.d.ts +1 -1
  25. package/esm/browser/style/conversation.js +18 -0
  26. package/esm/browser/style/layout.d.ts +1 -1
  27. package/esm/browser/style/layout.js +2 -0
  28. package/esm/browser/style/shell.d.ts +1 -1
  29. package/esm/browser/style/shell.js +2 -0
  30. package/esm/browser/style/surfaces.d.ts +1 -1
  31. package/esm/browser/style/surfaces.js +1 -0
  32. package/esm/browser/util/desktop.d.ts +6 -1
  33. package/esm/browser/util/desktop.js +10 -0
  34. package/esm/browser/util/gallery.d.ts +18 -0
  35. package/esm/browser/util/gallery.js +123 -0
  36. package/esm/browser/util/link.d.ts +8 -0
  37. package/esm/browser/util/link.js +14 -0
  38. package/esm/browser/util/markdown.d.ts +11 -0
  39. package/esm/browser/util/markdown.js +4 -0
  40. package/esm/browser/util/thumbnail.d.ts +18 -0
  41. package/esm/browser/util/thumbnail.js +26 -0
  42. package/esm/browser/workbench-protocol.d.ts +8 -0
  43. package/esm/browser/workbench.d.ts +16 -0
  44. package/esm/browser/workbench.js +67 -0
  45. package/lib/browser/components/account-menu.js +7 -0
  46. package/lib/browser/components/app-view.js +4 -1
  47. package/lib/browser/components/face.js +7 -2
  48. package/lib/browser/components/gallery.d.ts +10 -0
  49. package/lib/browser/components/gallery.js +93 -0
  50. package/lib/browser/components/host-view.d.ts +1 -1
  51. package/lib/browser/components/lightbox.d.ts +8 -1
  52. package/lib/browser/components/lightbox.js +4 -1
  53. package/lib/browser/components/markdown.js +6 -1
  54. package/lib/browser/components/media.d.ts +12 -2
  55. package/lib/browser/components/media.js +57 -13
  56. package/lib/browser/components/message-list.js +3 -2
  57. package/lib/browser/components/notice-center.js +6 -2
  58. package/lib/browser/components/serve-restart.d.ts +27 -0
  59. package/lib/browser/components/serve-restart.js +129 -0
  60. package/lib/browser/components/session-view.js +21 -13
  61. package/lib/browser/components/settings-parts.js +13 -4
  62. package/lib/browser/extension/icons.js +2 -0
  63. package/lib/browser/i18n/locales.d.ts +15 -3
  64. package/lib/browser/i18n/messages-ja.js +12 -0
  65. package/lib/browser/i18n/messages-zh-tw.js +12 -0
  66. package/lib/browser/i18n/messages.d.ts +12 -0
  67. package/lib/browser/i18n/messages.js +24 -0
  68. package/lib/browser/style/conversation.d.ts +1 -1
  69. package/lib/browser/style/conversation.js +18 -0
  70. package/lib/browser/style/layout.d.ts +1 -1
  71. package/lib/browser/style/layout.js +2 -0
  72. package/lib/browser/style/shell.d.ts +1 -1
  73. package/lib/browser/style/shell.js +2 -0
  74. package/lib/browser/style/surfaces.d.ts +1 -1
  75. package/lib/browser/style/surfaces.js +1 -0
  76. package/lib/browser/util/desktop.d.ts +6 -1
  77. package/lib/browser/util/desktop.js +10 -0
  78. package/lib/browser/util/gallery.d.ts +19 -0
  79. package/lib/browser/util/gallery.js +126 -0
  80. package/lib/browser/util/link.d.ts +8 -0
  81. package/lib/browser/util/link.js +14 -0
  82. package/lib/browser/util/markdown.d.ts +11 -0
  83. package/lib/browser/util/markdown.js +4 -0
  84. package/lib/browser/util/thumbnail.d.ts +19 -0
  85. package/lib/browser/util/thumbnail.js +29 -0
  86. package/lib/browser/workbench-protocol.d.ts +8 -0
  87. package/lib/browser/workbench.d.ts +16 -0
  88. package/lib/browser/workbench.js +67 -0
  89. package/package.json +7 -7
@@ -0,0 +1,129 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.ServeRestartUtil = void 0;
37
+ exports.useRestartTa = useRestartTa;
38
+ exports.ServeRestartNotices = ServeRestartNotices;
39
+ const React = __importStar(require("react"));
40
+ const hooks_1 = require("../hooks");
41
+ const use_t_1 = require("../i18n/use-t");
42
+ const workbench_util_1 = require("../workbench-util");
43
+ /** The build installed that the user put off restarting for (Later): not asked about again on this device. */
44
+ const LATER_KEY = 'ta.update.later';
45
+ var ServeRestartUtil;
46
+ (function (ServeRestartUtil) {
47
+ /** `v4.16.0`, with the commit of a build of the development channel: `v4.16.0 (695fbe1)`. */
48
+ function label(build) {
49
+ return `v${build.version}${build.build ? ` (${build.build})` : ''}`;
50
+ }
51
+ ServeRestartUtil.label = label;
52
+ function key(update) {
53
+ var _a;
54
+ return `${update.version}+${(_a = update.build) !== null && _a !== void 0 ? _a : ''}`;
55
+ }
56
+ ServeRestartUtil.key = key;
57
+ /** Whether the page may restart Ta: the owner, of a Ta service that can restart itself. */
58
+ function restartable(server) {
59
+ return !!server && !server.member && server.restartable === true;
60
+ }
61
+ ServeRestartUtil.restartable = restartable;
62
+ })(ServeRestartUtil || (exports.ServeRestartUtil = ServeRestartUtil = {}));
63
+ function useRestartTa() {
64
+ const t = (0, use_t_1.useT)();
65
+ const [{ server, restarting }, workbench] = (0, hooks_1.useWorkbench)();
66
+ const [, notices] = (0, hooks_1.useNotices)();
67
+ const restart = React.useCallback(async (ask = true) => {
68
+ if (ask && !(await notices.confirm({ title: t('ta.restart.confirm'), message: t('ta.restart.detail'), confirmLabel: t('ta.restart') }))) {
69
+ return;
70
+ }
71
+ await workbench.restartServer().catch(error => notices.error(error));
72
+ }, [t, notices, workbench]);
73
+ const can = ServeRestartUtil.restartable(server);
74
+ return { can, restarting: !!restarting, update: can ? server === null || server === void 0 ? void 0 : server.update : undefined, restart };
75
+ }
76
+ /**
77
+ * Tells of what restarting Ta is about, in a corner: another build installed (an update of Ta Desktop, `npm i -g`, a
78
+ * build of the repository), with Restart and Later, once for each build; Ta restarting, then back with its version.
79
+ */
80
+ function ServeRestartNotices() {
81
+ const t = (0, use_t_1.useT)();
82
+ const [{ server }] = (0, hooks_1.useWorkbench)();
83
+ const [, notices] = (0, hooks_1.useNotices)();
84
+ const { update, restarting, restart } = useRestartTa();
85
+ const told = React.useRef(undefined);
86
+ const key = update && ServeRestartUtil.key(update);
87
+ React.useEffect(() => {
88
+ var _a, _b;
89
+ if (!update || !key || restarting || ((_a = told.current) === null || _a === void 0 ? void 0 : _a.key) === key || ((_b = (0, workbench_util_1.storage)()) === null || _b === void 0 ? void 0 : _b.getItem(LATER_KEY)) === key) {
90
+ return;
91
+ }
92
+ told.current = {
93
+ key,
94
+ id: notices.notify(t('ta.update.ready', { version: ServeRestartUtil.label(update) }), {
95
+ detail: t('ta.update.readyDetail'),
96
+ key: 'ta-serve-update',
97
+ sticky: true,
98
+ actions: [{ label: t('ta.update.later'), run: () => { var _a; return (_a = (0, workbench_util_1.storage)()) === null || _a === void 0 ? void 0 : _a.setItem(LATER_KEY, key); } }],
99
+ action: { label: t('ta.restart'), run: () => void restart(false) },
100
+ }),
101
+ };
102
+ }, [update, key, restarting, notices, restart, t]);
103
+ React.useEffect(() => {
104
+ // Restarted, or put in place some other way: nothing to restart for any more.
105
+ if (!key && told.current) {
106
+ notices.dismiss(told.current.id);
107
+ told.current = undefined;
108
+ }
109
+ }, [key, notices]);
110
+ const restartingId = React.useRef(undefined);
111
+ // Read once the restart ended: a server read again meanwhile says nothing.
112
+ const serverNow = React.useRef(server);
113
+ serverNow.current = server;
114
+ React.useEffect(() => {
115
+ if (restarting) {
116
+ restartingId.current = notices.notify(t('ta.restart.restarting'), { key: 'ta-serve-restart', sticky: true });
117
+ }
118
+ else if (restartingId.current !== undefined) {
119
+ notices.dismiss(restartingId.current);
120
+ restartingId.current = undefined;
121
+ const back = serverNow.current;
122
+ if (back) {
123
+ notices.notify(t('ta.restart.done', { version: ServeRestartUtil.label(back) }), { level: 'success', key: 'ta-serve-restart' });
124
+ }
125
+ }
126
+ }, [restarting, notices, t]);
127
+ return null;
128
+ }
129
+ //# sourceMappingURL=serve-restart.js.map
@@ -43,8 +43,10 @@ const files_protocol_1 = require("../files/files-protocol");
43
43
  const hooks_1 = require("../hooks");
44
44
  const use_t_1 = require("../i18n/use-t");
45
45
  const code_renderers_1 = require("../markdown/code-renderers");
46
+ const link_1 = require("../util/link");
46
47
  const message_1 = require("../util/message");
47
48
  const terminal_text_1 = require("../util/terminal-text");
49
+ const thumbnail_1 = require("../util/thumbnail");
48
50
  const workbench_protocol_1 = require("../workbench-protocol");
49
51
  const chat_asks_1 = require("./chat-asks");
50
52
  const composer_1 = require("./composer");
@@ -54,7 +56,7 @@ const conversation_scroll_hooks_1 = require("./conversation-scroll-hooks");
54
56
  const dialog_view_1 = require("./dialog-view");
55
57
  const earlier_messages_1 = require("./earlier-messages");
56
58
  const grow_box_1 = require("./grow-box");
57
- const link_1 = require("./link");
59
+ const link_2 = require("./link");
58
60
  const media_1 = require("./media");
59
61
  const message_actions_1 = require("./message-actions");
60
62
  const message_footer_1 = require("./message-footer");
@@ -65,14 +67,17 @@ const terminal_art_1 = require("./terminal-art");
65
67
  const use_stop_times_1 = require("./use-stop-times");
66
68
  /**
67
69
  * What the extensions of the session say with `notify` goes to the notices of the page; what was said before it
68
- * opened stays quiet. A picture in it (a QR code to sign in) is drawn, and stays until the next notice of the
69
- * session, which says how it went or brings a new code.
70
+ * opened stays quiet. A picture in it (a QR code to sign in) is drawn, a web address in it (a page to sign in on)
71
+ * is a button that opens it, and either stays until the next notice of the session, which says how it went or
72
+ * brings a new one.
70
73
  */
71
74
  function useSessionNotices(store, notices) {
75
+ const t = (0, use_t_1.useT)();
72
76
  const [, center] = (0, hooks_1.useNotices)();
77
+ const openLink = (0, hooks_1.useOpenLink)(undefined);
73
78
  // Of the store shown: one that took the place of another (attached for what the device showed) starts quiet too.
74
79
  const seen = React.useRef(undefined);
75
- const picture = React.useRef(undefined);
80
+ const lasting = React.useRef(undefined);
76
81
  React.useEffect(() => {
77
82
  var _a;
78
83
  if (((_a = seen.current) === null || _a === void 0 ? void 0 : _a.store) !== store) {
@@ -82,16 +87,19 @@ function useSessionNotices(store, notices) {
82
87
  for (const notice of notices) {
83
88
  if (!seen.current.ids.has(notice.id)) {
84
89
  seen.current.ids.add(notice.id);
85
- if (picture.current !== undefined) {
86
- center.dismiss(picture.current);
87
- picture.current = undefined;
90
+ if (lasting.current !== undefined) {
91
+ center.dismiss(lasting.current);
92
+ lasting.current = undefined;
88
93
  }
89
- const { text, art } = terminal_text_1.TerminalText.art(notice.message);
90
- const id = center.notify(text, { level: notice.type, art, sticky: art !== undefined });
91
- picture.current = art ? id : undefined;
94
+ const art = terminal_text_1.TerminalText.art(notice.message);
95
+ const { text, url } = link_1.LinkUtil.noticeLink(art.text);
96
+ const action = url ? { label: t('ta.notice.openLink'), run: () => openLink({ type: 'url', url }, false) } : undefined;
97
+ const keep = art.art !== undefined || url !== undefined;
98
+ const id = center.notify(text, { level: notice.type, art: art.art, action, sticky: keep });
99
+ lasting.current = keep ? id : undefined;
92
100
  }
93
101
  }
94
- }, [store, notices, center]);
102
+ }, [store, notices, center, t, openLink]);
95
103
  }
96
104
  /** What an extension shows above or below the message box (`setWidget`): its lines as a terminal draws them, a picture in them drawn. */
97
105
  function WidgetView({ lines }) {
@@ -159,7 +167,7 @@ function SessionView({ store, server, workspace, info, onClosed, onActivity, lea
159
167
  }
160
168
  }, [draftText]);
161
169
  const files = (0, react_1.useInject)(files_protocol_1.TaFiles);
162
- const fileUrl = React.useCallback(async (path) => files.loadable(await workspace.fileUrl(path, cwd)), [workspace, cwd, files]);
170
+ const fileUrl = React.useCallback(async (path, box) => files.loadable(thumbnail_1.ThumbnailUtil.boxed(await workspace.fileUrl(path, cwd), box)), [workspace, cwd, files]);
163
171
  const namedPaths = React.useCallback(() => message_1.MessageUtil.namedPaths(store.state.messages), [store]);
164
172
  const openLink = (0, hooks_1.useOpenLink)(cwd, namedPaths);
165
173
  // biome-ignore lint/correctness/useExhaustiveDependencies: runs when a run starts or settles
@@ -202,7 +210,7 @@ function SessionView({ store, server, workspace, info, onClosed, onActivity, lea
202
210
  React.createElement(message_list_1.ConversationSession.Provider, { value: info },
203
211
  React.createElement(message_footer_1.MessageActions.Provider, { value: messageActions },
204
212
  React.createElement(media_1.FileUrls.Provider, { value: fileUrl },
205
- React.createElement(link_1.OpenLink.Provider, { value: openLink },
213
+ React.createElement(link_2.OpenLink.Provider, { value: openLink },
206
214
  React.createElement(message_list_1.MessageImages.Provider, { value: images },
207
215
  React.createElement(code_renderers_1.CodeReply.Provider, { value: reply },
208
216
  React.createElement(message_list_1.MessageList, { state: state, outbox: outbox, rows: rows }))))))))),
@@ -55,6 +55,7 @@ const launch_settings_1 = require("./launch-settings");
55
55
  const model_picker_1 = require("./model-picker");
56
56
  const relay_services_1 = require("./relay-services");
57
57
  const remote_hosts_1 = require("./remote-hosts");
58
+ const serve_restart_1 = require("./serve-restart");
58
59
  const settings_controls_1 = require("./settings-controls");
59
60
  const sign_in_setup_1 = require("./sign-in-setup");
60
61
  const trusted_domains_1 = require("./trusted-domains");
@@ -77,6 +78,7 @@ function useParts(scope, onScope, onClose, onDialog) {
77
78
  const access = (0, access_view_1.useAccess)();
78
79
  const signInConfig = (0, sign_in_setup_1.useSignInConfig)();
79
80
  const gateway = (0, environment_view_1.useGateway)();
81
+ const restartTa = (0, serve_restart_1.useRestartTa)();
80
82
  // As the menu of the account (useAccountEntries): a finger has no keys to learn; a phone is not the computer
81
83
  // that pairs phones, and signs out at the foot of Me.
82
84
  const touch = (0, device_1.useDevice)(device => device.touch);
@@ -353,10 +355,17 @@ function useParts(scope, onScope, onClose, onDialog) {
353
355
  icon: lucide_react_1.Info,
354
356
  rows: workbench.server
355
357
  ? [
356
- (0, settings_controls_1.row)('version', [t('ta.settings.version'), 'version'], React.createElement(settings_controls_1.Row, { label: t('ta.settings.version') },
357
- React.createElement("span", { className: "ta-path" },
358
- "v",
359
- workbench.server.version))),
358
+ (0, settings_controls_1.row)('version', [t('ta.settings.version'), 'version'], React.createElement(settings_controls_1.Row, { label: t('ta.settings.version'), description: restartTa.update && t('ta.update.ready', { version: serve_restart_1.ServeRestartUtil.label(restartTa.update) }) },
359
+ React.createElement("span", { className: "ta-path" }, serve_restart_1.ServeRestartUtil.label(workbench.server)))),
360
+ ...(restartTa.can
361
+ ? [
362
+ (0, settings_controls_1.row)('restart', [t('ta.restart'), t('ta.restart.description'), 'restart', 'update'], React.createElement(settings_controls_1.Row, { label: t('ta.restart'), description: t('ta.restart.description') },
363
+ React.createElement("button", { type: "button", className: `ta-button${restartTa.update ? ' ta-primary' : ''}`, disabled: restartTa.restarting, onClick: () => void restartTa.restart() },
364
+ restartTa.restarting ? React.createElement("span", { className: "ta-spinner" }) : React.createElement(icon_1.Icon, { icon: lucide_react_1.RotateCw, size: 15 }),
365
+ ' ',
366
+ t('ta.restart.button')))),
367
+ ]
368
+ : []),
360
369
  (0, settings_controls_1.row)('cwd', [t('ta.settings.cwd'), workbench.server.cwd], React.createElement(settings_controls_1.Row, { label: t('ta.settings.cwd'), description: t('ta.settings.cwdDescription', { path: workbench.server.cwd }) },
361
370
  React.createElement("button", { type: "button", className: "ta-button", onClick: () => onDialog('directory') },
362
371
  React.createElement(icon_1.Icon, { icon: lucide_react_1.FolderOpen, size: 15 }),
@@ -15,8 +15,10 @@ exports.WEB_ICONS = Object.freeze({
15
15
  BellOff: lucide_react_1.BellOff,
16
16
  BookOpen: lucide_react_1.BookOpen,
17
17
  Bot: lucide_react_1.Bot,
18
+ Box: lucide_react_1.Box,
18
19
  Building2: lucide_react_1.Building2,
19
20
  CaseSensitive: lucide_react_1.CaseSensitive,
21
+ ChartSpline: lucide_react_1.ChartSpline,
20
22
  Check: lucide_react_1.Check,
21
23
  ChevronDown: lucide_react_1.ChevronDown,
22
24
  ChevronRight: lucide_react_1.ChevronRight,