@astra-spec/ui 0.0.5 → 0.0.7

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 (172) hide show
  1. package/README.md +47 -4
  2. package/blocks.css +1 -0
  3. package/components.css +6 -0
  4. package/dist/blocks/analysis-tree.d.ts.map +1 -1
  5. package/dist/blocks/analysis-tree.js +4 -7
  6. package/dist/blocks/analysis-tree.js.map +1 -1
  7. package/dist/blocks/decisions-list.d.ts.map +1 -1
  8. package/dist/blocks/decisions-list.js +1 -1
  9. package/dist/blocks/decisions-list.js.map +1 -1
  10. package/dist/blocks/findings-list.d.ts.map +1 -1
  11. package/dist/blocks/findings-list.js +2 -4
  12. package/dist/blocks/findings-list.js.map +1 -1
  13. package/dist/blocks/index.d.ts +2 -4
  14. package/dist/blocks/index.d.ts.map +1 -1
  15. package/dist/blocks/index.js +1 -2
  16. package/dist/blocks/index.js.map +1 -1
  17. package/dist/blocks/outputs-list.d.ts +2 -7
  18. package/dist/blocks/outputs-list.d.ts.map +1 -1
  19. package/dist/blocks/outputs-list.js +11 -21
  20. package/dist/blocks/outputs-list.js.map +1 -1
  21. package/dist/blocks/papers-list.d.ts.map +1 -1
  22. package/dist/blocks/papers-list.js +3 -3
  23. package/dist/blocks/papers-list.js.map +1 -1
  24. package/dist/components/figure-zoom.d.ts +6 -0
  25. package/dist/components/figure-zoom.d.ts.map +1 -0
  26. package/dist/components/figure-zoom.js +28 -0
  27. package/dist/components/figure-zoom.js.map +1 -0
  28. package/dist/components/finding-detail.d.ts +4 -2
  29. package/dist/components/finding-detail.d.ts.map +1 -1
  30. package/dist/components/finding-detail.js +41 -25
  31. package/dist/components/finding-detail.js.map +1 -1
  32. package/dist/components/index.d.ts +9 -0
  33. package/dist/components/index.d.ts.map +1 -1
  34. package/dist/components/index.js +5 -0
  35. package/dist/components/index.js.map +1 -1
  36. package/dist/components/insight-trigger.js +2 -2
  37. package/dist/components/insight-trigger.js.map +1 -1
  38. package/dist/components/output-card.d.ts +13 -0
  39. package/dist/components/output-card.d.ts.map +1 -0
  40. package/dist/components/output-card.js +12 -0
  41. package/dist/components/output-card.js.map +1 -0
  42. package/dist/components/output-detail.d.ts +6 -2
  43. package/dist/components/output-detail.d.ts.map +1 -1
  44. package/dist/components/output-detail.js +49 -13
  45. package/dist/components/output-detail.js.map +1 -1
  46. package/dist/components/output-dialog.d.ts +6 -1
  47. package/dist/components/output-dialog.d.ts.map +1 -1
  48. package/dist/components/output-dialog.js +2 -2
  49. package/dist/components/output-dialog.js.map +1 -1
  50. package/dist/components/output-entry.d.ts +17 -0
  51. package/dist/components/output-entry.d.ts.map +1 -0
  52. package/dist/components/output-entry.js +21 -0
  53. package/dist/components/output-entry.js.map +1 -0
  54. package/dist/components/output-provenance.d.ts +6 -0
  55. package/dist/components/output-provenance.d.ts.map +1 -0
  56. package/dist/components/output-provenance.js +16 -0
  57. package/dist/components/output-provenance.js.map +1 -0
  58. package/dist/components/output-status.d.ts +8 -0
  59. package/dist/components/output-status.d.ts.map +1 -0
  60. package/dist/components/output-status.js +17 -0
  61. package/dist/components/output-status.js.map +1 -0
  62. package/dist/components/paper-detail.d.ts.map +1 -1
  63. package/dist/components/paper-detail.js +11 -15
  64. package/dist/components/paper-detail.js.map +1 -1
  65. package/dist/components/paper-row.d.ts +9 -0
  66. package/dist/components/paper-row.d.ts.map +1 -0
  67. package/dist/components/paper-row.js +11 -0
  68. package/dist/components/paper-row.js.map +1 -0
  69. package/dist/components/record-dialog.d.ts +5 -1
  70. package/dist/components/record-dialog.d.ts.map +1 -1
  71. package/dist/components/record-dialog.js +7 -4
  72. package/dist/components/record-dialog.js.map +1 -1
  73. package/dist/lib/labels.d.ts +34 -2
  74. package/dist/lib/labels.d.ts.map +1 -1
  75. package/dist/lib/labels.js +35 -4
  76. package/dist/lib/labels.js.map +1 -1
  77. package/dist/model/index.d.ts +4 -2
  78. package/dist/model/index.d.ts.map +1 -1
  79. package/dist/model/index.js +1 -1
  80. package/dist/model/index.js.map +1 -1
  81. package/dist/model/kind.d.ts +1 -1
  82. package/dist/model/kind.d.ts.map +1 -1
  83. package/dist/model/kind.js +0 -1
  84. package/dist/model/kind.js.map +1 -1
  85. package/dist/model/output-provenance.d.ts +17 -0
  86. package/dist/model/output-provenance.d.ts.map +1 -0
  87. package/dist/model/output-provenance.js +2 -0
  88. package/dist/model/output-provenance.js.map +1 -0
  89. package/dist/model/output-status.d.ts +17 -0
  90. package/dist/model/output-status.d.ts.map +1 -0
  91. package/dist/model/output-status.js +2 -0
  92. package/dist/model/output-status.js.map +1 -0
  93. package/dist/model/relations.d.ts +37 -12
  94. package/dist/model/relations.d.ts.map +1 -1
  95. package/dist/model/relations.js +76 -23
  96. package/dist/model/relations.js.map +1 -1
  97. package/dist/primitives/dialog.d.ts.map +1 -1
  98. package/dist/primitives/dialog.js +9 -1
  99. package/dist/primitives/dialog.js.map +1 -1
  100. package/dist/primitives/index.d.ts +2 -0
  101. package/dist/primitives/index.d.ts.map +1 -1
  102. package/dist/primitives/index.js +1 -0
  103. package/dist/primitives/index.js.map +1 -1
  104. package/dist/primitives/output-status-glyph.d.ts +8 -0
  105. package/dist/primitives/output-status-glyph.d.ts.map +1 -0
  106. package/dist/primitives/output-status-glyph.js +13 -0
  107. package/dist/primitives/output-status-glyph.js.map +1 -0
  108. package/dist/primitives/tooltip.d.ts +7 -0
  109. package/dist/primitives/tooltip.d.ts.map +1 -0
  110. package/dist/primitives/tooltip.js +31 -0
  111. package/dist/primitives/tooltip.js.map +1 -0
  112. package/dist/views/inventory.d.ts +12 -1
  113. package/dist/views/inventory.d.ts.map +1 -1
  114. package/dist/views/inventory.js +23 -17
  115. package/dist/views/inventory.js.map +1 -1
  116. package/package.json +3 -2
  117. package/primitives.css +1 -0
  118. package/src/blocks/analysis-tree.tsx +4 -30
  119. package/src/blocks/decisions-list.tsx +5 -3
  120. package/src/blocks/findings-list.tsx +8 -7
  121. package/src/blocks/index.ts +2 -4
  122. package/src/blocks/outputs-list.tsx +43 -106
  123. package/src/blocks/papers-list.tsx +2 -18
  124. package/src/components/figure-zoom.tsx +72 -0
  125. package/src/components/finding-detail.tsx +106 -30
  126. package/src/components/index.ts +13 -0
  127. package/src/components/insight-trigger.tsx +2 -2
  128. package/src/components/output-card.tsx +51 -0
  129. package/src/components/output-detail.tsx +69 -21
  130. package/src/components/output-dialog.tsx +9 -0
  131. package/src/components/output-entry.tsx +61 -0
  132. package/src/components/output-provenance.tsx +86 -0
  133. package/src/components/output-status.tsx +38 -0
  134. package/src/components/paper-detail.tsx +52 -54
  135. package/src/components/paper-row.tsx +41 -0
  136. package/src/components/record-dialog.tsx +13 -1
  137. package/src/lib/labels.tsx +69 -6
  138. package/src/model/index.ts +6 -2
  139. package/src/model/kind.ts +1 -2
  140. package/src/model/output-provenance.ts +18 -0
  141. package/src/model/output-status.ts +18 -0
  142. package/src/model/relations.ts +92 -26
  143. package/src/primitives/dialog.tsx +7 -1
  144. package/src/primitives/index.ts +2 -0
  145. package/src/primitives/output-status-glyph.tsx +37 -0
  146. package/src/primitives/tooltip.tsx +51 -0
  147. package/src/views/inventory.tsx +54 -22
  148. package/styles/base.css +2 -1
  149. package/styles/blocks/analysis-tree.css +22 -25
  150. package/styles/blocks/findings-list.css +50 -0
  151. package/styles/blocks/outputs-list.css +0 -421
  152. package/styles/blocks/papers-list.css +4 -70
  153. package/styles/components/evidence.css +1 -18
  154. package/styles/components/figure-zoom.css +62 -0
  155. package/styles/components/finding-detail.css +62 -0
  156. package/styles/components/insight-list.css +0 -4
  157. package/styles/components/insight-trigger.css +8 -6
  158. package/styles/components/output-card.css +290 -0
  159. package/styles/components/output-detail.css +91 -3
  160. package/styles/components/output-entry.css +141 -0
  161. package/styles/components/output-provenance.css +94 -0
  162. package/styles/components/output-status.css +31 -0
  163. package/styles/components/paper-detail.css +112 -59
  164. package/styles/components/paper-row.css +72 -0
  165. package/styles/primitives/dialog.css +4 -22
  166. package/styles/primitives/tooltip.css +22 -0
  167. package/styles/views/inventory.css +35 -2
  168. package/dist/blocks/prior-insights-list.d.ts +0 -9
  169. package/dist/blocks/prior-insights-list.d.ts.map +0 -1
  170. package/dist/blocks/prior-insights-list.js +0 -29
  171. package/dist/blocks/prior-insights-list.js.map +0 -1
  172. package/src/blocks/prior-insights-list.tsx +0 -52
