better-supabase 0.63.2 → 0.65.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 (467) hide show
  1. package/dist/{adapter-base-DXF0tNJJ.js → adapter-base-BWp_GpBq.js} +1 -1
  2. package/dist/{agents-C8BwEXD0.d.ts → agents-DwZDwOoT.d.ts} +2 -2
  3. package/dist/{ai-schedules-j51dDzm3.d.ts → ai-schedules-Snwu8x_i.d.ts} +1 -1
  4. package/dist/ai-sdk/agents/index.d.ts +1 -1
  5. package/dist/ai-sdk/workflow/index.d.ts +1 -1
  6. package/dist/{api-DhCLHpIU.js → api-DW835Q-a.js} +1 -1
  7. package/dist/{app-tables-Br5Khxij.d.ts → app-tables-Bfqe58WR.d.ts} +1 -1
  8. package/dist/astro/index.js +3 -3
  9. package/dist/{authorization-k0Y3L701.d.ts → authorization-CX-03Zgx.d.ts} +1 -1
  10. package/dist/{bind-CuRPlZYY.d.ts → bind-C9Bu9fgk.d.ts} +3 -3
  11. package/dist/{block-env-hdFBj6FQ.d.ts → block-env-B0azWULB.d.ts} +4 -4
  12. package/dist/{block-tables-1XNfpOPP.d.ts → block-tables-BYfcmfA5.d.ts} +1 -1
  13. package/dist/blocks/access-requests/index.d.ts +1 -1
  14. package/dist/blocks/accounting/index.d.ts +1 -1
  15. package/dist/blocks/acknowledgements/index.d.ts +1 -1
  16. package/dist/blocks/activities/index.d.ts +2 -2
  17. package/dist/blocks/advisories/index.d.ts +1 -1
  18. package/dist/blocks/agent-checkout/index.d.ts +1 -1
  19. package/dist/blocks/agents/index.d.ts +1 -1
  20. package/dist/blocks/ai-cache/index.d.ts +1 -1
  21. package/dist/blocks/ai-chat/index.d.ts +1 -1
  22. package/dist/blocks/ai-evals/index.d.ts +1 -1
  23. package/dist/blocks/ai-files/index.d.ts +1 -1
  24. package/dist/blocks/ai-guardrails/index.d.ts +1 -1
  25. package/dist/blocks/ai-keys/index.d.ts +1 -1
  26. package/dist/blocks/ai-schedules/index.d.ts +2 -2
  27. package/dist/blocks/announcements/index.d.ts +4 -4
  28. package/dist/blocks/api-keys/index.d.ts +1 -1
  29. package/dist/blocks/appraisals/index.d.ts +1 -1
  30. package/dist/blocks/approvals/index.d.ts +1 -1
  31. package/dist/blocks/assets/index.d.ts +2 -2
  32. package/dist/blocks/assignment/index.d.ts +1 -1
  33. package/dist/blocks/attachments/index.d.ts +5 -5
  34. package/dist/blocks/audit/index.d.ts +2 -2
  35. package/dist/blocks/automations/index.d.ts +3 -3
  36. package/dist/blocks/banking/index.d.ts +1 -1
  37. package/dist/blocks/billable-time/index.d.ts +1 -1
  38. package/dist/blocks/billing/index.d.ts +2 -2
  39. package/dist/blocks/bookings/index.d.ts +2 -2
  40. package/dist/blocks/bulk-actions/index.d.ts +2 -2
  41. package/dist/blocks/calendar/index.d.ts +3 -3
  42. package/dist/blocks/care/index.d.ts +27 -27
  43. package/dist/blocks/care-plans/index.d.ts +3 -3
  44. package/dist/blocks/cases/index.d.ts +3 -3
  45. package/dist/blocks/catalog/index.d.ts +2 -2
  46. package/dist/blocks/channels/index.d.ts +1 -1
  47. package/dist/blocks/clinical-decision-support/index.d.ts +1 -1
  48. package/dist/blocks/cms/index.d.ts +5 -5
  49. package/dist/blocks/collaboration/index.d.ts +6 -6
  50. package/dist/blocks/collections/index.d.ts +1 -1
  51. package/dist/blocks/comments/index.d.ts +2 -2
  52. package/dist/blocks/commerce/index.d.ts +5 -5
  53. package/dist/blocks/commissions/index.d.ts +1 -1
  54. package/dist/blocks/compliance/index.d.ts +1 -1
  55. package/dist/blocks/connectors/index.d.ts +1 -1
  56. package/dist/blocks/consents/index.d.ts +2 -2
  57. package/dist/blocks/contacts/index.d.ts +2 -2
  58. package/dist/blocks/content/index.d.ts +2 -2
  59. package/dist/blocks/contracts/index.d.ts +1 -1
  60. package/dist/blocks/courses/index.d.ts +2 -2
  61. package/dist/blocks/created-by/index.d.ts +2 -2
  62. package/dist/blocks/crm/index.d.ts +16 -16
  63. package/dist/blocks/custom-fields/index.d.ts +1 -1
  64. package/dist/blocks/dam/index.d.ts +2 -2
  65. package/dist/blocks/data-lifecycle/index.d.ts +2 -2
  66. package/dist/blocks/deadlines/index.d.ts +1 -1
  67. package/dist/blocks/deals/index.d.ts +1 -1
  68. package/dist/blocks/dispatch/index.d.ts +2 -2
  69. package/dist/blocks/document-templates/index.d.ts +2 -2
  70. package/dist/blocks/documents/index.d.ts +1 -1
  71. package/dist/blocks/domains/index.d.ts +1 -1
  72. package/dist/blocks/donations/index.d.ts +1 -1
  73. package/dist/blocks/drive/index.d.ts +5 -5
  74. package/dist/blocks/e-prescribing/index.d.ts +1 -1
  75. package/dist/blocks/employees/index.d.ts +1 -1
  76. package/dist/blocks/enrichment/index.d.ts +1 -1
  77. package/dist/blocks/enrollments/index.d.ts +2 -2
  78. package/dist/blocks/entitlements/index.d.ts +3 -3
  79. package/dist/blocks/events/index.d.ts +3 -3
  80. package/dist/blocks/expenses/index.d.ts +1 -1
  81. package/dist/blocks/field-history/index.d.ts +1 -1
  82. package/dist/blocks/filespace/index.d.ts +8 -8
  83. package/dist/blocks/finance/index.d.ts +5 -5
  84. package/dist/blocks/flags/index.d.ts +1 -1
  85. package/dist/blocks/forecasts/index.d.ts +1 -1
  86. package/dist/blocks/forms/index.d.ts +3 -3
  87. package/dist/blocks/funding/index.d.ts +2 -2
  88. package/dist/blocks/goals/index.d.ts +1 -1
  89. package/dist/blocks/governance/index.d.ts +4 -4
  90. package/dist/blocks/guests/index.d.ts +1 -1
  91. package/dist/blocks/hiring/index.d.ts +1 -1
  92. package/dist/blocks/identities/index.d.ts +1 -1
  93. package/dist/blocks/imports/index.d.ts +2 -2
  94. package/dist/blocks/inbox/index.d.ts +6 -6
  95. package/dist/blocks/incidents/index.d.ts +1 -1
  96. package/dist/blocks/index.d.ts +3 -3
  97. package/dist/blocks/inspections/index.d.ts +2 -2
  98. package/dist/blocks/inventory/index.d.ts +1 -1
  99. package/dist/blocks/invoices/index.d.ts +1 -1
  100. package/dist/blocks/knowledge/index.d.ts +1 -1
  101. package/dist/blocks/lead-scoring/index.d.ts +2 -2
  102. package/dist/blocks/learning/index.d.ts +3 -3
  103. package/dist/blocks/leases/index.d.ts +1 -1
  104. package/dist/blocks/leave/index.d.ts +1 -1
  105. package/dist/blocks/ledger/index.d.ts +1 -1
  106. package/dist/blocks/legal-entities/index.d.ts +2 -2
  107. package/dist/blocks/lims/index.d.ts +2 -2
  108. package/dist/blocks/mail-sync/index.d.ts +3 -3
  109. package/dist/blocks/maintenance/index.d.ts +2 -2
  110. package/dist/blocks/manufacturing/index.d.ts +2 -2
  111. package/dist/blocks/medications/index.d.ts +1 -1
  112. package/dist/blocks/meetings/index.d.ts +3 -3
  113. package/dist/blocks/memberships/index.d.ts +2 -2
  114. package/dist/blocks/memory/index.d.ts +1 -1
  115. package/dist/blocks/messaging/index.d.ts +5 -5
  116. package/dist/blocks/metrics/index.d.ts +1 -1
  117. package/dist/blocks/mfa/index.d.ts +2 -2
  118. package/dist/blocks/moderation/index.d.ts +2 -2
  119. package/dist/blocks/notifications/index.d.ts +5 -5
  120. package/dist/blocks/numbering/index.d.ts +1 -1
  121. package/dist/blocks/oauth-server/index.d.ts +1 -1
  122. package/dist/blocks/observations/index.d.ts +2 -2
  123. package/dist/blocks/onboarding/index.d.ts +2 -2
  124. package/dist/blocks/option-sets/index.d.ts +2 -2
  125. package/dist/blocks/orders/index.d.ts +1 -1
  126. package/dist/blocks/organizations/index.d.ts +2 -2
  127. package/dist/blocks/outbox/index.d.ts +1 -1
  128. package/dist/blocks/passes/index.d.ts +2 -2
  129. package/dist/blocks/payroll-export/index.d.ts +2 -2
  130. package/dist/blocks/people/index.d.ts +7 -7
  131. package/dist/blocks/periods/index.d.ts +1 -1
  132. package/dist/blocks/permissions/index.d.ts +3 -3
  133. package/dist/blocks/pipelines/index.d.ts +2 -2
  134. package/dist/blocks/posts/index.d.ts +2 -2
  135. package/dist/blocks/procurement/index.d.ts +5 -5
  136. package/dist/blocks/profiles/index.d.ts +1 -1
  137. package/dist/blocks/projects/index.d.ts +7 -7
  138. package/dist/blocks/promotions/index.d.ts +1 -1
  139. package/dist/blocks/prompts/index.d.ts +1 -1
  140. package/dist/blocks/push/index.d.ts +2 -2
  141. package/dist/blocks/qualifications/index.d.ts +2 -2
  142. package/dist/blocks/queue/index.d.ts +2 -2
  143. package/dist/blocks/quotes/index.d.ts +1 -1
  144. package/dist/blocks/rank/index.d.ts +1 -1
  145. package/dist/blocks/reactions/index.d.ts +4 -4
  146. package/dist/blocks/recruiting/index.d.ts +4 -4
  147. package/dist/blocks/referrals/index.d.ts +1 -1
  148. package/dist/blocks/relations/index.d.ts +1 -1
  149. package/dist/blocks/reminders/index.d.ts +1 -1
  150. package/dist/blocks/reviews/index.d.ts +1 -1
  151. package/dist/blocks/rfqs/index.d.ts +2 -2
  152. package/dist/blocks/risks/index.d.ts +2 -2
  153. package/dist/blocks/saas/index.d.ts +12 -12
  154. package/dist/blocks/sales/index.d.ts +1 -1
  155. package/dist/blocks/saved-views/index.d.ts +2 -2
  156. package/dist/blocks/scheduling/index.d.ts +4 -4
  157. package/dist/blocks/scores/index.d.ts +2 -2
  158. package/dist/blocks/search/index.d.ts +3 -3
  159. package/dist/blocks/security-events/index.d.ts +1 -1
  160. package/dist/blocks/segments/index.d.ts +2 -2
  161. package/dist/blocks/sequences/index.d.ts +3 -3
  162. package/dist/blocks/service/index.d.ts +7 -7
  163. package/dist/blocks/service-accounts/index.d.ts +1 -1
  164. package/dist/blocks/sessions/index.d.ts +2 -2
  165. package/dist/blocks/settings/index.d.ts +2 -2
  166. package/dist/blocks/share-links/index.d.ts +1 -1
  167. package/dist/blocks/shifts/index.d.ts +2 -2
  168. package/dist/blocks/shipments/index.d.ts +1 -1
  169. package/dist/blocks/signatures/index.d.ts +2 -2
  170. package/dist/blocks/signing-keys/index.d.ts +1 -1
  171. package/dist/blocks/sla/index.d.ts +1 -1
  172. package/dist/blocks/sso/index.d.ts +1 -1
  173. package/dist/blocks/state-machine/index.d.ts +1 -1
  174. package/dist/blocks/subjects/index.d.ts +2 -2
  175. package/dist/blocks/support/index.d.ts +5 -5
  176. package/dist/blocks/tags/index.d.ts +2 -2
  177. package/dist/blocks/tasks/index.d.ts +2 -2
  178. package/dist/blocks/tax/index.d.ts +2 -2
  179. package/dist/blocks/teams/index.d.ts +1 -1
  180. package/dist/blocks/templates/index.d.ts +1 -1
  181. package/dist/blocks/tills/index.d.ts +1 -1
  182. package/dist/blocks/time-entries/index.d.ts +2 -2
  183. package/dist/blocks/timeline/index.d.ts +1 -1
  184. package/dist/blocks/trash/index.d.ts +1 -1
  185. package/dist/blocks/undo/index.d.ts +2 -2
  186. package/dist/blocks/updated-at/index.d.ts +2 -2
  187. package/dist/blocks/usage/index.d.ts +2 -2
  188. package/dist/blocks/vercel-marketplace/index.d.ts +1 -1
  189. package/dist/blocks/versions/index.d.ts +1 -1
  190. package/dist/blocks/waitlist/index.d.ts +1 -1
  191. package/dist/blocks/warehouse/index.d.ts +1 -1
  192. package/dist/blocks/warranty/index.d.ts +1 -1
  193. package/dist/blocks/webhooks/index.d.ts +1 -1
  194. package/dist/blocks/workflow-editor/index.d.ts +4 -4
  195. package/dist/blocks/workflows/index.d.ts +4 -4
  196. package/dist/{blocks-C2F_SycJ.d.ts → blocks-DuL-Ds3g.d.ts} +11 -3
  197. package/dist/{build-Vd4JkaqJ.js → build-C4utCr_F.js} +1 -1
  198. package/dist/claims/index.d.ts +4 -4
  199. package/dist/{claims-source-fUk4pR24.d.ts → claims-source-Cek93vyw.d.ts} +1 -1
  200. package/dist/cli/{add-B8H-eHVK.js → add-CJunmhIu.js} +11 -11
  201. package/dist/cli/add-D70QLNK7.js +1 -0
  202. package/dist/cli/{add-DzsB2EMd.js → add-FzNe4YLu.js} +2 -2
  203. package/dist/cli/{app-table-files-BNbkk4mU.js → app-table-files-BDmrt2qu.js} +4 -4
  204. package/dist/cli/{app-tables-B9xoTgSg.js → app-tables-C38kyCXS.js} +2 -2
  205. package/dist/cli/{backfill-DxGGF0tw.js → backfill-BafFSdLq.js} +3 -3
  206. package/dist/cli/bin.js +1 -1
  207. package/dist/cli/{blocks-xgk0tdfI.js → blocks-CLZsTRQp.js} +1 -1
  208. package/dist/cli/{blocks-zWXWOGcv.js → blocks-zt9rwTL_.js} +1 -1
  209. package/dist/cli/{cache-DGTzqvsc.js → cache-CEIUM3JG.js} +1 -1
  210. package/dist/cli/{codemod-C63P8ybN.js → codemod-M2rQ1W_U.js} +5 -5
  211. package/dist/cli/{codemod-naming-wb0ni9VH.js → codemod-naming-DfHoYdJU.js} +1 -1
  212. package/dist/cli/{column-renames-Cw-VJmbc.js → column-renames-c21PFef3.js} +2 -2
  213. package/dist/cli/{config-D4AVoIh5.js → config-CVwtXlJf.js} +1 -1
  214. package/dist/cli/{config-By5EbpdJ.js → config-f3sjxKp2.js} +1 -1
  215. package/dist/cli/{content-mapper-DXjq7Wfl.js → content-mapper-DqVf_Fgs.js} +1 -1
  216. package/dist/cli/{db-C4up7wFU.js → db-ZevmfY9U.js} +2 -2
  217. package/dist/cli/{dev-r1oRNl1e.js → dev-D1GK3haS.js} +5 -5
  218. package/dist/cli/{doctor-BHIIEqOU.js → doctor-uoRPUZ8F.js} +19 -19
  219. package/dist/cli/{emit-C6S__22g.js → emit-B_Lm7_wL.js} +2 -2
  220. package/dist/cli/{gen-tasks-D0_qerE6.js → gen-tasks-DqGGUn1q.js} +11 -11
  221. package/dist/cli/{gen-DWNQMbqr.js → gen-wt2ZUpGe.js} +5 -5
  222. package/dist/cli/index.d.ts +1 -1
  223. package/dist/cli/index.js +8 -8
  224. package/dist/cli/{init-DiYhhVtO.js → init-D86uTIWa.js} +9 -9
  225. package/dist/cli/{live-C7AMtQsQ.js → live-BA_a2Jol.js} +2 -2
  226. package/dist/cli/{mcp-DaymIFzT.js → mcp-BAbfqDad.js} +2 -2
  227. package/dist/cli/{memo-backend-DaO-IuUk.js → memo-backend-DhdJmTUc.js} +1 -1
  228. package/dist/cli/{metadata-CsSZ8mZc.js → metadata-CDLkzqxG.js} +4 -4
  229. package/dist/cli/{migrate-Ceai0fte.js → migrate-CdPcq8-a.js} +1 -1
  230. package/dist/cli/{migration-safety-BXKmX5ar.js → migration-safety-Dwfz0WVB.js} +2 -2
  231. package/dist/cli/{module-migration-ueN8AWpK.js → module-migration-DFIsQn_x.js} +1 -1
  232. package/dist/cli/{partition-DMv3-JOr.js → partition-CXNI9PQP.js} +3 -3
  233. package/dist/cli/powersync-Crw4D8xt.js +1 -0
  234. package/dist/cli/{powersync-QpdoYTM1.js → powersync-DrwwjGP-.js} +4 -4
  235. package/dist/cli/{print-CQe9SQD_.js → print-DNSc_N-C.js} +2 -2
  236. package/dist/cli/{providers-DocDgHot.js → providers-QbWlzsWD.js} +1 -1
  237. package/dist/cli/{prune-workflows-w_4KdMR9.js → prune-workflows-BpWuOsJw.js} +3 -3
  238. package/dist/cli/{remove-DvnCBCVe.js → remove-C_qXMRzB.js} +6 -6
  239. package/dist/cli/{render-X1jNuye8.js → render-BETiezmy.js} +5 -5
  240. package/dist/cli/{render-cache-Be5Sm_Eu.js → render-cache-BB0JYz8w.js} +1 -1
  241. package/dist/cli/{run-72NxM1zM.js → run-BOVCY-r-.js} +101 -21
  242. package/dist/cli/{run-BoLLvybx.js → run-Dxc0-5HJ.js} +35 -35
  243. package/dist/cli/seed-CIRl--FX.js +1 -0
  244. package/dist/cli/{seed-BufZFJ_Q.js → seed-DWgxzesp.js} +2 -2
  245. package/dist/cli/{shared-BR48oJN4.js → shared-BaAJV9R_.js} +1 -1
  246. package/dist/cli/{source-aefKuXMY.js → source-1bNLaVRN.js} +1 -1
  247. package/dist/cli/{source-args-CvgOHwlj.js → source-args-BJ0HQoMM.js} +1 -1
  248. package/dist/cli/{spec-CxtMMgXM.js → spec-D4oXGSKz.js} +1 -1
  249. package/dist/cli/{spec-Dvz-C4MP.js → spec-LDMiECv9.js} +2 -2
  250. package/dist/cli/{sql-layout-B2fda2KP.js → sql-layout-C8AdA_Eo.js} +3 -3
  251. package/dist/cli/{squash-D7KwCZHj.js → squash-BB0Kxk8Q.js} +1 -1
  252. package/dist/cli/{sync-DvD3jbb4.js → sync-bBwKCyBW.js} +4 -4
  253. package/dist/cli/{upgrade-hDU5DI6_.js → upgrade-DNukTQY6.js} +5 -5
  254. package/dist/cli/{upgrade-C6Pw49Jc.js → upgrade-DfYVHnuj.js} +5 -5
  255. package/dist/cli/{verify-CR7f21Ri.js → verify-CiUN5skL.js} +2 -2
  256. package/dist/cli/{version-CiDgdPUD.js → version-DfAapHvH.js} +1 -1
  257. package/dist/client/index.d.ts +5 -5
  258. package/dist/client/index.js +1 -1
  259. package/dist/client/native/index.d.ts +4 -4
  260. package/dist/client/native/index.js +2 -2
  261. package/dist/{composite-C13UCNgm.js → composite-RorL_F8I.js} +1 -1
  262. package/dist/config/index.d.ts +4 -4
  263. package/dist/config/index.js +4 -4
  264. package/dist/{config-1kAVpZc_.js → config-BuZW7wNr.js} +3 -3
  265. package/dist/{config-L5_4kg24.js → config-ocvgjLWV.js} +1 -1
  266. package/dist/{context-DtyeoCvj.d.ts → context-CoxeOKXg.d.ts} +3 -3
  267. package/dist/contract/index.d.ts +3 -3
  268. package/dist/{controller-D6ZUjfhv.d.ts → controller-D4dnWk48.d.ts} +1 -1
  269. package/dist/{conversion-BiAEs9ja.d.ts → conversion-BK0OksW-.d.ts} +1 -1
  270. package/dist/create/index.d.ts +4 -4
  271. package/dist/create/index.js +3 -3
  272. package/dist/create/lite/index.d.ts +3 -3
  273. package/dist/create/lite/index.js +4 -4
  274. package/dist/{define-block-DpnCxELV.d.ts → define-block-BNN4jNs1.d.ts} +1 -1
  275. package/dist/{define-runtime-BbNPkt-5.js → define-runtime-DQC2Gjdr.js} +4 -0
  276. package/dist/{define-runtime-full-gpz09qAj.js → define-runtime-full-BIrEQWJR.js} +1 -1
  277. package/dist/{drive-_xuMA2xw.d.ts → drive-CNwty_R6.d.ts} +1 -1
  278. package/dist/edge/index.js +4 -4
  279. package/dist/{entitlements-Djh4bBdj.d.ts → entitlements-CYnE3d6D.d.ts} +2 -2
  280. package/dist/{executor-DABWqMfV.js → executor-D7avvqx3.js} +1 -1
  281. package/dist/expo/index.js +3 -3
  282. package/dist/{extract-DZznUgzb.d.ts → extract-DMI10ymS.d.ts} +1 -1
  283. package/dist/{extras-Cb1ZUvNK.d.ts → extras-DLKG5Qrz.d.ts} +1 -1
  284. package/dist/{field-errors-DSEpFDCa.d.ts → field-errors-B88R19Ds.d.ts} +5 -5
  285. package/dist/{former-permission-keys-FPrqQHXf.js → former-permission-keys-DVwR65bj.js} +1 -1
  286. package/dist/{framework-BQgHM3zD.js → framework-DxCx0pmS.js} +1 -1
  287. package/dist/generators/factories/index.d.ts +1 -1
  288. package/dist/generators/factories/index.js +1 -1
  289. package/dist/generators/index.d.ts +2 -2
  290. package/dist/generators/json-schema/index.d.ts +2 -2
  291. package/dist/generators/json-schema/index.js +1 -1
  292. package/dist/generators/nuqs/index.d.ts +1 -1
  293. package/dist/generators/nuqs/index.js +1 -1
  294. package/dist/generators/standard-schema/index.d.ts +1 -1
  295. package/dist/generators/standard-schema/index.js +1 -1
  296. package/dist/generators/valibot/index.d.ts +1 -1
  297. package/dist/generators/valibot/index.js +1 -1
  298. package/dist/generators/zod/index.d.ts +1 -1
  299. package/dist/generators/zod/index.js +1 -1
  300. package/dist/hono/index.js +3 -3
  301. package/dist/{index-Bx9qRuof.d.ts → index-7zilcSsn.d.ts} +1 -1
  302. package/dist/{index-D9fhYtnp.d.ts → index-95m7aK3r.d.ts} +1 -1
  303. package/dist/{index-DIwhnfIi.d.ts → index-B5_A0px6.d.ts} +2 -2
  304. package/dist/{index-Dsb6-otF.d.ts → index-B62LISft.d.ts} +1 -1
  305. package/dist/{index-DVmqH-jI.d.ts → index-BH0TBQjQ.d.ts} +3 -3
  306. package/dist/{index-CjmtqiRE.d.ts → index-Be44DVw_.d.ts} +1 -1
  307. package/dist/{index-bFOgwrCN.d.ts → index-BezbTIy8.d.ts} +1 -1
  308. package/dist/{index-jJ7Q-AYO.d.ts → index-Bn9uT8zK.d.ts} +2 -2
  309. package/dist/{index-Bt5jJrzR.d.ts → index-BnQd1un1.d.ts} +1 -1
  310. package/dist/{index-1aGCqU0F.d.ts → index-BpB7zXE8.d.ts} +1 -1
  311. package/dist/{index-BEVvxkvW.d.ts → index-BsxetsKr.d.ts} +1 -1
  312. package/dist/{index-DUDYFfnG.d.ts → index-BtBPT0Xd.d.ts} +1 -1
  313. package/dist/{index-BKD8Lkn9.d.ts → index-BuJNFxep.d.ts} +7 -7
  314. package/dist/{index-DtGyj0RU.d.ts → index-ByxPedDM.d.ts} +4 -4
  315. package/dist/{index-BDq77p1R.d.ts → index-C-dzSmym.d.ts} +1 -1
  316. package/dist/{index-BIOLHETk.d.ts → index-C0efZ4-1.d.ts} +1 -1
  317. package/dist/{index-D-LxyjmH.d.ts → index-CGWlGdkC.d.ts} +2 -2
  318. package/dist/{index-B2NJNoRd.d.ts → index-CHpvAU8q.d.ts} +16 -8
  319. package/dist/{index-BiX0gNGQ.d.ts → index-CIC4gEN2.d.ts} +2 -2
  320. package/dist/{index-CygaT0GH.d.ts → index-CIWIKJq9.d.ts} +1 -1
  321. package/dist/{index-Dga-eftL.d.ts → index-CUIQqlYq.d.ts} +4 -4
  322. package/dist/{index-DEHVn5Ma.d.ts → index-Ci5b0O38.d.ts} +1 -1
  323. package/dist/{index-_IFPpPG9.d.ts → index-CuIfFMrc.d.ts} +1 -1
  324. package/dist/{index-RGXgZmyg.d.ts → index-CzJiTefX.d.ts} +2 -2
  325. package/dist/{index-DAYCCmVC.d.ts → index-CzMeb47z.d.ts} +1 -1
  326. package/dist/{index-vOUlkC2o.d.ts → index-D9cT5n3D.d.ts} +1 -1
  327. package/dist/{index-CaE6XZnq.d.ts → index-D9oaJIco.d.ts} +3 -3
  328. package/dist/{index-BAccIXQt.d.ts → index-DIlQq5SD.d.ts} +2 -2
  329. package/dist/{index-CbKxPo6t.d.ts → index-DZBqNuEr.d.ts} +2 -2
  330. package/dist/{index-C8H6hpAP.d.ts → index-DZxb4kuD.d.ts} +2 -2
  331. package/dist/{index-CmHvVWGd.d.ts → index-Dl4NyBCR.d.ts} +1 -1
  332. package/dist/{index-S6WKucTU.d.ts → index-Dpuwg0TF.d.ts} +1 -1
  333. package/dist/{index-BeJMACah.d.ts → index-N---BEYQ.d.ts} +2 -2
  334. package/dist/{index-BREewNqU.d.ts → index-kKRVxhxd.d.ts} +1 -1
  335. package/dist/{index-DitpSLYH.d.ts → index-ljkv6cKx.d.ts} +2 -2
  336. package/dist/{index-C-h2MrvD.d.ts → index-o4u57crs.d.ts} +1 -1
  337. package/dist/{index-TkkZfmGg.d.ts → index-omC5tnCw.d.ts} +1 -1
  338. package/dist/{instances-PZAWgQEX.js → instances-B9oCgEOH.js} +76 -0
  339. package/dist/{json-schema-BwfI_jJ2.js → json-schema-BHx8LHzw.js} +1 -1
  340. package/dist/{manifest-B1bfLbzz.d.ts → manifest-0mtF51MB.d.ts} +1 -1
  341. package/dist/{manifest-C0-rnYge.d.ts → manifest-1Wrn1roh.d.ts} +1 -1
  342. package/dist/{manifest-DiJKbgrM.d.ts → manifest-1scY6yWo.d.ts} +1 -1
  343. package/dist/{manifest-DySuHx51.d.ts → manifest-2xnqzIEk.d.ts} +2 -2
  344. package/dist/{manifest-uAf9hw_t.d.ts → manifest-7jM_DQl2.d.ts} +1 -1
  345. package/dist/{manifest-ByfZrxkk.d.ts → manifest-9foPJ_Fd.d.ts} +1 -1
  346. package/dist/{manifest-BYHJvkqX.d.ts → manifest-B83vvPek.d.ts} +1 -1
  347. package/dist/{manifest-Cf8__tMA.d.ts → manifest-B8ThF_jn.d.ts} +1 -1
  348. package/dist/{manifest-CrO5Gwed.d.ts → manifest-BHwpLaPI.d.ts} +1 -1
  349. package/dist/{manifest-B-5cqXlx.d.ts → manifest-BJ3DoG3E.d.ts} +1 -1
  350. package/dist/{manifest-CzErrA0R.d.ts → manifest-BMLhR4Eg.d.ts} +1 -1
  351. package/dist/{manifest-Bgc-jWOV.d.ts → manifest-BNRs20Uf.d.ts} +1 -1
  352. package/dist/{manifest-rk3V9E0p.d.ts → manifest-BWzHfbrz.d.ts} +1 -1
  353. package/dist/{manifest-C3qUn0ka.d.ts → manifest-BYoi4yhl.d.ts} +1 -1
  354. package/dist/{manifest-C02JeWGr.d.ts → manifest-BZe8-T8v.d.ts} +1 -1
  355. package/dist/{manifest-B1R3o592.d.ts → manifest-B_wuy2Dp.d.ts} +1 -1
  356. package/dist/{manifest-DpW-TJwu.d.ts → manifest-BaElonmS.d.ts} +1 -1
  357. package/dist/{manifest-DgVrJNgv.d.ts → manifest-Batx8PnZ.d.ts} +1 -1
  358. package/dist/{manifest-nsV6ZrZ7.d.ts → manifest-BcgK5CNE.d.ts} +1 -1
  359. package/dist/{manifest-CRe-o25G.d.ts → manifest-BeYe1Tqi.d.ts} +1 -1
  360. package/dist/{manifest-BTZI-Jq1.d.ts → manifest-BlVniNtg.d.ts} +1 -1
  361. package/dist/{manifest-DFRP7LFo.d.ts → manifest-C0fdSZ8P.d.ts} +1 -1
  362. package/dist/{manifest-B__S-85Q.d.ts → manifest-C1hpLMFd.d.ts} +1 -1
  363. package/dist/{manifest-DWS1Hszm.d.ts → manifest-C2msUYGH.d.ts} +1 -1
  364. package/dist/{manifest-CKbJBLaW.d.ts → manifest-CA1Xja1g.d.ts} +1 -1
  365. package/dist/{manifest-D_RJDjHz.d.ts → manifest-CXuwQ864.d.ts} +1 -1
  366. package/dist/{manifest-BGBYLCP-.d.ts → manifest-CYptKcK7.d.ts} +1 -1
  367. package/dist/{manifest-rB3i09ej.d.ts → manifest-CkfGKcp8.d.ts} +1 -1
  368. package/dist/{manifest-BLVRM4WX.d.ts → manifest-ClyZmlqw.d.ts} +1 -1
  369. package/dist/{manifest-4K_pRDrE.d.ts → manifest-CnDmxd8U.d.ts} +1 -1
  370. package/dist/{manifest-DCIvxvg9.d.ts → manifest-CnSYGkcj.d.ts} +1 -1
  371. package/dist/{manifest-CQ1Xpja6.d.ts → manifest-CsFtXBBz.d.ts} +1 -1
  372. package/dist/{manifest-DEf81vUp.d.ts → manifest-CtUjuzks.d.ts} +1 -1
  373. package/dist/{manifest-DH1wX47F.d.ts → manifest-Cw2OY_as.d.ts} +1 -1
  374. package/dist/{manifest-BsuYq-pZ.d.ts → manifest-D0L-FCeR.d.ts} +1 -1
  375. package/dist/{manifest-Ca6Rm4u6.d.ts → manifest-D0bqUKw0.d.ts} +1 -1
  376. package/dist/{manifest-B5y82qsH.d.ts → manifest-D7F15gCk.d.ts} +1 -1
  377. package/dist/{manifest-C46GM61W.d.ts → manifest-DGyxea7P.d.ts} +1 -1
  378. package/dist/{manifest-Qa7Oz8op.d.ts → manifest-DJxtzNlO.d.ts} +1 -1
  379. package/dist/{manifest-BFc_Zpzf.d.ts → manifest-DMlBwnAD.d.ts} +1 -1
  380. package/dist/{manifest-DYMvHTJ4.d.ts → manifest-DO6xgonh.d.ts} +1 -1
  381. package/dist/{manifest-D-IfkyQg.d.ts → manifest-DSMOUOS4.d.ts} +1 -1
  382. package/dist/{manifest-C3-OpYr0.d.ts → manifest-DTo6wGdl.d.ts} +1 -1
  383. package/dist/{manifest-YV2wB81I.d.ts → manifest-DWftB4-k.d.ts} +1 -1
  384. package/dist/{manifest-B9FkI5Za.d.ts → manifest-DZujRBYP.d.ts} +1 -1
  385. package/dist/{manifest-BND77-ps.d.ts → manifest-DdASQqwu.d.ts} +1 -1
  386. package/dist/{manifest-CGnYiIs8.d.ts → manifest-DhxLrgXs.d.ts} +1 -1
  387. package/dist/{manifest-z_JoPdSA.d.ts → manifest-DiVRV5uU.d.ts} +1 -1
  388. package/dist/{manifest-B11QNHpO.d.ts → manifest-Dne-vzLU.d.ts} +1 -1
  389. package/dist/{manifest-DIsc4u7U.d.ts → manifest-Dwlal9hp.d.ts} +1 -1
  390. package/dist/{manifest-BQYkGxek.d.ts → manifest-Dyd4YmHX.d.ts} +1 -1
  391. package/dist/{manifest-CE4rGv9r.d.ts → manifest-Fjo0zGvZ.d.ts} +1 -1
  392. package/dist/{manifest-DF6MWZld.d.ts → manifest-PNunwDTR.d.ts} +1 -1
  393. package/dist/{manifest-BBQmMfq7.d.ts → manifest-QK3zY9yE.d.ts} +1 -1
  394. package/dist/{manifest-iwcDpOkG.d.ts → manifest-aUNaGswA.d.ts} +1 -1
  395. package/dist/{manifest-MIOw1h6u.d.ts → manifest-f3YpFDwr.d.ts} +1 -1
  396. package/dist/{manifest-4zuq-I0U.d.ts → manifest-iw_Mj8TT.d.ts} +1 -1
  397. package/dist/{manifest-D_u0Uhd9.d.ts → manifest-r4Qg9IUj.d.ts} +1 -1
  398. package/dist/{manifest-IWiafJCj.d.ts → manifest-rioWw1Xh.d.ts} +1 -1
  399. package/dist/{manifest-4ZM88myP.d.ts → manifest-svAvvbCb.d.ts} +1 -1
  400. package/dist/{manifest-BLkOEccx.d.ts → manifest-vm3Sbqkq.d.ts} +1 -1
  401. package/dist/{manifest-C9Cs9rtL.d.ts → manifest-z8UXpGBO.d.ts} +1 -1
  402. package/dist/mapper/bin.js +6 -6
  403. package/dist/mcp/index.d.ts +1 -1
  404. package/dist/mcp/index.js +1 -1
  405. package/dist/mcp/sdk/index.js +1 -1
  406. package/dist/{mcp-Cif2SnK4.js → mcp-B6AK8gXQ.js} +3 -3
  407. package/dist/next/index.d.ts +5 -5
  408. package/dist/next/index.js +2 -2
  409. package/dist/next/proxy/index.d.ts +2 -2
  410. package/dist/{operations-C4vxakMi.d.ts → operations-B4iP1805.d.ts} +1 -1
  411. package/dist/orpc/index.js +2 -2
  412. package/dist/otel/index.js +5 -5
  413. package/dist/{permissions-CP5Cwz8h.d.ts → permissions-DM2TO3IW.d.ts} +1 -1
  414. package/dist/{ports-ClJbgoyt.js → ports-BfHdHz1e.js} +1 -1
  415. package/dist/{ports-B1QMhbn5.d.ts → ports-CI4MCK_w.d.ts} +1 -1
  416. package/dist/powersync/index.d.ts +2 -2
  417. package/dist/powersync/index.js +1 -1
  418. package/dist/preset/index.d.ts +4 -4
  419. package/dist/preset/index.js +3 -3
  420. package/dist/{preset-BcwGsW_B.js → preset-DrfMF0Hv.js} +2 -2
  421. package/dist/{preview-ByZwgNq9.d.ts → preview-wfts0f_Q.d.ts} +2 -2
  422. package/dist/{project-DYyr_iyu.js → project-MUYG_cjl.js} +5 -5
  423. package/dist/{push-token-BAcQAeb8.d.ts → push-token-BlbHCW_P.d.ts} +1 -1
  424. package/dist/query/index.d.ts +1 -1
  425. package/dist/react/index.d.ts +5 -5
  426. package/dist/react/index.js +1 -1
  427. package/dist/react/native/index.d.ts +1 -1
  428. package/dist/react/server.d.ts +5 -5
  429. package/dist/react/server.js +1 -1
  430. package/dist/{react-hb2gg5UV.js → react-BkLf1aNc.js} +14 -1
  431. package/dist/react-router/index.js +3 -3
  432. package/dist/realtime/index.d.ts +3 -3
  433. package/dist/{record-form-53Hzv9d9.d.ts → record-form-Do_tZhFZ.d.ts} +1 -1
  434. package/dist/records/index.d.ts +7 -7
  435. package/dist/server/index.d.ts +4 -4
  436. package/dist/server/index.js +4 -4
  437. package/dist/{server-B0T944J9.js → server-DpcMKAt_.js} +1 -1
  438. package/dist/{sign-in-DbXRH5zh.d.ts → sign-in-BK0MoYoZ.d.ts} +4 -4
  439. package/dist/solid/index.d.ts +5 -5
  440. package/dist/solid-start/index.js +3 -3
  441. package/dist/spec/index.js +4 -4
  442. package/dist/sql/index.d.ts +5 -5
  443. package/dist/sql/index.js +2 -2
  444. package/dist/{sql-DPpcMNUF.js → sql-DLM5qTve.js} +82 -4
  445. package/dist/sqlite/index.js +1 -1
  446. package/dist/ssr/index.d.ts +1 -1
  447. package/dist/svelte/index.d.ts +5 -5
  448. package/dist/sveltekit/index.js +3 -3
  449. package/dist/tanstack-start/index.js +3 -3
  450. package/dist/{tenant-tAtS31r8.d.ts → tenant-Cue0nAH2.d.ts} +1 -1
  451. package/dist/testing/index.d.ts +6 -6
  452. package/dist/testing/index.js +3 -3
  453. package/dist/{timeline-BoKhn-Ei.d.ts → timeline-BzwEUkAX.d.ts} +2 -2
  454. package/dist/{topic-BdTuoZRL.d.ts → topic-vKeXr5Iq.d.ts} +1 -1
  455. package/dist/{types-D4wgpab9.d.ts → types-BHPiJK75.d.ts} +2 -2
  456. package/dist/{version-B9H4YoiS.js → version-g50CWvKI.js} +1 -1
  457. package/dist/vue/index.d.ts +5 -5
  458. package/dist/{watch-topic-BjkFSiGe.d.ts → watch-topic-DBvJTKe6.d.ts} +1 -1
  459. package/dist/webmcp/index.d.ts +1 -1
  460. package/dist/webmcp/index.js +1 -1
  461. package/dist/yjs/index.d.ts +1 -1
  462. package/package.json +9 -9
  463. package/schemas/config-v1.json +30 -2
  464. package/skills/better-supabase/references/ui-recipes.md +1174 -532
  465. package/dist/cli/add-BpikP7u5.js +0 -1
  466. package/dist/cli/powersync-CEhwfawV.js +0 -1
  467. package/dist/cli/seed-B3MrC1Qe.js +0 -1
