@kelpie/ui 0.16.0 → 0.18.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 (258) hide show
  1. package/dist/api/client.d.ts +1 -1
  2. package/dist/api/resources/ai.d.ts +21 -0
  3. package/dist/api/resources/ai.d.ts.map +1 -0
  4. package/dist/api/resources/ai.js +101 -0
  5. package/dist/api/resources/ai.js.map +1 -0
  6. package/dist/api/resources/conversions.js +1 -1
  7. package/dist/api/resources/conversions.js.map +1 -1
  8. package/dist/api/resources/forms.d.ts +8 -0
  9. package/dist/api/resources/forms.d.ts.map +1 -1
  10. package/dist/api/resources/forms.js +39 -0
  11. package/dist/api/resources/forms.js.map +1 -1
  12. package/dist/api/resources/personIntake.d.ts +12 -0
  13. package/dist/api/resources/personIntake.d.ts.map +1 -0
  14. package/dist/api/resources/personIntake.js +54 -0
  15. package/dist/api/resources/personIntake.js.map +1 -0
  16. package/dist/api/resources/session.d.ts.map +1 -1
  17. package/dist/api/resources/session.js +3 -1
  18. package/dist/api/resources/session.js.map +1 -1
  19. package/dist/api/resources/workspace.d.ts +2 -2
  20. package/dist/api/resources/workspace.js +2 -2
  21. package/dist/app/KelpieApp.js +2 -2
  22. package/dist/app/KelpieApp.js.map +1 -1
  23. package/dist/components/ActivitiesPanel.d.ts +7 -4
  24. package/dist/components/ActivitiesPanel.d.ts.map +1 -1
  25. package/dist/components/ActivitiesPanel.js +12 -2
  26. package/dist/components/ActivitiesPanel.js.map +1 -1
  27. package/dist/components/ActivityAction.d.ts +15 -0
  28. package/dist/components/ActivityAction.d.ts.map +1 -0
  29. package/dist/components/ActivityAction.js +20 -0
  30. package/dist/components/ActivityAction.js.map +1 -0
  31. package/dist/components/AgentTasks.d.ts +5 -0
  32. package/dist/components/AgentTasks.d.ts.map +1 -1
  33. package/dist/components/AgentTasks.js +88 -10
  34. package/dist/components/AgentTasks.js.map +1 -1
  35. package/dist/components/DecisionsPanel.d.ts.map +1 -1
  36. package/dist/components/DecisionsPanel.js +3 -1
  37. package/dist/components/DecisionsPanel.js.map +1 -1
  38. package/dist/components/LinkedText.d.ts +12 -0
  39. package/dist/components/LinkedText.d.ts.map +1 -0
  40. package/dist/components/LinkedText.js +25 -0
  41. package/dist/components/LinkedText.js.map +1 -0
  42. package/dist/components/MarkdownView.d.ts +3 -1
  43. package/dist/components/MarkdownView.d.ts.map +1 -1
  44. package/dist/components/MarkdownView.js +17 -3
  45. package/dist/components/MarkdownView.js.map +1 -1
  46. package/dist/components/NotesPanel.d.ts +2 -1
  47. package/dist/components/NotesPanel.d.ts.map +1 -1
  48. package/dist/components/NotesPanel.js +6 -7
  49. package/dist/components/NotesPanel.js.map +1 -1
  50. package/dist/components/PersonIntakeDialog.d.ts +19 -0
  51. package/dist/components/PersonIntakeDialog.d.ts.map +1 -0
  52. package/dist/components/PersonIntakeDialog.js +87 -0
  53. package/dist/components/PersonIntakeDialog.js.map +1 -0
  54. package/dist/components/PlanPanel.d.ts.map +1 -1
  55. package/dist/components/PlanPanel.js +3 -1
  56. package/dist/components/PlanPanel.js.map +1 -1
  57. package/dist/components/RecordLinkTextarea.d.ts +12 -0
  58. package/dist/components/RecordLinkTextarea.d.ts.map +1 -0
  59. package/dist/components/RecordLinkTextarea.js +142 -0
  60. package/dist/components/RecordLinkTextarea.js.map +1 -0
  61. package/dist/components/Shell.js +1 -1
  62. package/dist/components/Shell.js.map +1 -1
  63. package/dist/components/WorkspaceSwitcher.d.ts +2 -1
  64. package/dist/components/WorkspaceSwitcher.d.ts.map +1 -1
  65. package/dist/components/WorkspaceSwitcher.js +7 -2
  66. package/dist/components/WorkspaceSwitcher.js.map +1 -1
  67. package/dist/index.d.ts +5 -2
  68. package/dist/index.d.ts.map +1 -1
  69. package/dist/index.js +6 -1
  70. package/dist/index.js.map +1 -1
  71. package/dist/lib/fragmentTarget.d.ts +18 -0
  72. package/dist/lib/fragmentTarget.d.ts.map +1 -0
  73. package/dist/lib/fragmentTarget.js +73 -0
  74. package/dist/lib/fragmentTarget.js.map +1 -0
  75. package/dist/lib/recordLinks.d.ts +17 -0
  76. package/dist/lib/recordLinks.d.ts.map +1 -0
  77. package/dist/lib/recordLinks.js +48 -0
  78. package/dist/lib/recordLinks.js.map +1 -0
  79. package/dist/lib/recordReferences.d.ts +41 -0
  80. package/dist/lib/recordReferences.d.ts.map +1 -0
  81. package/dist/lib/recordReferences.js +92 -0
  82. package/dist/lib/recordReferences.js.map +1 -0
  83. package/dist/modules/PersonIntakeWizard.d.ts +3 -0
  84. package/dist/modules/PersonIntakeWizard.d.ts.map +1 -0
  85. package/dist/modules/PersonIntakeWizard.js +223 -0
  86. package/dist/modules/PersonIntakeWizard.js.map +1 -0
  87. package/dist/modules/ai.d.ts +14 -0
  88. package/dist/modules/ai.d.ts.map +1 -0
  89. package/dist/modules/ai.js +26 -0
  90. package/dist/modules/ai.js.map +1 -0
  91. package/dist/modules/aiRunner.d.ts +3 -0
  92. package/dist/modules/aiRunner.d.ts.map +1 -0
  93. package/dist/modules/aiRunner.js +68 -0
  94. package/dist/modules/aiRunner.js.map +1 -0
  95. package/dist/modules/personIntakeSelection.d.ts +7 -0
  96. package/dist/modules/personIntakeSelection.d.ts.map +1 -0
  97. package/dist/modules/personIntakeSelection.js +21 -0
  98. package/dist/modules/personIntakeSelection.js.map +1 -0
  99. package/dist/pages/CompanyDetail.d.ts.map +1 -1
  100. package/dist/pages/CompanyDetail.js +2 -1
  101. package/dist/pages/CompanyDetail.js.map +1 -1
  102. package/dist/pages/DealDetail.d.ts.map +1 -1
  103. package/dist/pages/DealDetail.js +2 -1
  104. package/dist/pages/DealDetail.js.map +1 -1
  105. package/dist/pages/EnquiryDetail.d.ts.map +1 -1
  106. package/dist/pages/EnquiryDetail.js +2 -1
  107. package/dist/pages/EnquiryDetail.js.map +1 -1
  108. package/dist/pages/EventDetail.d.ts.map +1 -1
  109. package/dist/pages/EventDetail.js +2 -1
  110. package/dist/pages/EventDetail.js.map +1 -1
  111. package/dist/pages/FormsPage.js +4 -4
  112. package/dist/pages/FormsPage.js.map +1 -1
  113. package/dist/pages/OpportunityDetail.d.ts.map +1 -1
  114. package/dist/pages/OpportunityDetail.js +2 -1
  115. package/dist/pages/OpportunityDetail.js.map +1 -1
  116. package/dist/pages/PartnershipDetail.d.ts.map +1 -1
  117. package/dist/pages/PartnershipDetail.js +2 -1
  118. package/dist/pages/PartnershipDetail.js.map +1 -1
  119. package/dist/pages/PeoplePage.d.ts.map +1 -1
  120. package/dist/pages/PeoplePage.js +7 -1
  121. package/dist/pages/PeoplePage.js.map +1 -1
  122. package/dist/pages/PersonDetail.d.ts.map +1 -1
  123. package/dist/pages/PersonDetail.js +2 -1
  124. package/dist/pages/PersonDetail.js.map +1 -1
  125. package/dist/pages/RaiseDetail.d.ts.map +1 -1
  126. package/dist/pages/RaiseDetail.js +2 -1
  127. package/dist/pages/RaiseDetail.js.map +1 -1
  128. package/dist/pages/SearchPage.d.ts.map +1 -1
  129. package/dist/pages/SearchPage.js +26 -14
  130. package/dist/pages/SearchPage.js.map +1 -1
  131. package/dist/pages/admin/AiAdminPage.d.ts +2 -0
  132. package/dist/pages/admin/AiAdminPage.d.ts.map +1 -0
  133. package/dist/pages/admin/AiAdminPage.js +19 -0
  134. package/dist/pages/admin/AiAdminPage.js.map +1 -0
  135. package/dist/pages/admin/AiPage.d.ts +5 -0
  136. package/dist/pages/admin/AiPage.d.ts.map +1 -0
  137. package/dist/pages/admin/AiPage.js +196 -0
  138. package/dist/pages/admin/AiPage.js.map +1 -0
  139. package/dist/pages/admin/McpPage.js +2 -2
  140. package/dist/pages/admin/McpPage.js.map +1 -1
  141. package/dist/pages/admin/McpPanel.d.ts +3 -0
  142. package/dist/pages/admin/McpPanel.d.ts.map +1 -0
  143. package/dist/pages/admin/McpPanel.js +123 -0
  144. package/dist/pages/admin/McpPanel.js.map +1 -0
  145. package/dist/pages/admin/PrivacyPage.js +19 -3
  146. package/dist/pages/admin/PrivacyPage.js.map +1 -1
  147. package/dist/pages/admin/WorkspaceSettingsPage.d.ts +5 -6
  148. package/dist/pages/admin/WorkspaceSettingsPage.d.ts.map +1 -1
  149. package/dist/pages/admin/WorkspaceSettingsPage.js +12 -17
  150. package/dist/pages/admin/WorkspaceSettingsPage.js.map +1 -1
  151. package/dist/pages/dashboard/attention.d.ts +0 -5
  152. package/dist/pages/dashboard/attention.d.ts.map +1 -1
  153. package/dist/pages/dashboard/attention.js +1 -21
  154. package/dist/pages/dashboard/attention.js.map +1 -1
  155. package/dist/pages/dashboard/sections.d.ts.map +1 -1
  156. package/dist/pages/dashboard/sections.js +6 -3
  157. package/dist/pages/dashboard/sections.js.map +1 -1
  158. package/dist/pages/forms/EmbedPanel.js +5 -2
  159. package/dist/pages/forms/EmbedPanel.js.map +1 -1
  160. package/dist/pages/forms/FieldsEditor.d.ts.map +1 -1
  161. package/dist/pages/forms/FieldsEditor.js +90 -8
  162. package/dist/pages/forms/FieldsEditor.js.map +1 -1
  163. package/dist/pages/forms/FormSettings.d.ts.map +1 -1
  164. package/dist/pages/forms/FormSettings.js +73 -6
  165. package/dist/pages/forms/FormSettings.js.map +1 -1
  166. package/dist/pages/forms/SubmissionDetail.d.ts.map +1 -1
  167. package/dist/pages/forms/SubmissionDetail.js +2 -1
  168. package/dist/pages/forms/SubmissionDetail.js.map +1 -1
  169. package/dist/pages/forms/SubmissionsTable.d.ts.map +1 -1
  170. package/dist/pages/forms/SubmissionsTable.js +2 -1
  171. package/dist/pages/forms/SubmissionsTable.js.map +1 -1
  172. package/dist/pages/forms/fieldList.d.ts +2 -2
  173. package/dist/pages/forms/fieldList.d.ts.map +1 -1
  174. package/dist/pages/forms/fieldList.js +38 -10
  175. package/dist/pages/forms/fieldList.js.map +1 -1
  176. package/dist/pages/forms/template.d.ts.map +1 -1
  177. package/dist/pages/forms/template.js +13 -0
  178. package/dist/pages/forms/template.js.map +1 -1
  179. package/dist/pages/handbook/HandbookPage.d.ts.map +1 -1
  180. package/dist/pages/handbook/HandbookPage.js +2 -3
  181. package/dist/pages/handbook/HandbookPage.js.map +1 -1
  182. package/dist/pages/onboarding/WorkspaceStepPage.d.ts.map +1 -1
  183. package/dist/pages/onboarding/WorkspaceStepPage.js +9 -27
  184. package/dist/pages/onboarding/WorkspaceStepPage.js.map +1 -1
  185. package/dist/pages/onboarding/onboardingRerun.d.ts +9 -0
  186. package/dist/pages/onboarding/onboardingRerun.d.ts.map +1 -1
  187. package/dist/pages/onboarding/onboardingRerun.js +11 -0
  188. package/dist/pages/onboarding/onboardingRerun.js.map +1 -1
  189. package/dist/registry/context.d.ts +7 -1
  190. package/dist/registry/context.d.ts.map +1 -1
  191. package/dist/registry/context.js +12 -0
  192. package/dist/registry/context.js.map +1 -1
  193. package/dist/registry/contributions.d.ts +70 -1
  194. package/dist/registry/contributions.d.ts.map +1 -1
  195. package/dist/registry/registry.d.ts +12 -1
  196. package/dist/registry/registry.d.ts.map +1 -1
  197. package/dist/registry/registry.js +21 -0
  198. package/dist/registry/registry.js.map +1 -1
  199. package/package.json +2 -2
  200. package/src/api/client.ts +1 -1
  201. package/src/api/resources/ai.ts +120 -0
  202. package/src/api/resources/conversions.ts +1 -1
  203. package/src/api/resources/forms.ts +56 -0
  204. package/src/api/resources/personIntake.ts +95 -0
  205. package/src/api/resources/session.ts +3 -1
  206. package/src/api/resources/workspace.ts +4 -4
  207. package/src/app/KelpieApp.tsx +4 -2
  208. package/src/components/ActivitiesPanel.tsx +39 -10
  209. package/src/components/ActivityAction.tsx +33 -0
  210. package/src/components/AgentTasks.tsx +138 -10
  211. package/src/components/DecisionsPanel.tsx +9 -1
  212. package/src/components/LinkedText.tsx +51 -0
  213. package/src/components/MarkdownView.tsx +37 -7
  214. package/src/components/NotesPanel.tsx +18 -12
  215. package/src/components/PersonIntakeDialog.tsx +226 -0
  216. package/src/components/PlanPanel.tsx +9 -1
  217. package/src/components/RecordLinkTextarea.tsx +257 -0
  218. package/src/components/Shell.tsx +1 -1
  219. package/src/components/WorkspaceSwitcher.tsx +15 -1
  220. package/src/index.ts +16 -0
  221. package/src/lib/fragmentTarget.ts +96 -0
  222. package/src/lib/recordLinks.ts +57 -0
  223. package/src/lib/recordReferences.ts +139 -0
  224. package/src/modules/PersonIntakeWizard.tsx +633 -0
  225. package/src/modules/ai.tsx +27 -0
  226. package/src/modules/aiRunner.ts +83 -0
  227. package/src/modules/personIntakeSelection.ts +24 -0
  228. package/src/pages/CompanyDetail.tsx +2 -1
  229. package/src/pages/DealDetail.tsx +2 -1
  230. package/src/pages/EnquiryDetail.tsx +2 -1
  231. package/src/pages/EventDetail.tsx +2 -1
  232. package/src/pages/FormsPage.tsx +4 -4
  233. package/src/pages/OpportunityDetail.tsx +2 -1
  234. package/src/pages/PartnershipDetail.tsx +2 -1
  235. package/src/pages/PeoplePage.tsx +21 -5
  236. package/src/pages/PersonDetail.tsx +2 -1
  237. package/src/pages/RaiseDetail.tsx +2 -1
  238. package/src/pages/SearchPage.tsx +30 -15
  239. package/src/pages/admin/AiAdminPage.tsx +52 -0
  240. package/src/pages/admin/AiPage.tsx +457 -0
  241. package/src/pages/admin/{McpPage.tsx → McpPanel.tsx} +15 -11
  242. package/src/pages/admin/PrivacyPage.tsx +42 -0
  243. package/src/pages/admin/WorkspaceSettingsPage.tsx +13 -28
  244. package/src/pages/dashboard/attention.ts +1 -24
  245. package/src/pages/dashboard/sections.tsx +9 -4
  246. package/src/pages/forms/EmbedPanel.tsx +5 -1
  247. package/src/pages/forms/FieldsEditor.tsx +204 -15
  248. package/src/pages/forms/FormSettings.tsx +156 -9
  249. package/src/pages/forms/SubmissionDetail.tsx +2 -1
  250. package/src/pages/forms/SubmissionsTable.tsx +2 -1
  251. package/src/pages/forms/fieldList.ts +39 -10
  252. package/src/pages/forms/template.ts +13 -0
  253. package/src/pages/handbook/HandbookPage.tsx +5 -6
  254. package/src/pages/onboarding/WorkspaceStepPage.tsx +19 -43
  255. package/src/pages/onboarding/onboardingRerun.ts +14 -0
  256. package/src/registry/context.ts +19 -0
  257. package/src/registry/contributions.ts +64 -1
  258. package/src/registry/registry.ts +48 -0