@@ -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,16 +1,16 @@
1
1
  import { KindGlyph } from '../primitives/kind-glyph.js';
2
2
  import type { ResolvedDecision, ResolvedEvidence, ResolvedInsight } from '@astra-spec/sdk';
3
- import { forwardRef, useCallback, useMemo, useRef, useState, type HTMLAttributes } from 'react';
3
+ import { forwardRef, useCallback, useId, useMemo, useRef, useState, type HTMLAttributes } from 'react';
4
4
  import { doiHref } from '../model/doi.js';
5
- import { countLabel, recordTitle } from '../model/records.js';
5
+ import { recordTitle } from '../model/records.js';
6
6
  import { decisionInsightPaths } from '../model/relations.js';
7
7
  import { paperEvidence, type InventoryPaper, type InventoryPaperMetadata } from '../model/papers.js';
8
8
  import { cn } from '../lib/cn.js';
9
9
  import { useLabels } from '../lib/labels.js';
10
10
  import { CountHeading } from '../primitives/detail-layout.js';
11
+ import { Prose } from '../primitives/prose.js';
11
12
  import { DetailDialog, DialogAction, type DetailDialogProps } from '../primitives/dialog.js';
12
13
  import type { TextRenderer } from '../lib/prose.js';
13
- import { InsightTrigger } from './insight-trigger.js';
14
14
  import { PaperPdfViewer, type PdfPassage } from './paper-pdf-viewer.js';
