@kelpie/ui 0.15.0 → 0.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/client.d.ts +6 -5
- package/dist/api/client.d.ts.map +1 -1
- package/dist/api/client.js +2 -2
- package/dist/api/client.js.map +1 -1
- package/dist/api/resource.d.ts +4 -4
- package/dist/api/resource.d.ts.map +1 -1
- package/dist/api/resource.js +4 -5
- package/dist/api/resource.js.map +1 -1
- package/dist/api/resources/ai.d.ts +16 -0
- package/dist/api/resources/ai.d.ts.map +1 -0
- package/dist/api/resources/ai.js +93 -0
- package/dist/api/resources/ai.js.map +1 -0
- package/dist/api/resources/conversions.js +1 -1
- package/dist/api/resources/conversions.js.map +1 -1
- package/dist/api/resources/members.d.ts +2 -2
- package/dist/api/resources/oauth.d.ts +21 -0
- package/dist/api/resources/oauth.d.ts.map +1 -0
- package/dist/api/resources/oauth.js +74 -0
- package/dist/api/resources/oauth.js.map +1 -0
- package/dist/api/resources/planItems.d.ts +1 -1
- package/dist/api/resources/planItems.d.ts.map +1 -1
- package/dist/api/resources/planItems.js +1 -1
- package/dist/api/resources/planItems.js.map +1 -1
- package/dist/api/resources/session.d.ts +1 -1
- package/dist/api/resources/session.d.ts.map +1 -1
- package/dist/api/resources/session.js +4 -2
- package/dist/api/resources/session.js.map +1 -1
- package/dist/api/resources/workspace.d.ts +2 -2
- package/dist/api/resources/workspace.js +2 -2
- package/dist/app/KelpieApp.d.ts.map +1 -1
- package/dist/app/KelpieApp.js +3 -1
- package/dist/app/KelpieApp.js.map +1 -1
- package/dist/components/ActivitiesPanel.d.ts +7 -4
- package/dist/components/ActivitiesPanel.d.ts.map +1 -1
- package/dist/components/ActivitiesPanel.js +12 -2
- package/dist/components/ActivitiesPanel.js.map +1 -1
- package/dist/components/ActivityAction.d.ts +15 -0
- package/dist/components/ActivityAction.d.ts.map +1 -0
- package/dist/components/ActivityAction.js +20 -0
- package/dist/components/ActivityAction.js.map +1 -0
- package/dist/components/AgentTasks.d.ts +5 -0
- package/dist/components/AgentTasks.d.ts.map +1 -1
- package/dist/components/AgentTasks.js +88 -10
- package/dist/components/AgentTasks.js.map +1 -1
- package/dist/components/ApiKeysPanel.d.ts.map +1 -1
- package/dist/components/ApiKeysPanel.js +4 -1
- package/dist/components/ApiKeysPanel.js.map +1 -1
- package/dist/components/DecisionsPanel.d.ts.map +1 -1
- package/dist/components/DecisionsPanel.js +3 -1
- package/dist/components/DecisionsPanel.js.map +1 -1
- package/dist/components/LinkedText.d.ts +12 -0
- package/dist/components/LinkedText.d.ts.map +1 -0
- package/dist/components/LinkedText.js +25 -0
- package/dist/components/LinkedText.js.map +1 -0
- package/dist/components/MarkdownView.d.ts +3 -1
- package/dist/components/MarkdownView.d.ts.map +1 -1
- package/dist/components/MarkdownView.js +17 -3
- package/dist/components/MarkdownView.js.map +1 -1
- package/dist/components/NotesPanel.d.ts +2 -1
- package/dist/components/NotesPanel.d.ts.map +1 -1
- package/dist/components/NotesPanel.js +6 -7
- package/dist/components/NotesPanel.js.map +1 -1
- package/dist/components/Paginator.d.ts +1 -1
- package/dist/components/PlanPanel.d.ts.map +1 -1
- package/dist/components/PlanPanel.js +3 -1
- package/dist/components/PlanPanel.js.map +1 -1
- package/dist/components/RecordLinkTextarea.d.ts +12 -0
- package/dist/components/RecordLinkTextarea.d.ts.map +1 -0
- package/dist/components/RecordLinkTextarea.js +142 -0
- package/dist/components/RecordLinkTextarea.js.map +1 -0
- package/dist/components/Shell.js +1 -1
- package/dist/components/SummaryBlock.d.ts +1 -1
- package/dist/components/SummaryBlock.js +1 -1
- package/dist/components/WorkspaceSwitcher.d.ts +2 -1
- package/dist/components/WorkspaceSwitcher.d.ts.map +1 -1
- package/dist/components/WorkspaceSwitcher.js +7 -2
- package/dist/components/WorkspaceSwitcher.js.map +1 -1
- package/dist/index.d.ts +5 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -1
- package/dist/index.js.map +1 -1
- package/dist/lib/fragmentTarget.d.ts +18 -0
- package/dist/lib/fragmentTarget.d.ts.map +1 -0
- package/dist/lib/fragmentTarget.js +73 -0
- package/dist/lib/fragmentTarget.js.map +1 -0
- package/dist/lib/mcpConfig.d.ts +10 -0
- package/dist/lib/mcpConfig.d.ts.map +1 -0
- package/dist/lib/mcpConfig.js +23 -0
- package/dist/lib/mcpConfig.js.map +1 -0
- package/dist/lib/money.d.ts +2 -2
- package/dist/lib/money.js +2 -2
- package/dist/lib/recordLinks.d.ts +17 -0
- package/dist/lib/recordLinks.d.ts.map +1 -0
- package/dist/lib/recordLinks.js +48 -0
- package/dist/lib/recordLinks.js.map +1 -0
- package/dist/lib/recordReferences.d.ts +41 -0
- package/dist/lib/recordReferences.d.ts.map +1 -0
- package/dist/lib/recordReferences.js +92 -0
- package/dist/lib/recordReferences.js.map +1 -0
- package/dist/modules/ai.d.ts +13 -0
- package/dist/modules/ai.d.ts.map +1 -0
- package/dist/modules/ai.js +22 -0
- package/dist/modules/ai.js.map +1 -0
- package/dist/modules/aiRunner.d.ts +3 -0
- package/dist/modules/aiRunner.d.ts.map +1 -0
- package/dist/modules/aiRunner.js +66 -0
- package/dist/modules/aiRunner.js.map +1 -0
- package/dist/pages/CompanyDetail.d.ts.map +1 -1
- package/dist/pages/CompanyDetail.js +2 -1
- package/dist/pages/CompanyDetail.js.map +1 -1
- package/dist/pages/DealDetail.d.ts.map +1 -1
- package/dist/pages/DealDetail.js +2 -1
- package/dist/pages/DealDetail.js.map +1 -1
- package/dist/pages/DealsPage.js +1 -1
- package/dist/pages/DealsPage.js.map +1 -1
- package/dist/pages/DecisionsPage.d.ts.map +1 -1
- package/dist/pages/DecisionsPage.js +5 -3
- package/dist/pages/DecisionsPage.js.map +1 -1
- package/dist/pages/EnquiryDetail.d.ts.map +1 -1
- package/dist/pages/EnquiryDetail.js +2 -1
- package/dist/pages/EnquiryDetail.js.map +1 -1
- package/dist/pages/EventDetail.d.ts.map +1 -1
- package/dist/pages/EventDetail.js +2 -1
- package/dist/pages/EventDetail.js.map +1 -1
- package/dist/pages/FundraisingPage.js +1 -1
- package/dist/pages/FundraisingPage.js.map +1 -1
- package/dist/pages/OpportunitiesPage.js +1 -1
- package/dist/pages/OpportunitiesPage.js.map +1 -1
- package/dist/pages/OpportunityDetail.d.ts.map +1 -1
- package/dist/pages/OpportunityDetail.js +2 -1
- package/dist/pages/OpportunityDetail.js.map +1 -1
- package/dist/pages/PartnershipDetail.d.ts.map +1 -1
- package/dist/pages/PartnershipDetail.js +2 -1
- package/dist/pages/PartnershipDetail.js.map +1 -1
- package/dist/pages/PartnershipsPage.js +1 -1
- package/dist/pages/PartnershipsPage.js.map +1 -1
- package/dist/pages/PersonDetail.d.ts.map +1 -1
- package/dist/pages/PersonDetail.js +4 -3
- package/dist/pages/PersonDetail.js.map +1 -1
- package/dist/pages/RaiseDetail.d.ts.map +1 -1
- package/dist/pages/RaiseDetail.js +2 -1
- package/dist/pages/RaiseDetail.js.map +1 -1
- package/dist/pages/SearchPage.d.ts.map +1 -1
- package/dist/pages/SearchPage.js +26 -14
- package/dist/pages/SearchPage.js.map +1 -1
- package/dist/pages/account/AccountLayout.d.ts.map +1 -1
- package/dist/pages/account/AccountLayout.js +2 -1
- package/dist/pages/account/AccountLayout.js.map +1 -1
- package/dist/pages/account/ConnectedAppsPage.d.ts +7 -0
- package/dist/pages/account/ConnectedAppsPage.d.ts.map +1 -0
- package/dist/pages/account/ConnectedAppsPage.js +32 -0
- package/dist/pages/account/ConnectedAppsPage.js.map +1 -0
- package/dist/pages/admin/AiPage.d.ts +2 -0
- package/dist/pages/admin/AiPage.d.ts.map +1 -0
- package/dist/pages/admin/AiPage.js +134 -0
- package/dist/pages/admin/AiPage.js.map +1 -0
- package/dist/pages/admin/McpPage.d.ts.map +1 -1
- package/dist/pages/admin/McpPage.js +7 -15
- package/dist/pages/admin/McpPage.js.map +1 -1
- package/dist/pages/admin/ModulesPage.d.ts.map +1 -1
- package/dist/pages/admin/ModulesPage.js +5 -4
- package/dist/pages/admin/ModulesPage.js.map +1 -1
- package/dist/pages/admin/WorkspaceSettingsPage.d.ts +5 -6
- package/dist/pages/admin/WorkspaceSettingsPage.d.ts.map +1 -1
- package/dist/pages/admin/WorkspaceSettingsPage.js +12 -17
- package/dist/pages/admin/WorkspaceSettingsPage.js.map +1 -1
- package/dist/pages/auth/AuthLayout.d.ts +1 -1
- package/dist/pages/auth/AuthLayout.d.ts.map +1 -1
- package/dist/pages/auth/AuthLayout.js +1 -1
- package/dist/pages/auth/AuthLayout.js.map +1 -1
- package/dist/pages/auth/SignUpPage.d.ts +1 -1
- package/dist/pages/auth/SignUpPage.js +1 -1
- package/dist/pages/dashboard/attention.d.ts +0 -5
- package/dist/pages/dashboard/attention.d.ts.map +1 -1
- package/dist/pages/dashboard/attention.js +1 -21
- package/dist/pages/dashboard/attention.js.map +1 -1
- package/dist/pages/dashboard/sections.d.ts.map +1 -1
- package/dist/pages/dashboard/sections.js +6 -3
- package/dist/pages/dashboard/sections.js.map +1 -1
- package/dist/pages/forms/SubmissionDetail.js +1 -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 +4 -3
- package/dist/pages/forms/SubmissionsTable.js.map +1 -1
- package/dist/pages/handbook/HandbookPage.d.ts.map +1 -1
- package/dist/pages/handbook/HandbookPage.js +2 -3
- package/dist/pages/handbook/HandbookPage.js.map +1 -1
- package/dist/pages/hiringDirectory.js +2 -2
- package/dist/pages/hiringDirectory.js.map +1 -1
- package/dist/pages/oauth/ConsentPage.d.ts +14 -0
- package/dist/pages/oauth/ConsentPage.d.ts.map +1 -0
- package/dist/pages/oauth/ConsentPage.js +87 -0
- package/dist/pages/oauth/ConsentPage.js.map +1 -0
- package/dist/pages/onboarding/WorkspaceStepPage.d.ts.map +1 -1
- package/dist/pages/onboarding/WorkspaceStepPage.js +9 -27
- package/dist/pages/onboarding/WorkspaceStepPage.js.map +1 -1
- package/dist/pages/onboarding/onboardingModules.d.ts +1 -1
- package/dist/pages/onboarding/onboardingRerun.d.ts +10 -1
- package/dist/pages/onboarding/onboardingRerun.d.ts.map +1 -1
- package/dist/pages/onboarding/onboardingRerun.js +12 -1
- package/dist/pages/onboarding/onboardingRerun.js.map +1 -1
- package/dist/pages/positionDirectory.js +2 -2
- package/dist/pages/positionDirectory.js.map +1 -1
- package/dist/registry/context.d.ts +3 -1
- package/dist/registry/context.d.ts.map +1 -1
- package/dist/registry/context.js +4 -0
- package/dist/registry/context.js.map +1 -1
- package/dist/registry/contributions.d.ts +39 -1
- package/dist/registry/contributions.d.ts.map +1 -1
- package/dist/registry/contributions.js +1 -1
- package/dist/registry/overridable.d.ts +1 -1
- package/dist/registry/registry.d.ts +8 -4
- package/dist/registry/registry.d.ts.map +1 -1
- package/dist/registry/registry.js +9 -1
- package/dist/registry/registry.js.map +1 -1
- package/package.json +2 -2
- package/src/api/client.ts +7 -6
- package/src/api/resource.ts +6 -7
- package/src/api/resources/ai.ts +110 -0
- package/src/api/resources/conversions.ts +1 -1
- package/src/api/resources/members.ts +2 -2
- package/src/api/resources/oauth.ts +112 -0
- package/src/api/resources/planItems.ts +1 -1
- package/src/api/resources/session.ts +4 -2
- package/src/api/resources/workspace.ts +4 -4
- package/src/app/KelpieApp.tsx +6 -0
- package/src/components/ActivitiesPanel.tsx +39 -10
- package/src/components/ActivityAction.tsx +33 -0
- package/src/components/AgentTasks.tsx +138 -10
- package/src/components/ApiKeysPanel.tsx +17 -0
- package/src/components/DecisionsPanel.tsx +9 -1
- package/src/components/LinkedText.tsx +51 -0
- package/src/components/MarkdownView.tsx +37 -7
- package/src/components/NotesPanel.tsx +18 -12
- package/src/components/Paginator.tsx +1 -1
- package/src/components/PlanPanel.tsx +9 -1
- package/src/components/RecordLinkTextarea.tsx +257 -0
- package/src/components/Shell.tsx +1 -1
- package/src/components/SummaryBlock.tsx +1 -1
- package/src/components/WorkspaceSwitcher.tsx +15 -1
- package/src/index.ts +10 -0
- package/src/lib/fragmentTarget.ts +96 -0
- package/src/lib/mcpConfig.ts +24 -0
- package/src/lib/money.ts +2 -2
- package/src/lib/recordLinks.ts +57 -0
- package/src/lib/recordReferences.ts +139 -0
- package/src/modules/ai.tsx +23 -0
- package/src/modules/aiRunner.ts +80 -0
- package/src/pages/CompanyDetail.tsx +2 -1
- package/src/pages/DealDetail.tsx +2 -1
- package/src/pages/DealsPage.tsx +1 -1
- package/src/pages/DecisionsPage.tsx +5 -3
- package/src/pages/EnquiryDetail.tsx +2 -1
- package/src/pages/EventDetail.tsx +2 -1
- package/src/pages/FormsPage.tsx +1 -1
- package/src/pages/FundraisingPage.tsx +1 -1
- package/src/pages/OpportunitiesPage.tsx +1 -1
- package/src/pages/OpportunityDetail.tsx +2 -1
- package/src/pages/PartnershipDetail.tsx +2 -1
- package/src/pages/PartnershipsPage.tsx +1 -1
- package/src/pages/PersonDetail.tsx +4 -3
- package/src/pages/RaiseDetail.tsx +2 -1
- package/src/pages/SearchPage.tsx +30 -15
- package/src/pages/account/AccountLayout.tsx +2 -1
- package/src/pages/account/ConnectedAppsPage.tsx +131 -0
- package/src/pages/admin/AiPage.tsx +353 -0
- package/src/pages/admin/McpPage.tsx +48 -27
- package/src/pages/admin/ModulesPage.tsx +5 -4
- package/src/pages/admin/WorkspaceSettingsPage.tsx +13 -28
- package/src/pages/auth/AuthLayout.tsx +1 -1
- package/src/pages/auth/SignUpPage.tsx +1 -1
- package/src/pages/dashboard/attention.ts +1 -24
- package/src/pages/dashboard/sections.tsx +9 -4
- package/src/pages/forms/SubmissionDetail.tsx +1 -1
- package/src/pages/forms/SubmissionsTable.tsx +4 -3
- package/src/pages/handbook/HandbookPage.tsx +5 -6
- package/src/pages/hiringDirectory.ts +2 -2
- package/src/pages/oauth/ConsentPage.tsx +219 -0
- package/src/pages/onboarding/InvitesStepPage.tsx +1 -1
- package/src/pages/onboarding/WorkspaceStepPage.tsx +19 -43
- package/src/pages/onboarding/onboardingModules.ts +1 -1
- package/src/pages/onboarding/onboardingRerun.ts +15 -1
- package/src/pages/positionDirectory.ts +2 -2
- package/src/registry/context.ts +6 -0
- package/src/registry/contributions.ts +31 -1
- package/src/registry/overridable.ts +1 -1
- package/src/registry/registry.ts +21 -3
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import type { Activity, ActivityKind, RecordTargetType } from '@kelpie/schemas'
|
|
2
|
+
import { Link } from 'react-router'
|
|
2
3
|
|
|
3
4
|
import { useTimezone } from '../api/resources/account.ts'
|
|
4
5
|
import { useActivities } from '../api/resources/activities.ts'
|
|
5
6
|
import { useMembers } from '../api/resources/members.ts'
|
|
6
7
|
import { formatRelativeTime, monthLabel } from '../lib/dates.ts'
|
|
8
|
+
import { targetHref } from '../lib/recordLinks.ts'
|
|
9
|
+
import { ActivityAction } from './ActivityAction.tsx'
|
|
10
|
+
import { LinkedText } from './LinkedText.tsx'
|
|
7
11
|
import { Paginator } from './Paginator.tsx'
|
|
8
12
|
import { ErrorPanel } from './QueryState.tsx'
|
|
9
13
|
import { SectionHeader } from './SectionHeader.tsx'
|
|
@@ -17,10 +21,13 @@ import { SectionHeader } from './SectionHeader.tsx'
|
|
|
17
21
|
* The roll-up is the server's: a person's timeline already carries the deals and
|
|
18
22
|
* partnerships they are on, so nothing here fetches related records to merge in.
|
|
19
23
|
*
|
|
20
|
-
* A rolled-up row says which kind of record it came from
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
+
* A rolled-up row says which kind of record it came from, names it, and links
|
|
25
|
+
* to it, as the mockup does. The name comes with the row (`targetName`), so the
|
|
26
|
+
* page fetches nothing more for it. A record the server could not name shows
|
|
27
|
+
* its type alone rather than an id.
|
|
28
|
+
*
|
|
29
|
+
* Record ids that the detail cites become links to those records too
|
|
30
|
+
* (`references`).
|
|
24
31
|
*/
|
|
25
32
|
|
|
26
33
|
export interface ActivitiesPanelProps {
|
|
@@ -224,7 +231,7 @@ function ActivityEvent({
|
|
|
224
231
|
<div className="flex items-baseline justify-between gap-3">
|
|
225
232
|
<p className="min-w-0 text-[12px] leading-snug text-ink">
|
|
226
233
|
<span className="font-semibold">{actorName}</span>{' '}
|
|
227
|
-
<
|
|
234
|
+
<ActivityAction action={activity.action} subject={activity.subject} />
|
|
228
235
|
</p>
|
|
229
236
|
<time
|
|
230
237
|
dateTime={activity.createdAt.toISOString()}
|
|
@@ -233,15 +240,37 @@ function ActivityEvent({
|
|
|
233
240
|
{formatRelativeTime(activity.createdAt, timezone)}
|
|
234
241
|
</time>
|
|
235
242
|
</div>
|
|
236
|
-
{isRolledUp &&
|
|
243
|
+
{isRolledUp && <RolledUpTarget activity={activity} />}
|
|
244
|
+
{activity.detail !== null && (
|
|
237
245
|
<p className="text-[11px] leading-snug text-ink-faint">
|
|
238
|
-
|
|
246
|
+
<LinkedText text={activity.detail} references={activity.references} />
|
|
239
247
|
</p>
|
|
240
248
|
)}
|
|
241
|
-
{activity.detail !== null && (
|
|
242
|
-
<p className="text-[11px] leading-snug text-ink-faint">{activity.detail}</p>
|
|
243
|
-
)}
|
|
244
249
|
</div>
|
|
245
250
|
</li>
|
|
246
251
|
)
|
|
247
252
|
}
|
|
253
|
+
|
|
254
|
+
/** `on Partnership · Sandbox`, with the name linked to the record when it has a page. */
|
|
255
|
+
function RolledUpTarget({ activity }: { readonly activity: Activity }): React.JSX.Element {
|
|
256
|
+
const href = targetHref(activity.targetType, activity.targetId)
|
|
257
|
+
const name = activity.targetName
|
|
258
|
+
|
|
259
|
+
return (
|
|
260
|
+
<p className="text-[11px] leading-snug text-ink-faint">
|
|
261
|
+
on <span className="text-ink-muted">{TARGET_TYPE_LABELS[activity.targetType]}</span>
|
|
262
|
+
{name !== null && (
|
|
263
|
+
<>
|
|
264
|
+
{' · '}
|
|
265
|
+
{href === undefined ? (
|
|
266
|
+
<span className="text-ink-muted">{name}</span>
|
|
267
|
+
) : (
|
|
268
|
+
<Link to={href} className="text-ink-muted hover:text-accent hover:underline">
|
|
269
|
+
{name}
|
|
270
|
+
</Link>
|
|
271
|
+
)}
|
|
272
|
+
</>
|
|
273
|
+
)}
|
|
274
|
+
</p>
|
|
275
|
+
)
|
|
276
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { RecordReference } from '@kelpie/schemas'
|
|
2
|
+
import { Link } from 'react-router'
|
|
3
|
+
|
|
4
|
+
import { referenceHref } from '../lib/recordLinks.ts'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* An activity's action — `added a note`, `linked to company`, `converted to
|
|
8
|
+
* Deal` — linked to the record the row is about, when it has one.
|
|
9
|
+
*
|
|
10
|
+
* The subject is the note that was added, the record linked to, the form
|
|
11
|
+
* something came in through. The server names it with its current name, which
|
|
12
|
+
* the tooltip shows; a subject that is gone arrives as null and the action stays
|
|
13
|
+
* plain text. A Note, Decision or Plan item opens on the record it is on.
|
|
14
|
+
*/
|
|
15
|
+
export function ActivityAction({
|
|
16
|
+
action,
|
|
17
|
+
subject,
|
|
18
|
+
}: {
|
|
19
|
+
readonly action: string
|
|
20
|
+
readonly subject: RecordReference | null
|
|
21
|
+
}): React.JSX.Element {
|
|
22
|
+
const href = subject === null ? undefined : referenceHref(subject)
|
|
23
|
+
|
|
24
|
+
if (subject === null || href === undefined) {
|
|
25
|
+
return <span className="text-ink-muted">{action}</span>
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<Link to={href} title={subject.name} className="text-ink-muted hover:text-accent hover:underline">
|
|
30
|
+
{action}
|
|
31
|
+
</Link>
|
|
32
|
+
)
|
|
33
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { useQueryClient } from '@tanstack/react-query'
|
|
1
2
|
import { useEffect, useId, useRef, useState } from 'react'
|
|
2
3
|
import type { AgentRun, AgentTaskDefinition, AgentTaskTargetType, ResolvedAgentTask } from '@kelpie/schemas'
|
|
3
4
|
|
|
@@ -8,6 +9,8 @@ import {
|
|
|
8
9
|
useResolveAgentTask,
|
|
9
10
|
useRunAgentTask,
|
|
10
11
|
} from '../api/resources/agentTasks.ts'
|
|
12
|
+
import { useAgentRunner } from '../registry/context.ts'
|
|
13
|
+
import type { AgentRunner, AgentRunnerProgress } from '../registry/contributions.ts'
|
|
11
14
|
import { ErrorPanel, LoadingPanel } from './QueryState.tsx'
|
|
12
15
|
|
|
13
16
|
/**
|
|
@@ -15,6 +18,11 @@ import { ErrorPanel, LoadingPanel } from './QueryState.tsx'
|
|
|
15
18
|
* prompt, Preview, and Run. Ported from the mockup with the in-memory resolve
|
|
16
19
|
* swapped for `POST …/resolve` and the pretend status ladder swapped for the
|
|
17
20
|
* run record the server settles, polled until it does.
|
|
21
|
+
*
|
|
22
|
+
* Run dispatches straight to the assembly's agent runner (Kelpie AI, from the
|
|
23
|
+
* optional `ai` module) with no dialog, and reports progress on the task's
|
|
24
|
+
* row. With no runner, or one that cannot run now, Run is disabled and says
|
|
25
|
+
* why. Preview's Run… still dispatches to any registered agent.
|
|
18
26
|
*/
|
|
19
27
|
export interface AgentTasksProps {
|
|
20
28
|
readonly targetType: AgentTaskTargetType
|
|
@@ -28,6 +36,55 @@ type PanelMode = 'preview' | 'run' | null
|
|
|
28
36
|
|
|
29
37
|
const COPIED_MS = 1800
|
|
30
38
|
|
|
39
|
+
/** What the menu uses when no module registered a runner: Run stays disabled. */
|
|
40
|
+
const NO_RUNNER: AgentRunner = {
|
|
41
|
+
id: 'none',
|
|
42
|
+
useAvailability: () => ({
|
|
43
|
+
status: 'unavailable',
|
|
44
|
+
reason: 'Running needs Kelpie AI, which this deployment does not include. Use Preview to dispatch to a registered agent.',
|
|
45
|
+
}),
|
|
46
|
+
useProgress: () => undefined,
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** The one Run the menu started, and the core agent run it created once the POST returns. */
|
|
50
|
+
interface DirectRun {
|
|
51
|
+
readonly taskId: string
|
|
52
|
+
readonly runId: string | null
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
type DirectRunStatus =
|
|
56
|
+
| { readonly tone: 'busy'; readonly text: string }
|
|
57
|
+
| { readonly tone: 'done'; readonly text: string }
|
|
58
|
+
| { readonly tone: 'failed'; readonly text: string }
|
|
59
|
+
|
|
60
|
+
function directRunStatus(
|
|
61
|
+
dispatchError: Error | null,
|
|
62
|
+
run: AgentRun | undefined,
|
|
63
|
+
progress: AgentRunnerProgress | undefined,
|
|
64
|
+
): DirectRunStatus {
|
|
65
|
+
if (dispatchError !== null) {
|
|
66
|
+
return { tone: 'failed', text: `Failed: ${dispatchError.message}` }
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (run === undefined || run.status === 'queued' || run.status === 'running') {
|
|
70
|
+
return { tone: 'busy', text: 'Running…' }
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (run.status === 'failed') {
|
|
74
|
+
return { tone: 'failed', text: `Failed: ${run.failureReason ?? 'no reason recorded'}` }
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
switch (progress?.status) {
|
|
78
|
+
case 'succeeded':
|
|
79
|
+
return { tone: 'done', text: 'Done.' }
|
|
80
|
+
case 'failed':
|
|
81
|
+
return { tone: 'failed', text: `Failed: ${progress.reason}` }
|
|
82
|
+
case 'running':
|
|
83
|
+
case undefined:
|
|
84
|
+
return { tone: 'busy', text: 'Running…' }
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
31
88
|
export function AgentTasks({
|
|
32
89
|
targetType,
|
|
33
90
|
targetId,
|
|
@@ -44,13 +101,26 @@ export function AgentTasks({
|
|
|
44
101
|
const [copiedId, setCopiedId] = useState<string | null>(null)
|
|
45
102
|
const [agentId, setAgentId] = useState('')
|
|
46
103
|
const [runId, setRunId] = useState<string | null>(null)
|
|
104
|
+
const [directRun, setDirectRun] = useState<DirectRun | null>(null)
|
|
47
105
|
const rootRef = useRef<HTMLDivElement>(null)
|
|
106
|
+
const refreshedRunId = useRef<string | null>(null)
|
|
48
107
|
const menuId = useId()
|
|
108
|
+
const queryClient = useQueryClient()
|
|
109
|
+
const runner = useAgentRunner() ?? NO_RUNNER
|
|
110
|
+
const directDispatch = useRunAgentTask()
|
|
49
111
|
|
|
50
112
|
// Fetched only once the run pane opens: the trigger sits on every detail
|
|
51
113
|
// page, and most visits never dispatch anything.
|
|
52
114
|
const agents = useAgents({ enabled: panel === 'run' })
|
|
53
115
|
const { record: run } = useAgentRun(runId ?? undefined)
|
|
116
|
+
// Checked only once the menu has opened, for the same reason as `agents`.
|
|
117
|
+
const availability = runner.useAvailability({ enabled: menuOpen || directRun !== null })
|
|
118
|
+
const { record: directAgentRun } = useAgentRun(directRun?.runId ?? undefined)
|
|
119
|
+
const progress = runner.useProgress(
|
|
120
|
+
directAgentRun?.status === 'succeeded' ? directAgentRun.id : undefined,
|
|
121
|
+
)
|
|
122
|
+
const directStatus =
|
|
123
|
+
directRun === null ? null : directRunStatus(directDispatch.error, directAgentRun, progress)
|
|
54
124
|
|
|
55
125
|
useEffect(() => {
|
|
56
126
|
if (!menuOpen) {
|
|
@@ -83,9 +153,21 @@ export function AgentTasks({
|
|
|
83
153
|
setActiveTaskId(null)
|
|
84
154
|
setResolved(null)
|
|
85
155
|
setRunId(null)
|
|
156
|
+
setDirectRun(null)
|
|
86
157
|
setMenuOpen(false)
|
|
87
158
|
}, [targetType, targetId])
|
|
88
159
|
|
|
160
|
+
// The agent wrote to this record, or to records around it. Refetch what is on
|
|
161
|
+
// screen, once per run.
|
|
162
|
+
useEffect(() => {
|
|
163
|
+
const id = directAgentRun?.id
|
|
164
|
+
|
|
165
|
+
if (progress?.status === 'succeeded' && id !== undefined && refreshedRunId.current !== id) {
|
|
166
|
+
refreshedRunId.current = id
|
|
167
|
+
void queryClient.invalidateQueries()
|
|
168
|
+
}
|
|
169
|
+
}, [progress?.status, directAgentRun?.id, queryClient])
|
|
170
|
+
|
|
89
171
|
useEffect(() => {
|
|
90
172
|
if (agentId === '' && agents.records.length > 0) {
|
|
91
173
|
setAgentId(agents.records[0]?.id ?? '')
|
|
@@ -131,6 +213,22 @@ export function AgentTasks({
|
|
|
131
213
|
}
|
|
132
214
|
}
|
|
133
215
|
|
|
216
|
+
function runDirectly(taskId: string): void {
|
|
217
|
+
if (availability.status !== 'ready') {
|
|
218
|
+
return
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
setDirectRun({ taskId, runId: null })
|
|
222
|
+
directDispatch
|
|
223
|
+
.runAsync({ taskId, targetType, targetId, agentId: availability.agentId })
|
|
224
|
+
.then((created) => {
|
|
225
|
+
setDirectRun({ taskId, runId: created.id })
|
|
226
|
+
})
|
|
227
|
+
.catch(() => {
|
|
228
|
+
// The task's row renders `directDispatch.error`.
|
|
229
|
+
})
|
|
230
|
+
}
|
|
231
|
+
|
|
134
232
|
function startRun(): void {
|
|
135
233
|
if (activeTaskId === null || agentId === '') {
|
|
136
234
|
return
|
|
@@ -149,6 +247,19 @@ export function AgentTasks({
|
|
|
149
247
|
const activeTask = catalog.records.find((task) => task.id === activeTaskId)
|
|
150
248
|
const settled = run?.status === 'succeeded' || run?.status === 'failed'
|
|
151
249
|
const dispatching = dispatch.isPending || (run !== undefined && !settled)
|
|
250
|
+
const runControl: RunControl = {
|
|
251
|
+
disabledReason:
|
|
252
|
+
availability.status === 'ready'
|
|
253
|
+
? directStatus?.tone === 'busy'
|
|
254
|
+
? 'A task is running.'
|
|
255
|
+
: null
|
|
256
|
+
: availability.status === 'loading'
|
|
257
|
+
? 'Checking Kelpie AI…'
|
|
258
|
+
: availability.reason,
|
|
259
|
+
activeTaskId: directRun?.taskId ?? null,
|
|
260
|
+
status: directStatus,
|
|
261
|
+
onRun: runDirectly,
|
|
262
|
+
}
|
|
152
263
|
|
|
153
264
|
return (
|
|
154
265
|
<div className="relative shrink-0" ref={rootRef}>
|
|
@@ -189,9 +300,7 @@ export function AgentTasks({
|
|
|
189
300
|
onPreview={(id) => {
|
|
190
301
|
openResolved(id, 'preview')
|
|
191
302
|
}}
|
|
192
|
-
|
|
193
|
-
openResolved(id, 'run')
|
|
194
|
-
}}
|
|
303
|
+
run={runControl}
|
|
195
304
|
/>
|
|
196
305
|
)}
|
|
197
306
|
{overflow.length > 0 && (
|
|
@@ -204,9 +313,7 @@ export function AgentTasks({
|
|
|
204
313
|
onPreview={(id) => {
|
|
205
314
|
openResolved(id, 'preview')
|
|
206
315
|
}}
|
|
207
|
-
|
|
208
|
-
openResolved(id, 'run')
|
|
209
|
-
}}
|
|
316
|
+
run={runControl}
|
|
210
317
|
/>
|
|
211
318
|
)}
|
|
212
319
|
</div>
|
|
@@ -388,6 +495,20 @@ function RunControls({
|
|
|
388
495
|
)
|
|
389
496
|
}
|
|
390
497
|
|
|
498
|
+
interface RunControl {
|
|
499
|
+
/** Why Run is disabled, shown as its tooltip. Null when it is enabled. */
|
|
500
|
+
readonly disabledReason: string | null
|
|
501
|
+
readonly activeTaskId: string | null
|
|
502
|
+
readonly status: DirectRunStatus | null
|
|
503
|
+
readonly onRun: (id: string) => void
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
const STATUS_TONE_CLASS: Readonly<Record<DirectRunStatus['tone'], string>> = {
|
|
507
|
+
busy: 'text-ink-muted',
|
|
508
|
+
done: 'text-ink-muted',
|
|
509
|
+
failed: 'text-danger',
|
|
510
|
+
}
|
|
511
|
+
|
|
391
512
|
function TaskGroup({
|
|
392
513
|
label,
|
|
393
514
|
tasks,
|
|
@@ -395,7 +516,7 @@ function TaskGroup({
|
|
|
395
516
|
bordered = false,
|
|
396
517
|
onCopy,
|
|
397
518
|
onPreview,
|
|
398
|
-
|
|
519
|
+
run,
|
|
399
520
|
}: {
|
|
400
521
|
readonly label: string
|
|
401
522
|
readonly tasks: readonly AgentTaskDefinition[]
|
|
@@ -403,7 +524,7 @@ function TaskGroup({
|
|
|
403
524
|
readonly bordered?: boolean
|
|
404
525
|
readonly onCopy: (id: string) => void
|
|
405
526
|
readonly onPreview: (id: string) => void
|
|
406
|
-
readonly
|
|
527
|
+
readonly run: RunControl
|
|
407
528
|
}): React.JSX.Element {
|
|
408
529
|
return (
|
|
409
530
|
<div className={bordered ? 'border-t border-border pt-1' : undefined}>
|
|
@@ -436,14 +557,21 @@ function TaskGroup({
|
|
|
436
557
|
</button>
|
|
437
558
|
<button
|
|
438
559
|
type="button"
|
|
439
|
-
className="rounded border border-border px-1.5 py-0.5 text-[11px] font-medium text-ink-muted transition hover:border-accent hover:text-accent"
|
|
560
|
+
className="rounded border border-border px-1.5 py-0.5 text-[11px] font-medium text-ink-muted transition hover:border-accent hover:text-accent disabled:cursor-not-allowed disabled:opacity-50 disabled:hover:border-border disabled:hover:text-ink-muted"
|
|
561
|
+
disabled={run.disabledReason !== null}
|
|
562
|
+
title={run.disabledReason ?? undefined}
|
|
440
563
|
onClick={() => {
|
|
441
|
-
onRun(task.id)
|
|
564
|
+
run.onRun(task.id)
|
|
442
565
|
}}
|
|
443
566
|
>
|
|
444
567
|
Run
|
|
445
568
|
</button>
|
|
446
569
|
</div>
|
|
570
|
+
{run.activeTaskId === task.id && run.status !== null && (
|
|
571
|
+
<p role="status" className={`mt-1.5 text-[11px] leading-snug ${STATUS_TONE_CLASS[run.status.tone]}`}>
|
|
572
|
+
{run.status.text}
|
|
573
|
+
</p>
|
|
574
|
+
)}
|
|
447
575
|
</li>
|
|
448
576
|
))}
|
|
449
577
|
</ul>
|
|
@@ -13,6 +13,7 @@ import type { FormEvent } from 'react'
|
|
|
13
13
|
import { useTimezone } from '../api/resources/account.ts'
|
|
14
14
|
import { useApiKeys, useCreateApiKey, useRevokeApiKey } from '../api/resources/apiKeys.ts'
|
|
15
15
|
import { formatDate } from '../lib/dates.ts'
|
|
16
|
+
import { mcpClientConfig, mcpEndpoint } from '../lib/mcpConfig.ts'
|
|
16
17
|
import { CopyButton } from './CopyButton.tsx'
|
|
17
18
|
import { ErrorPanel, LoadingPanel } from './QueryState.tsx'
|
|
18
19
|
|
|
@@ -346,6 +347,9 @@ function SecretOnce({
|
|
|
346
347
|
readonly apiKey: CreatedApiKey
|
|
347
348
|
readonly onDismiss: () => void
|
|
348
349
|
}): React.JSX.Element {
|
|
350
|
+
const endpoint = mcpEndpoint()
|
|
351
|
+
const config = mcpClientConfig(endpoint, apiKey.secret)
|
|
352
|
+
|
|
349
353
|
return (
|
|
350
354
|
<div className="rounded-md border border-accent/40 bg-accent-soft px-4 py-3">
|
|
351
355
|
<div className="flex items-start justify-between gap-3">
|
|
@@ -357,6 +361,19 @@ function SecretOnce({
|
|
|
357
361
|
</div>
|
|
358
362
|
<CopyButton value={apiKey.secret} label="Copy the API key" />
|
|
359
363
|
</div>
|
|
364
|
+
<div className="mt-4 flex items-start justify-between gap-3">
|
|
365
|
+
<div className="min-w-0 flex-1">
|
|
366
|
+
<p className="text-[13px] font-medium text-ink">MCP client config</p>
|
|
367
|
+
<p className="mt-0.5 text-[12px] text-ink-muted">
|
|
368
|
+
Paste into Claude, Cursor, or any MCP client. It connects to{' '}
|
|
369
|
+
<code className="font-mono text-[12px] break-all">{endpoint}</code> with this key.
|
|
370
|
+
</p>
|
|
371
|
+
<pre className="bg-code-bg text-code-fg mt-2 overflow-x-auto rounded border border-border p-3 font-mono text-[12px] leading-relaxed">
|
|
372
|
+
{config}
|
|
373
|
+
</pre>
|
|
374
|
+
</div>
|
|
375
|
+
<CopyButton value={config} label="Copy the MCP client config" />
|
|
376
|
+
</div>
|
|
360
377
|
<button
|
|
361
378
|
type="button"
|
|
362
379
|
onClick={onDismiss}
|
|
@@ -7,6 +7,7 @@ import { useTimezone } from '../api/resources/account.ts'
|
|
|
7
7
|
import { useCreateDecision, useDecisions, useDeleteDecision } from '../api/resources/decisions.ts'
|
|
8
8
|
import { useMembers } from '../api/resources/members.ts'
|
|
9
9
|
import { formatDate } from '../lib/dates.ts'
|
|
10
|
+
import { FRAGMENT_HIGHLIGHT, useFragmentTarget } from '../lib/fragmentTarget.ts'
|
|
10
11
|
import { Paginator } from './Paginator.tsx'
|
|
11
12
|
import { ErrorPanel } from './QueryState.tsx'
|
|
12
13
|
import { SectionHeader } from './SectionHeader.tsx'
|
|
@@ -202,9 +203,16 @@ function DecisionItem({
|
|
|
202
203
|
readonly onRemove: () => void
|
|
203
204
|
}): React.JSX.Element {
|
|
204
205
|
const timezone = useTimezone()
|
|
206
|
+
const target = useFragmentTarget<HTMLLIElement>(decision.id)
|
|
205
207
|
|
|
206
208
|
return (
|
|
207
|
-
<li
|
|
209
|
+
<li
|
|
210
|
+
id={decision.id}
|
|
211
|
+
ref={target.ref}
|
|
212
|
+
className={`border-b border-border px-4 py-3 transition-colors last:border-0 ${
|
|
213
|
+
target.highlighted ? FRAGMENT_HIGHLIGHT : ''
|
|
214
|
+
}`}
|
|
215
|
+
>
|
|
208
216
|
<div className="flex items-start justify-between gap-2">
|
|
209
217
|
<p className="min-w-0 flex-1 text-[13px] font-medium text-ink">{decision.body}</p>
|
|
210
218
|
<button
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { RecordReference } from '@kelpie/schemas'
|
|
2
|
+
import { Link } from 'react-router'
|
|
3
|
+
|
|
4
|
+
import { referenceHref } from '../lib/recordLinks.ts'
|
|
5
|
+
import { splitOnReferences, unresolvedLabel } from '../lib/recordReferences.ts'
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Plain text with each cited record id shown as the record's name, linked to
|
|
9
|
+
* its page. A record with no page of its own shows its name without a link.
|
|
10
|
+
* The id stays in the tooltip, so nothing the author wrote is lost. A
|
|
11
|
+
* `[[type:id|Label]]` token for a record that is gone shows its label.
|
|
12
|
+
*/
|
|
13
|
+
export function LinkedText({
|
|
14
|
+
text,
|
|
15
|
+
references,
|
|
16
|
+
}: {
|
|
17
|
+
readonly text: string
|
|
18
|
+
readonly references: readonly RecordReference[]
|
|
19
|
+
}): React.JSX.Element {
|
|
20
|
+
return (
|
|
21
|
+
<>
|
|
22
|
+
{splitOnReferences(text, references).map((segment, index) => {
|
|
23
|
+
if (segment.kind === 'text') {
|
|
24
|
+
return segment.text
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if (segment.kind === 'unresolved') {
|
|
28
|
+
return (
|
|
29
|
+
<span key={`${String(index)}-${segment.token.targetId}`} title={segment.token.targetId}>
|
|
30
|
+
{unresolvedLabel(segment.token)}
|
|
31
|
+
</span>
|
|
32
|
+
)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const { reference } = segment
|
|
36
|
+
const href = referenceHref(reference)
|
|
37
|
+
const key = `${String(index)}-${reference.targetId}`
|
|
38
|
+
|
|
39
|
+
return href === undefined ? (
|
|
40
|
+
<span key={key} title={reference.targetId} className="text-ink-muted">
|
|
41
|
+
{reference.name}
|
|
42
|
+
</span>
|
|
43
|
+
) : (
|
|
44
|
+
<Link key={key} to={href} title={reference.targetId} className="text-accent hover:underline">
|
|
45
|
+
{reference.name}
|
|
46
|
+
</Link>
|
|
47
|
+
)
|
|
48
|
+
})}
|
|
49
|
+
</>
|
|
50
|
+
)
|
|
51
|
+
}
|
|
@@ -1,7 +1,12 @@
|
|
|
1
|
+
import type { RecordReference } from '@kelpie/schemas'
|
|
2
|
+
import { useMemo } from 'react'
|
|
1
3
|
import Markdown from 'react-markdown'
|
|
2
4
|
import type { Components } from 'react-markdown'
|
|
5
|
+
import { Link } from 'react-router'
|
|
3
6
|
import remarkGfm from 'remark-gfm'
|
|
4
7
|
|
|
8
|
+
import { remarkRecordReferences } from '../lib/recordReferences.ts'
|
|
9
|
+
|
|
5
10
|
/**
|
|
6
11
|
* Handbook markdown, rendered by a library rather than by hand (roadmap
|
|
7
12
|
* decision 5).
|
|
@@ -20,8 +25,16 @@ import remarkGfm from 'remark-gfm'
|
|
|
20
25
|
*
|
|
21
26
|
* The class names are the mockup's, element for element, so a page reads the
|
|
22
27
|
* same as it did before the swap.
|
|
28
|
+
*
|
|
29
|
+
* `references` are the records the source cites by id, as the server named
|
|
30
|
+
* them. Each cited id renders as a link to the record, labelled with its name.
|
|
23
31
|
*/
|
|
24
32
|
|
|
33
|
+
/** An app path such as `/partnerships/prt_…`. `//host` is another site, so it does not count. */
|
|
34
|
+
function isAppPath(href: string | undefined): href is string {
|
|
35
|
+
return href !== undefined && href.startsWith('/') && !href.startsWith('//')
|
|
36
|
+
}
|
|
37
|
+
|
|
25
38
|
const components: Components = {
|
|
26
39
|
h1: ({ children }) => (
|
|
27
40
|
<h1 className="text-[22px] font-semibold tracking-tight text-ink">{children}</h1>
|
|
@@ -41,11 +54,18 @@ const components: Components = {
|
|
|
41
54
|
blockquote: ({ children }) => (
|
|
42
55
|
<blockquote className="border-l-2 border-border pl-3 text-ink-muted">{children}</blockquote>
|
|
43
56
|
),
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
57
|
+
// A path inside the app stays in this tab and in the router; anything else
|
|
58
|
+
// opens beside it.
|
|
59
|
+
a: ({ href, children }) =>
|
|
60
|
+
isAppPath(href) ? (
|
|
61
|
+
<Link to={href} className="text-accent hover:underline">
|
|
62
|
+
{children}
|
|
63
|
+
</Link>
|
|
64
|
+
) : (
|
|
65
|
+
<a href={href} className="text-accent hover:underline" target="_blank" rel="noreferrer">
|
|
66
|
+
{children}
|
|
67
|
+
</a>
|
|
68
|
+
),
|
|
49
69
|
hr: () => <hr className="border-border" />,
|
|
50
70
|
// The wrapper scrolls rather than the page, so a wide table cannot push the
|
|
51
71
|
// sidebar off screen.
|
|
@@ -62,10 +82,20 @@ const components: Components = {
|
|
|
62
82
|
td: ({ children }) => <td className="px-3 py-2">{children}</td>,
|
|
63
83
|
}
|
|
64
84
|
|
|
65
|
-
|
|
85
|
+
const NO_REFERENCES: readonly RecordReference[] = []
|
|
86
|
+
|
|
87
|
+
export function MarkdownView({
|
|
88
|
+
source,
|
|
89
|
+
references = NO_REFERENCES,
|
|
90
|
+
}: {
|
|
91
|
+
readonly source: string
|
|
92
|
+
readonly references?: readonly RecordReference[]
|
|
93
|
+
}): React.JSX.Element {
|
|
94
|
+
const plugins = useMemo(() => [remarkGfm, remarkRecordReferences(references)], [references])
|
|
95
|
+
|
|
66
96
|
return (
|
|
67
97
|
<div className="markdown space-y-3 text-[13px] leading-relaxed text-ink">
|
|
68
|
-
<Markdown remarkPlugins={
|
|
98
|
+
<Markdown remarkPlugins={plugins} components={components}>
|
|
69
99
|
{source}
|
|
70
100
|
</Markdown>
|
|
71
101
|
</div>
|
|
@@ -6,15 +6,18 @@ import { useTimezone } from '../api/resources/account.ts'
|
|
|
6
6
|
import { useMembers } from '../api/resources/members.ts'
|
|
7
7
|
import { useCreateNote, useDeleteNote, useNotes, useUpdateNote } from '../api/resources/notes.ts'
|
|
8
8
|
import { formatDateTime } from '../lib/dates.ts'
|
|
9
|
+
import { FRAGMENT_HIGHLIGHT, useFragmentTarget } from '../lib/fragmentTarget.ts'
|
|
9
10
|
import { MarkdownView } from './MarkdownView.tsx'
|
|
10
11
|
import { Paginator } from './Paginator.tsx'
|
|
12
|
+
import { RecordLinkTextarea } from './RecordLinkTextarea.tsx'
|
|
11
13
|
import { ErrorPanel } from './QueryState.tsx'
|
|
12
14
|
import { SectionHeader } from './SectionHeader.tsx'
|
|
13
15
|
|
|
14
16
|
/**
|
|
15
17
|
* The notes on one record.
|
|
16
18
|
*
|
|
17
|
-
* Bodies are markdown, rendered with the same component as the handbook.
|
|
19
|
+
* Bodies are markdown, rendered with the same component as the handbook. Typing
|
|
20
|
+
* `[[` in the editor links a record; see `RecordLinkTextarea`.
|
|
18
21
|
* Notes can be created, edited, and deleted here. There is no pin control: the
|
|
19
22
|
* mockup renders the badge on a note that carries the flag and offers no way to
|
|
20
23
|
* set it. `PATCH /v1/notes/:id` takes `pinned`, so an agent can still pin.
|
|
@@ -76,12 +79,10 @@ export function NotesPanel({ targetType, targetId }: NotesPanelProps): React.JSX
|
|
|
76
79
|
|
|
77
80
|
{adding && (
|
|
78
81
|
<form onSubmit={submit} className="mb-3 space-y-2">
|
|
79
|
-
<
|
|
82
|
+
<RecordLinkTextarea
|
|
80
83
|
value={body}
|
|
81
|
-
onChange={
|
|
82
|
-
|
|
83
|
-
}}
|
|
84
|
-
placeholder="Write a note… (Markdown supported)"
|
|
84
|
+
onChange={setBody}
|
|
85
|
+
placeholder="Write a note… (Markdown supported, [[ to link a record)"
|
|
85
86
|
rows={3}
|
|
86
87
|
autoFocus
|
|
87
88
|
className="w-full resize-y rounded-md border border-border bg-surface-raised px-3 py-2 text-[13px] outline-none focus:border-accent focus:ring-2 focus:ring-accent/20"
|
|
@@ -147,6 +148,7 @@ function NoteItem({
|
|
|
147
148
|
const [editing, setEditing] = useState(false)
|
|
148
149
|
const [confirmingDelete, setConfirmingDelete] = useState(false)
|
|
149
150
|
const [draft, setDraft] = useState(note.body)
|
|
151
|
+
const target = useFragmentTarget<HTMLLIElement>(note.id)
|
|
150
152
|
|
|
151
153
|
function cancelEdit(): void {
|
|
152
154
|
setDraft(note.body)
|
|
@@ -173,11 +175,9 @@ function NoteItem({
|
|
|
173
175
|
return (
|
|
174
176
|
<li className="rounded-md border border-border bg-surface-raised px-3.5 py-3">
|
|
175
177
|
<form onSubmit={submitEdit} className="space-y-2">
|
|
176
|
-
<
|
|
178
|
+
<RecordLinkTextarea
|
|
177
179
|
value={draft}
|
|
178
|
-
onChange={
|
|
179
|
-
setDraft(event.target.value)
|
|
180
|
-
}}
|
|
180
|
+
onChange={setDraft}
|
|
181
181
|
rows={3}
|
|
182
182
|
autoFocus
|
|
183
183
|
className="w-full resize-y rounded-md border border-border bg-surface-raised px-3 py-2 text-[13px] outline-none focus:border-accent focus:ring-2 focus:ring-accent/20"
|
|
@@ -208,10 +208,16 @@ function NoteItem({
|
|
|
208
208
|
}
|
|
209
209
|
|
|
210
210
|
return (
|
|
211
|
-
<li
|
|
211
|
+
<li
|
|
212
|
+
id={note.id}
|
|
213
|
+
ref={target.ref}
|
|
214
|
+
className={`group rounded-md border border-border bg-surface-raised px-3.5 py-3 transition-colors ${
|
|
215
|
+
target.highlighted ? FRAGMENT_HIGHLIGHT : ''
|
|
216
|
+
}`}
|
|
217
|
+
>
|
|
212
218
|
<div className="flex items-start justify-between gap-2">
|
|
213
219
|
<div className="min-w-0 flex-1">
|
|
214
|
-
<MarkdownView source={note.body} />
|
|
220
|
+
<MarkdownView source={note.body} references={note.references} />
|
|
215
221
|
</div>
|
|
216
222
|
<div className="flex shrink-0 flex-col items-end gap-1">
|
|
217
223
|
{note.pinned && (
|
|
@@ -3,7 +3,7 @@ import type { Paged } from '../api/resource.ts'
|
|
|
3
3
|
/**
|
|
4
4
|
* Prev / Next with a page indicator and an optional page size selector.
|
|
5
5
|
*
|
|
6
|
-
* The API is cursor-only
|
|
6
|
+
* The API is cursor-only, so there is no total count and no jump
|
|
7
7
|
* to page N. `pageIndex` is one-based on screen but zero-based in `Paged` —
|
|
8
8
|
* the label adds one so page 1 does not read as page 0.
|
|
9
9
|
*
|