@wildo-ai/saas-frontend-lib 1.1.12 → 1.1.13

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.
Files changed (46) hide show
  1. package/dist/esm/components/data-display/approval-seal.d.ts +97 -0
  2. package/dist/esm/components/data-display/approval-seal.d.ts.map +1 -0
  3. package/dist/esm/components/data-display/approval-seal.js +208 -0
  4. package/dist/esm/components/data-display/approval-seal.js.map +1 -0
  5. package/dist/esm/components/data-display/formatters/display-field-file.d.ts.map +1 -1
  6. package/dist/esm/components/data-display/formatters/display-field-file.js +16 -2
  7. package/dist/esm/components/data-display/formatters/display-field-file.js.map +1 -1
  8. package/dist/esm/components/flows-actors/approval.d.ts.map +1 -1
  9. package/dist/esm/components/flows-actors/approval.js +48 -18
  10. package/dist/esm/components/flows-actors/approval.js.map +1 -1
  11. package/dist/esm/components/resources/collection/calendar/ResourceCollectionBody_Calendar.d.ts.map +1 -1
  12. package/dist/esm/components/resources/collection/calendar/ResourceCollectionBody_Calendar.js +5 -1
  13. package/dist/esm/components/resources/collection/calendar/ResourceCollectionBody_Calendar.js.map +1 -1
  14. package/dist/esm/components/views/chart-dashboard/ChartDashboard.d.ts +27 -24
  15. package/dist/esm/components/views/chart-dashboard/ChartDashboard.d.ts.map +1 -1
  16. package/dist/esm/components/views/chart-dashboard/ChartDashboard.js +27 -33
  17. package/dist/esm/components/views/chart-dashboard/ChartDashboard.js.map +1 -1
  18. package/dist/esm/components/views/chart-dashboard/ChartDashboardLayoutEditor.d.ts +37 -0
  19. package/dist/esm/components/views/chart-dashboard/ChartDashboardLayoutEditor.d.ts.map +1 -0
  20. package/dist/esm/components/views/chart-dashboard/ChartDashboardLayoutEditor.js +100 -0
  21. package/dist/esm/components/views/chart-dashboard/ChartDashboardLayoutEditor.js.map +1 -0
  22. package/dist/esm/components/views/chart-dashboard/ChartDashboardLayoutEditor.labels.d.ts +3 -0
  23. package/dist/esm/components/views/chart-dashboard/ChartDashboardLayoutEditor.labels.d.ts.map +1 -0
  24. package/dist/esm/components/views/chart-dashboard/ChartDashboardLayoutEditor.labels.js +34 -0
  25. package/dist/esm/components/views/chart-dashboard/ChartDashboardLayoutEditor.labels.js.map +1 -0
  26. package/dist/esm/components/views/chart-dashboard/chart-dashboard-layout.utils.d.ts +47 -0
  27. package/dist/esm/components/views/chart-dashboard/chart-dashboard-layout.utils.d.ts.map +1 -0
  28. package/dist/esm/components/views/chart-dashboard/chart-dashboard-layout.utils.js +94 -0
  29. package/dist/esm/components/views/chart-dashboard/chart-dashboard-layout.utils.js.map +1 -0
  30. package/dist/esm/components/views/chart-dashboard/useChartDashboardLayout.d.ts +39 -0
  31. package/dist/esm/components/views/chart-dashboard/useChartDashboardLayout.d.ts.map +1 -0
  32. package/dist/esm/components/views/chart-dashboard/useChartDashboardLayout.js +155 -0
  33. package/dist/esm/components/views/chart-dashboard/useChartDashboardLayout.js.map +1 -0
  34. package/dist/esm/core/components-registry/assert-registry-completeness.frontend.helper.d.ts.map +1 -1
  35. package/dist/esm/core/components-registry/assert-registry-completeness.frontend.helper.js +2 -0
  36. package/dist/esm/core/components-registry/assert-registry-completeness.frontend.helper.js.map +1 -1
  37. package/dist/esm/core/requests/wildo-http-client-manual-calls.frontend.service.d.ts +34 -1
  38. package/dist/esm/core/requests/wildo-http-client-manual-calls.frontend.service.d.ts.map +1 -1
  39. package/dist/esm/core/requests/wildo-http-client-manual-calls.frontend.service.js +41 -0
  40. package/dist/esm/core/requests/wildo-http-client-manual-calls.frontend.service.js.map +1 -1
  41. package/dist/esm/index.d.ts +4 -0
  42. package/dist/esm/index.d.ts.map +1 -1
  43. package/dist/esm/index.js +4 -0
  44. package/dist/esm/index.js.map +1 -1
  45. package/dist/tsconfig.build.tsbuildinfo +1 -1
  46. package/package.json +6 -6
