@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.
- 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/insight-trigger.js +2 -2
- package/dist/components/insight-trigger.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-detail.d.ts.map +1 -1
- package/dist/components/paper-detail.js +11 -15
- package/dist/components/paper-detail.js.map +1 -1
- 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/insight-trigger.tsx +2 -2
- 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-detail.tsx +52 -54
- 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/evidence.css +1 -18
- package/styles/components/figure-zoom.css +62 -0
- package/styles/components/finding-detail.css +62 -0
- package/styles/components/insight-list.css +0 -4
- package/styles/components/insight-trigger.css +8 -6
- 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-detail.css +112 -59
- 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,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 {
|
|
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
|
-
<
|
|
162
|
-
title=
|
|
163
|
-
|
|
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
|
-
<
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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;
|
package/src/model/index.ts
CHANGED
|
@@ -9,12 +9,14 @@ export {
|
|
|
9
9
|
decisionInsights,
|
|
10
10
|
findingEvidence,
|
|
11
11
|
findingLiterature,
|
|
12
|
-
|
|
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' | '
|
|
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;
|
package/src/model/relations.ts
CHANGED
|
@@ -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
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
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
|
-
|
|
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
|
-
*
|
|
49
|
-
* provenance of every
|
|
50
|
-
*
|
|
51
|
-
*
|
|
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
|
|
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
|
-
|
|
56
|
-
const
|
|
57
|
-
const
|
|
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
|
|
60
|
-
|
|
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 (
|
|
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
|
-
|
|
69
|
-
|
|
94
|
+
const next = [...record.provenance.inputPaths, ...(record.resolvedFrom ? [record.resolvedFrom] : [])];
|
|
95
|
+
queue.push(...next.map((path) => ({ path, via })));
|
|
70
96
|
}
|
|
71
|
-
return
|
|
97
|
+
return decisions;
|
|
72
98
|
}
|
|
73
99
|
|
|
74
|
-
/** Inputs,
|
|
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:
|
|
80
|
-
|
|
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;
|
package/src/primitives/index.ts
CHANGED
|
@@ -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';
|