@astra-spec/ui 0.0.4 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (227) hide show
  1. package/README.md +47 -4
  2. package/TOKENS.md +14 -8
  3. package/blocks.css +1 -0
  4. package/components.css +6 -0
  5. package/dist/blocks/analysis-tree.d.ts.map +1 -1
  6. package/dist/blocks/analysis-tree.js +4 -7
  7. package/dist/blocks/analysis-tree.js.map +1 -1
  8. package/dist/blocks/decisions-list.d.ts.map +1 -1
  9. package/dist/blocks/decisions-list.js +1 -1
  10. package/dist/blocks/decisions-list.js.map +1 -1
  11. package/dist/blocks/findings-list.d.ts.map +1 -1
  12. package/dist/blocks/findings-list.js +3 -4
  13. package/dist/blocks/findings-list.js.map +1 -1
  14. package/dist/blocks/index.d.ts +2 -4
  15. package/dist/blocks/index.d.ts.map +1 -1
  16. package/dist/blocks/index.js +1 -2
  17. package/dist/blocks/index.js.map +1 -1
  18. package/dist/blocks/outputs-list.d.ts +2 -7
  19. package/dist/blocks/outputs-list.d.ts.map +1 -1
  20. package/dist/blocks/outputs-list.js +11 -21
  21. package/dist/blocks/outputs-list.js.map +1 -1
  22. package/dist/blocks/papers-list.d.ts.map +1 -1
  23. package/dist/blocks/papers-list.js +3 -3
  24. package/dist/blocks/papers-list.js.map +1 -1
  25. package/dist/blocks/section.d.ts.map +1 -1
  26. package/dist/blocks/section.js +3 -2
  27. package/dist/blocks/section.js.map +1 -1
  28. package/dist/components/figure-zoom.d.ts +6 -0
  29. package/dist/components/figure-zoom.d.ts.map +1 -0
  30. package/dist/components/figure-zoom.js +28 -0
  31. package/dist/components/figure-zoom.js.map +1 -0
  32. package/dist/components/finding-detail.d.ts +4 -2
  33. package/dist/components/finding-detail.d.ts.map +1 -1
  34. package/dist/components/finding-detail.js +41 -25
  35. package/dist/components/finding-detail.js.map +1 -1
  36. package/dist/components/index.d.ts +9 -0
  37. package/dist/components/index.d.ts.map +1 -1
  38. package/dist/components/index.js +5 -0
  39. package/dist/components/index.js.map +1 -1
  40. package/dist/components/insight-trigger.d.ts.map +1 -1
  41. package/dist/components/insight-trigger.js +3 -2
  42. package/dist/components/insight-trigger.js.map +1 -1
  43. package/dist/components/output-card.d.ts +13 -0
  44. package/dist/components/output-card.d.ts.map +1 -0
  45. package/dist/components/output-card.js +12 -0
  46. package/dist/components/output-card.js.map +1 -0
  47. package/dist/components/output-detail.d.ts +6 -2
  48. package/dist/components/output-detail.d.ts.map +1 -1
  49. package/dist/components/output-detail.js +49 -13
  50. package/dist/components/output-detail.js.map +1 -1
  51. package/dist/components/output-dialog.d.ts +6 -1
  52. package/dist/components/output-dialog.d.ts.map +1 -1
  53. package/dist/components/output-dialog.js +2 -2
  54. package/dist/components/output-dialog.js.map +1 -1
  55. package/dist/components/output-entry.d.ts +17 -0
  56. package/dist/components/output-entry.d.ts.map +1 -0
  57. package/dist/components/output-entry.js +21 -0
  58. package/dist/components/output-entry.js.map +1 -0
  59. package/dist/components/output-provenance.d.ts +6 -0
  60. package/dist/components/output-provenance.d.ts.map +1 -0
  61. package/dist/components/output-provenance.js +16 -0
  62. package/dist/components/output-provenance.js.map +1 -0
  63. package/dist/components/output-status.d.ts +8 -0
  64. package/dist/components/output-status.d.ts.map +1 -0
  65. package/dist/components/output-status.js +17 -0
  66. package/dist/components/output-status.js.map +1 -0
  67. package/dist/components/paper-detail.d.ts.map +1 -1
  68. package/dist/components/paper-detail.js +2 -2
  69. package/dist/components/paper-detail.js.map +1 -1
  70. package/dist/components/paper-row.d.ts +9 -0
  71. package/dist/components/paper-row.d.ts.map +1 -0
  72. package/dist/components/paper-row.js +11 -0
  73. package/dist/components/paper-row.js.map +1 -0
  74. package/dist/components/record-dialog.d.ts +5 -1
  75. package/dist/components/record-dialog.d.ts.map +1 -1
  76. package/dist/components/record-dialog.js +7 -4
  77. package/dist/components/record-dialog.js.map +1 -1
  78. package/dist/components/record-preview.d.ts.map +1 -1
  79. package/dist/components/record-preview.js +8 -7
  80. package/dist/components/record-preview.js.map +1 -1
  81. package/dist/lib/labels.d.ts +34 -2
  82. package/dist/lib/labels.d.ts.map +1 -1
  83. package/dist/lib/labels.js +35 -4
  84. package/dist/lib/labels.js.map +1 -1
  85. package/dist/model/index.d.ts +4 -2
  86. package/dist/model/index.d.ts.map +1 -1
  87. package/dist/model/index.js +1 -1
  88. package/dist/model/index.js.map +1 -1
  89. package/dist/model/kind.d.ts +2 -2
  90. package/dist/model/kind.d.ts.map +1 -1
  91. package/dist/model/kind.js +3 -4
  92. package/dist/model/kind.js.map +1 -1
  93. package/dist/model/output-provenance.d.ts +17 -0
  94. package/dist/model/output-provenance.d.ts.map +1 -0
  95. package/dist/model/output-provenance.js +2 -0
  96. package/dist/model/output-provenance.js.map +1 -0
  97. package/dist/model/output-status.d.ts +17 -0
  98. package/dist/model/output-status.d.ts.map +1 -0
  99. package/dist/model/output-status.js +2 -0
  100. package/dist/model/output-status.js.map +1 -0
  101. package/dist/model/relations.d.ts +37 -12
  102. package/dist/model/relations.d.ts.map +1 -1
  103. package/dist/model/relations.js +76 -23
  104. package/dist/model/relations.js.map +1 -1
  105. package/dist/primitives/dialog.d.ts.map +1 -1
  106. package/dist/primitives/dialog.js +9 -1
  107. package/dist/primitives/dialog.js.map +1 -1
  108. package/dist/primitives/index.d.ts +6 -0
  109. package/dist/primitives/index.d.ts.map +1 -1
  110. package/dist/primitives/index.js +3 -0
  111. package/dist/primitives/index.js.map +1 -1
  112. package/dist/primitives/inline-reference.d.ts +9 -0
  113. package/dist/primitives/inline-reference.d.ts.map +1 -0
  114. package/dist/primitives/inline-reference.js +14 -0
  115. package/dist/primitives/inline-reference.js.map +1 -0
  116. package/dist/primitives/kind-glyph.d.ts +8 -0
  117. package/dist/primitives/kind-glyph.d.ts.map +1 -0
  118. package/dist/primitives/kind-glyph.js +9 -0
  119. package/dist/primitives/kind-glyph.js.map +1 -0
  120. package/dist/primitives/output-status-glyph.d.ts +8 -0
  121. package/dist/primitives/output-status-glyph.d.ts.map +1 -0
  122. package/dist/primitives/output-status-glyph.js +13 -0
  123. package/dist/primitives/output-status-glyph.js.map +1 -0
  124. package/dist/primitives/preview-popover.d.ts +1 -1
  125. package/dist/primitives/preview-popover.d.ts.map +1 -1
  126. package/dist/primitives/record-list.d.ts.map +1 -1
  127. package/dist/primitives/record-list.js +3 -2
  128. package/dist/primitives/record-list.js.map +1 -1
  129. package/dist/primitives/relation-list.d.ts.map +1 -1
  130. package/dist/primitives/relation-list.js +3 -2
  131. package/dist/primitives/relation-list.js.map +1 -1
  132. package/dist/primitives/tooltip.d.ts +7 -0
  133. package/dist/primitives/tooltip.d.ts.map +1 -0
  134. package/dist/primitives/tooltip.js +31 -0
  135. package/dist/primitives/tooltip.js.map +1 -0
  136. package/dist/views/inventory.d.ts +12 -1
  137. package/dist/views/inventory.d.ts.map +1 -1
  138. package/dist/views/inventory.js +23 -17
  139. package/dist/views/inventory.js.map +1 -1
  140. package/isolate.css +7 -0
  141. package/package.json +7 -4
  142. package/primitives.css +3 -0
  143. package/src/blocks/analysis-tree.tsx +4 -30
  144. package/src/blocks/decisions-list.tsx +5 -3
  145. package/src/blocks/findings-list.tsx +10 -8
  146. package/src/blocks/index.ts +2 -4
  147. package/src/blocks/outputs-list.tsx +43 -106
  148. package/src/blocks/papers-list.tsx +2 -18
  149. package/src/blocks/section.tsx +3 -2
  150. package/src/components/figure-zoom.tsx +72 -0
  151. package/src/components/finding-detail.tsx +106 -30
  152. package/src/components/index.ts +13 -0
  153. package/src/components/insight-trigger.tsx +3 -2
  154. package/src/components/output-card.tsx +51 -0
  155. package/src/components/output-detail.tsx +69 -21
  156. package/src/components/output-dialog.tsx +9 -0
  157. package/src/components/output-entry.tsx +61 -0
  158. package/src/components/output-provenance.tsx +86 -0
  159. package/src/components/output-status.tsx +38 -0
  160. package/src/components/paper-detail.tsx +2 -2
  161. package/src/components/paper-row.tsx +41 -0
  162. package/src/components/record-dialog.tsx +13 -1
  163. package/src/components/record-preview.tsx +8 -14
  164. package/src/lib/labels.tsx +69 -6
  165. package/src/model/index.ts +6 -2
  166. package/src/model/kind.ts +4 -5
  167. package/src/model/output-provenance.ts +18 -0
  168. package/src/model/output-status.ts +18 -0
  169. package/src/model/relations.ts +92 -26
  170. package/src/primitives/dialog.tsx +7 -1
  171. package/src/primitives/index.ts +6 -0
  172. package/src/primitives/inline-reference.tsx +25 -0
  173. package/src/primitives/kind-glyph.tsx +24 -0
  174. package/src/primitives/output-status-glyph.tsx +37 -0
  175. package/src/primitives/preview-popover.tsx +1 -1
  176. package/src/primitives/record-list.tsx +3 -4
  177. package/src/primitives/relation-list.tsx +4 -7
  178. package/src/primitives/tooltip.tsx +51 -0
  179. package/src/views/inventory.tsx +54 -22
  180. package/styles/base.css +2 -1
  181. package/styles/blocks/analysis-tree.css +23 -26
  182. package/styles/blocks/decisions-list.css +6 -6
  183. package/styles/blocks/findings-list.css +50 -0
  184. package/styles/blocks/outputs-list.css +13 -434
  185. package/styles/blocks/papers-list.css +8 -74
  186. package/styles/blocks/records.css +13 -13
  187. package/styles/components/artifact-preview.css +15 -15
  188. package/styles/components/decision-detail.css +23 -23
  189. package/styles/components/evidence.css +2 -7
  190. package/styles/components/figure-zoom.css +62 -0
  191. package/styles/components/finding-detail.css +73 -11
  192. package/styles/components/input-detail.css +7 -7
  193. package/styles/components/insight-detail.css +17 -17
  194. package/styles/components/insight-list.css +6 -6
  195. package/styles/components/insight-trigger.css +5 -5
  196. package/styles/components/output-card.css +290 -0
  197. package/styles/components/output-detail.css +139 -51
  198. package/styles/components/output-entry.css +141 -0
  199. package/styles/components/output-provenance.css +94 -0
  200. package/styles/components/output-status.css +31 -0
  201. package/styles/components/paper-detail.css +22 -22
  202. package/styles/components/paper-doi.css +2 -2
  203. package/styles/components/paper-pdf-viewer.css +6 -6
  204. package/styles/components/paper-row.css +72 -0
  205. package/styles/components/record-preview.css +444 -268
  206. package/styles/primitives/badge.css +1 -1
  207. package/styles/primitives/button.css +25 -25
  208. package/styles/primitives/count-heading.css +3 -3
  209. package/styles/primitives/detail-layout.css +20 -20
  210. package/styles/primitives/dialog.css +75 -93
  211. package/styles/primitives/empty-state.css +1 -1
  212. package/styles/primitives/inline-reference.css +37 -0
  213. package/styles/primitives/kind-glyph.css +31 -0
  214. package/styles/primitives/kind.css +6 -0
  215. package/styles/primitives/preview-popover.css +6 -11
  216. package/styles/primitives/prose.css +1 -1
  217. package/styles/primitives/record-list.css +32 -48
  218. package/styles/primitives/relation-list.css +14 -36
  219. package/styles/primitives/surface-header.css +15 -11
  220. package/styles/primitives/tooltip.css +22 -0
  221. package/styles/tokens.css +19 -9
  222. package/styles/views/inventory.css +58 -27
  223. package/dist/blocks/prior-insights-list.d.ts +0 -9
  224. package/dist/blocks/prior-insights-list.d.ts.map +0 -1
  225. package/dist/blocks/prior-insights-list.js +0 -29
  226. package/dist/blocks/prior-insights-list.js.map +0 -1
  227. package/src/blocks/prior-insights-list.tsx +0 -52