@@ -0,0 +1,97 @@
1
+ import React from 'react';
2
+ import { type ApprovalSealCheckOutcome, type ApprovalSealOnRecordView } from '@wildo-ai/saas-models';
3
+ import type { ComponentPresetProps } from '../../core/components-registry/component-registry.frontend.schemas';
4
+ /** Where the read of a record's approval seal stands. */
5
+ export declare enum ApprovalSealReadState {
6
+ /** Asked, not answered yet. */
7
+ LOADING = "loading",
8
+ /** Answered: `view` says how the record shows its seal. */
9
+ READY = "ready",
10
+ /** The read failed: said so, never shown as a record with no seal. */
11
+ FAILED = "failed"
12
+ }
13
+ /** Where a check of the seal (the public verifier, run on demand) stands. */
14
+ export declare enum ApprovalSealCheckState {
15
+ /** Not asked. */
16
+ IDLE = "idle",
17
+ CHECKING = "checking",
18
+ /** Answered: `checkOutcome` says what the verifier found. */
19
+ DONE = "done",
20
+ /** The check could not be made (the request failed): not a verdict on the seal. */
21
+ FAILED = "failed"
22
+ }
23
+ /**
24
+ * What the preset draws (#2913). Presentational: the wrapper reads the seal, labels the moved fields in the record's own
25
+ * words and runs the actions; the preset never decides what a reader may see, the door already did.
26
+ */
27
+ export interface ApprovalSealProps {
28
+ readonly readState: ApprovalSealReadState;
29
+ /** Present when `readState` is READY. */
30
+ readonly view?: ApprovalSealOnRecordView;
31
+ /** The record's own labels of `view.currency.movedFields`, in the same order. Never their values. */
32
+ readonly movedFieldLabels?: readonly string[];
33
+ /** The approval's meaning, in its vocabulary's words (`system_enums.ApprovalSealMeaning`). */
34
+ readonly meaningLabel?: string;
35
+ /** The decision's outcome, in its vocabulary's words (`system_enums.HumanDecision_Outcome`). */
36
+ readonly outcomeLabel?: string;
37
+ readonly checkState?: ApprovalSealCheckState;
38
+ /** Present when `checkState` is DONE. */
39
+ readonly checkOutcome?: ApprovalSealCheckOutcome;
40
+ /** Runs the public verifier on the seal; offered only for a signed seal. */
41
+ readonly onCheck?: () => void;
42
+ /** Downloads the deliverable's manifested copy; offered only when the seal holds one that can be served. */
43
+ readonly onDownloadManifestedCopy?: () => void;
44
+ readonly downloadingManifestedCopy?: boolean;
45
+ /** What the seal is about, when the surface does not already say it (a decided card: the decision's title). */
46
+ readonly description?: string;
47
+ readonly className?: string;
48
+ }
49
+ /** The preset, resolved from the registry: an application may replace how a seal is drawn. */
50
+ export declare function ApprovalSeal({ preset, ...props }: ApprovalSealProps & ComponentPresetProps): React.JSX.Element;
51
+ export interface RecordApprovalSealProps {
52
+ /**
53
+ * The record's field holding the seal's id (`signOffApprovalSealId`). A top-level field: the door checks that the record
54
+ * stores this seal there, so a seal whose approved effect failed (one the record does not name) is never shown.
55
+ */
56
+ readonly field: string;
57
+ /** Draw nothing when the record names no seal in the field, instead of saying it has none. */
58
+ readonly hideWhenNone?: boolean;
59
+ readonly className?: string;
60
+ }
61
+ /**
62
+ * The approval seal the record on this display surface stores in `field` (#2913): who approved it, when, with what
63
+ * meaning, whether the approval still describes the record, its deliverable's manifested copy and a check of the seal.
64
+ *
65
+ * Place it in a resource's DISPLAY template (`*.ui-behavior.tsx`), where the record and its resource are in context. It
66
+ * asks `GET /approval-seals/:sealId/records/:resourceType/:resourceId/:field`, which admits exactly the readers the
67
+ * record's own READ admits, and asks again when the record changes, since whether the approval is current depends on it.
68
+ * Moved fields are labelled with the record's own field labels; their values are never shown.
69
+ */
70
+ export declare function RecordApprovalSeal({ field, hideWhenNone, className }: RecordApprovalSealProps): React.JSX.Element | null;
71
+ export interface FileApprovalSealProps {
72
+ /** The file a seal may attest: the deliverable a person approved by its hash (a close report's PDF). */
73
+ readonly fileId: string;
74
+ readonly className?: string;
75
+ }
76
+ /**
77
+ * The approval seal that attests a file, under the file (#2913): drawn by `DisplayFieldFile` on a DISPLAY surface, and
78
+ * nothing at all for the many files no seal attests. It asks `GET /approval-seals/files/:fileId`, admitted by the READ
79
+ * of the record the file belongs to, and only for a seal its own record still names (an approval whose effect failed
80
+ * shows nothing). Currency is not drawn here: it is a statement about the record the approval is about.
81
+ */
82
+ export declare function FileApprovalSeal({ fileId, className }: FileApprovalSealProps): React.JSX.Element | null;
83
+ export interface DecisionApprovalSealProps {
84
+ /** The decision the signed-in person just answered. */
85
+ readonly decisionRef: string;
86
+ /** What the decision was about, in the card's own words (the title the inbox showed). */
87
+ readonly description?: string;
88
+ readonly className?: string;
89
+ }
90
+ /**
91
+ * The seal of a decision the signed-in person answered (#2913), for a decision card once it is decided: asked of
92
+ * `GET /approval-seals/decisions/:decisionRef`, which answers the decider only. The seal is signed seconds after the
93
+ * decision, so a PENDING seal is asked again until it is signed (about a minute at most); a decision that sealed nothing
94
+ * draws nothing.
95
+ */
96
+ export declare function DecisionApprovalSeal({ decisionRef, description, className }: DecisionApprovalSealProps): React.JSX.Element | null;
97
+ //# sourceMappingURL=approval-seal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"approval-seal.d.ts","sourceRoot":"","sources":["../../../../src/components/data-display/approval-seal.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmD,MAAM,OAAO,CAAA;AACvE,OAAO,EAML,KAAK,wBAAwB,EAC7B,KAAK,wBAAwB,EAC9B,MAAM,uBAAuB,CAAA;AAG9B,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kFAAkF,CAAA;AAW5H,yDAAyD;AACzD,oBAAY,qBAAqB;IAC/B,+BAA+B;IAC/B,OAAO,YAAY;IACnB,2DAA2D;IAC3D,KAAK,UAAU;IACf,sEAAsE;IACtE,MAAM,WAAW;CAClB;AAED,6EAA6E;AAC7E,oBAAY,sBAAsB;IAChC,iBAAiB;IACjB,IAAI,SAAS;IACb,QAAQ,aAAa;IACrB,6DAA6D;IAC7D,IAAI,SAAS;IACb,mFAAmF;IACnF,MAAM,WAAW;CAClB;AAID;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,SAAS,EAAE,qBAAqB,CAAA;IACzC,yCAAyC;IACzC,QAAQ,CAAC,IAAI,CAAC,EAAE,wBAAwB,CAAA;IACxC,qGAAqG;IACrG,QAAQ,CAAC,gBAAgB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;IAC7C,8FAA8F;IAC9F,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAA;IAC9B,gGAAgG;IAChG,QAAQ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G,KAAK,CAAC,GAAG,CAAC,OAAO,GAAG,IAAI,CAUvG;AAED,MAAM,WAAW,yBAAyB;IACxC,uDAAuD;IACvD,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;IAC5B,yFAAyF;IACzF,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAA;IAC7B,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAC5B;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,EAAE,WAAW,EAAE,WAAW,EAAE,SAAS,EAAE,EAAE,yBAAyB,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,GAAG,IAAI,CAWjI"}
@@ -0,0 +1,208 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useCallback, useEffect, useRef, useState } from 'react';
3
+ import { ApprovalSealOnRecordState, ApprovalSealSchema, CoreResourceType, ErrorType, approvalSealCheckOutcomeOf, } from '@wildo-ai/saas-models';
4
+ import { FrontendComponentType, CorePresetNames } from '@wildo-ai/presets-components-models';
5
+ import { createComponentResolver } from '../../core/components-registry/component-resolver.frontend.helper.js';
6
+ import { getManualCallsHttpClient } from '../../core/requests/wildo-http-client-manual-calls.frontend.service.js';
7
+ import { saveBlobAsFile } from '../../core/commons/save-blob-as-file.frontend.utils.js';
8
+ import { useResourceDisplayContext } from '../../components/data-display/automatic-displayer.utils.js';
9
+ import { useOptionalDisplayTemplateContext } from '../../components/data-display/DisplayTemplateContext.js';
10
+ import { useI18n } from '../../core/i18n/useI18n.js';
11
+ import { isBackendRefusal } from '../../core/errors/backend-refusal.frontend.js';
12
+ /** The seal's own resource, whose fields declare the vocabularies the meaning and the outcome are worded from. */
13
+ const APPROVAL_SEALS = CoreResourceType.APPROVAL_SEALS;
14
+ /** Where the read of a record's approval seal stands. */
15
+ export var ApprovalSealReadState;
16
+ (function (ApprovalSealReadState) {
17
+ /** Asked, not answered yet. */
18
+ ApprovalSealReadState["LOADING"] = "loading";
19
+ /** Answered: `view` says how the record shows its seal. */
20
+ ApprovalSealReadState["READY"] = "ready";
21
+ /** The read failed: said so, never shown as a record with no seal. */
22
+ ApprovalSealReadState["FAILED"] = "failed";
23
+ })(ApprovalSealReadState || (ApprovalSealReadState = {}));
24
+ /** Where a check of the seal (the public verifier, run on demand) stands. */
25
+ export var ApprovalSealCheckState;
26
+ (function (ApprovalSealCheckState) {
27
+ /** Not asked. */
28
+ ApprovalSealCheckState["IDLE"] = "idle";
29
+ ApprovalSealCheckState["CHECKING"] = "checking";
30
+ /** Answered: `checkOutcome` says what the verifier found. */
31
+ ApprovalSealCheckState["DONE"] = "done";
32
+ /** The check could not be made (the request failed): not a verdict on the seal. */
33
+ ApprovalSealCheckState["FAILED"] = "failed";
34
+ })(ApprovalSealCheckState || (ApprovalSealCheckState = {}));
35
+ // --- Wrapper ---
36
+ /** The preset, resolved from the registry: an application may replace how a seal is drawn. */
37
+ export function ApprovalSeal({ preset = CorePresetNames.DEFAULT, ...props }) {
38
+ const Component = createComponentResolver(FrontendComponentType.LOW_LEVEL_APPROVAL_SEAL, 'ApprovalSeal')(preset);
39
+ return _jsx(Component, { ...props });
40
+ }
41
+ /** A stored id as a string; anything else is not an id. */
42
+ function sealIdOf(value) {
43
+ return typeof value === 'string' && value.length > 0 ? value : undefined;
44
+ }
45
+ /** How often, and how many times, a PENDING seal is asked again after a decision (about a minute in all). */
46
+ const PENDING_SEAL_POLL_INTERVAL_MS = 3_000;
47
+ const PENDING_SEAL_POLL_MAX = 20;
48
+ /** Whether a failed read is the door answering "nothing here" (404), never a failure the reader should see. */
49
+ function isNotFound(error) {
50
+ return isBackendRefusal(error) && error.errorType === ErrorType.NOT_FOUND;
51
+ }
52
+ /** The state shared by every seal wrapper: the read, the check, the download. */
53
+ function useApprovalSealView(source) {
54
+ const [read, setRead] = useState({ state: ApprovalSealReadState.LOADING });
55
+ const [none, setNone] = useState(false);
56
+ const [check, setCheck] = useState({ state: ApprovalSealCheckState.IDLE });
57
+ const [downloading, setDownloading] = useState(false);
58
+ const key = source?.key;
59
+ useEffect(() => {
60
+ if (!source)
61
+ return;
62
+ let current = true;
63
+ let polls = 0;
64
+ let timer;
65
+ setRead({ state: ApprovalSealReadState.LOADING });
66
+ setNone(false);
67
+ setCheck({ state: ApprovalSealCheckState.IDLE });
68
+ const ask = () => {
69
+ // Through a promise, so a load that throws before it returns one is a failed read like any other.
70
+ Promise.resolve().then(source.load)
71
+ .then((view) => {
72
+ if (!current)
73
+ return;
74
+ setRead({ state: ApprovalSealReadState.READY, view });
75
+ if (source.pollWhilePending && view.state === ApprovalSealOnRecordState.PENDING && polls < PENDING_SEAL_POLL_MAX) {
76
+ polls += 1;
77
+ timer = setTimeout(ask, PENDING_SEAL_POLL_INTERVAL_MS);
78
+ }
79
+ })
80
+ .catch((error) => {
81
+ if (!current)
82
+ return;
83
+ if (source.notFoundIsNone && isNotFound(error))
84
+ setNone(true);
85
+ else
86
+ setRead({ state: ApprovalSealReadState.FAILED });
87
+ });
88
+ };
89
+ ask();
90
+ return () => { current = false; if (timer)
91
+ clearTimeout(timer); };
92
+ // `key` names what is asked; the source object itself is rebuilt on every render.
93
+ }, [key]);
94
+ const jws = read.view?.jws;
95
+ const onCheck = useCallback(() => {
96
+ if (!jws)
97
+ return;
98
+ setCheck({ state: ApprovalSealCheckState.CHECKING });
99
+ getManualCallsHttpClient().checkApprovalSeal(jws)
100
+ .then((verdict) => setCheck({ state: ApprovalSealCheckState.DONE, outcome: approvalSealCheckOutcomeOf(verdict) }))
101
+ .catch(() => setCheck({ state: ApprovalSealCheckState.FAILED }));
102
+ }, [jws]);
103
+ const onDownloadManifestedCopy = useCallback(() => {
104
+ if (!source?.download)
105
+ return;
106
+ setDownloading(true);
107
+ source.download()
108
+ .then((blob) => saveBlobAsFile(blob, source.downloadName))
109
+ .catch(() => undefined)
110
+ .finally(() => setDownloading(false));
111
+ }, [key]);
112
+ return { read, none, check, onCheck, onDownloadManifestedCopy, downloading };
113
+ }
114
+ /** Draws one seal view through the preset, with the meaning and outcome in their vocabularies' words. */
115
+ function ApprovalSealOf({ state, offersCopy = true, movedFieldLabels, description, className }) {
116
+ const { tResourceFieldEnumValue } = useI18n();
117
+ const { read, check, onCheck, onDownloadManifestedCopy, downloading } = state;
118
+ const view = read.view;
119
+ const shape = ApprovalSealSchema.shape;
120
+ return (_jsx(ApprovalSeal, { readState: read.state, ...(view ? { view } : {}), ...(movedFieldLabels ? { movedFieldLabels } : {}), ...(description ? { description } : {}), ...(view?.meaning ? { meaningLabel: tResourceFieldEnumValue(APPROVAL_SEALS, 'meaning', view.meaning, shape.meaning) } : {}), ...(view?.outcome ? { outcomeLabel: tResourceFieldEnumValue(APPROVAL_SEALS, 'outcome', view.outcome, shape.outcome) } : {}), checkState: check.state, ...(check.outcome ? { checkOutcome: check.outcome } : {}), ...(view?.jws ? { onCheck } : {}), ...(offersCopy && view?.deliverable?.manifestedCopyAvailable ? { onDownloadManifestedCopy, downloadingManifestedCopy: downloading } : {}), ...(className ? { className } : {}) }));
121
+ }
122
+ /**
123
+ * The approval seal the record on this display surface stores in `field` (#2913): who approved it, when, with what
124
+ * meaning, whether the approval still describes the record, its deliverable's manifested copy and a check of the seal.
125
+ *
126
+ * Place it in a resource's DISPLAY template (`*.ui-behavior.tsx`), where the record and its resource are in context. It
127
+ * asks `GET /approval-seals/:sealId/records/:resourceType/:resourceId/:field`, which admits exactly the readers the
128
+ * record's own READ admits, and asks again when the record changes, since whether the approval is current depends on it.
129
+ * Moved fields are labelled with the record's own field labels; their values are never shown.
130
+ */
131
+ export function RecordApprovalSeal({ field, hideWhenNone, className }) {
132
+ const { resourceType, resourceId } = useResourceDisplayContext();
133
+ const template = useOptionalDisplayTemplateContext();
134
+ const record = template?.data;
135
+ const sealId = sealIdOf(record?.[field]);
136
+ const recordVersion = useRecordVersion(record);
137
+ const target = sealId && resourceType && resourceId ? { sealId, resourceType: String(resourceType), resourceId: String(resourceId), field } : undefined;
138
+ const state = useApprovalSealView(target ? {
139
+ // The record is part of what is asked: a value the approval covers may have moved.
140
+ key: `${target.sealId}|${target.resourceType}|${target.resourceId}|${field}|${recordVersion}`,
141
+ load: () => getManualCallsHttpClient().readApprovalSealOnRecord(target),
142
+ download: () => getManualCallsHttpClient().downloadApprovalSealManifestedCopy(target),
143
+ downloadName: `approval-${target.sealId}.pdf`,
144
+ } : undefined);
145
+ if (!record)
146
+ return null;
147
+ if (!target) {
148
+ if (hideWhenNone || !resourceType)
149
+ return null;
150
+ return _jsx(ApprovalSeal, { readState: ApprovalSealReadState.READY, view: { sealId: '', state: ApprovalSealOnRecordState.NO_SEAL }, ...(className ? { className } : {}) });
151
+ }
152
+ const movedFieldLabels = state.read.view?.currency?.movedFields.map((name) => template?.fieldLabels?.[name] ?? name);
153
+ return _jsx(ApprovalSealOf, { state: state, ...(movedFieldLabels ? { movedFieldLabels } : {}), ...(className ? { className } : {}) });
154
+ }
155
+ /** A record's identity in time, so the record's seal is asked again when the record changes. */
156
+ function useRecordVersion(record) {
157
+ const updatedAt = record?.updatedAt;
158
+ const stamp = updatedAt instanceof Date ? updatedAt.toISOString() : typeof updatedAt === 'string' ? updatedAt : '';
159
+ // Without a stamp, the object's identity is the version: a re-read hands a new object.
160
+ const [identity, setIdentity] = useState(0);
161
+ const last = useRef(record);
162
+ useEffect(() => {
163
+ if (last.current !== record) {
164
+ last.current = record;
165
+ if (!stamp)
166
+ setIdentity((value) => value + 1);
167
+ }
168
+ }, [record, stamp]);
169
+ return stamp || String(identity);
170
+ }
171
+ /**
172
+ * The approval seal that attests a file, under the file (#2913): drawn by `DisplayFieldFile` on a DISPLAY surface, and
173
+ * nothing at all for the many files no seal attests. It asks `GET /approval-seals/files/:fileId`, admitted by the READ
174
+ * of the record the file belongs to, and only for a seal its own record still names (an approval whose effect failed
175
+ * shows nothing). Currency is not drawn here: it is a statement about the record the approval is about.
176
+ */
177
+ export function FileApprovalSeal({ fileId, className }) {
178
+ const state = useApprovalSealView({
179
+ key: fileId,
180
+ load: () => getManualCallsHttpClient().readApprovalSealOnFile(fileId),
181
+ download: () => getManualCallsHttpClient().downloadApprovalSealFileManifestedCopy(fileId),
182
+ downloadName: `approval-${fileId}.pdf`,
183
+ notFoundIsNone: true,
184
+ });
185
+ if (state.none || state.read.state === ApprovalSealReadState.LOADING)
186
+ return null;
187
+ return _jsx(ApprovalSealOf, { state: state, ...(className ? { className } : {}) });
188
+ }
189
+ /**
190
+ * The seal of a decision the signed-in person answered (#2913), for a decision card once it is decided: asked of
191
+ * `GET /approval-seals/decisions/:decisionRef`, which answers the decider only. The seal is signed seconds after the
192
+ * decision, so a PENDING seal is asked again until it is signed (about a minute at most); a decision that sealed nothing
193
+ * draws nothing.
194
+ */
195
+ export function DecisionApprovalSeal({ decisionRef, description, className }) {
196
+ const state = useApprovalSealView({
197
+ key: decisionRef,
198
+ load: () => getManualCallsHttpClient().readApprovalSealOfDecision(decisionRef),
199
+ downloadName: `approval-${decisionRef}.pdf`,
200
+ notFoundIsNone: true,
201
+ pollWhilePending: true,
202
+ });
203
+ if (state.none)
204
+ return null;
205
+ // The decider's view offers no copy: the deliverable is the record's, downloaded where the record is read.
206
+ return _jsx(ApprovalSealOf, { state: state, offersCopy: false, ...(description ? { description } : {}), ...(className ? { className } : {}) });
207
+ }
208
+ //# sourceMappingURL=approval-seal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"approval-seal.js","sourceRoot":"","sources":["../../../../src/components/data-display/approval-seal.tsx"],"names":[],"mappings":";AAAA,OAAc,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AACvE,OAAO,EACL,yBAAyB,EACzB,kBAAkB,EAClB,gBAAgB,EAChB,SAAS,EACT,0BAA0B,GAG3B,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAA;AAC5F,OAAO,EAAE,uBAAuB,EAAE,MAAM,iFAAiF,CAAA;AAEzH,OAAO,EAAE,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B,EAAE,IAAI;KACvB,CAAC,CAAA;IACF,IAAI,KAAK,CAAC,IAAI;QAAE,OAAO,IAAI,CAAA;IAC3B,2GAA2G;IAC3G,OAAO,KAAC,cAAc,IAAC,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,KAAM,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,KAAM,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,GAAI,CAAA;AAC5I,CAAC","sourcesContent":["import React, { useCallback, useEffect, useRef, useState } from 'react'\nimport {\n ApprovalSealOnRecordState,\n ApprovalSealSchema,\n CoreResourceType,\n ErrorType,\n approvalSealCheckOutcomeOf,\n type ApprovalSealCheckOutcome,\n type ApprovalSealOnRecordView,\n} from '@wildo-ai/saas-models'\nimport { FrontendComponentType, CorePresetNames } from '@wildo-ai/presets-components-models'\nimport { createComponentResolver } from '~wildo-frontend-lib/core/components-registry/component-resolver.frontend.helper'\nimport type { ComponentPresetProps } from '~wildo-frontend-lib/core/components-registry/component-registry.frontend.schemas'\nimport { getManualCallsHttpClient } from '~wildo-frontend-lib/core/requests/wildo-http-client-manual-calls.frontend.service'\nimport { saveBlobAsFile } from '~wildo-frontend-lib/core/commons/save-blob-as-file.frontend.utils'\nimport { useResourceDisplayContext } from '~wildo-frontend-lib/components/data-display/automatic-displayer.utils'\nimport { useOptionalDisplayTemplateContext } from '~wildo-frontend-lib/components/data-display/DisplayTemplateContext'\nimport { useI18n } from '~wildo-frontend-lib/core/i18n/useI18n'\nimport { isBackendRefusal } from '~wildo-frontend-lib/core/errors/backend-refusal.frontend'\n\n/** The seal's own resource, whose fields declare the vocabularies the meaning and the outcome are worded from. */\nconst APPROVAL_SEALS = CoreResourceType.APPROVAL_SEALS\n\n/** Where the read of a record's approval seal stands. */\nexport enum ApprovalSealReadState {\n /** Asked, not answered yet. */\n LOADING = 'loading',\n /** Answered: `view` says how the record shows its seal. */\n READY = 'ready',\n /** The read failed: said so, never shown as a record with no seal. */\n FAILED = 'failed',\n}\n\n/** Where a check of the seal (the public verifier, run on demand) stands. */\nexport enum ApprovalSealCheckState {\n /** Not asked. */\n IDLE = 'idle',\n CHECKING = 'checking',\n /** Answered: `checkOutcome` says what the verifier found. */\n DONE = 'done',\n /** The check could not be made (the request failed): not a verdict on the seal. */\n FAILED = 'failed',\n}\n\n// --- Contract ---\n\n/**\n * What the preset draws (#2913). Presentational: the wrapper reads the seal, labels the moved fields in the record's own\n * words and runs the actions; the preset never decides what a reader may see, the door already did.\n */\nexport interface ApprovalSealProps {\n readonly readState: ApprovalSealReadState\n /** Present when `readState` is READY. */\n readonly view?: ApprovalSealOnRecordView\n /** The record's own labels of `view.currency.movedFields`, in the same order. Never their values. */\n readonly movedFieldLabels?: readonly string[]\n /** The approval's meaning, in its vocabulary's words (`system_enums.ApprovalSealMeaning`). */\n readonly meaningLabel?: string\n /** The decision's outcome, in its vocabulary's words (`system_enums.HumanDecision_Outcome`). */\n readonly outcomeLabel?: string\n readonly checkState?: ApprovalSealCheckState\n /** Present when `checkState` is DONE. */\n readonly checkOutcome?: ApprovalSealCheckOutcome\n /** Runs the public verifier on the seal; offered only for a signed seal. */\n readonly onCheck?: () => void\n /** Downloads the deliverable's manifested copy; offered only when the seal holds one that can be served. */\n readonly onDownloadManifestedCopy?: () => void\n readonly downloadingManifestedCopy?: boolean\n /** What the seal is about, when the surface does not already say it (a decided card: the decision's title). */\n readonly description?: string\n readonly className?: string\n}\n\n// --- Wrapper ---\n\n/** The preset, resolved from the registry: an application may replace how a seal is drawn. */\nexport function ApprovalSeal({ preset = CorePresetNames.DEFAULT, ...props }: ApprovalSealProps & ComponentPresetProps): React.JSX.Element {\n const Component = createComponentResolver<ApprovalSealProps>(FrontendComponentType.LOW_LEVEL_APPROVAL_SEAL, 'ApprovalSeal')(preset)\n return <Component {...props} />\n}\n\n/** A stored id as a string; anything else is not an id. */\nfunction sealIdOf(value: unknown): string | undefined {\n return typeof value === 'string' && value.length > 0 ? value : undefined\n}\n\nexport interface RecordApprovalSealProps {\n /**\n * The record's field holding the seal's id (`signOffApprovalSealId`). A top-level field: the door checks that the record\n * stores this seal there, so a seal whose approved effect failed (one the record does not name) is never shown.\n */\n readonly field: string\n /** Draw nothing when the record names no seal in the field, instead of saying it has none. */\n readonly hideWhenNone?: boolean\n readonly className?: string\n}\n\n/** How a wrapper reads one seal view, downloads its copy, and whether a missing seal is an answer or a failure. */\ninterface ApprovalSealSource {\n /** Changes when what is asked changes (and, for a record, when the record does). */\n readonly key: string\n readonly load: () => Promise<ApprovalSealOnRecordView>\n /** Absent where the view offers no copy (the decider's view: the deliverable is downloaded where its record is read). */\n readonly download?: () => Promise<Blob>\n readonly downloadName: string\n /** A 404 means \"no seal here\" (a file nothing attests, a decision that sealed nothing): draw nothing, not a failure. */\n readonly notFoundIsNone?: boolean\n /** Ask again while the seal is PENDING: a decision just made is signed seconds later. */\n readonly pollWhilePending?: boolean\n}\n\n/** How often, and how many times, a PENDING seal is asked again after a decision (about a minute in all). */\nconst PENDING_SEAL_POLL_INTERVAL_MS = 3_000\nconst PENDING_SEAL_POLL_MAX = 20\n\n/** Whether a failed read is the door answering \"nothing here\" (404), never a failure the reader should see. */\nfunction isNotFound(error: unknown): boolean {\n return isBackendRefusal(error) && error.errorType === ErrorType.NOT_FOUND\n}\n\n/** The state shared by every seal wrapper: the read, the check, the download. */\nfunction useApprovalSealView(source: ApprovalSealSource | undefined): {\n readonly read: { readonly state: ApprovalSealReadState; readonly view?: ApprovalSealOnRecordView }\n readonly none: boolean\n readonly check: { readonly state: ApprovalSealCheckState; readonly outcome?: ApprovalSealCheckOutcome }\n readonly onCheck: () => void\n readonly onDownloadManifestedCopy: () => void\n readonly downloading: boolean\n} {\n const [read, setRead] = useState<{ readonly state: ApprovalSealReadState; readonly view?: ApprovalSealOnRecordView }>({ state: ApprovalSealReadState.LOADING })\n const [none, setNone] = useState(false)\n const [check, setCheck] = useState<{ readonly state: ApprovalSealCheckState; readonly outcome?: ApprovalSealCheckOutcome }>({ state: ApprovalSealCheckState.IDLE })\n const [downloading, setDownloading] = useState(false)\n const key = source?.key\n\n useEffect(() => {\n if (!source) return\n let current = true\n let polls = 0\n let timer: ReturnType<typeof setTimeout> | undefined\n setRead({ state: ApprovalSealReadState.LOADING })\n setNone(false)\n setCheck({ state: ApprovalSealCheckState.IDLE })\n const ask = (): void => {\n // Through a promise, so a load that throws before it returns one is a failed read like any other.\n Promise.resolve().then(source.load)\n .then((view) => {\n if (!current) return\n setRead({ state: ApprovalSealReadState.READY, view })\n if (source.pollWhilePending && view.state === ApprovalSealOnRecordState.PENDING && polls < PENDING_SEAL_POLL_MAX) {\n polls += 1\n timer = setTimeout(ask, PENDING_SEAL_POLL_INTERVAL_MS)\n }\n })\n .catch((error: unknown) => {\n if (!current) return\n if (source.notFoundIsNone && isNotFound(error)) setNone(true)\n else setRead({ state: ApprovalSealReadState.FAILED })\n })\n }\n ask()\n return () => { current = false; if (timer) clearTimeout(timer) }\n // `key` names what is asked; the source object itself is rebuilt on every render.\n }, [key])\n\n const jws = read.view?.jws\n const onCheck = useCallback(() => {\n if (!jws) return\n setCheck({ state: ApprovalSealCheckState.CHECKING })\n getManualCallsHttpClient().checkApprovalSeal(jws)\n .then((verdict) => setCheck({ state: ApprovalSealCheckState.DONE, outcome: approvalSealCheckOutcomeOf(verdict) }))\n .catch(() => setCheck({ state: ApprovalSealCheckState.FAILED }))\n }, [jws])\n\n const onDownloadManifestedCopy = useCallback(() => {\n if (!source?.download) return\n setDownloading(true)\n source.download()\n .then((blob) => saveBlobAsFile(blob, source.downloadName))\n .catch(() => undefined)\n .finally(() => setDownloading(false))\n }, [key])\n\n return { read, none, check, onCheck, onDownloadManifestedCopy, downloading }\n}\n\n/** Draws one seal view through the preset, with the meaning and outcome in their vocabularies' words. */\nfunction ApprovalSealOf({ state, offersCopy = true, movedFieldLabels, description, className }: {\n readonly state: ReturnType<typeof useApprovalSealView>\n readonly offersCopy?: boolean\n readonly movedFieldLabels?: readonly string[]\n readonly description?: string\n readonly className?: string\n}): React.JSX.Element {\n const { tResourceFieldEnumValue } = useI18n()\n const { read, check, onCheck, onDownloadManifestedCopy, downloading } = state\n const view = read.view\n const shape = ApprovalSealSchema.shape\n return (\n <ApprovalSeal\n readState={read.state}\n {...(view ? { view } : {})}\n {...(movedFieldLabels ? { movedFieldLabels } : {})}\n {...(description ? { description } : {})}\n {...(view?.meaning ? { meaningLabel: tResourceFieldEnumValue(APPROVAL_SEALS, 'meaning', view.meaning, shape.meaning) } : {})}\n {...(view?.outcome ? { outcomeLabel: tResourceFieldEnumValue(APPROVAL_SEALS, 'outcome', view.outcome, shape.outcome) } : {})}\n checkState={check.state}\n {...(check.outcome ? { checkOutcome: check.outcome } : {})}\n {...(view?.jws ? { onCheck } : {})}\n {...(offersCopy && view?.deliverable?.manifestedCopyAvailable ? { onDownloadManifestedCopy, downloadingManifestedCopy: downloading } : {})}\n {...(className ? { className } : {})}\n />\n )\n}\n\n/**\n * The approval seal the record on this display surface stores in `field` (#2913): who approved it, when, with what\n * meaning, whether the approval still describes the record, its deliverable's manifested copy and a check of the seal.\n *\n * Place it in a resource's DISPLAY template (`*.ui-behavior.tsx`), where the record and its resource are in context. It\n * asks `GET /approval-seals/:sealId/records/:resourceType/:resourceId/:field`, which admits exactly the readers the\n * record's own READ admits, and asks again when the record changes, since whether the approval is current depends on it.\n * Moved fields are labelled with the record's own field labels; their values are never shown.\n */\nexport function RecordApprovalSeal({ field, hideWhenNone, className }: RecordApprovalSealProps): React.JSX.Element | null {\n const { resourceType, resourceId } = useResourceDisplayContext()\n const template = useOptionalDisplayTemplateContext()\n const record = template?.data\n const sealId = sealIdOf(record?.[field])\n const recordVersion = useRecordVersion(record)\n const target = sealId && resourceType && resourceId ? { sealId, resourceType: String(resourceType), resourceId: String(resourceId), field } : undefined\n const state = useApprovalSealView(target ? {\n // The record is part of what is asked: a value the approval covers may have moved.\n key: `${target.sealId}|${target.resourceType}|${target.resourceId}|${field}|${recordVersion}`,\n load: () => getManualCallsHttpClient().readApprovalSealOnRecord(target),\n download: () => getManualCallsHttpClient().downloadApprovalSealManifestedCopy(target),\n downloadName: `approval-${target.sealId}.pdf`,\n } : undefined)\n\n if (!record) return null\n if (!target) {\n if (hideWhenNone || !resourceType) return null\n return <ApprovalSeal readState={ApprovalSealReadState.READY} view={{ sealId: '', state: ApprovalSealOnRecordState.NO_SEAL }} {...(className ? { className } : {})} />\n }\n const movedFieldLabels = state.read.view?.currency?.movedFields.map((name) => template?.fieldLabels?.[name] ?? name)\n return <ApprovalSealOf state={state} {...(movedFieldLabels ? { movedFieldLabels } : {})} {...(className ? { className } : {})} />\n}\n\n/** A record's identity in time, so the record's seal is asked again when the record changes. */\nfunction useRecordVersion(record: Record<string, unknown> | undefined): string {\n const updatedAt = record?.updatedAt\n const stamp = updatedAt instanceof Date ? updatedAt.toISOString() : typeof updatedAt === 'string' ? updatedAt : ''\n // Without a stamp, the object's identity is the version: a re-read hands a new object.\n const [identity, setIdentity] = useState(0)\n const last = useRef(record)\n useEffect(() => {\n if (last.current !== record) { last.current = record; if (!stamp) setIdentity((value) => value + 1) }\n }, [record, stamp])\n return stamp || String(identity)\n}\n\nexport interface FileApprovalSealProps {\n /** The file a seal may attest: the deliverable a person approved by its hash (a close report's PDF). */\n readonly fileId: string\n readonly className?: string\n}\n\n/**\n * The approval seal that attests a file, under the file (#2913): drawn by `DisplayFieldFile` on a DISPLAY surface, and\n * nothing at all for the many files no seal attests. It asks `GET /approval-seals/files/:fileId`, admitted by the READ\n * of the record the file belongs to, and only for a seal its own record still names (an approval whose effect failed\n * shows nothing). Currency is not drawn here: it is a statement about the record the approval is about.\n */\nexport function FileApprovalSeal({ fileId, className }: FileApprovalSealProps): React.JSX.Element | null {\n const state = useApprovalSealView({\n key: fileId,\n load: () => getManualCallsHttpClient().readApprovalSealOnFile(fileId),\n download: () => getManualCallsHttpClient().downloadApprovalSealFileManifestedCopy(fileId),\n downloadName: `approval-${fileId}.pdf`,\n notFoundIsNone: true,\n })\n if (state.none || state.read.state === ApprovalSealReadState.LOADING) return null\n return <ApprovalSealOf state={state} {...(className ? { className } : {})} />\n}\n\nexport interface DecisionApprovalSealProps {\n /** The decision the signed-in person just answered. */\n readonly decisionRef: string\n /** What the decision was about, in the card's own words (the title the inbox showed). */\n readonly description?: string\n readonly className?: string\n}\n\n/**\n * The seal of a decision the signed-in person answered (#2913), for a decision card once it is decided: asked of\n * `GET /approval-seals/decisions/:decisionRef`, which answers the decider only. The seal is signed seconds after the\n * decision, so a PENDING seal is asked again until it is signed (about a minute at most); a decision that sealed nothing\n * draws nothing.\n */\nexport function DecisionApprovalSeal({ decisionRef, description, className }: DecisionApprovalSealProps): React.JSX.Element | null {\n const state = useApprovalSealView({\n key: decisionRef,\n load: () => getManualCallsHttpClient().readApprovalSealOfDecision(decisionRef),\n downloadName: `approval-${decisionRef}.pdf`,\n notFoundIsNone: true,\n pollWhilePending: true,\n })\n if (state.none) return null\n // The decider's view offers no copy: the deliverable is the record's, downloaded where the record is read.\n return <ApprovalSealOf state={state} offersCopy={false} {...(description ? { description } : {})} {...(className ? { className } : {})} />\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"display-field-file.d.ts","sourceRoot":"","sources":["../../../../../src/components/data-display/formatters/display-field-file.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAkB,MAAM,OAAO,CAAA;AACtC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAGvB,OAAO,EAAE,oBAAoB,EAAE,MAAM,kFAAkF,CAAA;AAEvH,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,kBAAkB,EAAE,MAAM,0BAA0B,CAAA;AAGlF,UAAU,qBAAqB,CAAC,OAAO,SAAS,CAAC,CAAC,UAAU,GAAG,CAAC,CAAC,UAAU;IACzE,MAAM,EAAE,OAAO,CAAA;IACf,KAAK,EAAE,CAAC,CAAC,K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AG,CAAC,OAAO,CAiBhI"}
1
+ {"version":3,"file":"display-field-file.d.ts","sourceRoot":"","sources":["../../../../../src/components/data-display/formatters/display-field-file.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAkB,MAAM,OAAO,CAAA;AACtC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAGvB,OAAO,EAAE,oBAAoB,EAAE,MAAM,kFAAkF,CAAA;AAEvH,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,kBAAkB,EAAE,MAAM,0BAA0B,CAAA;AAMlF,UAAU,qBAAqB,CAAC,OAAO,SAAS,CAAC,CAAC,UAAU,GAAG,CAAC,CAAC,UAAU;IACzE,MAAM,EAAE,OAAO,CAAA;IACf,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,IAAI,GAAG,SAAS,CAAA;IAC1C,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B,uBAAuB,CAAC,EAAE,OAAO,CAAA;IACjC,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,oBAAoB,CAAC,EAAE,OAAO,CAAA;CAC/B;AAED,MAAM,WAAW,qBAAsB,SAAQ,IAAI,CAAC,qBAAqB,CAAC,CAAC,CAAC,UAAU,CAAC,EAAE,OAAO,CAAC;IAC/F;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,KAAK,EAAE,SAAS,GAAG,IAAI,GAAG,SAAS,CAAA;IAGnC,SAAS,EAAE,IAAI,CAAC,kBAAkB,EAAE,aAAa,GAAG,OAAO,CAAC,CAAA;IAC5D,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,cAAc,CAAC,EAAE;QACf,GAAG,EAAE,CAAC,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC;QAC1C,gEAAgE;QAChE,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;YAAE,MAAM,CAAC,EAAE,WAAW,CAAA;SAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;KAC9E,CAAA;CACF;AAGD;;;;;;;;;GASG;AACH,KAAK,4BAA4B,GAAG,IAAI,CAAC,qBAAqB,EAAE,gBAAgB,CAAC,GAAG,oBAAoB,CAAA;AAExG,wBAAgB,gBAAgB,CAAC,EAAE,MAAgC,EAAE,GAAG,KAAK,EAAE,EAAE,4BAA4B,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CAgChI"}
@@ -1,8 +1,11 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useMemo } from 'react';
3
3
  import { createComponentResolver } from '../../../core/components-registry/component-resolver.frontend.helper.js';
