@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
@@ -0,0 +1,83 @@
1
+ import { AI_SERVICE_LABELS } from '@kelpie/schemas'
2
+
3
+ import { ApiError } from '../api/client.ts'
4
+ import { useAiRunForAgentRun, useAiSettings } from '../api/resources/ai.ts'
5
+ import { useAgents } from '../api/resources/agentTasks.ts'
6
+ import type { AgentRunner, AgentRunnerAvailability, AgentRunnerProgress } from '../registry/contributions.ts'
7
+
8
+ /** The `managed_by` value the server module writes on its agent row. */
9
+ const AI_MODULE_ID = 'ai'
10
+
11
+ /**
12
+ * Kelpie AI as the Agent menu's runner.
13
+ *
14
+ * Ready only when the workspace can run a task now: the module answers (so it
15
+ * is in the assembly and switched on), AI is enabled, a provider and key are
16
+ * available (the workspace's own, or the deployment's), and the agent row the
17
+ * module manages exists to dispatch to.
18
+ */
19
+ function useAvailability(options: { readonly enabled: boolean }): AgentRunnerAvailability {
20
+ const settings = useAiSettings({ enabled: options.enabled })
21
+ const agents = useAgents({ enabled: options.enabled })
22
+
23
+ if (settings.isLoading || agents.isLoading || !options.enabled) {
24
+ return { status: 'loading' }
25
+ }
26
+
27
+ if (settings.error !== null) {
28
+ // The runtime answers 403 or 404 when the module is switched off.
29
+ return settings.error instanceof ApiError && (settings.error.status === 403 || settings.error.status === 404)
30
+ ? { status: 'unavailable', reason: 'AI is switched off for this workspace.' }
31
+ : { status: 'unavailable', reason: 'AI settings could not be read.' }
32
+ }
33
+
34
+ const record = settings.record
35
+ const label = record === undefined ? 'AI' : AI_SERVICE_LABELS[record.service]
36
+
37
+ if (record === undefined || !record.enabled) {
38
+ return { status: 'unavailable', reason: `${label} is not enabled. An admin can enable it under Admin → AI.` }
39
+ }
40
+
41
+ if (!record.configured) {
42
+ return {
43
+ status: 'unavailable',
44
+ reason: `${label} has no provider key. An admin can add one under Admin → AI.`,
45
+ }
46
+ }
47
+
48
+ const agent = agents.records.find((candidate) => candidate.managedBy === AI_MODULE_ID)
49
+
50
+ if (agent === undefined) {
51
+ return {
52
+ status: 'unavailable',
53
+ reason: `The ${label} agent is missing. An admin can save Admin → AI again to restore it.`,
54
+ }
55
+ }
56
+
57
+ return { status: 'ready', agentId: agent.id }
58
+ }
59
+
60
+ function useProgress(agentRunId: string | undefined): AgentRunnerProgress | undefined {
61
+ const run = useAiRunForAgentRun(agentRunId)
62
+
63
+ if (agentRunId === undefined) {
64
+ return undefined
65
+ }
66
+
67
+ switch (run?.status) {
68
+ case 'succeeded':
69
+ return { status: 'succeeded' }
70
+ case 'failed':
71
+ return { status: 'failed', reason: run.failureReason ?? 'no reason recorded' }
72
+ case 'queued':
73
+ case 'running':
74
+ case undefined:
75
+ return { status: 'running' }
76
+ }
77
+ }
78
+
79
+ export const aiRunner: AgentRunner = {
80
+ id: AI_MODULE_ID,
81
+ useAvailability,
82
+ useProgress,
83
+ }
@@ -0,0 +1,24 @@
1
+ import { personIntakeDependencies } from '@kelpie/schemas'
2
+ import type { PersonIntakeItem } from '@kelpie/schemas'
3
+
4
+ /**
5
+ * The items that can be written given what is ticked: an item whose
6
+ * dependency is unticked, or cannot be written, drops out too.
7
+ */
8
+ export function effectiveSelection(items: readonly PersonIntakeItem[], ticked: ReadonlySet<string>): ReadonlySet<string> {
9
+ const keys = new Set(items.map((item) => item.key))
10
+ const effective = new Set([...ticked].filter((key) => keys.has(key)))
11
+ let changed = true
12
+
13
+ while (changed) {
14
+ changed = false
15
+ for (const item of items) {
16
+ if (effective.has(item.key) && personIntakeDependencies(item).some((key) => !effective.has(key))) {
17
+ effective.delete(item.key)
18
+ changed = true
19
+ }
20
+ }
21
+ }
22
+
23
+ return effective
24
+ }
@@ -56,6 +56,7 @@ import { SidebarField } from '../components/SidebarField.tsx'
56
56
  import { SummaryBlock } from '../components/SummaryBlock.tsx'
