@celljs/ta-web 4.46.2 → 4.47.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 (285) hide show
  1. package/esm/browser/account/account-side.d.ts +3 -3
  2. package/esm/browser/account/account-side.js +11 -21
  3. package/esm/browser/account/device-account.d.ts +8 -0
  4. package/esm/browser/account/device-account.js +20 -0
  5. package/esm/browser/chat/chat-protocol.d.ts +7 -0
  6. package/esm/browser/chat/chat-view.js +1 -1
  7. package/esm/browser/chat/chat.d.ts +1 -0
  8. package/esm/browser/chat/chat.js +15 -3
  9. package/esm/browser/chat/draft-model.d.ts +1 -1
  10. package/esm/browser/chat/draft-model.js +2 -2
  11. package/esm/browser/components/access-view.js +12 -10
  12. package/esm/browser/components/account-menu.d.ts +2 -0
  13. package/esm/browser/components/account-menu.js +11 -2
  14. package/esm/browser/components/account-view.js +9 -5
  15. package/esm/browser/components/app-nav.js +4 -1
  16. package/esm/browser/components/app-shell-state.d.ts +2 -0
  17. package/esm/browser/components/app-update-view.d.ts +2 -0
  18. package/esm/browser/components/app-update-view.js +37 -0
  19. package/esm/browser/components/app-view.js +33 -108
  20. package/esm/browser/components/auth-guide.d.ts +25 -0
  21. package/esm/browser/components/auth-guide.js +44 -0
  22. package/esm/browser/components/auth-view.d.ts +2 -0
  23. package/esm/browser/components/auth-view.js +30 -9
  24. package/esm/browser/components/chat-list-controls.d.ts +38 -0
  25. package/esm/browser/components/chat-list-controls.js +46 -0
  26. package/esm/browser/components/chat-list-hooks.d.ts +19 -0
  27. package/esm/browser/components/chat-list-hooks.js +52 -0
  28. package/esm/browser/components/chat-list-rows.d.ts +51 -0
  29. package/esm/browser/components/chat-list-rows.js +110 -0
  30. package/esm/browser/components/chat-list-sections.d.ts +36 -0
  31. package/esm/browser/components/chat-list-sections.js +72 -0
  32. package/esm/browser/components/chat-list.js +48 -221
  33. package/esm/browser/components/cloud-sign-in-view.d.ts +1 -1
  34. package/esm/browser/components/cloud-sign-in-view.js +4 -1
  35. package/esm/browser/components/custom-provider-util.d.ts +2 -0
  36. package/esm/browser/components/custom-provider-util.js +5 -0
  37. package/esm/browser/components/custom-provider-view.js +33 -12
  38. package/esm/browser/components/device-sign-in-page.js +4 -5
  39. package/esm/browser/components/discover-view.d.ts +8 -1
  40. package/esm/browser/components/discover-view.js +28 -3
  41. package/esm/browser/components/environment-view.js +60 -62
  42. package/esm/browser/components/extension-settings.js +1 -0
  43. package/esm/browser/components/first-steps-util.d.ts +29 -0
  44. package/esm/browser/components/first-steps-util.js +41 -0
  45. package/esm/browser/components/first-steps.d.ts +3 -0
  46. package/esm/browser/components/first-steps.js +36 -0
  47. package/esm/browser/components/host-view.d.ts +3 -3
  48. package/esm/browser/components/host-view.js +11 -11
  49. package/esm/browser/components/me-rows.d.ts +8 -1
  50. package/esm/browser/components/me-rows.js +3 -3
  51. package/esm/browser/components/me-view.js +1 -1
  52. package/esm/browser/components/message-user.js +6 -3
  53. package/esm/browser/components/model-picker.d.ts +5 -0
  54. package/esm/browser/components/model-picker.js +10 -1
  55. package/esm/browser/components/nav-places.d.ts +14 -0
  56. package/esm/browser/components/nav-places.js +11 -0
  57. package/esm/browser/components/phone-shell.d.ts +14 -0
  58. package/esm/browser/components/phone-shell.js +22 -0
  59. package/esm/browser/components/picture-dialog.js +4 -7
  60. package/esm/browser/components/profile-view.js +1 -1
  61. package/esm/browser/components/relay-services.js +4 -7
  62. package/esm/browser/components/relay-view-util.d.ts +5 -0
  63. package/esm/browser/components/relay-view-util.js +14 -0
  64. package/esm/browser/components/relay-view.js +40 -37
  65. package/esm/browser/components/scan-screen.js +5 -8
  66. package/esm/browser/components/screen-navigator.d.ts +9 -0
  67. package/esm/browser/components/screen-navigator.js +84 -0
  68. package/esm/browser/components/search-page.js +9 -2
  69. package/esm/browser/components/serve-value.d.ts +27 -0
  70. package/esm/browser/components/serve-value.js +61 -0
  71. package/esm/browser/components/serve-watch.d.ts +23 -0
  72. package/esm/browser/components/serve-watch.js +36 -0
  73. package/esm/browser/components/settings-choices.js +2 -0
  74. package/esm/browser/components/settings-controls.d.ts +15 -0
  75. package/esm/browser/components/settings-controls.js +13 -0
  76. package/esm/browser/components/settings-more.js +6 -4
  77. package/esm/browser/components/settings-parts.d.ts +3 -1
  78. package/esm/browser/components/settings-parts.js +3 -0
  79. package/esm/browser/components/settings-view.js +37 -11
  80. package/esm/browser/components/share-friends.js +3 -4
  81. package/esm/browser/components/share-sheet.js +3 -4
  82. package/esm/browser/components/tool-view.js +17 -3
  83. package/esm/browser/device/app-update.d.ts +62 -0
  84. package/esm/browser/device/app-update.js +144 -0
  85. package/esm/browser/extension/icons.js +2 -1
  86. package/esm/browser/extension/web-api-contributions.d.ts +6 -1
  87. package/esm/browser/extension/web-api-partners.d.ts +6 -0
  88. package/esm/browser/extension/web-api-spec.js +1 -0
  89. package/esm/browser/extension/web-home.js +9 -0
  90. package/esm/browser/extension/web-metrics.d.ts +3 -0
  91. package/esm/browser/extension/web-metrics.js +33 -22
  92. package/esm/browser/extension/web-pages.d.ts +3 -1
  93. package/esm/browser/extension/web-pages.js +1 -0
  94. package/esm/browser/gateway/console-agents.js +11 -15
  95. package/esm/browser/gateway/console-parts.d.ts +7 -4
  96. package/esm/browser/gateway/console-parts.js +11 -20
  97. package/esm/browser/gateway/console-trend.js +2 -2
  98. package/esm/browser/gateway/console-updates.js +6 -4
  99. package/esm/browser/gateway/console-view.js +6 -6
  100. package/esm/browser/i18n/en/account.d.ts +7 -0
  101. package/esm/browser/i18n/en/account.js +13 -6
  102. package/esm/browser/i18n/en/chat.d.ts +2 -0
  103. package/esm/browser/i18n/en/chat.js +2 -0
  104. package/esm/browser/i18n/en/discover.d.ts +3 -0
  105. package/esm/browser/i18n/en/discover.js +3 -0
  106. package/esm/browser/i18n/en/service.d.ts +6 -0
  107. package/esm/browser/i18n/en/service.js +6 -0
  108. package/esm/browser/i18n/en/settings.d.ts +3 -0
  109. package/esm/browser/i18n/en/settings.js +3 -0
  110. package/esm/browser/i18n/ja/account.js +13 -6
  111. package/esm/browser/i18n/ja/chat.js +2 -0
  112. package/esm/browser/i18n/ja/discover.js +3 -0
  113. package/esm/browser/i18n/ja/service.js +6 -0
  114. package/esm/browser/i18n/ja/settings.js +3 -0
  115. package/esm/browser/i18n/locales.d.ts +22 -1
  116. package/esm/browser/i18n/messages.d.ts +21 -0
  117. package/esm/browser/i18n/zh/account.js +13 -6
  118. package/esm/browser/i18n/zh/chat.js +2 -0
  119. package/esm/browser/i18n/zh/discover.js +3 -0
  120. package/esm/browser/i18n/zh/service.js +6 -0
  121. package/esm/browser/i18n/zh/settings.js +3 -0
  122. package/esm/browser/i18n/zh-tw/account.js +13 -6
  123. package/esm/browser/i18n/zh-tw/chat.js +2 -0
  124. package/esm/browser/i18n/zh-tw/discover.js +3 -0
  125. package/esm/browser/i18n/zh-tw/service.js +6 -0
  126. package/esm/browser/i18n/zh-tw/settings.js +3 -0
  127. package/esm/browser/notices/notices.d.ts +2 -0
  128. package/esm/browser/notices/notices.js +2 -0
  129. package/esm/browser/partners/group-picker.js +3 -4
  130. package/esm/browser/sandbox/sandbox-runtime-code.js +1 -1
  131. package/esm/browser/settings/settings-protocol.d.ts +5 -0
  132. package/esm/browser/settings/settings-protocol.js +2 -0
  133. package/esm/browser/style/chat-list.d.ts +1 -1
  134. package/esm/browser/style/chat-list.js +4 -3
  135. package/esm/browser/style/dialogs.d.ts +1 -1
  136. package/esm/browser/style/dialogs.js +7 -0
  137. package/esm/browser/style/pages.d.ts +1 -1
  138. package/esm/browser/style/pages.js +5 -3
  139. package/esm/browser/style/shell.d.ts +1 -1
  140. package/esm/browser/style/shell.js +1 -1
  141. package/esm/browser/util/tool.d.ts +5 -0
  142. package/esm/browser/util/tool.js +21 -3
  143. package/lib/browser/account/account-side.d.ts +3 -3
  144. package/lib/browser/account/account-side.js +11 -21
  145. package/lib/browser/account/device-account.d.ts +8 -0
  146. package/lib/browser/account/device-account.js +20 -0
  147. package/lib/browser/chat/chat-protocol.d.ts +7 -0
  148. package/lib/browser/chat/chat-view.js +1 -1
  149. package/lib/browser/chat/chat.d.ts +1 -0
  150. package/lib/browser/chat/chat.js +14 -2
  151. package/lib/browser/chat/draft-model.d.ts +1 -1
  152. package/lib/browser/chat/draft-model.js +2 -2
  153. package/lib/browser/components/access-view.js +12 -10
  154. package/lib/browser/components/account-menu.d.ts +2 -0
  155. package/lib/browser/components/account-menu.js +11 -2
  156. package/lib/browser/components/account-view.js +9 -5
  157. package/lib/browser/components/app-nav.js +3 -0
  158. package/lib/browser/components/app-shell-state.d.ts +2 -0
  159. package/lib/browser/components/app-update-view.d.ts +3 -0
  160. package/lib/browser/components/app-update-view.js +73 -0
  161. package/lib/browser/components/app-view.js +30 -105
  162. package/lib/browser/components/auth-guide.d.ts +26 -0
  163. package/lib/browser/components/auth-guide.js +47 -0
  164. package/lib/browser/components/auth-view.d.ts +2 -0
  165. package/lib/browser/components/auth-view.js +29 -8
  166. package/lib/browser/components/chat-list-controls.d.ts +39 -0
  167. package/lib/browser/components/chat-list-controls.js +86 -0
  168. package/lib/browser/components/chat-list-hooks.d.ts +19 -0
  169. package/lib/browser/components/chat-list-hooks.js +53 -0
  170. package/lib/browser/components/chat-list-rows.d.ts +52 -0
  171. package/lib/browser/components/chat-list-rows.js +147 -0
  172. package/lib/browser/components/chat-list-sections.d.ts +37 -0
  173. package/lib/browser/components/chat-list-sections.js +108 -0
  174. package/lib/browser/components/chat-list.js +44 -217
  175. package/lib/browser/components/cloud-sign-in-view.d.ts +1 -1
  176. package/lib/browser/components/cloud-sign-in-view.js +4 -1
  177. package/lib/browser/components/custom-provider-util.d.ts +2 -0
  178. package/lib/browser/components/custom-provider-util.js +5 -0
  179. package/lib/browser/components/custom-provider-view.js +32 -11
  180. package/lib/browser/components/device-sign-in-page.js +4 -5
  181. package/lib/browser/components/discover-view.d.ts +8 -1
  182. package/lib/browser/components/discover-view.js +27 -2
  183. package/lib/browser/components/environment-view.js +60 -62
  184. package/lib/browser/components/extension-settings.js +1 -0
  185. package/lib/browser/components/first-steps-util.d.ts +30 -0
  186. package/lib/browser/components/first-steps-util.js +44 -0
  187. package/lib/browser/components/first-steps.d.ts +4 -0
  188. package/lib/browser/components/first-steps.js +72 -0
  189. package/lib/browser/components/host-view.d.ts +3 -3
  190. package/lib/browser/components/host-view.js +11 -11
  191. package/lib/browser/components/me-rows.d.ts +8 -1
  192. package/lib/browser/components/me-rows.js +3 -3
  193. package/lib/browser/components/me-view.js +1 -1
  194. package/lib/browser/components/message-user.js +5 -2
  195. package/lib/browser/components/model-picker.d.ts +5 -0
  196. package/lib/browser/components/model-picker.js +10 -1
  197. package/lib/browser/components/nav-places.d.ts +14 -0
  198. package/lib/browser/components/nav-places.js +13 -1
  199. package/lib/browser/components/phone-shell.d.ts +14 -0
  200. package/lib/browser/components/phone-shell.js +23 -0
  201. package/lib/browser/components/picture-dialog.js +4 -7
  202. package/lib/browser/components/profile-view.js +1 -1
  203. package/lib/browser/components/relay-services.js +4 -7
  204. package/lib/browser/components/relay-view-util.d.ts +6 -0
  205. package/lib/browser/components/relay-view-util.js +17 -0
  206. package/lib/browser/components/relay-view.js +38 -35
  207. package/lib/browser/components/scan-screen.js +5 -8
  208. package/lib/browser/components/screen-navigator.d.ts +9 -0
  209. package/lib/browser/components/screen-navigator.js +85 -0
  210. package/lib/browser/components/search-page.js +8 -1
  211. package/lib/browser/components/serve-value.d.ts +28 -0
  212. package/lib/browser/components/serve-value.js +97 -0
  213. package/lib/browser/components/serve-watch.d.ts +24 -0
  214. package/lib/browser/components/serve-watch.js +39 -0
  215. package/lib/browser/components/settings-choices.js +2 -0
  216. package/lib/browser/components/settings-controls.d.ts +15 -0
  217. package/lib/browser/components/settings-controls.js +13 -0
  218. package/lib/browser/components/settings-more.js +6 -4
  219. package/lib/browser/components/settings-parts.d.ts +3 -1
  220. package/lib/browser/components/settings-parts.js +3 -0
  221. package/lib/browser/components/settings-view.js +36 -10
  222. package/lib/browser/components/share-friends.js +3 -4
  223. package/lib/browser/components/share-sheet.js +3 -4
  224. package/lib/browser/components/tool-view.js +17 -3
  225. package/lib/browser/device/app-update.d.ts +63 -0
  226. package/lib/browser/device/app-update.js +182 -0
  227. package/lib/browser/extension/icons.js +1 -0
  228. package/lib/browser/extension/web-api-contributions.d.ts +6 -1
  229. package/lib/browser/extension/web-api-partners.d.ts +6 -0
  230. package/lib/browser/extension/web-api-spec.js +1 -0
  231. package/lib/browser/extension/web-home.js +9 -0
  232. package/lib/browser/extension/web-metrics.d.ts +3 -0
  233. package/lib/browser/extension/web-metrics.js +32 -21
  234. package/lib/browser/extension/web-pages.d.ts +3 -1
  235. package/lib/browser/extension/web-pages.js +1 -0
  236. package/lib/browser/gateway/console-agents.js +10 -14
  237. package/lib/browser/gateway/console-parts.d.ts +7 -4
  238. package/lib/browser/gateway/console-parts.js +12 -21
  239. package/lib/browser/gateway/console-trend.js +1 -1
  240. package/lib/browser/gateway/console-updates.js +5 -3
  241. package/lib/browser/gateway/console-view.js +5 -5
  242. package/lib/browser/i18n/en/account.d.ts +7 -0
  243. package/lib/browser/i18n/en/account.js +13 -6
  244. package/lib/browser/i18n/en/chat.d.ts +2 -0
  245. package/lib/browser/i18n/en/chat.js +2 -0
  246. package/lib/browser/i18n/en/discover.d.ts +3 -0
  247. package/lib/browser/i18n/en/discover.js +3 -0
  248. package/lib/browser/i18n/en/service.d.ts +6 -0
  249. package/lib/browser/i18n/en/service.js +6 -0
  250. package/lib/browser/i18n/en/settings.d.ts +3 -0
  251. package/lib/browser/i18n/en/settings.js +3 -0
  252. package/lib/browser/i18n/ja/account.js +13 -6
  253. package/lib/browser/i18n/ja/chat.js +2 -0
  254. package/lib/browser/i18n/ja/discover.js +3 -0
  255. package/lib/browser/i18n/ja/service.js +6 -0
  256. package/lib/browser/i18n/ja/settings.js +3 -0
  257. package/lib/browser/i18n/locales.d.ts +22 -1
  258. package/lib/browser/i18n/messages.d.ts +21 -0
  259. package/lib/browser/i18n/zh/account.js +13 -6
  260. package/lib/browser/i18n/zh/chat.js +2 -0
  261. package/lib/browser/i18n/zh/discover.js +3 -0
  262. package/lib/browser/i18n/zh/service.js +6 -0
  263. package/lib/browser/i18n/zh/settings.js +3 -0
  264. package/lib/browser/i18n/zh-tw/account.js +13 -6
  265. package/lib/browser/i18n/zh-tw/chat.js +2 -0
  266. package/lib/browser/i18n/zh-tw/discover.js +3 -0
  267. package/lib/browser/i18n/zh-tw/service.js +6 -0
  268. package/lib/browser/i18n/zh-tw/settings.js +3 -0
  269. package/lib/browser/notices/notices.d.ts +2 -0
  270. package/lib/browser/notices/notices.js +3 -1
  271. package/lib/browser/partners/group-picker.js +3 -4
  272. package/lib/browser/sandbox/sandbox-runtime-code.js +1 -1
  273. package/lib/browser/settings/settings-protocol.d.ts +5 -0
  274. package/lib/browser/settings/settings-protocol.js +2 -0
  275. package/lib/browser/style/chat-list.d.ts +1 -1
  276. package/lib/browser/style/chat-list.js +4 -3
  277. package/lib/browser/style/dialogs.d.ts +1 -1
  278. package/lib/browser/style/dialogs.js +7 -0
  279. package/lib/browser/style/pages.d.ts +1 -1
  280. package/lib/browser/style/pages.js +5 -3
  281. package/lib/browser/style/shell.d.ts +1 -1
  282. package/lib/browser/style/shell.js +1 -1
  283. package/lib/browser/util/tool.d.ts +5 -0
  284. package/lib/browser/util/tool.js +21 -3
  285. package/package.json +7 -7
