@astra-spec/ui 0.0.5 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +47 -4
- package/blocks.css +1 -0
- package/components.css +6 -0
- package/dist/blocks/analysis-tree.d.ts.map +1 -1
- package/dist/blocks/analysis-tree.js +4 -7
- package/dist/blocks/analysis-tree.js.map +1 -1
- package/dist/blocks/decisions-list.d.ts.map +1 -1
- package/dist/blocks/decisions-list.js +1 -1
- package/dist/blocks/decisions-list.js.map +1 -1
- package/dist/blocks/findings-list.d.ts.map +1 -1
- package/dist/blocks/findings-list.js +2 -4
- package/dist/blocks/findings-list.js.map +1 -1
- package/dist/blocks/index.d.ts +2 -4
- package/dist/blocks/index.d.ts.map +1 -1
- package/dist/blocks/index.js +1 -2
- package/dist/blocks/index.js.map +1 -1
- package/dist/blocks/outputs-list.d.ts +2 -7
- package/dist/blocks/outputs-list.d.ts.map +1 -1
- package/dist/blocks/outputs-list.js +11 -21
- package/dist/blocks/outputs-list.js.map +1 -1
- package/dist/blocks/papers-list.d.ts.map +1 -1
- package/dist/blocks/papers-list.js +3 -3
- package/dist/blocks/papers-list.js.map +1 -1
- package/dist/components/figure-zoom.d.ts +6 -0
- package/dist/components/figure-zoom.d.ts.map +1 -0
- package/dist/components/figure-zoom.js +28 -0
- package/dist/components/figure-zoom.js.map +1 -0
- package/dist/components/finding-detail.d.ts +4 -2
- package/dist/components/finding-detail.d.ts.map +1 -1
- package/dist/components/finding-detail.js +41 -25
- package/dist/components/finding-detail.js.map +1 -1
- package/dist/components/index.d.ts +9 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +5 -0
- package/dist/components/index.js.map +1 -1
- package/dist/components/output-card.d.ts +13 -0
- package/dist/components/output-card.d.ts.map +1 -0
- package/dist/components/output-card.js +12 -0
- package/dist/components/output-card.js.map +1 -0
- package/dist/components/output-detail.d.ts +6 -2
- package/dist/components/output-detail.d.ts.map +1 -1
- package/dist/components/output-detail.js +49 -13
- package/dist/components/output-detail.js.map +1 -1
- package/dist/components/output-dialog.d.ts +6 -1
- package/dist/components/output-dialog.d.ts.map +1 -1
- package/dist/components/output-dialog.js +2 -2
- package/dist/components/output-dialog.js.map +1 -1
- package/dist/components/output-entry.d.ts +17 -0
- package/dist/components/output-entry.d.ts.map +1 -0
- package/dist/components/output-entry.js +21 -0
- package/dist/components/output-entry.js.map +1 -0
- package/dist/components/output-provenance.d.ts +6 -0
- package/dist/components/output-provenance.d.ts.map +1 -0
- package/dist/components/output-provenance.js +16 -0
- package/dist/components/output-provenance.js.map +1 -0
- package/dist/components/output-status.d.ts +8 -0
- package/dist/components/output-status.d.ts.map +1 -0
- package/dist/components/output-status.js +17 -0
- package/dist/components/output-status.js.map +1 -0
- package/dist/components/paper-row.d.ts +9 -0
- package/dist/components/paper-row.d.ts.map +1 -0
- package/dist/components/paper-row.js +11 -0
- package/dist/components/paper-row.js.map +1 -0
- package/dist/components/record-dialog.d.ts +5 -1
- package/dist/components/record-dialog.d.ts.map +1 -1
- package/dist/components/record-dialog.js +7 -4
- package/dist/components/record-dialog.js.map +1 -1
- package/dist/lib/labels.d.ts +34 -2
- package/dist/lib/labels.d.ts.map +1 -1
- package/dist/lib/labels.js +35 -4
- package/dist/lib/labels.js.map +1 -1
- package/dist/model/index.d.ts +4 -2
- package/dist/model/index.d.ts.map +1 -1
- package/dist/model/index.js +1 -1
- package/dist/model/index.js.map +1 -1
- package/dist/model/kind.d.ts +1 -1
- package/dist/model/kind.d.ts.map +1 -1
- package/dist/model/kind.js +0 -1
- package/dist/model/kind.js.map +1 -1
- package/dist/model/output-provenance.d.ts +17 -0
- package/dist/model/output-provenance.d.ts.map +1 -0
- package/dist/model/output-provenance.js +2 -0
- package/dist/model/output-provenance.js.map +1 -0
- package/dist/model/output-status.d.ts +17 -0
- package/dist/model/output-status.d.ts.map +1 -0
- package/dist/model/output-status.js +2 -0
- package/dist/model/output-status.js.map +1 -0
- package/dist/model/relations.d.ts +37 -12
- package/dist/model/relations.d.ts.map +1 -1
- package/dist/model/relations.js +76 -23
- package/dist/model/relations.js.map +1 -1
- package/dist/primitives/dialog.d.ts.map +1 -1
- package/dist/primitives/dialog.js +9 -1
- package/dist/primitives/dialog.js.map +1 -1
- package/dist/primitives/index.d.ts +2 -0
- package/dist/primitives/index.d.ts.map +1 -1
- package/dist/primitives/index.js +1 -0
- package/dist/primitives/index.js.map +1 -1
- package/dist/primitives/output-status-glyph.d.ts +8 -0
- package/dist/primitives/output-status-glyph.d.ts.map +1 -0
- package/dist/primitives/output-status-glyph.js +13 -0
- package/dist/primitives/output-status-glyph.js.map +1 -0
- package/dist/primitives/tooltip.d.ts +7 -0
- package/dist/primitives/tooltip.d.ts.map +1 -0
- package/dist/primitives/tooltip.js +31 -0
- package/dist/primitives/tooltip.js.map +1 -0
- package/dist/views/inventory.d.ts +12 -1
- package/dist/views/inventory.d.ts.map +1 -1
- package/dist/views/inventory.js +23 -17
- package/dist/views/inventory.js.map +1 -1
- package/package.json +3 -2
- package/primitives.css +1 -0
- package/src/blocks/analysis-tree.tsx +4 -30
- package/src/blocks/decisions-list.tsx +5 -3
- package/src/blocks/findings-list.tsx +8 -7
- package/src/blocks/index.ts +2 -4
- package/src/blocks/outputs-list.tsx +43 -106
- package/src/blocks/papers-list.tsx +2 -18
- package/src/components/figure-zoom.tsx +72 -0
- package/src/components/finding-detail.tsx +106 -30
- package/src/components/index.ts +13 -0
- package/src/components/output-card.tsx +51 -0
- package/src/components/output-detail.tsx +69 -21
- package/src/components/output-dialog.tsx +9 -0
- package/src/components/output-entry.tsx +61 -0
- package/src/components/output-provenance.tsx +86 -0
- package/src/components/output-status.tsx +38 -0
- package/src/components/paper-row.tsx +41 -0
- package/src/components/record-dialog.tsx +13 -1
- package/src/lib/labels.tsx +69 -6
- package/src/model/index.ts +6 -2
- package/src/model/kind.ts +1 -2
- package/src/model/output-provenance.ts +18 -0
- package/src/model/output-status.ts +18 -0
- package/src/model/relations.ts +92 -26
- package/src/primitives/dialog.tsx +7 -1
- package/src/primitives/index.ts +2 -0
- package/src/primitives/output-status-glyph.tsx +37 -0
- package/src/primitives/tooltip.tsx +51 -0
- package/src/views/inventory.tsx +54 -22
- package/styles/base.css +2 -1
- package/styles/blocks/analysis-tree.css +22 -25
- package/styles/blocks/findings-list.css +50 -0
- package/styles/blocks/outputs-list.css +0 -421
- package/styles/blocks/papers-list.css +4 -70
- package/styles/components/figure-zoom.css +62 -0
- package/styles/components/finding-detail.css +62 -0
- package/styles/components/output-card.css +290 -0
- package/styles/components/output-detail.css +91 -3
- package/styles/components/output-entry.css +141 -0
- package/styles/components/output-provenance.css +94 -0
- package/styles/components/output-status.css +31 -0
- package/styles/components/paper-row.css +72 -0
- package/styles/primitives/dialog.css +4 -22
- package/styles/primitives/tooltip.css +22 -0
- package/styles/views/inventory.css +35 -2
- package/dist/blocks/prior-insights-list.d.ts +0 -9
- package/dist/blocks/prior-insights-list.d.ts.map +0 -1
- package/dist/blocks/prior-insights-list.js +0 -29
- package/dist/blocks/prior-insights-list.js.map +0 -1
- package/src/blocks/prior-insights-list.tsx +0 -52
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';
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { forwardRef, type SVGAttributes } from 'react';
|
|
2
|
+
import type { OutputStatus } from '../model/output-status.js';
|
|
3
|
+
|
|
4
|
+
export interface OutputStatusGlyphProps extends SVGAttributes<SVGSVGElement> {
|
|
5
|
+
state: OutputStatus['state'];
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
/** One 16×16 glyph per state, so every surface that draws a status draws the same mark. */
|
|
9
|
+
const paths: Record<OutputStatus['state'], string> = {
|
|
10
|
+
current: 'm3.5 8 3 3 6-6',
|
|
11
|
+
behind: 'M12.5 5A5 5 0 1 0 13 9M12.5 1.5V5H9',
|
|
12
|
+
stale: 'm4.5 4.5 7 7m0-7-7 7',
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
/** Decorative execution-state mark; the surface around it supplies colour and the accessible name. */
|
|
16
|
+
export const OutputStatusGlyph = forwardRef<SVGSVGElement, OutputStatusGlyphProps>(function OutputStatusGlyph({
|
|
17
|
+
state, ...props
|
|
18
|
+
}, ref) {
|
|
19
|
+
return (
|
|
20
|
+
<svg
|
|
21
|
+
data-slot="output-status-glyph"
|
|
22
|
+
width="14"
|
|
23
|
+
height="14"
|
|
24
|
+
viewBox="0 0 16 16"
|
|
25
|
+
fill="none"
|
|
26
|
+
stroke="currentColor"
|
|
27
|
+
strokeWidth="1.5"
|
|
28
|
+
aria-hidden="true"
|
|
29
|
+
focusable="false"
|
|
30
|
+
{...props}
|
|
31
|
+
ref={ref}
|
|
32
|
+
data-state={state}
|
|
33
|
+
>
|
|
34
|
+
<path d={paths[state]} strokeLinecap="round" strokeLinejoin="round" />
|
|
35
|
+
</svg>
|
|
36
|
+
);
|
|
37
|
+
});
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/* eslint-disable react-hooks/refs, @typescript-eslint/unbound-method -- Floating UI uses callback refs during render. */
|
|
2
|
+
import {
|
|
3
|
+
FloatingPortal, autoUpdate, flip, offset, shift,
|
|
4
|
+
useDismiss, useFloating, useFocus, useHover, useInteractions, useRole,
|
|
5
|
+
} from '@floating-ui/react';
|
|
6
|
+
import { useCallback, useState, type ReactElement } from 'react';
|
|
7
|
+
import { Slot } from './slot.js';
|
|
8
|
+
|
|
9
|
+
/** A small, non-interactive explanation. Preserves the trigger's tab order. */
|
|
10
|
+
export function Tooltip({ children, content }: { children: ReactElement; content: string }) {
|
|
11
|
+
const [open, setOpen] = useState(false);
|
|
12
|
+
const [portalRoot, setPortalRoot] = useState<HTMLElement | null>(null);
|
|
13
|
+
const { refs, floatingStyles, context } = useFloating({
|
|
14
|
+
open,
|
|
15
|
+
onOpenChange: setOpen,
|
|
16
|
+
placement: 'top',
|
|
17
|
+
strategy: 'fixed',
|
|
18
|
+
whileElementsMounted: autoUpdate,
|
|
19
|
+
middleware: [offset(6), flip({ padding: 8 }), shift({ padding: 8 })],
|
|
20
|
+
});
|
|
21
|
+
const hover = useHover(context, { move: false, delay: { open: 150, close: 100 } });
|
|
22
|
+
const focus = useFocus(context);
|
|
23
|
+
const dismiss = useDismiss(context);
|
|
24
|
+
const role = useRole(context, { role: 'tooltip' });
|
|
25
|
+
const { getReferenceProps, getFloatingProps } = useInteractions([hover, focus, dismiss, role]);
|
|
26
|
+
const setFloatingReference = refs.setReference;
|
|
27
|
+
// Preserve host theme tokens and native-dialog stacking, outside clipped previews.
|
|
28
|
+
const setReference = useCallback((element: HTMLElement | null) => {
|
|
29
|
+
setFloatingReference(element);
|
|
30
|
+
setPortalRoot(element?.closest<HTMLElement>('dialog, .astra-ui') ?? null);
|
|
31
|
+
}, [setFloatingReference]);
|
|
32
|
+
return (
|
|
33
|
+
<>
|
|
34
|
+
<Slot ref={setReference} {...getReferenceProps()}>{children}</Slot>
|
|
35
|
+
{open ? (
|
|
36
|
+
<FloatingPortal root={portalRoot ?? undefined}>
|
|
37
|
+
<div className={portalRoot ? undefined : 'astra-ui'}>
|
|
38
|
+
<div
|
|
39
|
+
{...getFloatingProps()}
|
|
40
|
+
ref={refs.setFloating}
|
|
41
|
+
style={floatingStyles}
|
|
42
|
+
className="astra-tooltip"
|
|
43
|
+
>
|
|
44
|
+
{content}
|
|
45
|
+
</div>
|
|
46
|
+
</div>
|
|
47
|
+
</FloatingPortal>
|
|
48
|
+
) : null}
|
|
49
|
+
</>
|
|
50
|
+
);
|
|
51
|
+
}
|
package/src/views/inventory.tsx
CHANGED
|
@@ -6,42 +6,53 @@ import {
|
|
|
6
6
|
type ResolvedOutput,
|
|
7
7
|
type ResolvedRecord,
|
|
8
8
|
} from '@astra-spec/sdk';
|
|
9
|
-
import { forwardRef, useEffect, useMemo, useRef, type HTMLAttributes, type ReactNode } from 'react';
|
|
9
|
+
import { forwardRef, useEffect, useMemo, useRef, useState, type HTMLAttributes, type ReactNode } from 'react';
|
|
10
10
|
import { collectInventoryPapers, findPaper, paperForDoi, type InventoryPaper, type InventoryPaperMetadataMap } from '../model/papers.js';
|
|
11
11
|
import { locateRecord } from '../model/locate-record.js';
|
|
12
12
|
import { cn } from '../lib/cn.js';
|
|
13
13
|
import { LabelsProvider, useLabels, type AstraLabelOverrides } from '../lib/labels.js';
|
|
14
14
|
import type { OpenPaperFileHandler } from '../components/paper-detail.js';
|
|
15
15
|
import type { PdfJsLoader } from '../lib/pdf-runtime.js';
|
|
16
|
+
import type { OutputStatusLookup } from '../model/output-status.js';
|
|
16
17
|
import { RecordDialog } from '../components/record-dialog.js';
|
|
17
18
|
import { useDetailStack, type DetailEntry } from '../lib/detail-stack.js';
|
|
18
19
|
import type { ArtifactRenderer } from '../components/artifact-preview.js';
|
|
19
20
|
import { DialogProvider, type DialogMode } from '../primitives/dialog.js';
|
|
20
21
|
import type { TextRenderer } from '../lib/prose.js';
|
|
21
22
|
import { DecisionsList } from '../blocks/decisions-list.js';
|
|
23
|
+
import { AnalysisTree } from '../blocks/analysis-tree.js';
|
|
22
24
|
import { FindingsList } from '../blocks/findings-list.js';
|
|
23
25
|
import { InputsList } from '../blocks/inputs-list.js';
|
|
24
26
|
import { OutputsList } from '../blocks/outputs-list.js';
|
|
25
27
|
import { PapersList } from '../blocks/papers-list.js';
|
|
26
|
-
import { PriorInsightsList } from '../blocks/prior-insights-list.js';
|
|
27
28
|
import { InventoryOutline, InventorySection } from '../blocks/section.js';
|
|
28
29
|
import { sectionKind, type InventorySectionId } from '../model/kind.js';
|
|
29
30
|
|
|
30
|
-
export const DEFAULT_SECTIONS: readonly InventorySectionId[] = ['outputs', 'decisions', 'inputs', 'findings', '
|
|
31
|
+
export const DEFAULT_SECTIONS: readonly InventorySectionId[] = ['outputs', 'decisions', 'inputs', 'findings', 'papers'];
|
|
31
32
|
|
|
32
33
|
export interface InventoryProps extends Omit<HTMLAttributes<HTMLDivElement>, 'children'> {
|
|
33
34
|
document: ResolvedAnalysisDocument;
|
|
34
35
|
/** Pass a prebuilt index to share it with the host; otherwise one is derived from `document`. */
|
|
35
36
|
index?: AnalysisIndex | undefined;
|
|
36
|
-
/**
|
|
37
|
+
/** Controlled analysis selection; pair with `onSelectAnalysis`. Omit to let Inventory navigate internally. Unknown paths show the root. */
|
|
37
38
|
analysisPath?: string | undefined;
|
|
39
|
+
/** Observe navigation, or update `analysisPath` when controlling selection. */
|
|
40
|
+
onSelectAnalysis?: ((canonicalPath: string) => void) | undefined;
|
|
38
41
|
/** Which sections to show, in order. */
|
|
39
42
|
sections?: readonly InventorySectionId[] | undefined;
|
|
40
43
|
/** Prefix for section anchor ids, so several explorers can share a page. */
|
|
41
44
|
idPrefix?: string | undefined;
|
|
42
45
|
showOutline?: boolean | undefined;
|
|
46
|
+
/** Show project navigation below the outline (default true). Hosts controlling `analysisPath` must pair it with `onSelectAnalysis`. */
|
|
47
|
+
showHierarchy?: boolean | undefined;
|
|
43
48
|
labels?: AstraLabelOverrides | undefined;
|
|
44
49
|
renderArtifact?: ArtifactRenderer | undefined;
|
|
50
|
+
/** Host renderer for recorded output provenance, shown below Recipe. */
|
|
51
|
+
renderProvenance?: ((output: ResolvedOutput) => ReactNode) | undefined;
|
|
52
|
+
/** Optional execution status, keyed by the host to the selected universe. */
|
|
53
|
+
getOutputStatus?: OutputStatusLookup | undefined;
|
|
54
|
+
/** Host-provided link to the current code file, shown beside Recipe. */
|
|
55
|
+
renderCodeLink?: ((output: ResolvedOutput) => ReactNode) | undefined;
|
|
45
56
|
renderText?: TextRenderer | undefined;
|
|
46
57
|
loadPdfJs?: PdfJsLoader | undefined;
|
|
47
58
|
onOpenPaperFile?: OpenPaperFileHandler | undefined;
|
|
@@ -83,11 +94,16 @@ export const Inventory = forwardRef<HTMLDivElement, InventoryProps>(function Inv
|
|
|
83
94
|
const ExplorerBody = forwardRef<HTMLDivElement, Omit<InventoryProps, 'labels'>>(function ExplorerBody({
|
|
84
95
|
document,
|
|
85
96
|
index: providedIndex,
|
|
86
|
-
analysisPath
|
|
97
|
+
analysisPath,
|
|
98
|
+
onSelectAnalysis,
|
|
87
99
|
sections = DEFAULT_SECTIONS,
|
|
88
100
|
idPrefix = '',
|
|
89
101
|
showOutline = true,
|
|
102
|
+
showHierarchy = true,
|
|
90
103
|
renderArtifact,
|
|
104
|
+
renderProvenance,
|
|
105
|
+
getOutputStatus,
|
|
106
|
+
renderCodeLink,
|
|
91
107
|
renderText,
|
|
92
108
|
loadPdfJs,
|
|
93
109
|
onOpenPaperFile,
|
|
@@ -105,7 +121,16 @@ const ExplorerBody = forwardRef<HTMLDivElement, Omit<InventoryProps, 'labels'>>(
|
|
|
105
121
|
}, ref) {
|
|
106
122
|
const labels = useLabels();
|
|
107
123
|
const index = useMemo(() => providedIndex ?? indexAnalysis(document), [document, providedIndex]);
|
|
108
|
-
const
|
|
124
|
+
const [internalAnalysisPath, setInternalAnalysisPath] = useState('$');
|
|
125
|
+
// Reset a removed selection so reintroducing that path does not navigate back.
|
|
126
|
+
if (analysisPath === undefined && internalAnalysisPath !== '$' && !index.analysisByPath.has(internalAnalysisPath)) {
|
|
127
|
+
setInternalAnalysisPath('$');
|
|
128
|
+
}
|
|
129
|
+
const analysis = index.analysisByPath.get(analysisPath ?? internalAnalysisPath) ?? document.analysis;
|
|
130
|
+
const selectAnalysis = (path: string) => {
|
|
131
|
+
if (analysisPath === undefined) setInternalAnalysisPath(path);
|
|
132
|
+
onSelectAnalysis?.(path);
|
|
133
|
+
};
|
|
109
134
|
const papers = useMemo(
|
|
110
135
|
() => collectInventoryPapers(document, index, analysis, paperMetadata),
|
|
111
136
|
[analysis, document, index, paperMetadata],
|
|
@@ -141,7 +166,7 @@ const ExplorerBody = forwardRef<HTMLDivElement, Omit<InventoryProps, 'labels'>>(
|
|
|
141
166
|
const sectionContent: Record<InventorySectionId, { count: number; content: ReactNode }> = {
|
|
142
167
|
outputs: {
|
|
143
168
|
count: analysis.outputs.length,
|
|
144
|
-
content: <OutputsList analysis={analysis} renderArtifact={renderArtifact} onOpenRecord={openRecord} />,
|
|
169
|
+
content: <OutputsList analysis={analysis} getOutputStatus={getOutputStatus} renderArtifact={renderArtifact} onOpenRecord={openRecord} />,
|
|
145
170
|
},
|
|
146
171
|
decisions: {
|
|
147
172
|
count: analysis.decisions.length,
|
|
@@ -155,10 +180,6 @@ const ExplorerBody = forwardRef<HTMLDivElement, Omit<InventoryProps, 'labels'>>(
|
|
|
155
180
|
count: analysis.findings.length,
|
|
156
181
|
content: <FindingsList analysis={analysis} onOpenRecord={openRecord} />,
|
|
157
182
|
},
|
|
158
|
-
prior_insights: {
|
|
159
|
-
count: analysis.prior_insights.length,
|
|
160
|
-
content: <PriorInsightsList analysis={analysis} onOpenRecord={openRecord} />,
|
|
161
|
-
},
|
|
162
183
|
papers: {
|
|
163
184
|
count: papers.length,
|
|
164
185
|
content: (
|
|
@@ -170,11 +191,11 @@ const ExplorerBody = forwardRef<HTMLDivElement, Omit<InventoryProps, 'labels'>>(
|
|
|
170
191
|
),
|
|
171
192
|
},
|
|
172
193
|
};
|
|
173
|
-
const anchorId = (section: InventorySectionId) => `${idPrefix}${section
|
|
194
|
+
const anchorId = (section: InventorySectionId) => `${idPrefix}${section}`;
|
|
174
195
|
|
|
175
196
|
return (
|
|
176
197
|
<div data-slot="inventory" {...rest} ref={ref} className={cn('astra-inventory', className)}>
|
|
177
|
-
<div className="astra-inventory__layout">
|
|
198
|
+
<div className="astra-inventory__layout" data-sidebar={showOutline || showHierarchy ? '' : undefined}>
|
|
178
199
|
<div className="astra-inventory__sections">
|
|
179
200
|
{sections.map((section) => (
|
|
180
201
|
<InventorySection
|
|
@@ -190,15 +211,24 @@ const ExplorerBody = forwardRef<HTMLDivElement, Omit<InventoryProps, 'labels'>>(
|
|
|
190
211
|
))}
|
|
191
212
|
{children}
|
|
192
213
|
</div>
|
|
193
|
-
{showOutline ? (
|
|
194
|
-
<
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
214
|
+
{showOutline || showHierarchy ? (
|
|
215
|
+
<div className="astra-inventory__sidebar" data-has-tree={showHierarchy ? '' : undefined}>
|
|
216
|
+
{showOutline ? <InventoryOutline
|
|
217
|
+
entries={sections.map((section) => ({
|
|
218
|
+
id: anchorId(section),
|
|
219
|
+
label: labels.sections[section],
|
|
220
|
+
count: sectionContent[section].count,
|
|
221
|
+
kind: sectionKind(section),
|
|
222
|
+
}))}
|
|
223
|
+
/> : null}
|
|
224
|
+
{showHierarchy ? (
|
|
225
|
+
<AnalysisTree
|
|
226
|
+
document={document}
|
|
227
|
+
analysisPath={analysis.canonicalPath}
|
|
228
|
+
onSelectAnalysis={selectAnalysis}
|
|
229
|
+
/>
|
|
230
|
+
) : null}
|
|
231
|
+
</div>
|
|
202
232
|
) : null}
|
|
203
233
|
</div>
|
|
204
234
|
{stack.active ? (
|
|
@@ -211,6 +241,8 @@ const ExplorerBody = forwardRef<HTMLDivElement, Omit<InventoryProps, 'labels'>>(
|
|
|
211
241
|
papers={papers}
|
|
212
242
|
paperMetadata={paperMetadata}
|
|
213
243
|
renderArtifact={renderArtifact}
|
|
244
|
+
renderProvenance={renderProvenance}
|
|
245
|
+
renderCodeLink={renderCodeLink}
|
|
214
246
|
renderText={renderText}
|
|
215
247
|
loadPdfJs={loadPdfJs}
|
|
216
248
|
onOpenPaperFile={onOpenPaperFile}
|
package/styles/base.css
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
@layer astra.tokens, astra.base, astra.components, astra.views;
|
|
3
3
|
@layer astra.views {
|
|
4
4
|
:where(.astra-ui) .astra-analysis-tree {
|
|
5
|
-
overflow: visible;
|
|
6
5
|
font-family: var(--astra-font-ui);
|
|
7
6
|
}
|
|
8
7
|
|
|
@@ -21,44 +20,42 @@
|
|
|
21
20
|
list-style: none;
|
|
22
21
|
}
|
|
23
22
|
|
|
24
|
-
:where(.astra-ui) .astra-analysis-tree
|
|
25
|
-
|
|
23
|
+
:where(.astra-ui) .astra-analysis-tree ul ul {
|
|
24
|
+
margin-inline-start: 20px;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/* Indent four levels at most, so deep projects keep room for their labels. */
|
|
28
|
+
:where(.astra-ui) .astra-analysis-tree ul ul ul ul ul ul {
|
|
29
|
+
margin-inline-start: 0;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
:where(.astra-ui) .astra-analysis-tree__select {
|
|
33
|
+
display: block;
|
|
26
34
|
width: 100%;
|
|
27
|
-
|
|
28
|
-
|
|
35
|
+
min-width: 0;
|
|
36
|
+
padding: 7px 0;
|
|
29
37
|
cursor: pointer;
|
|
30
38
|
border: 0;
|
|
31
|
-
border-radius:
|
|
39
|
+
border-radius: 0;
|
|
32
40
|
background: transparent;
|
|
33
|
-
color: var(--astra-color-text-
|
|
34
|
-
padding: 6px 8px;
|
|
41
|
+
color: var(--astra-color-text-subtle);
|
|
35
42
|
font: inherit;
|
|
36
43
|
font-size: var(--astra-font-size-sm);
|
|
37
|
-
line-height: 1.
|
|
44
|
+
line-height: 1.4;
|
|
38
45
|
text-align: start;
|
|
39
46
|
}
|
|
40
47
|
|
|
41
|
-
:where(.astra-ui) .astra-analysis-
|
|
42
|
-
flex: 0 0 auto;
|
|
43
|
-
color: var(--astra-color-kind-analysis);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
:where(.astra-ui) .astra-analysis-tree button span {
|
|
48
|
+
:where(.astra-ui) .astra-analysis-tree__select span {
|
|
47
49
|
min-width: 0;
|
|
48
|
-
overflow:
|
|
49
|
-
text-overflow: ellipsis;
|
|
50
|
-
white-space: nowrap;
|
|
50
|
+
overflow-wrap: anywhere;
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
:where(.astra-ui) .astra-analysis-
|
|
54
|
-
|
|
55
|
-
background: var(--astra-color-surface-muted);
|
|
56
|
-
color: var(--astra-color-text);
|
|
53
|
+
:where(.astra-ui) .astra-analysis-tree__select:where([aria-current="page"]) {
|
|
54
|
+
font-weight: 700;
|
|
57
55
|
}
|
|
58
56
|
|
|
59
|
-
:where(.astra-ui) .astra-analysis-
|
|
60
|
-
|
|
57
|
+
:where(.astra-ui) .astra-analysis-tree__select:hover,
|
|
58
|
+
:where(.astra-ui) .astra-analysis-tree__select:focus-visible {
|
|
61
59
|
color: var(--astra-color-text);
|
|
62
|
-
font-weight: 700;
|
|
63
60
|
}
|
|
64
61
|
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/* findings-list — emitted by src/blocks/findings-list.tsx */
|
|
2
|
+
@layer astra.tokens, astra.base, astra.components, astra.views;
|
|
3
|
+
@layer astra.views {
|
|
4
|
+
/* A finding is a sentence, not a name: the row gives it the width to be
|
|
5
|
+
read, and hangs its identity and evidence count underneath. */
|
|
6
|
+
:where(.astra-ui) .astra-findings-list__entry {
|
|
7
|
+
align-items: start;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
:where(.astra-ui) .astra-findings-list__copy {
|
|
11
|
+
display: grid;
|
|
12
|
+
min-width: 0;
|
|
13
|
+
gap: 5px;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
:where(.astra-ui) .astra-findings-list__entry .astra-findings-list__claim {
|
|
17
|
+
overflow: visible;
|
|
18
|
+
color: var(--astra-color-text);
|
|
19
|
+
font: 400 var(--astra-font-size-sm)/1.45 var(--astra-font-body);
|
|
20
|
+
text-overflow: clip;
|
|
21
|
+
white-space: normal;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
:where(.astra-ui) .astra-findings-list__meta {
|
|
25
|
+
display: flex;
|
|
26
|
+
flex-wrap: wrap;
|
|
27
|
+
align-items: baseline;
|
|
28
|
+
gap: 4px 10px;
|
|
29
|
+
color: var(--astra-color-text-subtle);
|
|
30
|
+
font: 400 var(--astra-font-size-2xs)/1.3 var(--astra-font-ui);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
:where(.astra-ui) .astra-findings-list__entry .astra-findings-list__name {
|
|
34
|
+
overflow: visible;
|
|
35
|
+
color: var(--astra-color-kind-finding);
|
|
36
|
+
font-family: var(--astra-font-mono);
|
|
37
|
+
text-overflow: clip;
|
|
38
|
+
white-space: normal;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/* The evidence count now belongs to the metadata line, not a fixed column. */
|
|
42
|
+
:where(.astra-ui) .astra-findings-list__meta .astra-record-list__count {
|
|
43
|
+
overflow: visible;
|
|
44
|
+
color: inherit;
|
|
45
|
+
font: inherit;
|
|
46
|
+
text-overflow: clip;
|
|
47
|
+
white-space: normal;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
}
|