57
57
  import { useRecordTabs } from '../registry/context.ts'
58
58
  import { inSlotOrder } from '../registry/registry.ts'
59
+ import { useRecordTab } from '../lib/fragmentTarget.ts'
59
60
  import { toOptions, toTags } from './fields.ts'
60
61
 
61
62
  /**
@@ -87,7 +88,7 @@ export function CompanyDetail(): React.JSX.Element {
87
88
  const moduleTabs = inSlotOrder(useRecordTabs('company'))
88
89
  const hasCustomFields = useHasCustomFields('company')
89
90
  const eventsEnabled = useModuleEnabled('events')
90
- const [activeTab, setActiveTab] = useState('overview')
91
+ const [activeTab, setActiveTab] = useRecordTab()
91
92
  const formSubmissions = useFormSubmissionsForRecord('company', id)
92
93
 
93
94
  if (isNotFound) {
@@ -42,6 +42,7 @@ import { SidebarField } from '../components/SidebarField.tsx'
42
42
  import { SummaryBlock } from '../components/SummaryBlock.tsx'
43
43
  import { formatDay } from '../lib/dates.ts'
44
44
  import { formatMoney } from '../lib/money.ts'
45
+ import { useRecordTab } from '../lib/fragmentTarget.ts'
45
46
  import { useRecordTabs } from '../registry/context.ts'
46
47
  import { inSlotOrder } from '../registry/registry.ts'
47
48
  import { toTags } from './fields.ts'
@@ -68,7 +69,7 @@ export function DealDetail(): React.JSX.Element {
68
69
  const moduleTabs = inSlotOrder(useRecordTabs('deal'))
69
70
  const hasCustomFields = useHasCustomFields('deal')
70
71
  const eventsEnabled = useModuleEnabled('events')
71
- const [activeTab, setActiveTab] = useState('overview')
72
+ const [activeTab, setActiveTab] = useRecordTab()
72
73
  const [showConvert, setShowConvert] = useState(false)
73
74
  const formSubmissions = useFormSubmissionsForRecord('deal', id)
74
75
 
@@ -46,6 +46,7 @@ import { SidebarField } from '../components/SidebarField.tsx'
46
46
  import { SummaryBlock } from '../components/SummaryBlock.tsx'
47
47
  import { useRecordTabs } from '../registry/context.ts'
48
48
  import { inSlotOrder } from '../registry/registry.ts'
49
+ import { useRecordTab } from '../lib/fragmentTarget.ts'
49
50
  import { toTags } from './fields.ts'
50
51
 
51
52
  /**
@@ -71,7 +72,7 @@ export function EnquiryDetail(): React.JSX.Element {
71
72
  const moduleTabs = inSlotOrder(useRecordTabs('enquiry'))
72
73
  const hasCustomFields = useHasCustomFields('enquiry')
73
74
  const eventsEnabled = useModuleEnabled('events')
74
- const [activeTab, setActiveTab] = useState('overview')
75
+ const [activeTab, setActiveTab] = useRecordTab()
75
76
  const [showConvert, setShowConvert] = useState(false)
76
77
  const formSubmissions = useFormSubmissionsForRecord('enquiry', id)
77
78
 
@@ -64,6 +64,7 @@ import { SidebarField } from '../components/SidebarField.tsx'
64
64
  import { SummaryBlock } from '../components/SummaryBlock.tsx'
65
65
  import { TimezoneSearch } from '../components/TimezoneSearch.tsx'
66
66
  import { formatDateTime } from '../lib/dates.ts'
67
+ import { useRecordTab } from '../lib/fragmentTarget.ts'
67
68
  import { useRecordTabs } from '../registry/context.ts'
68
69
  import { inSlotOrder } from '../registry/registry.ts'
69
70
  import { toTags } from './fields.ts'
@@ -106,7 +107,7 @@ export function EventDetail(): React.JSX.Element {
106
107
  const deleteEvent = useDeleteEvent()
107
108
  const moduleTabs = inSlotOrder(useRecordTabs('event'))
108
109
  const hasCustomFields = useHasCustomFields('event')
109
- const [activeTab, setActiveTab] = useState('overview')
110
+ const [activeTab, setActiveTab] = useRecordTab()
110
111
 
111
112
  if (isNotFound) {
112
113
  return <NotFoundPanel label="Event" backTo="/events" />
@@ -136,11 +136,11 @@ export function FormsPage(): React.JSX.Element {
136
136
  ),
137
137
  },
138
138
  {
139
- key: 'publicKey',
140
- header: 'Public key',
141
- getSortValue: (form) => form.publicKey,
139
+ key: 'slug',
140
+ header: 'Slug',
141
+ getSortValue: (form) => form.slug,
142
142
  render: (form) => (
143
- <span className="font-mono text-[12px] text-ink-muted">{form.publicKey}</span>
143
+ <span className="font-mono text-[12px] text-ink-muted">{form.slug}</span>
144
144
  ),
145
145
  },
146
146
  {
@@ -45,6 +45,7 @@ import { SectionHeader } from '../components/SectionHeader.tsx'
45
45
  import { SidebarField } from '../components/SidebarField.tsx'
46
46
  import { SummaryBlock } from '../components/SummaryBlock.tsx'
47
47
  import { formatDay } from '../lib/dates.ts'
48
+ import { useRecordTab } from '../lib/fragmentTarget.ts'
48
49
  import { useRecordTabs } from '../registry/context.ts'
49
50
  import { inSlotOrder } from '../registry/registry.ts'
50
51
  import { toTags } from './fields.ts'
@@ -73,7 +74,7 @@ export function OpportunityDetail(): React.JSX.Element {
73
74
  const moduleTabs = inSlotOrder(useRecordTabs('opportunity'))
74
75
  const hasCustomFields = useHasCustomFields('opportunity')
75
76
  const eventsEnabled = useModuleEnabled('events')
76
- const [activeTab, setActiveTab] = useState('overview')
77
+ const [activeTab, setActiveTab] = useRecordTab()
77
78
  const [showConvert, setShowConvert] = useState(false)
78
79
  const formSubmissions = useFormSubmissionsForRecord('opportunity', id)
79
80
 
@@ -45,6 +45,7 @@ import { SectionHeader } from '../components/SectionHeader.tsx'
45
45
  import { SidebarField } from '../components/SidebarField.tsx'
46
46
  import { SummaryBlock } from '../components/SummaryBlock.tsx'
47
47
  import { formatDay } from '../lib/dates.ts'
48
+ import { useRecordTab } from '../lib/fragmentTarget.ts'
48
49
  import { useRecordTabs } from '../registry/context.ts'
49
50
  import { inSlotOrder } from '../registry/registry.ts'
50
51
  import { toTags } from './fields.ts'
@@ -73,7 +74,7 @@ export function PartnershipDetail(): React.JSX.Element {
73
74
  const moduleTabs = inSlotOrder(useRecordTabs('partnership'))
74
75
  const hasCustomFields = useHasCustomFields('partnership')
75
76
  const eventsEnabled = useModuleEnabled('events')
76
- const [activeTab, setActiveTab] = useState('overview')
77
+ const [activeTab, setActiveTab] = useRecordTab()
77
78
  const [showConvert, setShowConvert] = useState(false)
78
79
  const formSubmissions = useFormSubmissionsForRecord('partnership', id)
79
80
 
@@ -9,6 +9,7 @@ import { Chip } from '../components/Chip.tsx'
9
9
  import { SocialNetworkIcon } from '../components/SocialNetworkIcon.tsx'
10
10
  import { ColumnPicker } from '../components/ColumnPicker.tsx'
11
11
  import { DataTable } from '../components/DataTable.tsx'
12
+ import { AddFromNotesButton, PersonIntakeDialog } from '../components/PersonIntakeDialog.tsx'
12
13
  import type { Column } from '../components/DataTable.tsx'
13
14
  import { FilterBar, PageHeader } from '../components/PageHeader.tsx'
14
15
  import { Paginator } from '../components/Paginator.tsx'
@@ -59,6 +60,7 @@ export function PeoplePage(): React.JSX.Element {
59
60
  })
60
61
  const directory = usePeopleDirectory(people.records.map((person) => person.id))
61
62
  const createPerson = useCreatePerson()
63
+ const [intakeOpen, setIntakeOpen] = useState(false)
62
64
 
63
65
  async function addPerson(): Promise<void> {
64
66
  // The same defaults the API applies, so a person created here and one
@@ -242,13 +244,27 @@ export function PeoplePage(): React.JSX.Element {
242
244
  }}
243
245
  addLabel="Add person"
244
246
  actions={
245
- <ColumnPicker
246
- options={pickerOptions}
247
- visibleKeys={listView.visibleKeys}
248
- onChange={listView.setVisibleKeys}
249
- />
247
+ <>
248
+ <ColumnPicker
249
+ options={pickerOptions}
250
+ visibleKeys={listView.visibleKeys}
251
+ onChange={listView.setVisibleKeys}
252
+ />
253
+ <AddFromNotesButton
254
+ onClick={() => {
255
+ setIntakeOpen(true)
256
+ }}
257
+ />
258
+ </>
250
259
  }
251
260
  />
261
+ {intakeOpen && (
262
+ <PersonIntakeDialog
263
+ onClose={() => {
264
+ setIntakeOpen(false)
265
+ }}
266
+ />
267
+ )}
252
268
  <FilterBar
253
269
  value={term}
254
270
  onChange={setTerm}
@@ -55,6 +55,7 @@ import { PhonesField } from '../components/PhonesField.tsx'
55
55
  import { SummaryBlock } from '../components/SummaryBlock.tsx'
56
56
  import { useRecordTabs } from '../registry/context.ts'
57
57
  import { inSlotOrder } from '../registry/registry.ts'
58
+ import { useRecordTab } from '../lib/fragmentTarget.ts'
58
59
  import {
59
60
  CandidateReferrerField,
60
61
  CandidateStageField,
@@ -91,7 +92,7 @@ export function PersonDetail(): React.JSX.Element {
91
92
  const moduleTabs = inSlotOrder(useRecordTabs('person'))
92
93
  const hasCustomFields = useHasCustomFields('person')
93
94
  const eventsEnabled = useModuleEnabled('events')
94
- const [activeTab, setActiveTab] = useState('overview')
95
+ const [activeTab, setActiveTab] = useRecordTab()
95
96
  const candidacies = useCandidates({ personIds: id === undefined ? [] : [id] }, {
96
97
  enabled: id !== undefined,
97
98
  })
@@ -40,6 +40,7 @@ import { SidebarField } from '../components/SidebarField.tsx'
40
40
  import { SummaryBlock } from '../components/SummaryBlock.tsx'
41
41
  import { formatDay } from '../lib/dates.ts'
42
42
  import { formatMoney } from '../lib/money.ts'
43
+ import { useRecordTab } from '../lib/fragmentTarget.ts'
43
44
  import { useRecordTabs } from '../registry/context.ts'
44
45
  import { inSlotOrder } from '../registry/registry.ts'
45
46
  import { toTags } from './fields.ts'
@@ -72,7 +73,7 @@ export function RaiseDetail(): React.JSX.Element {
72
73
  const moduleTabs = inSlotOrder(useRecordTabs('raise'))
73
74
  const hasCustomFields = useHasCustomFields('raise')
74
75
  const eventsEnabled = useModuleEnabled('events')
75
- const [activeTab, setActiveTab] = useState('overview')
76
+ const [activeTab, setActiveTab] = useRecordTab()
76
77
  const [showConvert, setShowConvert] = useState(false)
77
78
 
78
79
  if (isNotFound) {
@@ -4,6 +4,7 @@ import { Link, useSearchParams } from 'react-router'
4
4
  import { useSearch } from '../api/resources/search.ts'
5
5
  import { ErrorPanel, LoadingPanel } from '../components/QueryState.tsx'
6
6
  import { PageHeader } from '../components/PageHeader.tsx'
7
+ import { attachedHref } from '../lib/recordLinks.ts'
7
8
 
8
9
  /**
9
10
  * `/search?q=`, the destination of the box in the application shell.
@@ -13,21 +14,35 @@ import { PageHeader } from '../components/PageHeader.tsx'
13
14
  * renderer, and the only thing it still owns is where a result links to.
14
15
  */
