@songsid/agend 2.3.5-alpha.6 → 2.3.5-alpha.8

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 (258) hide show
  1. package/dist/accounts-view.d.ts +17 -0
  2. package/dist/accounts-view.js +33 -6
  3. package/dist/accounts-view.js.map +1 -1
  4. package/dist/apply-job.d.ts +5 -0
  5. package/dist/apply-job.js +10 -3
  6. package/dist/apply-job.js.map +1 -1
  7. package/dist/auth-api.d.ts +1 -1
  8. package/dist/auth-api.js +15 -2
  9. package/dist/auth-api.js.map +1 -1
  10. package/dist/authority/web-authority.d.ts +13 -0
  11. package/dist/authority/web-authority.js +12 -0
  12. package/dist/authority/web-authority.js.map +1 -1
  13. package/dist/backend/claude-code.js +47 -9
  14. package/dist/backend/claude-code.js.map +1 -1
  15. package/dist/backend/kiro.js +1 -1
  16. package/dist/backend/kiro.js.map +1 -1
  17. package/dist/build-provenance.json +1 -1
  18. package/dist/channel/access-manager.d.ts +1 -6
  19. package/dist/channel/access-manager.js +4 -94
  20. package/dist/channel/access-manager.js.map +1 -1
  21. package/dist/channel/adapters/discord.d.ts +0 -2
  22. package/dist/channel/adapters/discord.js +0 -8
  23. package/dist/channel/adapters/discord.js.map +1 -1
  24. package/dist/channel/adapters/telegram.d.ts +0 -3
  25. package/dist/channel/adapters/telegram.js +1 -30
  26. package/dist/channel/adapters/telegram.js.map +1 -1
  27. package/dist/channel/types.d.ts +0 -2
  28. package/dist/cli.js +1 -19
  29. package/dist/cli.js.map +1 -1
  30. package/dist/config-validator.js +2 -1
  31. package/dist/config-validator.js.map +1 -1
  32. package/dist/fleet-manager.d.ts +84 -3
  33. package/dist/fleet-manager.js +494 -51
  34. package/dist/fleet-manager.js.map +1 -1
  35. package/dist/general-knowledge/skills/concepts/SKILL.md +22 -7
  36. package/dist/general-knowledge/steering/core-rules.md +7 -5
  37. package/dist/hub/buttons.js +4 -2
  38. package/dist/hub/buttons.js.map +1 -1
  39. package/dist/hub/catalog.d.ts +2 -2
  40. package/dist/hub/catalog.js +233 -48
  41. package/dist/hub/catalog.js.map +1 -1
  42. package/dist/hub/client.js +2 -0
  43. package/dist/hub/client.js.map +1 -1
  44. package/dist/hub/compose/member.d.ts +6 -0
  45. package/dist/hub/compose/member.js +9 -1
  46. package/dist/hub/compose/member.js.map +1 -1
  47. package/dist/hub/compose/server.d.ts +11 -1
  48. package/dist/hub/compose/server.js +70 -3
  49. package/dist/hub/compose/server.js.map +1 -1
  50. package/dist/hub/directory/directory.d.ts +1 -1
  51. package/dist/hub/directory/directory.js +32 -23
  52. package/dist/hub/directory/directory.js.map +1 -1
  53. package/dist/hub/directory/index.d.ts +1 -1
  54. package/dist/hub/directory/types.d.ts +8 -2
  55. package/dist/hub/directory/types.js.map +1 -1
  56. package/dist/hub/group-policy/admin-api.d.ts +30 -0
  57. package/dist/hub/group-policy/admin-api.js +83 -0
  58. package/dist/hub/group-policy/admin-api.js.map +1 -0
  59. package/dist/hub/group-policy/admin-context.d.ts +23 -0
  60. package/dist/hub/group-policy/admin-context.js +52 -0
  61. package/dist/hub/group-policy/admin-context.js.map +1 -0
  62. package/dist/hub/group-policy/admin-control.d.ts +34 -0
  63. package/dist/hub/group-policy/admin-control.js +258 -0
  64. package/dist/hub/group-policy/admin-control.js.map +1 -0
  65. package/dist/hub/group-policy/admin-dto.d.ts +243 -0
  66. package/dist/hub/group-policy/admin-dto.js +55 -0
  67. package/dist/hub/group-policy/admin-dto.js.map +1 -0
  68. package/dist/hub/group-policy/admin-facts.d.ts +17 -0
  69. package/dist/hub/group-policy/admin-facts.js +33 -0
  70. package/dist/hub/group-policy/admin-facts.js.map +1 -0
  71. package/dist/hub/group-policy/admin-impact.d.ts +51 -0
  72. package/dist/hub/group-policy/admin-impact.js +88 -0
  73. package/dist/hub/group-policy/admin-impact.js.map +1 -0
  74. package/dist/hub/group-policy/admin-inventory.d.ts +24 -0
  75. package/dist/hub/group-policy/admin-inventory.js +72 -0
  76. package/dist/hub/group-policy/admin-inventory.js.map +1 -0
  77. package/dist/hub/group-policy/admin-read.d.ts +21 -0
  78. package/dist/hub/group-policy/admin-read.js +90 -0
  79. package/dist/hub/group-policy/admin-read.js.map +1 -0
  80. package/dist/hub/group-policy/authorization.d.ts +60 -0
  81. package/dist/hub/group-policy/authorization.js +292 -0
  82. package/dist/hub/group-policy/authorization.js.map +1 -0
  83. package/dist/hub/group-policy/impact-inventory.d.ts +21 -0
  84. package/dist/hub/group-policy/impact-inventory.js +75 -0
  85. package/dist/hub/group-policy/impact-inventory.js.map +1 -0
  86. package/dist/hub/group-policy/resources.d.ts +22 -2
  87. package/dist/hub/group-policy/resources.js +119 -25
  88. package/dist/hub/group-policy/resources.js.map +1 -1
  89. package/dist/hub/group-policy/store.d.ts +19 -2
  90. package/dist/hub/group-policy/store.js +66 -5
  91. package/dist/hub/group-policy/store.js.map +1 -1
  92. package/dist/hub/group-policy/welcome.d.ts +36 -0
  93. package/dist/hub/group-policy/welcome.js +55 -0
  94. package/dist/hub/group-policy/welcome.js.map +1 -0
  95. package/dist/hub/http/compose.d.ts +2 -0
  96. package/dist/hub/http/compose.js +133 -12
  97. package/dist/hub/http/compose.js.map +1 -1
  98. package/dist/hub/http/core.d.ts +23 -3
  99. package/dist/hub/http/core.js +138 -5
  100. package/dist/hub/http/core.js.map +1 -1
  101. package/dist/hub/http/deps.d.ts +10 -0
  102. package/dist/hub/member/pairing-api.d.ts +2 -0
  103. package/dist/hub/member/pairing-api.js +1 -0
  104. package/dist/hub/member/pairing-api.js.map +1 -1
  105. package/dist/hub/member/pairing-notices.d.ts +18 -0
  106. package/dist/hub/member/pairing-notices.js +58 -0
  107. package/dist/hub/member/pairing-notices.js.map +1 -0
  108. package/dist/hub/pairing-notices.d.ts +47 -0
  109. package/dist/hub/pairing-notices.js +241 -0
  110. package/dist/hub/pairing-notices.js.map +1 -0
  111. package/dist/hub/pairing.d.ts +33 -1
  112. package/dist/hub/pairing.js +315 -15
  113. package/dist/hub/pairing.js.map +1 -1
  114. package/dist/hub/policy.d.ts +3 -1
  115. package/dist/hub/policy.js +13 -6
  116. package/dist/hub/policy.js.map +1 -1
  117. package/dist/hub/protocol.d.ts +32 -0
  118. package/dist/hub/protocol.js +6 -1
  119. package/dist/hub/protocol.js.map +1 -1
  120. package/dist/hub/rooms.d.ts +1 -0
  121. package/dist/hub/rooms.js +76 -26
  122. package/dist/hub/rooms.js.map +1 -1
  123. package/dist/hub/runtime.d.ts +4 -1
  124. package/dist/hub/runtime.js +11 -0
  125. package/dist/hub/runtime.js.map +1 -1
  126. package/dist/hub/server.js +4 -0
  127. package/dist/hub/server.js.map +1 -1
  128. package/dist/hub/sessions.js +2 -1
  129. package/dist/hub/sessions.js.map +1 -1
  130. package/dist/hub/store.d.ts +10 -1
  131. package/dist/hub/store.js +7 -4
  132. package/dist/hub/store.js.map +1 -1
  133. package/dist/hub/types.d.ts +15 -2
  134. package/dist/locale.js +48 -36
  135. package/dist/locale.js.map +1 -1
  136. package/dist/login-controller.d.ts +9 -1
  137. package/dist/login-controller.js +20 -1
  138. package/dist/login-controller.js.map +1 -1
  139. package/dist/login-flows.js +4 -2
  140. package/dist/login-flows.js.map +1 -1
  141. package/dist/office-share-page.js +1 -1
  142. package/dist/office-share-page.js.map +1 -1
  143. package/dist/outbound-handlers.js +1 -1
  144. package/dist/outbound-handlers.js.map +1 -1
  145. package/dist/quickstart-api.js +2 -2
  146. package/dist/quickstart-api.js.map +1 -1
  147. package/dist/reply-buttons-controller.d.ts +5 -1
  148. package/dist/reply-buttons-controller.js +8 -4
  149. package/dist/reply-buttons-controller.js.map +1 -1
  150. package/dist/reply-buttons.d.ts +6 -2
  151. package/dist/reply-buttons.js +7 -3
  152. package/dist/reply-buttons.js.map +1 -1
  153. package/dist/runtime-api.js +10 -2
  154. package/dist/runtime-api.js.map +1 -1
  155. package/dist/settings-api.d.ts +2 -1
  156. package/dist/settings-api.js +7 -5
  157. package/dist/settings-api.js.map +1 -1
  158. package/dist/settings-change.d.ts +10 -0
  159. package/dist/settings-change.js +17 -1
  160. package/dist/settings-change.js.map +1 -1
  161. package/dist/settings-confirmation.d.ts +25 -1
  162. package/dist/settings-confirmation.js +11 -3
  163. package/dist/settings-confirmation.js.map +1 -1
  164. package/dist/settings-effect.js +18 -6
  165. package/dist/settings-effect.js.map +1 -1
  166. package/dist/settings-http-confirmation.d.ts +21 -0
  167. package/dist/settings-http-confirmation.js +74 -3
  168. package/dist/settings-http-confirmation.js.map +1 -1
  169. package/dist/signin-keepalive.d.ts +2 -0
  170. package/dist/signin-keepalive.js +30 -2
  171. package/dist/signin-keepalive.js.map +1 -1
  172. package/dist/structured-signin.js +3 -1
  173. package/dist/structured-signin.js.map +1 -1
  174. package/dist/tips.js +4 -4
  175. package/dist/tips.js.map +1 -1
  176. package/dist/types.d.ts +2 -0
  177. package/dist/types.js.map +1 -1
  178. package/dist/ui/accounts-keepalive.js +14 -8
  179. package/dist/ui/accounts-manage.js +31 -13
  180. package/dist/ui/accounts-view.js +93 -35
  181. package/dist/ui/backend-signin.js +22 -4
  182. package/dist/ui/general-location.js +28 -14
  183. package/dist/ui/hub-chat-store.js +2 -1
  184. package/dist/ui/hub-client.js +43 -3
  185. package/dist/ui/hub-grant-strings.js +13 -0
  186. package/dist/ui/hub-group-policy.js +170 -0
  187. package/dist/ui/hub-group-strings.js +97 -0
  188. package/dist/ui/hub-owner-strings.js +6 -2
  189. package/dist/ui/hub-pairing-progress-strings.js +15 -0
  190. package/dist/ui/hub-quick-pairing.js +202 -0
  191. package/dist/ui/hub-quick-strings.js +43 -0
  192. package/dist/ui/hub-read-strings.js +7 -0
  193. package/dist/ui/hub-strings.js +4 -2
  194. package/dist/ui/hub-welcome.js +99 -0
  195. package/dist/ui/panel-hub.js +115 -33
  196. package/dist/ui/panel-log.js +2 -2
  197. package/dist/ui/panel-runtimes.js +14 -6
  198. package/dist/ui/panel-settings.js +12 -21
  199. package/dist/ui/runtime-cli-install.js +24 -4
  200. package/dist/ui/settings-apply.js +12 -5
  201. package/dist/ui/settings-confirm.js +28 -0
  202. package/dist/ui/settings-devices.js +8 -12
  203. package/dist/ui/settings-dialogs.js +3 -1
  204. package/dist/ui/settings-hub-membership.js +24 -10
  205. package/dist/ui/settings-hub-section.js +60 -0
  206. package/dist/ui/settings-hub.js +58 -13
  207. package/dist/ui/settings-layout.js +6 -2
  208. package/dist/ui/settings-named-test.js +2 -2
  209. package/dist/ui/settings-outside.js +1 -1
  210. package/dist/ui/settings-quota-notice.js +8 -6
  211. package/dist/ui/settings-registry.js +3 -0
  212. package/dist/ui/settings-restart-strings.js +17 -0
  213. package/dist/ui/settings-strings.js +12 -10
  214. package/dist/ui/shared/accounts-keepalive.css +11 -6
  215. package/dist/ui/shared/accounts.css +68 -18
  216. package/dist/ui/shared/app-i18n.js +7 -2
  217. package/dist/ui/shared/app-route.js +1 -1
  218. package/dist/ui/shared/app-shell.js +114 -7
  219. package/dist/ui/shared/app.css +16 -0
  220. package/dist/ui/shared/chat-strings.js +8 -8
  221. package/dist/ui/shared/hub-groups.css +26 -0
  222. package/dist/ui/shared/hub-owner.css +2 -2
  223. package/dist/ui/shared/hub-signin.css +24 -0
  224. package/dist/ui/shared/hub.css +1 -0
  225. package/dist/ui/shared/setup-host-text.js +4 -1
  226. package/dist/ui/shared/signin.js +3 -1
  227. package/dist/ui/shared/usage-dialog.js +3 -72
  228. package/dist/ui/shared/usage-meter.js +84 -0
  229. package/dist/ui/shared/view-strings.js +4 -4
  230. package/dist/ui/shared/web-authorize.js +4 -4
  231. package/dist/ui/structured-signin.js +16 -8
  232. package/dist/update-marker.d.ts +2 -0
  233. package/dist/update-marker.js.map +1 -1
  234. package/dist/usage/providers.d.ts +1 -0
  235. package/dist/usage/providers.js +13 -9
  236. package/dist/usage/providers.js.map +1 -1
  237. package/dist/web-api.d.ts +10 -1
  238. package/dist/web-api.js +40 -11
  239. package/dist/web-api.js.map +1 -1
  240. package/dist/web-backend-login.d.ts +16 -2
  241. package/dist/web-backend-login.js +14 -0
  242. package/dist/web-backend-login.js.map +1 -1
  243. package/dist/web-notices.d.ts +9 -0
  244. package/dist/web-notices.js +19 -0
  245. package/dist/web-notices.js.map +1 -1
  246. package/dist/web-remote-access.d.ts +6 -0
  247. package/dist/web-remote-access.js +10 -1
  248. package/dist/web-remote-access.js.map +1 -1
  249. package/dist/web-shell-routes.d.ts +1 -1
  250. package/dist/web-shell-routes.js +1 -1
  251. package/dist/web-shell-routes.js.map +1 -1
  252. package/dist/web-terminal.d.ts +7 -0
  253. package/dist/web-terminal.js +14 -2
  254. package/dist/web-terminal.js.map +1 -1
  255. package/dist/windows-cli-api.d.ts +8 -0
  256. package/dist/windows-cli-api.js +10 -0
  257. package/dist/windows-cli-api.js.map +1 -1
  258. package/package.json +2 -1