@@ -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
@@ -5,20 +5,20 @@ export type SurfaceKind = ResolvedRecord['kind'] | 'analysis' | 'paper';
5
5
 
6
6
  const SURFACE_GLYPHS: Record<SurfaceKind, string> = {
7
7
  analysis: '◐',
8
- input: '↳',
8
+ input: '▤',
9
9
  decision: '◇',
10
10
  output: '◆',
11
11
  finding: '●',
12
12
  prior_insight: '◈',
13
- paper: '▧',
13
+ paper: '📄',
14
14
  };
15
15
 
16
- /** The glyph that identifies a kind in lists, relations, and headers. */
16
+ /** Plain-text kind mark. Use KindGlyph for consistent, themed UI rendering. */
17
17
  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;
@@ -46,3 +46,9 @@ export { CountHeading, DetailLayout, DetailMain, DetailRail, DetailSection } fro
46
46
  export type { CountHeadingProps, DetailLayoutMode, DetailLayoutProps, DetailRailProps, DetailSectionProps } from './detail-layout.js';
47
47
  export { Prose } from './prose.js';
48
48
  export type { ProseProps } from './prose.js';
49
+ export { KindGlyph } from './kind-glyph.js';
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';
53
+ export { InlineReference } from './inline-reference.js';
54
+ export type { InlineReferenceProps } from './inline-reference.js';
@@ -0,0 +1,25 @@
1
+ import { Children, cloneElement, forwardRef, type HTMLAttributes, type ReactElement, type ReactNode } from 'react';
2
+ import type { SurfaceKind } from '../model/kind.js';
3
+ import { cn } from '../lib/cn.js';
4
+ import { Slot } from './slot.js';
5
+ import { KindGlyph } from './kind-glyph.js';
6
+
7
+ export interface InlineReferenceProps extends HTMLAttributes<HTMLSpanElement> {
8
+ kind?: SurfaceKind | 'value' | 'option' | undefined;
9
+ asChild?: boolean | undefined;
10
+ }
11
+
12
+ /** Editorial inline token. Hosts own its text, navigation and preview interaction. */
13
+ export const InlineReference = forwardRef<HTMLSpanElement, InlineReferenceProps>(function InlineReference({
14
+ kind, asChild = false, className, children, ...props
15
+ }, ref) {
16
+ const Component = asChild ? Slot : 'span';
17
+ const glyph = kind && kind !== 'value' ? <KindGlyph kind={kind === 'option' ? 'decision' : kind} /> : null;
18
+ const child = asChild ? Children.only(children) as ReactElement<{ children?: ReactNode }> : undefined;
19
+ const content = child ? cloneElement(child, {}, glyph, child.props.children) : <>{glyph}{children}</>;
20
+ return (
21
+ <Component data-slot="inline-reference" {...props} ref={ref} className={cn('astra-ui astra-inline-reference', className)} data-kind={kind}>
22
+ {content}
23
+ </Component>
24
+ );
25
+ });
@@ -0,0 +1,24 @@
1
+ import { forwardRef, type HTMLAttributes } from 'react';
2
+ import { surfaceGlyph, type SurfaceKind } from '../model/kind.js';
3
+ import { cn } from '../lib/cn.js';
4
+
5
+ export interface KindGlyphProps extends HTMLAttributes<HTMLSpanElement> {
6
+ kind: SurfaceKind;
7
+ }
8
+
9
+ /** Decorative kind mark. Its kind selects both symbol and colour; typography is shared across surfaces. */
10
+ export const KindGlyph = forwardRef<HTMLSpanElement, KindGlyphProps>(function KindGlyph({
11
+ kind, className, ...props
12
+ }, ref) {
13
+ return (
14
+ <span data-slot="kind-glyph" {...props} ref={ref} className={cn('astra-kind-glyph', className)} data-kind={kind} aria-hidden="true">
15
+ {kind === 'paper' ? (
16
+ <svg viewBox="0 0 24 24" width="1em" height="1em" fill="none" stroke="currentColor"
17
+ strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true" focusable="false">
18
+ <path d="M14 3H6a1 1 0 0 0-1 1v16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V8l-5-5Z" />
19
+ <path d="M14 3v5h5M8 12h8M8 16h6" />
20
+ </svg>
21
+ ) : surfaceGlyph(kind)}
22
+ </span>
23
+ );
24
+ });
@@ -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
+ });
@@ -57,7 +57,7 @@ export interface PreviewPopoverProps
57
57
  children: ReactNode;