4
4
  import { FrontendComponentType, CorePresetNames } from '@wildo-ai/presets-components-models';
5
5
  import { useApplication } from '../../../core/runtime/useApplication.js';
6
+ import { FileApprovalSeal } from '../../../components/data-display/approval-seal.js';
7
+ import { DisplayContextKind, useDisplayContextKind } from '../../../components/data-display/DisplayContextKindContext.js';
8
+ import { useOptionalDisplayTemplateContext } from '../../../components/data-display/DisplayTemplateContext.js';
6
9
  export function DisplayFieldFile({ preset = CorePresetNames.DEFAULT, ...props }) {
7
10
  const { httpClient } = useApplication();
8
11
  const httpOperations = useMemo(() => ({
@@ -17,6 +20,17 @@ export function DisplayFieldFile({ preset = CorePresetNames.DEFAULT, ...props })
17
20
  },
18
21
  }), [httpClient]);
19
22
  const Component = createComponentResolver(FrontendComponentType.LOW_LEVEL_DISPLAY_FIELD_FILE, 'DisplayFieldFile')(preset);
20
- return _jsx(Component, { ...props, httpOperations: httpOperations });
23
+ // #2913: on a record's DISPLAY surface, the approval seal that attests this file (the deliverable a person approved by
24
+ // its hash), drawn under it. Not on a SUMMARY (a list card would ask once per row) nor outside a display template; a
25
+ // file no seal attests draws nothing, since the door answers it exactly as a file the reader may not read.
26
+ const displayKind = useDisplayContextKind();
27
+ const template = useOptionalDisplayTemplateContext();
28
+ const sealed = displayKind === DisplayContextKind.DISPLAY && template !== null;
29
+ // A single file only: a field holding several (`fileIds`) is not a deliverable a seal binds.
30
+ const single = props.value && 'fileId' in props.value ? props.value.fileId : undefined;
31
+ const fileId = typeof single === 'string' && single.length > 0 ? single : undefined;
32
+ if (!sealed || !fileId)
33
+ return _jsx(Component, { ...props, httpOperations: httpOperations });
34
+ return (_jsxs(_Fragment, { children: [_jsx(Component, { ...props, httpOperations: httpOperations }), _jsx(FileApprovalSeal, { fileId: fileId })] }));
21
35
  }
