@astra-spec/ui 0.0.4 → 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.
Files changed (227) hide show
  1. package/README.md +47 -4
  2. package/TOKENS.md +14 -8
  3. package/blocks.css +1 -0
  4. package/components.css +6 -0
  5. package/dist/blocks/analysis-tree.d.ts.map +1 -1
  6. package/dist/blocks/analysis-tree.js +4 -7
  7. package/dist/blocks/analysis-tree.js.map +1 -1
  8. package/dist/blocks/decisions-list.d.ts.map +1 -1
  9. package/dist/blocks/decisions-list.js +1 -1
  10. package/dist/blocks/decisions-list.js.map +1 -1
  11. package/dist/blocks/findings-list.d.ts.map +1 -1
  12. package/dist/blocks/findings-list.js +3 -4
  13. package/dist/blocks/findings-list.js.map +1 -1
  14. package/dist/blocks/index.d.ts +2 -4
  15. package/dist/blocks/index.d.ts.map +1 -1
  16. package/dist/blocks/index.js +1 -2
  17. package/dist/blocks/index.js.map +1 -1
  18. package/dist/blocks/outputs-list.d.ts +2 -7
  19. package/dist/blocks/outputs-list.d.ts.map +1 -1
  20. package/dist/blocks/outputs-list.js +11 -21
  21. package/dist/blocks/outputs-list.js.map +1 -1
  22. package/dist/blocks/papers-list.d.ts.map +1 -1
  23. package/dist/blocks/papers-list.js +3 -3
  24. package/dist/blocks/papers-list.js.map +1 -1
  25. package/dist/blocks/section.d.ts.map +1 -1
  26. package/dist/blocks/section.js +3 -2
  27. package/dist/blocks/section.js.map +1 -1
  28. package/dist/components/figure-zoom.d.ts +6 -0
  29. package/dist/components/figure-zoom.d.ts.map +1 -0
  30. package/dist/components/figure-zoom.js +28 -0
  31. package/dist/components/figure-zoom.js.map +1 -0
  32. package/dist/components/finding-detail.d.ts +4 -2
  33. package/dist/components/finding-detail.d.ts.map +1 -1
  34. package/dist/components/finding-detail.js +41 -25
  35. package/dist/components/finding-detail.js.map +1 -1
  36. package/dist/components/index.d.ts +9 -0
  37. package/dist/components/index.d.ts.map +1 -1
  38. package/dist/components/index.js +5 -0
  39. package/dist/components/index.js.map +1 -1
  40. package/dist/components/insight-trigger.d.ts.map +1 -1
  41. package/dist/components/insight-trigger.js +3 -2
  42. package/dist/components/insight-trigger.js.map +1 -1
  43. package/dist/components/output-card.d.ts +13 -0
  44. package/dist/components/output-card.d.ts.map +1 -0
  45. package/dist/components/output-card.js +12 -0
  46. package/dist/components/output-card.js.map +1 -0
  47. package/dist/components/output-detail.d.ts +6 -2
  48. package/dist/components/output-detail.d.ts.map +1 -1
  49. package/dist/components/output-detail.js +49 -13
  50. package/dist/components/output-detail.js.map +1 -1
  51. package/dist/components/output-dialog.d.ts +6 -1
  52. package/dist/components/output-dialog.d.ts.map +1 -1
  53. package/dist/components/output-dialog.js +2 -2
  54. package/dist/components/output-dialog.js.map +1 -1
  55. package/dist/components/output-entry.d.ts +17 -0
  56. package/dist/components/output-entry.d.ts.map +1 -0
  57. package/dist/components/output-entry.js +21 -0
  58. package/dist/components/output-entry.js.map +1 -0
  59. package/dist/components/output-provenance.d.ts +6 -0
  60. package/dist/components/output-provenance.d.ts.map +1 -0
  61. package/dist/components/output-provenance.js +16 -0
  62. package/dist/components/output-provenance.js.map +1 -0
  63. package/dist/components/output-status.d.ts +8 -0
  64. package/dist/components/output-status.d.ts.map +1 -0
  65. package/dist/components/output-status.js +17 -0
  66. package/dist/components/output-status.js.map +1 -0
  67. package/dist/components/paper-detail.d.ts.map +1 -1
  68. package/dist/components/paper-detail.js +2 -2
  69. package/dist/components/paper-detail.js.map +1 -1
  70. package/dist/components/paper-row.d.ts +9 -0
  71. package/dist/components/paper-row.d.ts.map +1 -0
  72. package/dist/components/paper-row.js +11 -0
  73. package/dist/components/paper-row.js.map +1 -0
  74. package/dist/components/record-dialog.d.ts +5 -1
  75. package/dist/components/record-dialog.d.ts.map +1 -1
  76. package/dist/components/record-dialog.js +7 -4
  77. package/dist/components/record-dialog.js.map +1 -1
  78. package/dist/components/record-preview.d.ts.map +1 -1
  79. package/dist/components/record-preview.js +8 -7
  80. package/dist/components/record-preview.js.map +1 -1
  81. package/dist/lib/labels.d.ts +34 -2
  82. package/dist/lib/labels.d.ts.map +1 -1
  83. package/dist/lib/labels.js +35 -4
  84. package/dist/lib/labels.js.map +1 -1
  85. package/dist/model/index.d.ts +4 -2
  86. package/dist/model/index.d.ts.map +1 -1
  87. package/dist/model/index.js +1 -1
  88. package/dist/model/index.js.map +1 -1
  89. package/dist/model/kind.d.ts +2 -2
  90. package/dist/model/kind.d.ts.map +1 -1
  91. package/dist/model/kind.js +3 -4
  92. package/dist/model/kind.js.map +1 -1
  93. package/dist/model/output-provenance.d.ts +17 -0
  94. package/dist/model/output-provenance.d.ts.map +1 -0
  95. package/dist/model/output-provenance.js +2 -0
  96. package/dist/model/output-provenance.js.map +1 -0
  97. package/dist/model/output-status.d.ts +17 -0
  98. package/dist/model/output-status.d.ts.map +1 -0
  99. package/dist/model/output-status.js +2 -0
  100. package/dist/model/output-status.js.map +1 -0
  101. package/dist/model/relations.d.ts +37 -12
  102. package/dist/model/relations.d.ts.map +1 -1
  103. package/dist/model/relations.js +76 -23
  104. package/dist/model/relations.js.map +1 -1
  105. package/dist/primitives/dialog.d.ts.map +1 -1
  106. package/dist/primitives/dialog.js +9 -1
  107. package/dist/primitives/dialog.js.map +1 -1
  108. package/dist/primitives/index.d.ts +6 -0
  109. package/dist/primitives/index.d.ts.map +1 -1
  110. package/dist/primitives/index.js +3 -0
  111. package/dist/primitives/index.js.map +1 -1
  112. package/dist/primitives/inline-reference.d.ts +9 -0
  113. package/dist/primitives/inline-reference.d.ts.map +1 -0
  114. package/dist/primitives/inline-reference.js +14 -0
  115. package/dist/primitives/inline-reference.js.map +1 -0
  116. package/dist/primitives/kind-glyph.d.ts +8 -0
  117. package/dist/primitives/kind-glyph.d.ts.map +1 -0
  118. package/dist/primitives/kind-glyph.js +9 -0
  119. package/dist/primitives/kind-glyph.js.map +1 -0
  120. package/dist/primitives/output-status-glyph.d.ts +8 -0
  121. package/dist/primitives/output-status-glyph.d.ts.map +1 -0
  122. package/dist/primitives/output-status-glyph.js +13 -0
  123. package/dist/primitives/output-status-glyph.js.map +1 -0
  124. package/dist/primitives/preview-popover.d.ts +1 -1
  125. package/dist/primitives/preview-popover.d.ts.map +1 -1
  126. package/dist/primitives/record-list.d.ts.map +1 -1
  127. package/dist/primitives/record-list.js +3 -2
  128. package/dist/primitives/record-list.js.map +1 -1
  129. package/dist/primitives/relation-list.d.ts.map +1 -1
  130. package/dist/primitives/relation-list.js +3 -2
  131. package/dist/primitives/relation-list.js.map +1 -1
  132. package/dist/primitives/tooltip.d.ts +7 -0
  133. package/dist/primitives/tooltip.d.ts.map +1 -0
  134. package/dist/primitives/tooltip.js +31 -0
  135. package/dist/primitives/tooltip.js.map +1 -0
  136. package/dist/views/inventory.d.ts +12 -1
  137. package/dist/views/inventory.d.ts.map +1 -1
  138. package/dist/views/inventory.js +23 -17
  139. package/dist/views/inventory.js.map +1 -1
  140. package/isolate.css +7 -0
  141. package/package.json +7 -4
  142. package/primitives.css +3 -0
  143. package/src/blocks/analysis-tree.tsx +4 -30
  144. package/src/blocks/decisions-list.tsx +5 -3
  145. package/src/blocks/findings-list.tsx +10 -8
  146. package/src/blocks/index.ts +2 -4
  147. package/src/blocks/outputs-list.tsx +43 -106
  148. package/src/blocks/papers-list.tsx +2 -18
  149. package/src/blocks/section.tsx +3 -2
  150. package/src/components/figure-zoom.tsx +72 -0
  151. package/src/components/finding-detail.tsx +106 -30
  152. package/src/components/index.ts +13 -0
  153. package/src/components/insight-trigger.tsx +3 -2
  154. package/src/components/output-card.tsx +51 -0
  155. package/src/components/output-detail.tsx +69 -21
  156. package/src/components/output-dialog.tsx +9 -0
  157. package/src/components/output-entry.tsx +61 -0
  158. package/src/components/output-provenance.tsx +86 -0
  159. package/src/components/output-status.tsx +38 -0
  160. package/src/components/paper-detail.tsx +2 -2
  161. package/src/components/paper-row.tsx +41 -0
  162. package/src/components/record-dialog.tsx +13 -1
  163. package/src/components/record-preview.tsx +8 -14
  164. package/src/lib/labels.tsx +69 -6
  165. package/src/model/index.ts +6 -2
  166. package/src/model/kind.ts +4 -5
  167. package/src/model/output-provenance.ts +18 -0
  168. package/src/model/output-status.ts +18 -0
  169. package/src/model/relations.ts +92 -26
  170. package/src/primitives/dialog.tsx +7 -1
  171. package/src/primitives/index.ts +6 -0
  172. package/src/primitives/inline-reference.tsx +25 -0
  173. package/src/primitives/kind-glyph.tsx +24 -0
  174. package/src/primitives/output-status-glyph.tsx +37 -0
  175. package/src/primitives/preview-popover.tsx +1 -1
  176. package/src/primitives/record-list.tsx +3 -4
  177. package/src/primitives/relation-list.tsx +4 -7
  178. package/src/primitives/tooltip.tsx +51 -0
  179. package/src/views/inventory.tsx +54 -22
  180. package/styles/base.css +2 -1
  181. package/styles/blocks/analysis-tree.css +23 -26
  182. package/styles/blocks/decisions-list.css +6 -6
  183. package/styles/blocks/findings-list.css +50 -0
  184. package/styles/blocks/outputs-list.css +13 -434
  185. package/styles/blocks/papers-list.css +8 -74
  186. package/styles/blocks/records.css +13 -13
  187. package/styles/components/artifact-preview.css +15 -15
  188. package/styles/components/decision-detail.css +23 -23
  189. package/styles/components/evidence.css +2 -7
  190. package/styles/components/figure-zoom.css +62 -0
  191. package/styles/components/finding-detail.css +73 -11
  192. package/styles/components/input-detail.css +7 -7
  193. package/styles/components/insight-detail.css +17 -17
  194. package/styles/components/insight-list.css +6 -6
  195. package/styles/components/insight-trigger.css +5 -5
  196. package/styles/components/output-card.css +290 -0
  197. package/styles/components/output-detail.css +139 -51
  198. package/styles/components/output-entry.css +141 -0
  199. package/styles/components/output-provenance.css +94 -0
  200. package/styles/components/output-status.css +31 -0
  201. package/styles/components/paper-detail.css +22 -22
  202. package/styles/components/paper-doi.css +2 -2
  203. package/styles/components/paper-pdf-viewer.css +6 -6
  204. package/styles/components/paper-row.css +72 -0
  205. package/styles/components/record-preview.css +444 -268
  206. package/styles/primitives/badge.css +1 -1
  207. package/styles/primitives/button.css +25 -25
  208. package/styles/primitives/count-heading.css +3 -3
  209. package/styles/primitives/detail-layout.css +20 -20
  210. package/styles/primitives/dialog.css +75 -93
  211. package/styles/primitives/empty-state.css +1 -1
  212. package/styles/primitives/inline-reference.css +37 -0
  213. package/styles/primitives/kind-glyph.css +31 -0
  214. package/styles/primitives/kind.css +6 -0
  215. package/styles/primitives/preview-popover.css +6 -11
  216. package/styles/primitives/prose.css +1 -1
  217. package/styles/primitives/record-list.css +32 -48
  218. package/styles/primitives/relation-list.css +14 -36
  219. package/styles/primitives/surface-header.css +15 -11
  220. package/styles/primitives/tooltip.css +22 -0
  221. package/styles/tokens.css +19 -9
  222. package/styles/views/inventory.css +58 -27
  223. package/dist/blocks/prior-insights-list.d.ts +0 -9
  224. package/dist/blocks/prior-insights-list.d.ts.map +0 -1
  225. package/dist/blocks/prior-insights-list.js +0 -29
  226. package/dist/blocks/prior-insights-list.js.map +0 -1
  227. 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: the host's rendering when it
