@kelpie/ui 0.21.0 → 0.23.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/resource.d.ts +12 -0
- package/dist/api/resource.d.ts.map +1 -1
- package/dist/api/resource.js +11 -0
- package/dist/api/resource.js.map +1 -1
- package/dist/api/resources/decisions.d.ts +31 -0
- package/dist/api/resources/decisions.d.ts.map +1 -1
- package/dist/api/resources/decisions.js +51 -1
- package/dist/api/resources/decisions.js.map +1 -1
- package/dist/api/resources/forms.d.ts +21 -7
- package/dist/api/resources/forms.d.ts.map +1 -1
- package/dist/api/resources/forms.js +39 -1
- package/dist/api/resources/forms.js.map +1 -1
- package/dist/api/resources/oauth.d.ts +2 -0
- package/dist/api/resources/oauth.d.ts.map +1 -1
- package/dist/api/resources/oauth.js +13 -1
- package/dist/api/resources/oauth.js.map +1 -1
- package/dist/api/resources/personIntake.d.ts +15 -3
- package/dist/api/resources/personIntake.d.ts.map +1 -1
- package/dist/api/resources/personIntake.js +38 -9
- package/dist/api/resources/personIntake.js.map +1 -1
- package/dist/api/resources/session.d.ts.map +1 -1
- package/dist/api/resources/session.js +4 -0
- package/dist/api/resources/session.js.map +1 -1
- package/dist/api/resources/tags.d.ts +20 -0
- package/dist/api/resources/tags.d.ts.map +1 -0
- package/dist/api/resources/tags.js +52 -0
- package/dist/api/resources/tags.js.map +1 -0
- package/dist/app/KelpieApp.d.ts.map +1 -1
- package/dist/app/KelpieApp.js +2 -1
- package/dist/app/KelpieApp.js.map +1 -1
- package/dist/components/AddRecordPanel.d.ts +35 -0
- package/dist/components/AddRecordPanel.d.ts.map +1 -0
- package/dist/components/AddRecordPanel.js +35 -0
- package/dist/components/AddRecordPanel.js.map +1 -0
- package/dist/components/AiDrawer.d.ts.map +1 -1
- package/dist/components/AiDrawer.js +29 -6
- package/dist/components/AiDrawer.js.map +1 -1
- package/dist/components/ApiKeysPanel.d.ts.map +1 -1
- package/dist/components/ApiKeysPanel.js +101 -44
- package/dist/components/ApiKeysPanel.js.map +1 -1
- package/dist/components/Chip.d.ts +5 -1
- package/dist/components/Chip.d.ts.map +1 -1
- package/dist/components/Chip.js +8 -2
- package/dist/components/Chip.js.map +1 -1
- package/dist/components/CustomFieldsPanel.d.ts.map +1 -1
- package/dist/components/CustomFieldsPanel.js +5 -2
- package/dist/components/CustomFieldsPanel.js.map +1 -1
- package/dist/components/DecisionProvenance.d.ts +27 -0
- package/dist/components/DecisionProvenance.d.ts.map +1 -0
- package/dist/components/DecisionProvenance.js +53 -0
- package/dist/components/DecisionProvenance.js.map +1 -0
- package/dist/components/DecisionsPanel.d.ts +3 -0
- package/dist/components/DecisionsPanel.d.ts.map +1 -1
- package/dist/components/DecisionsPanel.js +9 -5
- package/dist/components/DecisionsPanel.js.map +1 -1
- package/dist/components/MarkdownView.d.ts.map +1 -1
- package/dist/components/MarkdownView.js +18 -2
- package/dist/components/MarkdownView.js.map +1 -1
- package/dist/components/NotesPanel.d.ts.map +1 -1
- package/dist/components/NotesPanel.js +7 -3
- package/dist/components/NotesPanel.js.map +1 -1
- package/dist/components/OriginLabel.d.ts +5 -0
- package/dist/components/OriginLabel.d.ts.map +1 -0
- package/dist/components/OriginLabel.js +22 -0
- package/dist/components/OriginLabel.js.map +1 -0
- package/dist/components/Shell.d.ts.map +1 -1
- package/dist/components/Shell.js +17 -5
- package/dist/components/Shell.js.map +1 -1
- package/dist/components/TagInput.d.ts +29 -0
- package/dist/components/TagInput.d.ts.map +1 -0
- package/dist/components/TagInput.js +139 -0
- package/dist/components/TagInput.js.map +1 -0
- package/dist/components/aiDrawerState.d.ts +12 -0
- package/dist/components/aiDrawerState.d.ts.map +1 -1
- package/dist/components/aiDrawerState.js.map +1 -1
- package/dist/components/personIntakeTask.d.ts +15 -0
- package/dist/components/personIntakeTask.d.ts.map +1 -1
- package/dist/components/personIntakeTask.js +42 -0
- package/dist/components/personIntakeTask.js.map +1 -1
- package/dist/lib/personIntakeRunStorage.d.ts +15 -0
- package/dist/lib/personIntakeRunStorage.d.ts.map +1 -0
- package/dist/lib/personIntakeRunStorage.js +88 -0
- package/dist/lib/personIntakeRunStorage.js.map +1 -0
- package/dist/modules/PersonIntakeWizard.d.ts +1 -1
- package/dist/modules/PersonIntakeWizard.d.ts.map +1 -1
- package/dist/modules/PersonIntakeWizard.js +243 -29
- package/dist/modules/PersonIntakeWizard.js.map +1 -1
- package/dist/modules/ai.d.ts +1 -1
- package/dist/modules/ai.js +1 -1
- package/dist/pages/CompaniesPage.d.ts.map +1 -1
- package/dist/pages/CompaniesPage.js +13 -6
- package/dist/pages/CompaniesPage.js.map +1 -1
- package/dist/pages/CompanyDetail.d.ts.map +1 -1
- package/dist/pages/CompanyDetail.js +4 -3
- package/dist/pages/CompanyDetail.js.map +1 -1
- package/dist/pages/DealDetail.d.ts.map +1 -1
- package/dist/pages/DealDetail.js +4 -3
- package/dist/pages/DealDetail.js.map +1 -1
- package/dist/pages/DealsPage.d.ts.map +1 -1
- package/dist/pages/DealsPage.js +16 -8
- package/dist/pages/DealsPage.js.map +1 -1
- package/dist/pages/DecisionsPage.d.ts.map +1 -1
- package/dist/pages/DecisionsPage.js +7 -3
- package/dist/pages/DecisionsPage.js.map +1 -1
- package/dist/pages/EnquiriesPage.d.ts.map +1 -1
- package/dist/pages/EnquiriesPage.js +14 -6
- package/dist/pages/EnquiriesPage.js.map +1 -1
- package/dist/pages/EnquiryDetail.js +4 -4
- package/dist/pages/EnquiryDetail.js.map +1 -1
- package/dist/pages/EventDetail.js +4 -4
- package/dist/pages/EventDetail.js.map +1 -1
- package/dist/pages/FundraisingPage.d.ts.map +1 -1
- package/dist/pages/FundraisingPage.js +16 -11
- package/dist/pages/FundraisingPage.js.map +1 -1
- package/dist/pages/OpportunitiesPage.d.ts.map +1 -1
- package/dist/pages/OpportunitiesPage.js +14 -6
- package/dist/pages/OpportunitiesPage.js.map +1 -1
- package/dist/pages/OpportunityDetail.js +4 -4
- package/dist/pages/OpportunityDetail.js.map +1 -1
- package/dist/pages/PartnershipDetail.js +4 -4
- package/dist/pages/PartnershipDetail.js.map +1 -1
- package/dist/pages/PartnershipsPage.d.ts.map +1 -1
- package/dist/pages/PartnershipsPage.js +16 -11
- package/dist/pages/PartnershipsPage.js.map +1 -1
- package/dist/pages/PeoplePage.d.ts.map +1 -1
- package/dist/pages/PeoplePage.js +13 -8
- package/dist/pages/PeoplePage.js.map +1 -1
- package/dist/pages/PersonDetail.js +7 -7
- package/dist/pages/PersonDetail.js.map +1 -1
- package/dist/pages/RaiseDetail.js +4 -4
- package/dist/pages/RaiseDetail.js.map +1 -1
- package/dist/pages/SearchPage.d.ts.map +1 -1
- package/dist/pages/SearchPage.js +2 -1
- package/dist/pages/SearchPage.js.map +1 -1
- package/dist/pages/account/ConnectedAppsPage.d.ts +0 -5
- package/dist/pages/account/ConnectedAppsPage.d.ts.map +1 -1
- package/dist/pages/account/ConnectedAppsPage.js +38 -6
- package/dist/pages/account/ConnectedAppsPage.js.map +1 -1
- package/dist/pages/admin/AgentsPanel.d.ts +10 -0
- package/dist/pages/admin/AgentsPanel.d.ts.map +1 -0
- package/dist/pages/admin/AgentsPanel.js +81 -0
- package/dist/pages/admin/AgentsPanel.js.map +1 -0
- package/dist/pages/admin/AiAdminPage.d.ts.map +1 -1
- package/dist/pages/admin/AiAdminPage.js +9 -6
- package/dist/pages/admin/AiAdminPage.js.map +1 -1
- package/dist/pages/admin/AiPage.js +1 -1
- package/dist/pages/admin/TeamPage.d.ts.map +1 -1
- package/dist/pages/admin/TeamPage.js +16 -3
- package/dist/pages/admin/TeamPage.js.map +1 -1
- package/dist/pages/ai/AiAccessPage.d.ts +11 -0
- package/dist/pages/ai/AiAccessPage.d.ts.map +1 -0
- package/dist/pages/ai/AiAccessPage.js +16 -0
- package/dist/pages/ai/AiAccessPage.js.map +1 -0
- package/dist/pages/ai/McpPanel.d.ts +7 -0
- package/dist/pages/ai/McpPanel.d.ts.map +1 -0
- package/dist/pages/ai/McpPanel.js +86 -0
- package/dist/pages/ai/McpPanel.js.map +1 -0
- package/dist/pages/auth/nextPath.d.ts +6 -0
- package/dist/pages/auth/nextPath.d.ts.map +1 -1
- package/dist/pages/auth/nextPath.js +16 -1
- package/dist/pages/auth/nextPath.js.map +1 -1
- package/dist/pages/dashboard/sections.d.ts.map +1 -1
- package/dist/pages/dashboard/sections.js +4 -2
- package/dist/pages/dashboard/sections.js.map +1 -1
- package/dist/pages/forms/EmbedPanel.js +1 -1
- 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 +6 -7
- package/dist/pages/forms/FieldsEditor.js.map +1 -1
- package/dist/pages/forms/FormActions.d.ts.map +1 -1
- package/dist/pages/forms/FormActions.js +4 -11
- package/dist/pages/forms/FormActions.js.map +1 -1
- package/dist/pages/forms/FormEmails.d.ts.map +1 -1
- package/dist/pages/forms/FormEmails.js +6 -1
- package/dist/pages/forms/FormEmails.js.map +1 -1
- package/dist/pages/forms/FormSettings.d.ts.map +1 -1
- package/dist/pages/forms/FormSettings.js +6 -2
- 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 +26 -6
- 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 +81 -6
- package/dist/pages/forms/SubmissionsTable.js.map +1 -1
- package/dist/pages/forms/fieldList.d.ts +13 -5
- package/dist/pages/forms/fieldList.d.ts.map +1 -1
- package/dist/pages/forms/fieldList.js +12 -4
- package/dist/pages/forms/fieldList.js.map +1 -1
- package/dist/pages/oauth/ConsentPage.d.ts.map +1 -1
- package/dist/pages/oauth/ConsentPage.js +132 -15
- package/dist/pages/oauth/ConsentPage.js.map +1 -1
- package/dist/registry/contributions.d.ts +1 -1
- package/package.json +3 -3
- package/src/api/resource.ts +16 -0
- package/src/api/resources/decisions.ts +81 -1
- package/src/api/resources/forms.ts +68 -7
- package/src/api/resources/oauth.ts +15 -1
- package/src/api/resources/personIntake.ts +54 -13
- package/src/api/resources/session.ts +4 -0
- package/src/api/resources/tags.ts +71 -0
- package/src/app/KelpieApp.tsx +4 -2
- package/src/components/AddRecordPanel.tsx +143 -0
- package/src/components/AiDrawer.tsx +34 -7
- package/src/components/ApiKeysPanel.tsx +193 -75
- package/src/components/Chip.tsx +32 -1
- package/src/components/CustomFieldsPanel.tsx +15 -5
- package/src/components/DecisionProvenance.tsx +95 -0
- package/src/components/DecisionsPanel.tsx +30 -2
- package/src/components/MarkdownView.tsx +45 -11
- package/src/components/NotesPanel.tsx +15 -6
- package/src/components/OriginLabel.tsx +26 -0
- package/src/components/Shell.tsx +30 -6
- package/src/components/TagInput.tsx +285 -0
- package/src/components/aiDrawerState.ts +12 -0
- package/src/components/personIntakeTask.tsx +48 -0
- package/src/lib/personIntakeRunStorage.ts +97 -0
- package/src/modules/PersonIntakeWizard.tsx +391 -30
- package/src/modules/ai.tsx +1 -1
- package/src/pages/CompaniesPage.tsx +22 -5
- package/src/pages/CompanyDetail.tsx +6 -17
- package/src/pages/DealDetail.tsx +6 -17
- package/src/pages/DealsPage.tsx +25 -8
- package/src/pages/DecisionsPage.tsx +28 -1
- package/src/pages/EnquiriesPage.tsx +23 -5
- package/src/pages/EnquiryDetail.tsx +6 -18
- package/src/pages/EventDetail.tsx +6 -18
- package/src/pages/FundraisingPage.tsx +25 -11
- package/src/pages/OpportunitiesPage.tsx +23 -5
- package/src/pages/OpportunityDetail.tsx +6 -18
- package/src/pages/PartnershipDetail.tsx +6 -18
- package/src/pages/PartnershipsPage.tsx +25 -11
- package/src/pages/PeoplePage.tsx +22 -7
- package/src/pages/PersonDetail.tsx +11 -21
- package/src/pages/RaiseDetail.tsx +6 -18
- package/src/pages/SearchPage.tsx +3 -0
- package/src/pages/account/ConnectedAppsPage.tsx +97 -14
- package/src/pages/admin/{McpPanel.tsx → AgentsPanel.tsx} +11 -168
- package/src/pages/admin/AiAdminPage.tsx +16 -11
- package/src/pages/admin/AiPage.tsx +1 -1
- package/src/pages/admin/TeamPage.tsx +33 -0
- package/src/pages/ai/AiAccessPage.tsx +23 -0
- package/src/pages/ai/McpPanel.tsx +261 -0
- package/src/pages/auth/nextPath.ts +18 -1
- package/src/pages/dashboard/sections.tsx +4 -0
- package/src/pages/forms/EmbedPanel.tsx +3 -2
- package/src/pages/forms/FieldsEditor.tsx +6 -7
- package/src/pages/forms/FormActions.tsx +18 -20
- package/src/pages/forms/FormEmails.tsx +11 -2
- package/src/pages/forms/FormSettings.tsx +5 -0
- package/src/pages/forms/SubmissionDetail.tsx +47 -9
- package/src/pages/forms/SubmissionsTable.tsx +180 -5
- package/src/pages/forms/fieldList.ts +21 -7
- package/src/pages/oauth/ConsentPage.tsx +271 -33
- package/src/registry/contributions.ts +1 -1
|
@@ -2,4 +2,19 @@ import type { AiDrawerTask } from './aiDrawerState.ts';
|
|
|
2
2
|
export declare const PERSON_INTAKE_TASK_ID = "person-intake";
|
|
3
3
|
/** The AI drawer task People's **Add from notes** opens. */
|
|
4
4
|
export declare function personIntakeTask(): AiDrawerTask;
|
|
5
|
+
/**
|
|
6
|
+
* Finds a person-intake run this tab saved before a reload, and makes it the
|
|
7
|
+
* drawer's task again with the drawer closed. The header button shows it, and
|
|
8
|
+
* the page stays uncovered. The wizard reads the saved run when it mounts and
|
|
9
|
+
* picks up on the saved step.
|
|
10
|
+
*
|
|
11
|
+
* Once per workspace the session lands in, so a task the user ended is not
|
|
12
|
+
* brought back while the page stays loaded. A workspace counts as checked
|
|
13
|
+
* only once nothing is saved there or the restore took: on a switch this runs
|
|
14
|
+
* before the drawer ends the old workspace's task, `restore` refuses while
|
|
15
|
+
* that task is active, and the check runs again when the drawer is free.
|
|
16
|
+
*
|
|
17
|
+
* A saved run another user left in this tab is deleted first.
|
|
18
|
+
*/
|
|
19
|
+
export declare function useRestorePersonIntake(): void;
|
|
5
20
|
//# sourceMappingURL=personIntakeTask.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"personIntakeTask.d.ts","sourceRoot":"","sources":["../../src/components/personIntakeTask.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"personIntakeTask.d.ts","sourceRoot":"","sources":["../../src/components/personIntakeTask.tsx"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAGtD,eAAO,MAAM,qBAAqB,kBAAkB,CAAA;AAEpD,4DAA4D;AAC5D,wBAAgB,gBAAgB,IAAI,YAAY,CAY/C;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,sBAAsB,IAAI,IAAI,CAkB7C"}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useRef } from 'react';
|
|
3
|
+
import { useSession } from '../api/resources/session.js';
|
|
4
|
+
import { clearOtherUsersIntakeRuns, clearSavedIntakeRuns, readSavedIntakeRun, } from '../lib/personIntakeRunStorage.js';
|
|
5
|
+
import { useAiDrawer } from './aiDrawerState.js';
|
|
2
6
|
import { PersonIntakePanel } from './PersonIntakePanel.js';
|
|
3
7
|
export const PERSON_INTAKE_TASK_ID = 'person-intake';
|
|
4
8
|
/** The AI drawer task People's **Add from notes** opens. */
|
|
@@ -8,6 +12,44 @@ export function personIntakeTask() {
|
|
|
8
12
|
title: 'Add a person from notes',
|
|
9
13
|
description: 'Paste what you know. Kelpie builds the record from it.',
|
|
10
14
|
render: (controls) => _jsx(PersonIntakePanel, { onClose: controls.finish, onPendingChange: controls.setPending }),
|
|
15
|
+
// Done, Discard and a workspace switch all end the task, and none of them
|
|
16
|
+
// should bring it back on the next reload.
|
|
17
|
+
onEnd: (workspaceId) => {
|
|
18
|
+
if (workspaceId !== null)
|
|
19
|
+
clearSavedIntakeRuns(workspaceId);
|
|
20
|
+
},
|
|
11
21
|
};
|
|
12
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* Finds a person-intake run this tab saved before a reload, and makes it the
|
|
25
|
+
* drawer's task again with the drawer closed. The header button shows it, and
|
|
26
|
+
* the page stays uncovered. The wizard reads the saved run when it mounts and
|
|
27
|
+
* picks up on the saved step.
|
|
28
|
+
*
|
|
29
|
+
* Once per workspace the session lands in, so a task the user ended is not
|
|
30
|
+
* brought back while the page stays loaded. A workspace counts as checked
|
|
31
|
+
* only once nothing is saved there or the restore took: on a switch this runs
|
|
32
|
+
* before the drawer ends the old workspace's task, `restore` refuses while
|
|
33
|
+
* that task is active, and the check runs again when the drawer is free.
|
|
34
|
+
*
|
|
35
|
+
* A saved run another user left in this tab is deleted first.
|
|
36
|
+
*/
|
|
37
|
+
export function useRestorePersonIntake() {
|
|
38
|
+
const { session } = useSession();
|
|
39
|
+
const { restore, activeTask } = useAiDrawer();
|
|
40
|
+
const workspaceId = session?.workspaceId ?? null;
|
|
41
|
+
const userId = session?.userId ?? null;
|
|
42
|
+
const checked = useRef(null);
|
|
43
|
+
useEffect(() => {
|
|
44
|
+
if (userId !== null)
|
|
45
|
+
clearOtherUsersIntakeRuns(userId);
|
|
46
|
+
}, [userId]);
|
|
47
|
+
useEffect(() => {
|
|
48
|
+
if (workspaceId === null || userId === null || checked.current === workspaceId)
|
|
49
|
+
return;
|
|
50
|
+
if (readSavedIntakeRun(workspaceId, userId) === undefined || restore(personIntakeTask())) {
|
|
51
|
+
checked.current = workspaceId;
|
|
52
|
+
}
|
|
53
|
+
}, [workspaceId, userId, restore, activeTask]);
|
|
54
|
+
}
|
|
13
55
|
//# sourceMappingURL=personIntakeTask.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"personIntakeTask.js","sourceRoot":"","sources":["../../src/components/personIntakeTask.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"personIntakeTask.js","sourceRoot":"","sources":["../../src/components/personIntakeTask.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAA;AAEzC,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAA;AACxD,OAAO,EACL,yBAAyB,EACzB,oBAAoB,EACpB,kBAAkB,GACnB,MAAM,kCAAkC,CAAA;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAEhD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAyB,CAAA;AAE3D,MAAM,CAAC,MAAM,qBAAqB,GAAG,eAAe,CAAA;AAEpD,4DAA4D;AAC5D,MAAM,UAAU,gBAAgB;IAC9B,OAAO;QACL,EAAE,EAAE,qBAAqB;QACzB,KAAK,EAAE,yBAAyB;QAChC,WAAW,EAAE,wDAAwD;QACrE,MAAM,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,KAAC,iBAAiB,IAAC,OAAO,EAAE,QAAQ,CAAC,MAAM,EAAE,eAAe,EAAE,QAAQ,CAAC,UAAU,GAAI;QAC3G,0EAA0E;QAC1E,2CAA2C;QAC3C,KAAK,EAAE,CAAC,WAAW,EAAE,EAAE;YACrB,IAAI,WAAW,KAAK,IAAI;gBAAE,oBAAoB,CAAC,WAAW,CAAC,CAAA;QAC7D,CAAC;KACF,CAAA;AACH,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,sBAAsB;IACpC,MAAM,EAAE,OAAO,EAAE,GAAG,UAAU,EAAE,CAAA;IAChC,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,GAAG,WAAW,EAAE,CAAA;IAC7C,MAAM,WAAW,GAAG,OAAO,EAAE,WAAW,IAAI,IAAI,CAAA;IAChD,MAAM,MAAM,GAAG,OAAO,EAAE,MAAM,IAAI,IAAI,CAAA;IACtC,MAAM,OAAO,GAAG,MAAM,CAAgB,IAAI,CAAC,CAAA;IAE3C,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,MAAM,KAAK,IAAI;YAAE,yBAAyB,CAAC,MAAM,CAAC,CAAA;IACxD,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAA;IAEZ,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,WAAW,KAAK,IAAI,IAAI,MAAM,KAAK,IAAI,IAAI,OAAO,CAAC,OAAO,KAAK,WAAW;YAAE,OAAM;QAEtF,IAAI,kBAAkB,CAAC,WAAW,EAAE,MAAM,CAAC,KAAK,SAAS,IAAI,OAAO,CAAC,gBAAgB,EAAE,CAAC,EAAE,CAAC;YACzF,OAAO,CAAC,OAAO,GAAG,WAAW,CAAA;QAC/B,CAAC;IACH,CAAC,EAAE,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC,CAAA;AAChD,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { PersonIntakeSavedRun } from '@kelpie/schemas';
|
|
2
|
+
/**
|
|
3
|
+
* The saved run for this workspace and user, or undefined when there is none
|
|
4
|
+
* or it cannot be read. An entry whose `user_id` is not this user's reads as
|
|
5
|
+
* none.
|
|
6
|
+
*/
|
|
7
|
+
export declare function readSavedIntakeRun(workspaceId: string, userId: string): PersonIntakeSavedRun | undefined;
|
|
8
|
+
export declare function saveIntakeRun(workspaceId: string, run: PersonIntakeSavedRun): void;
|
|
9
|
+
/** Forgets the workspace's saved run, whoever saved it. */
|
|
10
|
+
export declare function clearSavedIntakeRuns(workspaceId: string): void;
|
|
11
|
+
/** Forgets every saved run in this tab. Called on sign-out. */
|
|
12
|
+
export declare function clearAllSavedIntakeRuns(): void;
|
|
13
|
+
/** Forgets every saved run another user left in this tab. Called when the signed-in user is known. */
|
|
14
|
+
export declare function clearOtherUsersIntakeRuns(userId: string): void;
|
|
15
|
+
//# sourceMappingURL=personIntakeRunStorage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"personIntakeRunStorage.d.ts","sourceRoot":"","sources":["../../src/lib/personIntakeRunStorage.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAA;AA+C3D;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,oBAAoB,GAAG,SAAS,CAoBxG;AAED,wBAAgB,aAAa,CAAC,WAAW,EAAE,MAAM,EAAE,GAAG,EAAE,oBAAoB,GAAG,IAAI,CAMlF;AAED,2DAA2D;AAC3D,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAE9D;AAED,+DAA+D;AAC/D,wBAAgB,uBAAuB,IAAI,IAAI,CAE9C;AAED,sGAAsG;AACtG,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAE9D"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { personIntakeSavedRunSchema } from '@kelpie/schemas';
|
|
2
|
+
/**
|
|
3
|
+
* The person-intake run a tab is working on, kept in `sessionStorage` so a
|
|
4
|
+
* reload finds it again. One entry per workspace and user, because a task
|
|
5
|
+
* belongs to one workspace, and the notes in it belong to the person who
|
|
6
|
+
* typed them: a sign-out, or another user signing in to the same tab, must
|
|
7
|
+
* not show them.
|
|
8
|
+
*
|
|
9
|
+
* A convenience, not a record: storage can be blocked, full or cleared, and
|
|
10
|
+
* every read and write here treats a failure as "no saved run". The run itself
|
|
11
|
+
* lives on the server, which keeps its result for an hour.
|
|
12
|
+
*/
|
|
13
|
+
const KEY_PREFIX = 'kelpie.personIntake.run.';
|
|
14
|
+
function keyFor(workspaceId, userId) {
|
|
15
|
+
return `${KEY_PREFIX}${workspaceId}.${userId}`;
|
|
16
|
+
}
|
|
17
|
+
/** Every saved-run key in this tab's storage. Empty when storage cannot be read. */
|
|
18
|
+
function savedKeys() {
|
|
19
|
+
try {
|
|
20
|
+
const keys = [];
|
|
21
|
+
for (let index = 0; index < sessionStorage.length; index += 1) {
|
|
22
|
+
const key = sessionStorage.key(index);
|
|
23
|
+
if (key !== null && key.startsWith(KEY_PREFIX))
|
|
24
|
+
keys.push(key);
|
|
25
|
+
}
|
|
26
|
+
return keys;
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
// Blocked storage holds nothing to clear.
|
|
30
|
+
return [];
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
function removeKeys(keys) {
|
|
34
|
+
for (const key of keys) {
|
|
35
|
+
try {
|
|
36
|
+
sessionStorage.removeItem(key);
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
// Blocked storage: nothing could have been saved either.
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* The saved run for this workspace and user, or undefined when there is none
|
|
45
|
+
* or it cannot be read. An entry whose `user_id` is not this user's reads as
|
|
46
|
+
* none.
|
|
47
|
+
*/
|
|
48
|
+
export function readSavedIntakeRun(workspaceId, userId) {
|
|
49
|
+
let stored;
|
|
50
|
+
try {
|
|
51
|
+
stored = sessionStorage.getItem(keyFor(workspaceId, userId));
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
// Blocked storage (a private window, a sandboxed frame) means no saved run.
|
|
55
|
+
return undefined;
|
|
56
|
+
}
|
|
57
|
+
if (stored === null)
|
|
58
|
+
return undefined;
|
|
59
|
+
try {
|
|
60
|
+
const parsed = personIntakeSavedRunSchema.safeParse(JSON.parse(stored));
|
|
61
|
+
return parsed.success && parsed.data.user_id === userId ? parsed.data : undefined;
|
|
62
|
+
}
|
|
63
|
+
catch {
|
|
64
|
+
// Not JSON: written by hand or by something else. Treat it as no saved run.
|
|
65
|
+
return undefined;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
export function saveIntakeRun(workspaceId, run) {
|
|
69
|
+
try {
|
|
70
|
+
sessionStorage.setItem(keyFor(workspaceId, run.user_id), JSON.stringify(run));
|
|
71
|
+
}
|
|
72
|
+
catch {
|
|
73
|
+
// Not saving costs only the reload case: the task still runs in this tab.
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
/** Forgets the workspace's saved run, whoever saved it. */
|
|
77
|
+
export function clearSavedIntakeRuns(workspaceId) {
|
|
78
|
+
removeKeys(savedKeys().filter((key) => key.startsWith(`${KEY_PREFIX}${workspaceId}.`)));
|
|
79
|
+
}
|
|
80
|
+
/** Forgets every saved run in this tab. Called on sign-out. */
|
|
81
|
+
export function clearAllSavedIntakeRuns() {
|
|
82
|
+
removeKeys(savedKeys());
|
|
83
|
+
}
|
|
84
|
+
/** Forgets every saved run another user left in this tab. Called when the signed-in user is known. */
|
|
85
|
+
export function clearOtherUsersIntakeRuns(userId) {
|
|
86
|
+
removeKeys(savedKeys().filter((key) => !key.endsWith(`.${userId}`)));
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=personIntakeRunStorage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"personIntakeRunStorage.js","sourceRoot":"","sources":["../../src/lib/personIntakeRunStorage.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { PersonIntakeWizardProps } from '../registry/contributions.ts';
|
|
2
|
-
export declare function PersonIntakeWizard(
|
|
2
|
+
export declare function PersonIntakeWizard(props: PersonIntakeWizardProps): React.JSX.Element;
|
|
3
3
|
//# sourceMappingURL=PersonIntakeWizard.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PersonIntakeWizard.d.ts","sourceRoot":"","sources":["../../src/modules/PersonIntakeWizard.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"PersonIntakeWizard.d.ts","sourceRoot":"","sources":["../../src/modules/PersonIntakeWizard.tsx"],"names":[],"mappings":"AAoCA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAA;AAqI3E,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,uBAAuB,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CAcpF"}
|
|
@@ -1,70 +1,284 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { PERSON_INTAKE_KIND_LABELS, PERSON_INTAKE_KINDS, PERSON_INTAKE_PERSON_KEY, personIntakeDependencies, } from '@kelpie/schemas';
|
|
2
|
+
import { PERSON_INTAKE_KIND_LABELS, PERSON_INTAKE_KINDS, PERSON_INTAKE_PERSON_KEY, personIntakeCandidateBody, personIntakeDependencies, personIntakeCandidateSchema, } from '@kelpie/schemas';
|
|
3
3
|
import { useEffect, useState } from 'react';
|
|
4
4
|
import { Link } from 'react-router';
|
|
5
5
|
import { useAiServiceLabel } from '../api/resources/ai.js';
|
|
6
|
-
import { useApplyPersonIntake,
|
|
6
|
+
import { useApplyPersonIntake, usePersonIntakeRun, useStartIdentify, useStartResearch, } from '../api/resources/personIntake.js';
|
|
7
|
+
import { useSession } from '../api/resources/session.js';
|
|
7
8
|
import { Chip } from '../components/Chip.js';
|
|
8
9
|
import { IntakeFrame, NotesField } from '../components/PersonIntakePanel.js';
|
|
9
|
-
import { ErrorPanel } from '../components/QueryState.js';
|
|
10
|
+
import { ErrorPanel, LoadingPanel } from '../components/QueryState.js';
|
|
11
|
+
import { clearSavedIntakeRuns, readSavedIntakeRun, saveIntakeRun } from '../lib/personIntakeRunStorage.js';
|
|
10
12
|
import { effectiveSelection } from './personIntakeSelection.js';
|
|
11
13
|
const STEP_LABELS = ['Notes', 'Confirm', 'Choose', 'Done'];
|
|
12
|
-
const STEP_INDEX = {
|
|
14
|
+
const STEP_INDEX = {
|
|
15
|
+
notes: 0,
|
|
16
|
+
confirm: 1,
|
|
17
|
+
choose: 2,
|
|
18
|
+
done: 3,
|
|
19
|
+
};
|
|
20
|
+
/** Shown, with the notes still filled in, when a run's result has gone. */
|
|
21
|
+
const RESULT_GONE_MESSAGE = 'This result is no longer available. Start again.';
|
|
13
22
|
/** Pipeline records start unticked: the model suggests them, the user decides. */
|
|
14
23
|
const OFF_BY_DEFAULT = new Set(['partnership', 'deal', 'enquiry']);
|
|
15
24
|
const primaryButton = 'rounded-md bg-accent px-3 py-1.5 text-[12px] font-semibold text-accent-fg hover:bg-accent-hover disabled:opacity-50';
|
|
16
25
|
const secondaryButton = 'rounded-md px-2.5 py-1.5 text-[12px] font-medium text-ink-muted hover:text-ink disabled:opacity-50';
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
26
|
+
/** The Confirm step for a research run, rebuilt from the person it was started with. */
|
|
27
|
+
function confirmFrom(candidate, identifyRunId, existingPersonId) {
|
|
28
|
+
if (candidate === null)
|
|
29
|
+
return { kind: 'notes' };
|
|
30
|
+
return {
|
|
31
|
+
kind: 'confirm',
|
|
32
|
+
identified: { candidates: [personIntakeCandidateSchema.parse(candidate)], question: null, sources: [] },
|
|
33
|
+
identifyRunId,
|
|
34
|
+
target: existingPersonId,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
function confirmFor(watched) {
|
|
38
|
+
return confirmFrom(watched.candidate, watched.identifyRunId, watched.existingPersonId);
|
|
39
|
+
}
|
|
40
|
+
function stepIndex(step) {
|
|
41
|
+
return step.kind === 'restoring' ? STEP_INDEX[step.saved] : STEP_INDEX[step.kind];
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Where a reload starts: the run to read, or, for a run that failed, the step
|
|
45
|
+
* and the notes alone. A failed research run reads its identify run again,
|
|
46
|
+
* while that result is kept, to rebuild the Confirm step.
|
|
47
|
+
*/
|
|
48
|
+
function restoredState(saved) {
|
|
49
|
+
if (saved === undefined)
|
|
50
|
+
return { step: { kind: 'notes' }, watched: undefined };
|
|
51
|
+
const runId = saved.run_id ?? (saved.step === 'confirm' ? saved.identify_run_id : null);
|
|
52
|
+
if (runId !== null) {
|
|
53
|
+
return {
|
|
54
|
+
step: { kind: 'restoring', saved: saved.step },
|
|
55
|
+
watched: {
|
|
56
|
+
runId,
|
|
57
|
+
text: saved.text,
|
|
58
|
+
identifyRunId: saved.run_id === null ? null : saved.identify_run_id,
|
|
59
|
+
candidate: saved.run_id === null ? null : saved.candidate,
|
|
60
|
+
existingPersonId: saved.run_id === null ? null : saved.existing_person_id,
|
|
61
|
+
fallback: saved.run_id === null && saved.candidate !== null
|
|
62
|
+
? { candidate: saved.candidate, existingPersonId: saved.existing_person_id }
|
|
63
|
+
: null,
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
return {
|
|
68
|
+
step: saved.step === 'confirm' ? confirmFrom(saved.candidate, null, saved.existing_person_id) : { kind: 'notes' },
|
|
69
|
+
watched: undefined,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
export function PersonIntakeWizard(props) {
|
|
73
|
+
const { session } = useSession();
|
|
74
|
+
// The saved run is per workspace and user, so the wizard waits until it knows both.
|
|
75
|
+
if (session === undefined)
|
|
76
|
+
return _jsx(LoadingPanel, { label: "Loading\u2026" });
|
|
77
|
+
return (_jsx(IntakeWizard, { ...props, workspaceId: session.workspaceId, userId: session.userId }, `${session.workspaceId ?? ''}:${session.userId}`));
|
|
78
|
+
}
|
|
79
|
+
function IntakeWizard({ onClose, onPendingChange, workspaceId, userId, }) {
|
|
80
|
+
const [restored] = useState(() => {
|
|
81
|
+
const saved = workspaceId === null ? undefined : readSavedIntakeRun(workspaceId, userId);
|
|
82
|
+
return { ...restoredState(saved), text: saved?.text ?? '' };
|
|
83
|
+
});
|
|
84
|
+
const [step, setStep] = useState(restored.step);
|
|
85
|
+
const [text, setText] = useState(restored.text);
|
|
86
|
+
const [watched, setWatched] = useState(restored.watched);
|
|
87
|
+
/** Why the last run failed, from the server. Shown as written: it is the run log's reason. */
|
|
88
|
+
const [runFailure, setRunFailure] = useState(null);
|
|
89
|
+
const [resultGone, setResultGone] = useState(false);
|
|
90
|
+
const identify = useStartIdentify();
|
|
91
|
+
const research = useStartResearch();
|
|
22
92
|
const apply = useApplyPersonIntake();
|
|
23
|
-
const
|
|
93
|
+
const polled = usePersonIntakeRun(watched?.runId);
|
|
94
|
+
// While a run is watched, even one the wizard cannot read just now, nothing
|
|
95
|
+
// new starts: the server run goes on, and a second would spend another.
|
|
96
|
+
const pending = identify.isPending || research.isPending || apply.isPending || watched !== undefined;
|
|
97
|
+
const readError = watched !== undefined && !polled.isNotFound ? polled.error : null;
|
|
24
98
|
useEffect(() => {
|
|
25
99
|
onPendingChange?.(pending);
|
|
26
100
|
}, [pending, onPendingChange]);
|
|
101
|
+
// Moves the wizard on when the run it waits on changes, once per settled run.
|
|
102
|
+
useEffect(() => {
|
|
103
|
+
if (watched === undefined)
|
|
104
|
+
return;
|
|
105
|
+
function keep(state) {
|
|
106
|
+
if (workspaceId !== null)
|
|
107
|
+
saveIntakeRun(workspaceId, { user_id: userId, ...state });
|
|
108
|
+
}
|
|
109
|
+
function forget() {
|
|
110
|
+
if (workspaceId !== null)
|
|
111
|
+
clearSavedIntakeRuns(workspaceId);
|
|
112
|
+
}
|
|
113
|
+
/** The run's result has gone: Confirm from the saved person when there is one, else the notes. */
|
|
114
|
+
function resultGoneFor(current) {
|
|
115
|
+
setWatched(undefined);
|
|
116
|
+
if (current.fallback !== null) {
|
|
117
|
+
setStep(confirmFrom(current.fallback.candidate, null, current.fallback.existingPersonId));
|
|
118
|
+
keep({
|
|
119
|
+
run_id: null,
|
|
120
|
+
identify_run_id: null,
|
|
121
|
+
step: 'confirm',
|
|
122
|
+
text: current.text,
|
|
123
|
+
candidate: current.fallback.candidate,
|
|
124
|
+
existing_person_id: current.fallback.existingPersonId,
|
|
125
|
+
});
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
setResultGone(true);
|
|
129
|
+
setStep({ kind: 'notes' });
|
|
130
|
+
forget();
|
|
131
|
+
}
|
|
132
|
+
if (polled.isNotFound) {
|
|
133
|
+
resultGoneFor(watched);
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
if (polled.error !== null) {
|
|
137
|
+
// The run may still finish. Keep watching it, and show the error with
|
|
138
|
+
// a way to read it again; the step leaves the loading state.
|
|
139
|
+
setStep((current) => (current.kind === 'restoring' ? confirmOrNotes(watched) : current));
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
const run = polled.run;
|
|
143
|
+
if (run === undefined)
|
|
144
|
+
return;
|
|
145
|
+
if (run.status === 'queued' || run.status === 'running') {
|
|
146
|
+
setStep((current) => current.kind !== 'restoring' ? current : run.kind === 'identify' ? { kind: 'notes' } : confirmFor(watched));
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
setWatched(undefined);
|
|
150
|
+
if (run.status === 'failed') {
|
|
151
|
+
setRunFailure(run.failureReason ?? 'The AI run failed.');
|
|
152
|
+
setStep((current) => current.kind === 'confirm' ? current : run.kind === 'identify' ? { kind: 'notes' } : confirmFor(watched));
|
|
153
|
+
// The step and the notes stay saved, with no run to wait on.
|
|
154
|
+
keep({
|
|
155
|
+
run_id: null,
|
|
156
|
+
identify_run_id: run.kind === 'research' ? watched.identifyRunId : null,
|
|
157
|
+
step: run.kind === 'identify' ? 'notes' : 'confirm',
|
|
158
|
+
text: watched.text,
|
|
159
|
+
candidate: run.kind === 'research' ? watched.candidate : null,
|
|
160
|
+
existing_person_id: run.kind === 'research' ? watched.existingPersonId : null,
|
|
161
|
+
});
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
if (run.kind === 'identify' && run.result !== null) {
|
|
165
|
+
setStep({ kind: 'confirm', identified: run.result, identifyRunId: run.runId });
|
|
166
|
+
keep({
|
|
167
|
+
run_id: run.runId,
|
|
168
|
+
identify_run_id: null,
|
|
169
|
+
step: 'confirm',
|
|
170
|
+
text: watched.text,
|
|
171
|
+
candidate: null,
|
|
172
|
+
existing_person_id: null,
|
|
173
|
+
});
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
if (run.kind === 'research' && run.result !== null) {
|
|
177
|
+
setStep({ kind: 'choose', research: run.result });
|
|
178
|
+
keep({
|
|
179
|
+
run_id: run.runId,
|
|
180
|
+
identify_run_id: watched.identifyRunId,
|
|
181
|
+
step: 'choose',
|
|
182
|
+
text: watched.text,
|
|
183
|
+
candidate: watched.candidate,
|
|
184
|
+
existing_person_id: watched.existingPersonId,
|
|
185
|
+
});
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
// Succeeded, and the hour has passed: the result is gone.
|
|
189
|
+
resultGoneFor(watched);
|
|
190
|
+
}, [watched, polled.run, polled.error, polled.isNotFound, workspaceId, userId]);
|
|
191
|
+
function remember(run, savedStep) {
|
|
192
|
+
setWatched(run);
|
|
193
|
+
if (workspaceId === null)
|
|
194
|
+
return;
|
|
195
|
+
saveIntakeRun(workspaceId, {
|
|
196
|
+
user_id: userId,
|
|
197
|
+
run_id: run.runId,
|
|
198
|
+
identify_run_id: run.identifyRunId,
|
|
199
|
+
step: savedStep,
|
|
200
|
+
text: run.text,
|
|
201
|
+
candidate: run.candidate,
|
|
202
|
+
existing_person_id: run.existingPersonId,
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
function forgetSaved() {
|
|
206
|
+
if (workspaceId !== null)
|
|
207
|
+
clearSavedIntakeRuns(workspaceId);
|
|
208
|
+
}
|
|
27
209
|
async function runIdentify() {
|
|
28
|
-
|
|
29
|
-
|
|
210
|
+
setRunFailure(null);
|
|
211
|
+
setResultGone(false);
|
|
212
|
+
const notes = text.trim();
|
|
213
|
+
const started = await identify.runAsync(notes);
|
|
214
|
+
remember({ runId: started.runId, text: notes, identifyRunId: null, candidate: null, existingPersonId: null, fallback: null }, 'notes');
|
|
30
215
|
}
|
|
31
|
-
async function runResearch(candidate, existingPersonId) {
|
|
32
|
-
|
|
33
|
-
|
|
216
|
+
async function runResearch(candidate, existingPersonId, identifyRunId) {
|
|
217
|
+
setRunFailure(null);
|
|
218
|
+
const notes = text.trim();
|
|
219
|
+
const started = await research.runAsync({ text: notes, candidate, existingPersonId });
|
|
220
|
+
remember({
|
|
221
|
+
runId: started.runId,
|
|
222
|
+
text: notes,
|
|
223
|
+
identifyRunId,
|
|
224
|
+
candidate: personIntakeCandidateBody(candidate),
|
|
225
|
+
existingPersonId,
|
|
226
|
+
fallback: null,
|
|
227
|
+
}, 'confirm');
|
|
34
228
|
}
|
|
35
229
|
async function runApply(items) {
|
|
36
230
|
const applied = await apply.runAsync(items);
|
|
37
231
|
setStep({ kind: 'done', results: applied.results });
|
|
232
|
+
forgetSaved();
|
|
38
233
|
}
|
|
39
|
-
|
|
234
|
+
function startAgain() {
|
|
235
|
+
setRunFailure(null);
|
|
236
|
+
setStep({ kind: 'notes' });
|
|
237
|
+
forgetSaved();
|
|
238
|
+
}
|
|
239
|
+
return (_jsxs(_Fragment, { children: [_jsx(StepBar, { current: stepIndex(step) }), readError !== null && (_jsxs("div", { role: "alert", className: "border-b border-border px-4 py-3", children: [_jsx(ErrorPanel, { error: readError }), _jsx("p", { className: "mt-2 text-[12px] text-ink-muted", children: "The run may still be working. Kelpie will not start another until this one is read." }), _jsx("button", { type: "button", className: `${secondaryButton} mt-1`, onClick: () => {
|
|
240
|
+
polled.refetch();
|
|
241
|
+
}, children: "Check again" })] })), step.kind === 'restoring' && _jsx(LoadingPanel, { label: "Picking up where you left off\u2026" }), step.kind === 'notes' && (_jsx(NotesStep, { text: text, onChange: setText, pending: pending, error: identify.error, failure: runFailure, notice: resultGone ? RESULT_GONE_MESSAGE : null, onNext: () => {
|
|
40
242
|
void runIdentify().catch(() => undefined);
|
|
41
|
-
} })), step.kind === 'confirm' && (_jsx(ConfirmStep, { identified: step.identified,
|
|
42
|
-
|
|
43
|
-
}, onNext: (
|
|
44
|
-
void runResearch(candidate, existingPersonId).catch(() => undefined);
|
|
45
|
-
} })), step.kind === 'choose' && (_jsx(ChooseStep, { research: step.research, pending: apply.isPending, error: apply.error, onBack: () => {
|
|
46
|
-
setStep({ kind: 'notes' });
|
|
47
|
-
}, onNext: (items) => {
|
|
243
|
+
} })), step.kind === 'confirm' && (_jsx(ConfirmStep, { identified: step.identified, initialTarget: step.target, pending: pending, error: research.error, failure: runFailure, onBack: startAgain, onNext: (candidate, existingPersonId) => {
|
|
244
|
+
void runResearch(candidate, existingPersonId, step.identifyRunId).catch(() => undefined);
|
|
245
|
+
} })), step.kind === 'choose' && (_jsx(ChooseStep, { research: step.research, pending: apply.isPending, error: apply.error, onBack: startAgain, onNext: (items) => {
|
|
48
246
|
void runApply(items).catch(() => undefined);
|
|
49
247
|
} })), step.kind === 'done' && _jsx(DoneStep, { results: step.results, onClose: onClose })] }));
|
|
50
248
|
}
|
|
249
|
+
/**
|
|
250
|
+
* Where a run the wizard could not read leaves it: the Confirm step for
|
|
251
|
+
* research, or for a reload of a failed research run the saved person's
|
|
252
|
+
* Confirm step, else the notes.
|
|
253
|
+
*/
|
|
254
|
+
function confirmOrNotes(watched) {
|
|
255
|
+
if (watched.candidate !== null)
|
|
256
|
+
return confirmFor(watched);
|
|
257
|
+
if (watched.fallback !== null)
|
|
258
|
+
return confirmFrom(watched.fallback.candidate, null, watched.fallback.existingPersonId);
|
|
259
|
+
return { kind: 'notes' };
|
|
260
|
+
}
|
|
261
|
+
/** A failed run's reason. The server wrote it for the user, so it is shown as it is. */
|
|
262
|
+
function RunFailure({ reason }) {
|
|
263
|
+
return (_jsx("div", { role: "alert", className: "mt-3 rounded-md border border-danger/40 bg-danger-soft px-4 py-3", children: _jsx("p", { className: "text-[13px] font-medium text-danger", children: reason }) }));
|
|
264
|
+
}
|
|
51
265
|
function StepBar({ current }) {
|
|
52
266
|
return (_jsx("ol", { className: "flex gap-4 border-b border-border px-4 py-2 text-[11px]", children: STEP_LABELS.map((label, index) => (_jsxs("li", { "aria-current": index === current ? 'step' : undefined, className: index === current ? 'font-semibold text-ink' : index < current ? 'text-ink-muted' : 'text-ink-faint', children: [String(index + 1), ". ", label] }, label))) }));
|
|
53
267
|
}
|
|
54
|
-
function NotesStep({ text, onChange, pending, error, onNext, }) {
|
|
268
|
+
function NotesStep({ text, onChange, pending, error, notice, failure, onNext, }) {
|
|
55
269
|
const serviceLabel = useAiServiceLabel();
|
|
56
|
-
return (_jsxs(IntakeFrame, { footer: _jsx("button", { type: "button", className: primaryButton, disabled: pending || text.trim().length === 0, onClick: onNext, children: pending ? 'Looking them up…' : 'Find this person' }), children: [_jsx(NotesField, { value: text, onChange: onChange, disabled: pending }), pending && (_jsxs("p", { className: "mt-2 text-[12px] text-ink-muted", children: [serviceLabel, " is looking this person up. With web search on, this can take a minute. You can keep working: this task stays open in the drawer."] })), error !== null && (_jsx("div", { className: "mt-3", children: _jsx(ErrorPanel, { error: error }) }))] }));
|
|
270
|
+
return (_jsxs(IntakeFrame, { footer: _jsx("button", { type: "button", className: primaryButton, disabled: pending || text.trim().length === 0, onClick: onNext, children: pending ? 'Looking them up…' : 'Find this person' }), children: [notice !== null && (_jsx("p", { role: "status", className: "mb-2 rounded-md border border-warning/40 bg-warning-soft px-3 py-2 text-[12px] text-ink", children: notice })), _jsx(NotesField, { value: text, onChange: onChange, disabled: pending }), pending && (_jsxs("p", { className: "mt-2 text-[12px] text-ink-muted", children: [serviceLabel, " is looking this person up. With web search on, this can take a minute. You can keep working: this task stays open in the drawer."] })), error !== null && (_jsx("div", { className: "mt-3", children: _jsx(ErrorPanel, { error: error }) })), failure !== null && _jsx(RunFailure, { reason: failure })] }));
|
|
57
271
|
}
|
|
58
272
|
const CONFIDENCE_TONES = {
|
|
59
273
|
high: 'success',
|
|
60
274
|
medium: 'warning',
|
|
61
275
|
low: 'neutral',
|
|
62
276
|
};
|
|
63
|
-
function ConfirmStep({ identified, pending, error, onBack, onNext, }) {
|
|
277
|
+
function ConfirmStep({ identified, initialTarget, pending, error, failure, onBack, onNext, }) {
|
|
64
278
|
const serviceLabel = useAiServiceLabel();
|
|
65
279
|
const first = identified.candidates[0];
|
|
66
280
|
const [candidateKey, setCandidateKey] = useState(first?.key ?? '');
|
|
67
|
-
const [target, setTarget] = useState(first?.existingPeople[0]?.id ?? 'new');
|
|
281
|
+
const [target, setTarget] = useState(initialTarget === undefined ? (first?.existingPeople[0]?.id ?? 'new') : (initialTarget ?? 'new'));
|
|
68
282
|
const candidate = identified.candidates.find((entry) => entry.key === candidateKey);
|
|
69
283
|
if (identified.candidates.length === 0) {
|
|
70
284
|
return (_jsxs(IntakeFrame, { footer: _jsx("button", { type: "button", className: primaryButton, onClick: onBack, children: "Add more detail" }), children: [_jsxs("p", { className: "text-[13px] font-medium text-ink", children: [serviceLabel, " could not tell who this is."] }), identified.question !== null && _jsx("p", { className: "mt-1 text-[13px] text-ink-muted", children: identified.question })] }));
|
|
@@ -82,7 +296,7 @@ function ConfirmStep({ identified, pending, error, onBack, onNext, }) {
|
|
|
82
296
|
setTarget(person.id);
|
|
83
297
|
} }), "Update", ' ', _jsx(Link, { to: `/people/${person.id}`, target: "_blank", className: "font-medium text-accent hover:underline", children: person.name }), person.email !== null && _jsx("span", { className: "text-ink-muted", children: person.email })] }, person.id))), _jsxs("label", { className: "flex items-center gap-2 text-[12px] text-ink", children: [_jsx("input", { type: "radio", name: "target", checked: target === 'new', onChange: () => {
|
|
84
298
|
setTarget('new');
|
|
85
|
-
} }), "Create a new person"] })] })] }))] }), pending && (_jsxs("p", { className: "mt-3 text-[12px] text-ink-muted", children: [serviceLabel, " is researching this person. With web search on, this can take a minute. You can keep working: this task stays open in the drawer."] })), _jsx(Sources, { sources: identified.sources }), error !== null && (_jsx("div", { className: "mt-3", children: _jsx(ErrorPanel, { error: error }) }))] }));
|
|
299
|
+
} }), "Create a new person"] })] })] }))] }), pending && (_jsxs("p", { className: "mt-3 text-[12px] text-ink-muted", children: [serviceLabel, " is researching this person. With web search on, this can take a minute. You can keep working: this task stays open in the drawer."] })), _jsx(Sources, { sources: identified.sources }), error !== null && (_jsx("div", { className: "mt-3", children: _jsx(ErrorPanel, { error: error }) })), failure !== null && _jsx(RunFailure, { reason: failure })] }));
|
|
86
300
|
}
|
|
87
301
|
function ChooseStep({ research, pending, error, onBack, onNext, }) {
|
|
88
302
|
const [ticked, setTicked] = useState(() => new Set(research.items.filter((item) => !OFF_BY_DEFAULT.has(item.kind)).map((item) => item.key)));
|
|
@@ -133,7 +347,7 @@ function itemTitle(item, companyNames) {
|
|
|
133
347
|
return item.title === '' ? `At ${company}` : `${item.title} at ${company}`;
|
|
134
348
|
}
|
|
135
349
|
case 'note':
|
|
136
|
-
return '
|
|
350
|
+
return 'Research note';
|
|
137
351
|
}
|
|
138
352
|
}
|
|
139
353
|
function actionNote(item) {
|