22
36
  //# sourceMappingURL=display-field-file.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"display-field-file.js","sourceRoot":"","sources":["../../../../../src/components/data-display/formatters/display-field-file.tsx"],"names":[],"mappings":";AAAA,OAAc,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAEtC,OAAO,EAAE,uBAAuB,EAAE,MAAM,iFAAiF,CAAA;AACzH,OAAO,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAA;AAE5F,OAAO,EAAE,cAAc,EAAE,MAAM,iDAAiD,CAAA;AAiDhF,MAAM,UAAU,gBAAgB,CAAC,EAAE,MAAM,GAAG,eAAe,CAAC,OAAO,EAAE,GAAG,KAAK,EAAgC;IAC3G,MAAM,EAAE,UAAU,EAAE,GAAG,cAAc,EAAE,CAAA;IAEvC,MAAM,cAAc,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;QACpC,GAAG,EAAE,KAAK,EAAM,GAAW,EAAc,EAAE;YACzC,OAAO,UAAU,CAAC,GAAG,CAAI,GAAG,CAAC,CAAA;QAC/B,CAAC;QACD,8EAA8E;QAC9E,+EAA+E;QAC/E,gFAAgF;QAChF,OAAO,EAAE,CAAC,GAAW,EAAE,OAAkC,EAAiB,EAAE;YAC1E,OAAO,UAAU,CAAC,aAAa,CAAC,GAAG,EAAE,OAAO,CAAC,CAAA;QAC/C,CAAC;KACF,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC,CAAA;IAEjB,MAAM,SAAS,GAAG,uBAAuB,CAAwB,qBAAqB,CAAC,4BAA4B,EAAE,kBAAkB,CAAC,CAAC,MAAM,CAAC,CAAA;IAChJ,OAAO,KAAC,SAAS,OAAK,KAAK,EAAE,cAAc,EAAE,cAAc,GAAI,CAAA;AACjE,CAAC","sourcesContent":["import React, { useMemo } from 'react'\nimport { z } from 'zod'\nimport { createComponentResolver } from '~wildo-frontend-lib/core/components-registry/component-resolver.frontend.helper'\nimport { FrontendComponentType, CorePresetNames } from '@wildo-ai/presets-components-models'\nimport { ComponentPresetProps } from '~wildo-frontend-lib/core/components-registry/component-registry.frontend.schemas'\nimport { useApplication } from '~wildo-frontend-lib/core/runtime/useApplication'\nimport { type FileValue, type FileFieldEndpoints } from '@wildo-ai/zod-decorators'\n\n// --- Contract ---\ninterface DisplayFieldBaseProps<TSchema extends z.ZodTypeAny = z.ZodTypeAny> {\n schema: TSchema\n value: z.infer<TSchema> | null | undefined\n label?: string\n description?: string\n className?: string\n forceDisplayLabel?: boolean\n forceDisplayDescription?: boolean\n forceHideLabel?: boolean\n forceHideDescription?: boolean\n}\n\nexport interface DisplayFieldFileProps extends Omit<DisplayFieldBaseProps<z.ZodTypeAny>, 'value'> {\n /**\n * Resolved field path as rendered. Travels with a `FileActivationPolicy.CUSTOM`\n * activation so the dispatched operation knows WHICH field's file was activated.\n */\n fieldName?: string\n value: FileValue | null | undefined\n // `getMetadata` loads file metadata; `serve` is the resource-integrated authenticated\n // byte-serve base for inline previews (the consumer appends `/{fileId}`).\n endpoints: Pick<FileFieldEndpoints, 'getMetadata' | 'serve'>\n showSize?: boolean\n showType?: boolean\n showDownload?: boolean\n httpOperations?: {\n get: <T = any>(url: string) => Promise<T>;\n /** Authenticated byte fetch for inline previews (image/PDF). */\n getBlob?: (url: string, options?: { signal?: AbortSignal }) => Promise<Blob>;\n }\n}\n\n// --- Wrapper ---\n/**\n * Schema-aware DisplayFieldFile component.\n *\n * This wrapper sits between DisplayField and the preset component.\n * It injects authenticated HTTP operations from the app's HTTP client,\n * following the same pattern as the FormFieldFile wrapper.\n *\n * Without this, the preset would use raw `fetch` for metadata requests,\n * bypassing auth headers, retry logic, and centralized error handling.\n */\ntype DisplayFieldFileWrapperProps = Omit<DisplayFieldFileProps, 'httpOperations'> & ComponentPresetProps\n\nexport function DisplayFieldFile({ preset = CorePresetNames.DEFAULT, ...props }: DisplayFieldFileWrapperProps): React.JSX.Element {\n const { httpClient } = useApplication()\n\n const httpOperations = useMemo(() => ({\n get: async <T,>(url: string): Promise<T> => {\n return httpClient.get<T>(url)\n },\n // Authenticated byte fetch for inline previews (image/PDF): the browser can't\n // attach the bearer to an <img>/embed src, so we fetch the bytes and wrap them\n // in an object URL. The backend serve route authorizes via the linked resource.\n getBlob: (url: string, options?: { signal?: AbortSignal }): Promise<Blob> => {\n return httpClient.fetchFileBlob(url, options)\n },\n }), [httpClient])\n\n const Component = createComponentResolver<DisplayFieldFileProps>(FrontendComponentType.LOW_LEVEL_DISPLAY_FIELD_FILE, 'DisplayFieldFile')(preset)\n return <Component {...props} httpOperations={httpOperations} />\n}\n"]}
