@xynolog/react-ui 0.8.0 → 0.8.1

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 (235) hide show
  1. package/README.md +26 -46
  2. package/package.json +12 -9
  3. package/src/components/Button/Button.tsx +0 -188
  4. package/src/components/Button/__tests__/Button.test.tsx +0 -449
  5. package/src/components/CodeMirrorRenderer.tsx +0 -536
  6. package/src/components/DelegateProgress.tsx +0 -308
  7. package/src/components/ErrorBoundary.tsx +0 -174
  8. package/src/components/ItemFoundLog.tsx +0 -42
  9. package/src/components/LiveRegion.tsx +0 -261
  10. package/src/components/ProtectedErrorBoundary.tsx +0 -114
  11. package/src/components/ResizeHandle.tsx +0 -167
  12. package/src/components/ResourceTagsInline.tsx +0 -120
  13. package/src/components/SessionExpiryBanner.tsx +0 -74
  14. package/src/components/SessionTimer.tsx +0 -17
  15. package/src/components/StatusDisplay.tsx +0 -131
  16. package/src/components/Toast.tsx +0 -217
  17. package/src/components/Toolbar.tsx +0 -194
  18. package/src/components/UserMenuSkeleton.tsx +0 -13
  19. package/src/components/__tests__/DelegateProgress.denominator.test.tsx +0 -102
  20. package/src/components/__tests__/DelegateProgress.test.tsx +0 -649
  21. package/src/components/__tests__/ErrorBoundary.test.tsx +0 -565
  22. package/src/components/__tests__/LiveRegion.a11y.test.tsx +0 -258
  23. package/src/components/__tests__/LiveRegion.hooks.test.tsx +0 -140
  24. package/src/components/__tests__/ProtectedErrorBoundary.test.tsx +0 -225
  25. package/src/components/__tests__/ResizeHandle.test.tsx +0 -159
  26. package/src/components/__tests__/ResourceTagsInline.test.tsx +0 -325
  27. package/src/components/__tests__/SessionExpiryBanner.test.tsx +0 -124
  28. package/src/components/__tests__/SessionTimer.test.tsx +0 -199
  29. package/src/components/__tests__/StatusDisplay.test.tsx +0 -179
  30. package/src/components/__tests__/Toast.test.tsx +0 -96
  31. package/src/components/__tests__/Toolbar.test.tsx +0 -111
  32. package/src/components/__tests__/UserMenuSkeleton.test.tsx +0 -182
  33. package/src/components/annotation/AnchoredTextNotice.tsx +0 -36
  34. package/src/components/annotation/AnnotateToolbar.tsx +0 -531
  35. package/src/components/annotation/__tests__/AnnotateToolbar.display.test.tsx +0 -127
  36. package/src/components/annotation/__tests__/AnnotateToolbar.test.tsx +0 -304
  37. package/src/components/annotation-popups/JsonLdView.tsx +0 -127
  38. package/src/components/annotation-popups/SharedPopupElements.tsx +0 -131
  39. package/src/components/annotation-popups/__tests__/JsonLdView.test.tsx +0 -432
  40. package/src/components/annotation-popups/__tests__/SharedPopupElements.test.tsx +0 -297
  41. package/src/components/branding/XynologBranding.tsx +0 -41
  42. package/src/components/branding/__tests__/XynologBranding.test.tsx +0 -383
  43. package/src/components/error-states/ResourceErrorState.tsx +0 -30
  44. package/src/components/error-states/__tests__/ResourceErrorState.test.tsx +0 -102
  45. package/src/components/image-annotation/AnnotationOverlay.tsx +0 -307
  46. package/src/components/image-annotation/SvgDrawingCanvas.tsx +0 -514
  47. package/src/components/image-annotation/__tests__/AnnotationOverlay.click.test.tsx +0 -169
  48. package/src/components/image-annotation/__tests__/AnnotationOverlay.hover.test.tsx +0 -83
  49. package/src/components/image-annotation/__tests__/SvgDrawingCanvas.annotate-gate.test.tsx +0 -228
  50. package/src/components/image-annotation/__tests__/SvgDrawingCanvas.click.test.tsx +0 -204
  51. package/src/components/layout/LeftSidebar.tsx +0 -150
  52. package/src/components/layout/PageLayout.tsx +0 -49
  53. package/src/components/layout/SkipLinks.tsx +0 -36
  54. package/src/components/layout/UnifiedHeader.tsx +0 -151
  55. package/src/components/layout/__tests__/LeftSidebar.test.tsx +0 -426
  56. package/src/components/layout/__tests__/PageLayout.test.tsx +0 -311
  57. package/src/components/layout/__tests__/SkipLinks.a11y.test.tsx +0 -218
  58. package/src/components/layout/__tests__/UnifiedHeader.test.tsx +0 -555
  59. package/src/components/loading-states/ComposeLoadingState.tsx +0 -19
  60. package/src/components/loading-states/ResourceLoadingState.tsx +0 -13
  61. package/src/components/loading-states/__tests__/ComposeLoadingState.test.tsx +0 -37
  62. package/src/components/loading-states/__tests__/ResourceLoadingState.test.tsx +0 -31
  63. package/src/components/modals/ComposeStep.tsx +0 -245
  64. package/src/components/modals/ConfigureGatherStep.tsx +0 -110
  65. package/src/components/modals/ConfigureGenerationStep.tsx +0 -458
  66. package/src/components/modals/ConfigureSearchStep.tsx +0 -124
  67. package/src/components/modals/ContextSummary.tsx +0 -317
  68. package/src/components/modals/CorpusPane.tsx +0 -96
  69. package/src/components/modals/DiscardPrompt.tsx +0 -44
  70. package/src/components/modals/GatherContextStep.tsx +0 -480
  71. package/src/components/modals/KbIdentityConflictModal.tsx +0 -122
  72. package/src/components/modals/KeyboardShortcutsHelpModal.tsx +0 -238
  73. package/src/components/modals/PermissionDeniedModal.tsx +0 -207
  74. package/src/components/modals/ReferenceWizardModal.tsx +0 -656
  75. package/src/components/modals/ResourceGenerateModal.tsx +0 -457
  76. package/src/components/modals/SearchModal.tsx +0 -334
  77. package/src/components/modals/SearchResultsStep.tsx +0 -117
  78. package/src/components/modals/SessionEndedModal.tsx +0 -148
  79. package/src/components/modals/WizardFooter.tsx +0 -72
  80. package/src/components/modals/__tests__/ComposeStep.test.tsx +0 -187
  81. package/src/components/modals/__tests__/ConfigureGatherStep.test.tsx +0 -92
  82. package/src/components/modals/__tests__/ConfigureGenerationStep.test.tsx +0 -574
  83. package/src/components/modals/__tests__/ConfigureSearchStep.test.tsx +0 -124
  84. package/src/components/modals/__tests__/GatherContextStep.resource.test.tsx +0 -702
  85. package/src/components/modals/__tests__/KbIdentityConflictModal.test.tsx +0 -102
  86. package/src/components/modals/__tests__/KeyboardShortcutsHelpModal.test.tsx +0 -115
  87. package/src/components/modals/__tests__/PermissionDeniedModal.test.tsx +0 -218
  88. package/src/components/modals/__tests__/ReferenceWizardModal.test.tsx +0 -936
  89. package/src/components/modals/__tests__/ResourceGenerateModal.test.tsx +0 -532
  90. package/src/components/modals/__tests__/SearchModal.accessibility.test.tsx +0 -95
  91. package/src/components/modals/__tests__/SearchModal.basic.test.tsx +0 -84
  92. package/src/components/modals/__tests__/SearchModal.keyboard.test.tsx +0 -162
  93. package/src/components/modals/__tests__/SearchModal.search-wiring.test.tsx +0 -237
  94. package/src/components/modals/__tests__/SearchModal.translations.test.tsx +0 -91
  95. package/src/components/modals/__tests__/SearchResultsStep.test.tsx +0 -95
  96. package/src/components/modals/__tests__/SessionEndedModal.test.tsx +0 -171
  97. package/src/components/modals/__tests__/WizardFooter.test.tsx +0 -446
  98. package/src/components/modals/__tests__/search-modal-harness.ts +0 -82
  99. package/src/components/navigation/CollapsibleResourceNavigation.tsx +0 -364
  100. package/src/components/navigation/NavigationMenu.tsx +0 -66
  101. package/src/components/navigation/ObservableLink.tsx +0 -90
  102. package/src/components/navigation/SimpleNavigation.tsx +0 -169
  103. package/src/components/navigation/SortableResourceTab.tsx +0 -122
  104. package/src/components/navigation/__tests__/NavigationMenu.a11y.test.tsx +0 -302
  105. package/src/components/navigation/__tests__/NavigationMenu.test.tsx +0 -399
  106. package/src/components/navigation/__tests__/ObservableLink.test.tsx +0 -85
  107. package/src/components/navigation/__tests__/SimpleNavigation.test.tsx +0 -193
  108. package/src/components/navigation/__tests__/SortableResourceTab.test.tsx +0 -421
  109. package/src/components/pdf-annotation/PdfAnnotationCanvas.client.tsx +0 -10
  110. package/src/components/pdf-annotation/PdfAnnotationCanvas.tsx +0 -632
  111. package/src/components/pdf-annotation/PdfPageView.tsx +0 -527
  112. package/src/components/pdf-annotation/__tests__/PdfAnnotationCanvas.annotate-gate.test.tsx +0 -295
  113. package/src/components/pdf-annotation/__tests__/PdfAnnotationCanvas.pixels-before-anchoring.test.tsx +0 -166
  114. package/src/components/pdf-annotation/__tests__/PdfAnnotationCanvas.test.tsx +0 -1719
  115. package/src/components/pdf-annotation/__tests__/estimate-slot-height.test.ts +0 -61
  116. package/src/components/pdf-annotation/__tests__/rects-for-page.test.ts +0 -110
  117. package/src/components/pdf-annotation/estimate-slot-height.ts +0 -31
  118. package/src/components/pdf-annotation/rects-for-page.ts +0 -50
  119. package/src/components/resource/AnnotateView.tsx +0 -373
  120. package/src/components/resource/AnnotationHistory.tsx +0 -169
  121. package/src/components/resource/BrowseView.tsx +0 -440
  122. package/src/components/resource/DownloadFileLink.tsx +0 -53
  123. package/src/components/resource/HistoryEvent.tsx +0 -186
  124. package/src/components/resource/ResourceViewer.tsx +0 -617
  125. package/src/components/resource/__tests__/AnnotateView.code-point-offsets.test.tsx +0 -482
  126. package/src/components/resource/__tests__/AnnotateView.embeddable.test.tsx +0 -78
  127. package/src/components/resource/__tests__/AnnotateView.focus.test.tsx +0 -147
  128. package/src/components/resource/__tests__/AnnotateView.registry.test.tsx +0 -143
  129. package/src/components/resource/__tests__/AnnotationHistory.test.tsx +0 -257
  130. package/src/components/resource/__tests__/BrowseView.code-point-offsets.test.tsx +0 -123
  131. package/src/components/resource/__tests__/BrowseView.embeddable.test.tsx +0 -76
  132. package/src/components/resource/__tests__/BrowseView.links.test.tsx +0 -84
  133. package/src/components/resource/__tests__/BrowseView.overlay-async.test.tsx +0 -165
  134. package/src/components/resource/__tests__/BrowseView.reference-hover.test.tsx +0 -200
  135. package/src/components/resource/__tests__/BrowseView.registry.test.tsx +0 -57
  136. package/src/components/resource/__tests__/BrowseView.test.tsx +0 -915
  137. package/src/components/resource/__tests__/HistoryEvent.test.tsx +0 -571
  138. package/src/components/resource/__tests__/ResourceViewer.delete-failure.test.tsx +0 -103
  139. package/src/components/resource/__tests__/ResourceViewer.embeddable.test.tsx +0 -250
  140. package/src/components/resource/__tests__/ResourceViewer.mode-switch.test.tsx +0 -262
  141. package/src/components/resource/__tests__/ResourceViewer.multi-mount-invalidation.test.tsx +0 -166
  142. package/src/components/resource/__tests__/ResourceViewer.registry.test.tsx +0 -112
  143. package/src/components/resource/__tests__/ResourceViewer.toolbar-opt-out.test.tsx +0 -207
  144. package/src/components/resource/__tests__/ResourceViewer.toolbar-prefs.test.tsx +0 -274
  145. package/src/components/resource/__tests__/annotation-interactions.test.tsx +0 -116
  146. package/src/components/resource/__tests__/browse-renderers.dispatch.test.tsx +0 -183
  147. package/src/components/resource/__tests__/browse-renderers.test.tsx +0 -47
  148. package/src/components/resource/__tests__/download-link.test.tsx +0 -171
  149. package/src/components/resource/__tests__/event-formatting.test.ts +0 -379
  150. package/src/components/resource/__tests__/inline-embedding.test.tsx +0 -133
  151. package/src/components/resource/__tests__/media-completeness.test.tsx +0 -144
  152. package/src/components/resource/annotate-renderers.tsx +0 -186
  153. package/src/components/resource/browse-renderers.tsx +0 -133
  154. package/src/components/resource/event-formatting.ts +0 -393
  155. package/src/components/resource/panels/AssessmentEntry.tsx +0 -127
  156. package/src/components/resource/panels/AssessmentPanel.tsx +0 -309
  157. package/src/components/resource/panels/CollaborationPanel.tsx +0 -228
  158. package/src/components/resource/panels/CommentEntry.tsx +0 -242
  159. package/src/components/resource/panels/CommentsPanel.tsx +0 -320
  160. package/src/components/resource/panels/DelegateSection.tsx +0 -282
  161. package/src/components/resource/panels/DelegateShell.tsx +0 -134
  162. package/src/components/resource/panels/HighlightEntry.tsx +0 -83
  163. package/src/components/resource/panels/HighlightPanel.tsx +0 -212
  164. package/src/components/resource/panels/JsonLdPanel.tsx +0 -119
  165. package/src/components/resource/panels/PanelHeader.tsx +0 -22
  166. package/src/components/resource/panels/ReferenceEntry.tsx +0 -232
  167. package/src/components/resource/panels/ReferencesPanel.tsx +0 -626
  168. package/src/components/resource/panels/ResourceInfoPanel.tsx +0 -433
  169. package/src/components/resource/panels/StatisticsPanel.tsx +0 -145
  170. package/src/components/resource/panels/TagEntry.tsx +0 -87
  171. package/src/components/resource/panels/TaggingPanel.tsx +0 -554
  172. package/src/components/resource/panels/UnifiedAnnotationsPanel.tsx +0 -384
  173. package/src/components/resource/panels/__tests__/AssessmentEntry.test.tsx +0 -292
  174. package/src/components/resource/panels/__tests__/AssessmentPanel.test.tsx +0 -685
  175. package/src/components/resource/panels/__tests__/CollaborationPanel.test.tsx +0 -685
  176. package/src/components/resource/panels/__tests__/CommentEntry.test.tsx +0 -750
  177. package/src/components/resource/panels/__tests__/CommentsPanel.test.tsx +0 -877
  178. package/src/components/resource/panels/__tests__/DelegateSection.test.tsx +0 -623
  179. package/src/components/resource/panels/__tests__/DelegateShell.test.tsx +0 -212
  180. package/src/components/resource/panels/__tests__/HighlightEntry.test.tsx +0 -236
  181. package/src/components/resource/panels/__tests__/HighlightPanel.annotationProgress.test.tsx +0 -506
  182. package/src/components/resource/panels/__tests__/HighlightPanel.out-of-order.test.tsx +0 -132
  183. package/src/components/resource/panels/__tests__/JsonLdPanel.test.tsx +0 -230
  184. package/src/components/resource/panels/__tests__/PanelHeader.test.tsx +0 -54
  185. package/src/components/resource/panels/__tests__/ReferenceEntry.test.tsx +0 -578
  186. package/src/components/resource/panels/__tests__/ReferencesPanel.headless.test.tsx +0 -193
  187. package/src/components/resource/panels/__tests__/ReferencesPanel.observable-flow.test.tsx +0 -193
  188. package/src/components/resource/panels/__tests__/ReferencesPanel.test.tsx +0 -1080
  189. package/src/components/resource/panels/__tests__/ResourceInfoPanel.test.tsx +0 -812
  190. package/src/components/resource/panels/__tests__/ResourceInfoPanel.text-layer.test.tsx +0 -106
  191. package/src/components/resource/panels/__tests__/StatisticsPanel.test.tsx +0 -329
  192. package/src/components/resource/panels/__tests__/TagEntry.test.tsx +0 -250
  193. package/src/components/resource/panels/__tests__/TaggingPanel.test.tsx +0 -772
  194. package/src/components/resource/panels/__tests__/UnifiedAnnotationsPanel.delegated-job.test.tsx +0 -207
  195. package/src/components/resource/panels/__tests__/UnifiedAnnotationsPanel.failure.test.tsx +0 -89
  196. package/src/components/resource/panels/__tests__/agent-label.test.ts +0 -136
  197. package/src/components/resource/panels/agent-label.ts +0 -35
  198. package/src/components/settings/SettingsPanel.tsx +0 -251
  199. package/src/components/settings/__tests__/SettingsPanel.test.tsx +0 -260
  200. package/src/components/viewers/ImageViewer.tsx +0 -18
  201. package/src/components/viewers/__tests__/ImageViewer.test.tsx +0 -57
  202. package/src/components/viewers/index.ts +0 -1
  203. package/src/features/auth/__tests__/AuthErrorDisplay.test.tsx +0 -181
  204. package/src/features/auth/components/AuthErrorDisplay.tsx +0 -89
  205. package/src/features/moderate-entity-tags/__tests__/EntityTagsPage.test.tsx +0 -387
  206. package/src/features/moderate-entity-tags/components/EntityTagsPage.tsx +0 -161
  207. package/src/features/moderate-entity-tags/state/__tests__/entity-tags-state-unit.test.ts +0 -183
  208. package/src/features/moderate-entity-tags/state/entity-tags-state-unit.ts +0 -73
  209. package/src/features/moderate-recent/__tests__/RecentDocumentsPage.test.tsx +0 -422
  210. package/src/features/moderate-recent/components/RecentDocumentsPage.tsx +0 -117
  211. package/src/features/moderate-tag-schemas/__tests__/TagSchemasPage.test.tsx +0 -481
  212. package/src/features/moderate-tag-schemas/components/TagSchemasPage.tsx +0 -161
  213. package/src/features/resource-compose/__tests__/ResourceComposePage.test.tsx +0 -600
  214. package/src/features/resource-compose/__tests__/UploadProgressBar.test.tsx +0 -256
  215. package/src/features/resource-compose/components/ResourceComposePage.tsx +0 -809
  216. package/src/features/resource-compose/components/UploadProgressBar.tsx +0 -125
  217. package/src/features/resource-compose/state/__tests__/compose-page-state-unit.test.ts +0 -195
  218. package/src/features/resource-compose/state/compose-page-state-unit.ts +0 -187
  219. package/src/features/resource-discovery/__tests__/ResourceCard.test.tsx +0 -338
  220. package/src/features/resource-discovery/__tests__/ResourceDiscoveryPage.test.tsx +0 -449
  221. package/src/features/resource-discovery/components/ResourceCard.tsx +0 -80
  222. package/src/features/resource-discovery/components/ResourceDiscoveryPage.tsx +0 -330
  223. package/src/features/resource-discovery/state/__tests__/discover-state-unit.test.ts +0 -477
  224. package/src/features/resource-discovery/state/discover-state-unit.ts +0 -162
  225. package/src/features/resource-viewer/__tests__/ResourceViewerPage.content-loading.test.tsx +0 -260
  226. package/src/features/resource-viewer/__tests__/ResourceViewerPage.test.tsx +0 -570
  227. package/src/features/resource-viewer/__tests__/generation-params.test.ts +0 -49
  228. package/src/features/resource-viewer/components/ResourceViewerPage.tsx +0 -1058
  229. package/src/features/resource-viewer/generation-params.ts +0 -23
  230. package/src/features/resource-viewer/hooks/__tests__/useResourceViewedReport.test.tsx +0 -77
  231. package/src/features/resource-viewer/hooks/useResourceViewedReport.ts +0 -38
  232. package/src/features/resource-viewer/state/__tests__/resource-loader-state-unit.test.ts +0 -178
  233. package/src/features/resource-viewer/state/__tests__/resource-viewer-page-state-unit.test.ts +0 -505
  234. package/src/features/resource-viewer/state/resource-loader-state-unit.ts +0 -93
  235. package/src/features/resource-viewer/state/resource-viewer-page-state-unit.ts +0 -156