30
- * returns one, the built-in preview for figures and tables, nothing for other
31
- * output types (a data file or a metric has no picture to frame).
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 (renderArtifact) return renderArtifact(output, { compact: false });
35
- return isVisualOutput(output) ? <ArtifactPreview output={output} compact={false} /> : null;
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={relationItemsForLinks(relations.decisions, onOpenRecord)}
133
- empty="No decision dependencies are declared for this output."
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
- <h4>Recipe</h4>
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
- {artifact}
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 for an output: open the artifact in the host, enter full screen. */
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 visual = isVisualOutput(output);
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
- {visual ? (
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
+ });
@@ -1,3 +1,4 @@
1
+ import { KindGlyph } from '../primitives/kind-glyph.js';
1
2
  import type { ResolvedDecision, ResolvedEvidence, ResolvedInsight } from '@astra-spec/sdk';
2
3
  import { forwardRef, useCallback, useMemo, useRef, useState, type HTMLAttributes } from 'react';
3
4
  import { doiHref } from '../model/doi.js';
@@ -8,7 +9,6 @@ import { cn } from '../lib/cn.js';
8
9
  import { useLabels } from '../lib/labels.js';
9
10
  import { CountHeading } from '../primitives/detail-layout.js';
10
11
  import { DetailDialog, DialogAction, type DetailDialogProps } from '../primitives/dialog.js';