15
16
 
17
+ /**
18
+ * Where a Decision, Note or Plan item result opens: the page of the record it is
19
+ * on, at the item. With no record to open, the fallback.
20
+ */
21
+ function onItsRecord(fallback: string): (item: SearchResult) => string {
22
+ return (item) => (item.target === null ? fallback : (attachedHref(item.id, item.target) ?? fallback))
23
+ }
24
+
16
25
  /** What each collection is called on screen, and where one of its results lives. */
17
- const COLLECTIONS: Readonly<Record<SearchCollection, { label: string; path: (id: string) => string }>> = {
18
- handbook_page: { label: 'Handbook', path: (id) => `/handbook/${id}` },
19
- person: { label: 'People', path: (id) => `/people/${id}` },
20
- role: { label: 'Roles', path: (id) => `/hiring/${id}` },
21
- company: { label: 'Companies', path: (id) => `/companies/${id}` },
22
- enquiry: { label: 'Enquiries', path: (id) => `/enquiries/${id}` },
23
- deal: { label: 'Deals', path: (id) => `/deals/${id}` },
24
- opportunity: { label: 'Opportunities', path: (id) => `/opportunities/${id}` },
25
- raise: { label: 'Fundraising', path: (id) => `/fundraising/${id}` },
26
- partnership: { label: 'Partnerships', path: (id) => `/partnerships/${id}` },
27
- event: { label: 'Events', path: (id) => `/events/${id}` },
28
- // Decisions have no detail page of their own, in the mockup or here. The global
29
- // list is where one is read.
30
- decision: { label: 'Decisions', path: () => '/decisions' },
26
+ const COLLECTIONS: Readonly<
27
+ Record<SearchCollection, { label: string; path: (item: SearchResult) => string }>
28
+ > = {
29
+ handbook_page: { label: 'Handbook', path: (item) => `/handbook/${item.id}` },
30
+ person: { label: 'People', path: (item) => `/people/${item.id}` },
31
+ role: { label: 'Roles', path: (item) => `/hiring/${item.id}` },
32
+ company: { label: 'Companies', path: (item) => `/companies/${item.id}` },
33
+ enquiry: { label: 'Enquiries', path: (item) => `/enquiries/${item.id}` },
34
+ deal: { label: 'Deals', path: (item) => `/deals/${item.id}` },
35
+ opportunity: { label: 'Opportunities', path: (item) => `/opportunities/${item.id}` },
36
+ raise: { label: 'Fundraising', path: (item) => `/fundraising/${item.id}` },
37
+ partnership: { label: 'Partnerships', path: (item) => `/partnerships/${item.id}` },
38
+ event: { label: 'Events', path: (item) => `/events/${item.id}` },
39
+ // Decisions, Notes and Plan items have no page of their own. Each opens on the
40
+ // record it is on; the global list is where a decision with none is read.
41
+ decision: { label: 'Decisions', path: onItsRecord('/decisions') },
42
+ note: { label: 'Notes', path: onItsRecord('/dashboard') },
43
+ plan_item: { label: 'Plan items', path: onItsRecord('/planning') },
44
+ list: { label: 'Lists', path: (item) => `/lists/${item.id}` },
45
+ form: { label: 'Forms', path: (item) => `/forms/${item.id}` },
31
46
  }
32
47
 
33
48
  export function SearchPage(): React.JSX.Element {
@@ -120,7 +135,7 @@ function ResultRow({
120
135
  }): React.JSX.Element {
121
136
  return (
122
137
  <Link
123
- to={COLLECTIONS[collection].path(item.id)}
138
+ to={COLLECTIONS[collection].path(item)}
124
139
  className="block px-4 py-2.5 transition hover:bg-accent-soft/30"
125
140
  >
126
141
  <div className="flex items-center justify-between gap-3">
@@ -0,0 +1,52 @@
1
+ import type { ReactNode } from 'react'
2
+ import { useSearchParams } from 'react-router'
3
+
4
+ import { PageHeader } from '../../components/PageHeader.tsx'
5
+ import { RecordTabs } from '../../components/RecordTabs.tsx'
6
+ import { useAdminTabs } from '../../registry/context.ts'
7
+ import { inSlotOrder } from '../../registry/registry.ts'
8
+ import { McpPanel } from './McpPanel.tsx'
9
+
10
+ /**
11
+ * Admin → AI at `/admin/ai`: how agents reach this workspace.
12
+ *
13
+ * Core owns the page and its MCP tab, so every install has both. The optional
14
+ * `ai` module adds Kelpie AI's Settings and Run log tabs through `adminTab`,
15
+ * ordered before MCP. Without that module the page is MCP alone.
16
+ *
17
+ * The open tab is `?tab=`, so a link can open one; `/admin/mcp` redirects to
18
+ * `?tab=mcp`. With no `tab`, or one no module provides, the first tab opens.
19
+ */
20
+
21
+ interface PageTab {
22
+ readonly id: string
23
+ readonly label: string
24
+ readonly order?: number
25
+ readonly render: () => ReactNode
26
+ }
27
+
28
+ const MCP_TAB: PageTab = { id: 'mcp', label: 'MCP', order: 300, render: () => <McpPanel /> }
29
+
30
+ export function AiAdminPage(): React.JSX.Element {
31
+ const moduleTabs = useAdminTabs('ai')
32
+ const tabs = inSlotOrder<PageTab>([...moduleTabs, MCP_TAB])
33
+ const [searchParams, setSearchParams] = useSearchParams()
34
+ const requested = searchParams.get('tab')
35
+ const active = tabs.find((tab) => tab.id === requested) ?? tabs[0] ?? MCP_TAB
36
+
37
+ return (
38
+ <div className="animate-slide-in mx-auto max-w-4xl space-y-6">
39
+ <PageHeader title="AI" description="Connect agents to this workspace, and run agent tasks." />
40
+ <RecordTabs
41
+ tabs={tabs.map((tab) => ({ id: tab.id, label: tab.label }))}
42
+ active={active.id}
43
+ onChange={(id) => {
44
+ setSearchParams({ tab: id }, { replace: true })
45
+ }}
46
+ ariaLabel="AI sections"
47
+ >
48
+ {active.render()}
49
+ </RecordTabs>
50
+ </div>
51
+ )
52
+ }