@@ -1,656 +0,0 @@
1
- 'use client';
2
-
3
- import type { AnnotationId } from '@xynolog/core';
4
- import { useState, useEffect, useCallback, useRef } from 'react';
5
- import {
6
- Dialog,
7
- DialogPanel,
8
- DialogTitle,
9
- Transition,
10
- TransitionChild,
11
- } from '@headlessui/react';
12
- import type {
13
- GatheredContext,
14
- EngineWithLimits,
15
- ResourceId,
16
- } from '@xynolog/core';
17
- import { uuidV4 } from '@xynolog/core';
18
- import { HOVER_DELAY_MS } from '@xynolog/sdk';
19
- import { useXynolog } from '../../session/XynologProvider';
20
- import { useObservable } from '../../hooks/useObservable';
21
- import { useEventSubscription } from '../../contexts/useEventSubscription';
22
- import { GatherContextStep } from './GatherContextStep';
23
- import {
24
- ConfigureGenerationStep,
25
- freshGenerationDraft,
26
- } from './ConfigureGenerationStep';
27
- import type { GenerationConfig } from './ConfigureGenerationStep';
28
- import { ConfigureSearchStep } from './ConfigureSearchStep';
29
- import type { SearchConfig } from './ConfigureSearchStep';
30
- import type { GenerationDraft } from './ConfigureGenerationStep';
31
- import { SearchResultsStep } from './SearchResultsStep';
32
- import { ComposeStep } from './ComposeStep';
33
- import type { ComposeDraft, ComposeParams } from './ComposeStep';
34
- import { DiscardPrompt } from './DiscardPrompt';
35
- import { useLineNumbers } from '../../contexts/LineNumbersContext';
36
- import type { ScoredResult } from './SearchResultsStep';
37
-
38
- type WizardStep =
39
- | { step: 'gather' }
40
- | { step: 'configure-search' }
41
- | { step: 'search-results'; results: ScoredResult[] }
42
- | { step: 'configure-generation' }
43
- | { step: 'compose' };
44
-
45
- export interface ReferenceWizardModalProps {
46
- /**
47
- * The engine used for `yield` jobs, forwarded to ConfigureGenerationStep so
48
- * the max-length control is bounded by the model's real output ceiling.
49
- * Optional: absent means the default bounds, never an error.
50
- */
51
- generationEngine?: EngineWithLimits;
52
- isOpen: boolean;
53
- onClose: () => void;
54
- /** The annotation being resolved */
55
- annotationId: AnnotationId | null;
56
- /** The resource containing the annotation */
57
- resourceId: ResourceId | null;
58
- /** Default title (selected text) */
59
- defaultTitle: string;
60
- /** Folder of the source resource, so new files land beside it. */
61
- defaultFolder?: string;
62
- /** Entity types from the annotation */
63
- entityTypes: string[];
64
- /**
65
- * The source resource's display name — a page fact (the wizard opens FROM
66
- * that resource), shown in the gather skeleton's source line before the
67
- * gathered context can say it itself.
68
- */
69
- resourceName?: string;
70
- /** Current locale for generation defaults */
71
- locale: string;
72
- /** Gathered context state */
73
- context: GatheredContext | null;
74
- contextLoading: boolean;
75
- contextError: Error | null;
76
- /** Callbacks */
77
- onGenerateSubmit: (
78
- referenceId: AnnotationId,
79
- config: GenerationConfig,
80
- ) => void;
81
- onLinkResource: (
82
- referenceId: AnnotationId,
83
- targetResourceId: ResourceId,
84
- ) => void;
85
- /**
86
- * Create-and-link, inside the modal: the host runs `yield.resource` then
87
- * `bind.body` and settles the promise; rejection keeps the modal open with
88
- * the compose footer re-enabled.
89
- */
90
- onComposeSubmit: (
91
- referenceId: AnnotationId,
92
- params: ComposeParams,
93
- ) => Promise<void>;
94
- /** Picker vocabulary for compose when the reference fixed no entity types. */
95
- entityTypeOptions?: string[];
96
- /** Editor hover delay for the compose step's CodeMirror. */
97
- hoverDelayMs?: number;
98
- /** Translation strings */
99
- translations: {
100
- /** The ONE title, all steps — the flow is resolving a reference; the
101
- strategy band below says where in it you are. */
102
- resolveTitle: string;
103
- sourceContextLabel: string;
104
- connectionsLabel: string;
105
- citedByLabel: string;
106
- graphPaneTitle: string;
107
- graphEmpty: string;
108
- resourceLinkLabel: string;
109
- corpusPaneTitle: string;
110
- corpusEmpty: string;
111
- excludedReceipt: string;
112
- machineRead: string;
113
- userHintLabel: string;
114
- userHintEffect: string;
115
- userHintPlaceholder: string;
116
- loadingContext: string;
117
- failedContext: string;
118
- search: string;
119
- searching: string;
120
- generate: string;
121
- compose: string;
122
- resolutionStrategyLabel: string;
123
- back: string;
124
- link: string;
125
- score: string;
126
- noResults: string;
127
- resourceTitle: string;
128
- resourceTitlePlaceholder: string;
129
- saveLocation: string;
130
- additionalInstructions: string;
131
- additionalInstructionsPlaceholder: string;
132
- language: string;
133
- languageHelp: string;
134
- creativity: string;
135
- creativityFocused: string;
136
- creativityCreative: string;
137
- maxLength: string;
138
- maxLengthHelp: string;
139
- maxLengthCeiling: string;
140
- outputFormat: string;
141
- formatExtensionMismatch: string;
142
- maxResults: string;
143
- semanticScoring: string;
144
- semanticScoringHelp: string;
145
- searchFailed: string;
146
- entityTypes: string;
147
- contentLabel: string;
148
- createAndLink: string;
149
- creatingAndLinking: string;
150
- discardDraftPrompt: string;
151
- discardDraft: string;
152
- keepEditing: string;
153
- };
154
- }
155
-
156
- export function ReferenceWizardModal({
157
- isOpen,
158
- onClose,
159
- annotationId,
160
- resourceId,
161
- defaultTitle,
162
- defaultFolder,
163
- entityTypes,
164
- resourceName,
165
- locale,
166
- context,
167
- contextLoading,
168
- contextError,
169
- onGenerateSubmit,
170
- onLinkResource,
171
- onComposeSubmit,
172
- entityTypeOptions = [],
173
- hoverDelayMs = HOVER_DELAY_MS,
174
- translations: t,
175
- generationEngine,
176
- }: ReferenceWizardModalProps) {
177
- const session = useObservable(useXynolog().activeSession$);
178
- // The host's callbacks are read through refs, so a host that passes a new
179
- // function on every render does not re-create the handlers below.
180
- const onCloseRef = useRef(onClose);
181
- onCloseRef.current = onClose;
182
- const onGenerateSubmitRef = useRef(onGenerateSubmit);
183
- onGenerateSubmitRef.current = onGenerateSubmit;
184
- const onLinkResourceRef = useRef(onLinkResource);
185
- onLinkResourceRef.current = onLinkResource;
186
- const onComposeSubmitRef = useRef(onComposeSubmit);
187
- onComposeSubmitRef.current = onComposeSubmit;
188
- const [wizardStep, setWizardStep] = useState<WizardStep>({ step: 'gather' });
189
- // Both step drafts live HERE, not in the steps. Stepping back unmounts a step;
190
- // if the step owned its values, Back would silently discard everything typed.
191
- const [searchConfig, setSearchConfig] = useState<SearchConfig>({
192
- limit: 10,
193
- useSemanticScoring: true,
194
- });
195
- const [generationDraft, setGenerationDraft] = useState<GenerationDraft>(() =>
196
- freshGenerationDraft(defaultTitle, locale),
197
- );
198
- const [isSearching, setIsSearching] = useState(false);
199
- const [searchError, setSearchError] = useState<string | null>(null);
200
- const [userHint, setUserHint] = useState('');
201
- const freshComposeDraft = (): ComposeDraft => ({
202
- name: defaultTitle,
203
- storagePath: '',
204
- content: '',
205
- entityTypes: [],
206
- language: locale,
207
- });
208
- const [composeDraft, setComposeDraft] =
209
- useState<ComposeDraft>(freshComposeDraft);
210
- const [showDiscardPrompt, setShowDiscardPrompt] = useState(false);
211
- // The editor consumes the shared display setting; the step itself stays
212
- // provider-free, so the wizard resolves it and passes it down.
213
- const { showLineNumbers } = useLineNumbers();
214
-
215
- // The dirty baseline is what was SEEDED, not the live prop: defaultTitle
216
- // derives from observable wizard state and can re-emit while the modal is
217
- // open; an untouched draft must not read as dirty because the baseline
218
- // moved under it.
219
- const seededTitle = useRef(defaultTitle);
220
-
221
- // Reset to gather step when modal opens
222
- useEffect(() => {
223
- if (isOpen) {
224
- seededTitle.current = defaultTitle;
225
- setWizardStep({ step: 'gather' });
226
- setSearchConfig({ limit: 10, useSemanticScoring: true });
227
- setGenerationDraft(freshGenerationDraft(defaultTitle, locale));
228
- setIsSearching(false);
229
- setSearchError(null);
230
- setUserHint('');
231
- setComposeDraft(freshComposeDraft());
232
- setShowDiscardPrompt(false);
233
- }
234
- }, [isOpen]);
235
-
236
- // Subscribe to search results (only react while open and for the current annotation)
237
- useEventSubscription('match:search-results', (event) => {
238
- if (!isOpen) return;
239
- if (annotationId && event.referenceId === annotationId) {
240
- setIsSearching(false);
241
- setWizardStep({
242
- step: 'search-results',
243
- results: event.response as ScoredResult[],
244
- });
245
- }
246
- });
247
-
248
- // …and to failures, same scoping. A refused emit (/bus/emit 4xx), a matcher
249
- // error, and the match unit's timeout all land here — without this
250
- // subscription every one of them leaves the button on "Searching…" forever.
251
- useEventSubscription('match:search-failed', (event) => {
252
- if (!isOpen) return;
253
- if (annotationId && event.referenceId === annotationId) {
254
- setIsSearching(false);
255
- setSearchError(event.message);
256
- }
257
- });
258
-
259
- const handleBind = useCallback(() => {
260
- setWizardStep({ step: 'configure-search' });
261
- }, []);
262
-
263
- /**
264
- * The gather step's Hint, placed where the schema says it lives.
265
- *
266
- * Built ONCE, for search and generation alike: a path that builds its own
267
- * context can leave the hint out, silently discarding what the user typed —
268
- * and then showing them an empty "Additional Instructions" box. And under
269
- * `focus`, never as `{ ...context, userHint }`: that is a TOP-LEVEL key
270
- * `GatheredContext` does not define; `GatheredContext.json` puts it at
271
- * `focus.userHint` ("hint to supplement or replace the selected text for search and
272
- * generation").
273
- *
274
- * Both consumers read it: the matcher folds it into its search term and its
275
- * LLM-scoring passage (matcher.ts), and generation's prompt builder
276
- * renders it in the annotation section (resource-generation.ts).
277
- */
278
- const contextWithHint = !context
279
- ? null
280
- : userHint
281
- ? { ...context, focus: { ...context.focus, userHint } }
282
- : context;
283
-
284
- const handleGenerate = useCallback(() => {
285
- setWizardStep({ step: 'configure-generation' });
286
- }, []);
287
-
288
- const handleCompose = useCallback(() => {
289
- if (!context || !annotationId || !resourceId) return;
290
- setWizardStep({ step: 'compose' });
291
- }, [context, annotationId, resourceId]);
292
-
293
- const handleComposeSubmit = useCallback(
294
- async (params: ComposeParams) => {
295
- if (!annotationId) return;
296
- // Rejection propagates to ComposeStep (footer re-enables); the host
297
- // surfaces the error. Success closes UNCONDITIONALLY — the dirty guard
298
- // protects dismissal, not completion.
299
- await onComposeSubmitRef.current(annotationId, params);
300
- onCloseRef.current();
301
- },
302
- [annotationId],
303
- );
304
-
305
- // The dirty guard: a modal dies on ✕/Escape/backdrop, but typed work must
306
- // not die with it — WHEREVER the user currently is (drafts survive stepping
307
- // away, so the guard must too). Typed text only: seeded titles, toggles, and
308
- // sliders never nag.
309
- const draftDirty =
310
- composeDraft.content.trim() !== '' ||
311
- composeDraft.storagePath.trim() !== '' ||
312
- composeDraft.name !== seededTitle.current ||
313
- generationDraft.title !== seededTitle.current ||
314
- generationDraft.storagePath.trim() !== '' ||
315
- generationDraft.prompt.trim() !== '';
316
- const handleDismiss = useCallback(() => {
317
- if (draftDirty) {
318
- setShowDiscardPrompt(true);
319
- return;
320
- }
321
- onCloseRef.current();
322
- }, [draftDirty]);
323
-
324
- const handleBackToGather = useCallback(() => {
325
- setWizardStep({ step: 'gather' });
326
- }, []);
327
-
328
- // The strategy steps stack evidence + step content in ONE scroll pane. On
329
- // entry, start at the BOTTOM: the step's own content (form, results) shows
330
- // in full, the evidence tucks up under the modal top, reachable by
331
- // scrolling up. jsdom has no layout (scrollHeight 0), so this is a no-op
332
- // in tests — the same posture as the viewer's guarded scrolls.
333
- const stepScrollRef = useRef<HTMLDivElement>(null);
334
- useEffect(() => {
335
- const el = stepScrollRef.current;
336
- if (el) el.scrollTop = el.scrollHeight;
337
- }, [wizardStep.step]);
338
-
339
- const handleSearchSubmit = useCallback(
340
- (config: SearchConfig) => {
341
- if (!annotationId || !contextWithHint || !resourceId) return;
342
- setIsSearching(true);
343
- setSearchError(null);
344
- session?.client.match.requestSearch(
345
- {
346
- resourceId: resourceId,
347
- referenceId: annotationId,
348
- context: contextWithHint,
349
- limit: config.limit,
350
- useSemanticScoring: config.useSemanticScoring,
351
- },
352
- uuidV4(),
353
- );
354
- // Stay on configure-search until results arrive (subscription above handles transition)
355
- },
356
- [annotationId, resourceId, contextWithHint, session],
357
- );
358
-
359
- const handleGenerateSubmit = useCallback(
360
- (config: GenerationConfig) => {
361
- if (!annotationId) return;
362
- onGenerateSubmitRef.current(annotationId, config);
363
- onCloseRef.current();
364
- },
365
- [annotationId],
366
- );
367
-
368
- const handleLink = useCallback(
369
- (targetResourceId: ResourceId) => {
370
- if (!annotationId) return;
371
- onLinkResourceRef.current(annotationId, targetResourceId);
372
- onCloseRef.current();
373
- },
374
- [annotationId],
375
- );
376
-
377
- // The evidence display's translations — shared by the gather step and the
378
- // strategy steps, which keep the context in view (display-only)
379
- // above their forms rather than navigating away from it.
380
- const displayTranslations = {
381
- loadingContext: t.loadingContext,
382
- failedContext: t.failedContext,
383
- sourceContextLabel: t.sourceContextLabel,
384
- connectionsLabel: t.connectionsLabel,
385
- citedByLabel: t.citedByLabel,
386
- graphPaneTitle: t.graphPaneTitle,
387
- graphEmpty: t.graphEmpty,
388
- resourceLinkLabel: t.resourceLinkLabel,
389
- corpusPaneTitle: t.corpusPaneTitle,
390
- corpusEmpty: t.corpusEmpty,
391
- excludedReceipt: t.excludedReceipt,
392
- machineRead: t.machineRead,
393
- score: t.score,
394
- };
395
-
396
- return (
397
- <Transition appear show={isOpen}>
398
- <Dialog as="div" className="xynolog-search-modal" onClose={handleDismiss}>
399
- {/* Backdrop */}
400
- <TransitionChild
401
- enter="ease-out duration-200"
402
- enterFrom="opacity-0"
403
- enterTo="opacity-100"
404
- leave="ease-in duration-150"
405
- leaveFrom="opacity-100"
406
- leaveTo="opacity-0"
407
- >
408
- <div className="xynolog-search-modal__backdrop" />
409
- </TransitionChild>
410
-
411
- {/* Modal panel */}
412
- <div className="xynolog-search-modal__wrapper">
413
- <div className="xynolog-search-modal__centering xynolog-search-modal__centering--center">
414
- <TransitionChild
415
- enter="ease-out duration-200"
416
- enterFrom="opacity-0 scale-95"
417
- enterTo="opacity-100 scale-100"
418
- leave="ease-in duration-150"
419
- leaveFrom="opacity-100 scale-100"
420
- leaveTo="opacity-0 scale-95"
421
- >
422
- {/* Every step shows the evidence display, so every step is wide
423
- and gets the gather layout (flex column, capped height). */}
424
- <DialogPanel className="xynolog-search-modal__panel xynolog-search-modal__panel--with-border xynolog-search-modal__panel--gather xynolog-search-modal__panel--wide">
425
- <div className="xynolog-search-modal__header">
426
- <DialogTitle className="xynolog-search-modal__title">
427
- {t.resolveTitle}
428
- </DialogTitle>
429
- <button
430
- onClick={handleDismiss}
431
- className="xynolog-search-modal__close-button"
432
- aria-label="Close"
433
- >
434
- ✕
435
- </button>
436
- </div>
437
-
438
- {showDiscardPrompt && (
439
- <DiscardPrompt
440
- prompt={t.discardDraftPrompt}
441
- discardLabel={t.discardDraft}
442
- keepLabel={t.keepEditing}
443
- onDiscard={() => {
444
- setShowDiscardPrompt(false);
445
- onClose();
446
- }}
447
- onKeepEditing={() => setShowDiscardPrompt(false)}
448
- />
449
- )}
450
-
451
- {wizardStep.step === 'gather' && (
452
- <GatherContextStep
453
- context={context}
454
- contextLoading={contextLoading}
455
- contextError={contextError}
456
- pending={{
457
- exact: defaultTitle,
458
- entityTypes,
459
- ...(resourceName ? { resourceName } : {}),
460
- }}
461
- annotate={{
462
- userHint,
463
- onUserHintChange: setUserHint,
464
- onBind: handleBind,
465
- onGenerate: handleGenerate,
466
- onCompose: handleCompose,
467
- translations: {
468
- search: t.search,
469
- generate: t.generate,
470
- compose: t.compose,
471
- resolutionStrategyLabel: t.resolutionStrategyLabel,
472
- userHintLabel: t.userHintLabel,
473
- userHintEffect: t.userHintEffect,
474
- userHintPlaceholder: t.userHintPlaceholder,
475
- },
476
- }}
477
- translations={displayTranslations}
478
- />
479
- )}
480
-
481
- {wizardStep.step === 'compose' && context && (
482
- <div
483
- className="xynolog-wizard__step-scroll"
484
- ref={stepScrollRef}
485
- >
486
- <GatherContextStep
487
- context={context}
488
- contextLoading={contextLoading}
489
- contextError={contextError}
490
- chosenStrategy={{
491
- label: t.resolutionStrategyLabel,
492
- value: `✍️ ${t.compose}`,
493
- }}
494
- translations={displayTranslations}
495
- />
496
- <ComposeStep
497
- draft={composeDraft}
498
- onDraftChange={(patch) =>
499
- setComposeDraft((d) => ({ ...d, ...patch }))
500
- }
501
- defaultFolder={defaultFolder}
502
- referenceEntityTypes={entityTypes}
503
- entityTypeOptions={entityTypeOptions}
504
- showLineNumbers={showLineNumbers}
505
- hoverDelayMs={hoverDelayMs}
506
- onBack={handleBackToGather}
507
- onCompose={handleComposeSubmit}
508
- translations={{
509
- resourceTitle: t.resourceTitle,
510
- resourceTitlePlaceholder: t.resourceTitlePlaceholder,
511
- saveLocation: t.saveLocation,
512
- entityTypes: t.entityTypes,
513
- language: t.language,
514
- contentLabel: t.contentLabel,
515
- back: t.back,
516
- createAndLink: t.createAndLink,
517
- creatingAndLinking: t.creatingAndLinking,
518
- }}
519
- />
520
- </div>
521
- )}
522
-
523
- {wizardStep.step === 'configure-generation' && context && (
524
- <div
525
- className="xynolog-wizard__step-scroll"
526
- ref={stepScrollRef}
527
- >
528
- <GatherContextStep
529
- context={context}
530
- contextLoading={contextLoading}
531
- contextError={contextError}
532
- chosenStrategy={{
533
- label: t.resolutionStrategyLabel,
534
- value: `✨ ${t.generate}`,
535
- }}
536
- translations={displayTranslations}
537
- />
538
- <ConfigureGenerationStep
539
- {...(generationEngine ? { generationEngine } : {})}
540
- {...(userHint
541
- ? {
542
- hintEcho: {
543
- label: t.userHintLabel,
544
- value: userHint,
545
- },
546
- }
547
- : {})}
548
- context={contextWithHint ?? context}
549
- config={generationDraft}
550
- onConfigChange={setGenerationDraft}
551
- defaultFolder={defaultFolder}
552
- onBack={handleBackToGather}
553
- onGenerate={handleGenerateSubmit}
554
- translations={{
555
- resourceTitle: t.resourceTitle,
556
- resourceTitlePlaceholder: t.resourceTitlePlaceholder,
557
- saveLocation: t.saveLocation,
558
- additionalInstructions: t.additionalInstructions,
559
- additionalInstructionsPlaceholder:
560
- t.additionalInstructionsPlaceholder,
561
- language: t.language,
562
- languageHelp: t.languageHelp,
563
- creativity: t.creativity,
564
- creativityFocused: t.creativityFocused,
565
- creativityCreative: t.creativityCreative,
566
- maxLength: t.maxLength,
567
- maxLengthHelp: t.maxLengthHelp,
568
- maxLengthCeiling: t.maxLengthCeiling,
569
- outputFormat: t.outputFormat,
570
- formatExtensionMismatch: t.formatExtensionMismatch,
571
- back: t.back,
572
- generate: t.generate,
573
- }}
574
- />
575
- </div>
576
- )}
577
-
578
- {wizardStep.step === 'configure-search' && (
579
- <div
580
- className="xynolog-wizard__step-scroll"
581
- ref={stepScrollRef}
582
- >
583
- <GatherContextStep
584
- context={context}
585
- contextLoading={contextLoading}
586
- contextError={contextError}
587
- chosenStrategy={{
588
- label: t.resolutionStrategyLabel,
589
- value: `🔍 ${t.search}`,
590
- }}
591
- translations={displayTranslations}
592
- />
593
- <ConfigureSearchStep
594
- config={searchConfig}
595
- {...(userHint
596
- ? {
597
- hintEcho: {
598
- label: t.userHintLabel,
599
- value: userHint,
600
- },
601
- }
602
- : {})}
603
- onConfigChange={setSearchConfig}
604
- isSearching={isSearching}
605
- searchError={searchError}
606
- onBack={handleBackToGather}
607
- onSearch={handleSearchSubmit}
608
- translations={{
609
- maxResults: t.maxResults,
610
- semanticScoring: t.semanticScoring,
611
- semanticScoringHelp: t.semanticScoringHelp,
612
- back: t.back,
613
- search: t.search,
614
- searching: t.searching,
615
- searchFailed: t.searchFailed,
616
- }}
617
- />
618
- </div>
619
- )}
620
-
621
- {wizardStep.step === 'search-results' && context && (
622
- <div
623
- className="xynolog-wizard__step-scroll"
624
- ref={stepScrollRef}
625
- >
626
- <GatherContextStep
627
- context={context}
628
- contextLoading={contextLoading}
629
- contextError={contextError}
630
- chosenStrategy={{
631
- label: t.resolutionStrategyLabel,
632
- value: `🔍 ${t.search}`,
633
- }}
634
- translations={displayTranslations}
635
- />
636
- <SearchResultsStep
637
- results={wizardStep.results}
638
- onLink={handleLink}
639
- onBack={handleBackToGather}
640
- translations={{
641
- noResults: t.noResults,
642
- link: t.link,
643
- back: t.back,
644
- score: t.score,
645
- }}
646
- />
647
- </div>
648
- )}
649
- </DialogPanel>
650
- </TransitionChild>
651
- </div>
652
- </div>
653
- </Dialog>
654
- </Transition>
655
- );
656
- }