@@ -378,124 +378,447 @@ A search dialog over the search index, with favorites and recents before the use
378
378
  Web, with shadcn components:
379
379
 
380
380
  ```bash
381
- npx shadcn add button dialog input
381
+ npx shadcn add button command dialog kbd
382
382
  ```
383
383
 
384
384
  ```bash
385
385
  npx shadcn add @better-supabase/use-search
386
386
  ```
387
387
 
388
- ```tsx title="apps/examples/nextjs/src/features/search/components/command-search.tsx"
388
+ ```tsx title="apps/examples/nextjs/src/features/search/components/command-center.tsx"
389
389
  "use client";
390
390
 
391
- import { SearchIcon } from "lucide-react";
392
- import { useExtracted } from "next-intl";
391
+ import type { LucideIcon } from "lucide-react";
393
392
 
393
+ import { useTheme } from "@wrksz/themes/client";
394
+ import {
395
+ ArrowRightIcon,
396
+ BotIcon,
397
+ ClockIcon,
398
+ CompassIcon,
399
+ LanguagesIcon,
400
+ MonitorIcon,
401
+ MoonIcon,
402
+ PlusIcon,
403
+ RotateCwIcon,
404
+ SearchIcon,
405
+ StarIcon,
406
+ SunIcon,
407
+ UserPlusIcon,
408
+ } from "lucide-react";
409
+ import { hasLocale, useExtracted, useLocale } from "next-intl";
410
+ import { useState } from "react";
411
+
412
+ import type { CommandSearchItem } from "@/hooks/use-search";
413
+
414
+ import { Alert, AlertDescription, AlertTitle } from "@/components/reui/alert";
394
415
  import { Button } from "@/components/ui/button";