11
- import { surfaceGlyph } from '../model/kind.js';
12
12
  import type { TextRenderer } from '../lib/prose.js';
13
13
  import { InsightTrigger } from './insight-trigger.js';
14
14
  import { PaperPdfViewer, type PdfPassage } from './paper-pdf-viewer.js';
@@ -138,7 +138,7 @@ export const PaperDetail = forwardRef<HTMLDivElement, PaperDetailProps>(function
138
138
  setDecisionFilter(active ? undefined : decision.canonicalPath);
139
139
  }}
140
140
  >
141
- <span aria-hidden="true">{surfaceGlyph('decision')}</span>
141
+ <KindGlyph kind="decision" />
142
142
  <span>{recordTitle(decision)}</span>
143
143
  </button>
144
144
  );
@@ -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
- title: record.claim,
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
  ),
@@ -1,3 +1,4 @@
1
+ import { KindGlyph } from '../primitives/kind-glyph.js';
1
2
  import type {
2
3
  AnalysisIndex,
3
4
  ResolvedAnalysisDocument,
@@ -22,7 +23,7 @@ import { analysisTitle, recordTitle } from '../model/records.js';
22
23
  import { decisionInsights } from '../model/relations.js';
23
24
  import { Prose } from '../primitives/prose.js';
24
25
  import type { TextRenderer } from '../lib/prose.js';
25
- import { surfaceGlyph, type SurfaceKind } from '../model/kind.js';
26
+ import { type SurfaceKind } from '../model/kind.js';
26
27
  import { SurfaceHeader } from '../primitives/surface-header.js';
27
28
  import type { ArtifactRenderer } from './artifact-preview.js';
28
29
  import { primaryLiteratureEvidence } from '../model/papers.js';
@@ -115,7 +116,7 @@ function relationTitle(record: ResolvedRecord): string {
115
116
  function KindEyebrow({ kind, label }: { kind: SurfaceKind; label: ReactNode }) {
116
117
  return (
117
118
  <span className="astra-record-preview__kind">
118
- <span aria-hidden="true">{surfaceGlyph(kind)}</span>
119
+ <KindGlyph kind={kind} />
119
120
  {label}
120
121
  </span>
121
122
  );
@@ -126,7 +127,7 @@ function PreviewHeader({
126
127
  kindLabel,
127
128
  title,
128
129
  }: {
129
- kind: SurfaceKind;
130
+ kind?: SurfaceKind | undefined;
130
131
  kindLabel: ReactNode;
131
132
  title?: ReactNode | undefined;
132
133
  }) {
@@ -135,7 +136,7 @@ function PreviewHeader({
135
136
  density="compact"
136
137
  kind={kind}
137
138
  titleAs="h3"
138
- eyebrow={<KindEyebrow kind={kind} label={kindLabel} />}
139
+ eyebrow={kind ? <KindEyebrow kind={kind} label={kindLabel} /> : kindLabel}
139
140
  title={title}
140
141
  className="astra-record-preview__header"
141
142
  />
@@ -184,9 +185,7 @@ function RelatedRecord({
184
185
  const label = relationTitle(record);
185
186
  const copy = (
186
187
  <>
187
- <span className="astra-record-preview__relation-glyph" aria-hidden="true">
188
- {surfaceGlyph(record.kind)}
189
- </span>
188
+ <KindGlyph className="astra-record-preview__relation-glyph" kind={record.kind} />
190
189
  <span className="astra-record-preview__relation-label">{label}</span>
191
190
  {detail != null ? (
192
191
  <small className="astra-record-preview__relation-detail">{detail}</small>
@@ -370,12 +369,7 @@ function FindingPreview({
370
369
  className="astra-record-preview__relation-trigger"
371
370
  data-kind="output"
372
371
  >
373
- <span
374
- className="astra-record-preview__relation-glyph"
375
- aria-hidden="true"
376
- >
377
- {surfaceGlyph('output')}
378
- </span>
372
+ <KindGlyph className="astra-record-preview__relation-glyph" kind="output" />
379
373
  <span className="astra-record-preview__relation-label">
380
374
  {evidence.artifact}
381
375
  </span>
@@ -653,7 +647,6 @@ function ValuePreview({
653
647
  return (
654
648
  <>
655
649
  <PreviewHeader
656
- kind={record.kind}
657
650
  kindLabel={kindLabel}
658
651
  title={
659
652
  <span className="astra-record-preview__value">
@@ -735,6 +728,7 @@ export const RecordPreview = forwardRef<HTMLElement, RecordPreviewProps>(
735
728
  <article
736
729
  data-slot="record-preview"
737
730
  data-entry-kind={entry.kind}
731
+ data-value-product={entry.kind === 'value' && entry.product ? '' : undefined}
738
732
  data-kind={previewKind(entry)}
739
733
  {...props}
740
734
  ref={ref}