@skillcdn/console 0.6.0 → 0.6.2

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 (415) hide show
  1. package/README.md +7 -7
  2. package/dist/agent-page.d.ts.map +1 -1
  3. package/dist/agent-page.js +58 -35
  4. package/dist/agent-page.js.map +1 -1
  5. package/dist/agent-usage.d.ts +51 -0
  6. package/dist/agent-usage.d.ts.map +1 -0
  7. package/dist/agent-usage.js +77 -0
  8. package/dist/agent-usage.js.map +1 -0
  9. package/dist/api.d.ts +4 -2
  10. package/dist/api.d.ts.map +1 -1
  11. package/dist/api.js +4 -2
  12. package/dist/api.js.map +1 -1
  13. package/dist/cli/cli.d.ts +9 -2
  14. package/dist/cli/cli.d.ts.map +1 -1
  15. package/dist/cli/cli.js +491 -125
  16. package/dist/cli/cli.js.map +1 -1
  17. package/dist/cli/format.d.ts +46 -4
  18. package/dist/cli/format.d.ts.map +1 -1
  19. package/dist/cli/format.js +163 -45
  20. package/dist/cli/format.js.map +1 -1
  21. package/dist/cli/help.d.ts.map +1 -1
  22. package/dist/cli/help.js +62 -13
  23. package/dist/cli/help.js.map +1 -1
  24. package/dist/cli/machine-check.d.ts +24 -5
  25. package/dist/cli/machine-check.d.ts.map +1 -1
  26. package/dist/cli/machine-check.js +128 -16
  27. package/dist/cli/machine-check.js.map +1 -1
  28. package/dist/cli/pack.d.ts +11 -8
  29. package/dist/cli/pack.d.ts.map +1 -1
  30. package/dist/cli/pack.js +63 -28
  31. package/dist/cli/pack.js.map +1 -1
  32. package/dist/cli/runner-host.d.ts +2 -0
  33. package/dist/cli/runner-host.d.ts.map +1 -1
  34. package/dist/cli/runner-host.js +1 -0
  35. package/dist/cli/runner-host.js.map +1 -1
  36. package/dist/cli/secret-notes.d.ts.map +1 -1
  37. package/dist/cli/secret-notes.js +9 -1
  38. package/dist/cli/secret-notes.js.map +1 -1
  39. package/dist/cli/terminal.d.ts +10 -2
  40. package/dist/cli/terminal.d.ts.map +1 -1
  41. package/dist/cli/terminal.js +16 -4
  42. package/dist/cli/terminal.js.map +1 -1
  43. package/dist/client.d.ts +30 -7
  44. package/dist/client.d.ts.map +1 -1
  45. package/dist/client.js +13 -1
  46. package/dist/client.js.map +1 -1
  47. package/dist/components/agent-page.d.ts +76 -18
  48. package/dist/components/agent-page.d.ts.map +1 -1
  49. package/dist/components/agent-page.js +183 -53
  50. package/dist/components/agent-page.js.map +1 -1
  51. package/dist/components/agents.d.ts +2 -0
  52. package/dist/components/agents.d.ts.map +1 -1
  53. package/dist/components/agents.js +6 -5
  54. package/dist/components/agents.js.map +1 -1
  55. package/dist/components/calendar.d.ts +24 -4
  56. package/dist/components/calendar.d.ts.map +1 -1
  57. package/dist/components/calendar.js +79 -36
  58. package/dist/components/calendar.js.map +1 -1
  59. package/dist/components/categories.js +2 -2
  60. package/dist/components/categories.js.map +1 -1
  61. package/dist/components/comments.js +2 -2
  62. package/dist/components/comments.js.map +1 -1
  63. package/dist/components/decision-list.d.ts.map +1 -1
  64. package/dist/components/decision-list.js +5 -5
  65. package/dist/components/decision-list.js.map +1 -1
  66. package/dist/components/documents.d.ts.map +1 -1
  67. package/dist/components/documents.js +4 -4
  68. package/dist/components/documents.js.map +1 -1
  69. package/dist/components/event-feed.d.ts +2 -3
  70. package/dist/components/event-feed.d.ts.map +1 -1
  71. package/dist/components/event-feed.js +4 -184
  72. package/dist/components/event-feed.js.map +1 -1
  73. package/dist/components/goals.d.ts.map +1 -1
  74. package/dist/components/goals.js +3 -3
  75. package/dist/components/goals.js.map +1 -1
  76. package/dist/components/home.js +9 -9
  77. package/dist/components/home.js.map +1 -1
  78. package/dist/components/icon.d.ts.map +1 -1
  79. package/dist/components/icon.js +11 -2
  80. package/dist/components/icon.js.map +1 -1
  81. package/dist/components/notifications.d.ts +65 -0
  82. package/dist/components/notifications.d.ts.map +1 -0
  83. package/dist/components/notifications.js +162 -0
  84. package/dist/components/notifications.js.map +1 -0
  85. package/dist/components/pack-connect.js +1 -1
  86. package/dist/components/pack-connect.js.map +1 -1
  87. package/dist/components/pack-token.js +1 -1
  88. package/dist/components/pack-token.js.map +1 -1
  89. package/dist/components/people.js +2 -2
  90. package/dist/components/people.js.map +1 -1
  91. package/dist/components/pictures.js +1 -1
  92. package/dist/components/pictures.js.map +1 -1
  93. package/dist/components/plugin-settings.d.ts +22 -1
  94. package/dist/components/plugin-settings.d.ts.map +1 -1
  95. package/dist/components/plugin-settings.js +63 -11
  96. package/dist/components/plugin-settings.js.map +1 -1
  97. package/dist/components/projects.js +1 -1
  98. package/dist/components/projects.js.map +1 -1
  99. package/dist/components/roadmap.js +2 -2
  100. package/dist/components/roadmap.js.map +1 -1
  101. package/dist/components/rules.js +2 -2
  102. package/dist/components/rules.js.map +1 -1
  103. package/dist/components/runs.d.ts.map +1 -1
  104. package/dist/components/runs.js +1 -1
  105. package/dist/components/runs.js.map +1 -1
  106. package/dist/components/sessions.js +1 -1
  107. package/dist/components/sessions.js.map +1 -1
  108. package/dist/components/shell.d.ts +2 -0
  109. package/dist/components/shell.d.ts.map +1 -1
  110. package/dist/components/shell.js +1 -1
  111. package/dist/components/shell.js.map +1 -1
  112. package/dist/components/sign-in.js +2 -2
  113. package/dist/components/sign-in.js.map +1 -1
  114. package/dist/components/skills.d.ts.map +1 -1
  115. package/dist/components/skills.js +1 -1
  116. package/dist/components/skills.js.map +1 -1
  117. package/dist/components/task-view.d.ts +6 -0
  118. package/dist/components/task-view.d.ts.map +1 -1
  119. package/dist/components/task-view.js +3 -2
  120. package/dist/components/task-view.js.map +1 -1
  121. package/dist/components/tokens.js +1 -1
  122. package/dist/components/tokens.js.map +1 -1
  123. package/dist/components/ui.d.ts +21 -2
  124. package/dist/components/ui.d.ts.map +1 -1
  125. package/dist/components/ui.js +24 -3
  126. package/dist/components/ui.js.map +1 -1
  127. package/dist/components/work.js +1 -1
  128. package/dist/components/work.js.map +1 -1
  129. package/dist/console.css +506 -289
  130. package/dist/console.d.ts.map +1 -1
  131. package/dist/console.js +193 -16
  132. package/dist/console.js.map +1 -1
  133. package/dist/data.d.ts +17 -1
  134. package/dist/data.d.ts.map +1 -1
  135. package/dist/data.js +31 -0
  136. package/dist/data.js.map +1 -1
  137. package/dist/desk-page.js +5 -5
  138. package/dist/desk-page.js.map +1 -1
  139. package/dist/feed-words.d.ts +5 -0
  140. package/dist/feed-words.d.ts.map +1 -0
  141. package/dist/feed-words.js +193 -0
  142. package/dist/feed-words.js.map +1 -0
  143. package/dist/i18n/en.d.ts +93 -1
  144. package/dist/i18n/en.d.ts.map +1 -1
  145. package/dist/i18n/en.js +103 -15
  146. package/dist/i18n/en.js.map +1 -1
  147. package/dist/i18n/ko.d.ts.map +1 -1
  148. package/dist/i18n/ko.js +105 -22
  149. package/dist/i18n/ko.js.map +1 -1
  150. package/dist/icons/glyphs.d.ts +370 -104
  151. package/dist/icons/glyphs.d.ts.map +1 -1
  152. package/dist/icons/glyphs.js +72 -66
  153. package/dist/icons/glyphs.js.map +1 -1
  154. package/dist/icons/index.d.ts.map +1 -1
  155. package/dist/icons/index.js +9 -1
  156. package/dist/icons/index.js.map +1 -1
  157. package/dist/index.d.ts +3 -2
  158. package/dist/index.d.ts.map +1 -1
  159. package/dist/index.js +3 -2
  160. package/dist/index.js.map +1 -1
  161. package/dist/limits.d.ts +7 -0
  162. package/dist/limits.d.ts.map +1 -1
  163. package/dist/limits.js +7 -0
  164. package/dist/limits.js.map +1 -1
  165. package/dist/notifications.d.ts +124 -0
  166. package/dist/notifications.d.ts.map +1 -0
  167. package/dist/notifications.js +147 -0
  168. package/dist/notifications.js.map +1 -0
  169. package/dist/onboarding.d.ts.map +1 -1
  170. package/dist/onboarding.js +7 -12
  171. package/dist/onboarding.js.map +1 -1
  172. package/dist/plugin/capabilities.d.ts +1 -1
  173. package/dist/plugin/capabilities.d.ts.map +1 -1
  174. package/dist/plugin/capabilities.js +10 -0
  175. package/dist/plugin/capabilities.js.map +1 -1
  176. package/dist/plugin/context.d.ts +85 -1
  177. package/dist/plugin/context.d.ts.map +1 -1
  178. package/dist/plugin/limits.d.ts +7 -0
  179. package/dist/plugin/limits.d.ts.map +1 -1
  180. package/dist/plugin/limits.js +7 -0
  181. package/dist/plugin/limits.js.map +1 -1
  182. package/dist/plugin/manifest.d.ts +8 -0
  183. package/dist/plugin/manifest.d.ts.map +1 -1
  184. package/dist/plugin/manifest.js +13 -0
  185. package/dist/plugin/manifest.js.map +1 -1
  186. package/dist/plugin/rest-schemas.d.ts +22 -0
  187. package/dist/plugin/rest-schemas.d.ts.map +1 -1
  188. package/dist/plugin/rest-schemas.js +19 -3
  189. package/dist/plugin/rest-schemas.js.map +1 -1
  190. package/dist/plugin/testing.d.ts +2 -0
  191. package/dist/plugin/testing.d.ts.map +1 -1
  192. package/dist/plugin/testing.js +2 -0
  193. package/dist/plugin/testing.js.map +1 -1
  194. package/dist/plugin.d.ts +1 -1
  195. package/dist/plugin.d.ts.map +1 -1
  196. package/dist/plugin.js +1 -1
  197. package/dist/plugin.js.map +1 -1
  198. package/dist/router.d.ts +6 -0
  199. package/dist/router.d.ts.map +1 -1
  200. package/dist/router.js +5 -0
  201. package/dist/router.js.map +1 -1
  202. package/dist/routes.d.ts +2 -0
  203. package/dist/routes.d.ts.map +1 -1
  204. package/dist/routes.js +2 -0
  205. package/dist/routes.js.map +1 -1
  206. package/dist/rules.js +1 -1
  207. package/dist/rules.js.map +1 -1
  208. package/dist/runner/acp.d.ts.map +1 -1
  209. package/dist/runner/acp.js +12 -97
  210. package/dist/runner/acp.js.map +1 -1
  211. package/dist/runner/browser.d.ts +50 -0
  212. package/dist/runner/browser.d.ts.map +1 -0
  213. package/dist/runner/browser.js +104 -0
  214. package/dist/runner/browser.js.map +1 -0
  215. package/dist/runner/claude.d.ts +1 -2
  216. package/dist/runner/claude.d.ts.map +1 -1
  217. package/dist/runner/claude.js +352 -13
  218. package/dist/runner/claude.js.map +1 -1
  219. package/dist/runner/codex.d.ts +9 -10
  220. package/dist/runner/codex.d.ts.map +1 -1
  221. package/dist/runner/codex.js +809 -346
  222. package/dist/runner/codex.js.map +1 -1
  223. package/dist/runner/config.d.ts +14 -3
  224. package/dist/runner/config.d.ts.map +1 -1
  225. package/dist/runner/config.js +27 -7
  226. package/dist/runner/config.js.map +1 -1
  227. package/dist/runner/desk.d.ts +3 -1
  228. package/dist/runner/desk.d.ts.map +1 -1
  229. package/dist/runner/desk.js +17 -5
  230. package/dist/runner/desk.js.map +1 -1
  231. package/dist/runner/message.d.ts +53 -3
  232. package/dist/runner/message.d.ts.map +1 -1
  233. package/dist/runner/message.js +201 -20
  234. package/dist/runner/message.js.map +1 -1
  235. package/dist/runner/registry.d.ts +6 -0
  236. package/dist/runner/registry.d.ts.map +1 -1
  237. package/dist/runner/registry.js.map +1 -1
  238. package/dist/runner/rpc.d.ts +31 -0
  239. package/dist/runner/rpc.d.ts.map +1 -0
  240. package/dist/runner/rpc.js +102 -0
  241. package/dist/runner/rpc.js.map +1 -0
  242. package/dist/runner/runner.d.ts +41 -1
  243. package/dist/runner/runner.d.ts.map +1 -1
  244. package/dist/runner/runner.js +695 -52
  245. package/dist/runner/runner.js.map +1 -1
  246. package/dist/runner/slack.d.ts +17 -8
  247. package/dist/runner/slack.d.ts.map +1 -1
  248. package/dist/runner/slack.js +1250 -78
  249. package/dist/runner/slack.js.map +1 -1
  250. package/dist/runner/types.d.ts +160 -8
  251. package/dist/runner/types.d.ts.map +1 -1
  252. package/dist/runner/types.js.map +1 -1
  253. package/dist/runner/usage.d.ts +105 -0
  254. package/dist/runner/usage.d.ts.map +1 -0
  255. package/dist/runner/usage.js +218 -0
  256. package/dist/runner/usage.js.map +1 -0
  257. package/dist/runner.d.ts +4 -4
  258. package/dist/runner.d.ts.map +1 -1
  259. package/dist/runner.js +3 -3
  260. package/dist/runner.js.map +1 -1
  261. package/dist/schemas.d.ts +673 -0
  262. package/dist/schemas.d.ts.map +1 -1
  263. package/dist/schemas.js +205 -1
  264. package/dist/schemas.js.map +1 -1
  265. package/dist/services.js +3 -3
  266. package/dist/services.js.map +1 -1
  267. package/dist/setup-guide.d.ts +4 -3
  268. package/dist/setup-guide.d.ts.map +1 -1
  269. package/dist/setup-guide.js +11 -13
  270. package/dist/setup-guide.js.map +1 -1
  271. package/dist/text.d.ts +7 -0
  272. package/dist/text.d.ts.map +1 -1
  273. package/dist/text.js +18 -0
  274. package/dist/text.js.map +1 -1
  275. package/dist/vocabulary.d.ts +4 -2
  276. package/dist/vocabulary.d.ts.map +1 -1
  277. package/dist/vocabulary.js +4 -1
  278. package/dist/vocabulary.js.map +1 -1
  279. package/docs/specs/cli.md +26 -19
  280. package/docs/specs/plugins.md +16 -10
  281. package/docs/specs/rest.md +28 -10
  282. package/docs/specs/runner.md +132 -44
  283. package/package.json +4 -4
  284. package/skills/building-a-console/SKILL.md +2 -2
  285. package/skills/building-a-console/references/configuring.md +1 -1
  286. package/skills/building-a-plugin/SKILL.md +4 -4
  287. package/skills/planning-the-board/SKILL.md +1 -1
  288. package/skills/planning-the-board/references/setting-up.md +2 -2
  289. package/skills/running-an-agent/SKILL.md +15 -64
  290. package/skills/running-an-agent/references/preparing-the-machine.md +17 -0
  291. package/skills/running-an-agent/references/several-tasks.md +37 -0
  292. package/skills/running-an-agent/references/slack-app.md +70 -13
  293. package/skills/running-an-agent/references/the-account-and-the-invitation.md +5 -0
  294. package/skills/running-an-agent/references/what-was-not-seen-run-yet.md +3 -0
  295. package/skills/running-an-agent/references/when-the-agent-could-not-go-on.md +16 -0
  296. package/skills/running-an-agent/references/your-first-task.md +14 -0
  297. package/skills/working-the-board/SKILL.md +9 -12
  298. package/skills/working-the-board/references/a-pack-skills-questions.md +3 -0
  299. package/skills/working-the-board/references/a-plugins-commands.md +3 -0
  300. package/skills/working-the-board/references/a-review.md +3 -0
  301. package/skills/working-the-board/references/an-open-run.md +3 -0
  302. package/skills/working-the-board/references/requirements.md +7 -0
  303. package/skills/working-the-board/references/the-pack.md +2 -2
  304. package/skills/working-the-board/references/what-they-were-told.md +3 -0
  305. package/skills/working-the-board/references/work-given-in-chat.md +5 -0
  306. package/src/agent-page.tsx +76 -47
  307. package/src/agent-usage.ts +113 -0
  308. package/src/api.ts +62 -0
  309. package/src/cli/cli.ts +634 -162
  310. package/src/cli/format.ts +190 -47
  311. package/src/cli/help.ts +77 -12
  312. package/src/cli/machine-check.ts +182 -29
  313. package/src/cli/pack.ts +81 -40
  314. package/src/cli/runner-host.ts +3 -0
  315. package/src/cli/secret-notes.ts +9 -1
  316. package/src/cli/terminal.ts +20 -4
  317. package/src/client.ts +94 -6
  318. package/src/components/agent-page.tsx +280 -63
  319. package/src/components/agents.tsx +23 -3
  320. package/src/components/calendar.tsx +93 -37
  321. package/src/components/categories.tsx +2 -2
  322. package/src/components/comments.tsx +5 -5
  323. package/src/components/decision-list.tsx +13 -10
  324. package/src/components/documents.tsx +13 -8
  325. package/src/components/event-feed.tsx +4 -203
  326. package/src/components/goals.tsx +6 -4
  327. package/src/components/home.tsx +12 -12
  328. package/src/components/icon.tsx +16 -3
  329. package/src/components/notifications.tsx +419 -0
  330. package/src/components/pack-connect.tsx +1 -1
  331. package/src/components/pack-token.tsx +5 -5
  332. package/src/components/people.tsx +3 -3
  333. package/src/components/pictures.tsx +1 -1
  334. package/src/components/plugin-settings.tsx +128 -23
  335. package/src/components/projects.tsx +1 -1
  336. package/src/components/roadmap.tsx +2 -2
  337. package/src/components/rules.tsx +2 -2
  338. package/src/components/runs.tsx +6 -3
  339. package/src/components/sessions.tsx +2 -2
  340. package/src/components/shell.tsx +3 -0
  341. package/src/components/sign-in.tsx +3 -3
  342. package/src/components/skills.tsx +5 -3
  343. package/src/components/task-view.tsx +18 -7
  344. package/src/components/tokens.tsx +2 -2
  345. package/src/components/ui.tsx +70 -5
  346. package/src/components/work.tsx +2 -2
  347. package/src/console.tsx +269 -12
  348. package/src/data.ts +54 -0
  349. package/src/desk-page.tsx +5 -5
  350. package/src/feed-words.ts +214 -0
  351. package/src/i18n/en.ts +114 -15
  352. package/src/i18n/ko.ts +115 -22
  353. package/src/icons/glyphs.ts +74 -68
  354. package/src/icons/index.ts +9 -1
  355. package/src/index.ts +11 -0
  356. package/src/limits.ts +7 -0
  357. package/src/notifications.ts +205 -0
  358. package/src/onboarding.ts +10 -14
  359. package/src/plugin/capabilities.ts +13 -0
  360. package/src/plugin/context.ts +87 -0
  361. package/src/plugin/limits.ts +7 -0
  362. package/src/plugin/manifest.ts +14 -0
  363. package/src/plugin/rest-schemas.ts +27 -3
  364. package/src/plugin/testing.ts +4 -0
  365. package/src/plugin.ts +2 -0
  366. package/src/router.ts +7 -0
  367. package/src/routes.ts +2 -0
  368. package/src/rules.ts +1 -1
  369. package/src/runner/acp.ts +12 -118
  370. package/src/runner/browser.ts +128 -0
  371. package/src/runner/claude.ts +399 -12
  372. package/src/runner/codex.ts +904 -400
  373. package/src/runner/config.ts +30 -7
  374. package/src/runner/desk.ts +22 -6
  375. package/src/runner/message.ts +251 -21
  376. package/src/runner/registry.ts +6 -0
  377. package/src/runner/rpc.ts +140 -0
  378. package/src/runner/runner.ts +863 -53
  379. package/src/runner/slack.ts +1535 -85
  380. package/src/runner/types.ts +150 -5
  381. package/src/runner/usage.ts +299 -0
  382. package/src/runner.ts +16 -1
  383. package/src/schemas.ts +249 -0
  384. package/src/services.ts +3 -3
  385. package/src/setup-guide.ts +12 -14
  386. package/src/styles/README.md +11 -7
  387. package/src/styles/console.css +2 -0
  388. package/src/styles/drawn-by-pages.json +7 -82
  389. package/src/styles/pages/agents.css +46 -35
  390. package/src/styles/pages/calendar.css +0 -1
  391. package/src/styles/pages/connect.css +0 -14
  392. package/src/styles/pages/decisions.css +2 -43
  393. package/src/styles/pages/documents.css +0 -29
  394. package/src/styles/pages/home.css +4 -16
  395. package/src/styles/pages/people.css +2 -17
  396. package/src/styles/pages/plugins.css +9 -12
  397. package/src/styles/pages/roadmap.css +0 -16
  398. package/src/styles/pages/settings.css +0 -28
  399. package/src/styles/pages/sign-in.css +2 -17
  400. package/src/styles/pages/thread.css +4 -50
  401. package/src/styles/pages/work.css +0 -5
  402. package/src/styles/parts/button.css +31 -0
  403. package/src/styles/parts/count.css +10 -0
  404. package/src/styles/parts/divider.css +17 -0
  405. package/src/styles/parts/frame.css +12 -0
  406. package/src/styles/parts/icon.css +39 -0
  407. package/src/styles/parts/menu.css +184 -0
  408. package/src/styles/parts/panel.css +7 -0
  409. package/src/styles/parts/progress.css +63 -0
  410. package/src/styles/parts/settings.css +2 -0
  411. package/src/styles/parts/sheet.css +28 -0
  412. package/src/styles/parts/text.css +34 -0
  413. package/src/text.ts +19 -0
  414. package/src/vocabulary.ts +4 -1
  415. package/template/plugin/package.json +1 -1
