@songsid/agend 2.3.5-alpha.5 → 2.3.5-alpha.7

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 (410) hide show
  1. package/THIRD_PARTY_NOTICES.md +0 -1
  2. package/dist/accounts-profiles.d.ts +96 -0
  3. package/dist/accounts-profiles.js +178 -0
  4. package/dist/accounts-profiles.js.map +1 -0
  5. package/dist/accounts-signout.d.ts +59 -0
  6. package/dist/accounts-signout.js +184 -0
  7. package/dist/accounts-signout.js.map +1 -0
  8. package/dist/accounts-view.d.ts +54 -0
  9. package/dist/accounts-view.js +55 -11
  10. package/dist/accounts-view.js.map +1 -1
  11. package/dist/agent-workspace.d.ts +11 -0
  12. package/dist/agent-workspace.js +28 -0
  13. package/dist/agent-workspace.js.map +1 -1
  14. package/dist/auth-api.js +38 -5
  15. package/dist/auth-api.js.map +1 -1
  16. package/dist/authority/session-authorizations.d.ts +2 -0
  17. package/dist/authority/session-authorizations.js +7 -1
  18. package/dist/authority/session-authorizations.js.map +1 -1
  19. package/dist/authority/web-authority.d.ts +13 -0
  20. package/dist/authority/web-authority.js +12 -0
  21. package/dist/authority/web-authority.js.map +1 -1
  22. package/dist/backend/claude-code.js +47 -9
  23. package/dist/backend/claude-code.js.map +1 -1
  24. package/dist/backend/codex.js +1 -0
  25. package/dist/backend/codex.js.map +1 -1
  26. package/dist/backend/kiro.js +1 -1
  27. package/dist/backend/kiro.js.map +1 -1
  28. package/dist/backend/types.d.ts +2 -0
  29. package/dist/backend/types.js.map +1 -1
  30. package/dist/build-provenance.json +1 -1
  31. package/dist/bundled-tmux-guard.d.ts +19 -0
  32. package/dist/bundled-tmux-guard.js +83 -0
  33. package/dist/bundled-tmux-guard.js.map +1 -0
  34. package/dist/channel/access-manager.d.ts +1 -6
  35. package/dist/channel/access-manager.js +4 -94
  36. package/dist/channel/access-manager.js.map +1 -1
  37. package/dist/channel/adapters/discord.d.ts +0 -2
  38. package/dist/channel/adapters/discord.js +0 -8
  39. package/dist/channel/adapters/discord.js.map +1 -1
  40. package/dist/channel/adapters/telegram.d.ts +0 -3
  41. package/dist/channel/adapters/telegram.js +1 -30
  42. package/dist/channel/adapters/telegram.js.map +1 -1
  43. package/dist/channel/types.d.ts +0 -2
  44. package/dist/classic-bindings.d.ts +13 -0
  45. package/dist/classic-bindings.js +28 -2
  46. package/dist/classic-bindings.js.map +1 -1
  47. package/dist/classic-channel-manager.d.ts +2 -0
  48. package/dist/classic-channel-manager.js +5 -1
  49. package/dist/classic-channel-manager.js.map +1 -1
  50. package/dist/cli.js +117 -30
  51. package/dist/cli.js.map +1 -1
  52. package/dist/config-validator.js +11 -0
  53. package/dist/config-validator.js.map +1 -1
  54. package/dist/config.js +3 -1
  55. package/dist/config.js.map +1 -1
  56. package/dist/daemon.d.ts +27 -2
  57. package/dist/daemon.js +107 -6
  58. package/dist/daemon.js.map +1 -1
  59. package/dist/doctor.js +3 -4
  60. package/dist/doctor.js.map +1 -1
  61. package/dist/e2e-isolation.js +5 -2
  62. package/dist/e2e-isolation.js.map +1 -1
  63. package/dist/fleet-control-audit.d.ts +1 -1
  64. package/dist/fleet-manager.d.ts +188 -1
  65. package/dist/fleet-manager.js +1059 -79
  66. package/dist/fleet-manager.js.map +1 -1
  67. package/dist/general-knowledge/skills/concepts/SKILL.md +22 -7
  68. package/dist/general-knowledge/skills/credential-profiles/SKILL.md +10 -0
  69. package/dist/general-knowledge/steering/core-rules.md +6 -4
  70. package/dist/hub/buttons.js +4 -2
  71. package/dist/hub/buttons.js.map +1 -1
  72. package/dist/hub/catalog.d.ts +1 -1
  73. package/dist/hub/catalog.js +82 -15
  74. package/dist/hub/catalog.js.map +1 -1
  75. package/dist/hub/compose/server.d.ts +4 -1
  76. package/dist/hub/compose/server.js +30 -3
  77. package/dist/hub/compose/server.js.map +1 -1
  78. package/dist/hub/directory/directory.d.ts +1 -1
  79. package/dist/hub/directory/directory.js +142 -21
  80. package/dist/hub/directory/directory.js.map +1 -1
  81. package/dist/hub/directory/groups.d.ts +29 -0
  82. package/dist/hub/directory/groups.js +29 -0
  83. package/dist/hub/directory/groups.js.map +1 -0
  84. package/dist/hub/directory/index.d.ts +2 -1
  85. package/dist/hub/directory/types.d.ts +12 -2
  86. package/dist/hub/directory/types.js.map +1 -1
  87. package/dist/hub/group-policy/admin-context.d.ts +23 -0
  88. package/dist/hub/group-policy/admin-context.js +52 -0
  89. package/dist/hub/group-policy/admin-context.js.map +1 -0
  90. package/dist/hub/group-policy/admin-dto.d.ts +235 -0
  91. package/dist/hub/group-policy/admin-dto.js +55 -0
  92. package/dist/hub/group-policy/admin-dto.js.map +1 -0
  93. package/dist/hub/group-policy/admin-inventory.d.ts +24 -0
  94. package/dist/hub/group-policy/admin-inventory.js +72 -0
  95. package/dist/hub/group-policy/admin-inventory.js.map +1 -0
  96. package/dist/hub/group-policy/admin-read.d.ts +21 -0
  97. package/dist/hub/group-policy/admin-read.js +90 -0
  98. package/dist/hub/group-policy/admin-read.js.map +1 -0
  99. package/dist/hub/group-policy/authorization.d.ts +43 -0
  100. package/dist/hub/group-policy/authorization.js +170 -0
  101. package/dist/hub/group-policy/authorization.js.map +1 -0
  102. package/dist/hub/group-policy/model.d.ts +56 -0
  103. package/dist/hub/group-policy/model.js +46 -0
  104. package/dist/hub/group-policy/model.js.map +1 -0
  105. package/dist/hub/group-policy/resources.d.ts +60 -0
  106. package/dist/hub/group-policy/resources.js +191 -0
  107. package/dist/hub/group-policy/resources.js.map +1 -0
  108. package/dist/hub/group-policy/store.d.ts +58 -0
  109. package/dist/hub/group-policy/store.js +155 -0
  110. package/dist/hub/group-policy/store.js.map +1 -0
  111. package/dist/hub/http/compose.js +9 -9
  112. package/dist/hub/http/compose.js.map +1 -1
  113. package/dist/hub/http/core.d.ts +23 -3
  114. package/dist/hub/http/core.js +138 -5
  115. package/dist/hub/http/core.js.map +1 -1
  116. package/dist/hub/http/deps.d.ts +3 -0
  117. package/dist/hub/pairing.d.ts +3 -1
  118. package/dist/hub/pairing.js +6 -3
  119. package/dist/hub/pairing.js.map +1 -1
  120. package/dist/hub/policy.d.ts +3 -1
  121. package/dist/hub/policy.js +13 -6
  122. package/dist/hub/policy.js.map +1 -1
  123. package/dist/hub/rooms.d.ts +1 -0
  124. package/dist/hub/rooms.js +76 -26
  125. package/dist/hub/rooms.js.map +1 -1
  126. package/dist/hub/server.d.ts +2 -0
  127. package/dist/hub/server.js +12 -2
  128. package/dist/hub/server.js.map +1 -1
  129. package/dist/hub/sessions.js +2 -1
  130. package/dist/hub/sessions.js.map +1 -1
  131. package/dist/hub/types.d.ts +2 -0
  132. package/dist/instance-config-impact.js +4 -3
  133. package/dist/instance-config-impact.js.map +1 -1
  134. package/dist/instance-lifecycle.d.ts +17 -0
  135. package/dist/instance-lifecycle.js +38 -1
  136. package/dist/instance-lifecycle.js.map +1 -1
  137. package/dist/locale.js +45 -18
  138. package/dist/locale.js.map +1 -1
  139. package/dist/login-controller.d.ts +5 -0
  140. package/dist/login-controller.js +11 -0
  141. package/dist/login-controller.js.map +1 -1
  142. package/dist/login-window-lock.d.ts +2 -1
  143. package/dist/login-window-lock.js.map +1 -1
  144. package/dist/ls-rows.d.ts +1 -1
  145. package/dist/ls-rows.js +1 -1
  146. package/dist/ls-rows.js.map +1 -1
  147. package/dist/machine-accounts.d.ts +110 -0
  148. package/dist/machine-accounts.js +229 -0
  149. package/dist/machine-accounts.js.map +1 -0
  150. package/dist/machine-signins.d.ts +89 -0
  151. package/dist/machine-signins.js +182 -0
  152. package/dist/machine-signins.js.map +1 -0
  153. package/dist/muse-usage-relay.d.ts +2 -0
  154. package/dist/muse-usage-relay.js +5 -3
  155. package/dist/muse-usage-relay.js.map +1 -1
  156. package/dist/needs-you-hub.d.ts +3 -0
  157. package/dist/needs-you-hub.js +13 -3
  158. package/dist/needs-you-hub.js.map +1 -1
  159. package/dist/needs-you.d.ts +35 -2
  160. package/dist/needs-you.js +19 -0
  161. package/dist/needs-you.js.map +1 -1
  162. package/dist/quickstart.js +7 -18
  163. package/dist/quickstart.js.map +1 -1
  164. package/dist/quiet-run.d.ts +31 -0
  165. package/dist/quiet-run.js +50 -0
  166. package/dist/quiet-run.js.map +1 -0
  167. package/dist/quota-notice-config.d.ts +22 -0
  168. package/dist/quota-notice-config.js +41 -0
  169. package/dist/quota-notice-config.js.map +1 -0
  170. package/dist/runtime-api.d.ts +13 -0
  171. package/dist/runtime-api.js +134 -2
  172. package/dist/runtime-api.js.map +1 -1
  173. package/dist/runtime-build-info.d.ts +2 -1
  174. package/dist/runtime-build-info.js +7 -3
  175. package/dist/runtime-build-info.js.map +1 -1
  176. package/dist/runtime-cli-install.d.ts +153 -0
  177. package/dist/runtime-cli-install.js +675 -0
  178. package/dist/runtime-cli-install.js.map +1 -0
  179. package/dist/runtime-cli.js +157 -12
  180. package/dist/runtime-cli.js.map +1 -1
  181. package/dist/runtime-client.d.ts +64 -2
  182. package/dist/runtime-client.js +277 -20
  183. package/dist/runtime-client.js.map +1 -1
  184. package/dist/runtime-coordinator.d.ts +10 -1
  185. package/dist/runtime-coordinator.js +93 -2
  186. package/dist/runtime-coordinator.js.map +1 -1
  187. package/dist/runtime-credential-profiles.d.ts +11 -2
  188. package/dist/runtime-credential-profiles.js +28 -4
  189. package/dist/runtime-credential-profiles.js.map +1 -1
  190. package/dist/runtime-install.js +9 -6
  191. package/dist/runtime-install.js.map +1 -1
  192. package/dist/runtime-pane-link.js +2 -1
  193. package/dist/runtime-pane-link.js.map +1 -1
  194. package/dist/runtime-pane-service.js +2 -2
  195. package/dist/runtime-pane-service.js.map +1 -1
  196. package/dist/runtime-pane-store.d.ts +10 -0
  197. package/dist/runtime-pane-store.js +13 -1
  198. package/dist/runtime-pane-store.js.map +1 -1
  199. package/dist/runtime-profile-ownership.d.ts +66 -0
  200. package/dist/runtime-profile-ownership.js +391 -0
  201. package/dist/runtime-profile-ownership.js.map +1 -0
  202. package/dist/runtime-protocol.d.ts +88 -2
  203. package/dist/runtime-protocol.js +40 -0
  204. package/dist/runtime-protocol.js.map +1 -1
  205. package/dist/runtime-remote-accounts.d.ts +197 -0
  206. package/dist/runtime-remote-accounts.js +663 -0
  207. package/dist/runtime-remote-accounts.js.map +1 -0
  208. package/dist/runtime-remote-setup.d.ts +105 -0
  209. package/dist/runtime-remote-setup.js +529 -0
  210. package/dist/runtime-remote-setup.js.map +1 -0
  211. package/dist/runtime-signin-transport.d.ts +39 -0
  212. package/dist/runtime-signin-transport.js +110 -0
  213. package/dist/runtime-signin-transport.js.map +1 -0
  214. package/dist/runtime-signin.d.ts +132 -0
  215. package/dist/runtime-signin.js +289 -0
  216. package/dist/runtime-signin.js.map +1 -0
  217. package/dist/runtime-update-attention.d.ts +4 -0
  218. package/dist/runtime-update-attention.js +11 -0
  219. package/dist/runtime-update-attention.js.map +1 -0
  220. package/dist/runtime-update-controller.d.ts +75 -0
  221. package/dist/runtime-update-controller.js +691 -0
  222. package/dist/runtime-update-controller.js.map +1 -0
  223. package/dist/runtime-update-ipc.d.ts +42 -0
  224. package/dist/runtime-update-ipc.js +144 -0
  225. package/dist/runtime-update-ipc.js.map +1 -0
  226. package/dist/runtime-update-journal.d.ts +5 -0
  227. package/dist/runtime-update-journal.js +7 -0
  228. package/dist/runtime-update-journal.js.map +1 -1
  229. package/dist/runtime-update-lock.js +17 -2
  230. package/dist/runtime-update-lock.js.map +1 -1
  231. package/dist/runtime-update-status.d.ts +30 -0
  232. package/dist/runtime-update-status.js +31 -0
  233. package/dist/runtime-update-status.js.map +1 -0
  234. package/dist/settings-api.js +6 -2
  235. package/dist/settings-api.js.map +1 -1
  236. package/dist/settings-change.d.ts +10 -0
  237. package/dist/settings-change.js +25 -1
  238. package/dist/settings-change.js.map +1 -1
  239. package/dist/settings-confirmation.d.ts +25 -1
  240. package/dist/settings-confirmation.js +11 -3
  241. package/dist/settings-confirmation.js.map +1 -1
  242. package/dist/settings-effect.js +18 -6
  243. package/dist/settings-effect.js.map +1 -1
  244. package/dist/settings-http-confirmation.d.ts +21 -0
  245. package/dist/settings-http-confirmation.js +74 -3
  246. package/dist/settings-http-confirmation.js.map +1 -1
  247. package/dist/settings-instance-patch.js +1 -1
  248. package/dist/settings-instance-patch.js.map +1 -1
  249. package/dist/setup-wizard.js +3 -5
  250. package/dist/setup-wizard.js.map +1 -1
  251. package/dist/signin-keepalive.d.ts +203 -0
  252. package/dist/signin-keepalive.js +652 -0
  253. package/dist/signin-keepalive.js.map +1 -0
  254. package/dist/structured-signin-transport.js +4 -0
  255. package/dist/structured-signin-transport.js.map +1 -1
  256. package/dist/structured-signin.d.ts +7 -0
  257. package/dist/structured-signin.js +4 -2
  258. package/dist/structured-signin.js.map +1 -1
  259. package/dist/tips.js +4 -4
  260. package/dist/tips.js.map +1 -1
  261. package/dist/tmux-binary.d.ts +23 -23
  262. package/dist/tmux-binary.js +35 -46
  263. package/dist/tmux-binary.js.map +1 -1
  264. package/dist/tmux-exec-helper.js +3 -3
  265. package/dist/tmux-exec-helper.js.map +1 -1
  266. package/dist/tmux-legacy.d.ts +94 -0
  267. package/dist/tmux-legacy.js +309 -0
  268. package/dist/tmux-legacy.js.map +1 -0
  269. package/dist/tmux-manager.d.ts +7 -1
  270. package/dist/tmux-manager.js +21 -11
  271. package/dist/tmux-manager.js.map +1 -1
  272. package/dist/tmux-rollback.d.ts +31 -0
  273. package/dist/tmux-rollback.js +72 -0
  274. package/dist/tmux-rollback.js.map +1 -0
  275. package/dist/tmux-server.d.ts +102 -0
  276. package/dist/tmux-server.js +248 -0
  277. package/dist/tmux-server.js.map +1 -0
  278. package/dist/transcript-monitor.js +43 -5
  279. package/dist/transcript-monitor.js.map +1 -1
  280. package/dist/transcript-records.d.ts +2 -1
  281. package/dist/transcript-records.js +3 -0
  282. package/dist/transcript-records.js.map +1 -1
  283. package/dist/transcript-sources.js +3 -0
  284. package/dist/transcript-sources.js.map +1 -1
  285. package/dist/types.d.ts +5 -0
  286. package/dist/types.js.map +1 -1
  287. package/dist/ui/accounts-keepalive.js +113 -0
  288. package/dist/ui/accounts-manage.js +237 -0
  289. package/dist/ui/accounts-view.js +191 -36
  290. package/dist/ui/agent-runtime-settings.js +2 -1
  291. package/dist/ui/app.html +8 -1
  292. package/dist/ui/backend-signin.js +12 -3
  293. package/dist/ui/general-location.js +28 -14
  294. package/dist/ui/hub-attachments.js +90 -0
  295. package/dist/ui/hub-chat-store.js +11 -5
  296. package/dist/ui/hub-client.js +20 -1
  297. package/dist/ui/hub-grant-strings.js +13 -0
  298. package/dist/ui/hub-owner-strings.js +6 -2
  299. package/dist/ui/hub-preview.js +101 -0
  300. package/dist/ui/hub-strings.js +4 -2
  301. package/dist/ui/machine-signin.js +56 -0
  302. package/dist/ui/panel-fleet.js +1 -1
  303. package/dist/ui/panel-hub.js +194 -54
  304. package/dist/ui/panel-log.js +2 -2
  305. package/dist/ui/panel-needs.js +14 -8
  306. package/dist/ui/panel-notices.js +4 -3
  307. package/dist/ui/panel-runtimes.js +32 -11
  308. package/dist/ui/panel-settings.js +18 -24
  309. package/dist/ui/panel-windows-agent.js +2 -1
  310. package/dist/ui/preview-pages.js +3 -41
  311. package/dist/ui/preview-panel-actions.js +3 -161
  312. package/dist/ui/preview-panel.js +10 -557
  313. package/dist/ui/preview-versions.js +3 -155
  314. package/dist/ui/runtime-cli-install.js +134 -0
  315. package/dist/ui/runtime-update-commands.d.ts +2 -0
  316. package/dist/ui/runtime-update-commands.js +11 -0
  317. package/dist/ui/runtime-update-status.js +53 -0
  318. package/dist/ui/search-dialog.js +3 -2
  319. package/dist/ui/settings-confirm.js +28 -0
  320. package/dist/ui/settings-devices.js +6 -10
  321. package/dist/ui/settings-guests.js +3 -2
  322. package/dist/ui/settings-hub-browser-certificate.js +2 -0
  323. package/dist/ui/settings-hub-membership.js +17 -11
  324. package/dist/ui/settings-hub-retention.js +2 -0
  325. package/dist/ui/settings-hub-section.js +35 -0
  326. package/dist/ui/settings-hub.js +17 -5
  327. package/dist/ui/settings-layout.js +6 -2
  328. package/dist/ui/settings-named-test.js +2 -2
  329. package/dist/ui/settings-outside.js +1 -1
  330. package/dist/ui/settings-quota-notice.js +102 -0
  331. package/dist/ui/settings-registry.js +4 -0
  332. package/dist/ui/settings-strings.js +6 -6
  333. package/dist/ui/settings-web-authority.js +2 -1
  334. package/dist/ui/shared/accounts-keepalive.css +7 -0
  335. package/dist/ui/shared/accounts.css +13 -0
  336. package/dist/ui/shared/app-i18n.js +4 -2
  337. package/dist/ui/shared/app-route.js +1 -1
  338. package/dist/ui/shared/app-shell.js +111 -8
  339. package/dist/ui/shared/app-store.js +2 -2
  340. package/dist/ui/shared/app.css +29 -0
  341. package/dist/ui/shared/app.js +2 -1
  342. package/dist/ui/shared/chat-strings.js +8 -8
  343. package/dist/ui/shared/hub-chat.css +1 -0
  344. package/dist/ui/shared/hub-owner.css +3 -3
  345. package/dist/ui/shared/hub-signin.css +24 -0
  346. package/dist/ui/shared/loading.css +37 -0
  347. package/dist/ui/shared/preview-pages.js +41 -0
  348. package/dist/ui/shared/preview-panel-actions.js +168 -0
  349. package/dist/ui/shared/preview-panel.js +565 -0
  350. package/dist/ui/shared/preview-versions.js +155 -0
  351. package/dist/ui/shared/runtime-install.css +4 -0
  352. package/dist/ui/shared/signin.js +68 -6
  353. package/dist/ui/shared/ui-states.js +14 -3
  354. package/dist/ui/shared/view-strings.js +4 -4
  355. package/dist/ui/shared/workspace-follow.css +19 -0
  356. package/dist/ui/signin.html +7 -3
  357. package/dist/ui/structured-signin.js +43 -11
  358. package/dist/ui/workspace-follow-strings.js +28 -0
  359. package/dist/ui/workspace-panel.js +225 -36
  360. package/dist/update-install.d.ts +7 -0
  361. package/dist/update-install.js +23 -0
  362. package/dist/update-install.js.map +1 -1
  363. package/dist/usage/providers.d.ts +6 -0
  364. package/dist/usage/providers.js +18 -9
  365. package/dist/usage/providers.js.map +1 -1
  366. package/dist/usage/quota-notices.d.ts +38 -0
  367. package/dist/usage/quota-notices.js +160 -0
  368. package/dist/usage/quota-notices.js.map +1 -0
  369. package/dist/usage/usage-api.d.ts +1 -0
  370. package/dist/usage/usage-api.js +16 -0
  371. package/dist/usage/usage-api.js.map +1 -1
  372. package/dist/web-api.d.ts +38 -0
  373. package/dist/web-api.js +357 -14
  374. package/dist/web-api.js.map +1 -1
  375. package/dist/web-login.d.ts +35 -1
  376. package/dist/web-login.js +51 -5
  377. package/dist/web-login.js.map +1 -1
  378. package/dist/web-remote-access.d.ts +6 -0
  379. package/dist/web-remote-access.js +10 -1
  380. package/dist/web-remote-access.js.map +1 -1
  381. package/dist/web-session.d.ts +11 -0
  382. package/dist/web-session.js +38 -1
  383. package/dist/web-session.js.map +1 -1
  384. package/dist/web-shell-routes.d.ts +1 -1
  385. package/dist/web-shell-routes.js +1 -1
  386. package/dist/web-shell-routes.js.map +1 -1
  387. package/dist/web-signin-link.d.ts +42 -0
  388. package/dist/web-signin-link.js +110 -0
  389. package/dist/web-signin-link.js.map +1 -0
  390. package/dist/windows-cli-api.d.ts +14 -0
  391. package/dist/windows-cli-api.js +21 -0
  392. package/dist/windows-cli-api.js.map +1 -1
  393. package/dist/windows-cli-worker.d.ts +3 -1
  394. package/dist/windows-cli-worker.js +18 -3
  395. package/dist/windows-cli-worker.js.map +1 -1
  396. package/dist/workspace-follow-parse.d.ts +36 -0
  397. package/dist/workspace-follow-parse.js +208 -0
  398. package/dist/workspace-follow-parse.js.map +1 -0
  399. package/dist/workspace-follow-records.d.ts +17 -0
  400. package/dist/workspace-follow-records.js +88 -0
  401. package/dist/workspace-follow-records.js.map +1 -0
  402. package/dist/workspace-follow.d.ts +41 -0
  403. package/dist/workspace-follow.js +143 -0
  404. package/dist/workspace-follow.js.map +1 -0
  405. package/dist/wsl-detect.d.ts +1 -0
  406. package/dist/wsl-detect.js +20 -0
  407. package/dist/wsl-detect.js.map +1 -0
  408. package/launcher/tmux-bundle.cjs +26 -10
  409. package/package.json +7 -2
  410. package/templates/runtime-install/install.ps1 +154 -13