15
15
  import type { PdfJsLoader } from '../lib/pdf-runtime.js';
16
16
 
@@ -57,6 +57,7 @@ export const PaperDetail = forwardRef<HTMLDivElement, PaperDetailProps>(function
57
57
  const [focusKey, setFocusKey] = useState<string | undefined>(undefined);
58
58
  const [override, setOverride] = useState<PdfPassage | undefined>(undefined);
59
59
  const [decisionFilter, setDecisionFilter] = useState<string | undefined>(undefined);
60
+ const pickerId = useId();
60
61
  // Keyed by URL so a failure for one paper never outlives it inside a persistent dialog.
61
62
  const [failedPdfUrl, setFailedPdfUrl] = useState<string | undefined>(undefined);
62
63
  const key = `${paper.doi}|${focusInsight?.canonicalPath ?? ''}`;
@@ -118,64 +119,61 @@ export const PaperDetail = forwardRef<HTMLDivElement, PaperDetailProps>(function
118
119
  )}
119
120
  </div>
120
121
  <aside className="astra-paper-detail__rail" aria-label="Paper insights and decisions">
121
- <section className="astra-paper-decisions">
122
- <CountHeading title="Informs decisions" count={paper.decisions.length} />
123
- {paper.decisions.length ? (
124
- <div
125
- className="astra-paper-decisions__filters"
126
- role="group"
127
- aria-label="Filter insights by decision"
128
- >
129
- {paper.decisions.map((decision) => {
130
- const active = decision.canonicalPath === decisionFilter;
131
- return (
132
- <button
133
- key={decision.canonicalPath}
134
- type="button"
135
- className="astra-paper-decisions__filter"
136
- aria-pressed={active}
137
- onClick={() => {
138
- setDecisionFilter(active ? undefined : decision.canonicalPath);
139
- }}
140
- >
141
- <KindGlyph kind="decision" />
142
- <span>{recordTitle(decision)}</span>
143
- </button>
144
- );
145
- })}
146
- </div>
147
- ) : (
148
- <p className="astra-paper-decisions__empty">No decisions cite insights from this paper.</p>
149
- )}
150
- {filterDecision && onOpenDecision ? (
151
- <button
152
- type="button"
153
- className="astra-paper-decisions__open"
154
- onClick={() => { onOpenDecision(filterDecision); }}
155
- >
156
- Open {recordTitle(filterDecision)} →
157
- </button>
158
- ) : null}
159
- </section>
160
122
  <section className="astra-insight-list">