@@ -9,6 +9,7 @@ import { HostUtil } from '../hosts.js';
9
9
  import { useT } from '../i18n/use-t.js';
10
10
  import { pageHost, WorkbenchError, WorkbenchUtil } from '../workbench-util.js';
11
11
  import { AccountAsk } from './account-view.js';
12
+ import { BusyMark, useBusy } from './busy.js';
12
13
  import { Callout } from './callout.js';
13
14
  import { ChatListUtil } from './chat-list-util.js';
14
15
  import { Icon } from './icon.js';
@@ -22,9 +23,10 @@ import { TaAvatar } from './ta-avatar.js';
22
23
  export function useAddHost() {
23
24
  const t = useT();
24
25
  const [, bench] = useWorkbench();
25
- const [busy, setBusy] = React.useState(false);
26
+ // One at a time, scanning included: the button that started it turns until the computer is added or it failed.
27
+ const [busy, run] = useBusy();
26
28
  const [error, setError] = React.useState();
27
- const add = React.useCallback(async (text, scanned = false) => {
29
+ const connect = React.useCallback(async (text, scanned = false) => {
28
30
  var _a;
29
31
  const credential = WorkbenchUtil.credential(text);
30
32
  // The app and the mini program have no ta serve of their page to give a token to; a code is always a pairing.
@@ -32,7 +34,6 @@ export function useAddHost() {
32
34
  setError('ta.hosts.notPairing');
33
35
  return;
34
36
  }
35
- setBusy(true);
36
37
  setError(undefined);
37
38
  try {
38
39
  await bench.signIn(text);
@@ -45,22 +46,20 @@ export function useAddHost() {
45
46
  catch (failure) {
46
47
  setError(failure instanceof WorkbenchError && failure.reason === 'refused' ? 'ta.hosts.refused' : 'ta.hosts.unreachable');
47
48
  }
48
- finally {
49
- setBusy(false);
50
- }
51
49
  }, [bench]);
52
- const scan = React.useCallback(async () => {
50
+ const add = React.useCallback((text) => run(() => connect(text)), [run, connect]);
51
+ const scan = React.useCallback(() => run(async () => {
53
52
  setError(undefined);
54
53
  try {
55
54
  const text = await CodeScan.read(t('ta.hosts.scanInstructions'), t('ta.cancel'));
56
55
  if (text) {
57
- await add(text, true);
56
+ await connect(text, true);
58
57
  }
59
58
  }
60
59
  catch (failure) {
61
60
  setError(failure instanceof ScanError && failure.reason === 'denied' ? 'ta.hosts.cameraDenied' : 'ta.hosts.scanFailed');
62
61
  }
63
- }, [add, t]);
62
+ }), [run, connect, t]);
64
63
  return { busy, error, add, scan, canScan: CodeScan.available() };
65
64
  }
66
65
  /** The second line of a computer: who runs Ta there, and the way to it. */
@@ -152,8 +151,9 @@ export function ConnectComputer({ error, children }) {
152
151
  const [pasting, setPasting] = React.useState(!adding.canScan);
153
152
  const shown = (_a = adding.error) !== null && _a !== void 0 ? _a : error;
154
153
  return (React.createElement(React.Fragment, null,
155
- adding.canScan && (React.createElement("button", { type: "button", className: "ta-button ta-primary ta-wide ta-scan-button", disabled: adding.busy, onClick: () => void adding.scan() },
156
- adding.busy ? React.createElement("span", { className: "ta-spinner" }) : React.createElement(Icon, { icon: ScanLine, size: 18 }),
154
+ adding.canScan && (React.createElement("button", { type: "button", className: `ta-button ta-primary ta-wide ta-scan-button${adding.busy ? ' ta-busy' : ''}`, disabled: adding.busy, onClick: adding.scan },
155
+ React.createElement(BusyMark, { busy: adding.busy }),
156
+ React.createElement(Icon, { icon: ScanLine, size: 18 }),
157
157
  " ",
158
158
  t('ta.hosts.scan'))),
159
159
  pasting ? (React.createElement(LinkForm, { busy: adding.busy, autoFocus: !adding.canScan, placeholder: t(WorkbenchUtil.ownDevice() ? 'ta.signin.pairing' : 'ta.signin.token'), onSubmit: text => void adding.add(text) })) : (React.createElement("button", { type: "button", className: "ta-link-button", onClick: () => setPasting(true) }, t('ta.hosts.paste'))),
@@ -6,6 +6,8 @@ export interface MeState {
6
6
  own: string[];
7
7
  /** A new version of Ta waits for a restart. */
8
8
  update: boolean;
9
+ /** A newer version of the phone app, which does not update itself, to install (AppUpdates). */
10
+ appUpdate?: boolean;
9
11
  /** The page can be installed as an app and is not one yet. */
10
12
  installable: boolean;
11
13
  /** The phone app, signed in to an account. */
@@ -14,10 +16,15 @@ export interface MeState {
14
16
  signIn?: boolean;
15
17
  /** A computer's browser, which pairs phones (neither the app nor a phone). */
16
18
  pairPhone: boolean;
19
+ /**
20
+ * Something to sign out of: an account, or a Ta of another machine reached by a code. Not the Ta of this machine
21
+ * without an account, which signing out would only cut off.
22
+ */
23
+ signOut: boolean;
17
24
  }
18
25
  /**
19
26
  * The rows of Me, as WeChat's: what is the user's (the double's look, their devices, the model accounts, the vault),
20
- * the pages extensions add there, the settings (with what waits for the user: a new version, installing the app), and
27
+ * the pages extensions add there, the settings (with what waits for the user: a new version, of Ta or of the phone app, installing the app), and
21
28
  * leaving. What only sets something (the theme, the language, the extensions, the keys, about) is in the settings
22
29
  * alone, one tap away (docs/design/ta-me.md 9).
23
30
  */
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * The rows of Me, as WeChat's: what is the user's (the double's look, their devices, the model accounts, the vault),
3
- * the pages extensions add there, the settings (with what waits for the user: a new version, installing the app), and
3
+ * the pages extensions add there, the settings (with what waits for the user: a new version, of Ta or of the phone app, installing the app), and
4
4
  * leaving. What only sets something (the theme, the language, the extensions, the keys, about) is in the settings
5
5
  * alone, one tap away (docs/design/ta-me.md 9).
6
6
  */
@@ -10,8 +10,8 @@ export var MeUtil;
10
10
  return [
11
11
  ['look', 'devices', ...(state.pairPhone ? ['relay'] : []), 'accounts', ...(state.vault ? ['vault'] : [])],
12
12
  state.own.map(id => `page:${id}`),
13
- ['settings', ...(state.update ? ['restart'] : []), ...(state.installable ? ['install'] : [])],
14
- [...(state.signIn ? ['signIn'] : []), ...(state.switchAccount ? ['switchAccount'] : []), 'signOut'],
13
+ ['settings', ...(state.update ? ['restart'] : []), ...(state.appUpdate ? ['appUpdate'] : []), ...(state.installable ? ['install'] : [])],
14
+ [...(state.signIn ? ['signIn'] : []), ...(state.switchAccount ? ['switchAccount'] : []), ...(state.signOut ? ['signOut'] : [])],
15
15
  ].filter(group => group.length > 0);
16
16
  }
17
17
  MeUtil.keys = keys;
@@ -25,7 +25,7 @@ export function MeView({ onSettings }) {
25
25
  ((_a = account.account) !== null && _a !== void 0 ? _a : account.machine) && React.createElement("span", { className: "ta-me-host ta-ellipsis" }, (_b = account.account) !== null && _b !== void 0 ? _b : account.machine),
26
26
  React.createElement("span", { className: "ta-me-state" },
27
27
  React.createElement("span", { className: `ta-account-state ${account.online ? 'ta-ok' : 'ta-warn'}` }),
28
- account.account && account.machine ? account.machine : t('ta.account.service'),
28
+ account.account && account.machine ? account.machine : account.computer,
29
29
  " \u00B7 ",
30
30
  account.service)),
31
31
  React.createElement(Icon, { icon: ChevronRight, size: 18, className: "ta-list-chevron" })),
@@ -1,10 +1,11 @@
1
- import { TA_OWNER, TaImageNote, TaMessageAuthor, TaMessageContext, TaMessageSource, TaPackageTextUtil, TaSaid, TaSkillUse, TaTaskNote, } from '@celljs/ta-protocol';
1
+ import { TA_OWNER, TaErrorCode, TaImageNote, TaMessageAuthor, TaMessageContext, TaMessageSource, TaPackageTextUtil, TaSaid, TaSkillUse, TaTaskNote, } from '@celljs/ta-protocol';
2
2
  import { Bot, ChevronRight, CircleAlert, Clock3, Puzzle, Sparkles } from 'lucide-react';
3
3
  import * as React from 'react';
4
4
  import { AssistantTaskUtil } from '../assistant/assistant-task-util.js';
5
5
  import { LoadedExtensions } from '../extension/extension-view.js';
6
6
  import { WEB_ICONS } from '../extension/icons.js';
7
7
  import { useLanguage, useT } from '../i18n/use-t.js';
8
+ import { SIGN_IN_EVENT } from '../notices/notices.js';
8
9
  import { MessageUtil } from '../util/message.js';
9
10
  import { Face } from './face.js';
10
11
  import { Icon } from './icon.js';
@@ -19,11 +20,13 @@ export const Outbox = React.createContext({ of: new Map() });
19
20
  /** A message that did not go: marked as such, with a way to send it again or take it back, as in a messenger. */
20
21
  function SendFailed({ sent, actions }) {
21
22
  const t = useT();
23
+ // For want of a model: said, with the way to connect one; it goes by itself once one is (TaChat.resendSignedOut).
24
+ const noModel = sent.code === TaErrorCode.NOT_SIGNED_IN;
22
25
  return (React.createElement("div", { className: "ta-send-failed", title: sent.failed },
23
26
  React.createElement(Icon, { icon: CircleAlert, size: 14 }),
24
- React.createElement("span", null, t('ta.message.sendFailed')),
27
+ React.createElement("span", null, t(noModel ? 'ta.message.noModel' : 'ta.message.sendFailed')),
25
28
  actions && (React.createElement(React.Fragment, null,
26
- React.createElement("button", { type: "button", className: "ta-link-button", onClick: () => actions.resend(sent.id) }, t('ta.message.resend')),
29
+ noModel ? (React.createElement("button", { type: "button", className: "ta-link-button", onClick: () => window.dispatchEvent(new Event(SIGN_IN_EVENT)) }, t('ta.message.connectModel'))) : (React.createElement("button", { type: "button", className: "ta-link-button", onClick: () => actions.resend(sent.id) }, t('ta.message.resend'))),
27
30
  React.createElement("button", { type: "button", className: "ta-link-button", onClick: () => actions.discard(sent.id) }, t('ta.message.discard'))))));
28
31
  }
29
32
  /**
@@ -14,6 +14,11 @@ export declare namespace ModelPickerUtil {
14
14
  function withoutAgents<T extends ModelSource & Pick<TaSettingsSnapshot, 'agents'>>(source: T): T;
15
15
  /** The model of the settings of `snapshot`'s directory: the project's, else the user's. */
16
16
  function settingsModel(snapshot: Pick<TaSettingsSnapshot, 'user' | 'project'>): string | undefined;
17
+ /**
18
+ * The model a new conversation of `snapshot`'s directory works with when none is picked: pi's choice, that of
19
+ * the settings when the server did not tell it, or it is one `snapshot` leaves out (withoutAgents).
20
+ */
21
+ function initialModel(snapshot: Pick<TaSettingsSnapshot, 'user' | 'project' | 'models' | 'initialModel'>): string | undefined;
17
22
  /**
18
23
  * The models as entries of a list, under their providers in the order the providers first come, `value`
19
24
  * checked; a `value` no longer offered comes first, so that it stays.
@@ -40,6 +40,15 @@ export var ModelPickerUtil;
40
40
  return typeof model === 'string' && model ? model : undefined;
41
41
  }
42
42
  ModelPickerUtil.settingsModel = settingsModel;
43
+ /**
44
+ * The model a new conversation of `snapshot`'s directory works with when none is picked: pi's choice, that of
45
+ * the settings when the server did not tell it, or it is one `snapshot` leaves out (withoutAgents).
46
+ */
47
+ function initialModel(snapshot) {
48
+ const model = snapshot.initialModel;
49
+ return model && snapshot.models.includes(model) ? model : settingsModel(snapshot);
50
+ }
51
+ ModelPickerUtil.initialModel = initialModel;
43
52
  /**
44
53
  * The models as entries of a list, under their providers in the order the providers first come, `value`
45
54
  * checked; a `value` no longer offered comes first, so that it stays.
@@ -172,7 +181,7 @@ export function SettingsModelPicker({ settings, cwd, value, onChange, defaultLab
172
181
  const t = useT();
173
182
  const read = useModelSource(settings, cwd);
174
183
  const source = React.useMemo(() => (read && noAgents ? ModelPickerUtil.withoutAgents(read) : read), [read, noAgents]);
175
- const fallback = source && ModelPickerUtil.settingsModel(source);
184
+ const fallback = source && ModelPickerUtil.initialModel(source);
176
185
  const shown = defaultLabel !== null && defaultLabel !== void 0 ? defaultLabel : (fallback ? t('ta.model.default', { name: ModelPickerUtil.name(source, fallback) }) : t('ta.model.defaultNone'));
177
186
  // An agent picked before it was left out does not count: the default is what holds.
178
187
  const picked = noAgents && ((_a = read === null || read === void 0 ? void 0 : read.agents) === null || _a === void 0 ? void 0 : _a.includes(value)) ? '' : value;
@@ -43,6 +43,10 @@ export interface Navigation {
43
43
  */
44
44
  onOpen: WebPageInfo[];
45
45
  setting: NavigationSetting;
46
+ /** Whether Discover lists a page first (discoverFirst); none while the user has all listed (Settings.allFeatures). */
47
+ first?(id: string): boolean;
48
+ /** All features listed in Discover itself, or not. */
49
+ showAll(on: boolean): void;
46
50
  pin(id: string): void;
47
51
  fold(id: string): void;
48
52
  update(setting: NavigationSetting): void;
@@ -68,6 +72,16 @@ export declare function discoverGroups<T extends {
68
72
  group: WebPageGroup;
69
73
  pages: T[];
70
74
  }[];
75
+ /** A feature opened in the last of these days stays in the first list of Discover (docs/design/ta-simple.md 4.2). */
76
+ export declare const DISCOVER_RECENT_DAYS = 30;
77
+ /** What Discover reads of a page to place it: its WebPageInfo. */
78
+ export type DiscoverInfo = Pick<WebPageInfo, 'tier' | 'extensionId' | 'usedAt'>;
79
+ /**
80
+ * Whether Discover lists a page first, or under All features (docs/design/ta-simple.md 4.2): first, one of a package the
81
+ * user added, one for most people (`tier` common), one opened in the last DISCOVER_RECENT_DAYS days; the others wait
82
+ * under All features until used, as the apps of a phone in its library.
83
+ */
84
+ export declare function discoverFirst(info: DiscoverInfo | undefined, now: number): boolean;
71
85
  /** Discover is in the navigation: some pages are under it. */
72
86
  export declare function hasDiscover(navigation: Pick<Navigation, 'discover' | 'onOpen'>): boolean;
73
87
  export interface PhoneTabLabels {
@@ -53,6 +53,17 @@ export function discoverGroups(pages) {
53
53
  const of = (page) => (page.group && DISCOVER_GROUPS.includes(page.group) ? page.group : 'more');
54
54
  return DISCOVER_GROUPS.map(group => ({ group, pages: pages.filter(page => of(page) === group) })).filter(entry => entry.pages.length > 0);
55
55
  }
56
+ /** A feature opened in the last of these days stays in the first list of Discover (docs/design/ta-simple.md 4.2). */
57
+ export const DISCOVER_RECENT_DAYS = 30;
58
+ /**
59
+ * Whether Discover lists a page first, or under All features (docs/design/ta-simple.md 4.2): first, one of a package the
60
+ * user added, one for most people (`tier` common), one opened in the last DISCOVER_RECENT_DAYS days; the others wait
61
+ * under All features until used, as the apps of a phone in its library.
62
+ */
63
+ export function discoverFirst(info, now) {
64
+ return (!!info &&
65
+ (!!info.extensionId || info.tier === 'common' || (info.usedAt !== undefined && now - info.usedAt < DISCOVER_RECENT_DAYS * 24 * 60 * 60 * 1000)));
66
+ }
56
67
  /** Discover is in the navigation: some pages are under it. */
57
68
  export function hasDiscover(navigation) {
58
69
  return navigation.discover.length > 0 || navigation.onOpen.length > 0;
@@ -83,6 +83,20 @@ export interface PhoneStackProps {
83
83
  * an extension (`ui.Stack`), the head of the page shows back while it is open.
84
84
  */
85
85
  export declare function PhoneStack({ base, top, open, onClose }: PhoneStackProps): React.JSX.Element;
86
+ /**
87
+ * What a tab of a phone shows, and the conversations going on (ui.showChats with `busy`) pushed over it while
88
+ * `busy`, as the folder of the chats is pushed over their list: back with its button, a swipe from the left edge or the
89
+ * back of the system (PhoneStack, a layer of BackLayers), to the tab as it was; a conversation picked in it comes over
90
+ * it, and goes back to it. Drawn while open and while it slides away. Not over a page of an extension's own in the
91
+ * tabs (`pushable`, SideListUtil.pushesOver): the page is drawn as it is, the shell shows those going on over the chats.
92
+ */
93
+ export declare function PhoneHome({ pushable, busy, onBusy, busyList, children, }: {
94
+ pushable: boolean;
95
+ busy: boolean;
96
+ onBusy(busy: boolean): void;
97
+ busyList(): React.ReactNode;
98
+ children: React.ReactNode;
99
+ }): string | number | bigint | boolean | React.JSX.Element | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | Iterable<React.ReactNode> | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | React.ReactPortal | null | undefined> | null | undefined;
86
100
  export declare namespace PhoneUtil {
87
101
  /** Two taps of a tab within this are one double tap. */
88
102
  const DOUBLE_TAP_MS = 350;
@@ -200,6 +200,28 @@ export function PhoneStack({ base, top, open, onClose }) {
200
200
  React.createElement("div", { className: "ta-phone-stack-top", inert: !open },
201
201
  React.createElement(BackLayerContext.Provider, { value: back.layer }, top))));
202
202
  }
203
+ /**
204
+ * What a tab of a phone shows, and the conversations going on (ui.showChats with `busy`) pushed over it while
205
+ * `busy`, as the folder of the chats is pushed over their list: back with its button, a swipe from the left edge or the
206
+ * back of the system (PhoneStack, a layer of BackLayers), to the tab as it was; a conversation picked in it comes over
207
+ * it, and goes back to it. Drawn while open and while it slides away. Not over a page of an extension's own in the
208
+ * tabs (`pushable`, SideListUtil.pushesOver): the page is drawn as it is, the shell shows those going on over the chats.
209
+ */
210
+ export function PhoneHome({ pushable, busy, onBusy, busyList, children, }) {
211
+ const [drawn, setDrawn] = React.useState(busy);
212
+ React.useEffect(() => {
213
+ if (busy) {
214
+ setDrawn(true);
215
+ return;
216
+ }
217
+ const timer = setTimeout(() => setDrawn(false), DeviceMotion.SHEET_MS);
218
+ return () => clearTimeout(timer);
219
+ }, [busy]);
220
+ if (!pushable) {
221
+ return children;
222
+ }
223
+ return React.createElement(PhoneStack, { base: children, top: (busy || drawn) && busyList(), open: busy, onClose: () => onBusy(false) });
224
+ }
203
225
  function TabBar({ tabs, tab, onTab }) {
204
226
  const t = useT();
205
227
  const [menu, openMenu] = useContextMenu();
@@ -3,6 +3,7 @@ import * as React from 'react';
3
3
  import { useNotices, useWebExtensions, useWorkbench } from '../hooks.js';
4
4
  import { useT } from '../i18n/use-t.js';
5
5
  import { PictureUtil } from '../util/picture.js';
6
+ import { useBusy } from './busy.js';
6
7
  import { Face } from './face.js';
7
8
  import { FacePictures } from './face-pictures.js';
8
9
  import { Icon } from './icon.js';
@@ -52,19 +53,15 @@ export function PictureDialog({ onClose }) {
52
53
  const pictures = React.useContext(FacePictures);
53
54
  const mine = !!pictures.pictures[pictures.self];
54
55
  const input = React.useRef(null);
55
- const [busy, setBusy] = React.useState(false);
56
+ const [busy, run] = useBusy();
56
57
  const [drawing, setDrawing] = React.useState();
57
58
  const set = async (picture) => {
58
- setBusy(true);
59
59
  try {
60
60
  await workbench.rooms.setPicture(picture);
61
61
  }
62
62
  catch (error) {
63
63
  notices.error(error);
64
64
  }
65
- finally {
66
- setBusy(false);
67
- }
68
65
  };
69
66
  const picked = async (file) => {
70
67
  const picture = await PictureUtil.square(file).catch(() => undefined);
@@ -96,7 +93,7 @@ export function PictureDialog({ onClose }) {
96
93
  React.createElement("button", { type: "button", className: "ta-button ta-wide", disabled: busy, onClick: () => setDrawing('') },
97
94
  React.createElement(Icon, { icon: Sparkles, size: 16 }),
98
95
  t('ta.picture.draw')),
99
- mine && (React.createElement("button", { type: "button", className: "ta-button ta-wide", disabled: busy, onClick: () => void set(null) },
96
+ mine && (React.createElement("button", { type: "button", className: "ta-button ta-wide", disabled: busy, onClick: () => void run(() => set(null)) },
100
97
  React.createElement(Icon, { icon: RotateCcw, size: 16 }),
101
98
  t('ta.picture.reset'))))) : (React.createElement("form", { className: "ta-picture-actions", onSubmit: event => {
102
99
  event.preventDefault();
@@ -109,7 +106,7 @@ export function PictureDialog({ onClose }) {
109
106
  const file = (_a = event.currentTarget.files) === null || _a === void 0 ? void 0 : _a[0];
110
107
  event.currentTarget.value = '';
111
108
  if (file) {
112
- void picked(file);
109
+ void run(() => picked(file));
113
110
  }
114
111
  } }))));
115
112
  }
@@ -44,7 +44,7 @@ export function useIdentity() {
44
44
  /** The account in use as a line: "Company account · su"; null while signed out, undefined until read. */
45
45
  export function useAccountLine() {
46
46
  const side = useAccountSide();
47
- const { info, failed } = useAccountInfo(side, 15000);
47
+ const { info, failed } = useAccountInfo(side);
48
48
  const way = useAccountWay();
49
49
  if ((info === null || info === void 0 ? void 0 : info.account) && !info.waiting) {
50
50
  return `${way(info.account.id)} · ${accountName(info.account)}`;
@@ -2,6 +2,7 @@ import { ArrowUp, Building2, Cloud, Database, ExternalLink, FileJson, Folder, Gi
2
2
  import * as React from 'react';
3
3
  import { useNotices, useWorkbench } from '../hooks.js';
4
4
  import { useT } from '../i18n/use-t.js';
5
+ import { useBusy } from './busy.js';
5
6
  import { Icon, IconButton } from './icon.js';
6
7
  import { AddCloudHost } from './remote-hosts.js';
7
8
  import { Row, Switch } from './settings-controls.js';
@@ -238,7 +239,7 @@ function Deployment({ relays, changed }) {
238
239
  const [, bench] = useWorkbench();
239
240
  const [, notices] = useNotices();
240
241
  const [url, setUrl] = React.useState('');
241
- const [busy, setBusy] = React.useState(false);
242
+ const [busy, run] = useBusy();
242
243
  const [clouds, setClouds] = React.useState();
243
244
  const joined = relays.deployment;
244
245
  const gateway = joined === null || joined === void 0 ? void 0 : joined.gateway;
@@ -252,7 +253,6 @@ function Deployment({ relays, changed }) {
252
253
  }
253
254
  }, [gateway, readClouds]);
254
255
  const act = async (action) => {
255
- setBusy(true);
256
256
  try {
257
257
  const listed = await action();
258
258
  changed(listed);
@@ -262,15 +262,12 @@ function Deployment({ relays, changed }) {
262
262
  notices.error(error);
263
263
  return undefined;
264
264
  }
265
- finally {
266
- setBusy(false);
267
- }
268
265
  };
269
266
  if (!joined) {
270
267
  return (React.createElement(Row, { label: t('ta.deploy.join'), description: t('ta.deploy.joinHint'), stacked: true },
271
268
  React.createElement("form", { className: "ta-trusted-add", onSubmit: event => {
272
269
  event.preventDefault();
273
- void act(() => bench.relay.joinDeployment(url.trim())).then(listed => {
270
+ void run(() => act(() => bench.relay.joinDeployment(url.trim()))).then(listed => {
274
271
  if (listed === null || listed === void 0 ? void 0 : listed.deployment) {
275
272
  setUrl('');
276
273
  notices.notify(t('ta.deploy.joined', { name: RelayServicesUtil.deploymentName(listed.deployment) }), { level: 'success' });
@@ -290,7 +287,7 @@ function Deployment({ relays, changed }) {
290
287
  const added = gateway && (clouds === null || clouds === void 0 ? void 0 : clouds.some(each => RelayServicesUtil.host(each) === RelayServicesUtil.host(gateway)));
291
288
  return (React.createElement(React.Fragment, null,
292
289
  React.createElement(Row, { icon: Building2, label: RelayServicesUtil.deploymentName(joined), description: [t('ta.deploy.joinedLine'), ...parts].join(' · ') },
293
- React.createElement("button", { type: "button", className: `ta-button${busy ? ' ta-busy' : ''}`, disabled: busy, onClick: () => void act(() => bench.relay.leaveDeployment()) },
290
+ React.createElement("button", { type: "button", className: `ta-button${busy ? ' ta-busy' : ''}`, disabled: busy, onClick: () => void run(() => act(() => bench.relay.leaveDeployment())) },
294
291
  busy && React.createElement("span", { className: "ta-spinner ta-busy-mark" }),
295
292
  React.createElement("span", null, t('ta.deploy.leave')))),
296
293
  gateway && (React.createElement(Row, { label: t('ta.deploy.cloud'), description: added ? t('ta.deploy.cloudAdded') : t('ta.deploy.cloudHint'), stacked: true },
@@ -0,0 +1,5 @@
1
+ import type { TaRelayDevice } from '@celljs/ta-protocol';
2
+ export declare namespace RelayViewUtil {
3
+ /** The name of the next device paired: `base`, numbered when one paired already has it (`Phone 2`). */
4
+ function nextName(base: string, devices: readonly Pick<TaRelayDevice, 'name'>[]): string;
5
+ }
@@ -0,0 +1,14 @@
1
+ export var RelayViewUtil;
2
+ (function (RelayViewUtil) {
3
+ /** The name of the next device paired: `base`, numbered when one paired already has it (`Phone 2`). */
4
+ function nextName(base, devices) {
5
+ const taken = new Set(devices.map(device => device.name));
6
+ let name = base;
7
+ for (let n = 2; taken.has(name); n++) {
8
+ name = `${base} ${n}`;
9
+ }
10
+ return name;
11
+ }
12
+ RelayViewUtil.nextName = nextName;
13
+ })(RelayViewUtil || (RelayViewUtil = {}));
14
+ //# sourceMappingURL=relay-view-util.js.map
@@ -1,15 +1,20 @@
1
- import { Copy, Smartphone, Trash2, X } from 'lucide-react';
1
+ import { TaServeChanges } from '@celljs/ta-protocol';
2
+ import { RELAY_DOWNLOAD_PAGE } from '@celljs/ta-relay/lib/common/relay-protocol';
3
+ import { Copy, Download, Smartphone, Trash2, X } from 'lucide-react';
2
4
  import * as React from 'react';
3
5
  import { createPortal } from 'react-dom';
4
6
  import { useBackLayer } from '../device/back-stack.js';
5
7
  import { useNotices, useWorkbench } from '../hooks.js';
6
8
  import { useT } from '../i18n/use-t.js';
7
9
  import { accountName } from './account-view.js';
8
- import { BusyMark } from './busy.js';
10
+ import { BusyMark, useBusy } from './busy.js';
9
11
  import { Icon, IconButton } from './icon.js';
10
12
  import { Picture } from './picture.js';
11
13
  import { QrView } from './qr-view.js';
14
+ import { RelayViewUtil } from './relay-view-util.js';
15
+ import { useServeValue } from './serve-value.js';
12
16
  import { Switch } from './settings-controls.js';
17
+ const RELAY_TOPICS = [TaServeChanges.RELAY];
13
18
  /** A phone and this computer, a relay between them, and a lock on what goes through. */
14
19
  function RelayPicture() {
15
20
  return (React.createElement(Picture, { width: 240, height: 72, frame: false, className: "ta-relay-pic" },
@@ -26,19 +31,32 @@ function RelayPicture() {
26
31
  React.createElement("circle", { className: "ta-pic-mark ta-pic-go", cx: "74", cy: "36", r: "3" }),
27
32
  React.createElement("circle", { className: "ta-pic-mark ta-pic-go ta-pic-go-back", cx: "153", cy: "36", r: "3" })));
28
33
  }
34
+ /** A device paired: its button turns until the relay forgot it. */
35
+ function RelayDeviceRow({ device, onUnpair }) {
36
+ const t = useT();
37
+ const [busy, run] = useBusy();
38
+ return (React.createElement("div", { className: "ta-auth-row ta-relay-device" },
39
+ React.createElement(Icon, { icon: Smartphone, size: 16 }),
40
+ React.createElement("span", { className: "ta-auth-name" }, device.name),
41
+ React.createElement("span", { className: "ta-auth-note" }, new Date(device.createdAt).toLocaleDateString()),
42
+ React.createElement(IconButton, { icon: Trash2, label: t('ta.relay.unpair'), busy: busy, onClick: () => void run(onUnpair) })));
43
+ }
29
44
  /** Using Ta from a phone: pair it through a relay, see and remove the devices paired. */
30
45
  export function RelayDialog({ onClose }) {
31
46
  var _a, _b;
32
47
  const t = useT();
33
48
  const [, bench] = useWorkbench();
34
49
  const [, notices] = useNotices();
35
- const [info, setInfo] = React.useState();
36
50
  const [link, setLink] = React.useState();
37
- const [name, setName] = React.useState('');
38
- const [busy, setBusy] = React.useState(false);
39
- const load = React.useCallback(() => {
40
- bench.relay.getRelay().then(setInfo, (error) => notices.error(error));
41
- }, [bench, notices]);
51
+ const [busy, run] = useBusy();
52
+ // Whether ta serve reached the relay shows as it does (TaServeChanges.RELAY), a moment after pairing.
53
+ const getRelay = React.useCallback(() => bench.relay.getRelay(), [bench]);
54
+ const { value: info, failed, read: load, set: setInfo } = useServeValue(getRelay, { topics: RELAY_TOPICS });
55
+ React.useEffect(() => {
56
+ if (failed) {
57
+ notices.error(failed);
58
+ }
59
+ }, [failed, notices]);
42
60
  // The account of this computer: the phones that scan its code sign in to it, unless turned off.
43
61
  const [account, setAccount] = React.useState();
44
62
  React.useEffect(() => {
@@ -53,12 +71,6 @@ export function RelayDialog({ onClose }) {
53
71
  throw error;
54
72
  }
55
73
  };
56
- React.useEffect(() => {
57
- load();
58
- // Whether ta serve reached the relay shows a moment after pairing.
59
- const timer = setInterval(load, 3000);
60
- return () => clearInterval(timer);
61
- }, [load]);
62
74
  useBackLayer(true, onClose);
63
75
  React.useEffect(() => {
64
76
  const onKey = (event) => event.key === 'Escape' && onClose();
@@ -67,31 +79,23 @@ export function RelayDialog({ onClose }) {
67
79
  }, [onClose]);
68
80
  const pair = async () => {
69
81
  var _a;
70
- if (!info || busy) {
82
+ if (!info) {
71
83
  return;
72
84
  }
73
- setBusy(true);
74
85
  try {
75
- const paired = await bench.relay.pair((_a = info.relay) !== null && _a !== void 0 ? _a : info.defaultRelay, name.trim() || t('ta.relay.phone'));
86
+ // Named for the user, rather than asked: a name of the phone's, numbered (RelayViewUtil.nextName).
87
+ const paired = await bench.relay.pair((_a = info.relay) !== null && _a !== void 0 ? _a : info.defaultRelay, RelayViewUtil.nextName(t('ta.relay.phone'), info.devices));
76
88
  setLink(paired.link);
77
- setName('');
78
- load();
89
+ void load();
79
90
  }
80
91
  catch (error) {
81
92
  notices.error(error);
82
93
  }
83
- finally {
84
- setBusy(false);
85
- }
86
94
  };
87
- // The device being unpaired: its button turns until the relay forgot it.
88
- const [unpairing, setUnpairing] = React.useState();
89
95
  const unpair = async (device) => {
90
96
  if (await notices.confirm({ title: t('ta.relay.unpairConfirm', { name: device.name }), confirmLabel: t('ta.relay.unpair'), danger: true })) {
91
- setUnpairing(device.id);
92
97
  await bench.relay.unpair(device.id).catch((error) => notices.error(error));
93
- setUnpairing(undefined);
94
- load();
98
+ void load();
95
99
  }
96
100
  };
97
101
  const keepAwake = async (on) => {
@@ -114,8 +118,14 @@ export function RelayDialog({ onClose }) {
114
118
  link ? (React.createElement("div", { className: "ta-relay-pairing" },
115
119
  React.createElement(QrView, { text: link }),
116
120
  React.createElement("p", null, t('ta.relay.scan')),
121
+ React.createElement("p", { className: "ta-relay-download" },
122
+ React.createElement(Icon, { icon: Download, size: 14 }),
123
+ React.createElement("span", null,
124
+ t('ta.relay.noApp'),
125
+ ' ',
126
+ React.createElement("a", { href: RELAY_DOWNLOAD_PAGE, target: "_blank", rel: "noreferrer" }, t('ta.relay.download')))),
117
127
  React.createElement("div", { className: "ta-auth-actions" },
118
- React.createElement("button", { type: "button", className: "ta-button", onClick: () => { var _a; return void ((_a = navigator.clipboard) === null || _a === void 0 ? void 0 : _a.writeText(link).catch(() => undefined)); } },
128
+ React.createElement("button", { type: "button", className: "ta-button", onClick: () => void run(() => { var _a; return (_a = navigator.clipboard) === null || _a === void 0 ? void 0 : _a.writeText(link).catch(() => undefined); }) },
119
129
  React.createElement(Icon, { icon: Copy, size: 15 }),
120
130
  " ",
121
131
  t('ta.auth.copyLink')),
@@ -123,21 +133,14 @@ export function RelayDialog({ onClose }) {
123
133
  React.createElement(RelayPicture, null),
124
134
  React.createElement("p", null, t('ta.relay.hint')),
125
135
  React.createElement("div", { className: "ta-relay-form" },
126
- React.createElement("label", { className: "ta-field" },
127
- React.createElement(Smartphone, { size: 15, strokeWidth: 1.75, "aria-hidden": "true" }),
128
- React.createElement("input", { placeholder: t('ta.relay.phone'), value: name, onChange: event => setName(event.target.value) })),
129
- React.createElement("button", { type: "button", className: busy ? 'ta-button ta-primary ta-busy' : 'ta-button ta-primary', "aria-busy": busy || undefined, disabled: !info, onClick: () => void pair() },
136
+ React.createElement("button", { type: "button", className: busy ? 'ta-button ta-primary ta-busy' : 'ta-button ta-primary', "aria-busy": busy || undefined, disabled: !info, onClick: () => void run(pair) },
130
137
  t('ta.relay.pair'),
131
138
  React.createElement(BusyMark, { busy: busy }))))),
132
139
  info && info.devices.length > 0 && (React.createElement("section", { className: "ta-auth-group" },
133
140
  React.createElement("h3", null,
134
141
  t('ta.relay.devices'),
135
142
  React.createElement("span", { className: `ta-relay-state${info.online ? ' ta-on' : ''}` }, info.online ? t('ta.relay.online', { relay: relayHost }) : t('ta.relay.offline', { relay: relayHost }))),
136
- info.devices.map(device => (React.createElement("div", { key: device.id, className: "ta-auth-row ta-relay-device" },
137
- React.createElement(Icon, { icon: Smartphone, size: 16 }),
138
- React.createElement("span", { className: "ta-auth-name" }, device.name),
139
- React.createElement("span", { className: "ta-auth-note" }, new Date(device.createdAt).toLocaleDateString()),
140
- React.createElement(IconButton, { icon: Trash2, label: t('ta.relay.unpair'), busy: unpairing === device.id, onClick: () => void unpair(device) })))))),
143
+ info.devices.map(device => (React.createElement(RelayDeviceRow, { key: device.id, device: device, onUnpair: () => unpair(device) }))))),
141
144
  (account === null || account === void 0 ? void 0 : account.account) && !account.waiting && account.onScan !== undefined && (React.createElement("div", { className: "ta-relay-awake" },
142
145
  React.createElement("span", { className: "ta-relay-awake-text" },
143
146
  React.createElement("span", null, t('ta.relay.accountOnScan')),
@@ -8,6 +8,7 @@ import { nativePlugin } from '../device/device.js';
8
8
  import { MiniProgram } from '../device/mini-program.js';
9
9
  import { useWorkbench } from '../hooks.js';
10
10
  import { useT } from '../i18n/use-t.js';
11
+ import { useBusy } from './busy.js';
11
12
  import { Icon } from './icon.js';
12
13
  import { RelayDialog } from './relay-view.js';
13
14
  import { TaAvatar } from './ta-avatar.js';
@@ -105,7 +106,7 @@ function ScanView({ instructions, onCode, onClose, onAsk }) {
105
106
  const [phase, setPhase] = React.useState({ kind: 'live' });
106
107
  const [myCode, setMyCode] = React.useState(false);
107
108
  const [text, setText] = React.useState('');
108
- const [sending, setSending] = React.useState(false);
109
+ const [sending, run] = useBusy();
109
110
  const [missed, setMissed] = React.useState(false);
110
111
  const camera = useCamera(video, facing);
111
112
  React.useEffect(() => {
@@ -214,10 +215,9 @@ function ScanView({ instructions, onCode, onClose, onAsk }) {
214
215
  }
215
216
  };
216
217
  const ask = async (prompt) => {
217
- if (phase.kind !== 'photo' || sending || !onAsk) {
218
+ if (phase.kind !== 'photo' || !onAsk) {
218
219
  return;
219
220
  }
220
- setSending(true);
221
221
  try {
222
222
  await onAsk(prompt, CodeVision.image(phase.url));
223
223
  close();
@@ -225,9 +225,6 @@ function ScanView({ instructions, onCode, onClose, onAsk }) {
225
225
  catch (_a) {
226
226
  // Said by onAsk; the photo stays to send again.
227
227
  }
228
- finally {
229
- setSending(false);
230
- }
231
228
  };
232
229
  const problem = camera.error === 'denied' ? 'ta.hosts.cameraDenied' : camera.error === 'failed' ? 'ta.scan.cameraFailed' : undefined;
233
230
  const said = missed ? 'ta.scan.noCodeFound' : problem;
@@ -261,10 +258,10 @@ function ScanView({ instructions, onCode, onClose, onAsk }) {
261
258
  event.target.value = '';
262
259
  } }))) : (React.createElement("form", { className: "ta-scan-sheet", onSubmit: event => {
263
260
  event.preventDefault();
264
- void ask(text.trim() || t('ta.scan.identifyPrompt'));
261
+ void run(() => ask(text.trim() || t('ta.scan.identifyPrompt')));
265
262
  } },
266
263
  React.createElement("div", { className: "ta-scan-sheet-title" }, t(phase.noCode ? 'ta.scan.noCode' : 'ta.scan.askTitle')),
267
- React.createElement("div", { className: "ta-scan-chips" }, ASKS.map(each => (React.createElement("button", { key: each.label, type: "button", className: "ta-scan-chip", disabled: sending, onClick: () => void ask(t(each.prompt)) }, t(each.label))))),
264
+ React.createElement("div", { className: "ta-scan-chips" }, ASKS.map(each => (React.createElement("button", { key: each.label, type: "button", className: "ta-scan-chip", disabled: sending, onClick: () => void run(() => ask(t(each.prompt))) }, t(each.label))))),
268
265
  React.createElement("div", { className: "ta-scan-field" },
269
266
  React.createElement("input", { value: text, placeholder: t('ta.scan.askPlaceholder'), "aria-label": t('ta.scan.askPlaceholder'), enterKeyHint: "send", onChange: event => setText(event.target.value) }),
270
267
  React.createElement("button", { type: "submit", className: "ta-scan-send", "aria-label": t('ta.send'), disabled: sending }, sending ? React.createElement("span", { className: "ta-spinner" }) : React.createElement(Icon, { icon: ArrowUp, size: 18 }))))),