@@ -0,0 +1,237 @@
1
+ // #3212 PR 2: Settings → Accounts — + Add account and Remove (POST/DELETE /ui/accounts/…, accounts-profiles.ts on the
2
+ // server, which decides; this page only asks). A module of its own, its words registered here: a tab that loaded PR 1's
3
+ // accounts-view.js keeps working without these, and these never meet an older cached strings file.
4
+ // - AddAccountDialog: a name (checked here as the server checks it, so the person sees why at once); Add creates the
5
+ // profile's folder; then Sign in opens right away where the dashboard can sign it in, else the row shows the host command.
6
+ // - RemoveAccountDialog: names the account and its CLI and what is lost; while anything uses it, Remove is not offered and
7
+ // each user is listed with Move… (an agent: its own dialog's Account field; the fleet default: the card's selector; a
8
+ // ClassicBot room: where its account is set); typing the account's name enables Remove.
9
+ import { html, useEffect, useRef, useState } from "/assets/app-html.js";
10
+ import { register, t } from "/assets/app-i18n.js";
11
+ import { Dialog } from "/assets/ui-dialog.js";
12
+ import { toast } from "/assets/ui-toast.js";
13
+
14
+ register("accountsManage", {
15
+ en: {
16
+ add: "+ Add account", addTitle: "Add a {0} account", addLead: "A named account is a separate sign-in on this host. Name it, then sign it in.",
17
+ nameLabel: "Name", nameHint: "Letters, digits, dots, hyphens or underscores; it starts with a letter or digit.", addGo: "Add",
18
+ cancel: "Cancel", adding: "Adding…",
19
+ err_name: "Use 1–64 letters, digits, dots, hyphens or underscores, starting with a letter or digit; not ending with a dot, and not a Windows device name (CON, NUL…).",
20
+ err_exists: "An account with this name already exists.", err_case_clash: "“{0}” already exists; names that differ only in letter case would be the same folder.",
21
+ err_unsafe_root: "The accounts folder on this host isn't a plain folder of this account, so nothing was created.",
22
+ err_backend: "This CLI has no named accounts.", err_failed: "That didn't work. Try again.",
23
+ added: "Account “{0}” added.", addedHostSignIn: "Account “{0}” added. Send /login in chat, or ask General.",
24
+ remove: "Remove…", removeTitle: "Remove the {0} account “{1}”?",
25
+ removeLead: "This deletes the account's folder on this host: its sign-in.", removeLeadClaude: "This deletes the account's folder on this host: its sign-in and its own copies of conversations.",
26
+ removeAfter: "Agents can't use it afterwards.", sep: " ",
27
+ inUse: "Still used by — move each to another account first:", inUseAgent: "Agent {0}", inUseRoom: "ClassicBot room {0}", inUseDefault: "The fleet default for {0} agents",
28
+ move: "Move…", roomHow: "Change it in that room's ClassicBot settings (its credential_profile).",
29
+ typeLabel: "Type {0} to confirm", removeGo: "Remove", removing: "Removing…", removed: "Account “{0}” removed.",
30
+ err_confirm: "Type the account's name exactly.", err_in_use: "Something still uses this account.", err_signing_in: "A sign-in for this account is running. Wait for it to end, or cancel it.",
31
+ err_missing: "This account's folder is no longer there.", err_unsafe: "This account's folder isn't a plain folder of this account inside AgEnD's accounts folder, so nothing was deleted.",
32
+ err_default_home: "That is the CLI's default sign-in, which is never deleted here.",
33
+ err_users_unknown: "AgEnD can't read the ClassicBot settings, so it can't tell whether a room uses this account. Fix classicBot.yaml, then try again.",
34
+ signOut: "Sign out…", switchAccount: "Switch account…", signOutTitle: "Sign out of {0}'s {1}?", switchTitle: "Switch {0}'s default sign-in?",
35
+ signOutLead: "AgEnD runs {0}'s own logout for this account on the host. Its conversations stay.",
36
+ switchLead: "AgEnD signs this account out with {0}'s own logout, then opens Sign in for the account you want. Agents using it restart on the new account once you've signed in.",
37
+ stopUsers: "Using it now — they stop working until it's signed in again:", nobody: "No agent, ClassicBot room or fleet default uses it.",
38
+ signOutGo: "Sign out", switchGo: "Sign out and sign in", signingOut: "Signing out…", signedOut: "Signed out.",
39
+ keychainLeft: "Signed out, but a Keychain item for this account is still on this Mac. Remove it in Keychain Access.",
40
+ removedKeychainLeft: "Account “{0}” removed, but a Keychain item for it is still on this Mac. Remove it in Keychain Access.",
41
+ err_unsupported: "This CLI can't be signed out from here.", err_signout_failed: "{0}'s logout didn't succeed. Try again, or run it on the host.",
42
+ defName: "default sign-in", acctName: "account “{0}”",
43
+ // #3190 Part 3c: an account on a paired computer (its Runtime does the work; the computer's owner has to allow it there).
44
+ addTitleMachine: "Add a {0} account on {1}", addLeadMachine: "A named account is a separate sign-in kept on {0}. Name it, then sign it in here. Its folder is made by that computer's Runtime.",
45
+ removeLeadMachine: "This deletes the account's folder on {0}: its sign-in and its own copies of conversations. That computer's Runtime does it, and records it.",
46
+ inUseMachineDefault: "This computer's default account for agents (change it on that computer: agend-runtime profile default NAME)",
47
+ signOutLeadMachine: "AgEnD asks {0}'s Runtime to run {1}'s own logout for this account. Its conversations stay.",
48
+ err_machine_unknown: "That computer is not paired any more.", err_machine_offline: "That computer is offline. Start its Runtime, then try again.",
49
+ err_machine_unsupported: "That computer's Runtime is too old for this. Update the Runtime on it, then try again.",
50
+ err_machine_accounts_off: "The owner of that computer has not allowed this. On that computer run: agend-runtime remote-setup accounts on",
51
+ err_machine_unreachable: "That computer did not answer. Check its Runtime window, then try again.",
52
+ err_machine_profile_not_owned: "This account was not created by AgEnD's Runtime, so it can only be changed on that computer.",
53
+ err_machine_default_login: "That is the Windows user's own sign-in on that computer, which is never changed from here.",
54
+ err_machine_refused: "That computer did not do it.",
55
+ },
56
+ "zh-TW": {
57
+ add: "+ 新增帳號", addTitle: "新增 {0} 帳號", addLead: "具名帳號是這台主機上另一組登入。先取名,再登入。",
58
+ nameLabel: "名稱", nameHint: "英文字母、數字、句點、連字號或底線;以字母或數字開頭。", addGo: "新增",
59
+ cancel: "取消", adding: "正在新增…",
60
+ err_name: "請用 1–64 個英文字母、數字、句點、連字號或底線,以字母或數字開頭;不能以句點結尾,也不能是 Windows 裝置名稱(CON、NUL…)。",
61
+ err_exists: "已經有這個名稱的帳號。", err_case_clash: "已經有「{0}」;只差大小寫的名稱會是同一個資料夾。",
62
+ err_unsafe_root: "這台主機的帳號資料夾不是這個使用者的一般資料夾,所以沒有建立任何東西。",
63
+ err_backend: "這個 CLI 沒有具名帳號。", err_failed: "沒有成功,請再試一次。",
64
+ added: "已新增帳號「{0}」。", addedHostSignIn: "已新增帳號「{0}」。請在聊天傳 /login,或請 General。",
65
+ remove: "移除…", removeTitle: "要移除 {0} 帳號「{1}」嗎?",
66
+ removeLead: "這會刪除這台主機上該帳號的資料夾:它的登入。", removeLeadClaude: "這會刪除這台主機上該帳號的資料夾:它的登入,以及它自己的對話副本。",
67
+ removeAfter: "之後 Agent 就不能使用它。", sep: "",
68
+ inUse: "仍在使用中,請先把每一項移到其他帳號:", inUseAgent: "Agent {0}", inUseRoom: "ClassicBot 房間 {0}", inUseDefault: "{0} Agent 的 Fleet 預設帳號",
69
+ move: "移動…", roomHow: "請在該房間的 ClassicBot 設定(credential_profile)中更改。",
70
+ typeLabel: "輸入 {0} 以確認", removeGo: "移除", removing: "正在移除…", removed: "已移除帳號「{0}」。",
71
+ err_confirm: "請正確輸入帳號名稱。", err_in_use: "仍有項目在使用這個帳號。", err_signing_in: "這個帳號正在登入。請等它結束,或取消它。",
72
+ err_missing: "這個帳號的資料夾已經不在了。", err_unsafe: "這個帳號的資料夾不是 AgEnD 帳號資料夾裡、屬於這個使用者的一般資料夾,所以沒有刪除任何東西。",
73
+ err_default_home: "那是 CLI 的預設登入,這裡永遠不會刪除它。",
74
+ err_users_unknown: "AgEnD 無法讀取 ClassicBot 設定,所以無法確定是否有房間在使用這個帳號。請先修正 classicBot.yaml 再試一次。",
75
+ signOut: "登出…", switchAccount: "切換帳號…", signOutTitle: "要登出 {0} 的{1}嗎?", switchTitle: "要切換 {0} 的預設登入嗎?",
76
+ signOutLead: "AgEnD 會在主機上用 {0} 自己的登出指令登出這個帳號。它的對話會保留。",
77
+ switchLead: "AgEnD 會用 {0} 自己的登出指令登出這個帳號,然後開啟「登入」讓你登入想用的帳號。登入後,使用它的 Agent 會以新帳號重新啟動。",
78
+ stopUsers: "目前使用中——在重新登入前它們都無法運作:", nobody: "沒有 Agent、ClassicBot 房間或 Fleet 預設在使用它。",
79
+ signOutGo: "登出", switchGo: "登出並登入", signingOut: "正在登出…", signedOut: "已登出。",
80
+ keychainLeft: "已登出,但這台 Mac 上仍有這個帳號的鑰匙圈項目。請在「鑰匙圈存取」中刪除。",
81
+ removedKeychainLeft: "已移除帳號「{0}」,但這台 Mac 上仍有它的鑰匙圈項目。請在「鑰匙圈存取」中刪除。",
82
+ err_unsupported: "這個 CLI 無法在這裡登出。", err_signout_failed: "{0} 的登出沒有成功。請再試一次,或在主機上執行。",
83
+ defName: "預設登入", acctName: "帳號「{0}」",
84
+ // #3190 Part 3c:配對電腦上的帳號(由那台電腦的 Runtime 執行;需要電腦的擁有者在那裡允許)。
85
+ addTitleMachine: "在 {1} 新增 {0} 帳號", addLeadMachine: "具名帳號是保存在 {0} 上的另一組登入。先取名,再在這裡登入。它的資料夾由那台電腦的 Runtime 建立。",
86
+ removeLeadMachine: "這會刪除 {0} 上該帳號的資料夾:它的登入,以及它自己的對話副本。由那台電腦的 Runtime 執行並記錄。",
87
+ inUseMachineDefault: "這台電腦給 Agent 用的預設帳號(請在那台電腦上更改:agend-runtime profile default NAME)",
88
+ signOutLeadMachine: "AgEnD 會請 {0} 的 Runtime 用 {1} 自己的登出指令登出這個帳號。它的對話會保留。",
89
+ err_machine_unknown: "那台電腦已不再配對。", err_machine_offline: "那台電腦離線了。請先啟動它的 Runtime,再試一次。",
90
+ err_machine_unsupported: "那台電腦的 Runtime 太舊,無法這樣做。請先更新它的 Runtime,再試一次。",
91
+ err_machine_accounts_off: "那台電腦的擁有者尚未允許這件事。請在那台電腦上執行:agend-runtime remote-setup accounts on",
92
+ err_machine_unreachable: "那台電腦沒有回應。請檢查它的 Runtime 視窗,再試一次。",
93
+ err_machine_profile_not_owned: "這個帳號不是 AgEnD 的 Runtime 建立的,只能在那台電腦上更改。",
94
+ err_machine_default_login: "那是那台電腦上 Windows 使用者自己的登入,這裡永遠不會更改它。",
95
+ err_machine_refused: "那台電腦沒有執行。",
96
+ },
97
+ });
98
+ const tm = (k, ...v) => t(`accountsManage.${k}`, ...v);
99
+
100
+ /** The server's name rule (credential-profile.ts + #3190's Windows-safe checks), so the dialog says why before asking. */
101
+ const NAME = /^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/;
102
+ const DEVICE = /^(?:con|prn|aux|nul|conin\$|conout\$|com[0-9¹²³]|lpt[0-9¹²³])(?:\..*)?$/i;
103
+ export const validAccountName = (s) => typeof s === "string" && NAME.test(s) && !s.endsWith(".") && !DEVICE.test(s);
104
+
105
+ async function send(method, path, body) {
106
+ try {
107
+ const r = await fetch(path, { method, credentials: "same-origin", cache: "no-store", headers: { "Content-Type": "application/json" }, body: JSON.stringify(body) });
108
+ let j = null; try { j = await r.json(); } catch { /* none */ }
109
+ return r.ok ? { ok: true, ...(j || {}) } : { ok: false, error: (j && typeof j.error === "string" && j.error) || "failed", ...(j || {}) };
110
+ } catch { return { ok: false, error: "failed" }; }
111
+ }
112
+ const errText = (r) => {
113
+ // A computer's own refusal sentence (its Runtime's words, bounded; no path, URL, code or output) says more than ours does.
114
+ if (r.error === "machine_refused" && typeof r.message === "string" && r.message) return r.message;
115
+ const key = `err_${r.error}`, s = tm(key, r.clash || "");
116
+ return s === `accountsManage.${key}` ? tm("err_failed") : s;
117
+ };
118
+
119
+ /** `cli`: the Accounts view's card; `label`: the CLI's name; `onAdded(name)`: after the server made it. */
120
+ /**
121
+ * #3291 review (Prism P2-5): while its request runs a dialog can't be dismissed (Cancel disabled; Dialog's `busy` holds ×, Esc and the backdrop), and an answer that
122
+ * comes after the dialog left the page (navigation) does nothing — it never closes or opens what replaced it.
123
+ */
124
+ function useLive() {
125
+ const live = useRef(true);
126
+ useEffect(() => () => { live.current = false; }, []);
127
+ return live;
128
+ }
129
+ export function AddAccountDialog({ cli, label, machine = null, onClose, onAdded }) {
130
+ const [name, setName] = useState("");
131
+ const [busy, setBusy] = useState(false);
132
+ const [err, setErr] = useState("");
133
+ const input = useRef(null);
134
+ const live = useLive();
135
+ useEffect(() => { input.current && input.current.focus(); }, []);
136
+ const trimmed = name.trim();
137
+ const shownErr = err || (trimmed && !validAccountName(trimmed) ? tm("err_name") : "");
138
+ const go = async () => {
139
+ if (busy || !validAccountName(trimmed)) return;
140
+ setBusy(true); setErr("");
141
+ const r = await send("POST", `/ui/accounts/${encodeURIComponent(cli.backend)}`, { name: trimmed, ...(machine ? { machine: machine.id } : {}) });
142
+ if (!live.current) return;
143
+ setBusy(false);
144
+ if (!r.ok) { setErr(errText(r)); return; }
145
+ onClose(); onAdded(trimmed);
146
+ };
147
+ return html`<${Dialog} title=${machine ? tm("addTitleMachine", label, machine.name) : tm("addTitle", label)} onClose=${onClose} busy=${busy} actions=${html`<button type="button" class="btn" disabled=${busy} onClick=${onClose}>${tm("cancel")}</button>
148
+ <button type="button" class="btn btn-primary" disabled=${busy || !validAccountName(trimmed)} onClick=${go}>${busy ? tm("adding") : tm("addGo")}</button>`}>
149
+ <p>${machine ? tm("addLeadMachine", machine.name) : tm("addLead")}</p>
150
+ <div class="field"><label for="acctAddName">${tm("nameLabel")}</label>
151
+ <input id="acctAddName" ref=${input} value=${name} maxlength="64" autocomplete="off" spellcheck=${false}
152
+ onInput=${(e) => { setName(e.target.value); setErr(""); }} onKeyDown=${(e) => { if (e.key === "Enter") { e.preventDefault(); void go(); } }} />
153
+ <small class="note">${tm("nameHint")}</small>
154
+ ${shownErr ? html`<p class="err" role="alert">${shownErr}</p>` : null}</div>
155
+ </${Dialog}>`;
156
+ }
157
+
158
+ /**
159
+ * `row`: the named account's row (its `usedBy` from the view); `onMove(user)`: open where that user's account is set
160
+ * ({ kind: "agent", name } | { kind: "default" }); `onRemoved()`: after the server removed it.
161
+ */
162
+ export function RemoveAccountDialog({ cli, row, label, onClose, onMove, onRemoved }) {
163
+ const [typed, setTyped] = useState("");
164
+ const [busy, setBusy] = useState(false);
165
+ const [err, setErr] = useState("");
166
+ const [users, setUsers] = useState(row.usedBy); // the server's answer replaces it when it knows better
167
+ const live = useLive();
168
+ const machine = row.scope && row.scope.kind === "machine" ? row.scope : null; // #3190 Part 3c: an account on a paired computer
169
+ const inUse = users.agents.length > 0 || users.classic.length > 0 || users.fleetDefault;
170
+ const go = async () => {
171
+ if (busy || inUse || typed !== row.profile) return;
172
+ setBusy(true); setErr("");
173
+ const r = await send("DELETE", `/ui/accounts/${encodeURIComponent(cli.backend)}/${encodeURIComponent(row.profile)}`, { confirm: typed, ...(machine ? { machine: machine.id } : {}) });
174
+ if (!live.current) return;
175
+ setBusy(false);
176
+ if (r.ok) { toast(r.keychainLeft ? tm("removedKeychainLeft", row.profile) : tm("removed", row.profile), !r.keychainLeft); onClose(); onRemoved(); return; }
177
+ if (r.error === "in_use" && r.users) setUsers(r.users);
178
+ setErr(errText(r));
179
+ };
180
+ const moveBtn = (user) => html`<button type="button" class="btn btn-sm" disabled=${busy} onClick=${() => { onClose(); onMove(user); }}>${tm("move")}</button>`;
181
+ return html`<${Dialog} title=${tm("removeTitle", label, row.profile)} onClose=${onClose} busy=${busy} actions=${html`<button type="button" class="btn" disabled=${busy} onClick=${onClose}>${tm("cancel")}</button>
182
+ <button type="button" class="btn btn-danger" disabled=${busy || inUse || typed !== row.profile} onClick=${go}>${busy ? tm("removing") : tm("removeGo")}</button>`}>
183
+ <p>${machine ? tm("removeLeadMachine", machine.name) : cli.backend === "claude-code" ? tm("removeLeadClaude") : tm("removeLead")}${tm("sep")}${tm("removeAfter")}</p>
184
+ ${inUse ? html`<div class="s-account-inuse" role="status"><p><strong>${tm("inUse")}</strong></p><ul>
185
+ ${users.agents.map((name) => html`<li><span>${tm("inUseAgent", name)}</span>${moveBtn({ kind: "agent", name })}</li>`)}
186
+ ${users.fleetDefault ? html`<li><span>${machine ? tm("inUseMachineDefault") : tm("inUseDefault", label)}</span>${machine ? null : moveBtn({ kind: "default" })}</li>` : null}
187
+ ${users.classic.map((key) => html`<li><span>${tm("inUseRoom", key)}</span><small class="note">${tm("roomHow")}</small></li>`)}
188
+ </ul></div>` : html`<div class="field"><label for="acctRemoveName">${tm("typeLabel", row.profile)}</label>
189
+ <input id="acctRemoveName" value=${typed} autocomplete="off" spellcheck=${false} onInput=${(e) => { setTyped(e.target.value); setErr(""); }}
190
+ onKeyDown=${(e) => { if (e.key === "Enter") { e.preventDefault(); void go(); } }} /></div>`}
191
+ ${err ? html`<p class="err" role="alert">${err}</p>` : null}
192
+ </${Dialog}>`;
193
+ }
194
+
195
+ /**
196
+ * #3212 PR 3: Sign out (`mode` "signout") or Switch account (`mode` "switch", the default sign-in): names the account
197
+ * and who stops using it until it is signed in again (an agent and the fleet default with Move…); the CLI's own logout
198
+ * runs on the host. `onDone(result)`: after the server signed it out.
199
+ */
200
+ export function SignOutDialog({ cli, row, label, mode = "signout", onClose, onMove, onDone }) {
201
+ const [busy, setBusy] = useState(false);
202
+ const [err, setErr] = useState("");
203
+ const live = useLive();
204
+ const users = row.usedBy;
205
+ const any = users.agents.length > 0 || users.classic.length > 0 || users.fleetDefault;
206
+ const which = row.profile ? tm("acctName", row.profile) : tm("defName");
207
+ const machine = row.scope && row.scope.kind === "machine" ? row.scope : null; // #3190 Part 3c: an account on a paired computer
208
+ const go = async () => {
209
+ if (busy) return;
210
+ setBusy(true); setErr("");
211
+ const r = await send("POST", `/ui/accounts/${encodeURIComponent(cli.backend)}/signout`, { profile: row.profile || null, confirm: true, ...(machine ? { machine: machine.id } : {}) });
212
+ if (!live.current) return;
213
+ setBusy(false);
214
+ if (!r.ok) { setErr(r.error === "failed" ? tm("err_signout_failed", label) : errText(r)); return; }
215
+ toast(r.keychainLeft ? tm("keychainLeft") : tm("signedOut"), !r.keychainLeft);
216
+ onClose(); onDone(r);
217
+ };
218
+ const moveBtn = (user) => html`<button type="button" class="btn btn-sm" disabled=${busy} onClick=${() => { onClose(); onMove(user); }}>${tm("move")}</button>`;
219
+ return html`<${Dialog} title=${mode === "switch" ? tm("switchTitle", label) : tm("signOutTitle", label, which)} onClose=${onClose} busy=${busy}
220
+ actions=${html`<button type="button" class="btn" disabled=${busy} onClick=${onClose}>${tm("cancel")}</button>
221
+ <button type="button" class=${mode === "switch" ? "btn btn-primary" : "btn btn-danger"} disabled=${busy} onClick=${go}>${busy ? tm("signingOut") : mode === "switch" ? tm("switchGo") : tm("signOutGo")}</button>`}>
222
+ <p>${mode === "switch" ? tm("switchLead", label) : machine ? tm("signOutLeadMachine", machine.name, label) : tm("signOutLead", label)}</p>
223
+ ${any ? html`<div class="s-account-inuse" role="status"><p><strong>${tm("stopUsers")}</strong></p><ul>
224
+ ${users.agents.map((name) => html`<li><span>${tm("inUseAgent", name)}</span>${mode === "switch" ? null : moveBtn({ kind: "agent", name })}</li>`)}
225
+ ${users.fleetDefault && row.profile ? html`<li><span>${machine ? tm("inUseMachineDefault") : tm("inUseDefault", label)}</span>${machine ? null : moveBtn({ kind: "default" })}</li>` : null}
226
+ ${users.classic.map((key) => html`<li><span>${tm("inUseRoom", key)}</span></li>`)}
227
+ </ul></div>` : html`<p class="note">${tm("nobody")}</p>`}
228
+ ${err ? html`<p class="err" role="alert">${err}</p>` : null}
229
+ </${Dialog}>`;
230
+ }
231
+
232
+ /** The CLIs the dashboard can sign out (their own logout; accounts-signout.ts SIGN_OUT). */
233
+ export const SIGN_OUT_CLIS = new Set(["claude-code", "codex", "kiro-cli"]);
234
+
235
+ /** The button labels the view draws (from this module, so an older view never shows them). */
236
+ export const manageWords = { add: () => tm("add"), remove: () => tm("remove"), added: (n) => tm("added", n), addedHost: (n) => tm("addedHostSignIn", n),
237
+ signOut: () => tm("signOut"), switchAccount: () => tm("switchAccount") };
@@ -6,53 +6,82 @@
6
6
  // staging and Save (a change of account waits for the same confirmation as any credential setting, and restarts).