1
+ {"version":3,"file":"display-field-file.js","sourceRoot":"","sources":["../../../../../src/components/data-display/formatters/display-field-file.tsx"],"names":[],"mappings":";AAAA,OAAc,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAEtC,OAAO,EAAE,uBAAuB,EAAE,MAAM,iFAAiF,CAAA;AACzH,OAAO,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAA;AAE5F,OAAO,EAAE,cAAc,EAAE,MAAM,iDAAiD,CAAA;AAEhF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A;IACtF,MAAM,MAAM,GAAG,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAA;IACnF,IAAI,CAAC,MAAM,IAAI,CAAC,MAAM;QAAE,OAAO,KAAC,SAAS,OAAK,KAAK,EAAE,cAAc,EAAE,cAAc,GAAI,CAAA;IACvF,OAAO,CACL,8BACE,KAAC,SAAS,OAAK,KAAK,EAAE,cAAc,EAAE,cAAc,GAAI,EACxD,KAAC,gBAAgB,IAAC,MAAM,EAAE,MAAM,GAAI,IACnC,CACJ,CAAA;AACH,CAAC","sourcesContent":["import React, { useMemo } from 'react'\nimport { z } from 'zod'\nimport { createComponentResolver } from '~wildo-frontend-lib/core/components-registry/component-resolver.frontend.helper'\nimport { FrontendComponentType, CorePresetNames } from '@wildo-ai/presets-components-models'\nimport { ComponentPresetProps } from '~wildo-frontend-lib/core/components-registry/component-registry.frontend.schemas'\nimport { useApplication } from '~wildo-frontend-lib/core/runtime/useApplication'\nimport { type FileValue, type FileFieldEndpoints } from '@wildo-ai/zod-decorators'\nimport { FileApprovalSeal } from '~wildo-frontend-lib/components/data-display/approval-seal'\nimport { DisplayContextKind, useDisplayContextKind } from '~wildo-frontend-lib/components/data-display/DisplayContextKindContext'\nimport { useOptionalDisplayTemplateContext } from '~wildo-frontend-lib/components/data-display/DisplayTemplateContext'\n\n// --- Contract ---\ninterface DisplayFieldBaseProps<TSchema extends z.ZodTypeAny = z.ZodTypeAny> {\n schema: TSchema\n value: z.infer<TSchema> | null | undefined\n label?: string\n description?: string\n className?: string\n forceDisplayLabel?: boolean\n forceDisplayDescription?: boolean\n forceHideLabel?: boolean\n forceHideDescription?: boolean\n}\n\nexport interface DisplayFieldFileProps extends Omit<DisplayFieldBaseProps<z.ZodTypeAny>, 'value'> {\n /**\n * Resolved field path as rendered. Travels with a `FileActivationPolicy.CUSTOM`\n * activation so the dispatched operation knows WHICH field's file was activated.\n */\n fieldName?: string\n value: FileValue | null | undefined\n // `getMetadata` loads file metadata; `serve` is the resource-integrated authenticated\n // byte-serve base for inline previews (the consumer appends `/{fileId}`).\n endpoints: Pick<FileFieldEndpoints, 'getMetadata' | 'serve'>\n showSize?: boolean\n showType?: boolean\n showDownload?: boolean\n httpOperations?: {\n get: <T = any>(url: string) => Promise<T>;\n /** Authenticated byte fetch for inline previews (image/PDF). */\n getBlob?: (url: string, options?: { signal?: AbortSignal }) => Promise<Blob>;\n }\n}\n\n// --- Wrapper ---\n/**\n * Schema-aware DisplayFieldFile component.\n *\n * This wrapper sits between DisplayField and the preset component.\n * It injects authenticated HTTP operations from the app's HTTP client,\n * following the same pattern as the FormFieldFile wrapper.\n *\n * Without this, the preset would use raw `fetch` for metadata requests,\n * bypassing auth headers, retry logic, and centralized error handling.\n */\ntype DisplayFieldFileWrapperProps = Omit<DisplayFieldFileProps, 'httpOperations'> & ComponentPresetProps\n\nexport function DisplayFieldFile({ preset = CorePresetNames.DEFAULT, ...props }: DisplayFieldFileWrapperProps): React.JSX.Element {\n const { httpClient } = useApplication()\n\n const httpOperations = useMemo(() => ({\n get: async <T,>(url: string): Promise<T> => {\n return httpClient.get<T>(url)\n },\n // Authenticated byte fetch for inline previews (image/PDF): the browser can't\n // attach the bearer to an <img>/embed src, so we fetch the bytes and wrap them\n // in an object URL. The backend serve route authorizes via the linked resource.\n getBlob: (url: string, options?: { signal?: AbortSignal }): Promise<Blob> => {\n return httpClient.fetchFileBlob(url, options)\n },\n }), [httpClient])\n\n const Component = createComponentResolver<DisplayFieldFileProps>(FrontendComponentType.LOW_LEVEL_DISPLAY_FIELD_FILE, 'DisplayFieldFile')(preset)\n // #2913: on a record's DISPLAY surface, the approval seal that attests this file (the deliverable a person approved by\n // its hash), drawn under it. Not on a SUMMARY (a list card would ask once per row) nor outside a display template; a\n // file no seal attests draws nothing, since the door answers it exactly as a file the reader may not read.\n const displayKind = useDisplayContextKind()\n const template = useOptionalDisplayTemplateContext()\n const sealed = displayKind === DisplayContextKind.DISPLAY && template !== null\n // A single file only: a field holding several (`fileIds`) is not a deliverable a seal binds.\n const single = props.value && 'fileId' in props.value ? props.value.fileId : undefined\n const fileId = typeof single === 'string' && single.length > 0 ? single : undefined\n if (!sealed || !fileId) return <Component {...props} httpOperations={httpOperations} />\n return (\n <>\n <Component {...props} httpOperations={httpOperations} />\n <FileApprovalSeal fileId={fileId} />\n </>\n )\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"approval.d.ts","sourceRoot":"","sources":["../../../../src/components/flows-actors/approval.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAIL,KAAK,2BAA2B,EAEhC,KAAK,uBAAuB,EAC5B,KAAK,qBAAqB,EAE1B,KAAK,mBAAmB,EACzB,MAAM,8DAA8D,CAAC;AACtE,OAAO,EACL,iCAAiC,EACjC,2BAA2B,EAQ3B,2BAA2B,EAY3B,KAAK,yBAAyB,EAC9B,KAAK,qBAAqB,EAC3B,MAAM,uBAAuB,CAAC;AA6E/B;;;;;;;GAOG;AACH,wBAAgB,yBAAyB,CACvC,WAAW,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,EAC1C,WAAW,EAAE,CAAC,QAAQ,EAAE,OAAO,iCAAiC,EAAE,SAAS,EAAE,MAAM,KAAK,MAAM,GAC7F,2BAA2B,EAAE,GAAG,SAAS,CAG3C;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAChC,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,CAAC,QAAQ,EAAE,2BAA2B,CAAC,0BAA0B,EAAE,SAAS,EAAE,MAAM,KAAK,MAAM,GAC3G,MAAM,CAER;AAiBD,MAAM,MAAM,gCAAgC,GAAG,IAAI,CACjD,uBAAuB,EACvB,YAAY,GAAG,mBAAmB,GAAG,WAAW,GAAG,WAAW,GAAG,QAAQ,GAAG,YAAY,GAAG,YAAY,CACxG,GAAG;IACF,WAAW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AY,GAAG,SAAS,CAC3D,CAAC;AAoCF;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,CAAC,SAAS;IAAE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;CAAE,EAAE,KAAK,EAAE,SAAS,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,EAAE,CAKtI;AAED,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,8BAA8B,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CAqKlG"}
@@ -1,13 +1,16 @@
1
1
  "use client";
2
- import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import * as React from "react";
4
4
  import { AI_ApprovalRequest, AI_ApprovalQueue, } from "../../components/ai-elements/decision/approval.js";
5
- import { AGENT_WORK_REASON_CODE_VOCABULARY, ApplicationConfigVocabulary, FlowsActorsToolLabelSlot, flowsActorsToolLabelKey, flowsActorsToolLabelScope, HumanDecision_Act, HumanDecision_ActOutcomeKind, HumanDecision_Plane, HumanDecision_RefusalReason, HumanDecision_RequesterKind, HumanDecision_RouteKind, HumanDecisionPhraseKind, HUMAN_DECISION_INBOX_FOCUS_PARAM, HUMAN_DECISION_VERDICT_OPTIONS_BY_PLANE, ReviewDeadlineKind, describeHumanDecisionCard, humanDecisionAsksItsOwnQuestion, humanDecisionOptionPhrase, } from "@wildo-ai/saas-models";
5
+ import { AGENT_WORK_REASON_CODE_VOCABULARY, ApplicationConfigVocabulary, FlowsActorsToolLabelSlot, flowsActorsToolLabelKey, flowsActorsToolLabelScope, HumanDecision_Act, HumanDecision_ActOutcomeKind, HumanDecision_Plane, HumanDecision_RefusalReason, HumanDecision_RequesterKind, HumanDecision_RouteKind, HumanDecisionPhraseKind, HUMAN_DECISION_INBOX_FOCUS_PARAM, HUMAN_DECISION_VERDICT_OPTIONS_BY_PLANE, ReviewDeadlineKind, describeHumanDecisionCard, humanDecisionAsksItsOwnQuestion, humanDecisionOptionPhrase, humanDecisionPresentedRowsOf, } from "@wildo-ai/saas-models";
6
6
  import { PendingDecisionsReadState, usePendingDecisions } from "../../core/flows-actors/usePendingDecisions.js";
7
7
  import { useFlowsActors } from "../../core/flows-actors/useFlowsActors.js";
8
8
  import { FrontendComponentType, LabellingTypes, ResourceOperationTextSlot } from "@wildo-ai/presets-components-models";
9
9
  import { useI18n } from "../../core/i18n/useI18n.js";
10
10
  import { describeApprovalModificationRefusal } from "../../components/flows-actors/approval-modification-refusal.utils.js";
11
+ import { DecisionApprovalSeal } from "../../components/data-display/approval-seal.js";
12
+ /** How many decisions answered in this inbox keep their seal shown under it, newest first (#2913). */
13
+ const DECIDED_SEALS_SHOWN = 5;
11
14
  //===============================================================
12
15
  // Flows-Actors Approval Wrappers
13
16
  //
@@ -103,6 +106,12 @@ const NO_OPERATION_RESOURCES = [];
103
106
  export function FlowsActors_ApprovalRequest({ executionId, ...props }) {
104
107
  const { executions, respondToApproval, answerQuestion } = useFlowsActors();
105
108
  const [processingId, setProcessingId] = React.useState(null);
109
+ /**
110
+ * #2913: the decision this card answered, kept once the card's pending decision clears so the card shows its seal in
111
+ * its place. `shown` is what the card showed when it was answered: its decision and its title.
112
+ */
113
+ const [answered, setAnswered] = React.useState(null);
114
+ const shown = React.useRef(null);
106
115
  const execution = executions.get(executionId);
107
116
  const pendingApproval = execution?.pendingApproval;
108
117
  // The paused tool's title is loaded with the card's own words, so the card names the call as the inbox does.
@@ -114,11 +123,13 @@ export function FlowsActors_ApprovalRequest({ executionId, ...props }) {
114
123
  // review F1).
115
124
  const handleApprove = React.useCallback((id, comment, modifiedToolArgs, reasonCode) => {
116
125
  setProcessingId(id);
126
+ setAnswered(shown.current);
117
127
  // The reason rides only when given, so an answer without one keeps the call shape it always had.
118
128
  respondToApproval(executionId, id, true, comment, modifiedToolArgs, ...(reasonCode ? [reasonCode] : []));
119
129
  }, [executionId, respondToApproval]);
120
130
  const handleDeny = React.useCallback((id, comment, reasonCode) => {
121
131
  setProcessingId(id);
132
+ setAnswered(shown.current);
122
133
  if (reasonCode)
123
134
  respondToApproval(executionId, id, false, comment, undefined, reasonCode);
124
135
  else
@@ -127,6 +138,7 @@ export function FlowsActors_ApprovalRequest({ executionId, ...props }) {
127
138
  // #2720: the agent's QUESTION is answered with the person's values, or declined — never approved.
128
139
  const handleAnswer = React.useCallback((id, optionRef, values, comment) => {
129
140
  setProcessingId(id);
141
+ setAnswered(shown.current);
130
142
  answerQuestion(executionId, optionRef, values, comment);
131
143
  }, [executionId, answerQuestion]);
132
144
  const approvalWord = React.useCallback((labelRef) => tComponent(FrontendComponentType.LOW_LEVEL_AI_APPROVAL, labelRef), [tComponent]);
@@ -136,8 +148,11 @@ export function FlowsActors_ApprovalRequest({ executionId, ...props }) {
136
148
  React.useEffect(() => {
137
149
  setProcessingId(null);
138
150
  }, [pendingApproval]);
139
- if (!execution || !pendingApproval)
140
- return null;
151
+ if (!execution || !pendingApproval) {
152
+ // Answered here and gone from the pending state: the seal of that answer, signed seconds later (#2913). A decision that
153
+ // sealed nothing (or one answered by someone else) answers 404, and the card draws nothing, as before.
154
+ return answered ? _jsx(DecisionApprovalSeal, { decisionRef: answered.decisionRef, description: answered.title }) : null;
155
+ }
141
156
  const { approvalId, riskLevel, expiresAt, toolName, toolArgs, toolInputSchema, modificationRefusal, rejectedToolArgs, routeKind, reasonCodes, reasonCodeRefused, question, presentation, } = pendingApproval;
142
157
  /*
143
158
  * The card's title, in this reader's words (#3201): the decision's presentation when the server sealed one, else the
@@ -146,6 +161,7 @@ export function FlowsActors_ApprovalRequest({ executionId, ...props }) {
146
161
  * built from the tool's IDENTIFIER and rendered here as written, is gone from the announcement.
147
162
  */
148
163
  const actionDescription = wordHumanDecisionPhrase(presentation?.title ?? describeHumanDecisionCard({ plane: HumanDecision_Plane.CONVERSATIONAL, toolName: toolName ?? '' }).title, t, roleLabel, toolLabel, operationLabel);
164
+ shown.current = pendingApproval.decisionRef ? { decisionRef: pendingApproval.decisionRef, title: actionDescription } : null;
149
165
  /*
150
166
  * Only an OWNER-routed decision is answered here. One routed to an assignee or a role is answered by a
151
167
  * reviewer from their inbox, and the person whose conversation this is may not answer it (separation of
@@ -179,7 +195,8 @@ export function FlowsActors_ApprovalRequest({ executionId, ...props }) {
179
195
  // The call's line names the tool by its title, as the card's title does (#3201).
180
196
  toolLabel: toolName ? toolLabel(toolName) : undefined, executionContext: toolArgs,
181
197
  // #2903: the arguments as the server presented them, rendered verbatim: what the person reads is what is sealed.
182
- presentedArguments: pendingApproval.presentation?.fields, argumentsSchema: toolInputSchema,
198
+ // #2914: then the values of the record the approval covers, which the seal binds too.
199
+ presentedArguments: pendingApproval.presentation ? humanDecisionPresentedRowsOf(pendingApproval.presentation) : undefined, argumentsSchema: toolInputSchema,
183
200
  // The refusal in the approval's own labels, naming the tool and the offending arguments (#1186).
184
201
  argumentModificationError: modificationRefusal
185
202
  ? describeApprovalModificationRefusal(modificationRefusal, (labelRef, params) => tComponent(FrontendComponentType.LOW_LEVEL_AI_APPROVAL, labelRef, params))
@@ -262,7 +279,8 @@ operationLabel = (resourceType, operationIdentifier) => `${LabellingTypes.RESOUR
262
279
  */
263
280
  function describeInboxCard(card, t, roleLabel = (roleKey) => roleKey, toolLabel = (toolName) => toolName, operationLabel) {
264
281
  // #2903: the values as the server presented them, rendered verbatim, so what the reviewer reads is what is sealed.
265
- const presented = card.presentation ? { presentedArguments: card.presentation.fields } : {};
282
+ // #2914: with the values of the record the approval covers.
283
+ const presented = card.presentation ? { presentedArguments: humanDecisionPresentedRowsOf(card.presentation) } : {};
266
284
  const actionDescription = wordHumanDecisionPhrase(card.presentation?.title ?? describeHumanDecisionCard(card).title, t, roleLabel, toolLabel, operationLabel);
267
285
  // #2288: an operation approval shows the values the requester sent, as a tool approval shows its arguments.
268
286
  if (card.plane === HumanDecision_Plane.OPERATION_APPROVAL && card.operationApproval) {
@@ -355,10 +373,21 @@ export function FlowsActors_ApprovalQueue(props) {
355
373
  const [processing, setProcessing] = React.useState(() => new Set());
356
374
  const [notices, setNotices] = React.useState(() => new Map());
357
375
  const [reassignCandidates, setReassignCandidates] = React.useState(() => new Map());
376
+ /**
377
+ * #2913: the decisions this person answered here. An answered card leaves the pending list, so its seal is shown under
378
+ * the list instead: signed seconds after the answer, then current or not over the record it is about. Each keeps the
379
+ * title its card showed, read from `cardTitles` when the answer was sent.
380
+ */
381
+ const [decided, setDecided] = React.useState([]);
382
+ const cardTitles = React.useRef(new Map());
358
383
  const run = React.useCallback(async (decisionRef, decisionAct, request) => {
359
384
  setProcessing((previous) => new Set(previous).add(decisionRef));
385
+ const title = cardTitles.current.get(decisionRef);
360
386
  try {
361
387
  const outcome = await act(decisionRef, decisionAct, request);
388
+ if (decisionAct === HumanDecision_Act.ANSWER && outcome.kind === HumanDecision_ActOutcomeKind.APPLIED) {
389
+ setDecided((previous) => [{ decisionRef, ...(title ? { title } : {}) }, ...previous.filter((entry) => entry.decisionRef !== decisionRef)].slice(0, DECIDED_SEALS_SHOWN));
390
+ }
362
391
  const notice = noticeOfOutcome(outcome, t);
363
392
  setNotices((previous) => {
364
393
  const next = new Map(previous);
@@ -420,6 +449,7 @@ export function FlowsActors_ApprovalQueue(props) {
420
449
  allowArgumentModification: card.plane === HumanDecision_Plane.CONVERSATIONAL,
421
450
  argumentsSchema: card.toolInputSchema,
422
451
  })), [decisions, reassignCandidates, notices, t, roleLabel, toolLabel, operationLabel, tSystemEnum, formatDateTime]);
452
+ cardTitles.current = new Map(items.flatMap((item) => (typeof item.actionDescription === 'string' ? [[item.approvalId, item.actionDescription]] : [])));
423
453
  /**
424
454
  * An answer in the one answer shape: the option chosen, and no values. Which option refs "approve" and "deny" mean
425
455
  * depends on the decision's plane — a tool approval's, or a representative admission's (#1612) — so the card decides.
@@ -456,17 +486,17 @@ export function FlowsActors_ApprovalQueue(props) {
456
486
  people.map((person) => ({ value: person.userId, label: person.email ?? person.userId })))))
457
487
  .catch(() => setReassignCandidates((previous) => new Map(previous).set(decisionRef, [])));
458
488
  }, [candidates]);
459
- return (_jsx(AI_ApprovalQueue, { items: items, onApprove: (decisionRef, comment, modifiedToolArgs, reasonCode) => answer(decisionRef, true, comment, modifiedToolArgs, reasonCode), onDeny: (decisionRef, comment, reasonCode) => answer(decisionRef, false, comment, undefined, reasonCode), onEscalate: (decisionRef, comment) => void run(decisionRef, HumanDecision_Act.ESCALATE, comment ? { reason: comment } : {}),
460
- // #2526: the option the reviewer chose and the values it carries, in the one answer shape the server checks against
461
- // the decision's own request (an option it never offered, or values an option does not take, is refused).
462
- onAnswer: (decisionRef, optionRef, values, comment, reasonCode) => void run(decisionRef, HumanDecision_Act.ANSWER, {
463
- answer: { decisionId: decisionRef, optionRef, values: [...values] },
464
- ...presentationEchoOf(decisions, decisionRef),
465
- ...(comment ? { reason: comment } : {}),
466
- // #2539: an actor question that reviews an agent's work may carry a declared reason, as a tool approval does.
467
- ...(reasonCode ? { reasonCode } : {}),
468
- }), onClaim: (decisionRef) => void run(decisionRef, HumanDecision_Act.CLAIM, {}), onUnclaim: (decisionRef) => void run(decisionRef, HumanDecision_Act.UNCLAIM, {}), onReassignOpen: handleReassignOpen, onReassign: (decisionRef, targetUserId, comment) => void run(decisionRef, HumanDecision_Act.REASSIGN, { targetUserId, ...(comment ? { reason: comment } : {}) }), onPauseClock: (decisionRef, pauseStateRef) => void run(decisionRef, HumanDecision_Act.PAUSE_CLOCK, { pauseStateRef }), onResumeClock: (decisionRef) => void run(decisionRef, HumanDecision_Act.RESUME_CLOCK, {}), processingIds: processing,
469
- // #2526: a read still settling, and a read that failed, are states the inbox SHOWS — never an empty inbox.
470
- isLoading: readState === PendingDecisionsReadState.LOADING, loadFailed: readState === PendingDecisionsReadState.FAILED, onRetry: () => { void refresh(); }, ...props }));
489
+ return (_jsxs(_Fragment, { children: [_jsx(AI_ApprovalQueue, { items: items, onApprove: (decisionRef, comment, modifiedToolArgs, reasonCode) => answer(decisionRef, true, comment, modifiedToolArgs, reasonCode), onDeny: (decisionRef, comment, reasonCode) => answer(decisionRef, false, comment, undefined, reasonCode), onEscalate: (decisionRef, comment) => void run(decisionRef, HumanDecision_Act.ESCALATE, comment ? { reason: comment } : {}),
490
+ // #2526: the option the reviewer chose and the values it carries, in the one answer shape the server checks against
491
+ // the decision's own request (an option it never offered, or values an option does not take, is refused).
492
+ onAnswer: (decisionRef, optionRef, values, comment, reasonCode) => void run(decisionRef, HumanDecision_Act.ANSWER, {
493
+ answer: { decisionId: decisionRef, optionRef, values: [...values] },
494
+ ...presentationEchoOf(decisions, decisionRef),
495
+ ...(comment ? { reason: comment } : {}),
496
+ // #2539: an actor question that reviews an agent's work may carry a declared reason, as a tool approval does.
497
+ ...(reasonCode ? { reasonCode } : {}),
498
+ }), onClaim: (decisionRef) => void run(decisionRef, HumanDecision_Act.CLAIM, {}), onUnclaim: (decisionRef) => void run(decisionRef, HumanDecision_Act.UNCLAIM, {}), onReassignOpen: handleReassignOpen, onReassign: (decisionRef, targetUserId, comment) => void run(decisionRef, HumanDecision_Act.REASSIGN, { targetUserId, ...(comment ? { reason: comment } : {}) }), onPauseClock: (decisionRef, pauseStateRef) => void run(decisionRef, HumanDecision_Act.PAUSE_CLOCK, { pauseStateRef }), onResumeClock: (decisionRef) => void run(decisionRef, HumanDecision_Act.RESUME_CLOCK, {}), processingIds: processing,
499
+ // #2526: a read still settling, and a read that failed, are states the inbox SHOWS — never an empty inbox.
500
+ isLoading: readState === PendingDecisionsReadState.LOADING, loadFailed: readState === PendingDecisionsReadState.FAILED, onRetry: () => { void refresh(); }, ...props }), decided.map((entry) => (_jsx(DecisionApprovalSeal, { decisionRef: entry.decisionRef, ...(entry.title ? { description: entry.title } : {}) }, entry.decisionRef)))] }));
471
501
  }
472
502
  //# sourceMappingURL=approval.js.map