@astra-spec/ui 0.0.5 → 0.0.6
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/README.md +47 -4
- package/blocks.css +1 -0
- package/components.css +6 -0
- package/dist/blocks/analysis-tree.d.ts.map +1 -1
- package/dist/blocks/analysis-tree.js +4 -7
- package/dist/blocks/analysis-tree.js.map +1 -1
- package/dist/blocks/decisions-list.d.ts.map +1 -1
- package/dist/blocks/decisions-list.js +1 -1
- package/dist/blocks/decisions-list.js.map +1 -1
- package/dist/blocks/findings-list.d.ts.map +1 -1
- package/dist/blocks/findings-list.js +2 -4
- package/dist/blocks/findings-list.js.map +1 -1
- package/dist/blocks/index.d.ts +2 -4
- package/dist/blocks/index.d.ts.map +1 -1
- package/dist/blocks/index.js +1 -2
- package/dist/blocks/index.js.map +1 -1
- package/dist/blocks/outputs-list.d.ts +2 -7
- package/dist/blocks/outputs-list.d.ts.map +1 -1
- package/dist/blocks/outputs-list.js +11 -21
- package/dist/blocks/outputs-list.js.map +1 -1
- package/dist/blocks/papers-list.d.ts.map +1 -1
- package/dist/blocks/papers-list.js +3 -3
- package/dist/blocks/papers-list.js.map +1 -1
- package/dist/components/figure-zoom.d.ts +6 -0
- package/dist/components/figure-zoom.d.ts.map +1 -0
- package/dist/components/figure-zoom.js +28 -0
- package/dist/components/figure-zoom.js.map +1 -0
- package/dist/components/finding-detail.d.ts +4 -2
- package/dist/components/finding-detail.d.ts.map +1 -1
- package/dist/components/finding-detail.js +41 -25
- package/dist/components/finding-detail.js.map +1 -1
- package/dist/components/index.d.ts +9 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +5 -0
- package/dist/components/index.js.map +1 -1
- package/dist/components/output-card.d.ts +13 -0
- package/dist/components/output-card.d.ts.map +1 -0
- package/dist/components/output-card.js +12 -0
- package/dist/components/output-card.js.map +1 -0
- package/dist/components/output-detail.d.ts +6 -2
- package/dist/components/output-detail.d.ts.map +1 -1
- package/dist/components/output-detail.js +49 -13
- package/dist/components/output-detail.js.map +1 -1
- package/dist/components/output-dialog.d.ts +6 -1
- package/dist/components/output-dialog.d.ts.map +1 -1
- package/dist/components/output-dialog.js +2 -2
- package/dist/components/output-dialog.js.map +1 -1
- package/dist/components/output-entry.d.ts +17 -0
- package/dist/components/output-entry.d.ts.map +1 -0
- package/dist/components/output-entry.js +21 -0
- package/dist/components/output-entry.js.map +1 -0
- package/dist/components/output-provenance.d.ts +6 -0
- package/dist/components/output-provenance.d.ts.map +1 -0
- package/dist/components/output-provenance.js +16 -0
- package/dist/components/output-provenance.js.map +1 -0
- package/dist/components/output-status.d.ts +8 -0
- package/dist/components/output-status.d.ts.map +1 -0
- package/dist/components/output-status.js +17 -0
- package/dist/components/output-status.js.map +1 -0
- package/dist/components/paper-row.d.ts +9 -0
- package/dist/components/paper-row.d.ts.map +1 -0
- package/dist/components/paper-row.js +11 -0
- package/dist/components/paper-row.js.map +1 -0
- package/dist/components/record-dialog.d.ts +5 -1
- package/dist/components/record-dialog.d.ts.map +1 -1
- package/dist/components/record-dialog.js +7 -4
- package/dist/components/record-dialog.js.map +1 -1
- package/dist/lib/labels.d.ts +34 -2
- package/dist/lib/labels.d.ts.map +1 -1
- package/dist/lib/labels.js +35 -4
- package/dist/lib/labels.js.map +1 -1
- package/dist/model/index.d.ts +4 -2
- package/dist/model/index.d.ts.map +1 -1
- package/dist/model/index.js +1 -1
- package/dist/model/index.js.map +1 -1
- package/dist/model/kind.d.ts +1 -1
- package/dist/model/kind.d.ts.map +1 -1
- package/dist/model/kind.js +0 -1
- package/dist/model/kind.js.map +1 -1
- package/dist/model/output-provenance.d.ts +17 -0
- package/dist/model/output-provenance.d.ts.map +1 -0
- package/dist/model/output-provenance.js +2 -0
- package/dist/model/output-provenance.js.map +1 -0
- package/dist/model/output-status.d.ts +17 -0
- package/dist/model/output-status.d.ts.map +1 -0
- package/dist/model/output-status.js +2 -0
- package/dist/model/output-status.js.map +1 -0
- package/dist/model/relations.d.ts +37 -12
- package/dist/model/relations.d.ts.map +1 -1
- package/dist/model/relations.js +76 -23
- package/dist/model/relations.js.map +1 -1
- package/dist/primitives/dialog.d.ts.map +1 -1
- package/dist/primitives/dialog.js +9 -1
- package/dist/primitives/dialog.js.map +1 -1
- package/dist/primitives/index.d.ts +2 -0
- package/dist/primitives/index.d.ts.map +1 -1
- package/dist/primitives/index.js +1 -0
- package/dist/primitives/index.js.map +1 -1
- package/dist/primitives/output-status-glyph.d.ts +8 -0
- package/dist/primitives/output-status-glyph.d.ts.map +1 -0
- package/dist/primitives/output-status-glyph.js +13 -0
- package/dist/primitives/output-status-glyph.js.map +1 -0
- package/dist/primitives/tooltip.d.ts +7 -0
- package/dist/primitives/tooltip.d.ts.map +1 -0
- package/dist/primitives/tooltip.js +31 -0
- package/dist/primitives/tooltip.js.map +1 -0
- package/dist/views/inventory.d.ts +12 -1
- package/dist/views/inventory.d.ts.map +1 -1
- package/dist/views/inventory.js +23 -17
- package/dist/views/inventory.js.map +1 -1
- package/package.json +3 -2
- package/primitives.css +1 -0
- package/src/blocks/analysis-tree.tsx +4 -30
- package/src/blocks/decisions-list.tsx +5 -3
- package/src/blocks/findings-list.tsx +8 -7
- package/src/blocks/index.ts +2 -4
- package/src/blocks/outputs-list.tsx +43 -106
- package/src/blocks/papers-list.tsx +2 -18
- package/src/components/figure-zoom.tsx +72 -0
- package/src/components/finding-detail.tsx +106 -30
- package/src/components/index.ts +13 -0
- package/src/components/output-card.tsx +51 -0
- package/src/components/output-detail.tsx +69 -21
- package/src/components/output-dialog.tsx +9 -0
- package/src/components/output-entry.tsx +61 -0
- package/src/components/output-provenance.tsx +86 -0
- package/src/components/output-status.tsx +38 -0
- package/src/components/paper-row.tsx +41 -0
- package/src/components/record-dialog.tsx +13 -1
- package/src/lib/labels.tsx +69 -6
- package/src/model/index.ts +6 -2
- package/src/model/kind.ts +1 -2
- package/src/model/output-provenance.ts +18 -0
- package/src/model/output-status.ts +18 -0
- package/src/model/relations.ts +92 -26
- package/src/primitives/dialog.tsx +7 -1
- package/src/primitives/index.ts +2 -0
- package/src/primitives/output-status-glyph.tsx +37 -0
- package/src/primitives/tooltip.tsx +51 -0
- package/src/views/inventory.tsx +54 -22
- package/styles/base.css +2 -1
- package/styles/blocks/analysis-tree.css +22 -25
- package/styles/blocks/findings-list.css +50 -0
- package/styles/blocks/outputs-list.css +0 -421
- package/styles/blocks/papers-list.css +4 -70
- package/styles/components/figure-zoom.css +62 -0
- package/styles/components/finding-detail.css +62 -0
- package/styles/components/output-card.css +290 -0
- package/styles/components/output-detail.css +91 -3
- package/styles/components/output-entry.css +141 -0
- package/styles/components/output-provenance.css +94 -0
- package/styles/components/output-status.css +31 -0
- package/styles/components/paper-row.css +72 -0
- package/styles/primitives/dialog.css +4 -22
- package/styles/primitives/tooltip.css +22 -0
- package/styles/views/inventory.css +35 -2
- package/dist/blocks/prior-insights-list.d.ts +0 -9
- package/dist/blocks/prior-insights-list.d.ts.map +0 -1
- package/dist/blocks/prior-insights-list.js +0 -29
- package/dist/blocks/prior-insights-list.js.map +0 -1
- package/src/blocks/prior-insights-list.tsx +0 -52
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { ResolvedOutput } from '@astra-spec/sdk';
|
|
2
|
+
import { forwardRef, type HTMLAttributes } from 'react';
|
|
3
|
+
import type { OutputStatus } from '../model/output-status.js';
|
|
4
|
+
import { OutputStatusIndicator } from './output-status.js';
|
|
5
|
+
import { recordTitle } from '../model/records.js';
|
|
6
|
+
import { cn } from '../lib/cn.js';
|
|
7
|
+
import type { ArtifactRenderer } from './artifact-preview.js';
|
|
8
|
+
import { OutputPreview } from './output-detail.js';
|
|
9
|
+
|
|
10
|
+
export interface OutputCardProps extends Omit<HTMLAttributes<HTMLButtonElement>, 'children'> {
|
|
11
|
+
output: ResolvedOutput;
|
|
12
|
+
status?: OutputStatus | undefined;
|
|
13
|
+
renderArtifact?: ArtifactRenderer | undefined;
|
|
14
|
+
onOpen: () => void;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** A gallery card: compact preview and title, with a type label for non-figures. */
|
|
18
|
+
export const OutputCard = forwardRef<HTMLButtonElement, OutputCardProps>(function OutputCard({
|
|
19
|
+
output,
|
|
20
|
+
status,
|
|
21
|
+
renderArtifact,
|
|
22
|
+
onOpen,
|
|
23
|
+
className,
|
|
24
|
+
onClick,
|
|
25
|
+
'aria-label': hostLabel,
|
|
26
|
+
...props
|
|
27
|
+
}, ref) {
|
|
28
|
+
const title = recordTitle(output);
|
|
29
|
+
return (
|
|
30
|
+
<button
|
|
31
|
+
data-slot="output-card"
|
|
32
|
+
{...props}
|
|
33
|
+
ref={ref}
|
|
34
|
+
type="button"
|
|
35
|
+
className={cn('astra-output-card', className)}
|
|
36
|
+
aria-label={hostLabel ?? `Open ${output.type}: ${title}`}
|
|
37
|
+
onClick={(event) => { onClick?.(event); onOpen(); }}
|
|
38
|
+
>
|
|
39
|
+
<OutputStatusIndicator status={status} />
|
|
40
|
+
<span className="astra-output-card__preview">
|
|
41
|
+
<OutputPreview output={output} compact renderArtifact={renderArtifact} />
|
|
42
|
+
<span className="astra-output-card__open" aria-hidden="true">Open ↗</span>
|
|
43
|
+
</span>
|
|
44
|
+
<span className="astra-output-card__body">
|
|
45
|
+
{output.type !== 'figure' ? <span className="astra-output-card__kind">{output.type}</span> : null}
|
|
46
|
+
<strong>{title}</strong>
|
|
47
|
+
{output.label ? <code>{output.id}</code> : null}
|
|
48
|
+
</span>
|
|
49
|
+
</button>
|
|
50
|
+
);
|
|
51
|
+
});
|
|
@@ -10,6 +10,7 @@ import { Prose } from '../primitives/prose.js';
|
|
|
10
10
|
import type { TextRenderer } from '../lib/prose.js';
|
|
11
11
|
import { RelationList } from '../primitives/relation-list.js';
|
|
12
12
|
import { relationItemsForLinks } from './relation-items.js';
|
|
13
|
+
import { FigureZoom } from './figure-zoom.js';
|
|
13
14
|
import type { OpenRecordHandler } from '../lib/detail-stack.js';
|
|
14
15
|
|
|
15
16
|
export interface OutputPreviewProps {
|
|
@@ -26,19 +27,28 @@ export function OutputPreview({ output, compact = false, renderArtifact }: Outpu
|
|
|
26
27
|
}
|
|
27
28
|
|
|
28
29
|
/**
|
|
29
|
-
* What the detail shows in its artifact box:
|
|
30
|
-
*
|
|
31
|
-
*
|
|
30
|
+
* What the detail shows in its artifact box: only a figure or a table has a
|
|
31
|
+
* picture to frame, rendered by the host when it supplies a renderer. A data
|
|
32
|
+
* file or a metric gets no box — an empty reader column is all whitespace —
|
|
33
|
+
* so the host renderer is not consulted for them here; `OutputPreview` still
|
|
34
|
+
* asks it for the compact preview of any type, and a metric's value is asked
|
|
35
|
+
* for as a compact rendering below.
|
|
32
36
|
*/
|
|
33
37
|
function artifactNode(output: ResolvedOutput, renderArtifact: ArtifactRenderer | undefined): ReactNode {
|
|
34
|
-
if (
|
|
35
|
-
return
|
|
38
|
+
if (!isVisualOutput(output)) return null;
|
|
39
|
+
return renderArtifact
|
|
40
|
+
? renderArtifact(output, { compact: false })
|
|
41
|
+
: <ArtifactPreview output={output} compact={false} />;
|
|
36
42
|
}
|
|
37
43
|
|
|
38
44
|
export interface OutputDetailProps extends Omit<HTMLAttributes<HTMLDivElement>, 'children'> {
|
|
39
45
|
record: ResolvedOutput;
|
|
40
46
|
relations: OutputRelations;
|
|
41
47
|
renderArtifact?: ArtifactRenderer | undefined;
|
|
48
|
+
/** Recorded execution information, shown below Recipe. */
|
|
49
|
+
renderProvenance?: ((output: ResolvedOutput) => ReactNode) | undefined;
|
|
50
|
+
/** Host-provided link to the current code file, shown beside Recipe. */
|
|
51
|
+
renderCodeLink?: ((output: ResolvedOutput) => ReactNode) | undefined;
|
|
42
52
|
renderText?: TextRenderer | undefined;
|
|
43
53
|
onOpenRecord?: OpenRecordHandler | undefined;
|
|
44
54
|
/** Full-screen artifact state (controlled). */
|
|
@@ -46,11 +56,42 @@ export interface OutputDetailProps extends Omit<HTMLAttributes<HTMLDivElement>,
|
|
|
46
56
|
onExpandedChange?: ((expanded: boolean) => void) | undefined;
|
|
47
57
|
}
|
|
48
58
|
|
|
59
|
+
/**
|
|
60
|
+
* One decision per row. A decision the output declares reads plainly; one it
|
|
61
|
+
* inherits says which upstream output carries it, so a list that mixes the two
|
|
62
|
+
* still shows where each came from.
|
|
63
|
+
*/
|
|
64
|
+
function decisionDependencyItems(relations: OutputRelations, onOpenRecord: OpenRecordHandler | undefined) {
|
|
65
|
+
return relationItemsForLinks(relations.decisions, onOpenRecord).map((item, index) => {
|
|
66
|
+
const via = relations.decisions[index]?.via;
|
|
67
|
+
const origins = via?.map(({ record, canonicalPath }) => record ? recordTitle(record) : canonicalPath);
|
|
68
|
+
if (!origins?.length) return item;
|
|
69
|
+
const detail = `via ${origins.join(', ')}`;
|
|
70
|
+
return {
|
|
71
|
+
...item,
|
|
72
|
+
// The truncated text is for sighted readers; assistive technology gets
|
|
73
|
+
// the full list, whether or not the row becomes a navigation trigger
|
|
74
|
+
// (only a trigger carries `accessibleLabel`).
|
|
75
|
+
detail: origins.length > 1
|
|
76
|
+
? (
|
|
77
|
+
<span title={detail}>
|
|
78
|
+
<span aria-hidden="true">via {origins[0]} +{origins.length - 1} more</span>
|
|
79
|
+
<span className="astra-output-detail__visually-hidden">{detail}</span>
|
|
80
|
+
</span>
|
|
81
|
+
)
|
|
82
|
+
: detail,
|
|
83
|
+
accessibleLabel: item.accessibleLabel ? `${item.accessibleLabel}, ${detail}` : undefined,
|
|
84
|
+
};
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
|
|
49
88
|
/** Artifact preview with provenance: description, recipe, alias, decisions, and inputs. */
|
|
50
89
|
export const OutputDetail = forwardRef<HTMLDivElement, OutputDetailProps>(function OutputDetail({
|
|
51
90
|
record: output,
|
|
52
91
|
relations,
|
|
53
92
|
renderArtifact,
|
|
93
|
+
renderProvenance,
|
|
94
|
+
renderCodeLink,
|
|
54
95
|
renderText,
|
|
55
96
|
onOpenRecord,
|
|
56
97
|
expanded = false,
|
|
@@ -60,6 +101,10 @@ export const OutputDetail = forwardRef<HTMLDivElement, OutputDetailProps>(functi
|
|
|
60
101
|
}, ref) {
|
|
61
102
|
const labels = useLabels();
|
|
62
103
|
const artifact = artifactNode(output, renderArtifact);
|
|
104
|
+
// A metric's whole artifact is one number: it reads as a pill at the head of
|
|
105
|
+
// the provenance, above the description, not as a figure stretched across a
|
|
106
|
+
// reader column.
|
|
107
|
+
const metric = output.type === 'metric' ? renderArtifact?.(output, { compact: true }) : null;
|
|
63
108
|
// Reader layout (artifact column + details rail) only when there is an
|
|
64
109
|
// artifact to frame: a host renderer may opt out of a figure or table by
|
|
65
110
|
// returning null, and the details then take the single column instead.
|
|
@@ -110,6 +155,12 @@ export const OutputDetail = forwardRef<HTMLDivElement, OutputDetailProps>(functi
|
|
|
110
155
|
|
|
111
156
|
const supportingDetails = (
|
|
112
157
|
<aside className="astra-output-detail__provenance" aria-label="Output provenance and dependencies">
|
|
158
|
+
{metric ? (
|
|
159
|
+
<section className="astra-output-detail__metric">
|
|
160
|
+
<h4>Metric</h4>
|
|
161
|
+
<div className="astra-output-detail__metric-pill">{metric}</div>
|
|
162
|
+
</section>
|
|
163
|
+
) : null}
|
|
113
164
|
{output.description ? (
|
|
114
165
|
<section className="astra-output-detail__description">
|
|
115
166
|
<h4>Description</h4>
|
|
@@ -129,17 +180,9 @@ export const OutputDetail = forwardRef<HTMLDivElement, OutputDetailProps>(functi
|
|
|
129
180
|
<RelationList
|
|
130
181
|
className="astra-detail__relations"
|
|
131
182
|
title="Decision dependencies"
|
|
132
|
-
items={
|
|
133
|
-
empty="No
|
|
183
|
+
items={decisionDependencyItems(relations, onOpenRecord)}
|
|
184
|
+
empty="No decisions affect this output."
|
|
134
185
|
/>
|
|
135
|
-
{relations.indirectDecisions?.length ? (
|
|
136
|
-
<RelationList
|
|
137
|
-
className="astra-detail__relations"
|
|
138
|
-
title="Indirect decision dependencies"
|
|
139
|
-
items={relationItemsForLinks(relations.indirectDecisions, onOpenRecord)}
|
|
140
|
-
empty={null}
|
|
141
|
-
/>
|
|
142
|
-
) : null}
|
|
143
186
|
<RelationList
|
|
144
187
|
className="astra-detail__relations"
|
|
145
188
|
title="Inputs and upstream outputs"
|
|
@@ -150,13 +193,17 @@ export const OutputDetail = forwardRef<HTMLDivElement, OutputDetailProps>(functi
|
|
|
150
193
|
/>
|
|
151
194
|
{output.recipe?.command ? (
|
|
152
195
|
<section className="astra-output-detail__recipe">
|
|
153
|
-
<
|
|
196
|
+
<div className="astra-output-detail__recipe-heading">
|
|
197
|
+
<h4>Recipe</h4>
|
|
198
|
+
{renderCodeLink?.(output)}
|
|
199
|
+
</div>
|
|
154
200
|
<pre><code>{output.recipe.command}</code></pre>
|
|
155
201
|
{output.recipe.container
|
|
156
202
|
? <p>Container: <code>{output.recipe.container}</code></p>
|
|
157
203
|
: null}
|
|
158
204
|
</section>
|
|
159
205
|
) : null}
|
|
206
|
+
{renderProvenance?.(output)}
|
|
160
207
|
</aside>
|
|
161
208
|
);
|
|
162
209
|
|
|
@@ -191,7 +238,9 @@ export const OutputDetail = forwardRef<HTMLDivElement, OutputDetailProps>(functi
|
|
|
191
238
|
</div>
|
|
192
239
|
) : null}
|
|
193
240
|
<div className="astra-output-detail__preview" data-type={output.type}>
|
|
194
|
-
{
|
|
241
|
+
{output.type === 'figure'
|
|
242
|
+
? <FigureZoom key={output.canonicalPath}>{artifact}</FigureZoom>
|
|
243
|
+
: artifact}
|
|
195
244
|
</div>
|
|
196
245
|
</div>
|
|
197
246
|
) : null}
|
|
@@ -209,10 +258,10 @@ export interface OutputDialogActionsProps {
|
|
|
209
258
|
onExpandedChange: (expanded: boolean) => void;
|
|
210
259
|
}
|
|
211
260
|
|
|
212
|
-
/** Header actions
|
|
261
|
+
/** Header actions: open the artifact in the host, or expand a table. */
|
|
213
262
|
export function OutputDialogActions({ record: output, onOpenArtifact, expanded, onExpandedChange }: OutputDialogActionsProps) {
|
|
214
263
|
const labels = useLabels();
|
|
215
|
-
const
|
|
264
|
+
const canExpand = output.type === 'table';
|
|
216
265
|
return (
|
|
217
266
|
<>
|
|
218
267
|
{onOpenArtifact && output.artifact ? (
|
|
@@ -221,7 +270,7 @@ export function OutputDialogActions({ record: output, onOpenArtifact, expanded,
|
|
|
221
270
|
<span>{labels.actions.openArtifact}</span>
|
|
222
271
|
</DialogAction>
|
|
223
272
|
) : null}
|
|
224
|
-
{
|
|
273
|
+
{canExpand ? (
|
|
225
274
|
<DialogAction
|
|
226
275
|
aria-label={`View ${output.type} full screen`}
|
|
227
276
|
aria-expanded={expanded}
|
|
@@ -234,4 +283,3 @@ export function OutputDialogActions({ record: output, onOpenArtifact, expanded,
|
|
|
234
283
|
</>
|
|
235
284
|
);
|
|
236
285
|
}
|
|
237
|
-
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
1
2
|
import type { ResolvedOutput } from '@astra-spec/sdk';
|
|
2
3
|
import type { OutputRelations } from '../model/relations.js';
|
|
3
4
|
import { isVisualOutput, recordTitle } from '../model/records.js';
|
|
@@ -13,6 +14,10 @@ export interface OutputDialogProps extends Pick<DetailDialogProps, 'mode' | 'bac
|
|
|
13
14
|
record: ResolvedOutput;
|
|
14
15
|
relations: OutputRelations;
|
|
15
16
|
renderArtifact?: ArtifactRenderer | undefined;
|
|
17
|
+
/** Host renderer for recorded output provenance, shown below Recipe. */
|
|
18
|
+
renderProvenance?: ((output: ResolvedOutput) => ReactNode) | undefined;
|
|
19
|
+
/** Host-provided link to the current code file, shown beside Recipe. */
|
|
20
|
+
renderCodeLink?: ((output: ResolvedOutput) => ReactNode) | undefined;
|
|
16
21
|
renderText?: TextRenderer | undefined;
|
|
17
22
|
onOpenArtifact?: ((output: ResolvedOutput) => void | Promise<void>) | undefined;
|
|
18
23
|
onOpenRecord?: OpenRecordHandler | undefined;
|
|
@@ -24,6 +29,8 @@ export function OutputDialog({
|
|
|
24
29
|
record: output,
|
|
25
30
|
relations,
|
|
26
31
|
renderArtifact,
|
|
32
|
+
renderProvenance,
|
|
33
|
+
renderCodeLink,
|
|
27
34
|
renderText,
|
|
28
35
|
onOpenArtifact,
|
|
29
36
|
onOpenRecord,
|
|
@@ -54,6 +61,8 @@ export function OutputDialog({
|
|
|
54
61
|
record={output}
|
|
55
62
|
relations={relations}
|
|
56
63
|
renderArtifact={renderArtifact}
|
|
64
|
+
renderProvenance={renderProvenance}
|
|
65
|
+
renderCodeLink={renderCodeLink}
|
|
57
66
|
renderText={renderText}
|
|
58
67
|
onOpenRecord={onOpenRecord}
|
|
59
68
|
expanded={expanded}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { ResolvedOutput } from '@astra-spec/sdk';
|
|
2
|
+
import { forwardRef, type HTMLAttributes } from 'react';
|
|
3
|
+
import type { OutputStatus } from '../model/output-status.js';
|
|
4
|
+
import { OutputStatusIndicator } from './output-status.js';
|
|
5
|
+
import { recordTitle } from '../model/records.js';
|
|
6
|
+
import { cn } from '../lib/cn.js';
|
|
7
|
+
import type { ArtifactRenderer } from './artifact-preview.js';
|
|
8
|
+
|
|
9
|
+
export interface OutputEntryProps extends Omit<HTMLAttributes<HTMLButtonElement>, 'children'> {
|
|
10
|
+
output: ResolvedOutput;
|
|
11
|
+
status?: OutputStatus | undefined;
|
|
12
|
+
renderArtifact?: ArtifactRenderer | undefined;
|
|
13
|
+
onOpen: () => void;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* One output at a glance, for the types a gallery card would waste space on: a
|
|
18
|
+
* metric reads as its value over its name, anything else as its name. The row
|
|
19
|
+
* it wraps in decides how a run of these is laid out.
|
|
20
|
+
*/
|
|
21
|
+
export const OutputEntry = forwardRef<HTMLButtonElement, OutputEntryProps>(function OutputEntry({
|
|
22
|
+
output,
|
|
23
|
+
status,
|
|
24
|
+
renderArtifact,
|
|
25
|
+
onOpen,
|
|
26
|
+
className,
|
|
27
|
+
onClick,
|
|
28
|
+
'aria-label': hostLabel,
|
|
29
|
+
...props
|
|
30
|
+
}, ref) {
|
|
31
|
+
const title = recordTitle(output);
|
|
32
|
+
const metric = output.type === 'metric';
|
|
33
|
+
// Why the document itself has nothing to show, before any host status.
|
|
34
|
+
const absenceNote = !output.active ? 'Inactive' : !output.artifact ? 'Not yet generated' : undefined;
|
|
35
|
+
return (
|
|
36
|
+
<button
|
|
37
|
+
data-slot="output-entry"
|
|
38
|
+
{...props}
|
|
39
|
+
ref={ref}
|
|
40
|
+
type="button"
|
|
41
|
+
className={cn('astra-output-entry', className)}
|
|
42
|
+
data-kind={metric ? 'metric' : 'file'}
|
|
43
|
+
aria-label={hostLabel ?? `Open ${output.type}: ${title}`}
|
|
44
|
+
onClick={(event) => { onClick?.(event); onOpen(); }}
|
|
45
|
+
>
|
|
46
|
+
<OutputStatusIndicator status={status} />
|
|
47
|
+
<span className="astra-output-entry__name">
|
|
48
|
+
{title}
|
|
49
|
+
{!metric && absenceNote && !status ? <span className="astra-output-entry__status">{absenceNote}</span> : null}
|
|
50
|
+
</span>
|
|
51
|
+
{metric ? (
|
|
52
|
+
<span className="astra-output-entry__value">
|
|
53
|
+
{status?.state === 'stale' && !output.artifact
|
|
54
|
+
? <span className="astra-artifact__metric-value" aria-label="No value">–</span>
|
|
55
|
+
: renderArtifact?.(output, { compact: true })
|
|
56
|
+
?? <span className="astra-output-entry__status">{absenceNote ?? 'Preview unavailable'}</span>}
|
|
57
|
+
</span>
|
|
58
|
+
) : null}
|
|
59
|
+
</button>
|
|
60
|
+
);
|
|
61
|
+
});
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { forwardRef, useState, type HTMLAttributes } from 'react';
|
|
2
|
+
import { cn } from '../lib/cn.js';
|
|
3
|
+
import { useLabels } from '../lib/labels.js';
|
|
4
|
+
import type { OutputProvenanceData } from '../model/output-provenance.js';
|
|
5
|
+
import { DetailDialog } from '../primitives/dialog.js';
|
|
6
|
+
import { OutputStatusGlyph } from '../primitives/output-status-glyph.js';
|
|
7
|
+
|
|
8
|
+
export type OutputProvenanceProps = HTMLAttributes<HTMLDivElement> & OutputProvenanceData;
|
|
9
|
+
|
|
10
|
+
/** Compact run summary with the full execution metadata in a detail dialog. */
|
|
11
|
+
export const OutputProvenance = forwardRef<HTMLDivElement, OutputProvenanceProps>(function OutputProvenance({
|
|
12
|
+
status, run, error, className, ...props
|
|
13
|
+
}, ref) {
|
|
14
|
+
const labels = useLabels();
|
|
15
|
+
const copy = labels.provenance;
|
|
16
|
+
const [detailsOpen, setDetailsOpen] = useState(false);
|
|
17
|
+
const stateLabel = status ? labels.status[status.state] : copy.unknown;
|
|
18
|
+
const finished = run ? new Date(run.finishedAt) : null;
|
|
19
|
+
return (
|
|
20
|
+
<div data-slot="output-provenance" {...props} ref={ref} className={cn('astra-output-provenance', className)}>
|
|
21
|
+
<div className="astra-output-provenance__heading">
|
|
22
|
+
<h4>{copy.title}</h4>
|
|
23
|
+
{run ? <button type="button" aria-haspopup="dialog" onClick={() => { setDetailsOpen(true); }}>{copy.details}</button> : null}
|
|
24
|
+
</div>
|
|
25
|
+
<dl className="astra-output-provenance__summary">
|
|
26
|
+
<div>
|
|
27
|
+
<dt>{copy.status}</dt>
|
|
28
|
+
<dd>
|
|
29
|
+
<span className="astra-output-provenance__status">
|
|
30
|
+
{status ? (
|
|
31
|
+
<span className="astra-output-provenance__icon" data-state={status.state} aria-hidden="true">
|
|
32
|
+
<OutputStatusGlyph state={status.state} />
|
|
33
|
+
</span>
|
|
34
|
+
) : null}
|
|
35
|
+
{stateLabel}
|
|
36
|
+
</span>
|
|
37
|
+
{status?.detail ? <p className="astra-output-provenance__reason">{status.detail}</p> : null}
|
|
38
|
+
</dd>
|
|
39
|
+
</div>
|
|
40
|
+
{run ? <>
|
|
41
|
+
<div>
|
|
42
|
+
<dt>{copy.lastRun}</dt>
|
|
43
|
+
<dd><time dateTime={run.finishedAt}>{finished && !Number.isNaN(finished.getTime()) ? finished.toLocaleString() : run.finishedAt}</time></dd>
|
|
44
|
+
</div>
|
|
45
|
+
<div>
|
|
46
|
+
<dt>{copy.revision}</dt>
|
|
47
|
+
<dd><code title={run.gitRevision}>{run.gitRevision.slice(0, 8)}</code></dd>
|
|
48
|
+
</div>
|
|
49
|
+
</> : null}
|
|
50
|
+
</dl>
|
|
51
|
+
{error ? <p role="alert">{error}</p> : run === undefined ? <p role="status">{copy.loading}</p> : run === null ? <p>{copy.noRun}</p> : null}
|
|
52
|
+
{detailsOpen && run ? (
|
|
53
|
+
<DetailDialog
|
|
54
|
+
mode="modal"
|
|
55
|
+
title={copy.runDetails}
|
|
56
|
+
closeLabel={copy.closeDetails}
|
|
57
|
+
onClose={() => { setDetailsOpen(false); }}
|
|
58
|
+
panelClassName="astra-output-provenance__dialog-panel"
|
|
59
|
+
>
|
|
60
|
+
<div className="astra-output-provenance__details">
|
|
61
|
+
<section>
|
|
62
|
+
<h4>{copy.recipe}</h4>
|
|
63
|
+
<pre><code>{run.recipe}</code></pre>
|
|
64
|
+
</section>
|
|
65
|
+
<section>
|
|
66
|
+
<h4>{copy.inputs}</h4>
|
|
67
|
+
{Object.keys(run.inputVersions).length ? (
|
|
68
|
+
<dl>{Object.entries(run.inputVersions).map(([name, version]) => (
|
|
69
|
+
<div key={name}><dt>{name}</dt><dd><code>{version}</code></dd></div>
|
|
70
|
+
))}</dl>
|
|
71
|
+
) : <p>{copy.noInputs}</p>}
|
|
72
|
+
</section>
|
|
73
|
+
<section>
|
|
74
|
+
<h4>{copy.environment}</h4>
|
|
75
|
+
<p><code>{run.environment}</code></p>
|
|
76
|
+
</section>
|
|
77
|
+
<section>
|
|
78
|
+
<h4>{copy.cliVersion}</h4>
|
|
79
|
+
<p>{run.cliVersion}</p>
|
|
80
|
+
</section>
|
|
81
|
+
</div>
|
|
82
|
+
</DetailDialog>
|
|
83
|
+
) : null}
|
|
84
|
+
</div>
|
|
85
|
+
);
|
|
86
|
+
});
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { forwardRef, type HTMLAttributes } from 'react';
|
|
2
|
+
import { Tooltip } from '../primitives/tooltip.js';
|
|
3
|
+
import { OutputStatusGlyph } from '../primitives/output-status-glyph.js';
|
|
4
|
+
import type { OutputStatus } from '../model/output-status.js';
|
|
5
|
+
import { cn } from '../lib/cn.js';
|
|
6
|
+
import { useLabels } from '../lib/labels.js';
|
|
7
|
+
|
|
8
|
+
export interface OutputStatusIndicatorProps extends Omit<HTMLAttributes<HTMLSpanElement>, 'children'> {
|
|
9
|
+
status?: OutputStatus | undefined;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/** A corner marker calls attention only to results that need action. */
|
|
13
|
+
export const OutputStatusIndicator = forwardRef<HTMLSpanElement, OutputStatusIndicatorProps>(function OutputStatusIndicator({
|
|
14
|
+
status,
|
|
15
|
+
className,
|
|
16
|
+
...props
|
|
17
|
+
}, ref) {
|
|
18
|
+
const labels = useLabels();
|
|
19
|
+
if (!status || status.state === 'current') return null;
|
|
20
|
+
const label = labels.status[status.state];
|
|
21
|
+
const reason = status.detail?.trim();
|
|
22
|
+
const explanation = reason ? labels.status.withDetail(label, reason) : label;
|
|
23
|
+
return (
|
|
24
|
+
<Tooltip content={explanation}>
|
|
25
|
+
<span
|
|
26
|
+
data-slot="output-status"
|
|
27
|
+
role="img"
|
|
28
|
+
aria-label={explanation}
|
|
29
|
+
{...props}
|
|
30
|
+
ref={ref}
|
|
31
|
+
className={cn('astra-output-status', className)}
|
|
32
|
+
data-state={status.state}
|
|
33
|
+
>
|
|
34
|
+
<OutputStatusGlyph state={status.state} />
|
|
35
|
+
</span>
|
|
36
|
+
</Tooltip>
|
|
37
|
+
);
|
|
38
|
+
});
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { forwardRef, type HTMLAttributes } from 'react';
|
|
2
|
+
import type { InventoryPaper } from '../model/papers.js';
|
|
3
|
+
import { countLabel } from '../model/records.js';
|
|
4
|
+
import { cn } from '../lib/cn.js';
|
|
5
|
+
|
|
6
|
+
export interface PaperRowProps extends Omit<HTMLAttributes<HTMLButtonElement>, 'children'> {
|
|
7
|
+
paper: InventoryPaper;
|
|
8
|
+
onOpen: () => void;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/** One cited paper: title, byline, and how much of the analysis leans on it. */
|
|
12
|
+
export const PaperRow = forwardRef<HTMLButtonElement, PaperRowProps>(function PaperRow({
|
|
13
|
+
paper,
|
|
14
|
+
onOpen,
|
|
15
|
+
className,
|
|
16
|
+
onClick,
|
|
17
|
+
'aria-label': hostLabel,
|
|
18
|
+
...props
|
|
19
|
+
}, ref) {
|
|
20
|
+
const insights = countLabel(paper.insights.length, 'insight');
|
|
21
|
+
const decisions = countLabel(paper.decisions.length, 'decision');
|
|
22
|
+
return (
|
|
23
|
+
<button
|
|
24
|
+
data-slot="paper-row"
|
|
25
|
+
{...props}
|
|
26
|
+
ref={ref}
|
|
27
|
+
type="button"
|
|
28
|
+
className={cn('astra-paper-row', className)}
|
|
29
|
+
aria-label={hostLabel ?? `${paper.title}, ${paper.doi}, ${insights}, ${decisions}`}
|
|
30
|
+
onClick={(event) => { onClick?.(event); onOpen(); }}
|
|
31
|
+
>
|
|
32
|
+
<span className="astra-paper-row__thumbnail" aria-hidden="true">p.1</span>
|
|
33
|
+
<span className="astra-paper-row__copy">
|
|
34
|
+
<strong>{paper.title}</strong>
|
|
35
|
+
<small>{[paper.authors, paper.doi].filter(Boolean).join(' · ')}</small>
|
|
36
|
+
</span>
|
|
37
|
+
<span className="astra-paper-row__meta">{insights} · {decisions}</span>
|
|
38
|
+
<span className="astra-paper-row__arrow" aria-hidden="true">→</span>
|
|
39
|
+
</button>
|
|
40
|
+
);
|
|
41
|
+
});
|
|
@@ -36,6 +36,10 @@ export interface RecordDialogProps extends Pick<DetailDialogProps, 'mode' | 'bac
|
|
|
36
36
|
papers?: readonly InventoryPaper[] | undefined;
|
|
37
37
|
paperMetadata?: InventoryPaperMetadataMap | undefined;
|
|
38
38
|
renderArtifact?: ArtifactRenderer | undefined;
|
|
39
|
+
/** Host renderer for recorded output provenance, shown below Recipe. */
|
|
40
|
+
renderProvenance?: ((output: ResolvedOutput) => ReactNode) | undefined;
|
|
41
|
+
/** Host-provided link to the current code file, shown beside Recipe. */
|
|
42
|
+
renderCodeLink?: ((output: ResolvedOutput) => ReactNode) | undefined;
|
|
39
43
|
renderText?: TextRenderer | undefined;
|
|
40
44
|
loadPdfJs?: PdfJsLoader | undefined;
|
|
41
45
|
onOpenPaperFile?: OpenPaperFileHandler | undefined;
|
|
@@ -69,6 +73,8 @@ export function RecordDialog({
|
|
|
69
73
|
papers = [],
|
|
70
74
|
paperMetadata = {},
|
|
71
75
|
renderArtifact,
|
|
76
|
+
renderProvenance,
|
|
77
|
+
renderCodeLink,
|
|
72
78
|
renderText,
|
|
73
79
|
loadPdfJs,
|
|
74
80
|
onOpenPaperFile,
|
|
@@ -137,6 +143,8 @@ export function RecordDialog({
|
|
|
137
143
|
record={record}
|
|
138
144
|
relations={outputRelations(index, record)}
|
|
139
145
|
renderArtifact={renderArtifact}
|
|
146
|
+
renderProvenance={renderProvenance}
|
|
147
|
+
renderCodeLink={renderCodeLink}
|
|
140
148
|
renderText={renderText}
|
|
141
149
|
onOpenRecord={onOpenRecord}
|
|
142
150
|
expanded={expanded}
|
|
@@ -172,12 +180,16 @@ export function RecordDialog({
|
|
|
172
180
|
chrome = {
|
|
173
181
|
kind: 'finding',
|
|
174
182
|
kindLabel: labels.kinds.finding,
|
|
175
|
-
|
|
183
|
+
// The claim is a paragraph, not a name: it leads the body instead,
|
|
184
|
+
// where it can wrap. The header takes the record's own name, as
|
|
185
|
+
// every other kind does.
|
|
186
|
+
title: recordTitle(record),
|
|
176
187
|
body: (
|
|
177
188
|
<FindingDetail
|
|
178
189
|
record={record}
|
|
179
190
|
evidence={findingEvidence(index, record)}
|
|
180
191
|
renderText={renderText}
|
|
192
|
+
renderArtifact={renderArtifact}
|
|
181
193
|
onOpenRecord={onOpenRecord}
|
|
182
194
|
/>
|
|
183
195
|
),
|
package/src/lib/labels.tsx
CHANGED
|
@@ -7,7 +7,6 @@ export interface AstraLabels {
|
|
|
7
7
|
decisions: string;
|
|
8
8
|
inputs: string;
|
|
9
9
|
findings: string;
|
|
10
|
-
prior_insights: string;
|
|
11
10
|
papers: string;
|
|
12
11
|
};
|
|
13
12
|
outline: string;
|
|
@@ -33,7 +32,6 @@ export interface AstraLabels {
|
|
|
33
32
|
decisions: string;
|
|
34
33
|
inputs: string;
|
|
35
34
|
findings: string;
|
|
36
|
-
prior_insights: string;
|
|
37
35
|
papers: string;
|
|
38
36
|
};
|
|
39
37
|
actions: {
|
|
@@ -44,6 +42,40 @@ export interface AstraLabels {
|
|
|
44
42
|
openPaper: string;
|
|
45
43
|
locate: string;
|
|
46
44
|
};
|
|
45
|
+
/** Host-supplied execution status, shown as a marker on inventory results; the states are `lc status`'s. */
|
|
46
|
+
status: {
|
|
47
|
+
current: string;
|
|
48
|
+
behind: string;
|
|
49
|
+
stale: string;
|
|
50
|
+
withDetail: (label: string, detail: string) => string;
|
|
51
|
+
};
|
|
52
|
+
/** Recorded execution summaries and run details. */
|
|
53
|
+
provenance: {
|
|
54
|
+
status: string;
|
|
55
|
+
runDetails: string;
|
|
56
|
+
closeDetails: string;
|
|
57
|
+
noInputs: string;
|
|
58
|
+
title: string;
|
|
59
|
+
unknown: string;
|
|
60
|
+
loading: string;
|
|
61
|
+
noRun: string;
|
|
62
|
+
lastRun: string;
|
|
63
|
+
revision: string;
|
|
64
|
+
details: string;
|
|
65
|
+
recipe: string;
|
|
66
|
+
inputs: string;
|
|
67
|
+
environment: string;
|
|
68
|
+
cliVersion: string;
|
|
69
|
+
};
|
|
70
|
+
/** Figure magnification and panning. */
|
|
71
|
+
figure: {
|
|
72
|
+
controls: string;
|
|
73
|
+
zoomIn: string;
|
|
74
|
+
zoomOut: string;
|
|
75
|
+
fit: string;
|
|
76
|
+
zoomLevel: (percent: number) => string;
|
|
77
|
+
viewport: string;
|
|
78
|
+
};
|
|
47
79
|
/** PDF reading, evidence navigation, and accessible viewer controls. */
|
|
48
80
|
pdf: {
|
|
49
81
|
loading: string;
|
|
@@ -83,7 +115,6 @@ const SECTION_NOUNS: Record<keyof AstraLabels['sections'], [string, string]> = {
|
|
|
83
115
|
decisions: ['decision', 'decisions'],
|
|
84
116
|
inputs: ['input', 'inputs'],
|
|
85
117
|
findings: ['finding', 'findings'],
|
|
86
|
-
prior_insights: ['prior insight', 'prior insights'],
|
|
87
118
|
papers: ['paper', 'papers'],
|
|
88
119
|
};
|
|
89
120
|
|
|
@@ -93,8 +124,7 @@ export const defaultLabels: AstraLabels = {
|
|
|
93
124
|
decisions: 'Decisions',
|
|
94
125
|
inputs: 'Inputs',
|
|
95
126
|
findings: 'Findings',
|
|
96
|
-
|
|
97
|
-
papers: 'Papers',
|
|
127
|
+
papers: 'Bibliography',
|
|
98
128
|
},
|
|
99
129
|
outline: 'On this page',
|
|
100
130
|
analysisTree: 'Project hierarchy',
|
|
@@ -118,7 +148,6 @@ export const defaultLabels: AstraLabels = {
|
|
|
118
148
|
decisions: 'No decisions are declared in this analysis.',
|
|
119
149
|
inputs: 'No inputs are declared in this analysis.',
|
|
120
150
|
findings: 'No findings are declared in this analysis.',
|
|
121
|
-
prior_insights: 'No prior insights are declared in this analysis.',
|
|
122
151
|
papers: 'No supporting papers are linked to this analysis.',
|
|
123
152
|
},
|
|
124
153
|
actions: {
|
|
@@ -129,6 +158,37 @@ export const defaultLabels: AstraLabels = {
|
|
|
129
158
|
openPaper: 'Open',
|
|
130
159
|
locate: 'Locate',
|
|
131
160
|
},
|
|
161
|
+
status: {
|
|
162
|
+
current: 'Current',
|
|
163
|
+
behind: 'Behind',
|
|
164
|
+
stale: 'Stale',
|
|
165
|
+
withDetail: (label, detail) => `${label}: ${detail}`,
|
|
166
|
+
},
|
|
167
|
+
provenance: {
|
|
168
|
+
status: 'Status',
|
|
169
|
+
runDetails: 'Run details',
|
|
170
|
+
closeDetails: 'Close run details',
|
|
171
|
+
noInputs: 'No input versions recorded.',
|
|
172
|
+
title: 'Provenance',
|
|
173
|
+
unknown: 'Status unavailable',
|
|
174
|
+
loading: 'Loading run record…',
|
|
175
|
+
noRun: 'No recorded run yet.',
|
|
176
|
+
lastRun: 'Last run',
|
|
177
|
+
revision: 'Git revision',
|
|
178
|
+
details: 'Details',
|
|
179
|
+
recipe: 'Executed recipe',
|
|
180
|
+
inputs: 'Input versions',
|
|
181
|
+
environment: 'Environment',
|
|
182
|
+
cliVersion: 'Lightcone version',
|
|
183
|
+
},
|
|
184
|
+
figure: {
|
|
185
|
+
controls: 'Figure zoom',
|
|
186
|
+
zoomIn: 'Zoom figure in',
|
|
187
|
+
zoomOut: 'Zoom figure out',
|
|
188
|
+
fit: 'Fit figure',
|
|
189
|
+
zoomLevel: (percent) => `${percent}%`,
|
|
190
|
+
viewport: 'Figure preview: use arrow keys to pan, + and − to zoom, 0 to fit',
|
|
191
|
+
},
|
|
132
192
|
pdf: {
|
|
133
193
|
loading: 'Loading PDF…',
|
|
134
194
|
loadError: 'The PDF could not be loaded.',
|
|
@@ -187,6 +247,9 @@ function merge(base: AstraLabels, overrides: AstraLabelOverrides): AstraLabels {
|
|
|
187
247
|
kinds: { ...base.kinds, ...defined(overrides.kinds ?? {}) },
|
|
188
248
|
empty: { ...base.empty, ...defined(overrides.empty ?? {}) },
|
|
189
249
|
actions: { ...base.actions, ...defined(overrides.actions ?? {}) },
|
|
250
|
+
status: { ...base.status, ...defined(overrides.status ?? {}) },
|
|
251
|
+
provenance: { ...base.provenance, ...defined(overrides.provenance ?? {}) },
|
|
252
|
+
figure: { ...base.figure, ...defined(overrides.figure ?? {}) },
|
|
190
253
|
pdf: { ...base.pdf, ...defined(overrides.pdf ?? {}) },
|
|
191
254
|
preview: { ...base.preview, ...defined(overrides.preview ?? {}) },
|
|
192
255
|
} as AstraLabels;
|