7
7
  // - Fleet default: the same, for `defaults.backend_options.<cli>.credential_profile`.
8
8
  // - AccountSelect: the Agent dialog's Account field (settings-dialogs.js), from the same view.
9
- // Rows carry a `scope`: only `host` today; a paired computer's rows (`machine`) are drawn read-only under its name.
9
+ // Rows carry a `scope`: `host`, and (#3190 Part 3c) a paired computer's `machine` rows under its name — Claude Code first. A computer's account is signed in, signed
10
+ // out and removed here only where its Runtime allows it (its owner turned `accounts` on there, and the profile is one that Runtime created); every other row is
11
+ // read-only with the reason (a code from the server, worded here) and the command to run on that computer.
10
12
  // Words are registered here (a new module: an older cached strings file never leaves a raw key).
11
- import { html, useEffect, useState } from "/assets/app-html.js";
13
+ import { html, useEffect, useRef, useState } from "/assets/app-html.js";
12
14
  import { register, t } from "/assets/app-i18n.js";
13
- import { createStore, useStore } from "/assets/app-store.js";
15
+ import { appStore, createStore, useStore } from "/assets/app-store.js";
14
16
  import { Dialog } from "/assets/ui-dialog.js";
17
+ import { ErrorState, Skeleton } from "/assets/ui-states.js";
15
18
  import { CliProductMark, cliLabel } from "./cli-picker.js";