161
- <CountHeading
162
- title={filterDecision ? `Insights for ${recordTitle(filterDecision)}` : 'Insights from this paper'}
163
- count={visibleInsights.length}
164
- />
123
+ <div className="astra-paper-detail__rail-head">
124
+ <CountHeading title="Insights from this paper" count={visibleInsights.length} />
125
+ {paper.decisions.length ? (
126
+ <div className="astra-paper-decisions__picker">
127
+ <label className="astra-paper-decisions__picker-label" htmlFor={pickerId}>Informs decision:</label>
128
+ <div className="astra-paper-decisions__picker-row">
129
+ <KindGlyph kind="decision" />
130
+ <select
131
+ id={pickerId}
132
+ value={decisionFilter ?? ''}
133
+ onChange={(event) => { setDecisionFilter(event.target.value || undefined); }}
134
+ >
135
+ <option value="">Any decision</option>
136
+ {paper.decisions.map((decision) => (
137
+ <option key={decision.canonicalPath} value={decision.canonicalPath}>
138
+ {recordTitle(decision)}
139
+ </option>
140
+ ))}
141
+ </select>
142
+ {filterDecision && onOpenDecision ? (
143
+ <button
144
+ type="button"
145
+ className="astra-paper-decisions__open"
146
+ aria-label={`Open decision: ${recordTitle(filterDecision)}`}
147
+ onClick={() => { onOpenDecision(filterDecision); }}
148
+ >
149
+ Open <span aria-hidden="true">→</span>
150
+ </button>
151
+ ) : null}
152
+ </div>
153
+ </div>
154
+ ) : null}
155
+ </div>
165
156
  <ul className="astra-evidence astra-paper-detail__insights">