@@ -2,7 +2,7 @@
2
2
  // (the ones agents use, and the ones only on this host), which account each is (masked, #3190), who uses it and its
3
3
  // weekly usage. From GET /ui/accounts (the local admin session only; nothing about a credential reaches this page).
4
4
  // - Sign in / Sign in again: the existing dialogs (backend-signin.js: one implementation, the same login flows).
5
- // - Move agents here…: stages each chosen agent's `backend_options.<cli>.credential_profile`, through Settings' own
5
+ // - Move agents here: stages each chosen agent's `backend_options.<cli>.credential_profile`, through Settings' own
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.
@@ -14,7 +14,10 @@ import { html, useEffect, useRef, useState } from "/assets/app-html.js";
14
14
  import { register, t } from "/assets/app-i18n.js";
15
15
  import { appStore, createStore, useStore } from "/assets/app-store.js";
16
16
  import { Dialog } from "/assets/ui-dialog.js";
17
- import { Skeleton } from "/assets/ui-states.js";
17
+ import { Icon } from "/assets/ui-icons.js";
18
+ import { Menu } from "/assets/ui-menu.js";
19
+ import { ErrorState, Skeleton } from "/assets/ui-states.js";
20
+ import { CompactMeter } from "/assets/usage-meter.js"; // #3321: the Usage panel's meter, not a second one (its own module: a tab that kept an older usage-dialog.js still links)
18
21
  import { CliProductMark, cliLabel } from "./cli-picker.js";