@@ -1,17 +1,23 @@
1
- import { FORM_STATUSES } from '@kelpie/schemas'
1
+ import { useState } from 'react'
2
+ import { FORM_SLUG_PATTERN, FORM_STATUSES } from '@kelpie/schemas'
2
3
  import type { Form, FormStatus } from '@kelpie/schemas'
3
4
 
4
- import { useUpdateForm } from '../../api/resources/forms.ts'
5
+ import { ApiError } from '../../api/client.ts'
6
+ import {
7
+ useRegenerateFormSlug,
8
+ useUpdateForm,
9
+ useUpdateFormSlug,
10
+ } from '../../api/resources/forms.ts'
5
11
  import { ErrorPanel } from '../../components/QueryState.tsx'
6
12
  import { SectionHeader } from '../../components/SectionHeader.tsx'
7
13
 
8
14
  /**
9
- * The form's identity: status, public heading, thank-you copy, and the public key.
15
+ * The form's identity: status, public heading, thank-you copy, and the slug.
10
16
  *
11
17
  * Every control commits on change, because each one is a single field and the
12
18
  * optimistic update in `createResourceHooks` puts the old value back if the
13
19
  * PATCH is refused. The field list is the exception and has its own Save; see
14
- * `FieldsEditor`. What the form *does* on submit — create records, tag them,
20
+ * `FieldsEditor`, and so is the slug, which asks first; see `SlugSetting`. What the form *does* on submit — create records, tag them,
15
21
  * add to lists, attach the submitter — lives on the Actions tab.
16
22
  */
