@dexhq/canvas 0.14.0 → 0.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (451) hide show
  1. package/CHANGELOG.md +70 -0
  2. package/README.md +5 -3
  3. package/app/canvas/activity-parts.tsx +50 -6
  4. package/app/canvas/activity.tsx +10 -18
  5. package/app/canvas/agent-changes.ts +18 -8
  6. package/app/canvas/anchoring.ts +15 -7
  7. package/app/canvas/canvas-context.tsx +6 -2
  8. package/app/canvas/canvas-input.ts +186 -14
  9. package/app/canvas/canvas-keys.ts +9 -0
  10. package/app/canvas/canvas-model.ts +7 -44
  11. package/app/canvas/canvas-panels.ts +1 -17
  12. package/app/canvas/canvas-scene.ts +250 -27
  13. package/app/canvas/canvas-ui.ts +13 -3
  14. package/app/canvas/canvas.css +147 -29
  15. package/app/canvas/change-notice.tsx +10 -1
  16. package/app/canvas/comment-layer.tsx +2 -1
  17. package/app/canvas/comments.tsx +270 -111
  18. package/app/canvas/element-link.ts +135 -0
  19. package/app/canvas/element-picker.ts +223 -27
  20. package/app/canvas/engine/canvas-gestures.ts +72 -17
  21. package/app/canvas/engine/canvas-store.ts +17 -1
  22. package/app/canvas/engine/engine.css +6 -3
  23. package/app/canvas/export-dialog.tsx +265 -0
  24. package/app/canvas/find-bar.tsx +817 -0
  25. package/app/canvas/find-model.ts +135 -0
  26. package/app/canvas/flow-canvas.tsx +83 -16
  27. package/app/canvas/follow-pin.ts +26 -6
  28. package/app/canvas/frame-context-menu.tsx +61 -7
  29. package/app/canvas/frame-node.tsx +19 -20
  30. package/app/canvas/imported-reviews.tsx +12 -22
  31. package/app/canvas/layout.ts +68 -22
  32. package/app/canvas/linked-element.tsx +196 -0
  33. package/app/canvas/live-page.ts +156 -19
  34. package/app/canvas/mentions.tsx +209 -0
  35. package/app/canvas/page-find.ts +220 -0
  36. package/app/canvas/page-style.ts +23 -0
  37. package/app/canvas/picked-box.tsx +21 -0
  38. package/app/canvas/removed-views-panel.tsx +4 -4
  39. package/app/canvas/request-node.tsx +151 -0
  40. package/app/canvas/review-panel.tsx +8 -3
  41. package/app/canvas/section-node.tsx +6 -133
  42. package/app/canvas/spec-margin.tsx +4 -1
  43. package/app/canvas/spec-threads.ts +24 -23
  44. package/app/canvas/teammates-layer.tsx +205 -0
  45. package/app/canvas/text-layer.tsx +103 -17
  46. package/app/canvas/thread-focus.tsx +14 -12
  47. package/app/canvas/tool-cursors.ts +7 -6
  48. package/app/canvas/tool-icons.tsx +24 -56
  49. package/app/canvas/typing.ts +12 -0
  50. package/app/canvas/use-activity.ts +0 -8
  51. package/app/canvas/use-agent-changes.tsx +40 -42
  52. package/app/canvas/use-canvas-clipboard.tsx +11 -14
  53. package/app/canvas/use-canvas-editor.ts +4 -2
  54. package/app/canvas/xray.ts +3 -12
  55. package/app/export/player-model.ts +159 -0
  56. package/app/export/player.tsx +198 -0
  57. package/app/export.html +31 -0
  58. package/app/export.tsx +9 -0
  59. package/app/frame/announce-refreshes.ts +21 -0
  60. package/app/frame/start-frame.tsx +50 -0
  61. package/app/frame/view-loads.ts +161 -0
  62. package/app/frame/views.ts +13 -49
  63. package/app/frame.tsx +2 -33
  64. package/app/i18n/locales/en/messages.po +233 -14
  65. package/app/i18n/locales/en/messages.ts +1 -1
  66. package/app/i18n/locales/pseudo/messages.po +232 -13
  67. package/app/i18n/locales/pseudo/messages.ts +1 -1
  68. package/app/icons/dex-glyphs.tsx +219 -0
  69. package/app/icons/glyphs.tsx +80 -80
  70. package/app/kit/use-flow.ts +2 -1
  71. package/app/live/canvas-teammates.ts +90 -0
  72. package/app/live/studio-api.ts +30 -20
  73. package/app/main.tsx +3 -0
  74. package/app/pages/canvas.tsx +45 -14
  75. package/app/pages/commands-settings.tsx +17 -3
  76. package/app/pages/render.tsx +39 -11
  77. package/app/shell/bell.tsx +15 -5
  78. package/app/shell/feedback-form.tsx +10 -21
  79. package/app/shell/feedback-link.tsx +2 -1
  80. package/app/shell/presence.tsx +123 -26
  81. package/app/shell/scaled-frame.tsx +21 -9
  82. package/app/shell/thread-list.tsx +25 -8
  83. package/app/shell/working-on.tsx +35 -3
  84. package/app/types.ts +21 -205
  85. package/app/ui/file-drop.ts +128 -0
  86. package/app/ui/prompt-editor.tsx +39 -11
  87. package/app/ui/reference.tsx +21 -8
  88. package/app/ui/shadcn/input-group.tsx +2 -2
  89. package/bin/sudio.mjs +1 -1
  90. package/dist/cli/banner.d.mts +4 -2
  91. package/dist/cli/banner.mjs +34 -11
  92. package/dist/cli/commands/app.mjs +19 -11
  93. package/dist/cli/commands/create.d.mts +5 -5
  94. package/dist/cli/commands/create.mjs +4 -4
  95. package/dist/cli/commands/export.d.mts +40 -0
  96. package/dist/cli/commands/export.mjs +66 -0
  97. package/dist/cli/commands/hook.mjs +2 -1
  98. package/dist/cli/commands/init.d.mts +2 -2
  99. package/dist/cli/commands/upgrade.mjs +1 -1
  100. package/dist/cli/help.d.mts +1 -1
  101. package/dist/cli/help.mjs +13 -7
  102. package/dist/cli/main.d.mts +42 -5
  103. package/dist/cli/main.mjs +1 -0
  104. package/dist/config/load.mjs +14 -2
  105. package/dist/config/project-files.d.mts +11 -0
  106. package/dist/config/project-files.mjs +23 -2
  107. package/dist/config/renamed.d.mts +7 -2
  108. package/dist/config/renamed.mjs +13 -3
  109. package/dist/content/capture.d.mts +2 -2
  110. package/dist/content/capture.mjs +2 -2
  111. package/dist/content/commands.d.mts +11 -9
  112. package/dist/content/commands.mjs +22 -16
  113. package/dist/content/comments-log.mjs +2 -1
  114. package/dist/content/content.d.mts +13 -143
  115. package/dist/content/content.mjs +55 -76
  116. package/dist/content/element-words.d.mts +42 -0
  117. package/dist/content/element-words.mjs +112 -0
  118. package/dist/content/flow-specs.mjs +1 -1
  119. package/dist/content/hosted-person.d.mts +31 -0
  120. package/dist/content/hosted-person.mjs +68 -0
  121. package/dist/content/merge-rules.d.mts +5 -0
  122. package/dist/content/merge-rules.mjs +17 -1
  123. package/dist/content/prototype-summary.d.mts +3 -39
  124. package/dist/content/prototype-summary.mjs +2 -3
  125. package/dist/content/prototypes.mjs +1 -1
  126. package/dist/content/screenshot.mjs +9 -0
  127. package/dist/content/text-edit.d.mts +24 -14
  128. package/dist/content/text-edit.mjs +92 -81
  129. package/dist/content/text-replace.d.mts +30 -0
  130. package/dist/content/text-replace.mjs +285 -0
  131. package/dist/content/thread-module.d.mts +2 -4
  132. package/dist/content/thread-module.mjs +4 -5
  133. package/dist/content/threads.mjs +1 -1
  134. package/dist/paste/paste.mjs +1 -1
  135. package/dist/paths.d.mts +0 -2
  136. package/dist/paths.mjs +1 -3
  137. package/dist/server/agent-env.d.mts +5 -1
  138. package/dist/server/agent-env.mjs +7 -2
  139. package/dist/server/agent-session.d.mts +14 -1
  140. package/dist/server/agent-session.mjs +84 -19
  141. package/dist/server/agents.d.mts +10 -0
  142. package/dist/server/agents.mjs +21 -6
  143. package/dist/server/build-pictures.mjs +1 -1
  144. package/dist/server/canvas-presence.d.mts +22 -0
  145. package/dist/server/canvas-presence.mjs +160 -0
  146. package/dist/server/channel.d.mts +13 -24
  147. package/dist/server/channel.mjs +55 -37
  148. package/dist/server/claimed-presence.d.mts +3 -2
  149. package/dist/server/claimed-presence.mjs +15 -7
  150. package/dist/server/close-check.mjs +2 -2
  151. package/dist/server/command-settings.mjs +1 -1
  152. package/dist/server/comments/actions.d.mts +145 -0
  153. package/dist/server/comments/actions.mjs +146 -0
  154. package/dist/server/comments/routes.d.mts +25 -0
  155. package/dist/server/comments/routes.mjs +67 -0
  156. package/dist/server/comments/tools.d.mts +6 -0
  157. package/dist/server/comments/tools.mjs +154 -0
  158. package/dist/server/dev-server.mjs +59 -23
  159. package/dist/server/export/build.d.mts +15 -0
  160. package/dist/server/export/build.mjs +220 -0
  161. package/dist/server/export/page.d.mts +25 -0
  162. package/dist/server/export/page.mjs +40 -0
  163. package/dist/server/export/plugin.d.mts +31 -0
  164. package/dist/server/export/plugin.mjs +69 -0
  165. package/dist/server/export/run.d.mts +9 -0
  166. package/dist/server/export/run.mjs +61 -0
  167. package/dist/server/export/save.d.mts +7 -0
  168. package/dist/server/export/save.mjs +29 -0
  169. package/dist/server/file-lock.d.mts +2 -2
  170. package/dist/server/file-lock.mjs +130 -36
  171. package/dist/server/hosted.d.mts +8 -0
  172. package/dist/server/hosted.mjs +78 -0
  173. package/dist/server/live-mirror.mjs +66 -10
  174. package/dist/server/live.mjs +28 -1
  175. package/dist/server/mcp.d.mts +0 -2
  176. package/dist/server/mcp.mjs +9 -8
  177. package/dist/server/me.d.mts +3 -1
  178. package/dist/server/me.mjs +8 -2
  179. package/dist/server/notices.d.mts +1 -1
  180. package/dist/server/notices.mjs +1 -1
  181. package/dist/server/open-page.d.mts +22 -0
  182. package/dist/server/open-page.mjs +20 -2
  183. package/dist/server/outcome.d.mts +22 -0
  184. package/dist/server/outcome.mjs +8 -0
  185. package/dist/server/own-copies.mjs +1 -1
  186. package/dist/server/people.d.mts +8 -3
  187. package/dist/server/people.mjs +6 -2
  188. package/dist/server/pictures.d.mts +1 -1
  189. package/dist/server/pictures.mjs +2 -2
  190. package/dist/server/port.d.mts +12 -0
  191. package/dist/server/port.mjs +66 -14
  192. package/dist/server/prebundle.d.mts +32 -0
  193. package/dist/server/prebundle.mjs +115 -0
  194. package/dist/server/presence.d.mts +4 -1
  195. package/dist/server/presence.mjs +2 -2
  196. package/dist/server/problems.d.mts +8 -0
  197. package/dist/server/problems.mjs +13 -0
  198. package/dist/server/requests.d.mts +5 -1
  199. package/dist/server/requests.mjs +76 -78
  200. package/dist/server/source-stamp.d.mts +4 -3
  201. package/dist/server/source-stamp.mjs +60 -31
  202. package/dist/server/state.d.mts +19 -10
  203. package/dist/server/state.mjs +27 -18
  204. package/dist/server/studio-for.d.mts +5 -0
  205. package/dist/server/studio-for.mjs +17 -3
  206. package/dist/server/sync-install.d.mts +8 -12
  207. package/dist/server/sync-install.mjs +12 -30
  208. package/dist/server/thread-source.d.mts +8 -0
  209. package/dist/server/thread-source.mjs +25 -6
  210. package/dist/server/tools/describe.d.mts +1 -1
  211. package/dist/server/tools/describe.mjs +1 -1
  212. package/dist/server/tools/export.d.mts +5 -0
  213. package/dist/server/tools/export.mjs +35 -0
  214. package/dist/server/tools/feedback.d.mts +1 -1
  215. package/dist/server/tools/place-frame.mjs +16 -16
  216. package/dist/server/tools/reading.mjs +13 -4
  217. package/dist/server/tools/show.d.mts +1 -1
  218. package/dist/server/tools/snapshot.d.mts +1 -1
  219. package/dist/server/tools/thread-list.mjs +2 -2
  220. package/dist/server/tools/watch.mjs +5 -3
  221. package/dist/server/vite.d.mts +9 -4
  222. package/dist/server/vite.mjs +65 -63
  223. package/dist/server/web-app.mjs +4 -7
  224. package/dist/server/welcome.mjs +2 -1
  225. package/dist/server/work-groups.mjs +1 -1
  226. package/dist/setup/apply.d.mts +4 -0
  227. package/dist/setup/apply.mjs +5 -4
  228. package/dist/setup/create.d.mts +4 -2
  229. package/dist/setup/create.mjs +72 -22
  230. package/dist/setup/design-system-checks.mjs +3 -17
  231. package/dist/setup/desktop-app-script.mjs +4 -3
  232. package/dist/setup/desktop-app-start.d.mts +8 -2
  233. package/dist/setup/desktop-app-start.mjs +64 -29
  234. package/dist/setup/desktop-app.d.mts +8 -0
  235. package/dist/setup/desktop-app.mjs +19 -3
  236. package/dist/setup/detect/workspace.d.mts +10 -10
  237. package/dist/setup/detect/workspace.mjs +10 -12
  238. package/dist/setup/detect.d.mts +0 -2
  239. package/dist/setup/detect.mjs +1 -3
  240. package/dist/setup/doctor.d.mts +4 -1
  241. package/dist/setup/doctor.mjs +8 -6
  242. package/dist/setup/migrate/dex-folder.d.mts +61 -0
  243. package/dist/setup/migrate/dex-folder.mjs +544 -0
  244. package/dist/setup/migrate/files-folder.mjs +1 -1
  245. package/dist/setup/migrate/guides.mjs +1 -1
  246. package/dist/setup/migrate/migrations.mjs +4 -0
  247. package/dist/setup/migrate/row-titles.mjs +1 -1
  248. package/dist/setup/migrate/setup-files.d.mts +5 -0
  249. package/dist/setup/migrate/setup-files.mjs +115 -0
  250. package/dist/setup/migrate/studio-state.d.mts +2 -2
  251. package/dist/setup/migrate/studio-state.mjs +4 -4
  252. package/dist/setup/placement.d.mts +1 -1
  253. package/dist/setup/placement.mjs +5 -4
  254. package/dist/setup/plan.d.mts +5 -5
  255. package/dist/setup/plan.mjs +8 -12
  256. package/dist/setup/project.d.mts +6 -1
  257. package/dist/setup/project.mjs +10 -10
  258. package/dist/setup/prompts.d.mts +2 -1
  259. package/dist/setup/prompts.mjs +4 -3
  260. package/dist/setup/questions.mjs +3 -2
  261. package/dist/setup/starters.d.mts +3 -1
  262. package/dist/setup/starters.mjs +9 -3
  263. package/dist/setup/write.d.mts +15 -3
  264. package/dist/setup/write.mjs +23 -3
  265. package/dist/shared/annotations-core.mjs +1 -1
  266. package/dist/shared/canvas-core.d.mts +22 -7
  267. package/dist/shared/canvas-core.mjs +39 -11
  268. package/dist/shared/canvas-file.d.mts +201 -0
  269. package/dist/shared/canvas-file.mjs +1 -0
  270. package/dist/shared/comments/routes.d.mts +55 -0
  271. package/dist/shared/comments/routes.mjs +39 -0
  272. package/dist/shared/export-core.d.mts +62 -0
  273. package/dist/shared/export-core.mjs +101 -0
  274. package/dist/shared/feedback.d.mts +8 -0
  275. package/dist/shared/feedback.mjs +10 -2
  276. package/dist/shared/live-core.d.mts +2 -0
  277. package/dist/shared/live-core.mjs +6 -1
  278. package/dist/shared/live-presence.d.mts +57 -2
  279. package/dist/shared/live-presence.mjs +90 -4
  280. package/dist/shared/page-messages.d.mts +14 -1
  281. package/dist/shared/page-messages.mjs +30 -3
  282. package/dist/shared/page-review.d.mts +2 -11
  283. package/dist/shared/page-review.mjs +4 -13
  284. package/dist/shared/people-core.d.mts +28 -0
  285. package/dist/shared/people-core.mjs +27 -1
  286. package/dist/shared/presence-core.d.mts +13 -0
  287. package/dist/shared/presence-core.mjs +11 -2
  288. package/dist/shared/references-core.d.mts +4 -0
  289. package/dist/shared/references-core.mjs +12 -4
  290. package/dist/shared/review-file.d.mts +5 -0
  291. package/dist/shared/review-file.mjs +23 -13
  292. package/dist/shared/server-page.mjs +1 -1
  293. package/dist/shared/signup.d.mts +2 -5
  294. package/dist/shared/signup.mjs +2 -35
  295. package/dist/shared/studio-events.d.mts +0 -6
  296. package/dist/shared/studio-events.mjs +1 -5
  297. package/dist/shared/studio-files.d.mts +21 -0
  298. package/dist/shared/studio-files.mjs +16 -2
  299. package/dist/shared/studio-routes.d.mts +29 -63
  300. package/dist/shared/studio-routes.mjs +1 -69
  301. package/dist/shared/threads-core.d.mts +29 -6
  302. package/dist/shared/threads-core.mjs +68 -13
  303. package/extension/dist/feedback.js +104 -284
  304. package/extension/dist/manifest.json +1 -1
  305. package/extension/dist/picker.js +104 -284
  306. package/package.json +2 -2
  307. package/src/cli/banner.ts +45 -11
  308. package/src/cli/commands/app.ts +23 -8
  309. package/src/cli/commands/create.ts +4 -4
  310. package/src/cli/commands/export.ts +78 -0
  311. package/src/cli/commands/hook.ts +4 -1
  312. package/src/cli/commands/upgrade.ts +1 -1
  313. package/src/cli/help.ts +13 -7
  314. package/src/cli/main.ts +1 -0
  315. package/src/config/load.ts +26 -2
  316. package/src/config/project-files.ts +36 -6
  317. package/src/config/renamed.ts +19 -4
  318. package/src/content/capture.ts +6 -12
  319. package/src/content/commands.ts +30 -18
  320. package/src/content/comments-log.ts +4 -1
  321. package/src/content/content.ts +71 -257
  322. package/src/content/element-words.ts +175 -0
  323. package/src/content/flow-specs.ts +2 -1
  324. package/src/content/hosted-person.ts +107 -0
  325. package/src/content/merge-rules.ts +29 -0
  326. package/src/content/prototype-summary.ts +4 -44
  327. package/src/content/review-pages.ts +2 -1
  328. package/src/content/screenshot.ts +14 -0
  329. package/src/content/text-edit.ts +172 -105
  330. package/src/content/text-replace.ts +420 -0
  331. package/src/content/thread-module.ts +2 -4
  332. package/src/content/trash.ts +1 -1
  333. package/src/paths.ts +0 -8
  334. package/src/server/agent-env.ts +12 -2
  335. package/src/server/agent-session.ts +124 -34
  336. package/src/server/agents.ts +48 -17
  337. package/src/server/canvas-presence.ts +237 -0
  338. package/src/server/channel.ts +95 -53
  339. package/src/server/claimed-presence.ts +26 -10
  340. package/src/server/command-settings.ts +1 -1
  341. package/src/server/comments/actions.ts +333 -0
  342. package/src/server/comments/routes.ts +131 -0
  343. package/src/server/comments/tools.ts +317 -0
  344. package/src/server/dev-server.ts +94 -33
  345. package/src/server/export/build.ts +310 -0
  346. package/src/server/export/page.ts +85 -0
  347. package/src/server/export/plugin.ts +138 -0
  348. package/src/server/export/run.ts +79 -0
  349. package/src/server/export/save.ts +38 -0
  350. package/src/server/file-lock.ts +205 -54
  351. package/src/server/hosted.ts +113 -0
  352. package/src/server/live-mirror.ts +93 -8
  353. package/src/server/live.ts +46 -1
  354. package/src/server/machine-update.ts +3 -3
  355. package/src/server/mcp.ts +15 -14
  356. package/src/server/me.ts +12 -6
  357. package/src/server/notices.ts +2 -2
  358. package/src/server/open-page.ts +54 -4
  359. package/src/server/outcome.ts +26 -0
  360. package/src/server/people.ts +13 -3
  361. package/src/server/pictures.ts +2 -2
  362. package/src/server/port.ts +94 -20
  363. package/src/server/prebundle.ts +230 -0
  364. package/src/server/presence.ts +12 -4
  365. package/src/server/problems.ts +11 -0
  366. package/src/server/requests.ts +115 -110
  367. package/src/server/roster.ts +1 -1
  368. package/src/server/saved.ts +1 -1
  369. package/src/server/source-stamp.ts +118 -37
  370. package/src/server/state.ts +53 -31
  371. package/src/server/studio-for.ts +26 -2
  372. package/src/server/sync-install.ts +35 -26
  373. package/src/server/thread-place.ts +2 -4
  374. package/src/server/thread-source.ts +35 -3
  375. package/src/server/tools/export.ts +56 -0
  376. package/src/server/tools/place-frame.ts +23 -15
  377. package/src/server/tools/reading.ts +16 -3
  378. package/src/server/tools/thread-list.ts +1 -1
  379. package/src/server/tools/watch.ts +7 -7
  380. package/src/server/updates.ts +2 -2
  381. package/src/server/vite.ts +106 -110
  382. package/src/server/web-app.ts +11 -9
  383. package/src/server/welcome.ts +3 -1
  384. package/src/setup/apply.ts +8 -5
  385. package/src/setup/create.ts +101 -27
  386. package/src/setup/design-system-checks.ts +8 -21
  387. package/src/setup/desktop-app-script.ts +4 -3
  388. package/src/setup/desktop-app-start.ts +94 -26
  389. package/src/setup/desktop-app.ts +23 -2
  390. package/src/setup/detect/workspace.ts +20 -21
  391. package/src/setup/detect.ts +0 -4
  392. package/src/setup/doctor.ts +13 -6
  393. package/src/setup/migrate/dex-folder.ts +842 -0
  394. package/src/setup/migrate/files-folder.ts +1 -1
  395. package/src/setup/migrate/guides.ts +3 -1
  396. package/src/setup/migrate/migrations.ts +8 -2
  397. package/src/setup/migrate/setup-files.ts +198 -0
  398. package/src/setup/migrate/studio-state.ts +12 -10
  399. package/src/setup/own-app.ts +1 -1
  400. package/src/setup/placement.ts +7 -6
  401. package/src/setup/plan.ts +13 -18
  402. package/src/setup/project.ts +11 -10
  403. package/src/setup/prompts.ts +5 -4
  404. package/src/setup/questions.ts +6 -3
  405. package/src/setup/starters.ts +11 -4
  406. package/src/setup/write.ts +34 -3
  407. package/src/shared/canvas-core.ts +48 -9
  408. package/src/shared/canvas-file.ts +205 -0
  409. package/src/shared/comments/routes.ts +81 -0
  410. package/src/shared/export-core.ts +198 -0
  411. package/src/shared/feedback.ts +14 -4
  412. package/src/shared/live-core.ts +8 -0
  413. package/src/shared/live-presence.ts +171 -2
  414. package/src/shared/page-messages.ts +38 -2
  415. package/src/shared/page-review.ts +11 -16
  416. package/src/shared/people-core.ts +44 -0
  417. package/src/shared/presence-core.ts +18 -2
  418. package/src/shared/references-core.ts +22 -3
  419. package/src/shared/review-file.ts +28 -12
  420. package/src/shared/server-page.ts +2 -1
  421. package/src/shared/signup.ts +4 -28
  422. package/src/shared/studio-events.ts +0 -13
  423. package/src/shared/studio-files.ts +29 -1
  424. package/src/shared/studio-routes.ts +32 -65
  425. package/src/shared/threads-core.ts +134 -12
  426. package/templates/methods/explore.md +1 -1
  427. package/templates/methods/handoff.md +1 -1
  428. package/templates/methods/review.md +2 -1
  429. package/templates/rules/canvas-frames.md +6 -3
  430. package/templates/rules/commands.md +1 -0
  431. package/templates/rules/prototypes.md +1 -1
  432. package/templates/rules/studio.md +17 -11
  433. package/templates/skills/comprehend/SKILL.md +56 -0
  434. package/templates/skills/distill/SKILL.md +172 -0
  435. package/templates/skills/export-prototype/SKILL.md +35 -0
  436. package/templates/skills/riff/SKILL.md +21 -0
  437. package/templates/skills/riff-deep/SKILL.md +40 -0
  438. package/templates/skills/riff-max/SKILL.md +46 -0
  439. package/templates/skills/riff-state/SKILL.md +45 -0
  440. package/templates/skills/riff-up/SKILL.md +38 -0
  441. package/templates/skills/riff-wide/SKILL.md +40 -0
  442. package/templates/starters/standalone/README.md +1 -1
  443. package/templates/starters/turborepo/README.md +2 -2
  444. package/templates/starters/turborepo/apps/web/src/app.tsx +2 -2
  445. package/templates/starters/vite/README.md +1 -1
  446. package/dist/server/tools/close-reply.d.mts +0 -6
  447. package/dist/server/tools/close-reply.mjs +0 -138
  448. package/dist/server/tools/comment.d.mts +0 -6
  449. package/dist/server/tools/comment.mjs +0 -49
  450. package/src/server/tools/close-reply.ts +0 -271
  451. package/src/server/tools/comment.ts +0 -96