19
22
  import { identityText } from "./account-identity.js";
20
23
  import { openSignIn, refreshSignIn, signInStore } from "./backend-signin.js";
@@ -26,14 +29,15 @@ import { KeepAliveControl } from "./accounts-keepalive.js"; // #3292
26
29
 
27
30
  register("accounts", {
28
31
  en: {
29
- 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.",
32
+ 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.",
30
33
  loading: "Reading accounts…", failed: "Could not read the accounts.", empty: "No CLI is installed or used by an agent on this host.",
31
34
  def: "Default sign-in", profile: "Account “{0}”", state_usable: "signed in", state_not_signed_in: "not signed in", state_unknown: "not checked",
32
35
  state_not_installed: "not installed", state_too_old: "too old",
33
36
  usedBy: "used by {0}", usedByNone: "used by no agent", agents: "{0} agents", agent: "1 agent", channels: "{0} ClassicBot rooms", channel: "1 ClassicBot room",
34
- fleetDefaultTag: "fleet default", weekly: "{0}% of the week", resets: "resets {0}", stale: "last known",
35
- signIn: "Sign in", signInAgain: "Sign in again", hostCommand: "Sign in on the host", hostCommandHint: "Run this in a terminal on the host running AgEnD.",
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:",
37
+ fleetDefaultTag: "fleet default",
38
+ usageLabel: "Usage", winHours: "{0}h", winDays: "{0}d", winWeek: "7d", winStale: "(stale)",
39
+ 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.",
40
+ 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:",
37
41
  carry_claude: "Claude Code carries its conversation over.", carry_codex: "Codex keeps its conversation.", carry_kiro: "Kiro starts a new conversation, with a handover.",
38
42
  moveNone: "Every {0} agent already uses this account.", moveStage: "Stage", cancel: "Cancel", current: "now: {0}",
39
43
  fleetDefault: "Fleet default for {0} agents", fleetDefaultHint: "Agents that don't choose an account use this one.",
@@ -50,16 +54,18 @@ register("accounts", {
50
54
  acctLabel: "Account", acctInherit: "Fleet default ({0})", acctInheritDefault: "Fleet default (default sign-in)", acctNotSignedIn: "{0} — not signed in",
51
55
  acctHint: "Changing the account restarts the agent. A signed-out account can't be chosen: sign it in under Accounts first.",
52
56
  acctDefaultBlocked: "This fleet's default for {0} is “{1}”, so an agent follows it unless it names another account.",
57
+ usedPopTitle: "Agents using this account — choose one to open its settings",
53
58
  },
54
59
  "zh-TW": {
55
- title: "帳號", hint: "這台主機上各 CLI 的登入:預設登入與具名帳號(憑證設定檔)、誰在使用,以及每週用量。",
60
+ title: "帳號", hint: "這台 AgEnD 主機與已配對電腦上各 CLI 的登入:預設登入與具名帳號(憑證設定檔)、誰在使用,以及每週用量。",
56
61
  loading: "正在讀取帳號…", failed: "無法讀取帳號。", empty: "這台主機上沒有安裝或被 Agent 使用的 CLI。",
57
62
  def: "預設登入", profile: "帳號「{0}」", state_usable: "已登入", state_not_signed_in: "尚未登入", state_unknown: "未確認",
58
63
  state_not_installed: "未安裝", state_too_old: "版本太舊",
59
64
  usedBy: "使用者:{0}", usedByNone: "沒有 Agent 使用", agents: "{0} 個 Agent", agent: "1 個 Agent", channels: "{0} 個 ClassicBot 房間", channel: "1 個 ClassicBot 房間",
60
- fleetDefaultTag: "Fleet 預設", weekly: "本週已用 {0}%", resets: "{0} 重置", stale: "最後已知",
61
- signIn: "登入", signInAgain: "重新登入", hostCommand: "在主機上登入", hostCommandHint: "請在執行 AgEnD 的主機終端機執行。",
62
- moveHere: "把 Agent 移到這裡…", moveTitle: "把 Agent 移到 {0}", moveLead: "選擇要改用 {1} 的 {0} Agent。按「儲存」後,各自會以它重新啟動:",
65
+ fleetDefaultTag: "Fleet 預設",
66
+ usageLabel: "用量", winHours: "{0}h", winDays: "{0}天", winWeek: "本週", winStale: "(未更新)",
67
+ signIn: "登入", signInAgain: "重新登入", hostCommand: "從聊天登入", hostCommandHint: "這一列無法從儀表板登入。請在聊天傳 /login,或請 General。",
68
+ moveHere: "移入 Agent", moveTitle: "把 Agent 移到 {0}", moveLead: "選擇要改用 {1} 的 {0} Agent。按「儲存」後,各自會以它重新啟動:",
63
69
  carry_claude: "Claude Code 會帶著對話過去。", carry_codex: "Codex 保留原本的對話。", carry_kiro: "Kiro 會開新對話並附上交接。",
64
70
  moveNone: "所有 {0} Agent 都已經使用這個帳號。", moveStage: "加入待儲存", cancel: "取消", current: "目前:{0}",
65
71
  fleetDefault: "{0} Agent 的 Fleet 預設帳號", fleetDefaultHint: "沒有指定帳號的 Agent 會使用這個。",
@@ -76,6 +82,7 @@ register("accounts", {
76
82
  acctLabel: "帳號", acctInherit: "Fleet 預設({0})", acctInheritDefault: "Fleet 預設(預設登入)", acctNotSignedIn: "{0}——尚未登入",
77
83
  acctHint: "更換帳號會重新啟動 Agent。尚未登入的帳號不能選,請先在「帳號」登入。",
78
84
  acctDefaultBlocked: "這個 Fleet 的 {0} 預設帳號是「{1}」,Agent 除非指定其他帳號,否則會使用它。",
85
+ usedPopTitle: "使用此帳號的 Agent(點擊跳轉設定)",
79
86
  },
80
87
  });
81
88
  const tx = (k, ...v) => t(`accounts.${k}`, ...v);
@@ -132,7 +139,24 @@ const usedText = (row) => {
132
139
  if (c) parts.push(c === 1 ? tx("channel") : tx("channels", c));
133
140
  return parts.length ? tx("usedBy", parts.join(" · ")) : tx("usedByNone");
134
141
  };
135
- const when = (iso) => { try { const d = new Date(iso); return Number.isFinite(d.getTime()) ? d.toLocaleString(undefined, { weekday: "short", hour: "numeric", minute: "2-digit" }) : ""; } catch { return ""; } };
142
+ /** A usage window's name, from its length: "5h" for hours, the week's own word near seven days, else "30d". `fallback`: what a window of unknown length is. */
143
+ const winLabel = (u, fallback = "") => {
144
+ const ms = Number(u && u.windowMs);
145
+ if (!(ms > 0)) return fallback;
146
+ const h = ms / 3_600_000;
147
+ if (h < 48) return tx("winHours", Math.max(1, Math.round(h)));
148
+ const d = Math.round(h / 24);
149
+ return d >= 6 && d <= 8 ? tx("winWeek") : tx("winDays", d);
150
+ };
151
+ /**
152
+ * One window of the usage block: the Usage panel's own meter (`CompactMeter`, usage-dialog.js) — its name ("5h", "本週"), the bar, the percent
153
+ * (amber from 70%, red from 90%: the theme's --warn / --danger) and when the window resets. The server's window ({ percent, windowMs, resetsAt }) is
154
+ * given in the meter's shape.
155
+ */
156
+ function UsageWindow({ u, kind }) {
157
+ const name = winLabel(u, kind === "weekly" ? tx("winWeek") : "");
158
+ return html`<${CompactMeter} m=${{ used: Number(u.percent) || 0, windowMs: u.windowMs, resetsAt: u.resetsAt, label: name }} tag=${name} />`;
159
+ }
136
160
 
137
161
  /**
138
162
  * The fleet default's `backend_options` after choosing `profile` (null: none) for `backend`: the whole map, because the
@@ -161,6 +185,12 @@ export function accountChoices(view, backend) {
161
185
  * Settings → Agents → Accounts. `stageAgent(name, inst, patch)` and `stageDefault(backend, profile | null)` stage changes;
162
186
  * `openAgent(name)` (#3212 PR 2) opens an agent's own dialog, where its Account is chosen (Remove's Move…).
163
187
  */
188
+ // Ridge #3321 S08: the host's own group head, beside paired computers' "On <computer>".
189
+ register("accounts", {
190
+ en: { onHost: "On this AgEnD host" },
191
+ "zh-TW": { onHost: "在這台 AgEnD 主機上" },
192
+ });
193
+
164
194
  export function AccountsView({ instances, stageAgent, stageDefault, openAgent }) {
165
195
  const { loaded, failed, view } = useStore(accountsStore);
166
196
  // Settings read its data again (after a Save): so does this view.
@@ -189,11 +219,14 @@ export function AccountsView({ instances, stageAgent, stageDefault, openAgent })
189
219
  if (!loaded) return html`<section class="s-group s-accounts" aria-label=${tx("title")}>
190
220
  <header class="s-auth-section-head"><div><h3>${tx("title")}</h3><p>${tx("hint")}</p></div></header>
191
221
  <${Skeleton} variant="cards" lines=${2} label=${tx("loading")} /></section>`;
192
- if (failed && !view) return html`<p class="note" role="alert">${tx("failed")}</p>`;
222
+ // Ridge #3321 S07: a first read that fails keeps the section's heading and says so with Retry (the shared ErrorState).
223
+ if (failed && !view) return html`<section class="s-group s-accounts" aria-label=${tx("title")}>
224
+ <header class="s-auth-section-head"><div><h3>${tx("title")}</h3><p>${tx("hint")}</p></div></header>
225
+ <${ErrorState} message=${tx("failed")} onRetry=${() => void refreshAccounts({ fresh: true })} /></section>`;
193
226
  const clis = (view && view.clis) || [];
194
227
  return html`<section class="s-group s-accounts" aria-label=${tx("title")}>
195
228
  <header class="s-auth-section-head"><div><h3>${tx("title")}</h3><p>${tx("hint")}</p></div></header>
196
- ${!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}
229
+ ${!clis.length ? html`<p class="note">${tx("empty")}</p>` : clis.map((cli) => html`<${Card} key=${cli.backend} cli=${cli} running=${running} openAgent=${openAgent} onMove=${begin((row) => setMove({ cli, row }))} stageDefault=${stageDefault}
197
230
  onAdd=${begin((machine) => setAdding(machine ? { cli, machine } : cli))} onRemove=${begin((row) => setRemoving({ cli, row }))} onSignIn=${begin((target) => (target.machine ? openMachineSignIn(target) : openSignIn(target)))}
198
231
  onSignOut=${begin((row, mode) => setSigningOut({ cli, row, mode }))} />`)}
199
232
  ${move ? html`<${MoveDialog} cli=${move.cli} row=${move.row} instances=${instances} stageAgent=${stageAgent} onClose=${() => setMove(null)} />` : null}
@@ -248,18 +281,20 @@ function moveUser(backend, user, openAgent) {
248
281
  }
249
282
  }
250
283
 
251
- function Card({ cli, running, onMove, stageDefault, onAdd, onRemove, onSignIn, onSignOut }) {
284
+ function Card({ cli, running, openAgent, onMove, stageDefault, onAdd, onRemove, onSignIn, onSignOut }) {
252
285
  const [picked, setPicked] = useState(undefined); // a staged fleet default, shown until Save reads it back
253
286
  useEffect(() => setPicked(undefined), [cli.fleetDefault]);
254
287
  const host = cli.rows.filter((r) => r.scope && r.scope.kind === "host");
255
288
  const machines = new Map();
256
289
  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); }
257
290
  const signedIn = host.filter((r) => r.profile && r.state !== "not_signed_in");
258
- return html`<div class="s-account-card" data-backend=${cli.backend}>
291
+ return html`<div class="card s-account-card" data-backend=${cli.backend}>
259
292
  <div class="s-account-head"><${CliProductMark} id=${cli.backend} size=${24} /><strong>${cliLabel(cli.backend)}</strong>
260
293
  ${cli.profiles && typeof onAdd === "function" ? html`<button type="button" class="btn btn-sm s-account-add" onClick=${() => onAdd()}>${manageWords.add()}</button>` : null}</div>
261
- <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>
262
- ${[...machines.values()].map((m) => html`<${MachineSection} key=${m.scope.id} cli=${cli} m=${m} running=${running} onAdd=${onAdd} onSignIn=${onSignIn} onSignOut=${onSignOut} onRemove=${onRemove} />`)}
294
+ ${/* Ridge #3321 S08: beside paired computers' "On <computer>" groups, the host's rows are named as the host's too. */ ""}
295
+ ${machines.size && host.length ? html`<div class="s-account-machine-head s-account-host-head"><strong>${tx("onHost")}</strong></div>` : null}
296
+ <div class="s-account-rows">${host.map((row) => html`<${Row} key=${row.profile || ""} cli=${cli} row=${row} running=${running} openAgent=${openAgent} onMove=${onMove} onRemove=${onRemove} onSignIn=${onSignIn} onSignOut=${onSignOut} />`)}</div>
297
+ ${[...machines.values()].map((m) => html`<${MachineSection} key=${m.scope.id} cli=${cli} m=${m} running=${running} openAgent=${openAgent} onAdd=${onAdd} onSignIn=${onSignIn} onSignOut=${onSignOut} onRemove=${onRemove} />`)}
263
298
  ${cli.profiles && typeof stageDefault === "function" ? html`<label class="field s-account-default"><span>${tx("fleetDefault", cliLabel(cli.backend))}</span>
264
299
  <select value=${(picked !== undefined ? picked : cli.fleetDefault) || ""} onChange=${(e) => { setPicked(e.target.value || null); stageDefault(cli.backend, e.target.value || null); }}>
265
300
  <option value="">${tx("def")}</option>
@@ -273,7 +308,7 @@ function Card({ cli, running, onMove, stageDefault, onAdd, onRemove, onSignIn, o
273
308
  * #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
274
309
  * computer), + Add account where its Runtime will take one, and its rows.
275
310
  */
276
- function MachineSection({ cli, m, running, onAdd, onSignIn, onSignOut, onRemove }) {
311
+ function MachineSection({ cli, m, running, openAgent, onAdd, onSignIn, onSignOut, onRemove }) {
277
312
  const level = m.rows.map((r) => r.scope.readOnlyReason).find((code) => code && MACHINE_LEVEL.has(code));
278
313
  const online = !!m.scope.online;
279
314
  return html`<div class="s-account-machine" data-machine=${m.scope.id}>
@@ -281,36 +316,59 @@ function MachineSection({ cli, m, running, onAdd, onSignIn, onSignOut, onRemove
281
316
  <span class=${`tag s-auth-state is-${online ? "usable" : "unknown"}`}>${online ? tx("machineOnline") : tx("machineOffline")}</span>
282
317
  ${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>
283
318
  ${level ? html`<p class="note s-account-why" role="status">${reasonText(level, m.scope.name)}</p>` : null}
284
- ${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} />`)}
319
+ ${m.rows.map((row) => html`<${Row} key=${`m:${m.scope.id}:${row.profile || ""}`} cli=${cli} row=${row} running=${running} openAgent=${openAgent} onSignIn=${onSignIn} onSignOut=${onSignOut} onRemove=${onRemove} />`)}
285
320
  </div>`;
286
321
  }
287
322
 
288
- function Row({ cli, row, onMove, onRemove, onSignIn = openSignIn, onSignOut, running = false, readOnly = false }) {
323
+ /**
324
+ * "used by …" (#3212 box layout): a pill. When agents use the account it is a `Menu` (ui-menu.js: arrow keys, Enter, Esc, closes on a click outside,
325
+ * placed clear of the window's edge): one item per agent, and choosing one opens that agent's own settings (`openAgent`). Nobody using it: just the pill.
326
+ */
327
+ function UsedBy({ row, label, openAgent }) {
328
+ const agents = row.usedBy.agents;
329
+ if (!agents.length) return html`<span class="tag s-account-used">${label}</span>`;
330
+ const items = [{ key: "title", heading: true, label: tx("usedPopTitle") },
331
+ ...agents.map((name) => ({ key: name, label: name, disabled: typeof openAgent !== "function", onSelect: () => openAgent(name) }))];
332
+ return html`<${Menu} cls="s-account-used-menu" items=${items} label=${label} fit=${true} triggerClass="tag s-account-used has-users"
333
+ trigger=${html`<span>${label}</span><${Icon} name="chevron" size=${12} />`} />`;
334
+ }
335
+
336
+ function Row({ cli, row, onMove, onRemove, onSignIn = openSignIn, onSignOut, openAgent, running = false, readOnly = false }) {
289
337
  // #3212 PR 3: a signed-in account of a CLI whose own logout the dashboard runs; Switch account on the default sign-in.
290
338
  // #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.
291
339
  const machine = row.scope && row.scope.kind === "machine" ? row.scope : null;
292
340
  const manageable = !machine || (row.signIn && !!row.profile);
293
341
  const canSignOut = manageable && typeof onSignOut === "function" && row.state === "usable" && SIGN_OUT_CLIS.has(row.backend);
294
342
  const who = identityText(row.identity);
295
- const u = row.usage;
343
+ // The week's usage and the short window's (the "5h"), as the server gives them; a CLI that reports one shows one.
344
+ const windows = [row.shortUsage ? ["short", row.shortUsage] : null, row.usage ? ["weekly", row.usage] : null].filter(Boolean);
345
+ const stale = windows.some(([, w]) => w.stale);
296
346
  const why = machine && machine.readOnlyReason && !MACHINE_LEVEL.has(machine.readOnlyReason) ? reasonText(machine.readOnlyReason, machine.name) : "";
347
+ // Four layers in one box: the title bar (name, state, default tag · the buttons), the meta bar (who, used by), the usage block (5h and the week) and Keep sign-in alive as the box's foot.
297
348
  return html`<div class="s-row s-account-row" data-account=${row.profile || "default"}>
298
- <div class="s-account-who"><strong>${rowName(row)}</strong>
299
- ${who ? html`<small class="s-account-identity">${who}</small>` : null}
300
- <small class="s-account-used">${usedText(row)}${row.usedBy.fleetDefault && cli.profiles ? html` · <span class="tag">${machine ? tx("machineDefaultTag") : tx("fleetDefaultTag")}</span>` : null}</small>
349
+ <div class="s-account-title-bar">
350
+ <div class="s-account-title-left"><strong>${rowName(row)}</strong>
351
+ <span class=${`tag s-auth-state is-${row.state || "unknown"}`}>${tx(`state_${row.state || "unknown"}`)}</span>
352
+ ${row.usedBy.fleetDefault && cli.profiles ? html`<span class="tag s-account-default-tag">${machine ? tx("machineDefaultTag") : tx("fleetDefaultTag")}</span>` : null}</div>
353
+ ${readOnly ? null : html`<span class="s-actions">
354
+ ${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}
355
+ ${!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}
356
+ ${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}
357
+ ${canSignOut ? html`<button type="button" class="btn btn-sm btn-ghost s-account-signout" disabled=${running} onClick=${() => onSignOut(row, "signout")}>${manageWords.signOut()}</button>` : null}
358
+ ${manageable && row.profile && typeof onRemove === "function" ? html`<button type="button" class="btn btn-sm btn-ghost danger s-account-remove" onClick=${() => onRemove(row)}>${manageWords.remove()}</button>` : null}
359
+ </span>`}
360
+ </div>
361
+ <div class="s-account-meta-bar">
362
+ ${who ? html`<span class="tag s-account-identity">${who}</span>` : null}
363
+ <${UsedBy} row=${row} label=${usedText(row)} openAgent=${openAgent} />
301
364
  ${machine ? html`<small class="s-account-usage is-none" title=${tx("machineNoUsageHint")}>${tx("machineNoUsage")}</small>` : null}
302
- ${why ? html`<small class="note s-account-why">${why}</small>` : null}
303
- ${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}
304
365
  </div>
305
- <span class=${`tag s-auth-state is-${row.state || "unknown"}`}>${tx(`state_${row.state || "unknown"}`)}</span>
306
- ${readOnly ? null : html`<span class="s-actions">
307
- ${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}
308
- ${!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}
309
- ${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}
310
- ${canSignOut ? html`<button type="button" class="btn btn-sm btn-ghost s-account-signout" disabled=${running} onClick=${() => onSignOut(row, "signout")}>${manageWords.signOut()}</button>` : null}
311
- ${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}
312
- </span>`}
313
- ${!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><p class="s-host-cli-command"><code>${row.hostCommand}</code></p></details>` : null}
366
+ ${windows.length ? html`<div class=${`s-account-usage${stale ? " is-stale" : ""}`} role="group" aria-label=${tx("usageLabel")}>
367
+ ${windows.map(([kind, w]) => html`<${UsageWindow} key=${kind} u=${w} kind=${kind} />`)}
368
+ ${stale ? html`<small class="s-usage-stale">${tx("winStale")}</small>` : null}
369
+ </div>` : null}
370
+ ${why ? html`<p class="note s-account-why">${why}</p>` : null}
371
+ ${!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}
314
372
  ${!readOnly && row.keepAlive && (!row.scope || row.scope.kind === "host") ? html`<${KeepAliveControl} row=${row} onSaved=${() => refreshAccounts({ fresh: true })} />` : null}
315
373
  </div>`;
316
374
  }
@@ -10,6 +10,7 @@ import { t, register, lang, onLang } from "/assets/app-i18n.js";
10
10
  import { appStore, createStore, useStore } from "/assets/app-store.js";
11
11
  import { closeDialog, shellStore, showDialog } from "/assets/app-shell.js";
12
12
  import { Dialog } from "/assets/ui-dialog.js";
13
+ import { confirmDialog } from "/assets/ui-confirm.js";
13
14
  import { toast } from "/assets/ui-toast.js";
14
15
  import { mountStructuredSignIns } from "./structured-signin.js";
15
16
  import { CliProductMark, cliLabel } from "./cli-picker.js";
@@ -219,7 +220,9 @@ export function BrowserSignInDialog({ backend, backends, onClose }) {
219
220
  const root = useRef(null), close = onClose || closeDialog;
220
221
  useEffect(() => {
221
222
  let cards, last = "";
222
- cards = mountStructuredSignIns(root.current, { endpoint: "/ui/browser-backend-signins", lang, changed: next => {
223
+ // Ridge #3321 S01: "Sign in again" asks in the dashboard's own confirmation (its title names the CLI), not the browser's.
224
+ const ask = (message, cli) => confirmDialog({ title: t("signin.reloginTitle", cli), message, confirmLabel: t("signin.reloginGo") });
225
+ cards = mountStructuredSignIns(root.current, { endpoint: "/ui/browser-backend-signins", lang, ask, dashboard: true, changed: next => {
223
226
  if (backends) { if (backends.some(b => !next.selected.includes(b))) void cards.addBackends(backends); }
224
227
  else if (!next.selected.includes(backend)) void cards.addBackend(backend);
225
228
  const signature = JSON.stringify([next.login, next.pending]);
@@ -247,7 +250,7 @@ export function SignInDialog({ backend, profile, resume = false, onClose }) {
247
250
  const [step, setStep] = useState(resume ? { kind: "login" } : { kind: "checking" });
248
251
  const [busy, setBusy] = useState(false);
249
252
  const shown = shownOf(backend, profile);
250
- const close = onClose || closeDialog;
253
+ const dismiss = onClose || closeDialog;
251
254
  useEffect(() => {
252
255
  if (resume) return undefined;
253
256
  let gone = false;
@@ -259,6 +262,14 @@ export function SignInDialog({ backend, profile, resume = false, onClose }) {
259
262
  return () => { gone = true; };
260
263
  }, []);
261
264
  const login = s.login;
265
+ const close = () => {
266
+ if (step.kind === "login" && login && login.mine && login.phase === "running" && login.terminal && login.accessCode) {
267
+ // #3321 review: for the sign-in this dialog was showing, and only if the server finds it still that run, still this session's, its terminal still unopened —
268
+ // not "whatever is running", which a page that read two seconds ago can no longer know. A run that is gone or replaced is left alone.
269
+ void post("/ui/backend-login/cancel", { run: login.id, ifUnopened: true }).then(() => refreshSignIn());
270
+ }
271
+ dismiss();
272
+ };
262
273
  const live = step.kind === "login" && login && login.phase === "running";
263
274
  // While a running sign-in is on screen, read it every 2 s too (a page without the stream still sees it move).
264
275
  useEffect(() => {
@@ -279,6 +290,7 @@ export function SignInDialog({ backend, profile, resume = false, onClose }) {
279
290
  setBusy(false);
280
291
  toast((r.body && r.body.message) || tn("cancelled"));
281
292
  void refreshSignIn();
293
+ dismiss();
282
294
  };
283
295
  let body, actions;
284
296
  if (step.kind === "checking" || step.kind === "starting") {
@@ -337,13 +349,13 @@ register("signin", {
337
349
  hostTitle: "CLI sign-ins", hostHint: "Accounts used by CLIs on the host running AgEnD.",
338
350
  hostBadge: "AgEnD host", hostProfile: "Credential profile: {0}", hostLoading: "Reading CLI sign-ins…", hostEmpty: "No CLI sign-ins were reported on this host.",
339
351
  installHelp: "Installation instructions", updateHelp: "Update instructions", hostHelp: "Sign-in instructions",
340
- commandHint: "Run these instructions in a terminal on the host running AgEnD.",
352
+ commandHint: "Use Sign in on this page, or send /login in chat.",
341
353
  },
342
354
  "zh-TW": {
343
355
  hostTitle: "CLI 登入", hostHint: "執行 AgEnD 的主機上,各個 CLI 使用的帳號。",
344
356
  hostBadge: "AgEnD 主機", hostProfile: "憑證設定檔:{0}", hostLoading: "正在讀取 CLI 登入狀態…", hostEmpty: "這台主機尚未回報 CLI 登入項目。",
345
357
  installHelp: "安裝說明", updateHelp: "更新說明", hostHelp: "登入說明",
346
- commandHint: "請在執行 AgEnD 的主機終端機中操作。",
358
+ commandHint: "請用這一頁的「登入」,或在聊天傳 /login。",
347
359
  },
348
360
  });
349
361
 
@@ -370,3 +382,9 @@ export function SignInList() {
370
382
  })}</div>`}
371
383
  </section>`;
372
384
  }
385
+
386
+ // Ridge #3321 S01: "Sign in again" — the dashboard's confirmation, titled with the CLI it is for.
387
+ register("signin", {
388
+ en: { reloginTitle: "Sign in to {0} again", reloginGo: "Sign in again" },
389
+ "zh-TW": { reloginTitle: "重新登入 {0}", reloginGo: "重新登入" },
390
+ });
@@ -34,10 +34,14 @@ export function GeneralLocation({ name, attentionOnly = false }) {
34
34
  };
35
35
  useEffect(() => { if (!guestPage()) void read(); }, [name, attentionKey]);
36
36
  if (guestPage()) return null;
37
- return html`<section id="general-location" class="card general-location"><h2>${tr("label")}</h2>
37
+ // alpha.6 feedback (#3): the same card as the Shared agent settings below it (card s-group: a title and its note, then
38
+ // labelled fields in the grid, then the actions) — not a heading, a bare inline select and a full-width button. A select
39
+ // is as wide as its longest option unless bounded: a paired PC's long name ran the card off the right edge.
40
+ const rows = (data?.generals || []).filter(row => !name || row.name === name);
41
+ return html`<section id="general-location" class="card s-group general-location"><div><h3>${tr("label")}</h3>${!attentionOnly ? html`<p class="note">${tr("history")}</p>` : null}</div>
38
42
  ${error ? html`<p role="alert">${error}</p>` : null}
39
- ${(data?.generals || []).filter(row => !name || row.name === name).map(row => html`<${LocationRow} key=${row.name + row.revision} row=${row} machines=${data.machines || []} attentionOnly=${attentionOnly} refresh=${read} />`)}
40
- ${!attentionOnly ? html`<button type="button" class="btn btn-sm" onClick=${read}>${t("settings.refresh")}</button>` : null}
43
+ ${rows.map(row => html`<${LocationRow} key=${row.name + row.revision} row=${row} machines=${data.machines || []} attentionOnly=${attentionOnly} refresh=${read} />`)}
44
+ ${!attentionOnly && !rows.length ? html`<div class="general-location-actions"><button type="button" class="btn btn-sm" onClick=${read}>${t("settings.refresh")}</button></div>` : null}
41
45
  </section>`;
42
46
  }
43
47
  function LocationRow({ row, machines, attentionOnly, refresh }) {
@@ -54,18 +58,28 @@ function LocationRow({ row, machines, attentionOnly, refresh }) {
54
58
  finally { flight.current = false; if (lease.current()) setBusy(false); }
55
59
  };
56
60
  if (attentionOnly && !row.offline && !row.hold) return null;
61
+ const id = `gl-${row.name}`;
62
+ const recover = row.canSwitchBack || row.hold === "start";
57
63
  return html`<div class="general-location-row" data-general=${row.name}>
58
- <strong>${row.displayName}</strong><p>${row.location === "host" ? tr("host") : `${machines.find(item => item.id === row.machineId)?.name || tr("windows")} · ${row.cli}`}</p>
64
+ <p class="general-location-now"><strong>${row.displayName}</strong><span>${row.location === "host" ? tr("host") : `${machines.find(item => item.id === row.machineId)?.name || tr("windows")} · ${row.cli}`}</span></p>
59
65
  ${row.offline || row.hold ? html`<p role="alert">${tr(row.hold || "offline")}</p>` : null}
60
- <p class="note">${tr("history")}</p>
61
- ${row.canSwitchBack ? html`<button type="button" class="btn" disabled=${busy || row.switching} onClick=${() => propose({ location: "host" })}>${tr("host")}</button>` : null}
62
- ${row.hold === "start" ? html`<button type="button" class="btn" disabled=${busy || row.switching} onClick=${() => propose(row.retryTarget || (row.location === "host" ? { location: "host" } : { location: "windows", machineId: row.machineId, cli: row.cli, model: row.model }))}>${t("chat.start")}</button>` : null}
63
- ${!attentionOnly ? html`<label>${tr("label")}<select value=${target} disabled=${busy || row.switching} onChange=${e => { setTarget(e.target.value); setModel(""); }}>
64
- <option value="host">${tr("host")}</option>${machines.map(item => html`<option value=${item.id} disabled=${!item.online}>${item.name}</option>`)}
65
- </select></label>
66
- ${target !== "host" ? html`<label>${t("settings.backend")}<select value=${cli} onChange=${e => { setCli(e.target.value); setModel(""); }}>
67
- ${["claude-code", "codex"].map(id => html`<option value=${id} disabled=${!machine?.clis.some(item => item.id === id)}>${id}</option>`)}
68
- </select></label><${ModelSelect} value=${model} onChange=${setModel} backend=${cli} runtime="windows" machineId=${target} instance=${row.name} />` : null}
69
- <button type="button" class="btn btn-primary" disabled=${busy || row.switching || target === "host" && !row.canSwitchBack || target !== "host" && (!machine?.online || !machine.clis.some(item => item.id === cli))} onClick=${() => propose(target === "host" ? { location: "host" } : { location: "windows", machineId: target, cli, model })}>${t("settings.save")}</button>` : null}
66
+ ${attentionOnly ? html`<p class="note">${tr("history")}</p>` : null}
67
+ ${recover ? html`<div class="general-location-actions">
68
+ ${row.canSwitchBack ? html`<button type="button" class="btn" disabled=${busy || row.switching} onClick=${() => propose({ location: "host" })}>${tr("host")}</button>` : null}
69
+ ${row.hold === "start" ? html`<button type="button" class="btn" disabled=${busy || row.switching} onClick=${() => propose(row.retryTarget || (row.location === "host" ? { location: "host" } : { location: "windows", machineId: row.machineId, cli: row.cli, model: row.model }))}>${t("chat.start")}</button>` : null}
70
+ </div>` : null}
71
+ ${!attentionOnly ? html`<div class="grid2">
72
+ <div class="field"><label for=${`${id}-target`}>${tr("label")}</label><select id=${`${id}-target`} value=${target} disabled=${busy || row.switching} onChange=${e => { setTarget(e.target.value); setModel(""); }}>
73
+ <option value="host">${tr("host")}</option>${machines.map(item => html`<option value=${item.id} disabled=${!item.online}>${item.name}</option>`)}
74
+ </select></div>
75
+ ${target !== "host" ? html`<div class="field"><label for=${`${id}-cli`}>${t("settings.backend")}</label><select id=${`${id}-cli`} value=${cli} onChange=${e => { setCli(e.target.value); setModel(""); }}>
76
+ ${["claude-code", "codex"].map(id => html`<option value=${id} disabled=${!machine?.clis.some(item => item.id === id)}>${id}</option>`)}
77
+ </select></div>` : null}
78
+ </div>
79
+ ${target !== "host" ? html`<${ModelSelect} value=${model} onChange=${setModel} backend=${cli} runtime="windows" machineId=${target} instance=${row.name} />` : null}
80
+ <div class="general-location-actions">
81
+ <button type="button" class="btn btn-sm" onClick=${refresh}>${t("settings.refresh")}</button>
82
+ <button type="button" class="btn btn-primary btn-sm" disabled=${busy || row.switching || target === "host" && !row.canSwitchBack || target !== "host" && (!machine?.online || !machine.clis.some(item => item.id === cli))} onClick=${() => propose(target === "host" ? { location: "host" } : { location: "windows", machineId: target, cli, model })}>${t("settings.save")}</button>
83
+ </div>` : null}
70
84
  </div>`;
71
85
  }
@@ -37,7 +37,8 @@ export function hubEntryToMessages(entry, room, { me = "", reason = (code) => co
37
37
  const id = entry.sequence * 2, out = [];
38
38
  // D: a Hub file in the shared thread's shape (hub-attachments.js); one the renderer cannot take is left out.
39
39
  const files = (list) => { const a = Array.isArray(list) ? list.map(hubFileAttachment).filter(Boolean) : []; return a.length ? { attachments: a } : {}; };
40
- out.push({ boot: "hub", id, role: "user", sender: me, ts: iso(entry.askedAt) ?? iso(at),
40
+ // A closed poll's tally is already in its widget. Its automatic agent prompt was not typed by the asker.
41
+ if (entry.pollResult !== true) out.push({ boot: "hub", id, role: "user", sender: me, ts: iso(entry.askedAt) ?? iso(at),
41
42
  text: entry.expired && entry.question === undefined ? "" : String(entry.question ?? ""), delivery: stageMark(stage),
42
43
  ...files(entry.questionFiles), ...(entry.quote ? { quote: entry.quote } : {}) });
43
44
  if (entry.answer !== undefined) {
@@ -259,11 +259,44 @@ export function createHubWebClient({ fetchImpl = (...a) => fetch(...a) } = {}) {
259
259
  read(roomId, after = 0) { return call("GET", `/hub/v1/rooms/${id(roomId)}/messages?after=${id(after)}`); },
260
260
  chooseButtons(roomId, input) { return call("POST", `/hub/v1/rooms/${id(roomId)}/buttons`, input); },
261
261
  pairings() { return call("GET", "/hub/v1/pairings"); },
262
+ quickPairingV1: true,
263
+ createQuickPairing(label) { return call("POST", "/hub/v1/quick-pairing", { label }); },
264
+ quickPairing(pairingId) { return call("GET", `/hub/v1/quick-pairing${pairingId ? `?id=${id(pairingId)}` : ""}`); },
265
+ stopQuickPairing(pairingId) { return call("POST", `/hub/v1/quick-pairing/${id(pairingId)}/stop`); },
266
+ revokeOwnFleet(fleetId, generation) { return call("POST", `/hub/v1/fleets/${id(fleetId)}/revoke`, { generation }); },
267
+ pairingNotices() { return call("GET", "/hub/v1/notices"); },
268
+ /** The Hub's stream begins with the complete current snapshot; no bootstrap GET is needed. */
269
+ pairingNoticeSnapshotV1: typeof EventSource !== "undefined",
270
+ acknowledgePairingNotice(noticeId) { return call("POST", `/hub/v1/notices/${id(noticeId)}/ack`); },
271
+ subscribePairingNotices(fn, onClosed = () => {}) {
272
+ if (typeof EventSource === "undefined") return () => {};
273
+ const events = new EventSource("/hub/v1/notices/events"); let live = true;
274
+ events.addEventListener("notices", (event) => { if (!live) return; try { const value = JSON.parse(event.data); if (Array.isArray(value.notices)) fn(value.notices); } catch { /* bounded server DTO only */ } });
275
+ events.addEventListener("error", () => {
276
+ // A refused handshake is CLOSED, unlike a transient disconnect that EventSource itself reconnects.
277
+ if (live && events.readyState === 2) { live = false; events.close(); onClosed(); }
278
+ });
279
+ return () => { live = false; events.close(); };
280
+ },
262
281
  confirmPairing(pairingId, fingerprint) { return call("POST", `/hub/v1/pairings/${id(pairingId)}/confirm`, { fingerprint }); },
263
282
  adminOverview() { return call("GET", "/hub/v1/admin/overview"); },
264
283
  createPairing(login) { return call("POST", "/hub/v1/admin/pairings", { login }); },
265
284
  approvePairing(pairingId, fingerprint) { return call("POST", `/hub/v1/admin/pairings/${id(pairingId)}/approve`, { fingerprint }); },
266
285
  revokeFleet(fleetId) { return call("POST", `/hub/v1/admin/fleets/${id(fleetId)}/revoke`); },
286
+ // #3298 S-89 (experimental, off unless the session lists "group-policy-v1"): group permissions, admin only; the welcome, any
287
+ // signed-in person (display only — every action still asks the server).
288
+ groupPolicy() { return call("GET", "/hub/v1/admin/group-policy"); },
289
+ resolveGroup(dn) { return call("POST", "/hub/v1/admin/group-policy/resolve", { dn }); },
290
+ previewGroupPolicy(policy) { return call("POST", "/hub/v1/admin/group-policy/preview", { policy }); },
291
+ /** The policy that was previewed and that preview's digest: the server applies only its own sealed candidate for them. */
292
+ saveGroupPolicy(policy, previewDigest) { return call("PUT", "/hub/v1/admin/group-policy", { policy, previewDigest }); },
293
+ /** One exact paused resource: its own revision, and the policy and suspension-record (lifecycle) revisions the page was shown. */
294
+ resumeGroupResource(resource, expectedPolicyRevision, expectedLifecycleRevision) {
295
+ return call("POST", "/hub/v1/admin/group-policy/resources/resume", { resource, expectedPolicyRevision, expectedLifecycleRevision });
296
+ },
297
+ welcome() { return call("GET", "/hub/v1/me/welcome"); },
298
+ /** This client has the group permissions calls (a cached older client does not: the pages then hide them). */
299
+ groupPolicyV1: true,
267
300
  };
268
301
  }
269
302
 
@@ -275,6 +308,7 @@ export function createHubWebClient({ fetchImpl = (...a) => fetch(...a) } = {}) {
275
308
  * `confirm` is settings-confirm.js (loaded with the card): { api, isPendingResponse, track, newKey }.
276
309
  */
277
310
  export function createMemberClient({ confirm, pollMs = 5000, doc = typeof document !== "undefined" ? document : null, timers = globalThis }) {
311
+ let pairingNotices = [];
278
312
  const listed = async () => {
279
313
  const r = await confirm.api("/api/hub/member/exposures");
280
314
  return r.ok && r.body && Array.isArray(r.body.exposures) ? r.body.exposures : r.status === 404 ? null : [];
@@ -284,12 +318,17 @@ export function createMemberClient({ confirm, pollMs = 5000, doc = typeof docume
284
318
  // "sent for confirmation", followed in the background; the poll shows the result); cancel at once.
285
319
  const pairingNow = async () => {
286
320
  const r = await confirm.api("/api/hub/member/pairing");
287
- if (r.ok && r.body && r.body.pairing) return r.body.pairing;
321
+ if (r.ok && r.body && r.body.pairing) { pairingNotices = Array.isArray(r.body.notices) ? r.body.notices : []; return r.body.pairing; }
322
+ pairingNotices = [];
288
323
  return { state: "held", hold: r.status === 404 ? "unavailable" : "unsaved" };
289
324
  };
290
325
  const step = async (name, body) => {
291
326
  const r = await confirm.api(`/api/hub/member/pairing/${name}`, { method: "POST", headers: { "Idempotency-Key": confirm.newKey("hub") }, body: JSON.stringify(body || {}) });
292
- if (confirm.isPendingResponse(r)) { void Promise.resolve(confirm.track(r.body.pending_change, "hub")).catch(() => {}); return { ok: true, pendingConfirmation: true, pairing: await pairingNow() }; }
327
+ if (confirm.isPendingResponse(r)) {
328
+ const settled = Promise.resolve(confirm.track(r.body.pending_change, "hub"));
329
+ void settled.catch(() => {});
330
+ return { ok: true, pendingConfirmation: true, settled, pairing: await pairingNow() };
331
+ }
293
332
  if (r.status === 404) return { ok: false, error: "unavailable" };
294
333
  return r.body && typeof r.body === "object" ? r.body : { ok: false, error: "unsaved" };
295
334
  };
@@ -308,6 +347,7 @@ export function createMemberClient({ confirm, pollMs = 5000, doc = typeof docume
308
347
  return {
309
348
  stub: false, member: true,
310
349
  pairing: pairingNow,
350
+ pairingNotices: () => pairingNotices,
311
351
  async connect({ address, code }) {
312
352
  const a = String(address || "").trim(), c = String(code || "").trim();
313
353
  if (!ADDRESS_HINT.test(a)) return { ok: false, error: "address" };
@@ -320,7 +360,7 @@ export function createMemberClient({ confirm, pollMs = 5000, doc = typeof docume
320
360
  // #3115 r2: exactly the pairing shown — its hub and bindingId; the server refuses any other (a replacement, a re-pair).
321
361
  const hubId = shown && (shown.hub ? shown.hub.hubId : shown.hubId), binding = shown && shown.binding;
322
362
  if (!hubId || !binding) return { ok: false, error: "conflict" };
323
- const r = await step("disconnect", { hubId, binding }); return r.ok ? { ok: true, remote: "pending", ...(r.pendingConfirmation ? { pendingConfirmation: true } : {}) } : { ok: false, error: r.error === "unsaved" ? "unsaved" : "conflict" }; },
363
+ const r = await step("disconnect", { hubId, binding }); return r.ok ? { ok: true, remote: "pending", ...(r.pendingConfirmation ? { pendingConfirmation: true, settled: r.settled } : {}) } : { ok: false, error: r.error === "unsaved" ? "unsaved" : "conflict" }; },
324
364
  async cancel() { const r = await confirm.api("/api/hub/member/pairing/cancel", { method: "POST", body: "{}" }); return r.ok && r.body && r.body.pairing ? r.body.pairing : pairingNow(); },
325
365
  /** The local status, every pollMs while visible (one request at a time; none while hidden); stops with the last listener. */
326
366
  subscribe(fn) { listeners.add(fn); if (!timer) timer = timers.setTimeout(tick, pollMs); return () => { listeners.delete(fn); if (!listeners.size && timer) { timers.clearTimeout(timer); timer = null; } }; },
@@ -0,0 +1,13 @@
1
+ // Grant feedback lives in a fresh module, including in a tab that cached the older owner dictionary.
2
+ import { register, t } from "/assets/app-i18n.js";
3
+ register("hubGrant", {
4
+ en: {
5
+ recipientRefused: "This account can't be allowed here. Check the sign-in name and that the account is active, then try again.",
6
+ directoryUnavailable: "The directory couldn't be checked. Try again later.",
7
+ },
8
+ "zh-TW": {
9
+ recipientRefused: "目前無法允許這個帳號。請確認登入名稱正確、帳號仍可使用,再試一次。",
10
+ directoryUnavailable: "目前無法查核目錄服務,請稍後再試。",
11
+ },
12
+ });
13
+ export const hg = (key, ...values) => t(`hubGrant.${key}`, ...values);