16
19
  import { identityText } from "./account-identity.js";
17
20
  import { openSignIn, refreshSignIn, signInStore } from "./backend-signin.js";
21
+ import { toast } from "/assets/ui-toast.js";
22
+ import { shellStore } from "/assets/app-shell.js";
23
+ import { AddAccountDialog, RemoveAccountDialog, SignOutDialog, SIGN_OUT_CLIS, manageWords } from "./accounts-manage.js"; // #3212 PR 2, PR 3
24
+ import { machineSignInStore, openMachineSignIn } from "./machine-signin.js"; // #3190 Part 3c
25
+ import { KeepAliveControl } from "./accounts-keepalive.js"; // #3292
18
26
 
19
27
  register("accounts", {
20
28
  en: {
21
- title: "Accounts", hint: "Each CLI's sign-ins on this host: the default one and named accounts (credential profiles), who uses them and their weekly usage.",
29
+ title: "Accounts", hint: "Each CLI's sign-ins on this AgEnD host and on paired computers: the default one and named accounts (credential profiles), who uses them and their weekly usage.",
22
30
  loading: "Reading accounts…", failed: "Could not read the accounts.", empty: "No CLI is installed or used by an agent on this host.",
23
31
  def: "Default sign-in", profile: "Account “{0}”", state_usable: "signed in", state_not_signed_in: "not signed in", state_unknown: "not checked",
24
32
  state_not_installed: "not installed", state_too_old: "too old",
25
33
  usedBy: "used by {0}", usedByNone: "used by no agent", agents: "{0} agents", agent: "1 agent", channels: "{0} ClassicBot rooms", channel: "1 ClassicBot room",
26
34
  fleetDefaultTag: "fleet default", weekly: "{0}% of the week", resets: "resets {0}", stale: "last known",
27
- signIn: "Sign in", signInAgain: "Sign in again", hostCommand: "Sign in on the host", hostCommandHint: "Run this in a terminal on the host running AgEnD.",
35
+ signIn: "Sign in", signInAgain: "Sign in again", hostCommand: "Sign in from chat", hostCommandHint: "This row cannot sign in from the dashboard. Send /login in chat, or ask General.",
28
36
  moveHere: "Move agents here…", moveTitle: "Move agents to {0}", moveLead: "Choose the {0} agents that should use {1}. Each restarts on it when you Save:",
29
37
  carry_claude: "Claude Code carries its conversation over.", carry_codex: "Codex keeps its conversation.", carry_kiro: "Kiro starts a new conversation, with a handover.",
30
38
  moveNone: "Every {0} agent already uses this account.", moveStage: "Stage", cancel: "Cancel", current: "now: {0}",
31
39
  fleetDefault: "Fleet default for {0} agents", fleetDefaultHint: "Agents that don't choose an account use this one.",
32
- machine: "On {0}", machineReadOnly: "Read-only here",
40
+ machine: "On {0}", machineReadOnly: "Read-only here", machineOnline: "online", machineOffline: "offline", machineDefaultTag: "this computer's default",
41
+ machineNoUsage: "—", machineNoUsageHint: "That computer does not report usage.",
42
+ machineCommand: "Sign in on that computer", machineCommandHint: "Run this in a terminal on {0}.",
43
+ why_offline: "{0} is offline. Start its Runtime to manage its accounts.",
44
+ why_runtime_old: "{0}'s Runtime is too old to manage accounts from here. Update the Runtime on that computer.",
45
+ why_accounts_off: "The owner of {0} has not allowed account changes from AgEnD. On that computer run: agend-runtime remote-setup accounts on",
46
+ why_switch_unreadable: "{0} did not say whether account changes are allowed. Check its Runtime window.",
47
+ why_not_installed: "Claude Code is not installed on {0}. Install it from Settings → Runtime.",
48
+ why_not_created: "This account was not created by AgEnD's Runtime, so it can only be handled on {0}.",
49
+ why_default_login: "This is the Windows user's own sign-in on {0}. It is never changed from here: add an account instead.",
33
50
  acctLabel: "Account", acctInherit: "Fleet default ({0})", acctInheritDefault: "Fleet default (default sign-in)", acctNotSignedIn: "{0} — not signed in",
34
51
  acctHint: "Changing the account restarts the agent. A signed-out account can't be chosen: sign it in under Accounts first.",
35
52
  acctDefaultBlocked: "This fleet's default for {0} is “{1}”, so an agent follows it unless it names another account.",
36
53
  },
37
54
  "zh-TW": {
38
- title: "帳號", hint: "這台主機上各 CLI 的登入:預設登入與具名帳號(憑證設定檔)、誰在使用,以及每週用量。",
55
+ title: "帳號", hint: "這台 AgEnD 主機與已配對電腦上各 CLI 的登入:預設登入與具名帳號(憑證設定檔)、誰在使用,以及每週用量。",
39
56
  loading: "正在讀取帳號…", failed: "無法讀取帳號。", empty: "這台主機上沒有安裝或被 Agent 使用的 CLI。",
40
57
  def: "預設登入", profile: "帳號「{0}」", state_usable: "已登入", state_not_signed_in: "尚未登入", state_unknown: "未確認",
41
58
  state_not_installed: "未安裝", state_too_old: "版本太舊",
42
59
  usedBy: "使用者:{0}", usedByNone: "沒有 Agent 使用", agents: "{0} 個 Agent", agent: "1 個 Agent", channels: "{0} 個 ClassicBot 房間", channel: "1 個 ClassicBot 房間",
43
60
  fleetDefaultTag: "Fleet 預設", weekly: "本週已用 {0}%", resets: "{0} 重置", stale: "最後已知",
44
- signIn: "登入", signInAgain: "重新登入", hostCommand: "在主機上登入", hostCommandHint: "請在執行 AgEnD 的主機終端機執行。",
61
+ signIn: "登入", signInAgain: "重新登入", hostCommand: "從聊天登入", hostCommandHint: "這一列無法從儀表板登入。請在聊天傳 /login,或請 General。",
45
62
  moveHere: "把 Agent 移到這裡…", moveTitle: "把 Agent 移到 {0}", moveLead: "選擇要改用 {1} 的 {0} Agent。按「儲存」後,各自會以它重新啟動:",
46
63
  carry_claude: "Claude Code 會帶著對話過去。", carry_codex: "Codex 保留原本的對話。", carry_kiro: "Kiro 會開新對話並附上交接。",
47
64
  moveNone: "所有 {0} Agent 都已經使用這個帳號。", moveStage: "加入待儲存", cancel: "取消", current: "目前:{0}",
48
65
  fleetDefault: "{0} Agent 的 Fleet 預設帳號", fleetDefaultHint: "沒有指定帳號的 Agent 會使用這個。",
49
- machine: "在 {0}", machineReadOnly: "這裡只能檢視",
66
+ machine: "在 {0}", machineReadOnly: "這裡只能檢視", machineOnline: "在線", machineOffline: "離線", machineDefaultTag: "這台電腦的預設",
67
+ machineNoUsage: "—", machineNoUsageHint: "那台電腦不回報用量。",
68
+ machineCommand: "在那台電腦上登入", machineCommandHint: "請在 {0} 的終端機執行。",
69
+ why_offline: "{0} 離線了。請先啟動它的 Runtime,才能管理它的帳號。",
70
+ why_runtime_old: "{0} 的 Runtime 太舊,無法從這裡管理帳號。請更新那台電腦上的 Runtime。",
71
+ why_accounts_off: "{0} 的擁有者尚未允許從 AgEnD 變更帳號。請在那台電腦上執行:agend-runtime remote-setup accounts on",
72
+ why_switch_unreadable: "{0} 沒有回報是否允許變更帳號。請檢查它的 Runtime 視窗。",
73
+ why_not_installed: "{0} 上沒有安裝 Claude Code。請從「設定 → Runtime」安裝。",
74
+ why_not_created: "這個帳號不是 AgEnD 的 Runtime 建立的,只能在 {0} 上處理。",
75
+ why_default_login: "這是 {0} 上 Windows 使用者自己的登入,永遠不會從這裡更改:請改用新增帳號。",
50
76
  acctLabel: "帳號", acctInherit: "Fleet 預設({0})", acctInheritDefault: "Fleet 預設(預設登入)", acctNotSignedIn: "{0}——尚未登入",
51
77
  acctHint: "更換帳號會重新啟動 Agent。尚未登入的帳號不能選,請先在「帳號」登入。",
52
78
  acctDefaultBlocked: "這個 Fleet 的 {0} 預設帳號是「{1}」,Agent 除非指定其他帳號,否則會使用它。",
53
79
  },
54
80
  });