@@ -30,7 +30,9 @@ import { cn } from "cn";
30
30
  import {
31
31
  type ReactNode,
32
32
  type RefObject,
33
+ useCallback,
33
34
  useEffect,
35
+ useLayoutEffect,
34
36
  useMemo,
35
37
  useRef,
36
38
  useState,
@@ -74,13 +76,14 @@ import {
74
76
  } from "../shell/thread-list";
75
77
  import { shortTimeAgo } from "../shell/time-ago";
76
78
  import type { Thread, ThreadAudience, ThreadTarget } from "../types";
77
- import { detailsOf, PromptEditor } from "../ui/prompt-editor";
79
+ import { PromptEditor } from "../ui/prompt-editor";
78
80
  import { ReferenceDetails, ReferenceText } from "../ui/reference";
79
81
  import {
80
82
  type ScreenPoint,
81
83
  type ThreadsApi,
82
84
  useCanvasIfAny,
83
85
  } from "./canvas-context";
86
+ import { threadItemId } from "./canvas-scene";
84
87
  import {
85
88
  commandTrigger,
86
89
  QuickCommands,
@@ -89,6 +92,16 @@ import {
89
92
  } from "./command-menu";
90
93
  import { acceptRename } from "./flow-renames";
91
94
  import { useFollowPin } from "./follow-pin";
95
+ import {
96
+ MessageWords,
97
+ mentionsMe,
98
+ mentionTrigger,
99
+ POSTED_TRIGGERS,
100
+ useFrames,
101
+ useMentionable,
102
+ usePeople,
103
+ usePostedDetails,
104
+ } from "./mentions";
92
105
  import { overPin, QUICK_BAR_GAP } from "./quick-bar";
93
106
  import {
94
107
  ReviewMarker,
@@ -113,6 +126,19 @@ const CARD_MARGIN = 16;
113
126
  const CARD_MAX_HEIGHT = 480;
114
127
  /** Between a pin and its card. */
115
128
  const PIN_GAP = 8;
129
+ /**
130
+ * How long a card opened at its pin waits for it, unseen: while the canvas
131
+ * moves to it, and its frame's page loads and is measured. After, it shows
132
+ * by its frame until the pin comes.
133
+ */
134
+ export const PIN_WAIT_MS = 1500;
135
+ const CARD_OFFSET = 360;
136
+
137
+ /** Where a card with no pin to hang from opens: top right. */
138
+ export const cardPoint = (): ScreenPoint => ({
139
+ left: window.innerWidth - CARD_OFFSET - 32,
140
+ top: 96,
141
+ });
116
142
 
117
143
  /** A pin's place on screen, as getBoundingClientRect gives it. */
118
144
  interface PinRect {
@@ -213,48 +239,94 @@ const useDismiss = (
213
239
  };
214
240
 
215
241
  /** Where a card goes beside its pin: on the right, else the left, on screen. */
216
- const beside = (pin: DOMRect, card: HTMLElement): ScreenPoint =>
242
+ const beside = (pin: PinRect, card: HTMLElement): ScreenPoint =>
217
243
  besidePin(
218
244
  pin,
219
245
  { height: card.offsetHeight, width: CARD_WIDTH },
220
246
  { height: window.innerHeight, width: window.innerWidth }
221
247
  );
222
248
 
249
+ /**
250
+ * Where a card goes on its frame when its pin isn't drawn (its element is
251
+ * gone): beside the frame's top right corner, where a comment on the whole
252
+ * frame has its pin.
253
+ */
254
+ const besideCorner = (frame: DOMRect, card: HTMLElement): ScreenPoint =>
255
+ beside(
256
+ {
257
+ bottom: frame.top,
258
+ left: frame.right,
259
+ right: frame.right,
260
+ top: frame.top,
261
+ },
262
+ card
263
+ );
264
+
223
265
  /**
224
266
  * A card beside its pin, if it has one there, else at a point on screen kept
225
- * inside the window. Escape closes it.
267
+ * inside the window. With no point of its own, it waits unseen for its pin
268
+ * (PIN_WAIT_MS), once: open it again with a new key to wait again. If none
269
+ * comes, it shows by its frame, else top right. Escape closes it.
226
270
  */
227
271
  const FloatingCard = ({
228
272
  anchor,
229
273
  at,
230
274
  children,
275
+ frame,
231
276
  label,
232
277
  onClose,
233
278
  }: {
234
279
  /** The pin it hangs from, as a selector: it follows it as the canvas moves. */
235
280
  anchor?: string;
236
- at: ScreenPoint;
281
+ /** Where it opens; left out, at its pin. */
282
+ at?: ScreenPoint;
237
283
  children: ReactNode;
284
+ /** The frame its pin is on, as a selector: where it shows if the pin isn't. */
285
+ frame?: string;
238
286
  label: string;
239
287
  onClose: () => void;
240
288
  }) => {
241
289
  const ref = useRef<HTMLElement>(null);
290
+ const opensAtPin = at === undefined;
291
+ // Its pin drawn and the card put beside it; or the wait for it over.
292
+ const [pinSeen, setPinSeen] = useState(false);
293
+ const [waitOver, setWaitOver] = useState(false);
294
+ const seePin = useCallback(() => setPinSeen(true), []);
242
295
  useDismiss(ref, onClose);
243
- useFollowPin(ref, anchor, beside);
296
+ useFollowPin(ref, anchor, beside, {
297
+ onFound: seePin,
298
+ orElse:
299
+ opensAtPin && waitOver && !pinSeen && frame
300
+ ? { anchor: frame, place: besideCorner }
301
+ : undefined,
302
+ });
303
+ useEffect(() => {
304
+ if (!opensAtPin) {
305
+ return;
306
+ }
307
+ const timer = window.setTimeout(() => setWaitOver(true), PIN_WAIT_MS);
308
+ return () => window.clearTimeout(timer);
309
+ }, [opensAtPin]);
310
+ const start = at ?? cardPoint();
244
311
  const left = Math.max(
245
312
  CARD_MARGIN,
246
- Math.min(at.left, window.innerWidth - CARD_WIDTH - CARD_MARGIN)
313
+ Math.min(start.left, window.innerWidth - CARD_WIDTH - CARD_MARGIN)
247
314
  );
248
315
  const top = Math.max(
249
316
  CARD_MARGIN,
250
- Math.min(at.top, window.innerHeight - CARD_MAX_HEIGHT - CARD_MARGIN)
317
+ Math.min(start.top, window.innerHeight - CARD_MAX_HEIGHT - CARD_MARGIN)
251
318
  );
252
319
  return (
253
320
  <section
254
321
  aria-label={label}
255
322
  className="studio-overlay fixed z-50 flex max-h-[30rem] flex-col overflow-hidden"
256
323
  ref={ref}
257
- style={{ left, top, width: CARD_WIDTH }}
324
+ style={{
325
+ left,
326
+ top,
327
+ width: CARD_WIDTH,
328
+ visibility: opensAtPin && !(pinSeen || waitOver) ? "hidden" : undefined,
329
+ }}
258
330
  >
259
331
  {children}
260
332
  </section>
@@ -368,10 +440,23 @@ export const MessageInput = ({
368
440
  }) => {
369
441
  const [body, setBody] = useState(initial);
370
442
  const { t } = useLingui();
371
- const triggers = useMemo(
372
- () => (commands.length > 0 ? [commandTrigger(commands, t`Commands`)] : []),
373
- [commands, t]
374
- );
443
+ const people = usePeople({ ask: true });
444
+ const frames = useFrames();
445
+ const triggers = useMemo(() => {
446
+ // The "@" menu is named for what it lists.
447
+ let mentions = t`People and frames`;
448
+ if (frames.length === 0) {
449
+ mentions = t`People`;
450
+ } else if (people.length === 0) {
451
+ mentions = t`Frames`;
452
+ }
453
+ return [
454
+ ...(commands.length > 0 ? [commandTrigger(commands, t`Commands`)] : []),
455
+ ...(people.length > 0 || frames.length > 0
456
+ ? [mentionTrigger(people, frames, mentions)]
457
+ : []),
458
+ ];
459
+ }, [commands, frames, people, t]);
375
460
  const sendBody = useStudioAction(
376
461
  async (text: string) => {
377
462
  // False keeps the words: the post was held back, not made.
@@ -508,6 +593,31 @@ export const Composer = ({
508
593
  );
509
594
  };
510
595
 
596
+ /** A suggestion's Accept and Reject, small and side by side. */
597
+ const AcceptOrReject = ({
598
+ accepting,
599
+ onAccept,
600
+ onReject,
601
+ }: {
602
+ accepting?: boolean;
603
+ onAccept: () => void;
604
+ onReject: () => void;
605
+ }) => {
606
+ const { t } = useLingui();
607
+ return (
608
+ <div className="mt-2 flex gap-1.5">
609
+ <Button disabled={accepting} onClick={onAccept} size="xs">
610
+ <Icon data-icon="inline-start" name="Check" />
611
+ {t`Accept`}
612
+ </Button>
613
+ <Button onClick={onReject} size="xs" variant="outline">
614
+ <Icon data-icon="inline-start" name="X" />
615
+ {t`Reject`}
616
+ </Button>
617
+ </div>
618
+ );
619
+ };
620
+
511
621
  /**
512
622
  * A suggestion's change, as its entry's own words: the old struck, the new
513
623
  * after them; then Accept, which changes the words in the spec, and Reject,
@@ -520,7 +630,6 @@ const SuggestionChange = ({
520
630
  thread: Thread;
521
631
  threads: ThreadsApi;
522
632
  }) => {
523
- const { t } = useLingui();
524
633
  const me = useMe();
525
634
  const accept = useStudioAction(() => threads.accept(thread.id), {
526
635
  fallback: msg`Not accepted. Try again.`,
@@ -543,24 +652,11 @@ const SuggestionChange = ({
543
652
  {!CAN_WRITE ||
544
653
  isClosed(thread) ||
545
654
  !mayEditSpec(target.spec, me.contributor?.slug) ? null : (
546
- <div className="mt-2 flex gap-1.5">
547
- <Button
548
- disabled={accept.pending}
549
- onClick={() => accept.run()}
550
- size="xs"
551
- >
552
- <Icon data-icon="inline-start" name="Check" />
553
- {t`Accept`}
554
- </Button>
555
- <Button
556
- onClick={() => threads.send(thread.id, { status: "dismissed" })}
557
- size="xs"
558
- variant="outline"
559
- >
560
- <Icon data-icon="inline-start" name="X" />
561
- {t`Reject`}
562
- </Button>
563
- </div>
655
+ <AcceptOrReject
656
+ accepting={accept.pending}
657
+ onAccept={() => accept.run()}
658
+ onReject={() => threads.send(thread.id, { status: "dismissed" })}
659
+ />
564
660
  )}
565
661
  {problem ? (
566
662
  <p className="studio-small mt-1 text-destructive" role="alert">
@@ -582,7 +678,6 @@ const RenameChange = ({
582
678
  thread: Thread;
583
679
  threads: ThreadsApi;
584
680
  }) => {
585
- const { t } = useLingui();
586
681
  const canvas = useCanvasIfAny();
587
682
  const { target } = thread;
588
683
  if (!isRenameSuggestion(target)) {
@@ -603,25 +698,12 @@ const RenameChange = ({
603
698
  <span className="underline underline-offset-4">{target.rename}</span>
604
699
  </p>
605
700
  {CAN_WRITE && !isClosed(thread) && theirs ? (
606
- <div className="mt-2 flex gap-1.5">
607
- <Button
608
- onClick={() =>
609
- canvas && acceptRename(threads, canvas.editor, thread)
610
- }
611
- size="xs"
612
- >
613
- <Icon data-icon="inline-start" name="Check" />
614
- {t`Accept`}
615
- </Button>
616
- <Button
617
- onClick={() => threads.send(thread.id, { status: "dismissed" })}
618
- size="xs"
619
- variant="outline"
620
- >
621
- <Icon data-icon="inline-start" name="X" />
622
- {t`Reject`}
623
- </Button>
624
- </div>
701
+ <AcceptOrReject
702
+ onAccept={() =>
703
+ canvas && acceptRename(threads, canvas.editor, thread)
704
+ }
705
+ onReject={() => threads.send(thread.id, { status: "dismissed" })}
706
+ />
625
707
  ) : null}
626
708
  </>
627
709
  );
@@ -724,7 +806,7 @@ export const Reactions = ({
724
806
  );
725
807
  };
726
808
 
727
- /** A message's words, with the commands it names as chips. */
809
+ /** A message's words, with the commands and people it names as chips. */
728
810
  const MessageText = ({ body }: { body: string }) =>
729
811
  body ? (
730
812
  <p className="whitespace-pre-wrap">
@@ -732,9 +814,6 @@ const MessageText = ({ body }: { body: string }) =>
732
814
  </p>
733
815
  ) : null;
734
816
 
735
- /** The triggers a posted message's chips can start with: commands'. */
736
- const POSTED_TRIGGERS = ["/"];
737
-
738
817
  /** One entry in a thread: who, when, what they said, and anything under it. */
739
818
  const Entry = ({
740
819
  agent,
@@ -825,7 +904,7 @@ const ClosingLine = ({ body }: { body: string }) => {
825
904
  <p
826
905
  className={cn("whitespace-pre-wrap", long && !whole && "line-clamp-4")}
827
906
  >
828
- {body}
907
+ <MessageWords text={body} />
829
908
  </p>
830
909
  {long ? (
831
910
  <Button
@@ -1174,15 +1253,12 @@ export const ThreadBody = ({
1174
1253
  threads: ThreadsApi;
1175
1254
  }) => {
1176
1255
  const { i18n, t } = useLingui();
1177
- // Every command: the details of those its messages name (one may have
1178
- // left the / menu since), and, in work for the agent, what a reply or an
1179
- // edit can run as well.
1256
+ // Every command and person: the details of those its messages name (a
1257
+ // command may have left the / menu since), and, in work for the agent,
1258
+ // what a reply or an edit can run as well.
1180
1259
  const [answer] = useCommands(!GUEST_REVIEW);
1181
1260
  const known = answer?.commands ?? NO_COMMANDS;
1182
- const describe = useMemo(
1183
- () => detailsOf([commandTrigger(known, "")]),
1184
- [known]
1185
- );
1261
+ const describe = usePostedDetails();
1186
1262
  const commands = audienceOf(thread) === "agent" ? known : NO_COMMANDS;
1187
1263
  const closed = isClosed(thread);
1188
1264
  const state = threadState(thread);
@@ -1367,16 +1443,20 @@ const ThreadCard = ({
1367
1443
  thread,
1368
1444
  threads,
1369
1445
  }: {
1370
- at: ScreenPoint;
1446
+ at?: ScreenPoint;
1371
1447
  onClose: () => void;
1372
1448
  thread: Thread;
1373
1449
  threads: ThreadsApi;
1374
1450
  }) => {
1375
1451
  const { t } = useLingui();
1452
+ // The frame it is on, wherever that has moved: on the canvas, not in Play.
1453
+ const canvas = useCanvasIfAny()?.editor.canvas;
1454
+ const frame = canvas ? threadItemId(thread, canvas) : undefined;
1376
1455
  return (
1377
1456
  <FloatingCard
1378
1457
  anchor={threadAnchor(thread.id)}
1379
1458
  at={at}
1459
+ frame={frame ? `[data-frame-key="${CSS.escape(frame)}"]` : undefined}
1380
1460
  label={t`Comment`}
1381
1461
  onClose={onClose}
1382
1462
  >
@@ -1402,13 +1482,18 @@ export const DEFAULT_FILTER: CommentFilter = {
1402
1482
 
1403
1483
  /**
1404
1484
  * How comments are shown, shared by the Comments panel's header, its list
1405
- * and the pins: whether they are hidden (⇧C, or the panel's ⋯ menu), the
1406
- * filter, and what is searched for. It lasts until the page reloads; the
1485
+ * and the pins: whether their pins are hidden (⇧C, or the panel's ⋯ menu),
1486
+ * the filter, and what is searched for. It lasts until the page reloads; the
1407
1487
  * search, until the panel closes.
1408
1488
  */
1409
1489
  export interface CommentsView {
1410
1490
  filter: CommentFilter;
1411
1491
  hidden: boolean;
1492
+ /**
1493
+ * While comments are hidden, the thread opened since, from the list or the
1494
+ * heads-up: its card and its pin show.
1495
+ */
1496
+ opened?: string;
1412
1497
  /** The panel's page: the team's comments, or reviewers' reviews. */
1413
1498
  page: "comments" | "reviews";
1414
1499
  query: string;
@@ -1425,7 +1510,8 @@ const FIRST_VIEW: CommentsView = {
1425
1510
  hidden: false,
1426
1511
  page: "comments",
1427
1512
  query: "",
1428
- reviewsResolved: false,
1513
+ // As the team's: a review stays in sight once its comments are closed.
1514
+ reviewsResolved: true,
1429
1515
  reviewsShowing: false,
1430
1516
  };
1431
1517
 
@@ -1446,9 +1532,15 @@ export const resetCommentsView = () => updateCommentsView(FIRST_VIEW);
1446
1532
  export const setCommentsAudience = (audience: CommentFilter["audience"]) =>
1447
1533
  updateCommentsView({ filter: { ...view.filter, audience } });
1448
1534
 
1535
+ /** Whether a thread is out of sight: comments are hidden, and it wasn't opened since. */
1536
+ export const isHiddenThread = (
1537
+ { hidden, opened }: Pick<CommentsView, "hidden" | "opened">,
1538
+ id: string
1539
+ ) => hidden && opened !== id;
1540
+
1449
1541
  export const setCommentsHidden = (hidden: boolean) => {
1450
1542
  if (hidden !== view.hidden) {
1451
- updateCommentsView({ hidden });
1543
+ updateCommentsView({ hidden, opened: undefined });
1452
1544
  }
1453
1545
  };
1454
1546
 
@@ -1468,6 +1560,13 @@ export const useCommentsView = () =>
1468
1560
  /** Whether comments are hidden, as ⇧C or the ⋯ menu last left them. */
1469
1561
  export const useCommentsHidden = () => useCommentsView().hidden;
1470
1562
 
1563
+ /**
1564
+ * Whether a thread's marks on the canvas are out of sight (isHiddenThread):
1565
+ * its pin, and the tick where an agent's change for it landed.
1566
+ */
1567
+ export const useIsHiddenThread = (id: string) =>
1568
+ isHiddenThread(useCommentsView(), id);
1569
+
1471
1570
  /**
1472
1571
  * Comments hide while `active` is true; ⇧C still shows them. After, they
1473
1572
  * are as they were before.
@@ -1477,9 +1576,10 @@ export const useHideCommentsWhile = (active: boolean) => {
1477
1576
  if (!active) {
1478
1577
  return;
1479
1578
  }
1480
- const before = view.hidden;
1481
- setCommentsHidden(true);
1482
- return () => setCommentsHidden(before);
1579
+ // A thread opened while they were hidden hides too, and comes back.
1580
+ const before = { hidden: view.hidden, opened: view.opened };
1581
+ updateCommentsView({ hidden: true, opened: undefined });
1582
+ return () => updateCommentsView(before);
1483
1583
  }, [active]);
1484
1584
  };
1485
1585
 
@@ -1592,9 +1692,12 @@ export const usePinFilter = (showResolved: boolean, activeThread?: string) => {
1592
1692
  } = useCommentsView();
1593
1693
  const canvas = useCanvasIfAny();
1594
1694
  const isTeamComment = useIsTeamComment(canvas?.prototype.slug ?? "");
1695
+ const me = useMentionable();
1595
1696
  const resolvedShown = showResolved && status !== "open";
1596
- // On a deployed studio, "You" leaves only a guest's own pins.
1697
+ // On a deployed studio, "You" leaves only a guest's own pins; Mentions,
1698
+ // only those of threads that mention you.
1597
1699
  const onlyYours = audience === "yours";
1700
+ const onlyMentions = audience === "mentions";
1598
1701
  // Reviewers' imported comments stay within Reviews: on the canvas while
1599
1702
  // it shows (one review's, when one is picked), and never beside the team's.
1600
1703
  if (reviewsShowing) {
@@ -1606,7 +1709,8 @@ export const usePinFilter = (showResolved: boolean, activeThread?: string) => {
1606
1709
  thread.id === activeThread ||
1607
1710
  (isTeamComment(thread) &&
1608
1711
  (resolvedShown || !isClosed(thread)) &&
1609
- !(onlyYours && !isGuestThread(thread)));
1712
+ !(onlyYours && !isGuestThread(thread)) &&
1713
+ !(onlyMentions && !mentionsMe(me)(thread)));
1610
1714
  };
1611
1715
 
1612
1716
  /**
@@ -1640,7 +1744,10 @@ export const DraftPin = () => {
1640
1744
  );
1641
1745
  };
1642
1746
 
1643
- /** A thread's pin on the canvas: click it to open the thread. None while comments are hidden. */
1747
+ /**
1748
+ * A thread's pin on the canvas: click it to open the thread. None while
1749
+ * comments are hidden, but the open thread's when it was opened since.
1750
+ */
1644
1751
  export const Pin = ({
1645
1752
  folded = false,
1646
1753
  onOpen,
@@ -1652,8 +1759,8 @@ export const Pin = ({
1652
1759
  thread: Thread;
1653
1760
  }) => {
1654
1761
  const { t } = useLingui();
1655
- const commentsHidden = useCommentsHidden();
1656
- if (commentsHidden) {
1762
+ const hidden = useIsHiddenThread(thread.id);
1763
+ if (hidden) {
1657
1764
  return null;
1658
1765
  }
1659
1766
  const first = thread.messages[0];
@@ -1691,7 +1798,12 @@ export type FloatingComment =
1691
1798
  /** The quick bar first, centred above `at`, then the composer. */
1692
1799
  quick?: boolean;
1693
1800
  }
1694
- | { kind: "thread"; id: string; at: ScreenPoint };
1801
+ | {
1802
+ kind: "thread";
1803
+ id: string;
1804
+ /** Where its card opens; left out, at its pin, once that is drawn. */
1805
+ at?: ScreenPoint;
1806
+ };
1695
1807
 
1696
1808
  /** While its composer is open, the composer closes itself. */
1697
1809
  const NO_CLOSE = () => undefined;
@@ -1764,11 +1876,48 @@ const QuickBar = ({
1764
1876
  );
1765
1877
  };
1766
1878
 
1879
+ /**
1880
+ * A thread opened while comments are hidden, from the list or the heads-up,
1881
+ * shows with its pin: its card, or its words beside a spec. Hiding comments
1882
+ * again hides it, as any open thread.
1883
+ */
1884
+ export const showWhileHidden = (id: string) => {
1885
+ if (view.hidden && view.opened !== id) {
1886
+ updateCommentsView({ opened: id });
1887
+ }
1888
+ };
1889
+
1890
+ /**
1891
+ * Forgets the thread opened while comments are hidden once it closes, or
1892
+ * another opens: the floating one, or the spec thread open beside its spec.
1893
+ */
1894
+ export const useOpenedWhileHidden = (
1895
+ floating: FloatingComment | undefined,
1896
+ specThread: string | undefined
1897
+ ) => {
1898
+ useLayoutEffect(() => {
1899
+ const id = floating?.kind === "thread" ? floating.id : specThread;
1900
+ if (view.opened !== undefined && view.opened !== id) {
1901
+ updateCommentsView({ opened: undefined });
1902
+ }
1903
+ }, [floating, specThread]);
1904
+ // Leaving the canvas (for Play), it is no longer open.
1905
+ useEffect(
1906
+ () => () => {
1907
+ if (view.opened !== undefined) {
1908
+ updateCommentsView({ opened: undefined });
1909
+ }
1910
+ },
1911
+ []
1912
+ );
1913
+ };
1914
+
1767
1915
  /**
1768
1916
  * The card for what is floating, if anything; a thread gone since shows
1769
- * none, and an open thread hides with comments (a comment being written
1770
- * stays). On the canvas and in Play it is always there, so it also listens
1771
- * for ⇧C, which hides comments.
1917
+ * none, and an open thread hides with comments, unless it was opened since
1918
+ * (showWhileHidden; a comment being written stays). On the canvas and
1919
+ * in Play it is always there, so it also listens for ⇧C, which hides
1920
+ * comments.
1772
1921
  */
1773
1922
  export const FloatingCommentCard = ({
1774
1923
  floating,
@@ -1780,7 +1929,7 @@ export const FloatingCommentCard = ({
1780
1929
  threads: ThreadsApi;
1781
1930
  }) => {
1782
1931
  useHideCommentsKey();
1783
- const commentsHidden = useCommentsHidden();
1932
+ const commentsView = useCommentsView();
1784
1933
  if (floating?.kind === "compose" && floating.quick) {
1785
1934
  return (
1786
1935
  <QuickBar
@@ -1803,12 +1952,15 @@ export const FloatingCommentCard = ({
1803
1952
  );
1804
1953
  }
1805
1954
  const thread =
1806
- floating?.kind === "thread" && !commentsHidden
1955
+ floating?.kind === "thread" && !isHiddenThread(commentsView, floating.id)
1807
1956
  ? threads.threads.find((entry) => entry.id === floating.id)
1808
1957
  : undefined;
1958
+ // A card for each thread and each way it opens: one opened at its pin
1959
+ // waits for it afresh.
1809
1960
  return floating && thread ? (
1810
1961
  <ThreadCard
1811
1962
  at={floating.at}
1963
+ key={floating.at ? thread.id : `${thread.id}@pin`}
1812
1964
  onClose={onClose}
1813
1965
  thread={thread}
1814
1966
  threads={threads}
@@ -1835,14 +1987,15 @@ const says = (query: string) => {
1835
1987
 
1836
1988
  /**
1837
1989
  * The threads `filter` shows that say `query`: open ones (the agent's
1838
- * replies first, then newest), then resolved ones, newest first.
1990
+ * replies first, then newest), then resolved ones, newest first. `me`, a
1991
+ * contributor's slug, is who Mentions is for.
1839
1992
  */
1840
1993
  export const filterThreads = <T extends Thread>(
1841
1994
  threads: T[],
1842
1995
  { audience, status }: CommentFilter,
1843
- query = ""
1996
+ { me, query = "" }: { me?: string; query?: string } = {}
1844
1997
  ) => {
1845
- const mine = threads.filter(byFilter(audience)).filter(says(query));
1998
+ const mine = threads.filter(byFilter(audience, me)).filter(says(query));
1846
1999
  const open = mine.filter((thread) => !isClosed(thread)).sort(yourTurnFirst);
1847
2000
  const closed =
1848
2001
  status === "open" ? [] : mine.filter(isClosed).sort(newestFirst);
@@ -1866,6 +2019,15 @@ const emptyCopy = (
1866
2019
  ),
1867
2020
  };
1868
2021
  }
2022
+ if (filter.audience === "mentions") {
2023
+ return {
2024
+ icon: "AtSign",
2025
+ title: <Trans>No mentions</Trans>,
2026
+ line: (
2027
+ <Trans>Comments where someone writes @ and your name show here.</Trans>
2028
+ ),
2029
+ };
2030
+ }
1869
2031
  if (filter.audience === "people") {
1870
2032
  return {
1871
2033
  icon: "MessageCircle",
@@ -1930,6 +2092,7 @@ const FROM_OPTIONS: { id: ThreadFilter; label: MessageDescriptor }[] =
1930
2092
  { id: "all", label: msg`All` },
1931
2093
  { id: "people", label: msg`People` },
1932
2094
  { id: "agents", label: msg`Agents` },
2095
+ { id: "mentions", label: msg`Mentions` },
1933
2096
  ];
1934
2097
 
1935
2098
  /**
@@ -1944,6 +2107,8 @@ const FilterMenu = ({
1944
2107
  value: CommentFilter;
1945
2108
  }) => {
1946
2109
  const { i18n, t } = useLingui();
2110
+ // Only someone the workspace knows can be mentioned.
2111
+ const known = useMentionable() !== undefined;
1947
2112
  const label = t`Filter comments`;
1948
2113
  const filtered = value.audience !== DEFAULT_FILTER.audience;
1949
2114
  return (
@@ -1977,11 +2142,13 @@ const FilterMenu = ({
1977
2142
  }
1978
2143
  value={value.audience}
1979
2144
  >
1980
- {FROM_OPTIONS.map(({ id, label: name }) => (
1981
- <DropdownMenuRadioItem key={id} value={id}>
1982
- {i18n._(name)}
1983
- </DropdownMenuRadioItem>
1984
- ))}
2145
+ {FROM_OPTIONS.filter(({ id }) => known || id !== "mentions").map(
2146
+ ({ id, label: name }) => (
2147
+ <DropdownMenuRadioItem key={id} value={id}>
2148
+ {i18n._(name)}
2149
+ </DropdownMenuRadioItem>
2150
+ )
2151
+ )}
1985
2152
  </DropdownMenuRadioGroup>
1986
2153
  </DropdownMenuGroup>
1987
2154
  </DropdownMenuContent>
@@ -2090,8 +2257,9 @@ export const CommentsTools = () => {
2090
2257
  * Every thread on the prototype, open ones first, then resolved ones,
2091
2258
  * dimmed; filtered by where they stand, who they are from and what they
2092
2259
  * say, as CommentsTools sets. A row opens its thread on the canvas, and
2093
- * resolves or reopens it from its corner, except in a built studio. While
2094
- * comments are hidden, the list is too. Closing the panel clears the search.
2260
+ * resolves or reopens it from its corner, except in a built studio. With
2261
+ * comments hidden on the canvas, the list still shows them. Closing the
2262
+ * panel clears the search.
2095
2263
  */
2096
2264
  export const CommentsPanel = ({
2097
2265
  onResolve,
@@ -2102,18 +2270,16 @@ export const CommentsPanel = ({
2102
2270
  onSelect: (thread: Thread, at: ScreenPoint) => void;
2103
2271
  threads: Thread[];
2104
2272
  }) => {
2105
- const { filter, hidden, query } = useCommentsView();
2273
+ const { filter, query } = useCommentsView();
2106
2274
  useEffect(() => () => updateCommentsView({ query: "" }), []);
2107
2275
  return (
2108
2276
  <div className="flex min-h-0 flex-1 flex-col">
2109
- {hidden ? null : (
2110
- <StatusTabs
2111
- onChange={(status) =>
2112
- updateCommentsView({ filter: { ...filter, status } })
2113
- }
2114
- value={filter.status}
2115
- />
2116
- )}
2277
+ <StatusTabs
2278
+ onChange={(status) =>
2279
+ updateCommentsView({ filter: { ...filter, status } })
2280
+ }
2281
+ value={filter.status}
2282
+ />
2117
2283
  <CommentsBody
2118
2284
  filter={filter}
2119
2285
  onResolve={onResolve}
@@ -2139,22 +2305,15 @@ const CommentsBody = ({
2139
2305
  query: string;
2140
2306
  threads: Thread[];
2141
2307
  }) => {
2142
- const commentsHidden = useCommentsHidden();
2143
- const shown = filterThreads(threads, filter, query);
2308
+ const me = useMentionable();
2309
+ const shown = filterThreads(threads, filter, { me, query });
2144
2310
  const words = query.trim();
2145
- if (commentsHidden) {
2146
- return (
2147
- <EmptyState icon="MessageCircle" title={<Trans>Comments hidden</Trans>}>
2148
- <Trans>Press ⇧C, or choose Show comments in ⋯, to see them.</Trans>
2149
- </EmptyState>
2150
- );
2151
- }
2152
2311
  // A search that finds nothing says so in a line, where without it the
2153
2312
  // filter would show threads.
2154
2313
  if (
2155
2314
  words !== "" &&
2156
2315
  shown.length === 0 &&
2157
- filterThreads(threads, filter).length > 0
2316
+ filterThreads(threads, filter, { me }).length > 0
2158
2317
  ) {
2159
2318
  return (
2160
2319
  <p className="px-3 py-4 text-center text-muted-foreground">