@@ -0,0 +1,419 @@
1
+ import { type MouseEvent as ReactMouseEvent, useEffect, useId, useRef } from "react";
2
+ import {
3
+ agentLabel,
4
+ type RestEvent,
5
+ type RestNotification,
6
+ type RestNotificationSettings,
7
+ type RestNotificationSettingsInput,
8
+ } from "../api.js";
9
+ import { useWords } from "../i18n/index.js";
10
+ import { describeEvent } from "./event-feed.js";
11
+ import { Icon } from "./icon.js";
12
+ import { isPlainClick } from "./shell.js";
13
+ import { Avatar, Button, cx, personName, Spinner, Time } from "./ui.js";
14
+
15
+ // What a member is told of what happens on the board (ADR-0157): their notifications as a list
16
+ // that opens under a bell in the page's head, what they chose to be told of, and whether one
17
+ // task tells them anything. Each takes its data as props and nothing from the network; what
18
+ // happened is said as the feed says it (ADR-0012).
19
+
20
+ /** The kinds of notification by what they are of, as the settings group them, in the order they are read. */
21
+ const KIND_GROUPS = [
22
+ { group: "tasks", kinds: ["assigned", "ready", "commented", "moved", "changed", "archived"] },
23
+ { group: "decisions", kinds: ["decision", "answered"] },
24
+ { group: "agents", kinds: ["agent"] },
25
+ ] as const;
26
+
27
+ /**
28
+ * How much of what an event names a row of the list shows: the row says that something
29
+ * happened and to what, in two lines, and the page it leads to says it whole. A title is cut
30
+ * shorter than a comment or a question, since the sentence goes on after it.
31
+ */
32
+ const TITLE_SHOWN = 44;
33
+ const EXCERPT_SHOWN = 72;
34
+ const QUESTION_SHOWN = 72;
35
+
36
+ type KnownKind = (typeof KIND_GROUPS)[number]["kinds"][number];
37
+
38
+ const KNOWN_KINDS: readonly string[] = KIND_GROUPS.flatMap((one) => [...one.kinds]);
39
+
40
+ const isKnownKind = (kind: string): kind is KnownKind => KNOWN_KINDS.includes(kind);
41
+
42
+ /** A text cut to so many characters, never in the middle of a letter of two, with what says it was cut. */
43
+ function cut(text: string | undefined, most: number): string | undefined {
44
+ if (text === undefined || text.length <= most) {
45
+ return text;
46
+ }
47
+ const last = text.charCodeAt(most - 1);
48
+ return `${text.slice(0, last >= 0xd800 && last <= 0xdbff ? most - 1 : most).trimEnd()}…`;
49
+ }
50
+
51
+ /** An event with what it names cut to what a row of the list shows. */
52
+ function shortened(event: RestEvent): RestEvent {
53
+ const { data } = event;
54
+ const title = cut(data.title, TITLE_SHOWN);
55
+ const excerpt = cut(data.excerpt, EXCERPT_SHOWN);
56
+ const question = cut(data.question, QUESTION_SHOWN);
57
+ return {
58
+ ...event,
59
+ data: {
60
+ ...data,
61
+ ...(title === undefined ? {} : { title }),
62
+ ...(excerpt === undefined ? {} : { excerpt }),
63
+ ...(question === undefined ? {} : { question }),
64
+ },
65
+ };
66
+ }
67
+
68
+ export interface NotificationsMenuProps {
69
+ /** How many notifications the reader has not read: the bell is marked where there are any. */
70
+ readonly unread: number;
71
+ /** The notifications read so far, the newest first; nothing while the first of them are on their way. */
72
+ readonly notifications: readonly RestNotification[] | undefined;
73
+ /**
74
+ * The moment the list was read at when it opened: a notification read at that moment or
75
+ * after, or not read yet, was new to the reader until now, and is shown so.
76
+ */
77
+ readonly since?: string | undefined;
78
+ readonly problem?: string | undefined;
79
+ /** Where a notification leads: the task, the decision, the agent account's page; nothing where it leads nowhere the reader may go. */
80
+ readonly href: (notification: RestNotification) => string | undefined;
81
+ /** Where what the reader is told of is chosen. */
82
+ readonly settingsHref: string;
83
+ readonly more?: boolean | undefined;
84
+ readonly onMore?: (() => void) | undefined;
85
+ /** Called as the list opens: it is read then, and all of it counts as read from then on. */
86
+ readonly onOpen: () => void;
87
+ /** Follows a link inside the app without loading a document. */
88
+ readonly onNavigate: (href: string) => void;
89
+ }
90
+
91
+ /**
92
+ * A member's notifications, under a bell in the page's head: the bell is marked while there is
93
+ * something they have not read, and the list opens under it, the newest first. A row says who
94
+ * did what in two lines at most, and why and where the reader is told under them; one that was
95
+ * new when the list opened is marked. Opening the list reads all of it: nothing is read one by
96
+ * one.
97
+ */
98
+ export function NotificationsMenu(props: NotificationsMenuProps) {
99
+ const words = useWords();
100
+ const said = words.notifications;
101
+ const kinds: Readonly<Record<string, string>> = said.kinds;
102
+ const details = useRef<HTMLDetailsElement>(null);
103
+ const close = () => {
104
+ if (details.current !== null) {
105
+ details.current.open = false;
106
+ }
107
+ };
108
+ // A click elsewhere, or the escape key, closes it, as a menu is expected to.
109
+ useEffect(() => {
110
+ const onClick = (event: MouseEvent) => {
111
+ const element = details.current;
112
+ if (
113
+ element?.open === true &&
114
+ !(event.target instanceof Node && element.contains(event.target))
115
+ ) {
116
+ element.open = false;
117
+ }
118
+ };
119
+ const onKey = (event: KeyboardEvent) => {
120
+ if (event.key === "Escape" && details.current !== null) {
121
+ details.current.open = false;
122
+ }
123
+ };
124
+ // A click in a plugin's frame is a click elsewhere the page never sees: the window loses the focus.
125
+ const onBlur = () => {
126
+ if (details.current !== null) {
127
+ details.current.open = false;
128
+ }
129
+ };
130
+ document.addEventListener("click", onClick);
131
+ document.addEventListener("keydown", onKey);
132
+ window.addEventListener("blur", onBlur);
133
+ return () => {
134
+ document.removeEventListener("click", onClick);
135
+ document.removeEventListener("keydown", onKey);
136
+ window.removeEventListener("blur", onBlur);
137
+ };
138
+ }, []);
139
+ const follow = (href: string) => (event: ReactMouseEvent) => {
140
+ if (isPlainClick(event)) {
141
+ event.preventDefault();
142
+ close();
143
+ props.onNavigate(href);
144
+ }
145
+ };
146
+ const since = props.since === undefined ? undefined : Date.parse(props.since);
147
+ const fresh = (notification: RestNotification): boolean =>
148
+ notification.readAt === null ||
149
+ (since !== undefined && Date.parse(notification.readAt) >= since);
150
+ const { notifications } = props;
151
+ return (
152
+ <details
153
+ className="sc-menu"
154
+ ref={details}
155
+ onToggle={(event) => {
156
+ if (event.currentTarget.open) {
157
+ props.onOpen();
158
+ }
159
+ }}
160
+ >
161
+ <summary
162
+ className="sc-menu-summary sc-menu-summary-glyph"
163
+ aria-label={props.unread > 0 ? said.openNew(props.unread) : said.open}
164
+ title={said.open}
165
+ >
166
+ <Icon name="bell" size="md" />
167
+ {props.unread > 0 && <span className="sc-nav-dot" aria-hidden="true" />}
168
+ </summary>
169
+ <div className="sc-menu-panel sc-menu-panel-list">
170
+ <div className="sc-menu-head">
171
+ <span className="sc-menu-title">{said.title}</span>
172
+ <a
173
+ className="sc-menu-head-link"
174
+ href={props.settingsHref}
175
+ onClick={follow(props.settingsHref)}
176
+ >
177
+ {said.settingsLink}
178
+ </a>
179
+ </div>
180
+ {props.problem !== undefined ? (
181
+ <p className="sc-menu-note" role="alert">
182
+ {props.problem}
183
+ </p>
184
+ ) : notifications === undefined ? (
185
+ <div className="sc-menu-note">
186
+ <Spinner label={said.loading} />
187
+ </div>
188
+ ) : notifications.length === 0 ? (
189
+ <div className="sc-menu-note">
190
+ <p className="sc-menu-title">{said.empty.title}</p>
191
+ <p>{said.empty.body}</p>
192
+ </div>
193
+ ) : (
194
+ <ul className="sc-menu-rows" aria-label={said.list}>
195
+ {notifications.map((notification) => {
196
+ const { event } = notification;
197
+ const href = props.href(notification);
198
+ const sentence = describeEvent(shortened(event), words);
199
+ const why = notification.followed
200
+ ? said.followed
201
+ : Object.hasOwn(kinds, notification.kind)
202
+ ? kinds[notification.kind]
203
+ : notification.kind;
204
+ const isNew = fresh(notification);
205
+ const row = (
206
+ <>
207
+ {event.actor === null ? (
208
+ <span className="sc-menu-row-glyph">
209
+ <Icon name="bell" size="md" className="sc-icon-plain" />
210
+ </span>
211
+ ) : (
212
+ <Avatar person={event.actor} size="sm" />
213
+ )}
214
+ <span className="sc-menu-row-text">
215
+ <span className="sc-menu-row-title" title={describeEvent(event, words)}>
216
+ <span className="sc-menu-row-who">
217
+ {event.actor === null ? words.feed.console : personName(event.actor)}
218
+ </span>
219
+ {event.agent !== null && (
220
+ <span className="sc-feed-agent" title={event.agent}>
221
+ {" "}
222
+ {words.feed.as(agentLabel(event.agent))}
223
+ </span>
224
+ )}{" "}
225
+ {sentence}
226
+ </span>
227
+ <span className="sc-menu-row-facts">
228
+ <span className="sc-menu-row-why">
229
+ {why}
230
+ {notification.project !== null && ` · ${notification.project.name}`}
231
+ </span>
232
+ <Time iso={notification.createdAt} precision="clock" />
233
+ </span>
234
+ </span>
235
+ {isNew && <span className="sc-nav-dot" role="img" aria-label={said.fresh} />}
236
+ </>
237
+ );
238
+ return (
239
+ <li key={notification.id}>
240
+ {href === undefined ? (
241
+ <span className={cx("sc-menu-row", isNew && "sc-menu-row-new")}>{row}</span>
242
+ ) : (
243
+ <a
244
+ className={cx("sc-menu-row", isNew && "sc-menu-row-new")}
245
+ href={href}
246
+ onClick={follow(href)}
247
+ >
248
+ {row}
249
+ </a>
250
+ )}
251
+ </li>
252
+ );
253
+ })}
254
+ </ul>
255
+ )}
256
+ {props.more === true && props.onMore !== undefined && (
257
+ <div className="sc-menu-foot">
258
+ <button type="button" className="sc-menu-link" onClick={props.onMore}>
259
+ {said.more}
260
+ </button>
261
+ </div>
262
+ )}
263
+ </div>
264
+ </details>
265
+ );
266
+ }
267
+
268
+ export interface NotificationSettingsProps {
269
+ readonly settings: RestNotificationSettings;
270
+ /** The projects the member may see, to turn one off or on again. */
271
+ readonly projects: readonly { readonly key: string; readonly name: string }[];
272
+ /** Whether the member is an agent account: a notification is then what wakes it, and the page says so. */
273
+ readonly agent?: boolean | undefined;
274
+ readonly busy?: boolean | undefined;
275
+ readonly onChange: (input: RestNotificationSettingsInput) => void;
276
+ }
277
+
278
+ /**
279
+ * What a member is told of: each kind a choice that is lit while on, the projects they are
280
+ * told nothing of, and whether what their own agents do as them counts. It is of everything
281
+ * they are told and names no plugin: what a plugin that carries notifications elsewhere sends
282
+ * of it is set on that plugin's own page. A choice is kept as it is made: what the page shows
283
+ * is what holds.
284
+ */
285
+ export function NotificationSettings(props: NotificationSettingsProps) {
286
+ const words = useWords().notifications.settings;
287
+ const kindWords: Readonly<Record<string, string>> = useWords().notifications.kinds;
288
+ const { settings, busy } = props;
289
+ const ownAgentsId = useId();
290
+ const off = new Set(settings.projectsOff.map((project) => project.key));
291
+ const changed = Object.keys(settings.kinds).some(
292
+ (kind) => settings.kinds[kind] !== settings.defaults[kind],
293
+ );
294
+ const untouched = !changed && off.size === 0 && !settings.ownAgents;
295
+ // A kind a newer console adds is offered under its own name, after the ones this page knows.
296
+ const others = Object.keys(settings.kinds).filter((kind) => !isKnownKind(kind));
297
+ const nameOf = (kind: string): string =>
298
+ Object.hasOwn(kindWords, kind) ? (kindWords[kind] ?? kind) : kind;
299
+ const choice = (kind: string) => (
300
+ <label key={kind} className="sc-toggle-chip">
301
+ <input
302
+ type="checkbox"
303
+ checked={settings.kinds[kind] === true}
304
+ disabled={busy === true}
305
+ onChange={(event) => props.onChange({ kinds: { [kind]: event.target.checked } })}
306
+ />
307
+ {nameOf(kind)}
308
+ </label>
309
+ );
310
+ return (
311
+ <div className="sc-settings-form">
312
+ <p className="sc-lead">{props.agent === true ? words.introAgent : words.intro}</p>
313
+ {KIND_GROUPS.map(({ group, kinds }) => (
314
+ <div key={group} className="sc-settings-row">
315
+ <div>
316
+ <span className="sc-settings-label">{words.groups[group]}</span>
317
+ <p className="sc-settings-hint">{words.hints[group]}</p>
318
+ </div>
319
+ <div className="sc-settings-control">
320
+ <fieldset className="sc-toggle-chips" aria-label={words.groups[group]}>
321
+ {kinds.filter((kind) => Object.hasOwn(settings.kinds, kind)).map(choice)}
322
+ {group === "agents" && others.map(choice)}
323
+ </fieldset>
324
+ </div>
325
+ </div>
326
+ ))}
327
+ {props.projects.length > 0 && (
328
+ <div className="sc-settings-row">
329
+ <div>
330
+ <span className="sc-settings-label">{words.projects}</span>
331
+ <p className="sc-settings-hint">{words.projectsHint}</p>
332
+ </div>
333
+ <div className="sc-settings-control">
334
+ <fieldset className="sc-toggle-chips" aria-label={words.projects}>
335
+ {props.projects.map((project) => (
336
+ <label key={project.key} className="sc-toggle-chip">
337
+ <input
338
+ type="checkbox"
339
+ checked={!off.has(project.key)}
340
+ disabled={busy === true}
341
+ onChange={(event) =>
342
+ props.onChange({
343
+ projectsOff: event.target.checked
344
+ ? [...off].filter((key) => key !== project.key)
345
+ : [...off, project.key],
346
+ })
347
+ }
348
+ />
349
+ {project.name}
350
+ </label>
351
+ ))}
352
+ </fieldset>
353
+ </div>
354
+ </div>
355
+ )}
356
+ {props.agent !== true && (
357
+ <div className="sc-settings-row">
358
+ <div>
359
+ <label className="sc-settings-label" htmlFor={ownAgentsId}>
360
+ {words.ownAgents}
361
+ </label>
362
+ <p className="sc-settings-hint">{words.ownAgentsHint}</p>
363
+ </div>
364
+ <div className="sc-settings-control">
365
+ <label className="sc-check">
366
+ <input
367
+ id={ownAgentsId}
368
+ type="checkbox"
369
+ checked={settings.ownAgents}
370
+ disabled={busy === true}
371
+ onChange={(event) => props.onChange({ ownAgents: event.target.checked })}
372
+ />
373
+ {words.ownAgentsOn}
374
+ </label>
375
+ </div>
376
+ </div>
377
+ )}
378
+ <div className="sc-form-actions">
379
+ <Button
380
+ variant="ghost"
381
+ disabled={busy === true || untouched}
382
+ onClick={() => props.onChange({ reset: true })}
383
+ >
384
+ {words.reset}
385
+ </Button>
386
+ </div>
387
+ </div>
388
+ );
389
+ }
390
+
391
+ export interface TaskBellProps {
392
+ /** Whether the task tells the reader anything, as it stands. */
393
+ readonly on: boolean;
394
+ readonly busy?: boolean | undefined;
395
+ /** Called with what the reader turns it to. */
396
+ readonly onChange: (on: boolean) => void;
397
+ }
398
+
399
+ /**
400
+ * Whether one task tells the reader anything, as a bell that is pressed to turn it: lit while
401
+ * what happens on the task reaches them, struck through while it does not. On to begin with
402
+ * for a task their settings tell them of, and off for any other.
403
+ */
404
+ export function TaskBell(props: TaskBellProps) {
405
+ const words = useWords().notifications.task;
406
+ return (
407
+ <Button
408
+ variant="ghost"
409
+ className="sc-button-glyph"
410
+ aria-pressed={props.on}
411
+ aria-label={props.on ? words.turnOff : words.turnOn}
412
+ title={props.on ? words.on : words.off}
413
+ disabled={props.busy === true}
414
+ onClick={() => props.onChange(!props.on)}
415
+ >
416
+ <Icon name={props.on ? "bell" : "bell-off"} size="md" />
417
+ </Button>
418
+ );
419
+ }
@@ -147,7 +147,7 @@ export function PackConnect(props: PackConnectProps) {
147
147
  {pack.connectCancel}
148
148
  </Button>
149
149
  </div>
150
- <p className="sc-pack-connect-waiting">
150
+ <p className="sc-pack-connect-waiting sc-note">
151
151
  <span className="sc-spinner" aria-hidden="true">
152
152
  <span className="sc-spinner-ring" />
153
153
  </span>
@@ -41,10 +41,10 @@ export function PackTokenWays(props: PackTokenWaysProps) {
41
41
  return (
42
42
  <section className="sc-panel sc-panel-form" aria-label={props.title}>
43
43
  <h2 className="sc-section-title">{props.title}</h2>
44
- <p className="sc-pack-intro">{props.intro}</p>
44
+ <p className="sc-pack-intro sc-note">{props.intro}</p>
45
45
  <div className="sc-pack-ways">
46
- <section className="sc-pack-way" aria-label={pack.connectTitle}>
47
- <h3 className="sc-pack-way-title">{pack.connectTitle}</h3>
46
+ <section className="sc-sheet sc-sheet-large sc-pack-way" aria-label={pack.connectTitle}>
47
+ <h3 className="sc-subtitle">{pack.connectTitle}</h3>
48
48
  <PackConnect
49
49
  onStart={props.onStart}
50
50
  poll={props.poll}
@@ -54,8 +54,8 @@ export function PackTokenWays(props: PackTokenWaysProps) {
54
54
  busy={props.busy}
55
55
  />
56
56
  </section>
57
- <section className="sc-pack-way" aria-label={pack.pasteTitle}>
58
- <h3 className="sc-pack-way-title">{pack.pasteTitle}</h3>
57
+ <section className="sc-sheet sc-sheet-large sc-pack-way" aria-label={pack.pasteTitle}>
58
+ <h3 className="sc-subtitle">{pack.pasteTitle}</h3>
59
59
  <PackTokenForm
60
60
  set={props.set}
61
61
  setAt={props.setAt}
@@ -583,7 +583,7 @@ export function TeamList(props: TeamListProps) {
583
583
  });
584
584
  const candidates = active.filter((person) => !team.memberIds.includes(person.id));
585
585
  return (
586
- <li key={team.id} className="sc-team-card">
586
+ <li key={team.id} className="sc-panel sc-team-card">
587
587
  <div className="sc-team-head">
588
588
  <div className="sc-team-title">
589
589
  {props.onRename === undefined ? (
@@ -604,13 +604,13 @@ export function TeamList(props: TeamListProps) {
604
604
  }}
605
605
  />
606
606
  )}
607
- <span className="sc-team-key" title={teams.keyTitle}>
607
+ <span className="sc-fine-faint" title={teams.keyTitle}>
608
608
  {team.key}
609
609
  </span>
610
610
  </div>
611
611
  <Badge kind="count">{teams.members(team.memberIds.length)}</Badge>
612
612
  </div>
613
- <div className="sc-chips sc-team-members">
613
+ <div className="sc-chips sc-divider sc-team-members">
614
614
  {members.map((member) => (
615
615
  <Chip
616
616
  key={member.id}
@@ -550,7 +550,7 @@ export function PictureOverlay(props: PictureOverlayProps) {
550
550
  onLoad={(event) => sizeOf(event.currentTarget)}
551
551
  />
552
552
  </div>
553
- <p className="sc-overlay-hint">{words.hint}</p>
553
+ <p className="sc-overlay-hint sc-fine">{words.hint}</p>
554
554
  </div>
555
555
  );
556
556
  }