55
81
  const tx = (k, ...v) => t(`accounts.${k}`, ...v);
82
+ /** The reasons that apply to a whole computer (the heading says them once); the others belong to one row. A code a newer server sends that this page does not know is shown as it is. */
83
+ const MACHINE_LEVEL = new Set(["offline", "runtime_old", "accounts_off", "switch_unreadable", "not_installed"]);
84
+ const reasonText = (code, name) => { const key = `why_${code}`, text = tx(key, name); return text === `accounts.${key}` ? String(code) : text; };
56
85
  /** This view's stylesheet, linked once (a tab opened before an upgrade has an app.css without these rules). */
57
86
  function linkAccountsCss(doc = typeof document !== "undefined" ? document : null) {
58
87
  try {
@@ -65,15 +94,35 @@ function linkAccountsCss(doc = typeof document !== "undefined" ? document : null
65
94
  const CARRY = { "claude-code": "carry_claude", codex: "carry_codex", "kiro-cli": "carry_kiro" };
66
95
 
67
96
  export const accountsStore = createStore({ loaded: false, failed: false, view: null });
68
- let reading = null;
69
- /** Read GET /ui/accounts (one read at a time). */
70
- export function refreshAccounts() {
71
- if (reading) return reading;
72
- reading = fetch("/ui/accounts", { credentials: "same-origin", cache: "no-store" })
73
- .then(async (r) => { const v = r.ok ? await r.json() : null; accountsStore.set({ loaded: true, failed: !v, view: v }); })
74
- .catch(() => accountsStore.set({ loaded: true, failed: true, view: accountsStore.get().view }))
75
- .finally(() => { reading = null; });
76
- return reading;
97
+ /**
98
+ * #3313 review P2-7: the server says sign-ins changed (`backend_login`: a sign-in moved, an account was learned, a Keep
99
+ * sign-in alive check finished): a page showing the accounts reads them again, fresh. Listened to once per page. The
100
+ * existing event, so a tab whose cached shell (app-stream.js) predates this still delivers it.
101
+ */
102
+ let accountsEventOff = null;
103
+ export function listenAccountsEvent() {
104
+ if (accountsEventOff) return;
105
+ const on = appStore.get().streamOn;
106
+ if (typeof on !== "function") return;
107
+ accountsEventOff = on("backend_login", () => { if (accountsStore.get().loaded) void refreshAccounts({ fresh: true }); }) || (() => {});
108
+ }
109
+ let reading = null, started = 0, applied = 0;
110
+ /**
111
+ * Read GET /ui/accounts. A read already running is joined — unless `fresh` (#3291 review, Prism P2-4: after a write, the
112
+ * view must come from a read that began after it): then a new read starts, and an older one that answers later never
113
+ * replaces a newer answer. Resolves true only when THIS read's view was applied (#3313 review r2: what a write's follow-up
114
+ * read needs to know).
115
+ */
116
+ export function refreshAccounts({ fresh = false } = {}) {
117
+ if (reading && !fresh) return reading;
118
+ const mine = ++started;
119
+ const apply = (next) => { if (mine > applied) { applied = mine; accountsStore.set(next); return true; } return false; };
120
+ const p = fetch("/ui/accounts", { credentials: "same-origin", cache: "no-store" })
121
+ .then(async (r) => { const v = r.ok ? await r.json() : null; return apply({ loaded: true, failed: !v, view: v }) && !!v; })
122
+ .catch(() => { apply({ loaded: true, failed: true, view: accountsStore.get().view }); return false; })
123
+ .finally(() => { if (reading === p) reading = null; });
124
+ reading = p;
125
+ return p;
77
126
  }
78
127
  const rowName = (row) => (row.profile ? tx("profile", row.profile) : tx("def"));
79
128
  const usedText = (row) => {
@@ -108,31 +157,107 @@ export function accountChoices(view, backend) {
108
157
  return { fleetDefault: cli.fleetDefault, rows: cli.rows.filter((r) => r.scope && r.scope.kind === "host" && r.profile) };
109
158
  }
110
159
 
111
- /** Settings → Agents → Accounts. `stageAgent(name, inst, patch)` and `stageDefault(backend, profile | null)` stage changes. */
112
- export function AccountsView({ instances, stageAgent, stageDefault }) {
160
+ /**
161
+ * Settings → Agents → Accounts. `stageAgent(name, inst, patch)` and `stageDefault(backend, profile | null)` stage changes;
162
+ * `openAgent(name)` (#3212 PR 2) opens an agent's own dialog, where its Account is chosen (Remove's Move…).
163
+ */
164
+ // Ridge #3321 S08: the host's own group head, beside paired computers' "On <computer>".
165
+ register("accounts", {
166
+ en: { onHost: "On this AgEnD host" },
167
+ "zh-TW": { onHost: "在這台 AgEnD 主機上" },
168
+ });
169
+
170
+ export function AccountsView({ instances, stageAgent, stageDefault, openAgent }) {
113
171
  const { loaded, failed, view } = useStore(accountsStore);
114
172
  // Settings read its data again (after a Save): so does this view.
115
173
  useEffect(() => { if (loaded) void refreshAccounts(); }, [instances]);
116
174
  const { structured, login } = useStore(signInStore);
175
+ const machineLogin = useStore(machineSignInStore); // #3190 Part 3c: the open sign-in dialog of a computer's account
117
176
  const [move, setMove] = useState(null); // { cli, row }
177
+ const [adding, setAdding] = useState(null); // #3212 PR 2: the card whose + Add account is open; #3190 Part 3c: { cli, machine } for a computer's
178
+ const [removing, setRemoving] = useState(null); // { cli, row }
179
+ const [signingOut, setSigningOut] = useState(null); // #3212 PR 3: { cli, row, mode: "signout" | "switch" }
180
+ const mounted = useRef(true);
181
+ useEffect(() => () => { mounted.current = false; }, []);
182
+ // #3291 review (Prism P2-5 remainder): each dialog this view opens is a new interaction. Add's follow-up (the read,
183
+ // then Sign in) belongs to the interaction it came from: any later one — another Add, a Remove, Move agents — makes it
184
+ // do nothing.
185
+ const interaction = useRef(0);
186
+ const begin = (fn) => (...a) => { interaction.current++; fn(...a); };
118
187
  // The sign-in controllers' state too (a sign-in already running disables Sign in, as the old list did).
119
- useEffect(() => { linkAccountsCss(); void refreshAccounts(); void refreshSignIn(); }, []);
188
+ useEffect(() => { linkAccountsCss(); listenAccountsEvent(); void refreshAccounts(); void refreshSignIn(); }, []);
120
189
  // A sign-in that ends may be another account now: read again.
121
- const phase = `${(login && login.phase) || ""}:${(structured && structured.login && structured.login.phase) || ""}`;
190
+ const phase = `${(login && login.phase) || ""}:${(structured && structured.login && structured.login.phase) || ""}:${machineLogin.phase || ""}`;
122
191
  useEffect(() => { if (loaded) void refreshAccounts(); }, [phase]);
123
192
  const active = structured && structured.login;
124
- const running = !!((login && login.phase === "running") || (active && active.phase !== "done" && !(active.phase === "failed" && active.reason)));
125
- if (!loaded) return html`<p class="note" role="status">${tx("loading")}</p>`;
126
- if (failed && !view) return html`<p class="note" role="alert">${tx("failed")}</p>`;
193
+ const machineActive = !!machineLogin.phase && machineLogin.phase !== "done" && !(machineLogin.phase === "failed" && machineLogin.reason);
194
+ const running = !!((login && login.phase === "running") || (active && active.phase !== "done" && !(active.phase === "failed" && active.reason)) || machineActive);
195
+ if (!loaded) return html`<section class="s-group s-accounts" aria-label=${tx("title")}>
196
+ <header class="s-auth-section-head"><div><h3>${tx("title")}</h3><p>${tx("hint")}</p></div></header>
197
+ <${Skeleton} variant="cards" lines=${2} label=${tx("loading")} /></section>`;
198
+ // Ridge #3321 S07: a first read that fails keeps the section's heading and says so with Retry (the shared ErrorState).
199
+ if (failed && !view) return html`<section class="s-group s-accounts" aria-label=${tx("title")}>
200
+ <header class="s-auth-section-head"><div><h3>${tx("title")}</h3><p>${tx("hint")}</p></div></header>
201
+ <${ErrorState} message=${tx("failed")} onRetry=${() => void refreshAccounts({ fresh: true })} /></section>`;
127
202
  const clis = (view && view.clis) || [];
128
203
  return html`<section class="s-group s-accounts" aria-label=${tx("title")}>
129
204
  <header class="s-auth-section-head"><div><h3>${tx("title")}</h3><p>${tx("hint")}</p></div></header>
130
- ${!clis.length ? html`<p class="note">${tx("empty")}</p>` : clis.map((cli) => html`<${Card} key=${cli.backend} cli=${cli} running=${running} onMove=${(row) => setMove({ cli, row })} stageDefault=${stageDefault} />`)}
205
+ ${!clis.length ? html`<p class="note">${tx("empty")}</p>` : clis.map((cli) => html`<${Card} key=${cli.backend} cli=${cli} running=${running} onMove=${begin((row) => setMove({ cli, row }))} stageDefault=${stageDefault}
206
+ onAdd=${begin((machine) => setAdding(machine ? { cli, machine } : cli))} onRemove=${begin((row) => setRemoving({ cli, row }))} onSignIn=${begin((target) => (target.machine ? openMachineSignIn(target) : openSignIn(target)))}
207
+ onSignOut=${begin((row, mode) => setSigningOut({ cli, row, mode }))} />`)}
131
208
  ${move ? html`<${MoveDialog} cli=${move.cli} row=${move.row} instances=${instances} stageAgent=${stageAgent} onClose=${() => setMove(null)} />` : null}
209
+ ${adding ? html`<${AddAccountDialog} cli=${adding.machine ? adding.cli : adding} machine=${adding.machine || null} label=${cliLabel((adding.machine ? adding.cli : adding).backend)} onClose=${() => setAdding(null)}
210
+ onAdded=${(name) => { const mine = ++interaction.current, a = adding; void (a.machine ? machineAdded(a.machine, name, () => mounted.current && interaction.current === mine) : accountAdded(a.backend, name, () => mounted.current && interaction.current === mine)); }} />` : null}
211
+ ${signingOut ? html`<${SignOutDialog} cli=${signingOut.cli} row=${signingOut.row} mode=${signingOut.mode} label=${cliLabel(signingOut.cli.backend)}
212
+ onClose=${() => setSigningOut(null)} onMove=${(user) => moveUser(signingOut.cli.backend, user, openAgent)}
213
+ onDone=${() => { const s = signingOut, mine = ++interaction.current; void signedOut(s, () => mounted.current && interaction.current === mine); }} />` : null}
214
+ ${removing ? html`<${RemoveAccountDialog} cli=${removing.cli} row=${removing.row} label=${cliLabel(removing.cli.backend)} onClose=${() => setRemoving(null)}
215
+ onRemoved=${() => void refreshAccounts({ fresh: true })} onMove=${(user) => moveUser(removing.cli.backend, user, openAgent)} />` : null}
132
216
  </section>`;
133
217
  }
134
218
 
135
- function Card({ cli, running, onMove, stageDefault }) {
219
+ /**
220
+ * After + Add account: the view read again (a read begun after the write), then Sign in at once where the dashboard can
221
+ * sign it in (else its row shows the host command) — only while this is still the person's current interaction
222
+ * (`current()`: the view on screen, no dialog opened since) and no other dialog is open on the page.
223
+ */
224
+ async function accountAdded(backend, name, current) {
225
+ await refreshAccounts({ fresh: true });
226
+ if (!current() || shellStore.get().dialog) return;
227
+ const v = accountsStore.get().view, cli = v && Array.isArray(v.clis) ? v.clis.find((c) => c.backend === backend) : null;
228
+ const row = cli ? cli.rows.find((r) => r.scope && r.scope.kind === "host" && r.profile === name) : null;
229
+ if (row && row.signIn) { toast(manageWords.added(name), true); openSignIn({ backend, profile: name }); }
230
+ else toast(manageWords.addedHost(name), true);
231
+ }
232
+ /**
233
+ * #3190 Part 3c: after + Add account on a computer: the server only checked the name (the folder is made by that computer's Runtime when the first sign-in starts), so
234
+ * Sign in opens at once for the new name — while this is still the person's current interaction and no other dialog is open.
235
+ */
236
+ async function machineAdded(machine, name, current) {
237
+ await refreshAccounts({ fresh: true });
238
+ if (!current() || shellStore.get().dialog) return;
239
+ openMachineSignIn({ machine, profile: name });
240
+ }
241
+ /**
242
+ * #3212 PR 3: after Sign out — the view and the sign-ins read again (reads begun after it); Switch account then opens
243
+ * Sign in for the same CLI's default sign-in, while that is still the person's current interaction and no other dialog
244
+ * is open.
245
+ */
246
+ async function signedOut({ cli, row, mode }, current) {
247
+ await Promise.all([refreshAccounts({ fresh: true }), refreshSignIn()]);
248
+ if (mode !== "switch" || !current() || shellStore.get().dialog) return;
249
+ openSignIn({ backend: cli.backend, ...(row.profile ? { profile: row.profile } : {}) });
250
+ }
251
+ /** Remove's Move…: an agent's own dialog (its Account field), or the card's fleet-default selector. */
252
+ function moveUser(backend, user, openAgent) {
253
+ if (user.kind === "agent" && typeof openAgent === "function") { openAgent(user.name); return; }
254
+ if (user.kind === "default" && typeof document !== "undefined") {
255
+ const sel = document.querySelector(`.s-account-card[data-backend="${backend}"] .s-account-default select`);
256
+ if (sel) { sel.scrollIntoView?.({ block: "center" }); sel.focus(); }
257
+ }
258
+ }
259
+
260
+ function Card({ cli, running, onMove, stageDefault, onAdd, onRemove, onSignIn, onSignOut }) {
136
261
  const [picked, setPicked] = useState(undefined); // a staged fleet default, shown until Save reads it back
137
262
  useEffect(() => setPicked(undefined), [cli.fleetDefault]);
138
263
  const host = cli.rows.filter((r) => r.scope && r.scope.kind === "host");
@@ -140,10 +265,12 @@ function Card({ cli, running, onMove, stageDefault }) {
140
265
  for (const r of cli.rows) if (r.scope && r.scope.kind === "machine") { const k = r.scope.id; if (!machines.has(k)) machines.set(k, { scope: r.scope, rows: [] }); machines.get(k).rows.push(r); }
141
266
  const signedIn = host.filter((r) => r.profile && r.state !== "not_signed_in");
142
267
  return html`<div class="s-account-card" data-backend=${cli.backend}>
143
- <div class="s-account-head"><${CliProductMark} id=${cli.backend} size=${24} /><strong>${cliLabel(cli.backend)}</strong></div>
144
- <div class="s-account-rows">${host.map((row) => html`<${Row} key=${row.profile || ""} cli=${cli} row=${row} running=${running} onMove=${onMove} />`)}</div>
145
- ${[...machines.values()].map((m) => html`<div class="s-account-machine"><p class="note">${tx("machine", m.scope.name)}${m.scope.readOnlyReason ? ` — ${m.scope.readOnlyReason}` : ` — ${tx("machineReadOnly")}`}</p>
146
- ${m.rows.map((row) => html`<${Row} key=${`m:${m.scope.id}:${row.profile || ""}`} cli=${cli} row=${row} readOnly=${true} />`)}</div>`)}
268
+ <div class="s-account-head"><${CliProductMark} id=${cli.backend} size=${24} /><strong>${cliLabel(cli.backend)}</strong>
269
+ ${cli.profiles && typeof onAdd === "function" ? html`<button type="button" class="btn btn-sm s-account-add" onClick=${() => onAdd()}>${manageWords.add()}</button>` : null}</div>
270
+ ${/* Ridge #3321 S08: beside paired computers' "On <computer>" groups, the host's rows are named as the host's too. */ ""}
271
+ ${machines.size && host.length ? html`<div class="s-account-machine-head s-account-host-head"><strong>${tx("onHost")}</strong></div>` : null}
272
+ <div class="s-account-rows">${host.map((row) => html`<${Row} key=${row.profile || ""} cli=${cli} row=${row} running=${running} onMove=${onMove} onRemove=${onRemove} onSignIn=${onSignIn} onSignOut=${onSignOut} />`)}</div>
273
+ ${[...machines.values()].map((m) => html`<${MachineSection} key=${m.scope.id} cli=${cli} m=${m} running=${running} onAdd=${onAdd} onSignIn=${onSignIn} onSignOut=${onSignOut} onRemove=${onRemove} />`)}
147
274
  ${cli.profiles && typeof stageDefault === "function" ? html`<label class="field s-account-default"><span>${tx("fleetDefault", cliLabel(cli.backend))}</span>
148
275
  <select value=${(picked !== undefined ? picked : cli.fleetDefault) || ""} onChange=${(e) => { setPicked(e.target.value || null); stageDefault(cli.backend, e.target.value || null); }}>
149
276
  <option value="">${tx("def")}</option>
@@ -153,21 +280,49 @@ function Card({ cli, running, onMove, stageDefault }) {
153
280
  </div>`;
154
281
  }
155
282
 
156
- function Row({ cli, row, onMove, running = false, readOnly = false }) {
283
+ /**
284
+ * #3190 Part 3c: one paired computer's accounts under its name: online or not, why nothing can be changed there when that is so (said once, for the whole
285
+ * computer), + Add account where its Runtime will take one, and its rows.
286
+ */
287
+ function MachineSection({ cli, m, running, onAdd, onSignIn, onSignOut, onRemove }) {
288
+ const level = m.rows.map((r) => r.scope.readOnlyReason).find((code) => code && MACHINE_LEVEL.has(code));
289
+ const online = !!m.scope.online;
290
+ return html`<div class="s-account-machine" data-machine=${m.scope.id}>
291
+ <div class="s-account-machine-head"><strong>${tx("machine", m.scope.name)}</strong>
292
+ <span class=${`tag s-auth-state is-${online ? "usable" : "unknown"}`}>${online ? tx("machineOnline") : tx("machineOffline")}</span>
293
+ ${cli.profiles && !level && typeof onAdd === "function" ? html`<button type="button" class="btn btn-sm s-account-add" disabled=${running} onClick=${() => onAdd(m.scope)}>${manageWords.add()}</button>` : null}</div>
294
+ ${level ? html`<p class="note s-account-why" role="status">${reasonText(level, m.scope.name)}</p>` : null}
295
+ ${m.rows.map((row) => html`<${Row} key=${`m:${m.scope.id}:${row.profile || ""}`} cli=${cli} row=${row} running=${running} onSignIn=${onSignIn} onSignOut=${onSignOut} onRemove=${onRemove} />`)}
296
+ </div>`;
297
+ }
298
+
299
+ function Row({ cli, row, onMove, onRemove, onSignIn = openSignIn, onSignOut, running = false, readOnly = false }) {
300
+ // #3212 PR 3: a signed-in account of a CLI whose own logout the dashboard runs; Switch account on the default sign-in.
301
+ // #3190 Part 3c: a computer's row is changed only where its Runtime allows it (`signIn`); never its default (the Windows user's own sign-in), never Move or Switch.
302
+ const machine = row.scope && row.scope.kind === "machine" ? row.scope : null;
303
+ const manageable = !machine || (row.signIn && !!row.profile);
304
+ const canSignOut = manageable && typeof onSignOut === "function" && row.state === "usable" && SIGN_OUT_CLIS.has(row.backend);
157
305
  const who = identityText(row.identity);
158
306
  const u = row.usage;
307
+ const why = machine && machine.readOnlyReason && !MACHINE_LEVEL.has(machine.readOnlyReason) ? reasonText(machine.readOnlyReason, machine.name) : "";
159
308
  return html`<div class="s-row s-account-row" data-account=${row.profile || "default"}>
160
309
  <div class="s-account-who"><strong>${rowName(row)}</strong>
161
310
  ${who ? html`<small class="s-account-identity">${who}</small>` : null}
162
- <small class="s-account-used">${usedText(row)}${row.usedBy.fleetDefault && cli.profiles ? html` · <span class="tag">${tx("fleetDefaultTag")}</span>` : null}</small>
311
+ <small class="s-account-used">${usedText(row)}${row.usedBy.fleetDefault && cli.profiles ? html` · <span class="tag">${machine ? tx("machineDefaultTag") : tx("fleetDefaultTag")}</span>` : null}</small>
312
+ ${machine ? html`<small class="s-account-usage is-none" title=${tx("machineNoUsageHint")}>${tx("machineNoUsage")}</small>` : null}
313
+ ${why ? html`<small class="note s-account-why">${why}</small>` : null}
163
314
  ${u ? html`<small class=${`s-account-usage${u.stale ? " is-stale" : ""}`}>${tx("weekly", u.percent)}${u.resetsAt ? ` · ${tx("resets", when(u.resetsAt))}` : ""}${u.stale ? ` · ${tx("stale")}` : ""}</small>` : null}
164
315
  </div>
165
316
  <span class=${`tag s-auth-state is-${row.state || "unknown"}`}>${tx(`state_${row.state || "unknown"}`)}</span>
166
317
  ${readOnly ? null : html`<span class="s-actions">
167
- ${row.signIn ? html`<button type="button" class=${row.state === "not_signed_in" ? "btn btn-sm btn-primary" : "btn btn-sm"} disabled=${running} onClick=${() => openSignIn({ backend: row.backend, ...(row.profile ? { profile: row.profile } : {}) })}>${row.state === "usable" ? tx("signInAgain") : tx("signIn")}</button>` : null}
168
- ${cli.profiles && row.state !== "not_signed_in" && typeof onMove === "function" ? html`<button type="button" class="btn btn-sm" onClick=${() => onMove(row)}>${tx("moveHere")}</button>` : null}
318
+ ${row.signIn && typeof onSignIn === "function" ? html`<button type="button" class=${row.state === "not_signed_in" ? "btn btn-sm btn-primary" : "btn btn-sm"} disabled=${running} onClick=${() => onSignIn({ backend: row.backend, ...(row.profile ? { profile: row.profile } : {}), ...(machine ? { machine } : {}) })}>${row.state === "usable" ? tx("signInAgain") : tx("signIn")}</button>` : null}
319
+ ${!machine && cli.profiles && row.state !== "not_signed_in" && typeof onMove === "function" ? html`<button type="button" class="btn btn-sm" onClick=${() => onMove(row)}>${tx("moveHere")}</button>` : null}
320
+ ${canSignOut && !machine && !row.profile && row.signIn ? html`<button type="button" class="btn btn-sm s-account-switch" disabled=${running} onClick=${() => onSignOut(row, "switch")}>${manageWords.switchAccount()}</button>` : null}
321
+ ${canSignOut ? html`<button type="button" class="btn btn-sm btn-ghost s-account-signout" disabled=${running} onClick=${() => onSignOut(row, "signout")}>${manageWords.signOut()}</button>` : null}
322
+ ${manageable && row.profile && typeof onRemove === "function" ? html`<button type="button" class="btn btn-sm btn-ghost s-account-remove" onClick=${() => onRemove(row)}>${manageWords.remove()}</button>` : null}
169
323
  </span>`}
170
- ${!readOnly && !row.signIn && row.hostCommand ? html`<details class="s-host-cli-help"><summary>${tx("hostCommand")}</summary><p class="note">${tx("hostCommandHint")}</p><p class="s-host-cli-command"><code>${row.hostCommand}</code></p></details>` : null}
324
+ ${!readOnly && !row.signIn && row.hostCommand ? html`<details class="s-host-cli-help"><summary>${machine ? tx("machineCommand") : tx("hostCommand")}</summary><p class="note">${machine ? tx("machineCommandHint", machine.name) : tx("hostCommandHint")}</p>${machine ? html`<p class="s-host-cli-command"><code>${row.hostCommand}</code></p>` : null}</details>` : null}
325
+ ${!readOnly && row.keepAlive && (!row.scope || row.scope.kind === "host") ? html`<${KeepAliveControl} row=${row} onSaved=${() => refreshAccounts({ fresh: true })} />` : null}
171
326
  </div>`;
172
327
  }
173
328