58
58
  /** Accessible name for the non-modal preview dialog. */
59
59
  label: string;
60
- kind?: SurfaceKind | undefined;
60
+ kind?: SurfaceKind | 'value' | undefined;
61
61
  disabled?: boolean | undefined;
62
62
  open?: boolean | undefined;
63
63
  defaultOpen?: boolean | undefined;
@@ -1,6 +1,7 @@
1
+ import { KindGlyph } from './kind-glyph.js';
1
2
  import { forwardRef, type CSSProperties, type HTMLAttributes, type ReactNode } from 'react';
2
3
  import { cn } from '../lib/cn.js';
3
- import { surfaceGlyph, type SurfaceKind } from '../model/kind.js';
4
+ import { type SurfaceKind } from '../model/kind.js';
4
5
 
5
6
  export interface RecordListColumn {
6
7
  label?: string | undefined;
@@ -85,9 +86,7 @@ export const RecordIdentity = forwardRef<HTMLSpanElement, RecordIdentityProps>(f
85
86
  }, ref) {
86
87
  return (
87
88
  <span data-slot="record-identity" {...props} ref={ref} className={cn('astra-record-list__name', className)}>
88
- <span className="astra-record-list__glyph" data-kind={kind} aria-hidden="true">
89
- {surfaceGlyph(kind)}
90
- </span>
89
+ <KindGlyph className="astra-record-list__glyph" kind={kind} />
91
90
  <span>
92
91
  <strong>{title}</strong>
93
92
  {subtitle != null ? <small>{subtitle}</small> : null}
@@ -1,7 +1,8 @@
1
+ import { KindGlyph } from './kind-glyph.js';
1
2
  import { forwardRef, type HTMLAttributes, type ReactNode } from 'react';
2
3
  import { cn } from '../lib/cn.js';
3
4
  import { CountHeading } from './detail-layout.js';
4
- import { surfaceGlyph, type SurfaceKind } from '../model/kind.js';
5
+ import { type SurfaceKind } from '../model/kind.js';
5
6
 
6
7
  export interface RelationItem {
7
8
  key: string;
@@ -25,12 +26,8 @@ export interface RelationListProps extends Omit<HTMLAttributes<HTMLElement>, 'ti
25
26
  function RelationItemContent({ item }: { item: RelationItem }) {
26
27
  return (
27
28
  <>
28
- <span
29
- className="astra-relation-item__glyph"
30
- {...(item.kind ? {} : { 'data-empty': '' })}
31
- aria-hidden="true"
32
- >
33
- {item.kind ? surfaceGlyph(item.kind) : ''}
29
+ <span className="astra-relation-item__glyph" data-empty={!item.kind ? '' : undefined} aria-hidden="true">
30
+ {item.kind ? <KindGlyph kind={item.kind} /> : null}
34
31
  </span>
35
32
  <span className="astra-relation-item__copy">
36
33
  <span className="astra-relation-item__label">{item.label}</span>
@@ -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
+ }