@sixb/app 0.1.14 → 0.1.15
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/{chunk-vtp6nk44.js → chunk-736c9akn.js} +1 -1
- package/dist/{chunk-1rhht9y0.js → chunk-n0cxwvej.js} +1 -1
- package/dist/{chunk-0yb22w6m.js → chunk-qh1panvd.js} +1 -1
- package/dist/{chunk-aes17xmx.js → chunk-twjs2sb9.js} +3928 -3717
- package/dist/{chunk-aes17xmx.js.map → chunk-twjs2sb9.js.map} +46 -42
- package/dist/index.js +15 -6
- package/dist/index.js.map +6 -6
- package/dist/pages.js +60 -44
- package/dist/pages.js.map +8 -8
- package/dist/server.js +12 -6
- package/dist/server.js.map +3 -3
- package/package.json +3 -3
- package/src/agent/agent-chat.tsx +4 -22
- package/src/agent/agent-panel.tsx +4 -0
- package/src/agent/agent-surface.tsx +4 -0
- package/src/agent/agent.css +33 -3
- package/src/agent/approvals.ts +4 -5
- package/src/agent/artifact-panel.tsx +113 -37
- package/src/agent/components/activity-status.tsx +1 -1
- package/src/agent/components/agent-threads.tsx +377 -0
- package/src/agent/components/approval-card.tsx +336 -327
- package/src/agent/components/approval-mode-chip.tsx +38 -145
- package/src/agent/components/auto-model-chip.tsx +103 -167
- package/src/agent/components/composer-menu.tsx +185 -0
- package/src/agent/components/composer.tsx +38 -43
- package/src/agent/components/context-chips.tsx +1 -1
- package/src/agent/components/conversation-panel.tsx +16 -36
- package/src/agent/components/file-attachment-card.tsx +5 -2
- package/src/agent/components/message-parts.tsx +27 -11
- package/src/agent/components/message-view.tsx +182 -68
- package/src/agent/components/model-controls.tsx +133 -125
- package/src/agent/components/model-picker-row.tsx +38 -17
- package/src/agent/components/participant-input.tsx +159 -31
- package/src/agent/components/reasoning-effort-slider.tsx +27 -27
- package/src/agent/components/shared-thread-notice.tsx +1 -1
- package/src/agent/components/thread-people.tsx +45 -15
- package/src/agent/components/threads-button.tsx +70 -0
- package/src/agent/components/transcript.tsx +30 -1
- package/src/agent/conversation.ts +25 -1
- package/src/agent/delegation/child-card.tsx +187 -247
- package/src/agent/delegation/child-cards.tsx +4 -7
- package/src/agent/delegation/child-group.tsx +179 -98
- package/src/agent/delegation/child-parts.tsx +71 -106
- package/src/agent/delegation/child-work.tsx +6 -52
- package/src/agent/delegation/interpret.ts +0 -28
- package/src/agent/delegation/model.ts +115 -39
- package/src/agent/hooks/use-agent-conversation.ts +7 -92
- package/src/agent/hooks/use-people-suggestions.ts +90 -0
- package/src/agent/hooks/use-thread-lists.ts +77 -0
- package/src/agent/i18n/en.ts +96 -83
- package/src/agent/i18n/fr.ts +105 -100
- package/src/agent/react-router.tsx +48 -5
- package/src/agent/run-presentation.ts +6 -2
- package/src/agent/thread-navigation.ts +16 -0
- package/src/agent/thread-pages.ts +24 -0
- package/src/artifacts/person-avatar.tsx +1 -1
- package/src/createCustomApp.ts +13 -6
- package/src/index.ts +7 -3
- package/src/pages/home.tsx +3 -1
- package/src/pages/observability/ai-usage/calls.tsx +2 -1
- package/src/pages/settings/memory-history.tsx +2 -1
- package/src/pages/settings/messages.ts +2 -3
- package/src/pages/values.tsx +23 -1
- package/src/pages.ts +5 -1
- package/src/shell/agent-dock.tsx +4 -2
- package/src/agent/agents-page.ts +0 -7
- package/src/agent/components/agent-thread-switcher.tsx +0 -519
- /package/dist/{chunk-vtp6nk44.js.map → chunk-736c9akn.js.map} +0 -0
- /package/dist/{chunk-1rhht9y0.js.map → chunk-n0cxwvej.js.map} +0 -0
- /package/dist/{chunk-0yb22w6m.js.map → chunk-qh1panvd.js.map} +0 -0
|
@@ -4,8 +4,6 @@ import { useLocale } from "@sixb/ui/lib/i18n"
|
|
|
4
4
|
import { cn } from "@sixb/ui/lib/utils"
|
|
5
5
|
import { useQuery, useQueryClient } from "@tanstack/react-query"
|
|
6
6
|
import {
|
|
7
|
-
ArrowUpRight,
|
|
8
|
-
Box,
|
|
9
7
|
ChevronRight,
|
|
10
8
|
CircleAlert,
|
|
11
9
|
CircleCheck,
|
|
@@ -16,14 +14,13 @@ import {
|
|
|
16
14
|
Database,
|
|
17
15
|
Globe,
|
|
18
16
|
type LucideIcon,
|
|
17
|
+
RefreshCw,
|
|
19
18
|
SkipForward,
|
|
20
19
|
Workflow,
|
|
21
20
|
} from "lucide-react"
|
|
22
|
-
import { Fragment,
|
|
23
|
-
import { Link } from "react-router-dom"
|
|
21
|
+
import { Fragment, useId, useMemo, useRef, useState } from "react"
|
|
24
22
|
import { humanizeIdentifier } from "../../pages/ontology/lib/labels"
|
|
25
|
-
import {
|
|
26
|
-
import { useValueTypes, ValueTree, valueSchema } from "../../pages/values"
|
|
23
|
+
import { ObjectRefLinksContext, useValueTypes, ValueTree, valueSchema } from "../../pages/values"
|
|
27
24
|
import {
|
|
28
25
|
type AgentApproval,
|
|
29
26
|
type AgentApprovalDecision,
|
|
@@ -36,11 +33,13 @@ import {
|
|
|
36
33
|
} from "../approvals"
|
|
37
34
|
import { capitalize, humanize } from "../bash/interpret"
|
|
38
35
|
import { useDelegationCards } from "../delegation/context"
|
|
36
|
+
import { childTitle } from "../delegation/interpret"
|
|
39
37
|
import { formatRelativeTime } from "../format"
|
|
40
38
|
import { useAgentMessages } from "../i18n"
|
|
41
39
|
import type { AgentMessages } from "../i18n/en"
|
|
42
40
|
import { objectContextTitleQuery } from "../object-context-title"
|
|
43
41
|
import { samePrincipal } from "../sharing"
|
|
42
|
+
import { ACTIVITY_STATUS_ROW_CLASS_NAME } from "./activity-status"
|
|
44
43
|
|
|
45
44
|
const DAY_MS = 24 * 60 * 60 * 1_000
|
|
46
45
|
|
|
@@ -97,21 +96,26 @@ type DecisionNotice = { readonly tone: "info" | "warning"; readonly text: string
|
|
|
97
96
|
* One call the agent made that waits for, or waited for, its requester: what it does, to which
|
|
98
97
|
* record, with which values, and whether it stays in the project's data. Whoever asked for the turn
|
|
99
98
|
* approves or denies it here; everyone else reads it, and who decides. A call the thread holds no
|
|
100
|
-
* record of shows only when a message reported how it ended.
|
|
101
|
-
* sub-agent that made it, which names it already.
|
|
99
|
+
* record of shows only when a message reported how it ended.
|
|
102
100
|
*/
|
|
103
101
|
export function ApprovalCard({
|
|
104
102
|
held,
|
|
105
|
-
|
|
103
|
+
underCaller = false,
|
|
106
104
|
}: {
|
|
107
105
|
readonly held: HeldCall
|
|
108
|
-
|
|
106
|
+
/** Right under the line of the sub-agent that asked, which names it already. */
|
|
107
|
+
readonly underCaller?: boolean
|
|
109
108
|
}) {
|
|
110
109
|
const messages = useAgentMessages()
|
|
111
110
|
const labels = messages.approvals
|
|
112
111
|
const locale = useLocale()
|
|
113
112
|
const alsoId = useId()
|
|
114
|
-
const
|
|
113
|
+
const sectionRef = useRef<HTMLElement>(null)
|
|
114
|
+
// The buttons go once a decision lands: the reader's place moves to what now says how it ended.
|
|
115
|
+
const focusStatus = () =>
|
|
116
|
+
requestAnimationFrame(() =>
|
|
117
|
+
sectionRef.current?.querySelector<HTMLElement>("[data-approval-focus]")?.focus()
|
|
118
|
+
)
|
|
115
119
|
const { approvals: context, outcomes } = useApprovalCards()
|
|
116
120
|
const delegationCards = useDelegationCards()
|
|
117
121
|
const approval = context?.approvals.find((candidate) => candidate.id === held.id) ?? null
|
|
@@ -134,8 +138,9 @@ export function ApprovalCard({
|
|
|
134
138
|
|
|
135
139
|
const definition = useCallDefinition(call)
|
|
136
140
|
const title = definition.name
|
|
141
|
+
const effect = effectOf(call, definition, messages)
|
|
137
142
|
// A sub-agent's call says which one asked; its own card comes with the sub-agent's.
|
|
138
|
-
const caller = approval?.caller ?? reported?.caller
|
|
143
|
+
const caller = underCaller ? undefined : (approval?.caller ?? reported?.caller)
|
|
139
144
|
|
|
140
145
|
const canDecide =
|
|
141
146
|
state === "pending" && approval !== null && context?.decide !== undefined
|
|
@@ -155,8 +160,6 @@ export function ApprovalCard({
|
|
|
155
160
|
?.id === approval.id
|
|
156
161
|
// A waiting call shows what it runs with; a decided one keeps it a click away.
|
|
157
162
|
const waiting = state === "pending" || state === "unknown"
|
|
158
|
-
const open = waiting || (approval !== null && showInput)
|
|
159
|
-
const when = approval ? (approval.decidedAt ?? approval.createdAt) : undefined
|
|
160
163
|
const expiredDays = approval
|
|
161
164
|
? Math.round((Date.parse(approval.expiresAt) - Date.parse(approval.createdAt)) / DAY_MS)
|
|
162
165
|
: 7
|
|
@@ -190,7 +193,7 @@ export function ApprovalCard({
|
|
|
190
193
|
.catch(() => setStopFailed(true))
|
|
191
194
|
.finally(() => {
|
|
192
195
|
setStopping(false)
|
|
193
|
-
|
|
196
|
+
focusStatus()
|
|
194
197
|
})
|
|
195
198
|
}
|
|
196
199
|
|
|
@@ -224,245 +227,299 @@ export function ApprovalCard({
|
|
|
224
227
|
)
|
|
225
228
|
.finally(() => {
|
|
226
229
|
setDeciding(null)
|
|
227
|
-
|
|
228
|
-
requestAnimationFrame(() => statusRef.current?.focus())
|
|
230
|
+
focusStatus()
|
|
229
231
|
})
|
|
230
232
|
}
|
|
231
233
|
|
|
234
|
+
const subjectLine =
|
|
235
|
+
(call.kind === "action" && call.subject) || caller ? (
|
|
236
|
+
<>
|
|
237
|
+
{call.kind === "action" && call.subject ? <Subject subject={call.subject} /> : null}
|
|
238
|
+
{call.kind === "action" && call.subject && caller ? (
|
|
239
|
+
<span aria-hidden="true">·</span>
|
|
240
|
+
) : null}
|
|
241
|
+
{caller ? (
|
|
242
|
+
<span className="truncate">{labels.fromSubagent(childTitle(caller.key))}</span>
|
|
243
|
+
) : null}
|
|
244
|
+
</>
|
|
245
|
+
) : null
|
|
246
|
+
|
|
247
|
+
const notes = (
|
|
248
|
+
<>
|
|
249
|
+
{notice ? (
|
|
250
|
+
<p
|
|
251
|
+
role="status"
|
|
252
|
+
className={cn(
|
|
253
|
+
"text-xs",
|
|
254
|
+
notice.tone === "warning" ? "text-amber-700 dark:text-amber-400" : "text-foreground"
|
|
255
|
+
)}
|
|
256
|
+
>
|
|
257
|
+
{notice.text}
|
|
258
|
+
</p>
|
|
259
|
+
) : null}
|
|
260
|
+
{stopFailed ? (
|
|
261
|
+
<p role="alert" className="text-xs text-destructive">
|
|
262
|
+
{labels.stopFailed}
|
|
263
|
+
</p>
|
|
264
|
+
) : null}
|
|
265
|
+
{failure ? (
|
|
266
|
+
<p role="alert" className="text-xs text-destructive">
|
|
267
|
+
{labels.failures[failure]}
|
|
268
|
+
</p>
|
|
269
|
+
) : null}
|
|
270
|
+
</>
|
|
271
|
+
)
|
|
272
|
+
|
|
273
|
+
// Decided, the call is a line of the reply's record, as its work is: how it ended, what it was
|
|
274
|
+
// and to what, its values a click away.
|
|
275
|
+
if (!waiting) {
|
|
276
|
+
const when = approval?.decidedAt
|
|
277
|
+
const detail = outcomeDetail(state, approval?.outcome ?? reported?.outcome, expiredDays, labels)
|
|
278
|
+
const line = (
|
|
279
|
+
<>
|
|
280
|
+
<StatusLine state={state} requester={requester} messages={messages} inline />
|
|
281
|
+
<span className="text-muted-foreground/60" aria-hidden="true">
|
|
282
|
+
·
|
|
283
|
+
</span>
|
|
284
|
+
<span className="min-w-0 truncate">
|
|
285
|
+
<span className="font-medium text-foreground/85">{title}</span>
|
|
286
|
+
{subjectLine ? (
|
|
287
|
+
<span className="inline-flex min-w-0 items-center gap-1.5">
|
|
288
|
+
<span className="ml-1.5 text-muted-foreground/60" aria-hidden="true">
|
|
289
|
+
·
|
|
290
|
+
</span>
|
|
291
|
+
{subjectLine}
|
|
292
|
+
</span>
|
|
293
|
+
) : null}
|
|
294
|
+
</span>
|
|
295
|
+
{when ? (
|
|
296
|
+
<span className="shrink-0 text-muted-foreground/70 tabular-nums">
|
|
297
|
+
<span className="text-muted-foreground/60" aria-hidden="true">
|
|
298
|
+
·{" "}
|
|
299
|
+
</span>
|
|
300
|
+
{formatRelativeTime(when, locale, messages.time)}
|
|
301
|
+
</span>
|
|
302
|
+
) : null}
|
|
303
|
+
</>
|
|
304
|
+
)
|
|
305
|
+
return (
|
|
306
|
+
<section
|
|
307
|
+
ref={sectionRef}
|
|
308
|
+
aria-label={labels.card(title)}
|
|
309
|
+
data-approval-state={state}
|
|
310
|
+
data-approval-id={held.id}
|
|
311
|
+
tabIndex={-1}
|
|
312
|
+
className="flex min-w-0 flex-col gap-1 outline-none"
|
|
313
|
+
>
|
|
314
|
+
{approval ? (
|
|
315
|
+
<button
|
|
316
|
+
data-approval-focus=""
|
|
317
|
+
type="button"
|
|
318
|
+
aria-expanded={showInput}
|
|
319
|
+
onClick={() => setShowInput((value) => !value)}
|
|
320
|
+
className={cn(
|
|
321
|
+
ACTIVITY_STATUS_ROW_CLASS_NAME,
|
|
322
|
+
"outline-none transition-colors hover:bg-muted/50 hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring/40"
|
|
323
|
+
)}
|
|
324
|
+
>
|
|
325
|
+
{line}
|
|
326
|
+
<ChevronRight
|
|
327
|
+
className="size-3.5 shrink-0 opacity-50 transition-[opacity,transform] group-hover:opacity-100 group-aria-expanded:rotate-90"
|
|
328
|
+
aria-hidden="true"
|
|
329
|
+
/>
|
|
330
|
+
</button>
|
|
331
|
+
) : (
|
|
332
|
+
// Read without its record, there is nothing more to open.
|
|
333
|
+
<p data-approval-focus="" tabIndex={-1} className={ACTIVITY_STATUS_ROW_CLASS_NAME}>
|
|
334
|
+
{line}
|
|
335
|
+
</p>
|
|
336
|
+
)}
|
|
337
|
+
{detail ? <p className="pl-6 text-xs text-muted-foreground">{detail}</p> : null}
|
|
338
|
+
{showInput && approval ? (
|
|
339
|
+
<div className="pt-1 pb-1 pl-5">
|
|
340
|
+
<CallInput call={call} definition={definition} emptyLabel={labels.noInput} />
|
|
341
|
+
{effect ? (
|
|
342
|
+
<p className="mt-2 text-xs">
|
|
343
|
+
<EffectLine effect={effect} />
|
|
344
|
+
</p>
|
|
345
|
+
) : null}
|
|
346
|
+
</div>
|
|
347
|
+
) : null}
|
|
348
|
+
<div className="pl-5 empty:hidden">{notes}</div>
|
|
349
|
+
</section>
|
|
350
|
+
)
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
// Waiting, it is the one thing in the reply to act on: what, to what, with which values, what it
|
|
354
|
+
// reaches, then the decision.
|
|
232
355
|
return (
|
|
233
356
|
<section
|
|
357
|
+
ref={sectionRef}
|
|
234
358
|
aria-label={labels.card(title)}
|
|
235
359
|
aria-busy={deciding !== null}
|
|
236
360
|
data-approval-state={state}
|
|
237
361
|
data-approval-id={held.id}
|
|
238
|
-
// A sub-agent's
|
|
362
|
+
// A sub-agent's line brings the reader here when the call waits under a later turn.
|
|
239
363
|
tabIndex={-1}
|
|
240
|
-
className=
|
|
241
|
-
"min-w-0 overflow-hidden border bg-card text-card-foreground",
|
|
242
|
-
inCard ? "rounded-xl" : "rounded-2xl",
|
|
243
|
-
canDecide
|
|
244
|
-
? inCard
|
|
245
|
-
? "border-amber-500/35"
|
|
246
|
-
: "border-amber-500/35 shadow-[0_0_0_4px_rgb(245_158_11/0.06),0_1px_2px_0_rgb(0_0_0/0.04)]"
|
|
247
|
-
: inCard
|
|
248
|
-
? "border-border"
|
|
249
|
-
: "border-border shadow-[0_1px_2px_0_rgb(0_0_0/0.04)]"
|
|
250
|
-
)}
|
|
364
|
+
className="min-w-0 rounded-2xl bg-card p-4 text-card-foreground shadow-[0_0_0_1px_rgb(0_0_0/0.06),0_1px_2px_rgb(0_0_0/0.03),0_4px_16px_rgb(0_0_0/0.035)] outline-none sm:p-5 dark:shadow-[0_0_0_1px_rgb(255_255_255/0.09)]"
|
|
251
365
|
>
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
quiet={inCard && state === "pending"}
|
|
262
|
-
/>
|
|
263
|
-
{when && !(inCard && state === "pending" && !canStop) ? (
|
|
264
|
-
<span
|
|
265
|
-
className={cn(
|
|
266
|
-
"ml-auto shrink-0 text-[11px] tabular-nums text-muted-foreground",
|
|
267
|
-
// On a phone, Stop waiting needs the room more than the time does.
|
|
268
|
-
canStop && "max-sm:hidden"
|
|
269
|
-
)}
|
|
270
|
-
>
|
|
271
|
-
{formatRelativeTime(when, locale, messages.time)}
|
|
272
|
-
</span>
|
|
273
|
-
) : null}
|
|
274
|
-
{canStop ? (
|
|
275
|
-
<button
|
|
276
|
-
type="button"
|
|
277
|
-
onClick={stopWaiting}
|
|
278
|
-
disabled={stopping || deciding !== null}
|
|
279
|
-
title={labels.stopWaitingHint}
|
|
280
|
-
className="-my-1 -mr-1.5 shrink-0 rounded-md max-sm:ml-auto px-1.5 py-1 text-[11px] font-medium text-muted-foreground outline-none transition-colors hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring/40 disabled:opacity-60"
|
|
281
|
-
>
|
|
282
|
-
{stopping ? labels.stoppingWaiting : labels.stopWaiting}
|
|
283
|
-
</button>
|
|
284
|
-
) : null}
|
|
366
|
+
{/* The reader's own to decide: its buttons say so, and the status is for screen readers. For
|
|
367
|
+
anyone else, it says who decides. Under a sub-agent's line, the line says it already. */}
|
|
368
|
+
{underCaller ? null : canDecide ? (
|
|
369
|
+
<p data-approval-focus="" tabIndex={-1} role="status" className="sr-only">
|
|
370
|
+
{labels.waitingYou}
|
|
371
|
+
</p>
|
|
372
|
+
) : (
|
|
373
|
+
<div className="mb-2">
|
|
374
|
+
<StatusLine state={state} requester={requester} messages={messages} />
|
|
285
375
|
</div>
|
|
376
|
+
)}
|
|
286
377
|
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
)}
|
|
294
|
-
>
|
|
295
|
-
{title}
|
|
378
|
+
<div className="flex min-w-0 items-start gap-3">
|
|
379
|
+
<h3 className="flex min-w-0 flex-1 items-center gap-2 text-[15px] leading-snug font-semibold tracking-[-0.01em] text-foreground">
|
|
380
|
+
{canDecide && !underCaller ? (
|
|
381
|
+
<span className="size-1.5 shrink-0 rounded-full bg-amber-500" aria-hidden="true" />
|
|
382
|
+
) : null}
|
|
383
|
+
<span className="min-w-0">{title}</span>
|
|
296
384
|
</h3>
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
{
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
{call.kind === "action" && call.subject ? <Subject subject={call.subject} /> : null}
|
|
305
|
-
|
|
306
|
-
{waiting || state === "asked" ? null : (
|
|
307
|
-
<Outcome
|
|
308
|
-
state={state}
|
|
309
|
-
outcome={approval?.outcome ?? reported?.outcome}
|
|
310
|
-
expiredDays={expiredDays}
|
|
311
|
-
messages={messages}
|
|
385
|
+
{canStop ? (
|
|
386
|
+
<button
|
|
387
|
+
type="button"
|
|
388
|
+
onClick={stopWaiting}
|
|
389
|
+
disabled={stopping || deciding !== null}
|
|
390
|
+
title={labels.stopWaitingHint}
|
|
391
|
+
className="-my-0.5 -mr-2 shrink-0 rounded-full px-2 py-1 text-xs text-muted-foreground outline-none transition-colors hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring/40 disabled:opacity-60"
|
|
312
392
|
>
|
|
313
|
-
{
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
</button>
|
|
326
|
-
) : null}
|
|
327
|
-
</Outcome>
|
|
328
|
-
)}
|
|
393
|
+
{stopping ? labels.stoppingWaiting : labels.stopWaiting}
|
|
394
|
+
</button>
|
|
395
|
+
) : null}
|
|
396
|
+
</div>
|
|
397
|
+
{/* To what; and when it only changes records here, that reassurance, quietly beside it. */}
|
|
398
|
+
<p className="mt-0.5 flex min-w-0 flex-wrap items-center gap-x-3 gap-y-0.5 text-[13px] text-muted-foreground">
|
|
399
|
+
{subjectLine}
|
|
400
|
+
{effect?.reach === "records" ? <EffectLine effect={effect} /> : null}
|
|
401
|
+
</p>
|
|
402
|
+
|
|
403
|
+
<div className="mt-3">
|
|
404
|
+
<CallInput call={call} definition={definition} emptyLabel={labels.noInput} />
|
|
329
405
|
</div>
|
|
330
406
|
|
|
331
|
-
{
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
407
|
+
{/* Reaching past the app is the last thing read before saying yes. */}
|
|
408
|
+
{effect?.reach === "outside" ? (
|
|
409
|
+
<p className="mt-3.5 border-t border-border/60 pt-3 text-[13px]">
|
|
410
|
+
<EffectLine effect={effect} />
|
|
411
|
+
</p>
|
|
335
412
|
) : null}
|
|
336
413
|
|
|
337
|
-
{waiting ? <Effect call={call} external={definition.external} messages={messages} /> : null}
|
|
338
|
-
|
|
339
414
|
{canDecide ? (
|
|
340
|
-
<div className="
|
|
341
|
-
<div className="
|
|
415
|
+
<div className={effect?.reach === "outside" ? "mt-3" : "mt-4"}>
|
|
416
|
+
<div className="flex flex-wrap items-center gap-2">
|
|
342
417
|
<Button
|
|
343
418
|
type="button"
|
|
344
|
-
variant="
|
|
419
|
+
variant="secondary"
|
|
345
420
|
size="sm"
|
|
346
421
|
disabled={deciding !== null}
|
|
347
422
|
onClick={() => decide("deny")}
|
|
348
|
-
className="h-
|
|
423
|
+
className="h-8 rounded-full px-4 shadow-none"
|
|
349
424
|
>
|
|
350
425
|
{deciding === "deny" ? <Spinner className="size-3.5" /> : null}
|
|
351
426
|
{deciding === "deny" ? labels.denying : labels.deny}
|
|
352
427
|
</Button>
|
|
353
|
-
<span className="
|
|
428
|
+
<span className="flex-1" />
|
|
429
|
+
{/* Both ways to say yes, side by side: this once, or from now on in this conversation. */}
|
|
354
430
|
<Button
|
|
355
431
|
type="button"
|
|
356
|
-
variant="
|
|
432
|
+
variant="secondary"
|
|
357
433
|
size="sm"
|
|
358
434
|
disabled={deciding !== null}
|
|
359
435
|
onClick={() => decide("always")}
|
|
436
|
+
title={labels.alwaysAllowHint(alwaysModeLabel)}
|
|
360
437
|
aria-describedby={alsoApproved > 0 ? alsoId : undefined}
|
|
361
|
-
className="
|
|
438
|
+
className="h-8 rounded-full px-4 shadow-none"
|
|
362
439
|
>
|
|
363
440
|
{deciding === "always" ? <Spinner className="size-3.5" /> : null}
|
|
364
|
-
{
|
|
441
|
+
{/* For a call that reaches outside, it lets every such call run from now on. */}
|
|
442
|
+
{alwaysMode === "auto" ? labels.alwaysAllowAll : labels.alwaysAllow}
|
|
365
443
|
</Button>
|
|
366
444
|
<Button
|
|
367
445
|
type="button"
|
|
368
446
|
size="sm"
|
|
369
447
|
disabled={deciding !== null}
|
|
370
448
|
onClick={() => decide("approve")}
|
|
371
|
-
className="h-
|
|
449
|
+
className="h-8 rounded-full px-4 shadow-none"
|
|
372
450
|
>
|
|
373
451
|
{deciding === "approve" ? <Spinner className="size-3.5" /> : null}
|
|
374
452
|
{deciding === "approve" ? labels.approving : labels.approve}
|
|
375
453
|
</Button>
|
|
376
454
|
</div>
|
|
377
455
|
{alsoApproved > 0 ? (
|
|
378
|
-
<p id={alsoId} className="mt-2 text-xs text-muted-foreground
|
|
456
|
+
<p id={alsoId} className="mt-2 text-xs text-muted-foreground">
|
|
379
457
|
{labels.alwaysAllowAlso(alsoApproved)}
|
|
380
458
|
</p>
|
|
381
459
|
) : null}
|
|
382
460
|
</div>
|
|
383
461
|
) : state === "pending" && requester !== null ? (
|
|
384
|
-
<p className="
|
|
385
|
-
{labels.onlyRequester(requester)}
|
|
386
|
-
</p>
|
|
462
|
+
<p className="mt-3 text-xs text-muted-foreground">{labels.onlyRequester(requester)}</p>
|
|
387
463
|
) : null}
|
|
388
464
|
|
|
389
|
-
|
|
390
|
-
<p
|
|
391
|
-
role="status"
|
|
392
|
-
className={cn(
|
|
393
|
-
"border-t border-border/60 px-4 py-2.5 text-xs sm:px-5",
|
|
394
|
-
notice.tone === "warning" ? "text-amber-700 dark:text-amber-400" : "text-foreground"
|
|
395
|
-
)}
|
|
396
|
-
>
|
|
397
|
-
{notice.text}
|
|
398
|
-
</p>
|
|
399
|
-
) : null}
|
|
400
|
-
|
|
401
|
-
{stopFailed ? (
|
|
402
|
-
<p
|
|
403
|
-
role="alert"
|
|
404
|
-
className="border-t border-border/60 px-4 py-2.5 text-xs text-destructive sm:px-5"
|
|
405
|
-
>
|
|
406
|
-
{labels.stopFailed}
|
|
407
|
-
</p>
|
|
408
|
-
) : null}
|
|
409
|
-
|
|
410
|
-
{failure ? (
|
|
411
|
-
<p
|
|
412
|
-
role="alert"
|
|
413
|
-
className="border-t border-border/60 px-4 py-2.5 text-xs text-destructive sm:px-5"
|
|
414
|
-
>
|
|
415
|
-
{labels.failures[failure]}
|
|
416
|
-
</p>
|
|
417
|
-
) : null}
|
|
465
|
+
<div className="mt-3 flex flex-col gap-1 empty:hidden">{notes}</div>
|
|
418
466
|
</section>
|
|
419
467
|
)
|
|
420
468
|
}
|
|
421
469
|
|
|
470
|
+
/** Where the call stands, for anyone but the one who decides it: their buttons say it already. */
|
|
422
471
|
function StatusLine({
|
|
423
|
-
focusRef,
|
|
424
472
|
state,
|
|
425
473
|
requester,
|
|
426
|
-
canDecide,
|
|
427
474
|
messages,
|
|
428
|
-
|
|
475
|
+
inline = false,
|
|
429
476
|
}: {
|
|
430
|
-
/** Where focus goes once a decision removes the buttons. */
|
|
431
|
-
readonly focusRef: Ref<HTMLParagraphElement>
|
|
432
477
|
readonly state: CardState
|
|
433
478
|
readonly requester: string | null
|
|
434
|
-
readonly canDecide: boolean
|
|
435
479
|
readonly messages: AgentMessages
|
|
436
|
-
/**
|
|
437
|
-
readonly
|
|
480
|
+
/** In a decided call's line: its icon in the tone, its words in the line's. */
|
|
481
|
+
readonly inline?: boolean
|
|
438
482
|
}) {
|
|
439
|
-
const
|
|
440
|
-
const
|
|
483
|
+
const { Icon, label, tone } = statusOf(state, requester, messages)
|
|
484
|
+
const toneClass = cn(
|
|
485
|
+
tone === "waiting" && "text-amber-700 dark:text-amber-400",
|
|
486
|
+
tone === "done" && "text-emerald-600 dark:text-emerald-400",
|
|
487
|
+
tone === "error" && "text-destructive",
|
|
488
|
+
tone === "muted" && "text-muted-foreground"
|
|
489
|
+
)
|
|
490
|
+
const icon =
|
|
491
|
+
state === "running" ? (
|
|
492
|
+
<Spinner className="size-3 shrink-0" />
|
|
493
|
+
) : tone === "waiting" ? (
|
|
494
|
+
<span className="relative flex size-2 shrink-0" aria-hidden="true">
|
|
495
|
+
<span className="absolute inset-0 rounded-full bg-amber-500/40 motion-safe:animate-ping dark:bg-amber-400/40" />
|
|
496
|
+
<span className="relative size-2 rounded-full bg-amber-500 dark:bg-amber-400" />
|
|
497
|
+
</span>
|
|
498
|
+
) : (
|
|
499
|
+
<Icon className={cn("size-3.5 shrink-0", inline && toneClass)} aria-hidden="true" />
|
|
500
|
+
)
|
|
501
|
+
|
|
502
|
+
if (inline) {
|
|
503
|
+
return (
|
|
504
|
+
<span className="flex shrink-0 items-center gap-1.5">
|
|
505
|
+
{icon}
|
|
506
|
+
<span className={cn(tone === "error" && "text-destructive")}>{label}</span>
|
|
507
|
+
</span>
|
|
508
|
+
)
|
|
509
|
+
}
|
|
441
510
|
|
|
442
511
|
return (
|
|
443
512
|
<p
|
|
444
|
-
|
|
513
|
+
data-approval-focus=""
|
|
445
514
|
tabIndex={-1}
|
|
446
515
|
role="status"
|
|
447
516
|
className={cn(
|
|
448
|
-
"flex min-w-0 items-center gap-
|
|
449
|
-
|
|
450
|
-
tone === "waiting" && "text-amber-700 dark:text-amber-400",
|
|
451
|
-
tone === "done" && "text-emerald-700 dark:text-emerald-400",
|
|
452
|
-
tone === "error" && "text-destructive",
|
|
453
|
-
tone === "muted" && "text-muted-foreground"
|
|
517
|
+
"flex min-w-0 items-center gap-2 rounded-sm text-xs font-medium outline-none focus-visible:ring-2 focus-visible:ring-ring/40",
|
|
518
|
+
toneClass
|
|
454
519
|
)}
|
|
455
520
|
>
|
|
456
|
-
{
|
|
457
|
-
<Spinner className="size-3.5 shrink-0" />
|
|
458
|
-
) : (
|
|
459
|
-
<Icon
|
|
460
|
-
className={cn("size-3.5 shrink-0", state === "pending" && "motion-safe:animate-pulse")}
|
|
461
|
-
aria-hidden="true"
|
|
462
|
-
/>
|
|
463
|
-
)}
|
|
521
|
+
{icon}
|
|
464
522
|
<span className="truncate">{label}</span>
|
|
465
|
-
{state === "running" ? <span className="sr-only">{labels.running}</span> : null}
|
|
466
523
|
</p>
|
|
467
524
|
)
|
|
468
525
|
}
|
|
@@ -470,7 +527,6 @@ function StatusLine({
|
|
|
470
527
|
function statusOf(
|
|
471
528
|
state: CardState,
|
|
472
529
|
requester: string | null,
|
|
473
|
-
canDecide: boolean,
|
|
474
530
|
messages: AgentMessages
|
|
475
531
|
): {
|
|
476
532
|
readonly Icon: LucideIcon
|
|
@@ -482,7 +538,7 @@ function statusOf(
|
|
|
482
538
|
case "pending":
|
|
483
539
|
return {
|
|
484
540
|
Icon: CirclePause,
|
|
485
|
-
label:
|
|
541
|
+
label: requester === null ? labels.waitingYou : labels.waitingOther(requester),
|
|
486
542
|
tone: "waiting",
|
|
487
543
|
}
|
|
488
544
|
case "unknown":
|
|
@@ -490,17 +546,13 @@ function statusOf(
|
|
|
490
546
|
case "running":
|
|
491
547
|
return { Icon: CircleCheck, label: `${labels.approved} · ${labels.running}`, tone: "done" }
|
|
492
548
|
case "ran":
|
|
493
|
-
return { Icon: CircleCheck, label:
|
|
549
|
+
return { Icon: CircleCheck, label: labels.approved, tone: "done" }
|
|
494
550
|
case "failed":
|
|
495
551
|
return { Icon: CircleAlert, label: labels.failed, tone: "error" }
|
|
496
552
|
case "lost":
|
|
497
553
|
return { Icon: CircleAlert, label: labels.notRun, tone: "error" }
|
|
498
554
|
case "denied":
|
|
499
|
-
return {
|
|
500
|
-
Icon: CircleSlash,
|
|
501
|
-
label: `${labels.denied} · ${labels.deniedDetail}`,
|
|
502
|
-
tone: "muted",
|
|
503
|
-
}
|
|
555
|
+
return { Icon: CircleSlash, label: labels.denied, tone: "muted" }
|
|
504
556
|
case "superseded":
|
|
505
557
|
return { Icon: SkipForward, label: labels.superseded, tone: "muted" }
|
|
506
558
|
case "cancelled":
|
|
@@ -512,13 +564,15 @@ function statusOf(
|
|
|
512
564
|
}
|
|
513
565
|
}
|
|
514
566
|
|
|
515
|
-
/**
|
|
567
|
+
/**
|
|
568
|
+
* The record the action acts on: its type and its title. Named, not linked: the card is read by
|
|
569
|
+
* everyone in the conversation, and the record's page is not theirs to be sent to.
|
|
570
|
+
*/
|
|
516
571
|
function Subject({
|
|
517
572
|
subject,
|
|
518
573
|
}: {
|
|
519
574
|
readonly subject: { readonly objectTypeId: string; readonly primaryId: string }
|
|
520
575
|
}) {
|
|
521
|
-
const labels = useAgentMessages().approvals
|
|
522
576
|
const queryClient = useQueryClient()
|
|
523
577
|
const objectType = useQuery({
|
|
524
578
|
...getObjectTypeOptions({ path: { objectTypeId: subject.objectTypeId } }),
|
|
@@ -527,30 +581,18 @@ function Subject({
|
|
|
527
581
|
})
|
|
528
582
|
const title = useQuery(objectContextTitleQuery(queryClient, subject)).data ?? null
|
|
529
583
|
const typeName = objectType.data?.name ?? humanizeIdentifier(subject.objectTypeId)
|
|
530
|
-
const name = title ?? subject.primaryId
|
|
531
584
|
|
|
532
585
|
return (
|
|
533
|
-
<
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
className="group mt-2 flex w-fit max-w-full min-w-0 items-center gap-2 rounded-lg bg-muted/60 py-1 pr-2 pl-1.5 text-[13px] outline-none transition-colors hover:bg-muted focus-visible:ring-2 focus-visible:ring-ring/40"
|
|
537
|
-
>
|
|
538
|
-
<span className="flex size-5 shrink-0 items-center justify-center rounded-md bg-background ring-1 ring-border">
|
|
539
|
-
<Box className="size-3 text-emerald-600 dark:text-emerald-400" aria-hidden="true" />
|
|
540
|
-
</span>
|
|
541
|
-
<span className="shrink-0 text-muted-foreground">{typeName}</span>
|
|
542
|
-
<span className="min-w-0 truncate font-medium text-foreground">{name}</span>
|
|
543
|
-
<ArrowUpRight
|
|
544
|
-
className="size-3.5 shrink-0 text-muted-foreground transition-colors group-hover:text-foreground"
|
|
545
|
-
aria-hidden="true"
|
|
546
|
-
/>
|
|
547
|
-
</Link>
|
|
586
|
+
<span className="min-w-0 truncate">
|
|
587
|
+
{typeName} <span className="text-foreground">{title ?? subject.primaryId}</span>
|
|
588
|
+
</span>
|
|
548
589
|
)
|
|
549
590
|
}
|
|
550
591
|
|
|
551
592
|
/**
|
|
552
593
|
* The values the call runs with, one per line, labelled and formatted as the action or workflow
|
|
553
|
-
* declares them: a date reads as a date, an object reference as a link
|
|
594
|
+
* declares them: a date reads as a date, an object reference by its title. Not as a link: the
|
|
595
|
+
* card is read by everyone in the conversation, and the record's page is not theirs to visit.
|
|
554
596
|
*/
|
|
555
597
|
function CallInput({
|
|
556
598
|
call,
|
|
@@ -579,35 +621,35 @@ function CallInput({
|
|
|
579
621
|
}
|
|
580
622
|
|
|
581
623
|
return (
|
|
582
|
-
<
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
<
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
{item}
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
</
|
|
607
|
-
|
|
608
|
-
)
|
|
609
|
-
|
|
610
|
-
</
|
|
624
|
+
<ObjectRefLinksContext.Provider value={false}>
|
|
625
|
+
<dl className="grid grid-cols-[minmax(4.5rem,max-content)_minmax(0,1fr)] gap-x-6 gap-y-1.5 text-[13px] leading-5">
|
|
626
|
+
{entries.map(([key, item]) => {
|
|
627
|
+
const field = definition.fields?.[key]
|
|
628
|
+
return (
|
|
629
|
+
<Fragment key={key}>
|
|
630
|
+
<dt className="min-w-0 break-words text-muted-foreground">
|
|
631
|
+
{definition.labels?.[key] ?? sentence(key)}
|
|
632
|
+
</dt>
|
|
633
|
+
<dd className="min-w-0 text-foreground">
|
|
634
|
+
{isEnumSchema(fieldSchemaOf(field)) && typeof item === "string" ? (
|
|
635
|
+
// A declared choice, shown as the code it is rather than as prose.
|
|
636
|
+
<span className="uppercase">{item}</span>
|
|
637
|
+
) : (
|
|
638
|
+
<ValueTree
|
|
639
|
+
value={item}
|
|
640
|
+
schema={
|
|
641
|
+
definition.fields && field !== undefined
|
|
642
|
+
? valueSchema(fieldSchemaOf(field), valueTypes)
|
|
643
|
+
: undefined
|
|
644
|
+
}
|
|
645
|
+
/>
|
|
646
|
+
)}
|
|
647
|
+
</dd>
|
|
648
|
+
</Fragment>
|
|
649
|
+
)
|
|
650
|
+
})}
|
|
651
|
+
</dl>
|
|
652
|
+
</ObjectRefLinksContext.Provider>
|
|
611
653
|
)
|
|
612
654
|
}
|
|
613
655
|
|
|
@@ -622,111 +664,72 @@ function fieldSchemaOf(field: unknown): unknown {
|
|
|
622
664
|
: field
|
|
623
665
|
}
|
|
624
666
|
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
}
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
667
|
+
interface CallEffect {
|
|
668
|
+
readonly Icon: LucideIcon
|
|
669
|
+
readonly text: string
|
|
670
|
+
/** `outside`: it reaches past the app, which is worth a second look before saying yes. */
|
|
671
|
+
readonly reach: "records" | "outside"
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
/**
|
|
675
|
+
* What saying yes does beyond the values: only changes records in this app, or reaches past it —
|
|
676
|
+
* writing back to the system a record comes from, or acting outside (sending, paying, calling).
|
|
677
|
+
* The framework knows which kind, not which system, nor whether it can be undone.
|
|
678
|
+
*/
|
|
679
|
+
function effectOf(
|
|
680
|
+
call: CardCall,
|
|
681
|
+
definition: CallDefinition,
|
|
682
|
+
messages: AgentMessages
|
|
683
|
+
): CallEffect | null {
|
|
635
684
|
const effects = messages.approvals.effects
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
: effect === "external"
|
|
648
|
-
? { Icon: Globe, text: effects.external, tone: "strong" as const }
|
|
649
|
-
: { Icon: Database, text: effects.ontology, tone: "quiet" as const }
|
|
685
|
+
if (call.kind === "workflow") {
|
|
686
|
+
return { Icon: Workflow, text: effects.workflow(sentence(call.workflowId)), reach: "outside" }
|
|
687
|
+
}
|
|
688
|
+
const effect = call.effect ?? (definition.external ? "external" : undefined)
|
|
689
|
+
if (effect === undefined) return null
|
|
690
|
+
if (effect === "ontology") return { Icon: Database, text: effects.ontology, reach: "records" }
|
|
691
|
+
// A write-back alone updates the record's own system; anything else acts outside the app.
|
|
692
|
+
return definition.writeback && !definition.effects
|
|
693
|
+
? { Icon: RefreshCw, text: effects.writeback, reach: "outside" }
|
|
694
|
+
: { Icon: Globe, text: effects.external, reach: "outside" }
|
|
695
|
+
}
|
|
650
696
|
|
|
697
|
+
function EffectLine({ effect }: { readonly effect: CallEffect }) {
|
|
698
|
+
const { Icon, text, reach } = effect
|
|
651
699
|
return (
|
|
652
|
-
<
|
|
700
|
+
<span
|
|
653
701
|
className={cn(
|
|
654
|
-
"flex items-center gap-
|
|
655
|
-
|
|
702
|
+
"inline-flex items-center gap-1.5",
|
|
703
|
+
reach === "outside" ? "text-foreground" : "text-muted-foreground"
|
|
656
704
|
)}
|
|
657
705
|
>
|
|
658
|
-
<Icon
|
|
659
|
-
className={cn(
|
|
660
|
-
"size-3.5 shrink-0",
|
|
661
|
-
tone === "strong" ? "text-amber-600 dark:text-amber-400" : "text-muted-foreground"
|
|
662
|
-
)}
|
|
663
|
-
aria-hidden="true"
|
|
664
|
-
/>
|
|
706
|
+
<Icon className="size-3.5 shrink-0 text-muted-foreground" aria-hidden="true" />
|
|
665
707
|
{text}
|
|
666
|
-
</
|
|
708
|
+
</span>
|
|
667
709
|
)
|
|
668
710
|
}
|
|
669
711
|
|
|
670
|
-
/**
|
|
671
|
-
function
|
|
672
|
-
state,
|
|
673
|
-
outcome,
|
|
674
|
-
expiredDays,
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
: state === "expired"
|
|
692
|
-
? labels.expiredDetail(expiredDays)
|
|
693
|
-
: state === "lost"
|
|
694
|
-
? labels.authorityLost
|
|
695
|
-
: state === "failed"
|
|
696
|
-
? failureMessage(outcome)
|
|
697
|
-
: null
|
|
698
|
-
|
|
699
|
-
const runLink =
|
|
700
|
-
outcome?.kind === "action-run"
|
|
701
|
-
? actionRunHref(outcome.runId)
|
|
702
|
-
: outcome?.kind === "workflow-run"
|
|
703
|
-
? workflowRunHref(outcome.runId)
|
|
704
|
-
: null
|
|
705
|
-
if (!detail && !runLink && !children) return null
|
|
706
|
-
|
|
707
|
-
return (
|
|
708
|
-
<div className="mt-2.5 space-y-1.5 text-xs text-muted-foreground">
|
|
709
|
-
{detail ? (
|
|
710
|
-
<p className={cn((state === "failed" || state === "lost") && "text-destructive")}>
|
|
711
|
-
{detail}
|
|
712
|
-
</p>
|
|
713
|
-
) : null}
|
|
714
|
-
{children || runLink ? (
|
|
715
|
-
<div className="flex flex-wrap items-center gap-x-4 gap-y-1">
|
|
716
|
-
{children}
|
|
717
|
-
{runLink ? (
|
|
718
|
-
<Link
|
|
719
|
-
to={runLink}
|
|
720
|
-
className="inline-flex items-center gap-0.5 rounded-sm font-medium text-foreground underline-offset-4 outline-none hover:underline focus-visible:ring-2 focus-visible:ring-ring/40"
|
|
721
|
-
>
|
|
722
|
-
{labels.viewRun}
|
|
723
|
-
<ArrowUpRight className="size-3" aria-hidden="true" />
|
|
724
|
-
</Link>
|
|
725
|
-
) : null}
|
|
726
|
-
</div>
|
|
727
|
-
) : null}
|
|
728
|
-
</div>
|
|
729
|
-
)
|
|
712
|
+
/** Why a decided call ended as it did, when its status alone does not say. */
|
|
713
|
+
function outcomeDetail(
|
|
714
|
+
state: CardState,
|
|
715
|
+
outcome: AgentApproval["outcome"],
|
|
716
|
+
expiredDays: number,
|
|
717
|
+
labels: AgentMessages["approvals"]
|
|
718
|
+
): string | null {
|
|
719
|
+
switch (state) {
|
|
720
|
+
case "superseded":
|
|
721
|
+
return labels.supersededDetail
|
|
722
|
+
case "cancelled":
|
|
723
|
+
return labels.cancelledDetail
|
|
724
|
+
case "expired":
|
|
725
|
+
return labels.expiredDetail(expiredDays)
|
|
726
|
+
case "lost":
|
|
727
|
+
return labels.authorityLost
|
|
728
|
+
case "failed":
|
|
729
|
+
return failureMessage(outcome)
|
|
730
|
+
default:
|
|
731
|
+
return null
|
|
732
|
+
}
|
|
730
733
|
}
|
|
731
734
|
|
|
732
735
|
/** An id as the card names it: "payInvoice" reads "Pay invoice". */
|
|
@@ -750,6 +753,10 @@ interface CallDefinition {
|
|
|
750
753
|
readonly schemas: readonly unknown[]
|
|
751
754
|
/** From the definition, until the record says it: a writeback or effects reach out. */
|
|
752
755
|
readonly external?: boolean
|
|
756
|
+
/** It writes back to the system its records come from. */
|
|
757
|
+
readonly writeback?: boolean
|
|
758
|
+
/** It acts outside the app: sends, pays, calls. */
|
|
759
|
+
readonly effects?: boolean
|
|
753
760
|
}
|
|
754
761
|
|
|
755
762
|
const NO_SCHEMAS: readonly unknown[] = []
|
|
@@ -793,6 +800,8 @@ function useCallDefinition(call: CardCall): CallDefinition {
|
|
|
793
800
|
),
|
|
794
801
|
schemas: action.params.map((param) => param.schema),
|
|
795
802
|
external: action.phases.writeback || action.phases.effects,
|
|
803
|
+
writeback: action.phases.writeback,
|
|
804
|
+
effects: action.phases.effects,
|
|
796
805
|
}
|
|
797
806
|
}, [call.kind, callId, action, workflow])
|
|
798
807
|
}
|