@kelpie/ui 0.17.0 → 0.19.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/resources/ai.d.ts +5 -0
- package/dist/api/resources/ai.d.ts.map +1 -1
- package/dist/api/resources/ai.js +9 -1
- package/dist/api/resources/ai.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/app/KelpieApp.js +2 -2
- package/dist/app/KelpieApp.js.map +1 -1
- package/dist/components/AgentTasks.js +2 -2
- package/dist/components/AgentTasks.js.map +1 -1
- package/dist/components/AiDrawer.d.ts +13 -0
- package/dist/components/AiDrawer.d.ts.map +1 -0
- package/dist/components/AiDrawer.js +165 -0
- package/dist/components/AiDrawer.js.map +1 -0
- package/dist/components/ApiKeysPanel.js +1 -1
- package/dist/components/DataTable.js +1 -1
- package/dist/components/KanbanBoard.d.ts +5 -1
- package/dist/components/KanbanBoard.d.ts.map +1 -1
- package/dist/components/KanbanBoard.js +37 -2
- package/dist/components/KanbanBoard.js.map +1 -1
- package/dist/components/NotesPanel.js +2 -2
- package/dist/components/NotesPanel.js.map +1 -1
- package/dist/components/PageHeader.js +1 -1
- package/dist/components/PageHeader.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/PersonIntakePanel.d.ts +21 -0
- package/dist/components/PersonIntakePanel.d.ts.map +1 -0
- package/dist/components/PersonIntakePanel.js +76 -0
- package/dist/components/PersonIntakePanel.js.map +1 -0
- package/dist/components/SegmentedControl.js +2 -2
- package/dist/components/SegmentedControl.js.map +1 -1
- package/dist/components/Shell.d.ts.map +1 -1
- package/dist/components/Shell.js +40 -4
- package/dist/components/Shell.js.map +1 -1
- package/dist/components/WorkspaceSwitcher.d.ts.map +1 -1
- package/dist/components/WorkspaceSwitcher.js +10 -2
- package/dist/components/WorkspaceSwitcher.js.map +1 -1
- package/dist/components/aiDrawerState.d.ts +45 -0
- package/dist/components/aiDrawerState.d.ts.map +1 -0
- package/dist/components/aiDrawerState.js +14 -0
- package/dist/components/aiDrawerState.js.map +1 -0
- package/dist/components/personIntakeTask.d.ts +5 -0
- package/dist/components/personIntakeTask.d.ts.map +1 -0
- package/dist/components/personIntakeTask.js +13 -0
- package/dist/components/personIntakeTask.js.map +1 -0
- package/dist/index.d.ts +5 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -2
- package/dist/index.js.map +1 -1
- package/dist/lib/mediaQuery.d.ts +9 -0
- package/dist/lib/mediaQuery.d.ts.map +1 -0
- package/dist/lib/mediaQuery.js +24 -0
- package/dist/lib/mediaQuery.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 +227 -0
- package/dist/modules/PersonIntakeWizard.js.map +1 -0
- package/dist/modules/ai.d.ts +4 -3
- package/dist/modules/ai.d.ts.map +1 -1
- package/dist/modules/ai.js +10 -6
- package/dist/modules/ai.js.map +1 -1
- package/dist/modules/aiRunner.d.ts.map +1 -1
- package/dist/modules/aiRunner.js +7 -5
- package/dist/modules/aiRunner.js.map +1 -1
- 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/FormDetail.d.ts.map +1 -1
- package/dist/pages/FormDetail.js +7 -7
- package/dist/pages/FormDetail.js.map +1 -1
- package/dist/pages/FormsPage.js +4 -4
- package/dist/pages/FormsPage.js.map +1 -1
- package/dist/pages/ListDetail.d.ts.map +1 -1
- package/dist/pages/ListDetail.js +2 -2
- package/dist/pages/ListDetail.js.map +1 -1
- package/dist/pages/PeoplePage.d.ts.map +1 -1
- package/dist/pages/PeoplePage.js +9 -1
- package/dist/pages/PeoplePage.js.map +1 -1
- package/dist/pages/RoleDetail.d.ts.map +1 -1
- package/dist/pages/RoleDetail.js +3 -3
- package/dist/pages/RoleDetail.js.map +1 -1
- package/dist/pages/account/ConnectedAppsPage.js +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 +4 -1
- package/dist/pages/admin/AiPage.d.ts.map +1 -1
- package/dist/pages/admin/AiPage.js +77 -15
- package/dist/pages/admin/AiPage.js.map +1 -1
- package/dist/pages/admin/DataPage.js +2 -2
- 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/forms/AddFieldMenu.js +2 -2
- package/dist/pages/forms/AddFieldMenu.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.js +4 -4
- package/dist/pages/handbook/HandbookPage.js.map +1 -1
- package/dist/registry/context.d.ts +5 -1
- package/dist/registry/context.d.ts.map +1 -1
- package/dist/registry/context.js +8 -0
- package/dist/registry/context.js.map +1 -1
- package/dist/registry/contributions.d.ts +37 -1
- package/dist/registry/contributions.d.ts.map +1 -1
- package/dist/registry/registry.d.ts +8 -1
- package/dist/registry/registry.d.ts.map +1 -1
- package/dist/registry/registry.js +13 -0
- package/dist/registry/registry.js.map +1 -1
- package/package.json +2 -2
- package/src/api/resources/ai.ts +11 -1
- package/src/api/resources/forms.ts +56 -0
- package/src/api/resources/personIntake.ts +95 -0
- package/src/app/KelpieApp.tsx +4 -2
- package/src/components/AgentTasks.tsx +2 -2
- package/src/components/AiDrawer.tsx +272 -0
- package/src/components/ApiKeysPanel.tsx +1 -1
- package/src/components/DataTable.tsx +1 -1
- package/src/components/KanbanBoard.tsx +119 -2
- package/src/components/NotesPanel.tsx +7 -4
- package/src/components/PageHeader.tsx +1 -1
- package/src/components/PersonIntakePanel.tsx +193 -0
- package/src/components/SegmentedControl.tsx +2 -2
- package/src/components/Shell.tsx +99 -13
- package/src/components/WorkspaceSwitcher.tsx +13 -2
- package/src/components/aiDrawerState.ts +61 -0
- package/src/components/personIntakeTask.tsx +14 -0
- package/src/index.ts +12 -1
- package/src/lib/mediaQuery.ts +32 -0
- package/src/modules/PersonIntakeWizard.tsx +638 -0
- package/src/modules/ai.tsx +10 -6
- package/src/modules/aiRunner.ts +8 -5
- package/src/modules/personIntakeSelection.ts +24 -0
- package/src/pages/FormDetail.tsx +18 -14
- package/src/pages/FormsPage.tsx +4 -4
- package/src/pages/ListDetail.tsx +5 -3
- package/src/pages/PeoplePage.tsx +18 -5
- package/src/pages/RoleDetail.tsx +10 -5
- package/src/pages/account/ConnectedAppsPage.tsx +1 -1
- package/src/pages/admin/AiAdminPage.tsx +52 -0
- package/src/pages/admin/AiPage.tsx +136 -32
- package/src/pages/admin/DataPage.tsx +2 -2
- package/src/pages/admin/{McpPage.tsx → McpPanel.tsx} +4 -6
- package/src/pages/admin/PrivacyPage.tsx +42 -0
- package/src/pages/forms/AddFieldMenu.tsx +2 -2
- 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 -5
- package/src/registry/context.ts +13 -0
- package/src/registry/contributions.ts +39 -1
- package/src/registry/registry.ts +30 -0
package/src/components/Shell.tsx
CHANGED
|
@@ -9,6 +9,7 @@ import { ONBOARDING_RERUN_ENTRY } from '../pages/onboarding/onboardingRerun.ts'
|
|
|
9
9
|
import { useNavItems } from '../registry/context.ts'
|
|
10
10
|
import type { NavItem } from '../registry/contributions.ts'
|
|
11
11
|
import { useVisibleNavItems } from '../registry/visibleNav.ts'
|
|
12
|
+
import { AiDrawerLauncher, AiDrawerPanel, AiDrawerProvider } from './AiDrawer.tsx'
|
|
12
13
|
import { ErrorBoundary } from './ErrorBoundary.tsx'
|
|
13
14
|
import { WorkspaceSwitcher } from './WorkspaceSwitcher.tsx'
|
|
14
15
|
|
|
@@ -29,7 +30,7 @@ const CORE_ADMIN_NAV: readonly NavItem[] = [
|
|
|
29
30
|
{ id: 'data', label: 'Data', to: '/admin/data', order: 300 },
|
|
30
31
|
{ id: 'api-keys', label: 'API keys', to: '/admin/api-keys', order: 350 },
|
|
31
32
|
{ id: 'webhooks', label: 'Webhooks', to: '/admin/webhooks', order: 400 },
|
|
32
|
-
{ id: '
|
|
33
|
+
{ id: 'ai', label: 'AI', to: '/admin/ai', order: 500 },
|
|
33
34
|
{ id: 'modules', label: 'Modules', to: '/admin/modules', order: 600 },
|
|
34
35
|
]
|
|
35
36
|
|
|
@@ -90,6 +91,16 @@ const THEME_LABELS: Readonly<Record<ThemePreference, string>> = {
|
|
|
90
91
|
}
|
|
91
92
|
|
|
92
93
|
export function Shell(): React.JSX.Element {
|
|
94
|
+
// The drawer's state sits here, above the routed outlet, so an AI task
|
|
95
|
+
// survives a route change.
|
|
96
|
+
return (
|
|
97
|
+
<AiDrawerProvider>
|
|
98
|
+
<ShellLayout />
|
|
99
|
+
</AiDrawerProvider>
|
|
100
|
+
)
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function ShellLayout(): React.JSX.Element {
|
|
93
104
|
const navigate = useNavigate()
|
|
94
105
|
const location = useLocation()
|
|
95
106
|
const { account } = useAccount()
|
|
@@ -97,6 +108,9 @@ export function Shell(): React.JSX.Element {
|
|
|
97
108
|
const moduleNav = useNavItems('primary')
|
|
98
109
|
const moduleAdminNav = useNavItems('admin')
|
|
99
110
|
const [menuOpen, setMenuOpen] = useState(false)
|
|
111
|
+
// Below `md` the sidebar is an off-canvas drawer; from `md` up it is always
|
|
112
|
+
// shown and this flag has no effect.
|
|
113
|
+
const [navOpen, setNavOpen] = useState(false)
|
|
100
114
|
// The same preference the account page writes, so this button and that page
|
|
101
115
|
// cannot disagree about which theme the account is on.
|
|
102
116
|
const { theme, setTheme } = useTheme()
|
|
@@ -129,6 +143,24 @@ export function Shell(): React.JSX.Element {
|
|
|
129
143
|
}
|
|
130
144
|
}, [menuOpen])
|
|
131
145
|
|
|
146
|
+
useEffect(() => {
|
|
147
|
+
if (!navOpen) {
|
|
148
|
+
return
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
function onKeyDown(event: KeyboardEvent): void {
|
|
152
|
+
if (event.key === 'Escape') {
|
|
153
|
+
setNavOpen(false)
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
document.addEventListener('keydown', onKeyDown)
|
|
158
|
+
|
|
159
|
+
return () => {
|
|
160
|
+
document.removeEventListener('keydown', onKeyDown)
|
|
161
|
+
}
|
|
162
|
+
}, [navOpen])
|
|
163
|
+
|
|
132
164
|
const navItems = useVisibleNavItems(CORE_NAV, moduleNav)
|
|
133
165
|
const topLevelItems = navItems.filter((item) => TOP_LEVEL_NAV_IDS.has(item.id))
|
|
134
166
|
const nonTopLevelItems = navItems.filter((item) => !TOP_LEVEL_NAV_IDS.has(item.id))
|
|
@@ -142,16 +174,50 @@ export function Shell(): React.JSX.Element {
|
|
|
142
174
|
|
|
143
175
|
return (
|
|
144
176
|
<div className="flex min-h-screen bg-surface">
|
|
145
|
-
|
|
146
|
-
<div
|
|
177
|
+
{navOpen && (
|
|
178
|
+
<div
|
|
179
|
+
aria-hidden
|
|
180
|
+
className="fixed inset-0 z-40 bg-black/40 md:hidden"
|
|
181
|
+
onClick={() => {
|
|
182
|
+
setNavOpen(false)
|
|
183
|
+
}}
|
|
184
|
+
/>
|
|
185
|
+
)}
|
|
186
|
+
<aside
|
|
187
|
+
id="shell-nav"
|
|
188
|
+
className={[
|
|
189
|
+
'fixed inset-y-0 left-0 z-40 flex w-[240px] shrink-0 flex-col border-r border-sidebar-border bg-sidebar transition-transform duration-150 md:static md:w-[200px] md:translate-x-0',
|
|
190
|
+
navOpen ? 'translate-x-0' : '-translate-x-full',
|
|
191
|
+
].join(' ')}
|
|
192
|
+
>
|
|
193
|
+
<div className="flex items-center justify-between px-3 py-4">
|
|
147
194
|
<NavLink to="/dashboard" className="group block px-2">
|
|
148
195
|
<div className="text-[15px] font-semibold tracking-tight text-sidebar-ink transition-opacity group-hover:opacity-80">
|
|
149
196
|
Kelpie
|
|
150
197
|
</div>
|
|
151
198
|
</NavLink>
|
|
199
|
+
<button
|
|
200
|
+
type="button"
|
|
201
|
+
aria-label="Close navigation"
|
|
202
|
+
onClick={() => {
|
|
203
|
+
setNavOpen(false)
|
|
204
|
+
}}
|
|
205
|
+
className="rounded-md px-2 py-1 text-[12px] text-sidebar-muted transition hover:bg-sidebar-hover hover:text-sidebar-ink md:hidden"
|
|
206
|
+
>
|
|
207
|
+
Close
|
|
208
|
+
</button>
|
|
152
209
|
</div>
|
|
153
210
|
|
|
154
|
-
|
|
211
|
+
{/* A tap on any link closes the drawer, including a tap on the link
|
|
212
|
+
for the page already open, which does not change the route. */}
|
|
213
|
+
<nav
|
|
214
|
+
className="flex flex-1 flex-col gap-5 overflow-y-auto px-2 pb-4"
|
|
215
|
+
onClick={(event) => {
|
|
216
|
+
if (event.target instanceof Element && event.target.closest('a') !== null) {
|
|
217
|
+
setNavOpen(false)
|
|
218
|
+
}
|
|
219
|
+
}}
|
|
220
|
+
>
|
|
155
221
|
{inAdminNav ? (
|
|
156
222
|
<>
|
|
157
223
|
<Link
|
|
@@ -229,9 +295,23 @@ export function Shell(): React.JSX.Element {
|
|
|
229
295
|
</aside>
|
|
230
296
|
|
|
231
297
|
<div className="flex min-w-0 flex-1 flex-col">
|
|
232
|
-
<header className="flex h-11 items-center gap-
|
|
298
|
+
<header className="flex h-11 items-center gap-2 border-b border-border px-3 sm:gap-3 md:px-5">
|
|
299
|
+
<button
|
|
300
|
+
type="button"
|
|
301
|
+
aria-label="Open navigation"
|
|
302
|
+
aria-controls="shell-nav"
|
|
303
|
+
aria-expanded={navOpen}
|
|
304
|
+
onClick={() => {
|
|
305
|
+
setNavOpen(true)
|
|
306
|
+
}}
|
|
307
|
+
className="flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-ink-muted transition hover:bg-surface-sunken hover:text-ink md:hidden"
|
|
308
|
+
>
|
|
309
|
+
<svg viewBox="0 0 16 16" aria-hidden className="h-4 w-4">
|
|
310
|
+
<path d="M2 4h12M2 8h12M2 12h12" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" />
|
|
311
|
+
</svg>
|
|
312
|
+
</button>
|
|
233
313
|
<form
|
|
234
|
-
className="flex-1"
|
|
314
|
+
className="min-w-0 flex-1"
|
|
235
315
|
onSubmit={(event) => {
|
|
236
316
|
event.preventDefault()
|
|
237
317
|
const term = query.trim()
|
|
@@ -253,6 +333,7 @@ export function Shell(): React.JSX.Element {
|
|
|
253
333
|
className="w-full max-w-sm rounded-md border border-transparent bg-surface-sunken px-2.5 py-1 text-[13px] text-ink outline-none transition placeholder:text-ink-faint focus:border-border focus:bg-surface-raised"
|
|
254
334
|
/>
|
|
255
335
|
</form>
|
|
336
|
+
<AiDrawerLauncher />
|
|
256
337
|
<button
|
|
257
338
|
type="button"
|
|
258
339
|
onClick={() => {
|
|
@@ -343,13 +424,18 @@ export function Shell(): React.JSX.Element {
|
|
|
343
424
|
</div>
|
|
344
425
|
</header>
|
|
345
426
|
|
|
346
|
-
<
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
<
|
|
351
|
-
|
|
352
|
-
|
|
427
|
+
<div className="flex min-h-0 flex-1">
|
|
428
|
+
<main className="min-w-0 flex-1 overflow-auto px-4 py-5 md:px-5">
|
|
429
|
+
{/* Keyed on the path so navigating away from a crashed page remounts
|
|
430
|
+
the boundary instead of leaving it stuck showing the old error. */}
|
|
431
|
+
<ErrorBoundary key={location.pathname}>
|
|
432
|
+
<Outlet />
|
|
433
|
+
</ErrorBoundary>
|
|
434
|
+
</main>
|
|
435
|
+
{/* Outside the route boundary, so a page that throws does not take a
|
|
436
|
+
running AI task with it. */}
|
|
437
|
+
<AiDrawerPanel />
|
|
438
|
+
</div>
|
|
353
439
|
</div>
|
|
354
440
|
</div>
|
|
355
441
|
)
|
|
@@ -3,6 +3,7 @@ import { useNavigate } from 'react-router'
|
|
|
3
3
|
|
|
4
4
|
import { useAccountWorkspaces, useSession, useSwitchWorkspace } from '../api/resources/session.ts'
|
|
5
5
|
import { ONBOARDING_NEW_WORKSPACE_ENTRY } from '../pages/onboarding/onboardingRerun.ts'
|
|
6
|
+
import { useAiDrawer } from './aiDrawerState.ts'
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* Header control: the workspace this session is in, and a menu to move it.
|
|
@@ -17,6 +18,7 @@ export function WorkspaceSwitcher(): React.JSX.Element | null {
|
|
|
17
18
|
const { session } = useSession()
|
|
18
19
|
const { workspaces, isLoading } = useAccountWorkspaces()
|
|
19
20
|
const switchWorkspace = useSwitchWorkspace()
|
|
21
|
+
const aiDrawer = useAiDrawer()
|
|
20
22
|
const [open, setOpen] = useState(false)
|
|
21
23
|
const menuRef = useRef<HTMLDivElement>(null)
|
|
22
24
|
const currentId = session?.workspaceId ?? null
|
|
@@ -50,7 +52,7 @@ export function WorkspaceSwitcher(): React.JSX.Element | null {
|
|
|
50
52
|
|
|
51
53
|
if (isLoading && workspaces.length === 0) {
|
|
52
54
|
return (
|
|
53
|
-
<span className="max-w-[
|
|
55
|
+
<span className="max-w-[8rem] truncate px-2 py-1 sm:max-w-[10rem] text-[12px] text-ink-faint" aria-hidden>
|
|
54
56
|
Workspace
|
|
55
57
|
</span>
|
|
56
58
|
)
|
|
@@ -73,7 +75,7 @@ export function WorkspaceSwitcher(): React.JSX.Element | null {
|
|
|
73
75
|
aria-haspopup="menu"
|
|
74
76
|
aria-label="Switch workspace"
|
|
75
77
|
title={label}
|
|
76
|
-
className="inline-flex max-w-[
|
|
78
|
+
className="inline-flex max-w-[8rem] items-center gap-1 rounded-md sm:max-w-[12rem] px-2 py-1 text-[12px] text-ink-muted transition hover:bg-surface-sunken hover:text-ink"
|
|
77
79
|
>
|
|
78
80
|
<span className="truncate">{label}</span>
|
|
79
81
|
<svg viewBox="0 0 12 12" aria-hidden className="h-2.5 w-2.5 shrink-0">
|
|
@@ -108,10 +110,19 @@ export function WorkspaceSwitcher(): React.JSX.Element | null {
|
|
|
108
110
|
return
|
|
109
111
|
}
|
|
110
112
|
|
|
113
|
+
// An AI task belongs to one workspace, so the switch discards it.
|
|
114
|
+
if (
|
|
115
|
+
aiDrawer.isPending &&
|
|
116
|
+
!window.confirm('AI is still working on a task. Switching workspace discards it. Switch anyway?')
|
|
117
|
+
) {
|
|
118
|
+
return
|
|
119
|
+
}
|
|
120
|
+
|
|
111
121
|
switchWorkspace
|
|
112
122
|
.runAsync({ workspaceId: workspace.id })
|
|
113
123
|
.then(() => {
|
|
114
124
|
setOpen(false)
|
|
125
|
+
aiDrawer.finish()
|
|
115
126
|
void navigate('/dashboard', { replace: true })
|
|
116
127
|
})
|
|
117
128
|
.catch(() => undefined)
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { createContext, useContext } from 'react'
|
|
2
|
+
import type { ReactNode } from 'react'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The AI drawer's contract and hook, apart from its components so the
|
|
6
|
+
* component file keeps fast refresh (the same split as `registry/context.ts`).
|
|
7
|
+
* The drawer itself is `AiDrawer.tsx`.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/** What a task may do to the drawer it sits in. */
|
|
11
|
+
export interface AiDrawerControls {
|
|
12
|
+
/** Hides the drawer. The task stays mounted. */
|
|
13
|
+
readonly close: () => void
|
|
14
|
+
/** Ends the task and unmounts it. */
|
|
15
|
+
readonly finish: () => void
|
|
16
|
+
/** Tells the header button to show the pending spinner. */
|
|
17
|
+
readonly setPending: (pending: boolean) => void
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** The content of the drawer. One is active at a time. */
|
|
21
|
+
export interface AiDrawerTask {
|
|
22
|
+
readonly id: string
|
|
23
|
+
readonly title: string
|
|
24
|
+
/** A line under the title. */
|
|
25
|
+
readonly description?: string
|
|
26
|
+
readonly render: (controls: AiDrawerControls) => ReactNode
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface AiDrawerState {
|
|
30
|
+
readonly activeTask: AiDrawerTask | undefined
|
|
31
|
+
readonly isOpen: boolean
|
|
32
|
+
readonly isPending: boolean
|
|
33
|
+
/**
|
|
34
|
+
* Opens the drawer on `task`. When another task is active, opens on that
|
|
35
|
+
* one instead, says so, and returns `false`. Nothing is replaced silently.
|
|
36
|
+
*/
|
|
37
|
+
readonly open: (task: AiDrawerTask) => boolean
|
|
38
|
+
/** Shows the active task again. */
|
|
39
|
+
readonly reopen: () => void
|
|
40
|
+
readonly close: () => void
|
|
41
|
+
/** Ends the active task. */
|
|
42
|
+
readonly finish: () => void
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export const AiDrawerContext = createContext<AiDrawerState | undefined>(undefined)
|
|
46
|
+
|
|
47
|
+
export function useAiDrawer(): AiDrawerState {
|
|
48
|
+
const state = useContext(AiDrawerContext)
|
|
49
|
+
|
|
50
|
+
if (state === undefined) {
|
|
51
|
+
throw new Error('useAiDrawer needs an AiDrawerProvider above it. Shell provides one.')
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return state
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** Whether the drawer says that a new task has to wait for the active one. */
|
|
58
|
+
export const AiDrawerBusyNoticeContext = createContext(false)
|
|
59
|
+
|
|
60
|
+
/** The active task's pending setter, handed to it through its controls. */
|
|
61
|
+
export const AiDrawerPendingContext = createContext<(pending: boolean) => void>(() => undefined)
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { AiDrawerTask } from './aiDrawerState.ts'
|
|
2
|
+
import { PersonIntakePanel } from './PersonIntakePanel.tsx'
|
|
3
|
+
|
|
4
|
+
export const PERSON_INTAKE_TASK_ID = 'person-intake'
|
|
5
|
+
|
|
6
|
+
/** The AI drawer task People's **Add from notes** opens. */
|
|
7
|
+
export function personIntakeTask(): AiDrawerTask {
|
|
8
|
+
return {
|
|
9
|
+
id: PERSON_INTAKE_TASK_ID,
|
|
10
|
+
title: 'Add a person from notes',
|
|
11
|
+
description: 'Paste what you know. Kelpie builds the record from it.',
|
|
12
|
+
render: (controls) => <PersonIntakePanel onClose={controls.finish} onPendingChange={controls.setPending} />,
|
|
13
|
+
}
|
|
14
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -208,15 +208,19 @@ export type { ThemePreference } from './lib/theme.ts'
|
|
|
208
208
|
|
|
209
209
|
export { EXTENSIBLE_RECORD_TYPES, NAV_SLOTS } from './registry/contributions.ts'
|
|
210
210
|
export type {
|
|
211
|
+
AdminTab,
|
|
211
212
|
AgentRunner,
|
|
212
213
|
AgentRunnerAvailability,
|
|
213
214
|
AgentRunnerProgress,
|
|
214
215
|
AuthMethod,
|
|
215
216
|
AuthMethodContext,
|
|
216
217
|
DashboardCard,
|
|
218
|
+
ExtensibleAdminPage,
|
|
217
219
|
ExtensibleRecordType,
|
|
218
220
|
NavItem,
|
|
219
221
|
NavSlot,
|
|
222
|
+
PersonIntakeProvider,
|
|
223
|
+
PersonIntakeWizardProps,
|
|
220
224
|
RecordContext,
|
|
221
225
|
RecordSidebarCard,
|
|
222
226
|
RecordTab,
|
|
@@ -230,22 +234,29 @@ export { NO_UI_MODULES, UiModuleError, inSlotOrder, registerUiModules } from './
|
|
|
230
234
|
export type { UiExtensions, UiModule, UiModuleContext } from './registry/registry.ts'
|
|
231
235
|
|
|
232
236
|
export {
|
|
237
|
+
useAdminTabs,
|
|
233
238
|
useAgentRunner,
|
|
234
239
|
useAuthMethods,
|
|
235
240
|
useDashboardCards,
|
|
236
241
|
useModuleRoutes,
|
|
237
242
|
useNavItems,
|
|
238
243
|
useOverridable,
|
|
244
|
+
usePersonIntakeProvider,
|
|
239
245
|
useRecordSidebarCards,
|
|
240
246
|
useRecordTabs,
|
|
241
247
|
useUiExtensions,
|
|
242
248
|
} from './registry/context.ts'
|
|
243
249
|
|
|
244
250
|
export { UiExtensionProvider } from './registry/UiExtensionProvider.tsx'
|
|
251
|
+
|
|
252
|
+
// The side drawer AI work runs in. Shell provides it; a module or page opens a
|
|
253
|
+
// task in it with `useAiDrawer().open(task)`.
|
|
254
|
+
export { useAiDrawer } from './components/aiDrawerState.ts'
|
|
255
|
+
export type { AiDrawerControls, AiDrawerState, AiDrawerTask } from './components/aiDrawerState.ts'
|
|
245
256
|
export type { UiExtensionProviderProps } from './registry/UiExtensionProvider.tsx'
|
|
246
257
|
|
|
247
258
|
// The optional `ai` module's UI. An assembly that lists `createAiModule()` on
|
|
248
259
|
// the server lists `aiUi` in its `uiModules`.
|
|
249
260
|
export { aiUi } from './modules/ai.tsx'
|
|
250
|
-
export {
|
|
261
|
+
export { AiRunLogTab, AiSettingsTab } from './pages/admin/AiPage.tsx'
|
|
251
262
|
export { useAiRuns, useAiSettings, useDisableAi, useSaveAiSettings } from './api/resources/ai.ts'
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { useSyncExternalStore } from 'react'
|
|
2
|
+
|
|
3
|
+
/** Tailwind's `md` breakpoint, as a query that matches below it. */
|
|
4
|
+
export const BELOW_MD_QUERY = '(max-width: 767.98px)'
|
|
5
|
+
|
|
6
|
+
function hasMatchMedia(): boolean {
|
|
7
|
+
return typeof window !== 'undefined' && typeof window.matchMedia === 'function'
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Whether `query` matches now, updated when it starts or stops matching. For
|
|
12
|
+
* a layout that cannot be done with CSS alone, such as rendering a different
|
|
13
|
+
* component tree. Without `matchMedia` (jsdom, server rendering) it is false.
|
|
14
|
+
*/
|
|
15
|
+
export function useMediaQuery(query: string): boolean {
|
|
16
|
+
return useSyncExternalStore(
|
|
17
|
+
(onChange: () => void): (() => void) => {
|
|
18
|
+
if (!hasMatchMedia()) {
|
|
19
|
+
return () => undefined
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const list = window.matchMedia(query)
|
|
23
|
+
list.addEventListener('change', onChange)
|
|
24
|
+
|
|
25
|
+
return () => {
|
|
26
|
+
list.removeEventListener('change', onChange)
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
(): boolean => hasMatchMedia() && window.matchMedia(query).matches,
|
|
30
|
+
(): boolean => false,
|
|
31
|
+
)
|
|
32
|
+
}
|