@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
|
@@ -4,10 +4,16 @@ import type { FormEvent } from 'react'
|
|
|
4
4
|
import { Link } from 'react-router'
|
|
5
5
|
|
|
6
6
|
import { useTimezone } from '../api/resources/account.ts'
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
useConfirmDecision,
|
|
9
|
+
useCreateDecision,
|
|
10
|
+
useDecisions,
|
|
11
|
+
useDeleteDecision,
|
|
12
|
+
} from '../api/resources/decisions.ts'
|
|
8
13
|
import { useMembers } from '../api/resources/members.ts'
|
|
9
14
|
import { formatDate } from '../lib/dates.ts'
|
|
10
15
|
import { FRAGMENT_HIGHLIGHT, useFragmentTarget } from '../lib/fragmentTarget.ts'
|
|
16
|
+
import { ConfirmDecisionButton, ConfirmedAnnouncement, DecisionProvenance } from './DecisionProvenance.tsx'
|
|
11
17
|
import { Paginator } from './Paginator.tsx'
|
|
12
18
|
import { ErrorPanel } from './QueryState.tsx'
|
|
13
19
|
import { SectionHeader } from './SectionHeader.tsx'
|
|
@@ -18,6 +24,9 @@ import { SectionHeader } from './SectionHeader.tsx'
|
|
|
18
24
|
* Ports the mockup's panel: add, remove, and the workspace-list link. The
|
|
19
25
|
* decision's owner defaults server-side to whoever records it, which is what
|
|
20
26
|
* the mockup's `members[0]` stood in for, so the form does not send one.
|
|
27
|
+
*
|
|
28
|
+
* A Decision a hosted AI run wrote is a proposal until a member confirms it.
|
|
29
|
+
* It is labelled as one and carries a Confirm button; Remove rejects it.
|
|
21
30
|
*/
|
|
22
31
|
|
|
23
32
|
export interface DecisionsPanelProps {
|
|
@@ -30,6 +39,7 @@ export function DecisionsPanel({ targetType, targetId }: DecisionsPanelProps): R
|
|
|
30
39
|
const members = useMembers()
|
|
31
40
|
const createDecision = useCreateDecision()
|
|
32
41
|
const deleteDecision = useDeleteDecision()
|
|
42
|
+
const confirmDecision = useConfirmDecision()
|
|
33
43
|
const [adding, setAdding] = useState(false)
|
|
34
44
|
const [body, setBody] = useState('')
|
|
35
45
|
const [rationale, setRationale] = useState('')
|
|
@@ -94,6 +104,12 @@ export function DecisionsPanel({ targetType, targetId }: DecisionsPanelProps): R
|
|
|
94
104
|
<ErrorPanel error={deleteDecision.error} />
|
|
95
105
|
</div>
|
|
96
106
|
)}
|
|
107
|
+
<ConfirmedAnnouncement count={confirmDecision.confirmedCount} />
|
|
108
|
+
{confirmDecision.error !== null && (
|
|
109
|
+
<div className="mb-3">
|
|
110
|
+
<ErrorPanel error={confirmDecision.error} />
|
|
111
|
+
</div>
|
|
112
|
+
)}
|
|
97
113
|
{decisions.error !== null && <ErrorPanel error={decisions.error} />}
|
|
98
114
|
|
|
99
115
|
{adding && (
|
|
@@ -163,6 +179,10 @@ export function DecisionsPanel({ targetType, targetId }: DecisionsPanelProps): R
|
|
|
163
179
|
onRemove={() => {
|
|
164
180
|
deleteDecision.run(decision.id)
|
|
165
181
|
}}
|
|
182
|
+
onConfirm={() => {
|
|
183
|
+
confirmDecision.run({ id: decision.id, updatedAt: decision.updatedAt })
|
|
184
|
+
}}
|
|
185
|
+
isConfirming={confirmDecision.pendingIds.has(decision.id)}
|
|
166
186
|
/>
|
|
167
187
|
))}
|
|
168
188
|
</ul>
|
|
@@ -197,10 +217,14 @@ function DecisionItem({
|
|
|
197
217
|
decision,
|
|
198
218
|
ownerName,
|
|
199
219
|
onRemove,
|
|
220
|
+
onConfirm,
|
|
221
|
+
isConfirming,
|
|
200
222
|
}: {
|
|
201
223
|
readonly decision: Decision
|
|
202
224
|
readonly ownerName: string | undefined
|
|
203
225
|
readonly onRemove: () => void
|
|
226
|
+
readonly onConfirm: () => void
|
|
227
|
+
readonly isConfirming: boolean
|
|
204
228
|
}): React.JSX.Element {
|
|
205
229
|
const timezone = useTimezone()
|
|
206
230
|
const target = useFragmentTarget<HTMLLIElement>(decision.id)
|
|
@@ -215,6 +239,9 @@ function DecisionItem({
|
|
|
215
239
|
>
|
|
216
240
|
<div className="flex items-start justify-between gap-2">
|
|
217
241
|
<p className="min-w-0 flex-1 text-[13px] font-medium text-ink">{decision.body}</p>
|
|
242
|
+
{decision.confirmedAt === null && (
|
|
243
|
+
<ConfirmDecisionButton body={decision.body} onConfirm={onConfirm} isPending={isConfirming} />
|
|
244
|
+
)}
|
|
218
245
|
<button
|
|
219
246
|
type="button"
|
|
220
247
|
onClick={onRemove}
|
|
@@ -226,10 +253,11 @@ function DecisionItem({
|
|
|
226
253
|
{decision.rationale !== null && (
|
|
227
254
|
<p className="mt-1 text-[12px] text-ink-muted">{decision.rationale}</p>
|
|
228
255
|
)}
|
|
229
|
-
<div className="mt-2 flex flex-wrap gap-x-3 gap-y-1 text-[11px] text-ink-faint">
|
|
256
|
+
<div className="mt-2 flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px] text-ink-faint">
|
|
230
257
|
<span>Decided {formatDate(decision.decidedAt, timezone)}</span>
|
|
231
258
|
{decision.dueAt !== null && <span>By {formatDate(decision.dueAt, timezone)}</span>}
|
|
232
259
|
{ownerName !== undefined && <span>{ownerName}</span>}
|
|
260
|
+
<DecisionProvenance origin={decision.origin} confirmedAt={decision.confirmedAt} />
|
|
233
261
|
</div>
|
|
234
262
|
</li>
|
|
235
263
|
)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { RecordReference } from '@kelpie/schemas'
|
|
2
|
-
import { useMemo } from 'react'
|
|
2
|
+
import { createContext, useContext, useMemo } from 'react'
|
|
3
3
|
import Markdown from 'react-markdown'
|
|
4
4
|
import type { Components } from 'react-markdown'
|
|
5
5
|
import { Link } from 'react-router'
|
|
@@ -23,6 +23,13 @@ import { remarkRecordReferences } from '../lib/recordReferences.ts'
|
|
|
23
23
|
* written by workspace members but read by everyone in the workspace, and an
|
|
24
24
|
* agent with write access to the handbook is another author again.
|
|
25
25
|
*
|
|
26
|
+
* **Nothing here loads an image.** Markdown image syntax renders as a link to
|
|
27
|
+
* the image, not as an `<img>`. A browser fetches an `<img>` the moment the
|
|
28
|
+
* page draws it, with no click, so an image URL in a note or a handbook page
|
|
29
|
+
* would tell another server who opened the page and when, and can carry data
|
|
30
|
+
* out in its query string. Kelpie has no image upload, so each image is on
|
|
31
|
+
* another server.
|
|
32
|
+
*
|
|
26
33
|
* The class names are the mockup's, element for element, so a page reads the
|
|
27
34
|
* same as it did before the swap.
|
|
28
35
|
*
|
|
@@ -35,6 +42,28 @@ function isAppPath(href: string | undefined): href is string {
|
|
|
35
42
|
return href !== undefined && href.startsWith('/') && !href.startsWith('//')
|
|
36
43
|
}
|
|
37
44
|
|
|
45
|
+
/** True for what a markdown link holds. A link inside a link is not valid HTML. */
|
|
46
|
+
const InsideLink = createContext(false)
|
|
47
|
+
|
|
48
|
+
function ImageLink({
|
|
49
|
+
src,
|
|
50
|
+
alt,
|
|
51
|
+
}: {
|
|
52
|
+
readonly src: unknown
|
|
53
|
+
readonly alt: string | undefined
|
|
54
|
+
}): React.JSX.Element {
|
|
55
|
+
const insideLink = useContext(InsideLink)
|
|
56
|
+
const label = alt === undefined || alt === '' ? 'Image' : `Image: ${alt}`
|
|
57
|
+
|
|
58
|
+
return typeof src === 'string' && src !== '' && !insideLink ? (
|
|
59
|
+
<a href={src} className="text-accent hover:underline" target="_blank" rel="noreferrer">
|
|
60
|
+
{label}
|
|
61
|
+
</a>
|
|
62
|
+
) : (
|
|
63
|
+
<span>{label}</span>
|
|
64
|
+
)
|
|
65
|
+
}
|
|
66
|
+
|
|
38
67
|
const components: Components = {
|
|
39
68
|
h1: ({ children }) => (
|
|
40
69
|
<h1 className="text-[22px] font-semibold tracking-tight text-ink">{children}</h1>
|
|
@@ -56,16 +85,21 @@ const components: Components = {
|
|
|
56
85
|
),
|
|
57
86
|
// A path inside the app stays in this tab and in the router; anything else
|
|
58
87
|
// opens beside it.
|
|
59
|
-
a: ({ href, children }) =>
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
{
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
{
|
|
67
|
-
|
|
68
|
-
|
|
88
|
+
a: ({ href, children }) => (
|
|
89
|
+
<InsideLink value={true}>
|
|
90
|
+
{isAppPath(href) ? (
|
|
91
|
+
<Link to={href} className="text-accent hover:underline">
|
|
92
|
+
{children}
|
|
93
|
+
</Link>
|
|
94
|
+
) : (
|
|
95
|
+
<a href={href} className="text-accent hover:underline" target="_blank" rel="noreferrer">
|
|
96
|
+
{children}
|
|
97
|
+
</a>
|
|
98
|
+
)}
|
|
99
|
+
</InsideLink>
|
|
100
|
+
),
|
|
101
|
+
// Never an `<img>`: see the note on images above.
|
|
102
|
+
img: ({ src, alt }) => <ImageLink src={src} alt={alt} />,
|
|
69
103
|
hr: () => <hr className="border-border" />,
|
|
70
104
|
// The wrapper scrolls rather than the page, so a wide table cannot push the
|
|
71
105
|
// sidebar off screen.
|
|
@@ -8,6 +8,7 @@ import { useCreateNote, useDeleteNote, useNotes, useUpdateNote } from '../api/re
|
|
|
8
8
|
import { formatDateTime } from '../lib/dates.ts'
|
|
9
9
|
import { FRAGMENT_HIGHLIGHT, useFragmentTarget } from '../lib/fragmentTarget.ts'
|
|
10
10
|
import { MarkdownView } from './MarkdownView.tsx'
|
|
11
|
+
import { OriginLabel } from './OriginLabel.tsx'
|
|
11
12
|
import { Paginator } from './Paginator.tsx'
|
|
12
13
|
import { RecordLinkTextarea } from './RecordLinkTextarea.tsx'
|
|
13
14
|
import { ErrorPanel } from './QueryState.tsx'
|
|
@@ -126,10 +127,13 @@ export function NotesPanel({ targetType, targetId }: NotesPanelProps): React.JSX
|
|
|
126
127
|
* A null author is a note written by a workspace API key, which belongs to the
|
|
127
128
|
* workspace rather than to a person. An id with no matching member is one whose
|
|
128
129
|
* membership was removed.
|
|
130
|
+
*
|
|
131
|
+
* A hosted AI run has no author and no key either, so it gets no name: the
|
|
132
|
+
* origin label beside the date says what wrote the note.
|
|
129
133
|
*/
|
|
130
|
-
function authorNameFor(note: Note, nameById: ReadonlyMap<string, string>): string {
|
|
134
|
+
function authorNameFor(note: Note, nameById: ReadonlyMap<string, string>): string | undefined {
|
|
131
135
|
if (note.authorId === null) {
|
|
132
|
-
return 'API key'
|
|
136
|
+
return note.origin === 'ai' ? undefined : 'API key'
|
|
133
137
|
}
|
|
134
138
|
|
|
135
139
|
return nameById.get(note.authorId) ?? 'Unknown'
|
|
@@ -140,7 +144,7 @@ function NoteItem({
|
|
|
140
144
|
authorName,
|
|
141
145
|
}: {
|
|
142
146
|
readonly note: Note
|
|
143
|
-
readonly authorName: string
|
|
147
|
+
readonly authorName: string | undefined
|
|
144
148
|
}): React.JSX.Element {
|
|
145
149
|
const timezone = useTimezone()
|
|
146
150
|
const updateNote = useUpdateNote()
|
|
@@ -275,10 +279,15 @@ function NoteItem({
|
|
|
275
279
|
)}
|
|
276
280
|
</div>
|
|
277
281
|
</div>
|
|
278
|
-
<div className="mt-2 flex items-center gap-2 text-[11px] text-ink-faint">
|
|
279
|
-
|
|
280
|
-
|
|
282
|
+
<div className="mt-2 flex flex-wrap items-center gap-2 text-[11px] text-ink-faint">
|
|
283
|
+
{authorName !== undefined && (
|
|
284
|
+
<>
|
|
285
|
+
<span>{authorName}</span>
|
|
286
|
+
<span>·</span>
|
|
287
|
+
</>
|
|
288
|
+
)}
|
|
281
289
|
<span>{formatDateTime(note.createdAt, timezone)}</span>
|
|
290
|
+
<OriginLabel origin={note.origin} />
|
|
282
291
|
</div>
|
|
283
292
|
{deleteNote.error !== null && (
|
|
284
293
|
<div className="mt-2">
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { WriteOrigin } from '@kelpie/schemas'
|
|
2
|
+
|
|
3
|
+
import { Chip } from './Chip.tsx'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Says when a Note or a Decision was not written by a member.
|
|
7
|
+
*
|
|
8
|
+
* A member's row shows nothing: that is the ordinary case, and a label on
|
|
9
|
+
* every row would hide the ones that matter. A row from before origin was
|
|
10
|
+
* recorded (`unknown`) shows nothing either: there is nothing true to say
|
|
11
|
+
* about it. The server sets `origin` from the caller, so the label does not
|
|
12
|
+
* depend on what the text says about itself.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
const ORIGIN_LABELS: Readonly<Record<WriteOrigin, string | null>> = {
|
|
16
|
+
member: null,
|
|
17
|
+
unknown: null,
|
|
18
|
+
agent: 'Written by an agent',
|
|
19
|
+
ai: 'Written by AI',
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function OriginLabel({ origin }: { readonly origin: WriteOrigin }): React.JSX.Element | null {
|
|
23
|
+
const label = ORIGIN_LABELS[origin]
|
|
24
|
+
|
|
25
|
+
return label === null ? null : <Chip>{label}</Chip>
|
|
26
|
+
}
|
package/src/components/Shell.tsx
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { useEffect, useRef, useState } from 'react'
|
|
2
|
-
import { Link, NavLink, Outlet, useLocation, useNavigate } from 'react-router'
|
|
2
|
+
import { Link, NavLink, Navigate, Outlet, useLocation, useNavigate } from 'react-router'
|
|
3
3
|
|
|
4
4
|
import { useAccount, useTheme } from '../api/resources/account.ts'
|
|
5
|
-
import { useLogOut } from '../api/resources/session.ts'
|
|
5
|
+
import { useLogOut, useSession } from '../api/resources/session.ts'
|
|
6
6
|
import { initialsOf } from '../lib/names.ts'
|
|
7
7
|
import type { ThemePreference } from '../lib/theme.ts'
|
|
8
8
|
import { ONBOARDING_RERUN_ENTRY } from '../pages/onboarding/onboardingRerun.ts'
|
|
@@ -10,6 +10,7 @@ import { useNavItems } from '../registry/context.ts'
|
|
|
10
10
|
import type { NavItem } from '../registry/contributions.ts'
|
|
11
11
|
import { useVisibleNavItems } from '../registry/visibleNav.ts'
|
|
12
12
|
import { AiDrawerLauncher, AiDrawerPanel, AiDrawerProvider } from './AiDrawer.tsx'
|
|
13
|
+
import { useRestorePersonIntake } from './personIntakeTask.tsx'
|
|
13
14
|
import { ErrorBoundary } from './ErrorBoundary.tsx'
|
|
14
15
|
import { WorkspaceSwitcher } from './WorkspaceSwitcher.tsx'
|
|
15
16
|
|
|
@@ -64,6 +65,7 @@ const DIRECTORY_NAV_IDS: ReadonlySet<string> = new Set(['people', 'companies'])
|
|
|
64
65
|
const TOOLS_NAV_IDS: ReadonlySet<string> = new Set(['lists', 'forms'])
|
|
65
66
|
|
|
66
67
|
const ADMIN_ENTRY_PATH = '/admin/workspace'
|
|
68
|
+
const AI_ENTRY_PATH = '/ai'
|
|
67
69
|
|
|
68
70
|
function isAdminRoute(pathname: string): boolean {
|
|
69
71
|
return pathname.startsWith('/admin/')
|
|
@@ -101,6 +103,9 @@ export function Shell(): React.JSX.Element {
|
|
|
101
103
|
}
|
|
102
104
|
|
|
103
105
|
function ShellLayout(): React.JSX.Element {
|
|
106
|
+
// A reload finds a person-intake run this tab started, and shows it in the
|
|
107
|
+
// header with the drawer closed.
|
|
108
|
+
useRestorePersonIntake()
|
|
104
109
|
const navigate = useNavigate()
|
|
105
110
|
const location = useLocation()
|
|
106
111
|
const { account } = useAccount()
|
|
@@ -170,7 +175,14 @@ function ShellLayout(): React.JSX.Element {
|
|
|
170
175
|
(item) => !DIRECTORY_NAV_IDS.has(item.id) && !TOOLS_NAV_IDS.has(item.id),
|
|
171
176
|
)
|
|
172
177
|
const adminItems = useVisibleNavItems(CORE_ADMIN_NAV, moduleAdminNav)
|
|
173
|
-
|
|
178
|
+
// Admin is for owners and admins. A member gets no link to it, and an admin
|
|
179
|
+
// address sends a member back to the dashboard. The check is on the path, so
|
|
180
|
+
// an admin page that a module adds is covered too. The API refuses the same
|
|
181
|
+
// work on its own; this only keeps a member off pages that cannot work.
|
|
182
|
+
const { session } = useSession()
|
|
183
|
+
const isAdmin = session?.role === 'owner' || session?.role === 'admin'
|
|
184
|
+
const onAdminRoute = isAdminRoute(location.pathname)
|
|
185
|
+
const inAdminNav = onAdminRoute && isAdmin
|
|
174
186
|
|
|
175
187
|
return (
|
|
176
188
|
<div className="flex min-h-screen bg-surface">
|
|
@@ -284,9 +296,16 @@ function ShellLayout(): React.JSX.Element {
|
|
|
284
296
|
</div>
|
|
285
297
|
)}
|
|
286
298
|
|
|
299
|
+
{/* AI is how a member connects an agent, so every member gets
|
|
300
|
+
the link. Admin is for owners and admins. */}
|
|
287
301
|
<div className="flex flex-col gap-0.5">
|
|
288
|
-
|
|
289
|
-
|
|
302
|
+
{isAdmin && (
|
|
303
|
+
<NavLink to={ADMIN_ENTRY_PATH} className={linkClass}>
|
|
304
|
+
Admin
|
|
305
|
+
</NavLink>
|
|
306
|
+
)}
|
|
307
|
+
<NavLink to={AI_ENTRY_PATH} className={linkClass}>
|
|
308
|
+
AI
|
|
290
309
|
</NavLink>
|
|
291
310
|
</div>
|
|
292
311
|
</>
|
|
@@ -429,7 +448,12 @@ function ShellLayout(): React.JSX.Element {
|
|
|
429
448
|
{/* Keyed on the path so navigating away from a crashed page remounts
|
|
430
449
|
the boundary instead of leaving it stuck showing the old error. */}
|
|
431
450
|
<ErrorBoundary key={location.pathname}>
|
|
432
|
-
|
|
451
|
+
{/* Nothing shows on an admin address until the role is known. */}
|
|
452
|
+
{!onAdminRoute || isAdmin ? (
|
|
453
|
+
<Outlet />
|
|
454
|
+
) : session === undefined ? null : (
|
|
455
|
+
<Navigate to="/dashboard" replace />
|
|
456
|
+
)}
|
|
433
457
|
</ErrorBoundary>
|
|
434
458
|
</main>
|
|
435
459
|
{/* Outside the route boundary, so a page that throws does not take a
|
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
import type { TagTargetType } from '@kelpie/schemas'
|
|
2
|
+
import { useEffect, useId, useRef, useState } from 'react'
|
|
3
|
+
|
|
4
|
+
import { useInvalidateTagSuggestions, useTagSuggestions } from '../api/resources/tags.ts'
|
|
5
|
+
import { Chip } from './Chip.tsx'
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Edit a record's tags: search the tags already in use, or create one.
|
|
9
|
+
*
|
|
10
|
+
* The search box holds only what is being typed. The chosen tags sit below it as
|
|
11
|
+
* chips, each with an × to remove it, so the box can be empty while the record
|
|
12
|
+
* still has tags. Every add and remove calls `onChange` at once with the whole
|
|
13
|
+
* new list; the caller saves it.
|
|
14
|
+
*
|
|
15
|
+
* The list opens in the page flow, not over it, so it pushes the chips down
|
|
16
|
+
* rather than hiding them. Chosen tags also lead the list, ticked, and a click
|
|
17
|
+
* removes one.
|
|
18
|
+
*
|
|
19
|
+
* Suggestions come from `GET /v1/tags` for `targetType`, so a person's picker
|
|
20
|
+
* offers person tags and not deal tags. A typed tag that differs from an
|
|
21
|
+
* existing one only by case takes the existing spelling, so "Investor" does not
|
|
22
|
+
* appear beside "investor".
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
export interface TagInputProps {
|
|
26
|
+
readonly value: readonly string[]
|
|
27
|
+
readonly onChange: (next: readonly string[]) => void
|
|
28
|
+
readonly targetType: TagTargetType
|
|
29
|
+
readonly placeholder?: string | undefined
|
|
30
|
+
/** `sm` for a record sidebar, `md` for a full-width form. */
|
|
31
|
+
readonly size?: 'sm' | 'md' | undefined
|
|
32
|
+
readonly label?: string | undefined
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
interface Row {
|
|
36
|
+
readonly kind: 'chosen' | 'existing' | 'create'
|
|
37
|
+
readonly tag: string
|
|
38
|
+
readonly count: number | null
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function sameTag(left: string, right: string): boolean {
|
|
42
|
+
return left.toLowerCase() === right.toLowerCase()
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function TagInput({
|
|
46
|
+
value,
|
|
47
|
+
onChange,
|
|
48
|
+
targetType,
|
|
49
|
+
placeholder = 'Search or create a tag…',
|
|
50
|
+
size = 'sm',
|
|
51
|
+
label = 'Tags',
|
|
52
|
+
}: TagInputProps): React.JSX.Element {
|
|
53
|
+
const listId = useId()
|
|
54
|
+
const rootRef = useRef<HTMLDivElement>(null)
|
|
55
|
+
const [query, setQuery] = useState('')
|
|
56
|
+
const [open, setOpen] = useState(false)
|
|
57
|
+
const [highlight, setHighlight] = useState(0)
|
|
58
|
+
const { suggestions, isLoading } = useTagSuggestions(targetType, query, open)
|
|
59
|
+
const invalidate = useInvalidateTagSuggestions()
|
|
60
|
+
|
|
61
|
+
const trimmed = query.trim()
|
|
62
|
+
// Chosen tags lead the list, ticked, so a reader can see what is already on
|
|
63
|
+
// the record without closing it. They come from `value`, not the server, so
|
|
64
|
+
// one outside the top suggestions still shows.
|
|
65
|
+
const chosen = value.filter((tag) => tag.toLowerCase().includes(trimmed.toLowerCase()))
|
|
66
|
+
const offered = suggestions.filter(
|
|
67
|
+
(suggestion) => !value.some((tag) => sameTag(tag, suggestion.tag)),
|
|
68
|
+
)
|
|
69
|
+
const alreadyChosen = trimmed.length > 0 && value.some((tag) => sameTag(tag, trimmed))
|
|
70
|
+
const exists = suggestions.some((suggestion) => sameTag(suggestion.tag, trimmed))
|
|
71
|
+
const rows: readonly Row[] = [
|
|
72
|
+
...chosen.map((tag): Row => ({ kind: 'chosen', tag, count: null })),
|
|
73
|
+
...offered.map((suggestion): Row => ({
|
|
74
|
+
kind: 'existing',
|
|
75
|
+
tag: suggestion.tag,
|
|
76
|
+
count: suggestion.count,
|
|
77
|
+
})),
|
|
78
|
+
...(trimmed.length > 0 && !exists && !alreadyChosen
|
|
79
|
+
? [{ kind: 'create' as const, tag: trimmed, count: null }]
|
|
80
|
+
: []),
|
|
81
|
+
]
|
|
82
|
+
|
|
83
|
+
useEffect(() => {
|
|
84
|
+
if (!open) {
|
|
85
|
+
return
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function onPointerDown(event: MouseEvent): void {
|
|
89
|
+
if (rootRef.current?.contains(event.target as Node) !== true) {
|
|
90
|
+
setOpen(false)
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
document.addEventListener('mousedown', onPointerDown)
|
|
95
|
+
|
|
96
|
+
return () => {
|
|
97
|
+
document.removeEventListener('mousedown', onPointerDown)
|
|
98
|
+
}
|
|
99
|
+
}, [open])
|
|
100
|
+
|
|
101
|
+
// Start on the first tag not yet chosen, so Enter adds rather than removes.
|
|
102
|
+
// With nothing to add, nothing is highlighted, and Enter does nothing.
|
|
103
|
+
const firstOffered = chosen.length < rows.length ? chosen.length : -1
|
|
104
|
+
|
|
105
|
+
useEffect(() => {
|
|
106
|
+
setHighlight(firstOffered)
|
|
107
|
+
}, [query, open, firstOffered])
|
|
108
|
+
|
|
109
|
+
/** Adds each tag not already chosen, in order, and clears the box. */
|
|
110
|
+
function add(...tags: readonly string[]): void {
|
|
111
|
+
const next = [...value]
|
|
112
|
+
|
|
113
|
+
for (const tag of tags) {
|
|
114
|
+
const clean = tag.trim()
|
|
115
|
+
|
|
116
|
+
if (clean.length === 0 || next.some((existing) => sameTag(existing, clean))) {
|
|
117
|
+
continue
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// Take the spelling already in use, if there is one.
|
|
121
|
+
const known = suggestions.find((suggestion) => sameTag(suggestion.tag, clean))
|
|
122
|
+
|
|
123
|
+
next.push(known?.tag ?? clean)
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
setQuery('')
|
|
127
|
+
|
|
128
|
+
if (next.length !== value.length) {
|
|
129
|
+
onChange(next)
|
|
130
|
+
invalidate()
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* A comma ends a tag, as it did when this was a text box. Handled on change
|
|
136
|
+
* rather than on keydown, so a pasted "a, b, c" adds three tags too. What
|
|
137
|
+
* follows the last comma stays in the box.
|
|
138
|
+
*/
|
|
139
|
+
function type(text: string): void {
|
|
140
|
+
const parts = text.split(',')
|
|
141
|
+
const rest = parts.pop() ?? ''
|
|
142
|
+
|
|
143
|
+
if (parts.length > 0) {
|
|
144
|
+
add(...parts)
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
setQuery(rest)
|
|
148
|
+
setOpen(true)
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
function remove(tag: string): void {
|
|
152
|
+
onChange(value.filter((existing) => existing !== tag))
|
|
153
|
+
invalidate()
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
const inputClass = size === 'sm' ? 'px-2 py-1.5 text-[12px]' : 'px-3 py-2 text-[13px]'
|
|
157
|
+
|
|
158
|
+
return (
|
|
159
|
+
<div ref={rootRef} className="space-y-1.5">
|
|
160
|
+
<div className="relative">
|
|
161
|
+
<input
|
|
162
|
+
value={query}
|
|
163
|
+
onChange={(event) => {
|
|
164
|
+
type(event.target.value)
|
|
165
|
+
}}
|
|
166
|
+
onFocus={() => {
|
|
167
|
+
setOpen(true)
|
|
168
|
+
}}
|
|
169
|
+
onKeyDown={(event) => {
|
|
170
|
+
if (event.key === 'ArrowDown') {
|
|
171
|
+
event.preventDefault()
|
|
172
|
+
setOpen(true)
|
|
173
|
+
setHighlight((current) => Math.min(current + 1, Math.max(rows.length - 1, 0)))
|
|
174
|
+
} else if (event.key === 'ArrowUp') {
|
|
175
|
+
event.preventDefault()
|
|
176
|
+
setHighlight((current) => Math.max(current - 1, 0))
|
|
177
|
+
} else if (event.key === 'Enter') {
|
|
178
|
+
event.preventDefault()
|
|
179
|
+
const row = open ? rows[highlight] : undefined
|
|
180
|
+
|
|
181
|
+
if (row?.kind === 'chosen') {
|
|
182
|
+
remove(row.tag)
|
|
183
|
+
} else {
|
|
184
|
+
add(row?.tag ?? trimmed)
|
|
185
|
+
}
|
|
186
|
+
} else if (event.key === 'Escape') {
|
|
187
|
+
setOpen(false)
|
|
188
|
+
setQuery('')
|
|
189
|
+
}
|
|
190
|
+
}}
|
|
191
|
+
placeholder={placeholder}
|
|
192
|
+
role="combobox"
|
|
193
|
+
aria-label={label}
|
|
194
|
+
aria-expanded={open}
|
|
195
|
+
aria-controls={listId}
|
|
196
|
+
aria-autocomplete="list"
|
|
197
|
+
className={`w-full rounded-md border border-border bg-surface-raised outline-none focus:border-accent focus:ring-2 focus:ring-accent/20 ${inputClass}`}
|
|
198
|
+
/>
|
|
199
|
+
|
|
200
|
+
{open && (
|
|
201
|
+
<ul
|
|
202
|
+
id={listId}
|
|
203
|
+
role="listbox"
|
|
204
|
+
aria-label={`${label} suggestions`}
|
|
205
|
+
className="mt-1 max-h-56 w-full overflow-auto rounded-md border border-border bg-surface-raised py-1"
|
|
206
|
+
>
|
|
207
|
+
{rows.length === 0 ? (
|
|
208
|
+
<li className="px-3 py-2 text-[12px] text-ink-faint">
|
|
209
|
+
{isLoading ? 'Loading…' : 'Type to create a tag'}
|
|
210
|
+
</li>
|
|
211
|
+
) : (
|
|
212
|
+
rows.map((row, index) => (
|
|
213
|
+
<li
|
|
214
|
+
key={`${row.kind}:${row.tag}`}
|
|
215
|
+
role="option"
|
|
216
|
+
aria-selected={index === highlight}
|
|
217
|
+
aria-checked={row.kind === 'chosen'}
|
|
218
|
+
// A rule between the groups: chosen, then in use, then create.
|
|
219
|
+
className={
|
|
220
|
+
index > 0 && rows[index - 1]?.kind !== row.kind ? 'border-t border-border' : ''
|
|
221
|
+
}
|
|
222
|
+
>
|
|
223
|
+
<button
|
|
224
|
+
type="button"
|
|
225
|
+
onMouseEnter={() => {
|
|
226
|
+
setHighlight(index)
|
|
227
|
+
}}
|
|
228
|
+
onClick={() => {
|
|
229
|
+
if (row.kind === 'chosen') {
|
|
230
|
+
remove(row.tag)
|
|
231
|
+
} else {
|
|
232
|
+
add(row.tag)
|
|
233
|
+
}
|
|
234
|
+
}}
|
|
235
|
+
className={[
|
|
236
|
+
'flex w-full items-center justify-between gap-2 px-3 py-1.5 text-left text-[12px]',
|
|
237
|
+
row.kind === 'create' ? 'font-medium text-accent' : 'text-ink',
|
|
238
|
+
index === highlight ? 'bg-accent-soft' : 'hover:bg-surface',
|
|
239
|
+
].join(' ')}
|
|
240
|
+
>
|
|
241
|
+
<span className="flex min-w-0 items-center gap-1.5">
|
|
242
|
+
{row.kind === 'chosen' && (
|
|
243
|
+
<span aria-hidden className="text-accent">
|
|
244
|
+
✓
|
|
245
|
+
</span>
|
|
246
|
+
)}
|
|
247
|
+
<span className="truncate">
|
|
248
|
+
{row.kind === 'create' ? `Create “${row.tag}”` : row.tag}
|
|
249
|
+
</span>
|
|
250
|
+
</span>
|
|
251
|
+
{row.kind === 'chosen' && (
|
|
252
|
+
<span className="shrink-0 text-[10px] text-ink-faint">
|
|
253
|
+
Added · click to remove
|
|
254
|
+
</span>
|
|
255
|
+
)}
|
|
256
|
+
{row.count !== null && row.count > 0 && (
|
|
257
|
+
<span className="shrink-0 text-[10px] text-ink-faint">{row.count}</span>
|
|
258
|
+
)}
|
|
259
|
+
</button>
|
|
260
|
+
</li>
|
|
261
|
+
))
|
|
262
|
+
)}
|
|
263
|
+
</ul>
|
|
264
|
+
)}
|
|
265
|
+
</div>
|
|
266
|
+
|
|
267
|
+
{value.length > 0 && (
|
|
268
|
+
<ul aria-label={label} className="flex flex-wrap gap-1">
|
|
269
|
+
{value.map((tag) => (
|
|
270
|
+
<li key={tag}>
|
|
271
|
+
<Chip
|
|
272
|
+
onRemove={() => {
|
|
273
|
+
remove(tag)
|
|
274
|
+
}}
|
|
275
|
+
removeLabel={`Remove tag ${tag}`}
|
|
276
|
+
>
|
|
277
|
+
{tag}
|
|
278
|
+
</Chip>
|
|
279
|
+
</li>
|
|
280
|
+
))}
|
|
281
|
+
</ul>
|
|
282
|
+
)}
|
|
283
|
+
</div>
|
|
284
|
+
)
|
|
285
|
+
}
|
|
@@ -24,6 +24,12 @@ export interface AiDrawerTask {
|
|
|
24
24
|
/** A line under the title. */
|
|
25
25
|
readonly description?: string
|
|
26
26
|
readonly render: (controls: AiDrawerControls) => ReactNode
|
|
27
|
+
/**
|
|
28
|
+
* Called once when the task ends: Done, Discard, or a workspace switch.
|
|
29
|
+
* `workspaceId` is the workspace the task belonged to. For clearing
|
|
30
|
+
* anything the task saved outside React state.
|
|
31
|
+
*/
|
|
32
|
+
readonly onEnd?: (workspaceId: string | null) => void
|
|
27
33
|
}
|
|
28
34
|
|
|
29
35
|
export interface AiDrawerState {
|
|
@@ -35,6 +41,12 @@ export interface AiDrawerState {
|
|
|
35
41
|
* one instead, says so, and returns `false`. Nothing is replaced silently.
|
|
36
42
|
*/
|
|
37
43
|
readonly open: (task: AiDrawerTask) => boolean
|
|
44
|
+
/**
|
|
45
|
+
* Makes `task` the active task with the drawer closed, so the header button
|
|
46
|
+
* shows it. For a task found again after a reload. Returns `false`, and
|
|
47
|
+
* changes nothing, when a task is active.
|
|
48
|
+
*/
|
|
49
|
+
readonly restore: (task: AiDrawerTask) => boolean
|
|
38
50
|
/** Shows the active task again. */
|
|
39
51
|
readonly reopen: () => void
|
|
40
52
|
readonly close: () => void
|