166
157
  {visibleInsights.map((insight) => {
167
158
  const evidence = paperEvidence(insight, paper.doi);
168
159
  return (
169
160
  <li key={insight.canonicalPath} className="astra-evidence__item astra-paper-insight">
170
- <InsightTrigger
171
- insight={insight}
172
- variant="claim"
173
- renderText={renderText}
174
- onOpen={() => onOpenInsight?.(insight)}
175
- />
176
- {evidence.length ? (
161
+ <KindGlyph className="astra-paper-insight__glyph" kind="prior_insight" />
162
+ <div className="astra-paper-insight__claim">
163
+ <Prose text={insight.claim} field="claim" renderText={renderText} />
164
+ </div>
165
+ {evidence.length || onOpenInsight ? (
177
166
  <div className="astra-paper-insight__sources">
178
- <span>{countLabel(evidence.length, 'passage')}</span>
167
+ {onOpenInsight ? (
168
+ <button
169
+ type="button"
170
+ className="astra-paper-insight__open"
171
+ aria-label={`Open insight details: ${recordTitle(insight)}`}
172
+ onClick={() => { onOpenInsight(insight); }}
173
+ >
174
+ {recordTitle(insight)} <span aria-hidden="true">→</span>
175
+ </button>
176
+ ) : null}
179
177
  {paper.pdfUrl && loadPdfJs ? (
180
178
  <div>
181
179
  {evidence.map((source, index) => (
@@ -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
  ),
@@ -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
- prior_insights: 'Prior Insights',
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;
@@ -9,12 +9,14 @@ export {
9
9
  decisionInsights,
10
10
  findingEvidence,
11
11
  findingLiterature,
12
- indirectDecisionPaths,
12
+ groupFindingEvidence,
13
13
  informedDecisions,
14
14
  linkedRecord,
15
+ outputDecisionPaths,
16
+ outputDecisionRoutes,
15
17
  outputRelations,
16
18
  } from './relations.js';
17
- export type { FindingEvidenceLink, LinkedRecord, OutputRelations } from './relations.js';
19
+ export type { FindingEvidenceGroup, FindingEvidenceLink, LinkedRecord, OutputRelations } from './relations.js';
18
20
  export {
19
21
  analysesForPaperView,
20
22
  collectInventoryPapers,
@@ -32,3 +34,5 @@ export type {
32
34
  PaperFetchStatus,
33
35
  } from './papers.js';
34
36
  export { doiHref } from './doi.js';
37
+ export type { OutputStatus, OutputStatusLookup } from './output-status.js';
38
+ export type { OutputProvenanceData, OutputRun } from './output-provenance.js';
package/src/model/kind.ts CHANGED
@@ -18,7 +18,7 @@ export function surfaceGlyph(kind: SurfaceKind): string {
18
18
  return SURFACE_GLYPHS[kind];
19
19
  }
20
20
 
21
- export type InventorySectionId = 'outputs' | 'decisions' | 'inputs' | 'findings' | 'prior_insights' | 'papers';
21
+ export type InventorySectionId = 'outputs' | 'decisions' | 'inputs' | 'findings' | 'papers';
22
22
 
23
23
  /** The record kind each inventory section lists; drives the outline glyph and colour. */
24
24
  export function sectionKind(section: InventorySectionId): SurfaceKind {
@@ -27,7 +27,6 @@ export function sectionKind(section: InventorySectionId): SurfaceKind {
27
27
  case 'decisions': return 'decision';
28
28
  case 'inputs': return 'input';
29
29
  case 'findings': return 'finding';
30
- case 'prior_insights': return 'prior_insight';
31
30
  case 'papers': return 'paper';
32
31
  }
33
32
  }
@@ -0,0 +1,18 @@
1
+ import type { OutputStatus } from './output-status.js';
2
+
3
+ /** Recorded execution metadata supplied by the host, independent of the current recipe. */
4
+ export interface OutputRun {
5
+ finishedAt: string;
6
+ gitRevision: string;
7
+ recipe: string;
8
+ environment: string;
9
+ inputVersions: Readonly<Record<string, string>>;
10
+ cliVersion: string;
11
+ }
12
+
13
+ export interface OutputProvenanceData {
14
+ status?: OutputStatus | undefined;
15
+ /** null means the host found no recorded run; undefined means it has not loaded. */
16
+ run?: OutputRun | null | undefined;
17
+ error?: string | undefined;
18
+ }
@@ -0,0 +1,18 @@
1
+ import type { ResolvedOutput } from '@astra-spec/sdk';
2
+
3
+ /**
4
+ * Execution status supplied by the host, separate from the ASTRA document: the
5
+ * document declares what an analysis produces, the host knows what has actually
6
+ * been run. The states are the ones `lc status` reports, so a marker in the UI
7
+ * and a line in the terminal name the same thing: `current` is exactly what the
8
+ * spec asks for, `behind` still is but the environment moved since, and `stale`
9
+ * contradicts the project (definition or input changed, hand-edited, or never
10
+ * materialized). `detail` is the host's own reason, as `lc status` prints it.
11
+ */
12
+ export interface OutputStatus {
13
+ state: 'current' | 'behind' | 'stale';
14
+ detail?: string | undefined;
15
+ }
16
+
17
+ /** Host lookup for one output's execution status; `undefined` means unknown. */
18
+ export type OutputStatusLookup = (output: ResolvedOutput) => OutputStatus | undefined;
@@ -19,14 +19,13 @@ export interface LinkedRecord {
19
19
 
20
20
  export interface OutputRelations {
21
21
  inputs: LinkedRecord[];
22
- /** Decisions the output declares directly. */
23
- decisions: LinkedRecord[];
24
22
  /**
25
- * Decisions reached through upstream outputs (see `indirectDecisionPaths`).
26
- * `outputRelations()` always fills it (possibly empty); optional so hosts
27
- * assembling relations by hand can leave it out.
23
+ * Every decision on a dependency path to the output: the ones it declares,
24
+ * then those reached through upstream outputs, in any analysis (see
25
+ * `outputDecisionPaths`). `via` names the immediate upstream outputs a
26
+ * decision arrives through, and is absent on one the output declares.
28
27
  */
29
- indirectDecisions?: LinkedRecord[] | undefined;
28
+ decisions: (LinkedRecord & { via?: LinkedRecord[] | undefined })[];
30
29
  alias?: LinkedRecord | undefined;
31
30
  }
32
31
 
@@ -45,39 +44,69 @@ export function linkedRecord(index: AnalysisIndex, canonicalPath: string): Linke
45
44
  }
46
45
 
47
46
  /**
48
- * Decisions an output depends on only through its upstream outputs: the
49
- * provenance of every input that is (or aliases) an output, followed
50
- * recursively, minus the output's own direct decisions. Document order of
51
- * discovery; cycles are ignored.
47
+ * Every decision with a dependency path to an output: the ones its own
48
+ * provenance declares, then those of every upstream output — an input that
49
+ * is (or aliases) an output, the output's own alias target, and so on
50
+ * recursively, across analyses. Direct decisions come first in document
51
+ * order, then the rest in order of discovery; a decision reached by several
52
+ * paths is listed once, and cycles are ignored.
52
53
  */
53
- export function indirectDecisionPaths(index: AnalysisIndex, output: ResolvedOutput): string[] {
54
+ export function outputDecisionPaths(index: AnalysisIndex, output: ResolvedOutput): string[] {
55
+ return [...collectOutputDecisions(index, output).keys()];
56
+ }
57
+
58
+ /**
59
+ * The immediate upstream outputs each decision arrives through, for the ones
60
+ * an output does not declare itself. A decision reachable through two upstream
61
+ * outputs names both; decisions the output declares are omitted.
62
+ */
63
+ export function outputDecisionRoutes(index: AnalysisIndex, output: ResolvedOutput): Map<string, Set<string>> {
64
+ return new Map([...collectOutputDecisions(index, output)].filter(([, via]) => via.size));
65
+ }
66
+
67
+ /** Ordered decisions and their routes, derived in one walk for every consumer. */
68
+ function collectOutputDecisions(index: AnalysisIndex, output: ResolvedOutput): Map<string, Set<string>> {
54
69
  const direct = new Set(output.provenance.decisionPaths);
55
- const seen = new Set<string>([output.canonicalPath]);
56
- const found: string[] = [];
57
- const queue = [...output.provenance.inputPaths];
70
+ // Empty routes mark direct decisions, which always precede inherited ones.
71
+ const decisions = new Map([...direct].map((path) => [path, new Set<string>()]));
72
+ const seenByRoute = new Map<string, Set<string>>();
73
+ const queue: { path: string; via?: string }[] = [
74
+ ...output.provenance.inputPaths.map((path) => ({ path })),
75
+ ...(output.resolvedFrom ? [{ path: output.resolvedFrom }] : []),
76
+ ];
58
77
  // Array iteration sees entries pushed while it runs, so the walk is a BFS.
59
- for (const path of queue) {
60
- if (seen.has(path)) continue;
61
- seen.add(path);
62
- let record = index.recordByPath.get(path);
78
+ for (const entry of queue) {
79
+ let record = index.recordByPath.get(entry.path);
63
80
  if (record?.kind === 'input' && record.resolvedFrom) record = index.recordByPath.get(record.resolvedFrom);
64
- if (record?.kind !== 'output') continue;
81
+ if (record?.kind !== 'output' || record.canonicalPath === output.canonicalPath) continue;
82
+ // The first upstream output on a path is the route; deeper hops keep it.
83
+ const via = entry.via ?? record.canonicalPath;
84
+ const walked = seenByRoute.get(via) ?? new Set<string>();
85
+ if (walked.has(record.canonicalPath)) continue;
86
+ walked.add(record.canonicalPath);
87
+ seenByRoute.set(via, walked);
65
88
  for (const decisionPath of record.provenance.decisionPaths) {
66
- if (!direct.has(decisionPath) && !found.includes(decisionPath)) found.push(decisionPath);
89
+ if (direct.has(decisionPath)) continue;
90
+ const found = decisions.get(decisionPath) ?? new Set<string>();
91
+ found.add(via);
92
+ decisions.set(decisionPath, found);
67
93
  }
68
- queue.push(...record.provenance.inputPaths);
69
- if (record.resolvedFrom) queue.push(record.resolvedFrom);
94
+ const next = [...record.provenance.inputPaths, ...(record.resolvedFrom ? [record.resolvedFrom] : [])];
95
+ queue.push(...next.map((path) => ({ path, via })));
70
96
  }
71
- return found;
97
+ return decisions;
72
98
  }
73
99
 
74
- /** Inputs, direct and indirect decisions, and alias source an output depends on; a record referenced twice (e.g. through an alias) is listed once. */
100
+ /** Inputs, every decision on a dependency path, and alias source an output depends on; a record referenced twice (e.g. through an alias) is listed once. */
75
101
  export function outputRelations(index: AnalysisIndex, output: ResolvedOutput): OutputRelations {
76
102
  const unique = (paths: readonly string[]) => [...new Set(paths)];
103
+ const decisions = collectOutputDecisions(index, output);
77
104
  return {
78
105
  inputs: unique(output.provenance.inputPaths).map((path) => linkedRecord(index, path)),
79
- decisions: unique(output.provenance.decisionPaths).map((path) => linkedRecord(index, path)),
80
- indirectDecisions: indirectDecisionPaths(index, output).map((path) => linkedRecord(index, path)),
106
+ decisions: [...decisions].map(([path, via]) => ({
107
+ ...linkedRecord(index, path),
108
+ ...(via.size ? { via: [...via].map((from) => linkedRecord(index, from)) } : {}),
109
+ })),
81
110
  ...(output.resolvedFrom ? { alias: linkedRecord(index, output.resolvedFrom) } : {}),
82
111
  };
83
112
  }
@@ -98,6 +127,43 @@ export function findingEvidence(index: AnalysisIndex, finding: ResolvedInsight):
98
127
  });
99
128
  }
100
129
 
130
+ /** A supporting result and every evidence entry a finding anchors into it. */
131
+ export interface FindingEvidenceGroup {
132
+ /** Resolved output path when known, else the artifact name. */
133
+ key: string;
134
+ output?: ResolvedOutput | undefined;
135
+ analysis?: ResolvedAnalysisNode | undefined;
136
+ artifact?: string | undefined;
137
+ evidence: ResolvedEvidence[];
138
+ }
139
+
140
+ /**
141
+ * Folds evidence links onto the result they cite. A finding that anchors two
142
+ * quotes into the same artifact — one per quantity its claim names — is
143
+ * supported by one result, not two identical-looking ones. Order of first
144
+ * appearance; every entry is kept, so no anchor is dropped.
145
+ */
146
+ export function groupFindingEvidence(links: FindingEvidenceLink[]): FindingEvidenceGroup[] {
147
+ const groups = new Map<string, FindingEvidenceGroup>();
148
+ for (const link of links) {
149
+ // `findingEvidence` keeps only links carrying one of these, so the key exists.
150
+ const key = link.evidence.resolvedOutputPath ?? link.evidence.artifact ?? link.evidence.id;
151
+ const existing = groups.get(key);
152
+ if (existing) {
153
+ existing.evidence.push(link.evidence);
154
+ continue;
155
+ }
156
+ groups.set(key, {
157
+ key,
158
+ ...(link.output ? { output: link.output } : {}),
159
+ ...(link.analysis ? { analysis: link.analysis } : {}),
160
+ ...(link.evidence.artifact ? { artifact: link.evidence.artifact } : {}),
161
+ evidence: [link.evidence],
162
+ });
163
+ }
164
+ return [...groups.values()];
165
+ }
166
+
101
167
  /** Literature evidence (a DOI, with or without a quote) a finding or insight cites. */
102
168
  export function findingLiterature(finding: ResolvedInsight): ResolvedEvidence[] {
103
169
  return finding.evidence.filter((evidence) => Boolean(evidence.doi));
@@ -286,14 +286,20 @@ export const DialogContent = forwardRef<HTMLElement, DialogContentProps>(functio
286
286
  closeRef.current?.focus();
287
287
  });
288
288
 
289
+ // `cancel` and `close` do not bubble in the DOM, but React still runs an
290
+ // ancestor's handler when a nested <dialog> fires one. The innermost layer
291
+ // owns its own dismissal, so ignore anything another dialog raised.
292
+ const isOwnEvent = (event: SyntheticEvent<HTMLDialogElement>) => event.target === event.currentTarget;
289
293
  const handleCancel = (event: SyntheticEvent<HTMLDialogElement>) => {
294
+ if (!isOwnEvent(event)) return;
290
295
  // Escape. Close (or let the guard handle it) explicitly rather than via
291
296
  // the browser's default, which is deterministic across browsers
292
297
  // (Chromium makes a repeated Escape non-cancelable) and test environments.
293
298
  event.preventDefault();
294
299
  requestDismiss();
295
300
  };
296
- const handleClose = () => {
301
+ const handleClose = (event: SyntheticEvent<HTMLDialogElement>) => {
302
+ if (!isOwnEvent(event)) return;
297
303
  if (closingSilently.current) {
298
304
  closingSilently.current = false;
299
305
  return;
@@ -48,5 +48,7 @@ export { Prose } from './prose.js';
48
48
  export type { ProseProps } from './prose.js';
49
49
  export { KindGlyph } from './kind-glyph.js';
50
50
  export type { KindGlyphProps } from './kind-glyph.js';
51
+ export { OutputStatusGlyph } from './output-status-glyph.js';
52
+ export type { OutputStatusGlyphProps } from './output-status-glyph.js';
51
53
  export { InlineReference } from './inline-reference.js';
52
54
  export type { InlineReferenceProps } from './inline-reference.js';