@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.
- package/dist/api/client.d.ts +1 -1
- package/dist/api/resources/ai.d.ts +21 -0
- package/dist/api/resources/ai.d.ts.map +1 -0
- package/dist/api/resources/ai.js +101 -0
- package/dist/api/resources/ai.js.map +1 -0
- package/dist/api/resources/conversions.js +1 -1
- package/dist/api/resources/conversions.js.map +1 -1
- package/dist/api/resources/forms.d.ts +8 -0
- package/dist/api/resources/forms.d.ts.map +1 -1
- package/dist/api/resources/forms.js +39 -0
- package/dist/api/resources/forms.js.map +1 -1
- package/dist/api/resources/personIntake.d.ts +12 -0
- package/dist/api/resources/personIntake.d.ts.map +1 -0
- package/dist/api/resources/personIntake.js +54 -0
- package/dist/api/resources/personIntake.js.map +1 -0
- package/dist/api/resources/session.d.ts.map +1 -1
- package/dist/api/resources/session.js +3 -1
- package/dist/api/resources/session.js.map +1 -1
- package/dist/api/resources/workspace.d.ts +2 -2
- package/dist/api/resources/workspace.js +2 -2
- package/dist/app/KelpieApp.js +2 -2
- package/dist/app/KelpieApp.js.map +1 -1
- package/dist/components/ActivitiesPanel.d.ts +7 -4
- package/dist/components/ActivitiesPanel.d.ts.map +1 -1
- package/dist/components/ActivitiesPanel.js +12 -2
- package/dist/components/ActivitiesPanel.js.map +1 -1
- package/dist/components/ActivityAction.d.ts +15 -0
- package/dist/components/ActivityAction.d.ts.map +1 -0
- package/dist/components/ActivityAction.js +20 -0
- package/dist/components/ActivityAction.js.map +1 -0
- package/dist/components/AgentTasks.d.ts +5 -0
- package/dist/components/AgentTasks.d.ts.map +1 -1
- package/dist/components/AgentTasks.js +88 -10
- package/dist/components/AgentTasks.js.map +1 -1
- package/dist/components/DecisionsPanel.d.ts.map +1 -1
- package/dist/components/DecisionsPanel.js +3 -1
- package/dist/components/DecisionsPanel.js.map +1 -1
- package/dist/components/LinkedText.d.ts +12 -0
- package/dist/components/LinkedText.d.ts.map +1 -0
- package/dist/components/LinkedText.js +25 -0
- package/dist/components/LinkedText.js.map +1 -0
- package/dist/components/MarkdownView.d.ts +3 -1
- package/dist/components/MarkdownView.d.ts.map +1 -1
- package/dist/components/MarkdownView.js +17 -3
- package/dist/components/MarkdownView.js.map +1 -1
- package/dist/components/NotesPanel.d.ts +2 -1
- package/dist/components/NotesPanel.d.ts.map +1 -1
- package/dist/components/NotesPanel.js +6 -7
- package/dist/components/NotesPanel.js.map +1 -1
- package/dist/components/PersonIntakeDialog.d.ts +19 -0
- package/dist/components/PersonIntakeDialog.d.ts.map +1 -0
- package/dist/components/PersonIntakeDialog.js +87 -0
- package/dist/components/PersonIntakeDialog.js.map +1 -0
- package/dist/components/PlanPanel.d.ts.map +1 -1
- package/dist/components/PlanPanel.js +3 -1
- package/dist/components/PlanPanel.js.map +1 -1
- package/dist/components/RecordLinkTextarea.d.ts +12 -0
- package/dist/components/RecordLinkTextarea.d.ts.map +1 -0
- package/dist/components/RecordLinkTextarea.js +142 -0
- package/dist/components/RecordLinkTextarea.js.map +1 -0
- package/dist/components/Shell.js +1 -1
- package/dist/components/Shell.js.map +1 -1
- package/dist/components/WorkspaceSwitcher.d.ts +2 -1
- package/dist/components/WorkspaceSwitcher.d.ts.map +1 -1
- package/dist/components/WorkspaceSwitcher.js +7 -2
- package/dist/components/WorkspaceSwitcher.js.map +1 -1
- package/dist/index.d.ts +5 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -1
- package/dist/index.js.map +1 -1
- package/dist/lib/fragmentTarget.d.ts +18 -0
- package/dist/lib/fragmentTarget.d.ts.map +1 -0
- package/dist/lib/fragmentTarget.js +73 -0
- package/dist/lib/fragmentTarget.js.map +1 -0
- package/dist/lib/recordLinks.d.ts +17 -0
- package/dist/lib/recordLinks.d.ts.map +1 -0
- package/dist/lib/recordLinks.js +48 -0
- package/dist/lib/recordLinks.js.map +1 -0
- package/dist/lib/recordReferences.d.ts +41 -0
- package/dist/lib/recordReferences.d.ts.map +1 -0
- package/dist/lib/recordReferences.js +92 -0
- package/dist/lib/recordReferences.js.map +1 -0
- package/dist/modules/PersonIntakeWizard.d.ts +3 -0
- package/dist/modules/PersonIntakeWizard.d.ts.map +1 -0
- package/dist/modules/PersonIntakeWizard.js +223 -0
- package/dist/modules/PersonIntakeWizard.js.map +1 -0
- package/dist/modules/ai.d.ts +14 -0
- package/dist/modules/ai.d.ts.map +1 -0
- package/dist/modules/ai.js +26 -0
- package/dist/modules/ai.js.map +1 -0
- package/dist/modules/aiRunner.d.ts +3 -0
- package/dist/modules/aiRunner.d.ts.map +1 -0
- package/dist/modules/aiRunner.js +68 -0
- package/dist/modules/aiRunner.js.map +1 -0
- package/dist/modules/personIntakeSelection.d.ts +7 -0
- package/dist/modules/personIntakeSelection.d.ts.map +1 -0
- package/dist/modules/personIntakeSelection.js +21 -0
- package/dist/modules/personIntakeSelection.js.map +1 -0
- package/dist/pages/CompanyDetail.d.ts.map +1 -1
- package/dist/pages/CompanyDetail.js +2 -1
- package/dist/pages/CompanyDetail.js.map +1 -1
- package/dist/pages/DealDetail.d.ts.map +1 -1
- package/dist/pages/DealDetail.js +2 -1
- package/dist/pages/DealDetail.js.map +1 -1
- package/dist/pages/EnquiryDetail.d.ts.map +1 -1
- package/dist/pages/EnquiryDetail.js +2 -1
- package/dist/pages/EnquiryDetail.js.map +1 -1
- package/dist/pages/EventDetail.d.ts.map +1 -1
- package/dist/pages/EventDetail.js +2 -1
- package/dist/pages/EventDetail.js.map +1 -1
- package/dist/pages/FormsPage.js +4 -4
- package/dist/pages/FormsPage.js.map +1 -1
- package/dist/pages/OpportunityDetail.d.ts.map +1 -1
- package/dist/pages/OpportunityDetail.js +2 -1
- package/dist/pages/OpportunityDetail.js.map +1 -1
- package/dist/pages/PartnershipDetail.d.ts.map +1 -1
- package/dist/pages/PartnershipDetail.js +2 -1
- package/dist/pages/PartnershipDetail.js.map +1 -1
- package/dist/pages/PeoplePage.d.ts.map +1 -1
- package/dist/pages/PeoplePage.js +7 -1
- package/dist/pages/PeoplePage.js.map +1 -1
- package/dist/pages/PersonDetail.d.ts.map +1 -1
- package/dist/pages/PersonDetail.js +2 -1
- package/dist/pages/PersonDetail.js.map +1 -1
- package/dist/pages/RaiseDetail.d.ts.map +1 -1
- package/dist/pages/RaiseDetail.js +2 -1
- package/dist/pages/RaiseDetail.js.map +1 -1
- package/dist/pages/SearchPage.d.ts.map +1 -1
- package/dist/pages/SearchPage.js +26 -14
- package/dist/pages/SearchPage.js.map +1 -1
- package/dist/pages/admin/AiAdminPage.d.ts +2 -0
- package/dist/pages/admin/AiAdminPage.d.ts.map +1 -0
- package/dist/pages/admin/AiAdminPage.js +19 -0
- package/dist/pages/admin/AiAdminPage.js.map +1 -0
- package/dist/pages/admin/AiPage.d.ts +5 -0
- package/dist/pages/admin/AiPage.d.ts.map +1 -0
- package/dist/pages/admin/AiPage.js +196 -0
- package/dist/pages/admin/AiPage.js.map +1 -0
- package/dist/pages/admin/McpPage.js +2 -2
- package/dist/pages/admin/McpPage.js.map +1 -1
- package/dist/pages/admin/McpPanel.d.ts +3 -0
- package/dist/pages/admin/McpPanel.d.ts.map +1 -0
- package/dist/pages/admin/McpPanel.js +123 -0
- package/dist/pages/admin/McpPanel.js.map +1 -0
- package/dist/pages/admin/PrivacyPage.js +19 -3
- package/dist/pages/admin/PrivacyPage.js.map +1 -1
- package/dist/pages/admin/WorkspaceSettingsPage.d.ts +5 -6
- package/dist/pages/admin/WorkspaceSettingsPage.d.ts.map +1 -1
- package/dist/pages/admin/WorkspaceSettingsPage.js +12 -17
- package/dist/pages/admin/WorkspaceSettingsPage.js.map +1 -1
- package/dist/pages/dashboard/attention.d.ts +0 -5
- package/dist/pages/dashboard/attention.d.ts.map +1 -1
- package/dist/pages/dashboard/attention.js +1 -21
- package/dist/pages/dashboard/attention.js.map +1 -1
- package/dist/pages/dashboard/sections.d.ts.map +1 -1
- package/dist/pages/dashboard/sections.js +6 -3
- package/dist/pages/dashboard/sections.js.map +1 -1
- package/dist/pages/forms/EmbedPanel.js +5 -2
- package/dist/pages/forms/EmbedPanel.js.map +1 -1
- package/dist/pages/forms/FieldsEditor.d.ts.map +1 -1
- package/dist/pages/forms/FieldsEditor.js +90 -8
- package/dist/pages/forms/FieldsEditor.js.map +1 -1
- package/dist/pages/forms/FormSettings.d.ts.map +1 -1
- package/dist/pages/forms/FormSettings.js +73 -6
- package/dist/pages/forms/FormSettings.js.map +1 -1
- package/dist/pages/forms/SubmissionDetail.d.ts.map +1 -1
- package/dist/pages/forms/SubmissionDetail.js +2 -1
- package/dist/pages/forms/SubmissionDetail.js.map +1 -1
- package/dist/pages/forms/SubmissionsTable.d.ts.map +1 -1
- package/dist/pages/forms/SubmissionsTable.js +2 -1
- package/dist/pages/forms/SubmissionsTable.js.map +1 -1
- package/dist/pages/forms/fieldList.d.ts +2 -2
- package/dist/pages/forms/fieldList.d.ts.map +1 -1
- package/dist/pages/forms/fieldList.js +38 -10
- package/dist/pages/forms/fieldList.js.map +1 -1
- package/dist/pages/forms/template.d.ts.map +1 -1
- package/dist/pages/forms/template.js +13 -0
- package/dist/pages/forms/template.js.map +1 -1
- package/dist/pages/handbook/HandbookPage.d.ts.map +1 -1
- package/dist/pages/handbook/HandbookPage.js +2 -3
- package/dist/pages/handbook/HandbookPage.js.map +1 -1
- package/dist/pages/onboarding/WorkspaceStepPage.d.ts.map +1 -1
- package/dist/pages/onboarding/WorkspaceStepPage.js +9 -27
- package/dist/pages/onboarding/WorkspaceStepPage.js.map +1 -1
- package/dist/pages/onboarding/onboardingRerun.d.ts +9 -0
- package/dist/pages/onboarding/onboardingRerun.d.ts.map +1 -1
- package/dist/pages/onboarding/onboardingRerun.js +11 -0
- package/dist/pages/onboarding/onboardingRerun.js.map +1 -1
- package/dist/registry/context.d.ts +7 -1
- package/dist/registry/context.d.ts.map +1 -1
- package/dist/registry/context.js +12 -0
- package/dist/registry/context.js.map +1 -1
- package/dist/registry/contributions.d.ts +70 -1
- package/dist/registry/contributions.d.ts.map +1 -1
- package/dist/registry/registry.d.ts +12 -1
- package/dist/registry/registry.d.ts.map +1 -1
- package/dist/registry/registry.js +21 -0
- package/dist/registry/registry.js.map +1 -1
- package/package.json +2 -2
- package/src/api/client.ts +1 -1
- package/src/api/resources/ai.ts +120 -0
- package/src/api/resources/conversions.ts +1 -1
- package/src/api/resources/forms.ts +56 -0
- package/src/api/resources/personIntake.ts +95 -0
- package/src/api/resources/session.ts +3 -1
- package/src/api/resources/workspace.ts +4 -4
- package/src/app/KelpieApp.tsx +4 -2
- package/src/components/ActivitiesPanel.tsx +39 -10
- package/src/components/ActivityAction.tsx +33 -0
- package/src/components/AgentTasks.tsx +138 -10
- package/src/components/DecisionsPanel.tsx +9 -1
- package/src/components/LinkedText.tsx +51 -0
- package/src/components/MarkdownView.tsx +37 -7
- package/src/components/NotesPanel.tsx +18 -12
- package/src/components/PersonIntakeDialog.tsx +226 -0
- package/src/components/PlanPanel.tsx +9 -1
- package/src/components/RecordLinkTextarea.tsx +257 -0
- package/src/components/Shell.tsx +1 -1
- package/src/components/WorkspaceSwitcher.tsx +15 -1
- package/src/index.ts +16 -0
- package/src/lib/fragmentTarget.ts +96 -0
- package/src/lib/recordLinks.ts +57 -0
- package/src/lib/recordReferences.ts +139 -0
- package/src/modules/PersonIntakeWizard.tsx +633 -0
- package/src/modules/ai.tsx +27 -0
- package/src/modules/aiRunner.ts +83 -0
- package/src/modules/personIntakeSelection.ts +24 -0
- package/src/pages/CompanyDetail.tsx +2 -1
- package/src/pages/DealDetail.tsx +2 -1
- package/src/pages/EnquiryDetail.tsx +2 -1
- package/src/pages/EventDetail.tsx +2 -1
- package/src/pages/FormsPage.tsx +4 -4
- package/src/pages/OpportunityDetail.tsx +2 -1
- package/src/pages/PartnershipDetail.tsx +2 -1
- package/src/pages/PeoplePage.tsx +21 -5
- package/src/pages/PersonDetail.tsx +2 -1
- package/src/pages/RaiseDetail.tsx +2 -1
- package/src/pages/SearchPage.tsx +30 -15
- package/src/pages/admin/AiAdminPage.tsx +52 -0
- package/src/pages/admin/AiPage.tsx +457 -0
- package/src/pages/admin/{McpPage.tsx → McpPanel.tsx} +15 -11
- package/src/pages/admin/PrivacyPage.tsx +42 -0
- package/src/pages/admin/WorkspaceSettingsPage.tsx +13 -28
- package/src/pages/dashboard/attention.ts +1 -24
- package/src/pages/dashboard/sections.tsx +9 -4
- package/src/pages/forms/EmbedPanel.tsx +5 -1
- package/src/pages/forms/FieldsEditor.tsx +204 -15
- package/src/pages/forms/FormSettings.tsx +156 -9
- package/src/pages/forms/SubmissionDetail.tsx +2 -1
- package/src/pages/forms/SubmissionsTable.tsx +2 -1
- package/src/pages/forms/fieldList.ts +39 -10
- package/src/pages/forms/template.ts +13 -0
- package/src/pages/handbook/HandbookPage.tsx +5 -6
- package/src/pages/onboarding/WorkspaceStepPage.tsx +19 -43
- package/src/pages/onboarding/onboardingRerun.ts +14 -0
- package/src/registry/context.ts +19 -0
- package/src/registry/contributions.ts +64 -1
- package/src/registry/registry.ts +48 -0
|
@@ -1,17 +1,23 @@
|
|
|
1
|
-
import {
|
|
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 {
|
|
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
|
|
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
|
|
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
|
-
|
|
94
|
-
|
|
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
|
|
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
|
|
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
|
-
|
|
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
|
|
100
|
-
// that may repeat — consent's uniqueness is per purpose, not
|
|
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
|
-
|
|
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 (
|
|
121
|
-
return
|
|
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
|
-
<
|
|
486
|
+
<RecordLinkTextarea
|
|
486
487
|
value={body}
|
|
487
|
-
|
|
488
|
-
onChange={
|
|
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(),
|
|
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
|
|
92
|
-
*
|
|
93
|
-
*
|
|
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=
|
|
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
|
-
|
|
131
|
-
|
|
132
|
-
|
|
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={
|
|
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
|
package/src/registry/context.ts
CHANGED
|
@@ -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
|
+
}
|