395
416
  import {
396
- Dialog,
397
- DialogContent,
398
- DialogDescription,
399
- DialogHeader,
400
- DialogTitle,
401
- } from "@/components/ui/dialog";
402
- import { Input } from "@/components/ui/input";
417
+ CommandDialog,
418
+ Command,
419
+ CommandGroup,
420
+ CommandInput,
421
+ CommandItem,
422
+ CommandList,
423
+ CommandSeparator,
424
+ } from "@/components/ui/command";
425
+ import { Kbd, KbdGroup } from "@/components/ui/kbd";
426
+ import { Skeleton } from "@/components/ui/skeleton";
427
+ import { CreateOrganizationDialog } from "@/features/organization/components/create-organization-dialog";
403
428
  import { useCommandSearch } from "@/hooks/use-search";
404
- import { Link, toAppHref } from "@/i18n/navigation";
429
+ import { usePathname, useRouter, toAppHref } from "@/i18n/navigation";
430
+ import { routing } from "@/i18n/routing";
405
431
  import { searchConfig } from "@/lib/supabase/blocks/slices";
406
432
 
433
+ import { useSubjectTypeLabel } from "../use-subject-type-label";
434
+ import { CommandSearchTrigger } from "./command-search-trigger";
435
+ import { OrganizationCommands } from "./organization-commands";
436
+
437
+ /** A page of the side menu the caller may open. */
438
+ export interface CommandPage {
439
+ readonly id: string;
440
+ /** Without the locale prefix. */
441
+ readonly href: string;
442
+ readonly label: string;
443
+ }
444
+
407
445
  /** The API schema `gen` wrote for the search block. */
408
446
  const API_SCHEMA = searchConfig.api;
409
447
 