17
23
 
@@ -32,7 +38,7 @@ export function FormSettings({ form }: FormSettingsProps): React.JSX.Element {
32
38
  <div className="max-w-xl space-y-4">
33
39
  <SectionHeader
34
40
  title="Settings"
35
- description="Status, the public form title, thank-you copy, and the public key."
41
+ description="Status, the public form title, thank-you copy, and the slug in its submit URL."
36
42
  />
37
43
 
38
44
  {updateForm.error !== null && <ErrorPanel error={updateForm.error} />}
@@ -90,14 +96,155 @@ export function FormSettings({ form }: FormSettingsProps): React.JSX.Element {
90
96
  <strong className="font-medium text-ink">Actions</strong> tab.
91
97
  </p>
92
98
 
93
- <Labelled label="Public key">
94
- <input className={`${inputClass} font-mono text-[12px]`} value={form.publicKey} readOnly />
95
- <Hint>The only credential the public submit takes. It never changes.</Hint>
96
- </Labelled>
99
+ {/* Keyed on the slug so the draft starts over whenever the stored slug moves. */}
100
+ <SlugSetting key={form.slug} form={form} />
97
101
  </div>
98
102
  )
99
103
  }
100
104
 
105
+ type SlugAction = 'change' | 'regenerate'
106
+
107
+ /**
108
+ * The form's slug, with an edit and a Regenerate button.
109
+ *
110
+ * The slug is only in the submit URL. Embed snippets use the form id, and the
111
+ * embed page carries the current submit URL, so embeds follow a change on their
112
+ * own. Anything that saved the old submit URL does not, which is the point of
113
+ * Regenerate. So, unlike the other settings, a change here does not commit on
114
+ * blur: both actions say what moves and wait for a confirm.
115
+ */
116
+ function SlugSetting({ form }: { readonly form: Form }): React.JSX.Element {
117
+ const updateSlug = useUpdateFormSlug()
118
+ const regenerateSlug = useRegenerateFormSlug()
119
+ const [draft, setDraft] = useState(form.slug)
120
+ const [confirming, setConfirming] = useState<SlugAction | null>(null)
121
+ const [lastError, setLastError] = useState<Error | null>(null)
122
+
123
+ const trimmed = draft.trim()
124
+ const edited = trimmed !== form.slug
125
+ const valid = FORM_SLUG_PATTERN.test(trimmed)
126
+ const isPending = updateSlug.isPending || regenerateSlug.isPending
127
+ const pendingAction: SlugAction | null = edited ? 'change' : confirming
128
+
129
+ const reset = (): void => {
130
+ setDraft(form.slug)
131
+ setConfirming(null)
132
+ setLastError(null)
133
+ }
134
+
135
+ const commit = async (): Promise<void> => {
136
+ setLastError(null)
137
+ try {
138
+ // Success moves `form.slug`, and the key on this component then resets it.
139
+ await (pendingAction === 'regenerate'
140
+ ? regenerateSlug.runAsync(form.id)
141
+ : updateSlug.runAsync({ id: form.id, slug: trimmed }))
142
+ } catch (error) {
143
+ setLastError(error instanceof Error ? error : new Error(String(error)))
144
+ }
145
+ }
146
+
147
+ return (
148
+ <div>
149
+ <label htmlFor="form-slug" className="mb-1.5 block text-[12px] font-medium text-ink">
150
+ Slug
151
+ </label>
152
+ <div className="flex gap-2">
153
+ <input
154
+ id="form-slug"
155
+ className={`${inputClass} font-mono text-[12px]`}
156
+ value={draft}
157
+ spellCheck={false}
158
+ autoComplete="off"
159
+ disabled={isPending}
160
+ aria-invalid={edited && !valid}
161
+ onChange={(event) => {
162
+ setDraft(event.target.value)
163
+ setConfirming(null)
164
+ setLastError(null)
165
+ }}
166
+ onKeyDown={(event) => {
167
+ if (event.key === 'Escape') {
168
+ reset()
169
+ }
170
+ }}
171
+ />
172
+ <button
173
+ type="button"
174
+ disabled={isPending || edited}
175
+ onClick={() => {
176
+ setConfirming('regenerate')
177
+ setLastError(null)
178
+ }}
179
+ className="shrink-0 rounded-md border border-border bg-surface-raised px-3 py-2 text-[12px] font-medium text-ink transition hover:bg-surface disabled:opacity-50"
180
+ >
181
+ Regenerate
182
+ </button>
183
+ </div>
184
+
185
+ {edited && !valid ? (
186
+ <p className="mt-1 text-[11px] text-danger">
187
+ Use 3 to 64 characters: letters, digits, hyphens (-) or underscores (_).
188
+ </p>
189
+ ) : (
190
+ <Hint>
191
+ The name of this form in its submit URL. It is not a secret: every page that embeds
192
+ the form shows it. If a bot sends spam to the form, regenerate the slug. Your
193
+ embeds keep working and use the new slug.
194
+ </Hint>
195
+ )}
196
+
197
+ {pendingAction !== null && (edited ? valid : true) && (
198
+ <div className="mt-2 rounded-md border border-border bg-surface px-3 py-2">
199
+ <p className="text-[12px] text-ink">
200
+ {pendingAction === 'regenerate'
201
+ ? 'Replace the slug with a new random one?'
202
+ : `Change the slug to "${trimmed}"?`}{' '}
203
+ Embeds on your sites change to the new slug in less than a minute. You do not
204
+ need to paste new code. Anything that sends to the old submit URL directly gets
205
+ an error.
206
+ </p>
207
+ <div className="mt-2 flex justify-end gap-2">
208
+ <button
209
+ type="button"
210
+ disabled={isPending}
211
+ onClick={reset}
212
+ className="rounded-md px-2 py-1 text-[12px] font-medium text-ink-muted hover:text-ink"
213
+ >
214
+ Cancel
215
+ </button>
216
+ <button
217
+ type="button"
218
+ disabled={isPending}
219
+ onClick={() => {
220
+ void commit()
221
+ }}
222
+ className="rounded-md bg-accent px-2.5 py-1 text-[12px] font-semibold text-accent-fg transition hover:bg-accent-hover disabled:opacity-50"
223
+ >
224
+ {isPending
225
+ ? 'Saving…'
226
+ : pendingAction === 'regenerate'
227
+ ? 'Regenerate slug'
228
+ : 'Change slug'}
229
+ </button>
230
+ </div>
231
+ </div>
232
+ )}
233
+
234
+ {lastError !== null && <p className="mt-1 text-[11px] text-danger">{slugErrorText(lastError)}</p>}
235
+ </div>
236
+ )
237
+ }
238
+
239
+ /** The field-level message for a refused slug write, when the API gives one. */
240
+ function slugErrorText(error: Error): string {
241
+ if (error instanceof ApiError && error.status === 409) {
242
+ return 'Another form in this workspace uses this slug. Choose a different one.'
243
+ }
244
+
245
+ return error.message
246
+ }
247
+
101
248
  function Labelled({
102
249
  label,
103
250
  children,
@@ -1,3 +1,4 @@
1
+ import { formFieldDisplayLabel } from '@kelpie/schemas'
1
2
  import type { Form, FormField, FormSubmission, FormSubmissionActionEntry } from '@kelpie/schemas'
2
3
  import { useMemo } from 'react'
3
4
  import { Link, useParams } from 'react-router'
@@ -112,7 +113,7 @@ function SubmissionDetailView({
112
113
  className="grid gap-0.5 px-3 py-2.5 sm:grid-cols-[10rem_1fr] sm:gap-3"
113
114
  >
114
115
  <dt className="text-[12px] font-medium text-ink-muted">
115
- {field.label}
116
+ {formFieldDisplayLabel(field)}
116
117
  {field.required && <span className="ml-0.5 text-danger">*</span>}
117
118
  </dt>
118
119
  <dd className="whitespace-pre-wrap text-[13px] text-ink">
@@ -1,3 +1,4 @@
1
+ import { formFieldDisplayLabel } from '@kelpie/schemas'
1
2
  import type { Form, FormSubmission, FormSubmissionActionEntry } from '@kelpie/schemas'
2
3
  import { useMemo } from 'react'
3
4
  import { Link, useNavigate } from 'react-router'
@@ -251,7 +252,7 @@ function summarise(form: Form, submission: FormSubmission): string {
251
252
  ? (field.options.find((option) => option.key === answer)?.value ?? answer)
252
253
  : answer
253
254
 
254
- return `${field.label}: ${shown}`
255
+ return `${formFieldDisplayLabel(field)}: ${shown}`
255
256
  })
256
257
  .filter((part): part is string => part !== undefined)
257
258
  .slice(0, 2)
@@ -1,5 +1,6 @@
1
1
  import {
2
2
  FORM_FIELD_TYPES,
3
+ FORM_LIST_TARGET,
3
4
  isCompatibleFormFieldType,
4
5
  isKnownMapTarget,
5
6
  isRepeatableMapTarget,
@@ -35,7 +36,13 @@ export interface EditableField extends FormFieldInput {
35
36
  readonly id: string
36
37
  }
37
38
 
38
- export const FIELD_TYPE_OPTIONS = FORM_FIELD_TYPES.map((type) => ({ value: type, label: type }))
39
+ /** The type picker's text. Each type shows as its own name, except `list`. */
40
+ const FIELD_TYPE_LABELS: Partial<Record<FormFieldType, string>> = { list: 'add to list' }
41
+
42
+ export const FIELD_TYPE_OPTIONS = FORM_FIELD_TYPES.map((type) => ({
43
+ value: type,
44
+ label: FIELD_TYPE_LABELS[type] ?? type,
45
+ }))
39
46
 
40
47
  export interface FindProblemsOptions {
41
48
  readonly customFieldDefinitions?: readonly CustomFieldDefinitionRef[]
@@ -54,6 +61,8 @@ export function toEditableFields(form: Form): EditableField[] {
54
61
  statement: field.statement,
55
62
  consentPurposeIds: [...field.consentPurposeIds],
56
63
  consentPurposeLabels: { ...field.consentPurposeLabels },
64
+ listIds: [...field.listIds],
65
+ listLabels: { ...field.listLabels },
57
66
  }))
58
67
  }
59
68
 
@@ -96,9 +105,9 @@ export function editField(
96
105
  return fields.map((field) => {
97
106
  if (field.id !== id) {
98
107
  // Only one field may carry a CRM target, so taking one releases it
99
- // wherever it was. `submission` and `person.consent` are the targets
100
- // that may repeat — consent's uniqueness is per purpose, not per
101
- // target, and is enforced when the purpose is picked.
108
+ // wherever it was. `submission`, `person.consent` and `lists` are the
109
+ // targets that may repeat — consent's uniqueness is per purpose, not
110
+ // per target, and is enforced when the purpose is picked.
102
111
  return change.mapTo !== undefined &&
103
112
  !isRepeatableMapTarget(change.mapTo) &&
104
113
  field.mapTo === change.mapTo
@@ -106,19 +115,32 @@ export function editField(
106
115
  : field
107
116
  }
108
117
 
109
- const next: EditableField = { ...field, ...change }
110
-
111
- // A consent or notice field must map to person.consent; anything else
112
- // clears any lingering purpose list.
118
+ let next: EditableField = { ...field, ...change }
113
119
  const isConsentLike = next.type === 'consent' || next.type === 'notice'
120
+ const isList = next.type === 'list'
121
+
122
+ // Only a consent or notice field carries purposes, and only a list field
123
+ // carries lists. A field that changes type drops the ones it left behind.
124
+ if (!isConsentLike && (next.consentPurposeIds ?? []).length > 0) {
125
+ next = { ...next, consentPurposeIds: [], consentPurposeLabels: {} }
126
+ }
127
+ if (!isList && (next.listIds ?? []).length > 0) {
128
+ next = { ...next, listIds: [], listLabels: {} }
129
+ }
130
+
131
+ // A list field maps to `lists`, and a consent or notice field to
132
+ // person.consent. Each of those targets takes only its own types.
133
+ if (isList && next.mapTo !== FORM_LIST_TARGET) {
134
+ return { ...withoutOptions(next), mapTo: FORM_LIST_TARGET }
135
+ }
114
136
  if (isConsentLike && next.mapTo !== PERSON_CONSENT_TARGET) {
115
137
  return { ...withoutOptions(next), mapTo: PERSON_CONSENT_TARGET }
116
138
  }
117
139
  if (next.mapTo === PERSON_CONSENT_TARGET && !isConsentLike) {
118
140
  return { ...withoutOptions(next), type: 'consent' }
119
141
  }
120
- if (!isConsentLike && (next.consentPurposeIds ?? []).length > 0) {
121
- return withoutOptions({ ...next, consentPurposeIds: [] })
142
+ if (next.mapTo === FORM_LIST_TARGET && !isList) {
143
+ return { ...withoutOptions(next), type: 'list' }
122
144
  }
123
145
 
124
146
  if (next.type !== 'select') {
@@ -242,6 +264,13 @@ export function findProblems(
242
264
  }
243
265
  }
244
266
  }
267
+ } else if (field.mapTo === FORM_LIST_TARGET) {
268
+ const lists = field.listIds ?? []
269
+ if (lists.length === 0) {
270
+ byField.set(field.id, 'Pick at least one list this field offers.')
271
+ } else if (new Set(lists).size !== lists.length) {
272
+ byField.set(field.id, 'This field lists a list twice.')
273
+ }
245
274
  } else if (!isRepeatableMapTarget(field.mapTo)) {
246
275
  if (seen.has(field.mapTo)) {
247
276
  byField.set(field.id, `Another field already maps to ${field.mapTo}.`)
@@ -130,6 +130,19 @@ export const SUBMISSION_FIELD_PRESETS: readonly SubmissionFieldPreset[] = [
130
130
  consentPurposeLabels: {},
131
131
  },
132
132
  },
133
+ {
134
+ menuLabel: 'Add to list',
135
+ field: {
136
+ label: 'Add to list',
137
+ type: 'list',
138
+ required: false,
139
+ mapTo: 'lists',
140
+ placeholder: null,
141
+ statement: null,
142
+ listIds: [],
143
+ listLabels: {},
144
+ },
145
+ },
133
146
  {
134
147
  menuLabel: 'Notice',
135
148
  field: {
@@ -23,6 +23,7 @@ import {
23
23
  import { useMembers } from '../../api/resources/members.ts'
24
24
  import { AgentTasks } from '../../components/AgentTasks.tsx'
25
25
  import { MarkdownView } from '../../components/MarkdownView.tsx'
26
+ import { RecordLinkTextarea } from '../../components/RecordLinkTextarea.tsx'
26
27
  import { ErrorPanel, LoadingPanel } from '../../components/QueryState.tsx'
27
28
  import { formatDateTime } from '../../lib/dates.ts'
28
29
  import { INDENT, descendantIds, flattenTree, landingMoves, projectDrop } from './tree.ts'
@@ -482,18 +483,16 @@ function HandbookEditor({
482
483
  </div>
483
484
  )}
484
485
  {editing ? (
485
- <textarea
486
+ <RecordLinkTextarea
486
487
  value={body}
487
- aria-label="Page body"
488
- onChange={(event) => {
489
- setBody(event.target.value)
490
- }}
488
+ ariaLabel="Page body"
489
+ onChange={setBody}
491
490
  className="min-h-[480px] w-full resize-y rounded-md border border-border bg-surface p-4 font-mono text-[13px] leading-relaxed outline-none focus:border-accent focus:ring-2 focus:ring-accent/20"
492
491
  spellCheck
493
492
  />
494
493
  ) : (
495
494
  <div className="animate-slide-in max-w-3xl">
496
- <MarkdownView source={page.body} />
495
+ <MarkdownView source={page.body} references={page.references} />
497
496
  </div>
498
497
  )}
499
498
  </div>
@@ -7,7 +7,7 @@ import { ErrorPanel } from '../../components/QueryState.tsx'
7
7
  import { TextField } from '../auth/AuthForm.tsx'
8
8
  import { AuthLayout } from '../auth/AuthLayout.tsx'
9
9
  import { OnboardingNav } from './OnboardingNav.tsx'
10
- import { isOnboardingRerun, ONBOARDING_ORG_PARAM, onboardingPath } from './onboardingRerun.ts'
10
+ import { isNewWorkspace, isOnboardingRerun, ONBOARDING_ORG_PARAM, onboardingPath } from './onboardingRerun.ts'
11
11
 
12
12
  /**
13
13
  * Onboarding step 1: the workspace, against `POST /v1/workspaces`.
@@ -26,15 +26,6 @@ import { isOnboardingRerun, ONBOARDING_ORG_PARAM, onboardingPath } from './onboa
26
26
  * signed out fills in a form whose only possible answer is `401`.
27
27
  */
28
28
 
29
- /** The rule the API enforces: lowercase letters, digits, and hyphens. */
30
- function slugify(name: string): string {
31
- return name
32
- .toLowerCase()
33
- .replace(/[^a-z0-9]+/gu, '-')
34
- .replace(/^-+|-+$/gu, '')
35
- .slice(0, 63)
36
- }
37
-
38
29
  /**
39
30
  * The zone the browser is in.
40
31
  *
@@ -50,32 +41,18 @@ export function WorkspaceStepPage(): React.JSX.Element {
50
41
  const navigate = useNavigate()
51
42
  const [searchParams] = useSearchParams()
52
43
  const rerun = isOnboardingRerun(searchParams)
44
+ const adding = isNewWorkspace(searchParams)
53
45
  const { isSignedOut, session } = useSession()
54
46
  const createWorkspace = useCreateWorkspace()
55
47
  const hasWorkspace = session?.workspaceId !== null && session?.workspaceId !== undefined
56
48
  const [name, setName] = useState('')
57
- const [slug, setSlug] = useState('')
58
- const [slugEdited, setSlugEdited] = useState(false)
59
49
  const [timezone] = useState(browserTimezone)
60
50
 
61
- function changeName(value: string): void {
62
- setName(value)
63
-
64
- if (!slugEdited) {
65
- setSlug(slugify(value))
66
- }
67
- }
68
-
69
- function changeSlug(value: string): void {
70
- setSlugEdited(true)
71
- setSlug(slugify(value))
72
- }
73
-
74
51
  function submit(event: FormEvent): void {
75
52
  event.preventDefault()
76
53
 
77
54
  createWorkspace
78
- .runAsync({ name: name.trim(), slug: slug.trim(), timezone })
55
+ .runAsync({ name: name.trim(), timezone })
79
56
  .then(() => {
80
57
  navigate('/onboarding/organisation', { replace: true })
81
58
  })
@@ -88,11 +65,12 @@ export function WorkspaceStepPage(): React.JSX.Element {
88
65
 
89
66
  /**
90
67
  * Previous on a later step lands here after the workspace already exists.
91
- * Showing the create form again would offer a second POST that this account
92
- * cannot use. Next is the only action that remains. A rerun keeps the flag
93
- * so organisation does not seed handbook pages and the review step is skipped.
68
+ * Showing the create form again would make a second workspace by accident,
69
+ * so Next is the only action. The workspace menu asks for the form on
70
+ * purpose with `?new=1`. A rerun keeps its flag so organisation does not
71
+ * seed handbook pages and the review step is skipped.
94
72
  */
95
- if (hasWorkspace) {
73
+ if (hasWorkspace && !adding) {
96
74
  return (
97
75
  <AuthLayout
98
76
  step={1}
@@ -124,31 +102,29 @@ export function WorkspaceStepPage(): React.JSX.Element {
124
102
  return (
125
103
  <AuthLayout
126
104
  step={1}
127
- title="Create your workspace"
105
+ title={adding ? 'Create a new workspace' : 'Create your workspace'}
128
106
  description="A workspace is your company brain — CRM records, handbook, and team."
129
107
  footer={
130
- <Link to="/login" className="font-medium text-accent hover:underline">
131
- Sign in as somebody else
132
- </Link>
108
+ adding ? (
109
+ <Link to="/dashboard" className="font-medium text-accent hover:underline">
110
+ Cancel
111
+ </Link>
112
+ ) : (
113
+ <Link to="/login" className="font-medium text-accent hover:underline">
114
+ Sign in as somebody else
115
+ </Link>
116
+ )
133
117
  }
134
118
  >
135
119
  <form onSubmit={submit} className="mt-5 space-y-3">
136
120
  <TextField
137
121
  label="Workspace name"
138
122
  value={name}
139
- onChange={changeName}
123
+ onChange={setName}
140
124
  placeholder="Acme Labs"
141
125
  autoComplete="organization"
142
126
  required
143
127
  />
144
- <TextField
145
- label="Slug"
146
- value={slug}
147
- onChange={changeSlug}
148
- hint="Lowercase letters, digits, and hyphens. It appears in URLs."
149
- mono
150
- required
151
- />
152
128
  <p className="text-[11px] text-ink-faint">
153
129
  Timezone: {timezone}. Change it later in Admin → Workspace.
154
130
  </p>
@@ -19,6 +19,20 @@ export function isOnboardingRerun(searchParams: URLSearchParams): boolean {
19
19
  return searchParams.get(ONBOARDING_RERUN_PARAM) === ONBOARDING_RERUN_VALUE
20
20
  }
21
21
 
22
+ /**
23
+ * An account that already has a workspace can add another from the workspace
24
+ * menu. `?new=1` shows the create form on step 1 instead of "ready". The new
25
+ * workspace then walks the whole wizard, handbook seeding included.
26
+ */
27
+ export const ONBOARDING_NEW_PARAM = 'new'
28
+
29
+ /** Entry URL the workspace menu opens to add a workspace. */
30
+ export const ONBOARDING_NEW_WORKSPACE_ENTRY = `/onboarding/workspace?${ONBOARDING_NEW_PARAM}=1`
31
+
32
+ export function isNewWorkspace(searchParams: URLSearchParams): boolean {
33
+ return searchParams.get(ONBOARDING_NEW_PARAM) === '1'
34
+ }
35
+
22
36
  /**
23
37
  * Keep the rerun flag and the organisation type when moving between onboarding
24
38
  * routes. `org` is how the modules step knows which defaults to offer; nothing
@@ -2,11 +2,15 @@ import { createContext, useContext } from 'react'
2
2
  import type { ComponentType } from 'react'
3
3
 
4
4
  import type {
5
+ AdminTab,
6
+ AgentRunner,
5
7
  AuthMethod,
6
8
  DashboardCard,
9
+ ExtensibleAdminPage,
7
10
  ExtensibleRecordType,
8
11
  NavItem,
9
12
  NavSlot,
13
+ PersonIntakeProvider,
10
14
  RecordSidebarCard,
11
15
  RecordTab,
12
16
  RouteContribution,
@@ -50,6 +54,11 @@ export function useRecordSidebarCards(objectType: ExtensibleRecordType): readonl
50
54
  return useUiExtensions().recordSidebarCards(objectType)
51
55
  }
52
56
 
57
+ /** Module tabs for an admin page, in order. The page merges its own tabs in. */
58
+ export function useAdminTabs(page: ExtensibleAdminPage): readonly AdminTab[] {
59
+ return useUiExtensions().adminTabs(page)
60
+ }
61
+
53
62
  export function useDashboardCards(): readonly DashboardCard[] {
54
63
  return useUiExtensions().dashboardCards()
55
64
  }
@@ -59,6 +68,16 @@ export function useAuthMethods(): readonly AuthMethod[] {
59
68
  return useUiExtensions().authMethods()
60
69
  }
61
70
 
71
+ /** The agent the Agent menu's Run button dispatches to, when a module provides one. */
72
+ export function useAgentRunner(): AgentRunner | undefined {
73
+ return useUiExtensions().agentRunner()
74
+ }
75
+
76
+ /** The wizard behind People's Add from notes, when a module provides one. */
77
+ export function usePersonIntakeProvider(): PersonIntakeProvider | undefined {
78
+ return useUiExtensions().personIntake()
79
+ }
80
+
62
81
  /**
63
82
  * The component to render for an overridable: a module's replacement, or core's
64
83
  * own. Core calls this instead of rendering its component directly.
@@ -1,5 +1,5 @@
1
1
  import type { ExtensibleRecordType } from '@kelpie/schemas'
2
- import type { ReactNode } from 'react'
2
+ import type { ComponentType, ReactNode } from 'react'
3
3
 
4
4
  /**
5
5
  * What a UI module may add to the shell.
@@ -82,6 +82,20 @@ export interface RecordTab {
82
82
  readonly render: (context: RecordContext) => ReactNode
83
83
  }
84
84
 
85
+ /**
86
+ * An admin page whose tabs modules may add to. `ai` is Admin → AI: core owns
87
+ * the page and its MCP tab, and the optional `ai` module adds Kelpie AI's
88
+ * settings and run log.
89
+ */
90
+ export type ExtensibleAdminPage = 'ai'
91
+
92
+ export interface AdminTab {
93
+ readonly id: string
94
+ readonly label: string
95
+ readonly order?: number
96
+ readonly render: () => ReactNode
97
+ }
98
+
85
99
  export interface RecordSidebarCard {
86
100
  readonly id: string
87
101
  readonly order?: number
@@ -94,3 +108,52 @@ export interface DashboardCard {
94
108
  readonly render: () => ReactNode
95
109
  }
96
110
 
111
+
112
+ /**
113
+ * Whether the runner can take a task now, for the workspace the viewer is in.
114
+ * `reason` is a sentence the Agent menu shows on its disabled Run button.
115
+ */
116
+ export type AgentRunnerAvailability =
117
+ | { readonly status: 'loading' }
118
+ | { readonly status: 'unavailable'; readonly reason: string }
119
+ | { readonly status: 'ready'; readonly agentId: string }
120
+
121
+ /** Where a dispatched run got to, once core has handed it to the runner's agent. */
122
+ export type AgentRunnerProgress =
123
+ | { readonly status: 'running' }
124
+ | { readonly status: 'succeeded' }
125
+ | { readonly status: 'failed'; readonly reason: string }
126
+
127
+ /**
128
+ * The agent the Agent menu's Run button dispatches to, with no dialog.
129
+ *
130
+ * Core has no model of its own, so with no runner registered Run stays
131
+ * disabled and Preview is the way to reach a registered agent. Both members are
132
+ * React hooks: the menu calls them on every render, so they follow the Rules of
133
+ * Hooks, and `enabled` lets the menu defer the fetch until it opens.
134
+ */
135
+ export interface AgentRunner {
136
+ readonly id: string
137
+ readonly useAvailability: (options: { readonly enabled: boolean }) => AgentRunnerAvailability
138
+ /** Progress for the core agent run `agentRunId`. `undefined` polls nothing. */
139
+ readonly useProgress: (agentRunId: string | undefined) => AgentRunnerProgress | undefined
140
+ }
141
+
142
+ export interface PersonIntakeWizardProps {
143
+ /** Closes the dialog the wizard sits in. */
144
+ readonly onClose: () => void
145
+ }
146
+
147
+ /**
148
+ * The model-driven wizard behind People's **Add from notes**.
149
+ *
150
+ * Core owns the button and the dialog, and with no provider (or one that is
151
+ * not ready) the dialog offers a copy-prompt for the user's own agent. A
152
+ * provider replaces that with a wizard that identifies, researches and
153
+ * creates. `useAvailability` is a hook, with the runner's shape and rules.
154
+ */
155
+ export interface PersonIntakeProvider {
156
+ readonly id: string
157
+ readonly useAvailability: (options: { readonly enabled: boolean }) => AgentRunnerAvailability
158
+ readonly Wizard: ComponentType<PersonIntakeWizardProps>
159
+ }