410
- /** Cmd+K over the search index: customers by name, plus recents and favorites. */
411
- export function CommandSearch() {
412
- const t = useExtracted("search");
413
- const search = useCommandSearch({ schema: API_SCHEMA });
448
+ /** Pages listed before the user types; typing searches all of them. */
449
+ const PAGES_WHEN_EMPTY = 6;
414
450
 
415
- const heading = (key: string) => {
416
- if (key === "favorites") {
417
- return t("Favorites");
418
- }
451
+ const LOCALE_NAMES = { en: "English", nl: "Nederlands" } as const;
419
452
 
420
- if (key === "recents") {
421
- return t("Recent");
422
- }
453
+ /** Every word of `query` appears in one of the texts. */
454
+ function matches(query: string, ...texts: readonly string[]): boolean {
455
+ const haystack = texts.join(" ").toLowerCase();
456
+
457
+ return query
458
+ .toLowerCase()
459
+ .split(/\s+/)
460
+ .filter((word) => word !== "")
461
+ .every((word) => haystack.includes(word));
462
+ }
463
+
464
+ interface CommandAction {
465
+ readonly id: string;
466
+ readonly label: string;
467
+ readonly keywords: string;
468
+ readonly icon: LucideIcon;
469
+ readonly run: () => void;
470
+ }
471
+
472
+ /**
473
+ * Cmd+K over the app: records from every subject the search block indexes (one
474
+ * call to `search(q)` per typing burst, answered by Postgres under the caller's
475
+ * access), recents and favorites, actions, and the pages of the menu. The code
476
+ * loads on the first intent (ADR 0483), so it stays out of every route's first
477
+ * load.
478
+ */
479
+ export function CommandCenter({
480
+ pages,
481
+ canCreateCustomer,
482
+ }: {
483
+ pages: readonly CommandPage[];
484
+ canCreateCustomer: boolean;
485
+ }) {
486
+ const t = useExtracted("search");
487
+ const typeLabel = useSubjectTypeLabel();
488
+ const router = useRouter();
489
+ const pathname = usePathname();
490
+ const locale = useLocale();
491
+ const { setTheme } = useTheme();
492
+ const [creatingOrganization, setCreatingOrganization] = useState(false);
493
+ const search = useCommandSearch({ schema: API_SCHEMA, limit: 30 });
494
+ const query = search.query.trim();
495
+
496
+ const go = (href: string) => {
497
+ search.setOpen(false);
498
+ router.push(toAppHref(href));
499
+ };
423
500
 
424
- if (key === "customer") {
425
- return t("Customers");
501
+ const open = (item: CommandSearchItem) => {
502
+ if (item.url === null) {
503
+ return;
426
504
  }
427
505
 
428
- return key;
506
+ const href = item.url;
507
+ void search.select(item);
508
+ router.push(toAppHref(href));
429
509
  };
430
510
 
511
+ const actions: readonly CommandAction[] = [
512
+ ...(canCreateCustomer
513
+ ? [
514
+ {
515
+ id: "new-customer",
516
+ label: t("New customer"),
517
+ keywords: t("create add customer"),
518
+ icon: UserPlusIcon,
519
+ run: () => {
520
+ go("/customers?new=1");
521
+ },
522
+ },
523
+ ]
524
+ : []),
525
+ {
526
+ id: "new-organization",
527
+ label: t("Create organization"),
528
+ keywords: t("new organization workspace"),
529
+ icon: PlusIcon,
530
+ run: () => {
531
+ search.setOpen(false);
532
+ setCreatingOrganization(true);
533
+ },
534
+ },
535
+ {
536
+ id: "theme-light",
537
+ label: t("Light theme"),
538
+ keywords: t("theme appearance light"),
539
+ icon: SunIcon,
540
+ run: () => {
541
+ setTheme("light");
542
+ search.setOpen(false);
543
+ },
544
+ },
545
+ {
546
+ id: "theme-dark",
547
+ label: t("Dark theme"),
548
+ keywords: t("theme appearance dark"),
549
+ icon: MoonIcon,
550
+ run: () => {
551
+ setTheme("dark");
552
+ search.setOpen(false);
553
+ },
554
+ },
555
+ {
556
+ id: "theme-system",
557
+ label: t("System theme"),
558
+ keywords: t("theme appearance system"),
559
+ icon: MonitorIcon,
560
+ run: () => {
561
+ setTheme("system");
562
+ search.setOpen(false);
563
+ },
564
+ },
565
+ ...routing.locales
566
+ .filter((option) => option !== locale)
567
+ .map((option) => ({
568
+ id: `locale-${option}`,
569
+ label: t("Switch language to {language}", {
570
+ language: LOCALE_NAMES[option],
571
+ }),
572
+ keywords: t("language locale"),
573
+ icon: LanguagesIcon,
574
+ run: () => {
575
+ search.setOpen(false);
576
+
577
+ if (hasLocale(routing.locales, option)) {
578
+ router.replace(pathname, { locale: option });
579
+ }
580
+ },
581
+ })),
582
+ ];
583
+
584
+ const shownActions =
585
+ query === ""
586
+ ? actions
587
+ : actions.filter((action) =>
588
+ matches(query, action.label, action.keywords),
589
+ );
590
+
591
+ const shownPages =
592
+ query === ""
593
+ ? pages.slice(0, PAGES_WHEN_EMPTY)
594
+ : pages.filter((page) => matches(query, page.label, page.href));
595
+
596
+ const waiting = search.loading && search.results.length === 0;
597
+ const noMatches = query !== "" && !search.loading;
598
+
431
599
  return (
432
600
  <>
433
- <Button
434
- variant="ghost"
435
- size="sm"
436
- aria-label={t("Search")}
437
- aria-keyshortcuts="Meta+K Control+K"
601
+ <CommandSearchTrigger
438
602
  onClick={() => {
439
603
  search.setOpen(true);
440
604
  }}
605
+ />
606
+ <CommandDialog
607
+ open={search.open}
608
+ onOpenChange={search.setOpen}
609
+ title={t("Search")}
610
+ description={t(
611
+ "Find records, run an action or open a page. Press Escape to close.",
612
+ )}
613
+ className="sm:max-w-xl"
441
614
  >
442
- <SearchIcon />
443
- <span className="hidden sm:inline">{t("Search")}</span>
444
- <kbd className="hidden text-xs text-muted-foreground sm:inline">⌘K</kbd>
445
- </Button>
446
- <Dialog open={search.open} onOpenChange={search.setOpen}>
447
- <DialogContent className="gap-4 sm:max-w-lg">
448
- <DialogHeader>
449
- <DialogTitle>{t("Search")}</DialogTitle>
450
- <DialogDescription>
451
- {t("Find a customer by name, even with a typo.")}
452
- </DialogDescription>
453
- </DialogHeader>
454
- <Input
455
- type="search"
615
+ <Command shouldFilter={false} loop>
616
+ <CommandInput
456
617
  value={search.query}
457
- onChange={(event) => {
458
- search.setQuery(event.target.value);
459
- }}
460
- placeholder={t("Search customers")}
461
- aria-label={t("Search customers")}
618
+ onValueChange={search.setQuery}
619
+ placeholder={t("Search records, actions and pages")}
620
+ aria-label={t("Search records, actions and pages")}
462
621
  />
463
- <div className="max-h-80 overflow-y-auto" aria-live="polite">
622
+ <CommandList aria-live="polite">
464
623
  {search.error === undefined ? null : (
465
- <p className="text-sm text-destructive">
466
- {t("Search failed. Try again.")}
467
- </p>
624
+ <div className="p-1">
625
+ <Alert variant="destructive">
626
+ <AlertTitle>{t("Search failed")}</AlertTitle>
627
+ <AlertDescription className="flex items-center justify-between gap-2">
628
+ {t("Records could not load. Actions and pages still work.")}
629
+ <Button
630
+ size="sm"
631
+ variant="outline"
632
+ onClick={() => {
633
+ // The controller queries again only when the trimmed text changes.
634
+ const again = search.query;
635
+ search.setQuery("");
636
+ search.setQuery(again);
637
+ }}
638
+ >
639
+ <RotateCwIcon />
640
+ {t("Retry")}
641
+ </Button>
642
+ </AlertDescription>
643
+ </Alert>
644
+ </div>
468
645
  )}
469
- {search.groups.length === 0 && !search.loading ? (
470
- <p className="text-sm text-muted-foreground">
471
- {search.query.trim() === ""
472
- ? t("Type to search.")
473
- : t("No matches.")}
474
- </p>
475
- ) : null}
476
- {search.groups.map((group) => (
477
- <section key={group.key} className="mb-3">
478
- <h3 className="mb-1 text-xs font-medium text-muted-foreground">
479
- {heading(group.key)}
480
- </h3>
481
- <ul>
482
- {group.items.map((item) => (
483
- <li key={`${item.subjectType}:${item.subjectId}`}>
484
- <Link
485
- href={toAppHref(item.url)}
486
- onClick={() => void search.select(item)}
487
- className="block rounded-md px-2 py-1.5 outline-none hover:bg-muted focus-visible:bg-muted"
646
+
647
+ {query === "" ? (
648
+ <>
649
+ {search.groups.map((group) => (
650
+ <CommandGroup
651
+ key={group.key}
652
+ heading={
653
+ group.key === "favorites" ? t("Favorites") : t("Recent")
654
+ }
655
+ >
656
+ {group.items.map((item) => (
657
+ <CommandItem
658
+ key={`${group.key}:${item.subjectType}:${item.subjectId}`}
659
+ value={`${group.key}:${item.subjectType}:${item.subjectId}`}
660
+ disabled={item.url === null}
661
+ onSelect={() => {
662
+ open(item);
663
+ }}
488
664
  >
489
- {item.title ?? item.subjectId}
490
- </Link>
491
- </li>
665
+ {group.key === "favorites" ? (
666
+ <StarIcon />
667
+ ) : (
668
+ <ClockIcon />
669
+ )}
670
+ <span className="truncate">
671
+ {item.title ?? item.subjectId}
672
+ </span>
673
+ <span className="ml-auto text-xs text-muted-foreground">
674
+ {typeLabel(item.subjectType)}
675
+ </span>
676
+ </CommandItem>
677
+ ))}
678
+ </CommandGroup>
679
+ ))}
680
+ </>
681
+ ) : (
682
+ <>
683
+ {search.groups.map((group) => (
684
+ <CommandGroup key={group.key} heading={typeLabel(group.key)}>
685
+ {group.items.map((item) => (
686
+ <CommandItem
687
+ key={`${item.subjectType}:${item.subjectId}`}
688
+ value={`${item.subjectType}:${item.subjectId}`}
689
+ disabled={item.url === null}
690
+ onSelect={() => {
691
+ open(item);
692
+ }}
693
+ >
694
+ <span className="truncate">
695
+ {item.title ?? item.subjectId}
696
+ </span>
697
+ </CommandItem>
698
+ ))}
699
+ </CommandGroup>
700
+ ))}
701
+ {waiting ? (
702
+ <CommandGroup heading={t("Records")}>
703
+ <div className="flex flex-col gap-2 p-2" aria-busy="true">
704
+ <Skeleton className="h-5 w-3/4" />
705
+ <Skeleton className="h-5 w-1/2" />
706
+ <Skeleton className="h-5 w-2/3" />
707
+ </div>
708
+ </CommandGroup>
709
+ ) : null}
710
+ <CommandGroup>
711
+ <CommandItem
712
+ value={`all:${query}`}
713
+ onSelect={() => {
714
+ go(`/search?q=${encodeURIComponent(query)}`);
715
+ }}
716
+ >
717
+ <SearchIcon />
718
+ {t("See all results for {query}", { query })}
719
+ </CommandItem>
720
+ </CommandGroup>
721
+ </>
722
+ )}
723
+
724
+ {shownActions.length === 0 ? null : (
725
+ <>
726
+ <CommandSeparator />
727
+ <CommandGroup heading={t("Actions")}>
728
+ {shownActions.map((action) => (
729
+ <CommandItem
730
+ key={action.id}
731
+ value={`action:${action.id}`}
732
+ onSelect={action.run}
733
+ >
734
+ <action.icon />
735
+ {action.label}
736
+ </CommandItem>
492
737
  ))}
493
- </ul>
494
- </section>
495
- ))}
738
+ </CommandGroup>
739
+ </>
740
+ )}
741
+
742
+ <OrganizationCommands
743
+ query={query}
744
+ onSwitched={() => {
745
+ search.setOpen(false);
746
+ }}
747
+ />
748
+
749
+ {shownPages.length === 0 ? null : (
750
+ <>
751
+ <CommandSeparator />
752
+ <CommandGroup heading={t("Go to")}>
753
+ {shownPages.map((page) => (
754
+ <CommandItem
755
+ key={page.id}
756
+ value={`page:${page.id}`}
757
+ onPointerEnter={() => {
758
+ router.prefetch(toAppHref(page.href));
759
+ }}
760
+ onSelect={() => {
761
+ go(page.href);
762
+ }}
763
+ >
764
+ <CompassIcon />
765
+ {page.label}
766
+ <ArrowRightIcon className="ml-auto opacity-50" />
767
+ </CommandItem>
768
+ ))}
769
+ </CommandGroup>
770
+ </>
771
+ )}
772
+
773
+ {query === "" ? null : (
774
+ <>
775
+ <CommandSeparator />
776
+ <CommandGroup heading={t("Assistant")}>
777
+ <CommandItem
778
+ value="ask-assistant"
779
+ onSelect={() => {
780
+ go(`/assistant?ask=${encodeURIComponent(query)}`);
781
+ }}
782
+ >
783
+ <BotIcon />
784
+ {t("Ask the assistant: {query}", { query })}
785
+ </CommandItem>
786
+ </CommandGroup>
787
+ </>
788
+ )}
789
+
790
+ {noMatches &&
791
+ search.results.length === 0 &&
792
+ shownActions.length === 0 &&
793
+ shownPages.length === 0 ? (
794
+ <p className="px-3 py-4 text-center text-sm text-muted-foreground">
795
+ {t("No records match. Ask the assistant or see all results.")}
796
+ </p>
797
+ ) : null}
798
+ </CommandList>
799
+ <div className="flex items-center justify-between gap-2 border-t px-3 py-2 text-xs text-muted-foreground">
800
+ <span className="flex items-center gap-1">
801
+ <KbdGroup>
802
+ <Kbd>↑</Kbd>
803
+ <Kbd>↓</Kbd>
804
+ </KbdGroup>
805
+ {t("to move")}
806
+ </span>
807
+ <span className="flex items-center gap-1">
808
+ <Kbd>↵</Kbd>
809
+ {t("to open")}
810
+ </span>
811
+ <span className="flex items-center gap-1">
812
+ <Kbd>Esc</Kbd>
813
+ {t("to close")}
814
+ </span>
496
815
  </div>
497
- </DialogContent>
498
- </Dialog>
816
+ </Command>
817
+ </CommandDialog>
818
+ <CreateOrganizationDialog
819
+ open={creatingOrganization}
820
+ onOpenChange={setCreatingOrganization}
821
+ />
499
822
  </>
500
823
  );
501
824
  }
@@ -2272,6 +2595,7 @@ import { DataGridTable } from "@/components/reui/data-grid/data-grid-table";
2272
2595
  import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar";
2273
2596
  import { Badge } from "@/components/ui/badge";
2274
2597
  import { Button } from "@/components/ui/button";
2598
+ import { Checkbox } from "@/components/ui/checkbox";
2275
2599
  import {
2276
2600
  Empty,
2277
2601
  EmptyContent,
@@ -2400,6 +2724,8 @@ function JoinedCell({ row }: MemberCell) {
2400
2724
  interface MemberActions {
2401
2725
  readonly changeRole: (member: Member, role: Role) => Promise<void>;
2402
2726
  readonly removeMember: (member: Member) => Promise<void>;
2727
+ readonly selected: ReadonlySet<string>;
2728
+ readonly toggle: (userId: string, on: boolean) => void;
2403
2729
  }
2404
2730
 
2405
2731
  const MemberActionsContext = createContext<MemberActions | null>(null);
@@ -2414,6 +2740,29 @@ function useMemberActions(): MemberActions {
2414
2740
  return actions;
2415
2741
  }
2416
2742
 
2743
+ function SelectCell({ row }: MemberCell) {
2744
+ const t = useExtracted("members");
2745
+ const { selected, toggle } = useMemberActions();
2746
+ const member = row.original;
2747
+
2748
+ if (member.roleChoices.length === 0) {
2749
+ return null;
2750
+ }
2751
+
2752
+ return (
2753
+ <Checkbox
2754
+ checked={selected.has(member.userId)}
2755
+ disabled={member.busy}
2756
+ aria-label={t("Select {name}", {
2757
+ name: member.name ?? member.email ?? "",
2758
+ })}
2759
+ onCheckedChange={(checked) => {
2760
+ toggle(member.userId, checked);
2761
+ }}
2762
+ />
2763
+ );
2764
+ }
2765
+
2417
2766
  function RoleCell({ row }: MemberCell) {
2418
2767
  const t = useExtracted("members");
2419
2768
  const roleLabel = useRoleLabel();
@@ -2558,12 +2907,33 @@ export function MemberTable({
2558
2907
  [remove, t, errorMessage],
2559
2908
  );
2560
2909
 
2910
+ const [selected, setSelected] = useState<ReadonlySet<string>>(new Set());
2911
+ const [bulkRole, setBulkRole] = useState<Role | null>(null);
2912
+ const [applying, setApplying] = useState(false);
2913
+
2914
+ const toggle = useCallback((userId: string, on: boolean) => {
2915
+ setSelected((current) => {
2916
+ const next = new Set(current);
2917
+
2918
+ if (on) {
2919
+ next.add(userId);
2920
+ } else {
2921
+ next.delete(userId);
2922
+ }
2923
+
2924
+ return next;
2925
+ });
2926
+ }, []);
2927
+
2561
2928
  const actions = useMemo(
2562
- () => ({ changeRole, removeMember }),
2563
- [changeRole, removeMember],
2929
+ () => ({ changeRole, removeMember, selected, toggle }),
2930
+ [changeRole, removeMember, selected, toggle],
2564
2931
  );
2565
2932
 
2566
2933
  const columns: ColumnDef<ReadOnlyGridFeatures, MemberRow>[] = [
2934
+ ...(canUpdateRole
2935
+ ? [{ id: "select", header: "", cell: SelectCell, size: 40 }]
2936
+ : []),
2567
2937
  { id: "member", header: t("Member"), cell: MemberCellView, size: 280 },
2568
2938
  { accessorKey: "role", header: t("Role"), cell: RoleCell, size: 150 },
2569
2939
  { id: "teams", header: t("Teams"), cell: TeamsCell, size: 200 },
@@ -2604,6 +2974,36 @@ export function MemberTable({
2604
2974
  getRowId: (row) => row.userId,
2605
2975
  });
2606
2976
 
2977
+ const applyBulkRole = async () => {
2978
+ if (!bulkRole) {
2979
+ return;
2980
+ }
2981
+
2982
+ setApplying(true);
2983
+ let changed = 0;
2984
+
2985
+ for (const userId of selected) {
2986
+ const result = await setRole({ userId, role: bulkRole });
2987
+
2988
+ if (result.ok) {
2989
+ changed += 1;
2990
+ } else {
2991
+ toast.error(errorMessage(result.error));
2992
+ }
2993
+ }
2994
+
2995
+ setApplying(false);
2996
+ setSelected(new Set());
2997
+
2998
+ if (changed > 0) {
2999
+ toast.success(
3000
+ t("{count, plural, one {# role updated} other {# roles updated}}", {
3001
+ count: changed,
3002
+ }),
3003
+ );
3004
+ }
3005
+ };
3006
+
2607
3007
  const clearFilters = () => {
2608
3008
  setSearch("");
2609
3009
  setRoleFilter(ALL_ROLES);
@@ -2642,6 +3042,60 @@ export function MemberTable({
2642
3042
  </SelectContent>
2643
3043
  </Select>
2644
3044
  </div>
3045
+ {selected.size > 0 ? (
3046
+ <div
3047
+ className="flex flex-wrap items-center gap-2 rounded-lg border bg-muted/40 p-2"
3048
+ data-testid="members-bulk-bar"
3049
+ >
3050
+ <span className="text-sm">
3051
+ {t("{count, number} selected", { count: selected.size })}
3052
+ </span>
3053
+ <Select
3054
+ value={bulkRole}
3055
+ items={assignable.map((role) => ({
3056
+ value: role,
3057
+ label: roleLabel(role),
3058
+ }))}
3059
+ onValueChange={(value) => {
3060
+ setBulkRole(v.is(Role, value) ? value : null);
3061
+ }}
3062
+ >
3063
+ <SelectTrigger
3064
+ size="sm"
3065
+ className="w-40"
3066
+ aria-label={t("New role")}
3067
+ >
3068
+ <SelectValue placeholder={t("Change role to")} />
3069
+ </SelectTrigger>
3070
+ <SelectContent>
3071
+ {assignable.map((role) => (
3072
+ <SelectItem key={role} value={role}>
3073
+ {roleLabel(role)}
3074
+ </SelectItem>
3075
+ ))}
3076
+ </SelectContent>
3077
+ </Select>
3078
+ <Button
3079
+ size="sm"
3080
+ disabled={!bulkRole || applying}
3081
+ onClick={() => {
3082
+ void applyBulkRole();
3083
+ }}
3084
+ >
3085
+ {t("Apply")}
3086
+ </Button>
3087
+ <Button
3088
+ size="sm"
3089
+ variant="ghost"
3090
+ disabled={applying}
3091
+ onClick={() => {
3092
+ setSelected(new Set());
3093
+ }}
3094
+ >
3095
+ {t("Clear selection")}
3096
+ </Button>
3097
+ </div>
3098
+ ) : null}
2645
3099
  <div data-testid="members">
2646
3100
  <DataGrid
2647
3101
  table={table}
@@ -4351,34 +4805,44 @@ export function TwoFactorCard({
4351
4805
 
4352
4806
  ## Inbox with threads
4353
4807
 
4354
- A shared inbox of conversations with status tabs, an assignee filter and the open thread beside the list. It calls `useInbox` from `@/hooks/use-inbox`; the [inbox block](https://bettersupabase.com/blocks/inbox) must be installed (`npx better-supabase add inbox`). Page: https://bettersupabase.com/recipes/inbox-threads.
4808
+ A shared inbox queue with search and status, assignee and channel filters in the URL; each row opens its thread beside the list. It calls `useInbox` from `@/hooks/use-inbox`; the [inbox block](https://bettersupabase.com/blocks/inbox) must be installed (`npx better-supabase add inbox`). Page: https://bettersupabase.com/recipes/inbox-threads.
4355
4809
 
4356
4810
  Web, with shadcn components:
4357
4811
 
4358
4812
  ```bash
4359
- npx shadcn add badge empty select tabs
4813
+ npx shadcn add badge button empty input select skeleton
4360
4814
  ```
4361
4815
 
4362
4816
  ```bash
4363
4817
  npx shadcn add @better-supabase/use-inbox
4364
4818
  ```
4365
4819
 
4366
- ```tsx title="apps/examples/nextjs/src/features/inbox/components/inbox-view.tsx"
4820
+ ```tsx title="apps/examples/nextjs/src/features/inbox/components/conversation-queue.tsx"
4367
4821
  "use client";
4368
4822
 
4369
- import { InboxIcon } from "lucide-react";
4370
- import { useExtracted, useFormatter } from "next-intl";
4371
- import { useState } from "react";
4372
- import * as v from "valibot";
4823
+ import { useAction } from "better-supabase/react";
4824
+ import { InboxIcon, SearchIcon } from "lucide-react";
4825
+ import { useExtracted, useFormatter, useNow } from "next-intl";
4826
+ import { useParams } from "next/navigation";
4827
+ import {
4828
+ debounce,
4829
+ parseAsString,
4830
+ parseAsStringLiteral,
4831
+ useQueryStates,
4832
+ } from "nuqs";
4833
+ import { useEffect, useEffectEvent, useState } from "react";
4373
4834
 
4374
- import { Badge } from "@/components/ui/badge";
4835
+ import { Badge } from "@/components/reui/badge";
4836
+ import { Button } from "@/components/ui/button";
4375
4837
  import {
4376
4838
  Empty,
4839
+ EmptyContent,
4377
4840
  EmptyDescription,
4378
4841
  EmptyHeader,
4379
4842
  EmptyMedia,
4380
4843
  EmptyTitle,
4381
4844
  } from "@/components/ui/empty";
4845
+ import { Input } from "@/components/ui/input";
4382
4846
  import {
4383
4847
  Select,
4384
4848
  SelectContent,
@@ -4386,18 +4850,34 @@ import {
4386
4850
  SelectTrigger,
4387
4851
  SelectValue,
4388
4852
  } from "@/components/ui/select";
4389
- import { Tabs, TabsList, TabsTrigger } from "@/components/ui/tabs";
4853
+ import { Skeleton } from "@/components/ui/skeleton";
4390
4854
  import { useInbox } from "@/hooks/use-inbox";
4855
+ import { Link, toAppHref } from "@/i18n/navigation";
4391
4856
  import { cn } from "@/lib/utils";
4392
4857
 
4393
- import type { ConversationRow } from "../inbox-types";
4858
+ import type { ConversationRow, InboxSummary } from "../inbox-types";
4394
4859
 
4395
- import { loadConversations } from "../inbox-actions";
4860
+ import { loadConversations, loadInboxes } from "../inbox-actions";
4396
4861
  import { unwrap } from "../inbox-load";
4397
- import { AssigneeFilter, ConversationStatus } from "../inbox-types";
4398
- import { ConversationPanel } from "./conversation-panel";
4862
+ import { QUEUE_ASSIGNEES, QUEUE_STATUSES, slaStateOf } from "../inbox-types";
4863
+ import { ChannelBadge, SlaBadge } from "./conversation-badges";
4399
4864
 
4400
- export function InboxView({
4865
+ const ALL_CHANNELS = "all";
4866
+
4867
+ const queueParsers = {
4868
+ q: parseAsString.withDefault(""),
4869
+ status: parseAsStringLiteral(QUEUE_STATUSES).withDefault("open"),
4870
+ assignee: parseAsStringLiteral(QUEUE_ASSIGNEES).withDefault("anyone"),
4871
+ channel: parseAsString.withDefault(""),
4872
+ };
4873
+
4874
+ /**
4875
+ * The conversation queue: search, status, assignee and channel run in the
4876
+ * database (`loadConversations`), the filters live in the URL, and Realtime
4877
+ * pings reload the list without refetching the page. A row links to
4878
+ * `/inbox/<id>` and keeps the filters, so the thread opens beside the queue.
4879
+ */
4880
+ export function ConversationQueue({
4401
4881
  organizationId,
4402
4882
  initial,
4403
4883
  }: {
@@ -4405,187 +4885,372 @@ export function InboxView({
4405
4885
  initial: readonly ConversationRow[];
4406
4886
  }) {
4407
4887
  const t = useExtracted("inbox");
4408
- const [status, setStatus] = useState<ConversationStatus>("open");
4409
- const [assignee, setAssignee] = useState<AssigneeFilter>("anyone");
4410
- const [selected, setSelected] = useState<string | null>(null);
4888
+
4889
+ const [filters, setFilters] = useQueryStates(queueParsers, {
4890
+ limitUrlUpdates: debounce(300),
4891
+ });
4892
+
4893
+ const inboxes = useAction(loadInboxes);
4894
+
4895
+ const loadChannels = useEffectEvent(() => {
4896
+ void inboxes.run(undefined);
4897
+ });
4898
+
4899
+ useEffect(() => {
4900
+ loadChannels();
4901
+ }, []);
4902
+
4903
+ const channelItems = [
4904
+ { value: ALL_CHANNELS, label: t("All channels") },
4905
+ ...(inboxes.data ?? []).map((inbox: InboxSummary) => ({
4906
+ value: inbox.id,
4907
+ label: inbox.name,
4908
+ })),
4909
+ ];
4910
+
4911
+ const statusItems = [
4912
+ { value: "open", label: t("Open") },
4913
+ { value: "pending", label: t("Pending") },
4914
+ { value: "snoozed", label: t("Snoozed") },
4915
+ { value: "resolved", label: t("Resolved") },
4916
+ { value: "all", label: t("All statuses") },
4917
+ ];
4411
4918
 
4412
4919
  const assigneeItems = [
4413
4920
  { value: "anyone", label: t("Anyone") },
4414
4921
  { value: "me", label: t("Mine") },
4415
4922
  { value: "unassigned", label: t("Unassigned") },
4416
- ] satisfies readonly { value: AssigneeFilter; label: string }[];
4923
+ ];
4924
+
4925
+ const isDefault =
4926
+ filters.status === "open" &&
4927
+ filters.assignee === "anyone" &&
4928
+ filters.channel === "" &&
4929
+ filters.q === "";
4417
4930
 
4418
4931
  return (
4419
- <div className="grid min-h-128 gap-4 lg:grid-cols-3">
4420
- <section aria-label={t("Conversations")} className="space-y-3">
4421
- <div className="flex flex-wrap items-center gap-2">
4422
- <Tabs
4423
- value={status}
4424
- onValueChange={(value) => {
4425
- if (!v.is(ConversationStatus, value)) {
4426
- return;
4427
- }
4932
+ <section
4933
+ aria-label={t("Conversations")}
4934
+ className="flex h-full min-h-0 flex-col gap-3 p-3"
4935
+ >
4936
+ <div className="relative">
4937
+ <SearchIcon
4938
+ aria-hidden
4939
+ className="pointer-events-none absolute top-1/2 left-2.5 size-4 -translate-y-1/2 text-muted-foreground"
4940
+ />
4941
+ <Input
4942
+ type="search"
4943
+ value={filters.q}
4944
+ placeholder={t("Search conversations")}
4945
+ aria-label={t("Search conversations")}
4946
+ className="pl-8"
4947
+ onChange={(event) => {
4948
+ void setFilters({ q: event.target.value });
4949
+ }}
4950
+ />
4951
+ </div>
4952
+ <div className="grid grid-cols-2 gap-2">
4953
+ <Select
4954
+ value={filters.status}
4955
+ items={statusItems}
4956
+ onValueChange={(value) => {
4957
+ const status = QUEUE_STATUSES.find((item) => item === value);
4428
4958
 
4429
- setStatus(value);
4430
- }}
4431
- >
4432
- <TabsList>
4433
- <TabsTrigger value="open">{t("Open")}</TabsTrigger>
4434
- <TabsTrigger value="pending">{t("Pending")}</TabsTrigger>
4435
- <TabsTrigger value="resolved">{t("Resolved")}</TabsTrigger>
4436
- <TabsTrigger value="all">{t("All")}</TabsTrigger>
4437
- </TabsList>
4438
- </Tabs>
4439
- <Select
4440
- value={assignee}
4441
- items={assigneeItems}
4442
- onValueChange={(value) => {
4443
- if (!v.is(AssigneeFilter, value)) {
4444
- return;
4445
- }
4959
+ if (status !== undefined) {
4960
+ void setFilters({ status });
4961
+ }
4962
+ }}
4963
+ >
4964
+ <SelectTrigger size="sm" className="w-full" aria-label={t("Status")}>
4965
+ <SelectValue />
4966
+ </SelectTrigger>
4967
+ <SelectContent>
4968
+ {statusItems.map((item) => (
4969
+ <SelectItem key={item.value} value={item.value}>
4970
+ {item.label}
4971
+ </SelectItem>
4972
+ ))}
4973
+ </SelectContent>
4974
+ </Select>
4975
+ <Select
4976
+ value={filters.assignee}
4977
+ items={assigneeItems}
4978
+ onValueChange={(value) => {
4979
+ const assignee = QUEUE_ASSIGNEES.find((item) => item === value);
4446
4980
 
4447
- setAssignee(value);
4448
- }}
4981
+ if (assignee !== undefined) {
4982
+ void setFilters({ assignee });
4983
+ }
4984
+ }}
4985
+ >
4986
+ <SelectTrigger
4987
+ size="sm"
4988
+ className="flex-1"
4989
+ aria-label={t("Assignee")}
4449
4990
  >
4450
- <SelectTrigger
4451
- size="sm"
4452
- className="w-32"
4453
- aria-label={t("Assignee")}
4454
- >
4455
- <SelectValue />
4456
- </SelectTrigger>
4457
- <SelectContent>
4458
- {assigneeItems.map((item) => (
4459
- <SelectItem key={item.value} value={item.value}>
4460
- {item.label}
4461
- </SelectItem>
4462
- ))}
4463
- </SelectContent>
4464
- </Select>
4465
- </div>
4466
- <ConversationList
4467
- key={`${status}:${assignee}`}
4468
- organizationId={organizationId}
4469
- status={status}
4470
- assignee={assignee}
4471
- initial={status === "open" && assignee === "anyone" ? initial : []}
4472
- selected={selected}
4473
- onSelect={setSelected}
4474
- />
4475
- </section>
4476
- {selected === null ? (
4477
- <Empty className="border lg:col-span-2">
4478
- <EmptyHeader>
4479
- <EmptyTitle>{t("Pick a conversation")}</EmptyTitle>
4480
- <EmptyDescription>
4481
- {t("Its messages, notes and actions show here.")}
4482
- </EmptyDescription>
4483
- </EmptyHeader>
4484
- </Empty>
4485
- ) : (
4486
- <div className="lg:col-span-2">
4487
- <ConversationPanel key={selected} conversationId={selected} />
4488
- </div>
4489
- )}
4490
- </div>
4991
+ <SelectValue />
4992
+ </SelectTrigger>
4993
+ <SelectContent>
4994
+ {assigneeItems.map((item) => (
4995
+ <SelectItem key={item.value} value={item.value}>
4996
+ {item.label}
4997
+ </SelectItem>
4998
+ ))}
4999
+ </SelectContent>
5000
+ </Select>
5001
+ <Select
5002
+ value={filters.channel === "" ? ALL_CHANNELS : filters.channel}
5003
+ items={channelItems}
5004
+ onValueChange={(value) => {
5005
+ void setFilters({
5006
+ channel: value === null || value === ALL_CHANNELS ? "" : value,
5007
+ });
5008
+ }}
5009
+ >
5010
+ <SelectTrigger
5011
+ size="sm"
5012
+ className="col-span-2 w-full"
5013
+ aria-label={t("Channel")}
5014
+ >
5015
+ <SelectValue />
5016
+ </SelectTrigger>
5017
+ <SelectContent>
5018
+ {channelItems.map((item) => (
5019
+ <SelectItem key={item.value} value={item.value}>
5020
+ {item.label}
5021
+ </SelectItem>
5022
+ ))}
5023
+ </SelectContent>
5024
+ </Select>
5025
+ </div>
5026
+ <QueueRows
5027
+ key={`${filters.status}:${filters.assignee}:${filters.channel}:${filters.q}`}
5028
+ organizationId={organizationId}
5029
+ status={filters.status}
5030
+ assignee={filters.assignee}
5031
+ channel={filters.channel}
5032
+ q={filters.q}
5033
+ initial={isDefault ? initial : null}
5034
+ onClear={() => {
5035
+ void setFilters({
5036
+ q: "",
5037
+ status: "open",
5038
+ assignee: "anyone",
5039
+ channel: "",
5040
+ });
5041
+ }}
5042
+ />
5043
+ </section>
4491
5044
  );
4492
5045
  }
4493
5046
 
4494
- function ConversationList({
5047
+ const PAGE_SIZE = 40;
5048
+
5049
+ function QueueRows({
4495
5050
  organizationId,
4496
5051
  status,
4497
5052
  assignee,
5053
+ channel,
5054
+ q,
4498
5055
  initial,
4499
- selected,
4500
- onSelect,
5056
+ onClear,
4501
5057
  }: {
4502
5058
  organizationId: string;
4503
- status: ConversationStatus;
4504
- assignee: AssigneeFilter;
4505
- initial: readonly ConversationRow[];
4506
- selected: string | null;
4507
- onSelect: (id: string) => void;
5059
+ status: ConversationRow["status"] | "all";
5060
+ assignee: (typeof QUEUE_ASSIGNEES)[number];
5061
+ channel: string;
5062
+ q: string;
5063
+ initial: readonly ConversationRow[] | null;
5064
+ onClear: () => void;
4508
5065
  }) {
4509
5066
  const t = useExtracted("inbox");
4510
5067
  const format = useFormatter();
5068
+ const selected = useParams<{ conversation?: string }>().conversation;
5069
+ const [search] = useQueryStates(queueParsers);
5070
+ const [more, setMore] = useState<readonly ConversationRow[]>([]);
5071
+ const nowDate = useNow({ updateInterval: 60_000 });
5072
+ const now = nowDate.getTime();
4511
5073
 
4512
5074
  const inbox = useInbox({
4513
5075
  organizationId,
4514
- load: async () => unwrap(await loadConversations({ status, assignee })),
5076
+ load: async () =>
5077
+ unwrap(await loadConversations({ status, assignee, channel, q })),
4515
5078
  });
4516
5079
 
4517
- const conversations = inbox.items ?? initial;
5080
+ const next = useAction(loadConversations);
4518
5081
 
4519
- // Staff reads send no broadcast, so an opened conversation clears its badge here.
4520
- const [openedAt, setOpenedAt] = useState<ReadonlyMap<string, number>>(
4521
- () => new Map(),
4522
- );
5082
+ const first = inbox.items ?? initial;
5083
+
5084
+ if (first === null) {
5085
+ return inbox.error === undefined || inbox.error === null ? (
5086
+ <QueueSkeleton />
5087
+ ) : (
5088
+ <Empty className="border">
5089
+ <EmptyHeader>
5090
+ <EmptyTitle>{t("The queue did not load")}</EmptyTitle>
5091
+ <EmptyDescription>
5092
+ {inbox.error instanceof Error
5093
+ ? inbox.error.message
5094
+ : t("Check your connection and try again.")}
5095
+ </EmptyDescription>
5096
+ </EmptyHeader>
5097
+ <EmptyContent>
5098
+ <Button
5099
+ variant="outline"
5100
+ size="sm"
5101
+ onClick={() => {
5102
+ void inbox.refresh();
5103
+ }}
5104
+ >
5105
+ {t("Retry")}
5106
+ </Button>
5107
+ </EmptyContent>
5108
+ </Empty>
5109
+ );
5110
+ }
5111
+
5112
+ const rows = [...first, ...more];
5113
+ const last = rows.at(-1);
5114
+ const hasMore = first.length >= PAGE_SIZE && more.length % PAGE_SIZE === 0;
5115
+
5116
+ const query = new URLSearchParams();
4523
5117
 
4524
- const unread = (conversation: ConversationRow): boolean => {
4525
- const opened = openedAt.get(conversation.id);
5118
+ if (search.q !== "") {
5119
+ query.set("q", search.q);
5120
+ }
5121
+
5122
+ if (search.status !== "open") {
5123
+ query.set("status", search.status);
5124
+ }
4526
5125
 
5126
+ if (search.assignee !== "anyone") {
5127
+ query.set("assignee", search.assignee);
5128
+ }
5129
+
5130
+ if (search.channel !== "") {
5131
+ query.set("channel", search.channel);
5132
+ }
5133
+
5134
+ const suffix = query.size === 0 ? "" : `?${query.toString()}`;
5135
+
5136
+ if (rows.length === 0) {
4527
5137
  return (
4528
- conversation.unread &&
4529
- (opened === undefined ||
4530
- (conversation.lastMessageAt !== null &&
4531
- Date.parse(conversation.lastMessageAt) > opened))
5138
+ <Empty className="border">
5139
+ <EmptyHeader>
5140
+ <EmptyMedia variant="icon">
5141
+ <InboxIcon />
5142
+ </EmptyMedia>
5143
+ <EmptyTitle>{t("No conversations")}</EmptyTitle>
5144
+ <EmptyDescription>
5145
+ {t(
5146
+ "Nothing matches these filters. Clear them, or use the simulator to receive a message.",
5147
+ )}
5148
+ </EmptyDescription>
5149
+ </EmptyHeader>
5150
+ <EmptyContent>
5151
+ <Button variant="outline" size="sm" onClick={onClear}>
5152
+ {t("Clear filters")}
5153
+ </Button>
5154
+ </EmptyContent>
5155
+ </Empty>
4532
5156
  );
4533
- };
5157
+ }
4534
5158
 
4535
- return conversations.length === 0 ? (
4536
- <Empty className="border">
4537
- <EmptyHeader>
4538
- <EmptyMedia variant="icon">
4539
- <InboxIcon />
4540
- </EmptyMedia>
4541
- <EmptyTitle>{t("No conversations")}</EmptyTitle>
4542
- <EmptyDescription>
4543
- {t("Open Help in the header to start one as a customer.")}
4544
- </EmptyDescription>
4545
- </EmptyHeader>
4546
- </Empty>
4547
- ) : (
4548
- <ul className="divide-y rounded-xl border">
4549
- {conversations.map((conversation) => (
4550
- <li key={conversation.id}>
4551
- <button
4552
- type="button"
4553
- aria-current={selected === conversation.id ? "true" : undefined}
4554
- className={cn(
4555
- "flex w-full flex-col gap-1 px-4 py-3 text-left text-sm hover:bg-muted/50",
4556
- selected === conversation.id && "bg-muted",
4557
- )}
5159
+ return (
5160
+ <ul className="-mx-3 min-h-0 flex-1 divide-y overflow-y-auto border-y">
5161
+ {rows.map((conversation) => {
5162
+ const sla = slaStateOf(conversation, now);
5163
+
5164
+ return (
5165
+ <li key={conversation.id}>
5166
+ <Link
5167
+ href={toAppHref(`/inbox/${conversation.id}${suffix}`)}
5168
+ aria-current={selected === conversation.id ? "page" : undefined}
5169
+ prefetch={false}
5170
+ className={cn(
5171
+ "flex flex-col gap-1 px-3 py-3 text-sm transition-colors hover:bg-muted/50",
5172
+ selected === conversation.id && "bg-muted",
5173
+ )}
5174
+ >
5175
+ <span className="flex items-center gap-2">
5176
+ <span
5177
+ className={cn(
5178
+ "flex-1 truncate",
5179
+ conversation.unread ? "font-semibold" : "font-medium",
5180
+ )}
5181
+ >
5182
+ {conversation.contactName || t("Visitor")}
5183
+ </span>
5184
+ {conversation.unread ? (
5185
+ <Badge variant="primary-light">{t("New")}</Badge>
5186
+ ) : null}
5187
+ {conversation.lastMessageAt ? (
5188
+ <span className="text-xs text-muted-foreground tabular-nums">
5189
+ {format.relativeTime(
5190
+ new Date(conversation.lastMessageAt),
5191
+ now,
5192
+ )}
5193
+ </span>
5194
+ ) : null}
5195
+ </span>
5196
+ <span className="truncate">
5197
+ {conversation.subject ?? t("No subject")}
5198
+ </span>
5199
+ <span className="truncate text-xs text-muted-foreground">
5200
+ {conversation.preview}
5201
+ </span>
5202
+ <span className="flex flex-wrap items-center gap-1">
5203
+ <ChannelBadge channel={conversation.channel} />
5204
+ <SlaBadge state={sla} />
5205
+ {conversation.assigneeId === null ? (
5206
+ <Badge variant="secondary">{t("Unassigned")}</Badge>
5207
+ ) : null}
5208
+ {conversation.botMode === "bot" ? (
5209
+ <Badge variant="secondary">{t("Bot")}</Badge>
5210
+ ) : null}
5211
+ </span>
5212
+ </Link>
5213
+ </li>
5214
+ );
5215
+ })}
5216
+ {hasMore && last ? (
5217
+ <li className="p-3">
5218
+ <Button
5219
+ variant="outline"
5220
+ size="sm"
5221
+ className="w-full"
5222
+ disabled={next.pending}
4558
5223
  onClick={() => {
4559
- setOpenedAt((current) =>
4560
- new Map(current).set(conversation.id, Date.now()),
4561
- );
4562
- onSelect(conversation.id);
5224
+ void next
5225
+ .run({
5226
+ status,
5227
+ assignee,
5228
+ channel,
5229
+ q,
5230
+ cursor: { id: last.id, lastMessageAt: last.lastMessageAt },
5231
+ })
5232
+ .then((result) => {
5233
+ if (result.ok) {
5234
+ setMore((current) => [...current, ...result.data]);
5235
+ }
5236
+ });
4563
5237
  }}
4564
5238
  >
4565
- <span className="flex items-center gap-2">
4566
- <span className="flex-1 truncate font-medium">
4567
- {conversation.contactName || t("Visitor")}
4568
- </span>
4569
- {unread(conversation) ? <Badge>{t("New")}</Badge> : null}
4570
- </span>
4571
- <span className="truncate">
4572
- {conversation.subject ?? t("No subject")}
4573
- </span>
4574
- <span className="flex gap-2 text-xs text-muted-foreground">
4575
- <span className="flex-1 truncate">{conversation.preview}</span>
4576
- {conversation.lastMessageAt ? (
4577
- <span className="tabular-nums">
4578
- {format.dateTime(new Date(conversation.lastMessageAt), {
4579
- dateStyle: "short",
4580
- timeStyle: "short",
4581
- })}
4582
- </span>
4583
- ) : null}
4584
- </span>
4585
- </button>
5239
+ {t("Load more")}
5240
+ </Button>
4586
5241
  </li>
5242
+ ) : null}
5243
+ </ul>
5244
+ );
5245
+ }
5246
+
5247
+ export function QueueSkeleton() {
5248
+ return (
5249
+ <div className="flex flex-col gap-2" aria-busy="true">
5250
+ {Array.from({ length: 6 }, (_, index) => (
5251
+ <Skeleton key={index} className="h-20 w-full" />
4587
5252
  ))}
4588
- </ul>
5253
+ </div>
4589
5254
  );
4590
5255
  }
4591
5256
  ```
@@ -5877,32 +6542,66 @@ import { useState } from "react";
5877
6542
 
5878
6543
  import { Button } from "@/components/ui/button";
5879
6544
 
6545
+ import type { MessageBranch, ModelOption } from "../assistant-queries";
6546
+
6547
+ import { switchChatBranch } from "../assistant-actions";
5880
6548
  import { ChatView } from "./chat-view";
5881
6549
 
6550
+ const NO_MODELS: readonly ModelOption[] = [];
6551
+ const NO_BRANCHES: readonly MessageBranch[] = [];
6552
+
5882
6553
  export type ChatMode = "standard" | "durable" | "research";
5883
6554
 
5884
6555
  interface PanelProps {
5885
6556
  readonly id: string;
5886
6557
  readonly messages: UIMessage[];
5887
6558
  readonly streaming: boolean;
6559
+ readonly models: readonly ModelOption[];
6560
+ readonly model: string | undefined;
6561
+ readonly onModelChange: (model: string) => void;
6562
+ readonly branches: readonly MessageBranch[];
5888
6563
  }
5889
6564
 
5890
6565
  /**
5891
6566
  * The answer streams from the request; a reload picks it up from the stream
5892
6567
  * store.
5893
6568
  */
5894
- function StandardPanel({ id, messages }: PanelProps) {
6569
+ function StandardPanel({
6570
+ id,
6571
+ messages,
6572
+ models,
6573
+ model,
6574
+ onModelChange,
6575
+ branches,
6576
+ }: PanelProps) {
5895
6577
  const router = useRouter();
5896
6578
 
5897
6579
  const chat = useAssistant({
5898
6580
  id,
5899
6581
  messages,
6582
+ ...(model === undefined ? {} : { model }),
5900
6583
  onFinish: () => {
5901
6584
  router.refresh();
5902
6585
  },
5903
6586
  });
5904
6587
 
5905
- return <ChatView id={id} chat={chat} />;
6588
+ return (
6589
+ <ChatView
6590
+ id={id}
6591
+ chat={chat}
6592
+ models={models}
6593
+ {...(model === undefined ? {} : { model })}
6594
+ onModelChange={onModelChange}
6595
+ branches={branches}
6596
+ onSwitchBranch={(messageId) => {
6597
+ void switchChatBranch({ chatId: id, messageId }).then(() => {
6598
+ router.refresh();
6599
+ });
6600
+ }}
6601
+ uploads
6602
+ rating
6603
+ />
6604
+ );
5906
6605
  }
5907
6606
 
5908
6607
  /**
@@ -5928,7 +6627,7 @@ function DurablePanel({
5928
6627
  },
5929
6628
  });
5930
6629
 
5931
- return <ChatView id={id} chat={chat} />;
6630
+ return <ChatView id={id} chat={chat} uploads rating />;
5932
6631
  }
5933
6632
 
5934
6633
  /**
@@ -5941,12 +6640,18 @@ export function AssistantChat({
5941
6640
  streaming = false,
5942
6641
  initialMode = "standard",
5943
6642
  durableAvailable,
6643
+ models = NO_MODELS,
6644
+ initialModel,
6645
+ branches = NO_BRANCHES,
5944
6646
  }: {
5945
6647
  id: string;
5946
6648
  messages: UIMessage[];
5947
6649
  streaming?: boolean;
5948
6650
  initialMode?: ChatMode;
5949
6651
  durableAvailable: boolean;
6652
+ models?: readonly ModelOption[];
6653
+ initialModel?: string | undefined;
6654
+ branches?: readonly MessageBranch[];
5950
6655
  }) {
5951
6656
  const t = useExtracted("assistant");
5952
6657
 
@@ -5960,7 +6665,19 @@ export function AssistantChat({
5960
6665
  { mode: "research", label: t("Research") },
5961
6666
  ];
5962
6667
 
5963
- const panel = { id, messages, streaming };
6668
+ const [model, setModel] = useState<string | undefined>(
6669
+ initialModel ?? models[0]?.id,
6670
+ );
6671
+
6672
+ const panel = {
6673
+ id,
6674
+ messages,
6675
+ streaming,
6676
+ models,
6677
+ model,
6678
+ onModelChange: setModel,
6679
+ branches,
6680
+ };
5964
6681
 
5965
6682
  return (
5966
6683
  <div className="flex flex-col gap-3">
@@ -6752,7 +7469,7 @@ export function WorkflowRuns({ tenant }: { tenant: string | null }) {
6752
7469
  <TableRow key={run.id}>
6753
7470
  <TableCell>
6754
7471
  <Link
6755
- href={`/workflows/${run.id}`}
7472
+ href={`/workflows/runs/${run.id}`}
6756
7473
  prefetch
6757
7474
  className="font-medium"
6758
7475
  >
@@ -12159,7 +12876,16 @@ export async function ContactDetail({ id }: { id: string }) {
12159
12876
  </CardContent>
12160
12877
  </Card>
12161
12878
  <Suspense fallback={<ActivityTimelineSkeleton />}>
12162
- <ActivityTimeline subject={{ type: contact.kind, id: contact.id }} />
12879
+ <AfterNavigation>
12880
+ <ActivityTimeline
12881
+ subject={{ type: contact.kind, id: contact.id }}
12882
+ />
12883
+ </AfterNavigation>
12884
+ </Suspense>
12885
+ <Suspense fallback={<ContactSalesPanelSkeleton />}>
12886
+ <AfterNavigation>
12887
+ <ContactSalesPanel type={contact.kind} id={contact.id} />
12888
+ </AfterNavigation>
12163
12889
  </Suspense>
12164
12890
  </div>
12165
12891
  {contact.kind === "company" ? (
@@ -13435,7 +14161,57 @@ export function WorkItemGrid({
13435
14161
  const sortLabel = useSortLabel();
13436
14162
  const [navigating, startTransition] = useTransition();
13437
14163
  const [search, setSearch] = useState(query.q);
13438
- const [selected, setSelected] = useState<ReadonlySet<string>>(new Set());
14164
+ // The controller outlives renders, so it reads the latest message formatter.
14165
+ const latestErrorMessage = useLatest(errorMessage);
14166
+
14167
+ const { view: bulk } = useController(
14168
+ () =>
14169
+ createBulkSelectionController({
14170
+ run: async ({ rows: ids, action, args }) => {
14171
+ const to = WORK_ITEM_STATES.find((state) => state === args?.["to"]);
14172
+
14173
+ const result = await runWorkBulkAction(
14174
+ action === "state" && to !== undefined
14175
+ ? { action: "state", ids: [...ids], to }
14176
+ : { action: "delete", ids: [...ids] },
14177
+ );
14178
+
14179
+ if (!result.ok) {
14180
+ toast.error(latestErrorMessage.current(result.error));
14181
+ throw new Error(result.error.message);
14182
+ }
14183
+
14184
+ const failed = new Map(
14185
+ result.data.failed.map((row) => [row.id, row]),
14186
+ );
14187
+
14188
+ return {
14189
+ mode: "now",
14190
+ total: result.data.total,
14191
+ succeeded: result.data.succeeded,
14192
+ failed: failed.size,
14193
+ results: ids.map((id) => {
14194
+ const row = failed.get(id);
14195
+
14196
+ return {
14197
+ id,
14198
+ ok: row === undefined,
14199
+ error: row
14200
+ ? {
14201
+ code: row.code ?? undefined,
14202
+ message: row.message,
14203
+ sqlstate: undefined,
14204
+ }
14205
+ : null,
14206
+ };
14207
+ }),
14208
+ };
14209
+ },
14210
+ }),
14211
+ [latestErrorMessage],
14212
+ );
14213
+
14214
+ const selected = new Set(bulk.selected);
13439
14215
 
13440
14216
  const onEditError = (error: DbError) => {
13441
14217
  toast.error(workErrorHint(error.hint) ?? errorMessage(error));
@@ -13607,14 +14383,7 @@ export function WorkItemGrid({
13607
14383
  )}
13608
14384
  </div>
13609
14385
  </div>
13610
- {canBulk ? (
13611
- <BulkActionBar
13612
- selected={selectedRows}
13613
- onSettled={(failedIds) => {
13614
- setSelected(new Set(failedIds));
13615
- }}
13616
- />
13617
- ) : null}
14386
+ {canBulk ? <BulkActionBar selected={selectedRows} bulk={bulk} /> : null}
13618
14387
  <Table>
13619
14388
  <TableHeader>
13620
14389
  <TableRow>
@@ -13625,9 +14394,11 @@ export function WorkItemGrid({
13625
14394
  indeterminate={selection.length > 0 && !allSelected}
13626
14395
  aria-label={t("Select all")}
13627
14396
  onCheckedChange={(checked) => {
13628
- setSelected(
13629
- checked ? new Set(rows.map((row) => row.id)) : new Set(),
13630
- );
14397
+ if (checked) {
14398
+ bulk.selectMany(rows.map((row) => row.id));
14399
+ } else {
14400
+ bulk.clear();
14401
+ }
13631
14402
  }}
13632
14403
  />
13633
14404
  </TableHead>
@@ -13666,17 +14437,11 @@ export function WorkItemGrid({
13666
14437
  identifier: row.identifier,
13667
14438
  })}
13668
14439
  onCheckedChange={(checked) => {
13669
- setSelected((current) => {
13670
- const next = new Set(current);
13671
-
13672
- if (checked) {
13673
- next.add(row.id);
13674
- } else {
13675
- next.delete(row.id);
13676
- }
13677
-
13678
- return next;
13679
- });
14440
+ if (checked) {
14441
+ bulk.select(row.id);
14442
+ } else {
14443
+ bulk.deselect(row.id);
14444
+ }
13680
14445
  }}
13681
14446
  />
13682
14447
  </TableCell>
@@ -14498,59 +15263,60 @@ npx shadcn add alert alert-dialog button select
14498
15263
  */
14499
15264
  export function BulkActionBar({
14500
15265
  selected,
14501
- onSettled,
15266
+ bulk,
14502
15267
  }: {
14503
15268
  selected: readonly Pick<WorkItemRow, "id" | "identifier">[];
14504
- onSettled: (failedIds: readonly string[]) => void;
15269
+ bulk: BulkSelectionSnapshot & BulkSelectionActions;
14505
15270
  }) {
14506
15271
  const t = useExtracted("work");
14507
- const errorMessage = useErrorMessage();
14508
15272
  const stateLabel = useStateLabel();
14509
15273
  const [to, setTo] = useState<TaskState | null>(null);
14510
15274
  const [confirming, setConfirming] = useState(false);
14511
15275
  const [failures, setFailures] = useState<readonly BulkFailure[]>([]);
14512
- const bulk = useAction(runWorkBulkAction);
14513
15276
 
14514
15277
  const identifiers = new Map(selected.map((row) => [row.id, row.identifier]));
14515
15278
 
14516
15279
  const run = async (
14517
15280
  input: { action: "state"; to: TaskState } | { action: "delete" },
14518
15281
  ): Promise<void> => {
14519
- const ids = selected.map((row) => row.id);
14520
- const result = await bulk.run({ ...input, ids });
14521
-
14522
- if (!result.ok) {
14523
- toast.error(errorMessage(result.error));
15282
+ const outcome = await bulk.run(
15283
+ input.action === "state"
15284
+ ? { action: "state", args: { to: input.to } }
15285
+ : { action: "delete" },
15286
+ );
14524
15287
 
15288
+ // The grid's `run` already showed the error of a call that threw.
15289
+ if (outcome?.mode !== "now") {
14525
15290
  return;
14526
15291
  }
14527
15292
 
14528
- const { succeeded, failed } = result.data;
15293
+ const failed = outcome.results.flatMap((row) =>
15294
+ row.ok || row.error === null ? [] : [{ id: row.id, error: row.error }],
15295
+ );
14529
15296
 
14530
15297
  setFailures(
14531
15298
  failed.map((row) => ({
14532
15299
  id: row.id,
14533
15300
  identifier: identifiers.get(row.id) ?? row.id,
14534
- message: row.message === "" ? t("No reason given.") : row.message,
15301
+ message:
15302
+ row.error.message === "" ? t("No reason given.") : row.error.message,
14535
15303
  })),
14536
15304
  );
14537
15305
 
14538
15306
  if (failed.length === 0) {
14539
15307
  toast.success(
14540
15308
  t("{count, plural, one {# item updated} other {# items updated}}", {
14541
- count: succeeded,
15309
+ count: outcome.succeeded,
14542
15310
  }),
14543
15311
  );
14544
15312
  } else {
14545
15313
  toast.warning(
14546
15314
  t("{failed, number} of {total, number} items failed", {
14547
15315
  failed: failed.length,
14548
- total: result.data.total,
15316
+ total: outcome.total,
14549
15317
  }),
14550
15318
  );
14551
15319
  }
14552
-
14553
- onSettled(failed.map((row) => row.id));
14554
15320
  };
14555
15321
 
14556
15322
  const stateItems = WORK_ITEM_STATES.map((state) => ({
@@ -14670,7 +15436,7 @@ export function BulkActionBar({
14670
15436
  variant="ghost"
14671
15437
  disabled={bulk.pending}
14672
15438
  onClick={() => {
14673
- onSettled([]);
15439
+ bulk.clear();
14674
15440
  }}
14675
15441
  >
14676
15442
  <XIcon />
@@ -15012,21 +15778,16 @@ export function RelatedItemsPanelSkeleton() {
15012
15778
 
15013
15779
  ## Employee directory
15014
15780
 
15015
- A searchable list of employees with an org chart of who reports to whom. It loads its data on the server through the block's client; the [employees block](https://bettersupabase.com/blocks/employees) must be installed (`npx better-supabase add employees`). Page: https://bettersupabase.com/recipes/employee-directory.
15016
-
15017
- Web, with shadcn components:
15781
+ A list of employees with server-side search, a status filter and a link to each record. It loads its data on the server through the block's client; the [employees block](https://bettersupabase.com/blocks/employees) must be installed (`npx better-supabase add employees`). Page: https://bettersupabase.com/recipes/employee-directory.
15018
15782
 
15019
- ```bash
15020
- npx shadcn add card empty skeleton
15021
- ```
15783
+ Web, with no shadcn components.
15022
15784
 
15023
- ```tsx title="apps/examples/nextjs/src/features/people/components/employee-directory.tsx"
15785
+ ```tsx title="apps/examples/nextjs/src/features/people/components/employee-overview.tsx"
15024
15786
  /**
15025
- * Render inside `<Suspense>`: the employees as an org chart, each manager above
15026
- * their reports, with a search. Private details open in a sheet for callers
15027
- * with `employees.read_sensitive`.
15787
+ * Render inside `<Suspense>`: every employee on the list kit, with the add
15788
+ * action for callers who can write.
15028
15789
  */
15029
- export async function EmployeeDirectory() {
15790
+ export async function EmployeeOverview() {
15030
15791
  const [t, permissions] = await Promise.all([
15031
15792
  getExtracted("people"),
15032
15793
  getPermissions(),
@@ -15042,61 +15803,34 @@ export async function EmployeeDirectory() {
15042
15803
  return null;
15043
15804
  }
15044
15805
 
15045
- const canWrite = can(permissions, "employees.write");
15046
- const canViewSensitive = can(permissions, "employees.read_sensitive");
15047
-
15048
- const managers =
15049
- directory.kind === "ok"
15050
- ? directory.data.map((employee) => ({
15051
- value: employee.id,
15052
- label: employee.name,
15053
- }))
15054
- : [];
15806
+ if (directory.kind === "error") {
15807
+ return <PeopleLoadError title={t("The directory didn't load")} />;
15808
+ }
15055
15809
 
15056
- const addEmployee = canWrite ? (
15057
- <AddEmployeeDialog
15058
- managers={managers}
15059
- canViewSensitive={canViewSensitive}
15060
- />
15061
- ) : null;
15810
+ const managers = directory.data.map((employee) => ({
15811
+ value: employee.id,
15812
+ label: employee.name,
15813
+ }));
15062
15814
 
15063
15815
  return (
15064
- <Card data-recipe="employee-directory">
15065
- <CardHeader>
15066
- <CardTitle>{t("Employees")}</CardTitle>
15067
- <CardDescription>
15068
- {t("Everyone in the organization and who they report to.")}
15069
- </CardDescription>
15070
- {addEmployee && managers.length > 0 ? (
15071
- <CardAction>{addEmployee}</CardAction>
15072
- ) : null}
15073
- </CardHeader>
15074
- <CardContent>
15075
- {directory.kind === "error" ? (
15076
- <PeopleLoadError title={t("The directory didn't load")} />
15077
- ) : directory.data.length === 0 ? (
15078
- <Empty className="border">
15079
- <EmptyHeader>
15080
- <EmptyMedia variant="icon">
15081
- <UsersIcon />
15082
- </EmptyMedia>
15083
- <EmptyTitle>{t("No employees yet")}</EmptyTitle>
15084
- <EmptyDescription>
15085
- {canWrite
15086
- ? t("Add the first employee to start the org chart.")
15087
- : t("Ask an admin to add employees.")}
15088
- </EmptyDescription>
15089
- </EmptyHeader>
15090
- {addEmployee ? <EmptyContent>{addEmployee}</EmptyContent> : null}
15091
- </Empty>
15092
- ) : (
15093
- <EmployeeTable
15094
- employees={directory.data}
15095
- canViewSensitive={canViewSensitive}
15816
+ <div className="flex flex-col gap-4">
15817
+ {can(permissions, "employees.write") ? (
15818
+ <div className="flex justify-end">
15819
+ <AddEmployeeDialog
15820
+ managers={managers}
15821
+ canViewSensitive={can(permissions, "employees.read_sensitive")}
15096
15822
  />
15823
+ </div>
15824
+ ) : null}
15825
+ <EmployeeRecordList
15826
+ initial={pageBlockRows(
15827
+ employeeList,
15828
+ employeeSpec,
15829
+ directory.data,
15830
+ employeeList.defaults,
15097
15831
  )}
15098
- </CardContent>
15099
- </Card>
15832
+ />
15833
+ </div>
15100
15834
  );
15101
15835
  }
15102
15836
  ```
@@ -15563,9 +16297,10 @@ export async function RosterBoard() {
15563
16297
  {shifts
15564
16298
  .filter((shift) => shift.day === day)
15565
16299
  .map((shift) => (
15566
- <div
16300
+ <Link
15567
16301
  key={shift.id}
15568
- className="flex flex-col gap-2 rounded-md border p-2"
16302
+ href={`/shifts/${shift.id}?on=${shift.day}`}
16303
+ className="flex flex-col gap-2 rounded-md border p-2 transition-colors hover:bg-muted/50"
15569
16304
  >
15570
16305
  <span className="text-sm">
15571
16306
  {time(shift.startsAt)} – {time(shift.endsAt)}
@@ -15594,7 +16329,7 @@ export async function RosterBoard() {
15594
16329
  })}
15595
16330
  </span>
15596
16331
  ) : null}
15597
- </div>
16332
+ </Link>
15598
16333
  ))}
15599
16334
  </div>
15600
16335
  ))}
@@ -18647,6 +19382,8 @@ export async function CalendarView({
18647
19382
  }: {
18648
19383
  query: Record<string, string | string[] | undefined>;
18649
19384
  }) {
19385
+ // The current month is read from the clock, which a prerender may not do.
19386
+ await io();
18650
19387
  const first = firstOfMonth(query["month"], "UTC");
18651
19388
  const weeks = weeksOf(first);
18652
19389
  const from = weeks[0]?.[0] ?? first;
@@ -18659,7 +19396,6 @@ export async function CalendarView({
18659
19396
  getExtracted("calendar"),
18660
19397
  getFormatter(),
18661
19398
  settle(() => loadCalendarMonth(from.toString(), until.toString())),
18662
- io(),
18663
19399
  ]);
18664
19400
 
18665
19401
  if (!can(permissions, "calendar.read")) {
@@ -27122,62 +27858,46 @@ The organization's risks in a data grid with their residual band, status and nex
27122
27858
  Web, with shadcn components:
27123
27859
 
27124
27860
  ```bash
27125
- npx shadcn add alert badge button empty skeleton @reui/data-grid @reui/frame
27861
+ npx shadcn add badge @reui/data-grid
27126
27862
  ```
27127
27863
 
27128
- ```tsx title="apps/examples/nextjs/src/features/risks/components/risk-register.tsx"
27864
+ ```tsx title="apps/examples/nextjs/src/features/risks/components/risk-record-list.tsx"
27129
27865
  "use client";
27130
27866
 
27131
- import type { CellContext, ColumnDef } from "@tanstack/react-table";
27132
- import type { RiskStatus } from "better-supabase/blocks/risks";
27867
+ import type { CellContext } from "@tanstack/react-table";
27133
27868
 
27134
- import { useTable } from "@tanstack/react-table";
27135
- import { ShieldAlertIcon, TriangleAlertIcon } from "lucide-react";
27869
+ import { ShieldAlertIcon } from "lucide-react";
27136
27870
  import { useExtracted, useFormatter } from "next-intl";
27137
- import { useRouter } from "next/navigation";
27138
- import { useTransition } from "react";
27139
27871
 
27872
+ import type { RecordListColumns } from "@/components/record-list/record-list-grid";
27873
+ import type { RecordListPage } from "@/components/record-list/record-list-types";
27140
27874
  import type { ReadOnlyGridFeatures } from "@/components/reui/data-grid/data-grid";
27141
27875
 
27142
- import {
27143
- Alert,
27144
- AlertAction,
27145
- AlertDescription,
27146
- AlertTitle,
27147
- } from "@/components/reui/alert";
27148
- import { Badge } from "@/components/reui/badge";
27149
- import {
27150
- DataGrid,
27151
- DataGridContainer,
27152
- } from "@/components/reui/data-grid/data-grid";
27153
- import { readOnlyGridFeatures } from "@/components/reui/data-grid/data-grid-features-read-only";
27154
- import { DataGridScrollArea } from "@/components/reui/data-grid/data-grid-scroll-area";
27155
- import { DataGridTable } from "@/components/reui/data-grid/data-grid-table";
27156
- import {
27157
- Frame,
27158
- FrameDescription,
27159
- FrameHeader,
27160
- FramePanel,
27161
- FrameTitle,
27162
- } from "@/components/reui/frame";
27163
- import { Button } from "@/components/ui/button";
27164
- import {
27165
- Empty,
27166
- EmptyContent,
27167
- EmptyDescription,
27168
- EmptyHeader,
27169
- EmptyMedia,
27170
- EmptyTitle,
27171
- } from "@/components/ui/empty";
27876
+ import { RecordListView } from "@/components/record-list/record-list-view";
27877
+ import { Link } from "@/i18n/navigation";
27172
27878
 
27173
- import type { BandTone, Loaded, RiskRow } from "../risks-queries";
27879
+ import type { RiskRow } from "../risk-rows";
27174
27880
 
27175
- const TONE_VARIANT = {
27176
- low: "success-light",
27177
- medium: "warning-light",
27178
- high: "destructive-light",
27179
- critical: "destructive",
27180
- } as const satisfies Record<BandTone, string>;
27881
+ import { useRiskListState } from "../use-risk-list-state";
27882
+ import { RiskBandBadge } from "./risk-band-badge";
27883
+ import { RiskStatusBadge, useRiskStatusLabel } from "./risk-status-badge";
27884
+
27885
+ const STATUSES = ["identified", "assessed", "treating", "accepted", "closed"];
27886
+ const BANDS = ["low", "medium", "high", "critical"];
27887
+
27888
+ const CATEGORIES = [
27889
+ "quality",
27890
+ "safety",
27891
+ "environment",
27892
+ "security",
27893
+ "compliance",
27894
+ "operational",
27895
+ "financial",
27896
+ "strategic",
27897
+ ];
27898
+
27899
+ const capitalized = (value: string): string =>
27900
+ value.charAt(0).toUpperCase() + value.slice(1);
27181
27901
 
27182
27902
  type RiskCell = CellContext<ReadOnlyGridFeatures, RiskRow>;
27183
27903
 
@@ -27190,53 +27910,23 @@ function NumberCell({ row }: RiskCell) {
27190
27910
  }
27191
27911
 
27192
27912
  function TitleCell({ row }: RiskCell) {
27193
- return <span className="font-medium">{row.original.title}</span>;
27913
+ return (
27914
+ <Link
27915
+ href={`/risks/${row.original.id}`}
27916
+ prefetch
27917
+ className="font-medium hover:underline"
27918
+ >
27919
+ {row.original.title}
27920
+ </Link>
27921
+ );
27194
27922
  }
27195
27923
 
27196
27924
  function BandCell({ row }: RiskCell) {
27197
- const t = useExtracted("risks");
27198
- const { band, tone, score } = row.original;
27199
-
27200
- return band === null || tone === null ? (
27201
- <span className="text-muted-foreground">{t("Not assessed")}</span>
27202
- ) : (
27203
- <Badge variant={TONE_VARIANT[tone]}>
27204
- {t("{band} · {score, number}", { band, score: score ?? 0 })}
27205
- </Badge>
27206
- );
27925
+ return <RiskBandBadge {...row.original} />;
27207
27926
  }
27208
27927
 
27209
27928
  function StatusCell({ row }: RiskCell) {
27210
- const t = useExtracted("risks");
27211
- const status: RiskStatus = row.original.status;
27212
-
27213
- switch (status) {
27214
- case "identified": {
27215
- return <Badge variant="secondary">{t("Identified")}</Badge>;
27216
- }
27217
-
27218
- case "assessed": {
27219
- return <Badge variant="info-light">{t("Assessed")}</Badge>;
27220
- }
27221
-
27222
- case "treating": {
27223
- return <Badge variant="warning-light">{t("Treating")}</Badge>;
27224
- }
27225
-
27226
- case "accepted": {
27227
- return <Badge variant="success-light">{t("Accepted")}</Badge>;
27228
- }
27229
-
27230
- case "closed": {
27231
- return <Badge variant="secondary">{t("Closed")}</Badge>;
27232
- }
27233
-
27234
- default: {
27235
- const unknown: never = status;
27236
-
27237
- return unknown;
27238
- }
27239
- }
27929
+ return <RiskStatusBadge status={row.original.status} />;
27240
27930
  }
27241
27931
 
27242
27932
  function ReviewCell({ row }: RiskCell) {
@@ -27255,12 +27945,24 @@ function ReviewCell({ row }: RiskCell) {
27255
27945
  );
27256
27946
  }
27257
27947
 
27258
- function RiskGrid({ risks }: { risks: readonly RiskRow[] }) {
27948
+ /**
27949
+ * The risk register on the list kit: the URL holds the search, the status,
27950
+ * category and band filters and the keyset cursor; the list route serves every
27951
+ * state but the default first page, which the server renders. The block orders
27952
+ * by residual score, so there is no sort control.
27953
+ */
27954
+ export function RiskRecordList({
27955
+ initial,
27956
+ }: {
27957
+ initial: RecordListPage<RiskRow>;
27958
+ }) {
27259
27959
  const t = useExtracted("risks");
27960
+ const statusLabel = useRiskStatusLabel();
27961
+ const list = useRiskListState();
27260
27962
 
27261
- const columns: ColumnDef<ReadOnlyGridFeatures, RiskRow>[] = [
27963
+ const columns: RecordListColumns<RiskRow> = [
27262
27964
  { accessorKey: "number", header: t("Number"), cell: NumberCell, size: 100 },
27263
- { accessorKey: "title", header: t("Risk"), cell: TitleCell, size: 260 },
27965
+ { accessorKey: "title", header: t("Risk"), cell: TitleCell, size: 280 },
27264
27966
  { accessorKey: "category", header: t("Category"), size: 140 },
27265
27967
  { accessorKey: "band", header: t("Residual"), cell: BandCell, size: 150 },
27266
27968
  { accessorKey: "status", header: t("Status"), cell: StatusCell, size: 120 },
@@ -27272,100 +27974,40 @@ function RiskGrid({ risks }: { risks: readonly RiskRow[] }) {
27272
27974
  },
27273
27975
  ];
27274
27976
 
27275
- const table = useTable({
27276
- features: readOnlyGridFeatures,
27277
- columns,
27278
- data: [...risks],
27279
- getRowId: (row) => row.id,
27280
- });
27281
-
27282
- return (
27283
- <DataGrid
27284
- table={table}
27285
- recordCount={risks.length}
27286
- tableLayout={{ dense: true }}
27287
- >
27288
- <DataGridContainer>
27289
- <DataGridScrollArea>
27290
- <DataGridTable />
27291
- </DataGridScrollArea>
27292
- </DataGridContainer>
27293
- </DataGrid>
27294
- );
27295
- }
27296
-
27297
- /**
27298
- * The organization's risk register: each risk with its residual band and the
27299
- * date of its next review, the highest residual score first.
27300
- */
27301
- export function RiskRegister({ state }: { state: Loaded<readonly RiskRow[]> }) {
27302
- const t = useExtracted("risks");
27303
- const router = useRouter();
27304
- const [retrying, startRetry] = useTransition();
27305
-
27306
- if (state.kind === "no-organization") {
27307
- return null;
27308
- }
27309
-
27310
27977
  return (
27311
- <Frame spacing="sm" data-recipe="risk-register">
27312
- <FrameHeader className="gap-0.5">
27313
- <FrameTitle>{t("Risk register")}</FrameTitle>
27314
- <FrameDescription>
27315
- {t(
27316
- "Every identified risk with its residual rating after controls. A review moves the next review date ahead by the risk's interval.",
27317
- )}
27318
- </FrameDescription>
27319
- </FrameHeader>
27320
- <FramePanel>
27321
- {state.kind === "error" ? (
27322
- <Alert variant="destructive">
27323
- <TriangleAlertIcon />
27324
- <AlertTitle>{t("The risk register didn't load")}</AlertTitle>
27325
- <AlertDescription>{t("Try again in a moment.")}</AlertDescription>
27326
- <AlertAction>
27327
- <Button
27328
- size="sm"
27329
- variant="outline"
27330
- type="button"
27331
- disabled={retrying}
27332
- onClick={() => {
27333
- startRetry(() => {
27334
- router.refresh();
27335
- });
27336
- }}
27337
- >
27338
- {t("Retry")}
27339
- </Button>
27340
- </AlertAction>
27341
- </Alert>
27342
- ) : state.data.length === 0 ? (
27343
- <Empty>
27344
- <EmptyHeader>
27345
- <EmptyMedia variant="icon">
27346
- <ShieldAlertIcon />
27347
- </EmptyMedia>
27348
- <EmptyTitle>{t("No risks yet")}</EmptyTitle>
27349
- <EmptyDescription>
27350
- {t(
27351
- "Register a risk with its cause and consequence, then assess it against the organization's matrix.",
27352
- )}
27353
- </EmptyDescription>
27354
- </EmptyHeader>
27355
- <EmptyContent>
27356
- <a
27357
- className="text-sm underline underline-offset-4"
27358
- href="https://bettersupabase.com/docs/blocks/risks"
27359
- >
27360
- {t("Read the risks guide")}
27361
- </a>
27362
- </EmptyContent>
27363
- </Empty>
27364
- ) : (
27365
- <RiskGrid risks={state.data} />
27366
- )}
27367
- </FramePanel>
27368
- </Frame>
27978
+ <RecordListView
27979
+ list={list}
27980
+ endpoint="/api/risks/list"
27981
+ initial={initial}
27982
+ columns={columns}
27983
+ facets={[
27984
+ {
27985
+ key: "status",
27986
+ label: t("Status"),
27987
+ values: STATUSES,
27988
+ valueLabel: statusLabel,
27989
+ },
27990
+ {
27991
+ key: "category",
27992
+ label: t("Category"),
27993
+ values: CATEGORIES,
27994
+ valueLabel: capitalized,
27995
+ },
27996
+ {
27997
+ key: "band",
27998
+ label: t("Residual"),
27999
+ values: BANDS,
28000
+ valueLabel: capitalized,
28001
+ },
28002
+ ]}
28003
+ sorts={[]}
28004
+ searchLabel={t("Search risks")}
28005
+ emptyIcon={<ShieldAlertIcon />}
28006
+ emptyTitle={t("No risks found")}
28007
+ emptyDescription={t(
28008
+ "Register a risk with its cause and consequence, then assess it against the organization's matrix, or change the filters.",
28009
+ )}
28010
+ />
27369
28011
  );
27370
28012
  }
27371
28013
  ```