@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,127 +0,0 @@
1
- 'use client';
2
-
3
- import type { Ref } from 'react';
4
- import type { Annotation } from '@xynolog/core';
5
- import { getAnnotationExactText } from '@xynolog/core';
6
- import type { XynologSession } from '@xynolog/sdk';
7
- import { useHoverEmitter } from '../../../hooks/useHoverEmitter';
8
- import { creatorName, renderAgentLabels } from './agent-label';
9
-
10
- // W3C Annotation TextualBody type
11
- interface TextualBody {
12
- type: 'TextualBody';
13
- value: string;
14
- format?: string;
15
- language?: string;
16
- }
17
-
18
- interface AssessmentEntryProps {
19
- /** Session for interaction routing (browse.click etc.); the panel threads it. */
20
- session: XynologSession | null;
21
- assessment: Annotation;
22
- isFocused: boolean;
23
- isHovered?: boolean;
24
- ref?: Ref<HTMLDivElement>;
25
- }
26
-
27
- function formatRelativeTime(isoString: string): string {
28
- const date = new Date(isoString);
29
- const now = new Date();
30
- const diffMs = now.getTime() - date.getTime();
31
- const diffSecs = Math.floor(diffMs / 1000);
32
- const diffMins = Math.floor(diffSecs / 60);
33
- const diffHours = Math.floor(diffMins / 60);
34
- const diffDays = Math.floor(diffHours / 24);
35
-
36
- if (diffSecs < 60) return 'just now';
37
- if (diffMins < 60) return `${diffMins} minute${diffMins > 1 ? 's' : ''} ago`;
38
- if (diffHours < 24) return `${diffHours} hour${diffHours > 1 ? 's' : ''} ago`;
39
- if (diffDays < 7) return `${diffDays} day${diffDays > 1 ? 's' : ''} ago`;
40
-
41
- return date.toLocaleDateString();
42
- }
43
-
44
- function isTextualBody(body: unknown): body is TextualBody {
45
- return (
46
- typeof body === 'object' &&
47
- body !== null &&
48
- 'type' in body &&
49
- body.type === 'TextualBody' &&
50
- 'value' in body &&
51
- typeof body.value === 'string'
52
- );
53
- }
54
-
55
- function getAssessmentText(annotation: Annotation): string | null {
56
- if (!annotation.body) return null;
57
-
58
- // Handle TextualBody directly
59
- if (isTextualBody(annotation.body)) {
60
- return annotation.body.value || null;
61
- }
62
-
63
- // Handle array of bodies
64
- if (Array.isArray(annotation.body) && annotation.body.length > 0) {
65
- const textBody = annotation.body.find(isTextualBody);
66
- return textBody?.value || null;
67
- }
68
-
69
- return null;
70
- }
71
-
72
- /**
73
- * @emits browse:click - This entry clicked. Payload: { annotationId: string }
74
- */
75
- export function AssessmentEntry({
76
- session,
77
- assessment,
78
- isFocused,
79
- isHovered = false,
80
- ref,
81
- }: AssessmentEntryProps) {
82
- const hoverProps = useHoverEmitter(session, assessment.id);
83
-
84
- const selectedText = getAnnotationExactText(assessment);
85
- const assessmentText = getAssessmentText(assessment);
86
-
87
- return (
88
- <div
89
- ref={ref}
90
- className={`xynolog-annotation-entry${isHovered ? ' xynolog-annotation-pulse' : ''}`}
91
- data-type="assessment"
92
- data-focused={isFocused ? 'true' : 'false'}
93
- onClick={() => {
94
- session?.client.browse.click(assessment.id);
95
- }}
96
- {...hoverProps}
97
- >
98
- {/* Selected text quote */}
99
- {selectedText && (
100
- <div className="xynolog-annotation-entry__quote" data-type="assessment">
101
- "{selectedText.substring(0, 100)}
102
- {selectedText.length > 100 ? '...' : ''}"
103
- </div>
104
- )}
105
-
106
- {/* Assessment body */}
107
- {assessmentText && (
108
- <div className="xynolog-annotation-entry__body" data-type="assessment">
109
- {assessmentText}
110
- </div>
111
- )}
112
-
113
- {/* Metadata */}
114
- <div className="xynolog-annotation-entry__metadata">
115
- {creatorName(assessment.creator) && (
116
- <>By {creatorName(assessment.creator)} • </>
117
- )}
118
- {formatRelativeTime(assessment.created || new Date().toISOString())}
119
- </div>
120
- {assessment.generator && renderAgentLabels(assessment.generator) && (
121
- <div className="xynolog-annotation-entry__metadata">
122
- Via {renderAgentLabels(assessment.generator)}
123
- </div>
124
- )}
125
- </div>
126
- );
127
- }
@@ -1,309 +0,0 @@
1
- 'use client';
2
-
3
- import { useState, useEffect, useRef, useCallback, useMemo } from 'react';
4
- import { useTranslations } from '../../../contexts/TranslationContext';
5
- import type {
6
- MarkStateUnit,
7
- PendingAnnotation,
8
- XynologSession,
9
- } from '@xynolog/sdk';
10
- import { useSessionEventSubscriptions } from '../../../hooks/useSessionEventSubscriptions';
11
- import type { components, JobId, ResourceId, Selector } from '@xynolog/core';
12
- import { getTextPositionSelector, getTargetSelector } from '@xynolog/core';
13
- import { AssessmentEntry } from './AssessmentEntry';
14
- import { DelegateSection } from './DelegateSection';
15
- import { PanelHeader } from './PanelHeader';
16
-
17
- import type { Annotation } from '@xynolog/core';
18
- type JobProgress = components['schemas']['JobProgress'];
19
-
20
- // Unified pending annotation type
21
- // Helper to extract display text from selector
22
- function getSelectorDisplayText(
23
- selector: Selector | Selector[],
24
- ): string | null {
25
- if (Array.isArray(selector)) {
26
- // Text selectors: array of [TextPositionSelector, TextQuoteSelector]
27
- const quoteSelector = selector.find((s) => s.type === 'TextQuoteSelector');
28
- if (quoteSelector && 'exact' in quoteSelector) {
29
- return quoteSelector.exact;
30
- }
31
- } else {
32
- // Single selector
33
- if (selector.type === 'TextQuoteSelector' && 'exact' in selector) {
34
- return selector.exact;
35
- }
36
- }
37
- return null;
38
- }
39
-
40
- interface AssessmentPanelProps {
41
- /** Session carrying the client and event bus; null renders inert. */
42
- session: XynologSession | null;
43
- /** The resource's mark unit, which delegations, cancels and dismissals are asked of; undefined renders inert. */
44
- mark: MarkStateUnit | undefined;
45
- /** The '@id' of the panel's resource — stamped as `source` on mark:submit (multi-viewer routing). */
46
- resourceId: ResourceId;
47
- annotations: Annotation[];
48
- pendingAnnotation: PendingAnnotation | null;
49
- isDelegating?: boolean;
50
- progress?: JobProgress | null;
51
- /**
52
- * The id of the delegated job (`mark.jobId$`): what the cancel control
53
- * names. Null until the queue has answered the job's creation and once the
54
- * job is over, and then there is no control.
55
- */
56
- jobId: JobId | null;
57
- /**
58
- * The delegated job ended cancelled (`mark.failure$` holds a
59
- * `JobCancelledError`): its display stays, in its cancelled form.
60
- */
61
- cancelled: boolean;
62
- locale?: string;
63
- /** BCP-47 tag of the resource being analyzed — forwarded to the delegated job. */
64
- sourceLanguage?: string;
65
- annotateMode?: boolean;
66
- scrollToAnnotationId?: string | null;
67
- onScrollCompleted?: () => void;
68
- hoveredAnnotationId?: string | null;
69
- }
70
-
71
- /**
72
- * Panel for managing assessment annotations with text input
73
- *
74
- * @emits mark:submit - Create new assessment annotation. Payload: MarkSubmitEvent with motivation 'assessing', and a TextualBody when there is text
75
- * @subscribes browse:click - Annotation clicked. Payload: { annotationId: string }
76
- */
77
- export function AssessmentPanel({
78
- session,
79
- mark,
80
- resourceId,
81
- annotations,
82
- pendingAnnotation,
83
- isDelegating = false,
84
- progress,
85
- jobId,
86
- cancelled,
87
- locale,
88
- sourceLanguage,
89
- annotateMode = true,
90
- scrollToAnnotationId,
91
- onScrollCompleted,
92
- hoveredAnnotationId,
93
- }: AssessmentPanelProps) {
94
- const t = useTranslations('AssessmentPanel');
95
- const [newAssessmentText, setNewAssessmentText] = useState('');
96
- const [focusedAnnotationId, setFocusedAnnotationId] = useState<string | null>(
97
- null,
98
- );
99
- const containerRef = useRef<HTMLDivElement>(null);
100
-
101
- // Direct ref management
102
- const entryRefs = useRef<Map<string, HTMLDivElement>>(new Map());
103
-
104
- // Sort annotations by their position in the resource
105
- const sortedAnnotations = useMemo(() => {
106
- return [...annotations].sort((a, b) => {
107
- const aSelector = getTextPositionSelector(getTargetSelector(a.target));
108
- const bSelector = getTextPositionSelector(getTargetSelector(b.target));
109
- if (!aSelector || !bSelector) return 0;
110
- return aSelector.start - bSelector.start;
111
- });
112
- }, [annotations]);
113
-
114
- // Ref callback for entry components
115
- const setEntryRef = useCallback(
116
- (id: string, element: HTMLDivElement | null) => {
117
- if (element) {
118
- entryRefs.current.set(id, element);
119
- } else {
120
- entryRefs.current.delete(id);
121
- }
122
- },
123
- [],
124
- );
125
-
126
- // Handle scrollToAnnotationId (click scroll)
127
- useEffect(() => {
128
- if (!scrollToAnnotationId) return;
129
- const element = entryRefs.current.get(scrollToAnnotationId);
130
- if (element && containerRef.current) {
131
- const elementTop = element.offsetTop;
132
- const containerHeight = containerRef.current.clientHeight;
133
- const elementHeight = element.offsetHeight;
134
- const scrollTo = elementTop - containerHeight / 2 + elementHeight / 2;
135
- containerRef.current.scrollTo({ top: scrollTo, behavior: 'smooth' });
136
- element.classList.remove('xynolog-annotation-pulse');
137
- void element.offsetWidth;
138
- element.classList.add('xynolog-annotation-pulse');
139
- if (onScrollCompleted) onScrollCompleted();
140
- }
141
- }, [scrollToAnnotationId]);
142
-
143
- // Handle hoveredAnnotationId (hover scroll only - pulse is handled by isHovered prop)
144
- useEffect(() => {
145
- if (!hoveredAnnotationId) return;
146
- const element = entryRefs.current.get(hoveredAnnotationId);
147
- if (!element || !containerRef.current) return;
148
-
149
- const container = containerRef.current;
150
- const elementRect = element.getBoundingClientRect();
151
- const containerRect = container.getBoundingClientRect();
152
- const isVisible =
153
- elementRect.top >= containerRect.top &&
154
- elementRect.bottom <= containerRect.bottom;
155
- if (!isVisible) {
156
- const elementTop = element.offsetTop;
157
- const containerHeight = container.clientHeight;
158
- const elementHeight = element.offsetHeight;
159
- const scrollTo = elementTop - containerHeight / 2 + elementHeight / 2;
160
- container.scrollTo({ top: scrollTo, behavior: 'smooth' });
161
- }
162
-
163
- // Pulse effect is handled by isHovered prop on AssessmentEntry
164
- }, [hoveredAnnotationId]);
165
-
166
- const handleSaveNewAssessment = () => {
167
- if (pendingAnnotation) {
168
- // Body is optional for assessments. When the user typed text,
169
- // emit a single TextualBody (matching the worker's output and
170
- // the majority of persisted assessments). When they
171
- // didn't, omit body entirely — motivation:'assessing' on a
172
- // target is a valid empty-content assessment.
173
- const trimmed = newAssessmentText.trim();
174
- const body: components['schemas']['AnnotationBody'] | undefined = trimmed
175
- ? { type: 'TextualBody', value: trimmed, purpose: 'assessing' }
176
- : undefined;
177
-
178
- session?.client.mark.submit({
179
- source: resourceId,
180
- motivation: 'assessing',
181
- selector: pendingAnnotation.selector,
182
- ...(body !== undefined ? { body } : {}),
183
- });
184
- setNewAssessmentText('');
185
- }
186
- };
187
-
188
- // Escape key handler for cancelling pending annotation
189
- useEffect(() => {
190
- if (!pendingAnnotation) return;
191
-
192
- const handleEscape = (e: KeyboardEvent) => {
193
- if (e.key === 'Escape') {
194
- mark?.cancelPending();
195
- setNewAssessmentText('');
196
- }
197
- };
198
-
199
- document.addEventListener('keydown', handleEscape);
200
- return () => document.removeEventListener('keydown', handleEscape);
201
- }, [pendingAnnotation, mark]);
202
-
203
- // Event handler for annotation clicks (a named callback rather than an inline arrow function)
204
- const handleAnnotationClick = useCallback(
205
- ({ annotationId }: { annotationId: string }) => {
206
- setFocusedAnnotationId(annotationId);
207
- setTimeout(() => setFocusedAnnotationId(null), 3000);
208
- },
209
- [],
210
- );
211
-
212
- // Subscribe to click events - update focused state
213
- useSessionEventSubscriptions(session, {
214
- 'browse:click': handleAnnotationClick,
215
- });
216
-
217
- return (
218
- <div className="xynolog-panel">
219
- <PanelHeader count={annotations.length} title={t('title')} />
220
-
221
- {/* New assessment input - shown when there's a pending annotation with assessing motivation */}
222
- {pendingAnnotation && pendingAnnotation.motivation === 'assessing' && (
223
- <div className="xynolog-annotation-prompt" data-type="assessment">
224
- <div className="xynolog-annotation-prompt__quote">
225
- {(() => {
226
- const displayText = getSelectorDisplayText(
227
- pendingAnnotation.selector,
228
- );
229
- if (displayText) {
230
- return `"${displayText.substring(0, 100)}${displayText.length > 100 ? '...' : ''}"`;
231
- }
232
- // Generic labels for PDF/image annotations without text
233
- return t('fragmentSelected');
234
- })()}
235
- </div>
236
- <textarea
237
- value={newAssessmentText}
238
- onChange={(e) => setNewAssessmentText(e.target.value)}
239
- className="xynolog-textarea"
240
- rows={3}
241
- placeholder={t('assessmentPlaceholder')}
242
- autoFocus
243
- maxLength={2000}
244
- />
245
- <div className="xynolog-annotation-prompt__footer">
246
- <span className="xynolog-annotation-prompt__char-count">
247
- {newAssessmentText.length}/2000
248
- </span>
249
- <div className="xynolog-annotation-prompt__actions">
250
- <button
251
- onClick={() => {
252
- mark?.cancelPending();
253
- setNewAssessmentText('');
254
- }}
255
- className="xynolog-button xynolog-button--secondary"
256
- data-type="assessment"
257
- >
258
- {t('cancel')}
259
- </button>
260
- <button
261
- onClick={handleSaveNewAssessment}
262
- className="xynolog-button xynolog-button--primary"
263
- data-type="assessment"
264
- >
265
- {t('save')}
266
- </button>
267
- </div>
268
- </div>
269
- </div>
270
- )}
271
-
272
- {/* Scrollable content area */}
273
- <div ref={containerRef} className="xynolog-panel__content">
274
- {/* Delegate section - only in Annotate mode; shown for any media type (AI detection is media-agnostic — text is resolved via the media-type registry, incl. PDF text layers) */}
275
- {annotateMode && (
276
- <DelegateSection
277
- session={session}
278
- mark={mark}
279
- annotationType="assessment"
280
- isDelegating={isDelegating}
281
- locale={locale}
282
- sourceLanguage={sourceLanguage}
283
- progress={progress}
284
- jobId={jobId}
285
- cancelled={cancelled}
286
- />
287
- )}
288
-
289
- {/* Assessments list */}
290
- <div className="xynolog-panel__list">
291
- {sortedAnnotations.length === 0 ? (
292
- <p className="xynolog-panel__empty">{t('noAssessments')}</p>
293
- ) : (
294
- sortedAnnotations.map((assessment) => (
295
- <AssessmentEntry
296
- session={session}
297
- key={assessment.id}
298
- assessment={assessment}
299
- isFocused={assessment.id === focusedAnnotationId}
300
- isHovered={assessment.id === hoveredAnnotationId}
301
- ref={(el) => setEntryRef(assessment.id, el)}
302
- />
303
- ))
304
- )}
305
- </div>
306
- </div>
307
- </div>
308
- );
309
- }
@@ -1,228 +0,0 @@
1
- 'use client';
2
-
3
- import type { ConnectionState, EngineWithLimits } from '@xynolog/core';
4
- import { useTranslations } from '../../../contexts/TranslationContext';
5
- import './CollaborationPanel.css';
6
-
7
- /**
8
- * Token counts read as ceilings, not quantities — "200K" carries the meaning a
9
- * bare 200000 makes the reader compute. Kept lossless above the K/M break so a
10
- * 128000 window never displays as a rounded-away 130K.
11
- */
12
- function formatTokens(n: number): string {
13
- if (n >= 1_000_000) {
14
- const m = n / 1_000_000;
15
- return `${Number.isInteger(m) ? m : m.toFixed(1)}M`;
16
- }
17
- if (n >= 1_000) {
18
- const k = n / 1_000;
19
- return `${Number.isInteger(k) ? k : k.toFixed(1)}K`;
20
- }
21
- return String(n);
22
- }
23
-
24
- interface Props {
25
- /**
26
- * The state of the client's connection to the bus, as its transport
27
- * reports it (`ConnectionState`, in `@xynolog/core`).
28
- *
29
- * UI mapping:
30
- * `open` | `reconnecting` | `initial` | `connecting`
31
- * → treated as "healthy" (green dot, "Live" label, event count visible).
32
- * `reconnecting` is specifically INCLUDED in healthy because a
33
- * quick blip shouldn't alarm the user: the first retry is
34
- * sub-second, which makes `reconnecting` a transient state.
35
- * `degraded` | `closed`
36
- * → treated as "disconnected" (red dot, "Disconnected" label).
37
- * `degraded` is the 3 s threshold at which the state machine
38
- * decides the disconnect is sustained; this is the UI-banner
39
- * trigger.
40
- */
41
- state: ConnectionState;
42
- eventCount: number;
43
- lastEventTimestamp?: string;
44
- knowledgeBaseName?: string;
45
- /**
46
- * The KB's engines (`client.browse.engines()`, typically via
47
- * `useEngines`). Optional so hosts that never wire it — including
48
- * external consumers of this package — render without the engines section.
49
- *
50
- * Each entry's `limits` is absent whenever discovery could not answer *right
51
- * now*, so a missing ceiling is normal and shows as no ceiling rather than as
52
- * an error.
53
- */
54
- engines?: EngineWithLimits[];
55
- }
56
-
57
- export function CollaborationPanel({
58
- state,
59
- eventCount,
60
- lastEventTimestamp,
61
- knowledgeBaseName,
62
- engines = [],
63
- }: Props) {
64
- const t = useTranslations('CollaborationPanel');
65
-
66
- // Healthy = live, or briefly flapping. Only genuinely sustained
67
- // disconnects surface as "Disconnected" in the UI.
68
- const isHealthy =
69
- state === 'open' ||
70
- state === 'reconnecting' ||
71
- state === 'initial' ||
72
- state === 'connecting';
73
-
74
- // Format last sync time
75
- let lastSyncText: string;
76
- if (!lastEventTimestamp) {
77
- lastSyncText = t('noActivity');
78
- } else {
79
- const now = new Date();
80
- const eventTime = new Date(lastEventTimestamp);
81
- const diffMs = now.getTime() - eventTime.getTime();
82
- const diffSecs = Math.floor(diffMs / 1000);
83
- const diffMins = Math.floor(diffSecs / 60);
84
- const diffHours = Math.floor(diffMins / 60);
85
-
86
- if (diffSecs < 10) {
87
- lastSyncText = t('justNow');
88
- } else if (diffSecs < 60) {
89
- lastSyncText = t('secondsAgo', { count: diffSecs });
90
- } else if (diffMins === 1) {
91
- lastSyncText = t('minuteAgo');
92
- } else if (diffMins < 60) {
93
- lastSyncText = t('minutesAgo', { count: diffMins });
94
- } else if (diffHours === 1) {
95
- lastSyncText = t('hourAgo');
96
- } else if (diffHours < 24) {
97
- lastSyncText = t('hoursAgo', { count: diffHours });
98
- } else {
99
- lastSyncText = eventTime.toLocaleDateString();
100
- }
101
- }
102
-
103
- return (
104
- <div className="xynolog-collaboration-panel">
105
- {/* Panel Title */}
106
- <h3 className="xynolog-collaboration-panel__title">{t('title')}</h3>
107
-
108
- {knowledgeBaseName && (
109
- <div
110
- style={{
111
- padding: '0 0.75rem 0.5rem',
112
- fontSize: '0.8rem',
113
- color: 'var(--xynolog-color-neutral-400)',
114
- }}
115
- >
116
- {knowledgeBaseName}
117
- </div>
118
- )}
119
-
120
- {/* Connection Status Section */}
121
- <div className="xynolog-collaboration-panel__section">
122
- <h3 className="xynolog-collaboration-panel__heading">
123
- {t('connectionStatus')}
124
- </h3>
125
-
126
- {/* Live indicator */}
127
- <div className="xynolog-collaboration-panel__status">
128
- <span className="xynolog-collaboration-panel__indicator">
129
- <span
130
- className="xynolog-collaboration-panel__dot"
131
- data-connected={isHealthy ? 'true' : 'false'}
132
- ></span>
133
- <span
134
- className="xynolog-collaboration-panel__status-text"
135
- data-connected={isHealthy ? 'true' : 'false'}
136
- >
137
- {isHealthy ? t('live') : t('disconnected')}
138
- </span>
139
- </span>
140
- {isHealthy && eventCount > 0 && (
141
- <span className="xynolog-collaboration-panel__event-count">
142
- ({t('events', { count: eventCount })})
143
- </span>
144
- )}
145
- </div>
146
-
147
- {/* Last sync */}
148
- <div className="xynolog-collaboration-panel__details">
149
- <div>
150
- <span className="xynolog-collaboration-panel__label">
151
- {t('lastSync')}
152
- </span>{' '}
153
- {lastSyncText}
154
- </div>
155
- <div>{isHealthy ? t('realtimeActive') : t('reconnecting')}</div>
156
- </div>
157
- </div>
158
-
159
- {/* Engines — each a provider and a model, with its discovered ceilings */}
160
- {engines.length > 0 && (
161
- <div className="xynolog-collaboration-panel__section xynolog-collaboration-panel__section--bordered">
162
- <h3 className="xynolog-collaboration-panel__heading">
163
- {t('engines')}
164
- </h3>
165
- {engines.map((entry) => {
166
- const { provider, model } = entry.engine;
167
- const limits = entry.limits;
168
- // `maxOutputTokens === contextTokens` is the schema's documented
169
- // sentinel for a provider with ONE shared window (Ollama). Showing
170
- // "128K in / 128K out" there would invent a distinction the
171
- // provider does not make.
172
- const ceiling = !limits
173
- ? null
174
- : limits.maxOutputTokens === limits.contextTokens
175
- ? t('sharedWindow', {
176
- contextTokens: formatTokens(limits.contextTokens),
177
- })
178
- : t('ceilings', {
179
- contextTokens: formatTokens(limits.contextTokens),
180
- maxOutputTokens: formatTokens(limits.maxOutputTokens),
181
- });
182
-
183
- return (
184
- <div
185
- key={`${provider}:${model}`}
186
- className="xynolog-collaboration-panel__engine"
187
- data-testid="xynolog-engine-row"
188
- >
189
- <div className="xynolog-collaboration-panel__engine-id">
190
- <span className="xynolog-collaboration-panel__engine-provider">
191
- {provider}
192
- </span>
193
- <span className="xynolog-collaboration-panel__engine-model">
194
- {model}
195
- </span>
196
- </div>
197
- {entry.jobs && entry.jobs.length > 0 && (
198
- <div className="xynolog-collaboration-panel__engine-jobs">
199
- {entry.jobs
200
- .map((filter) =>
201
- filter.jobType === 'mark'
202
- ? filter.params.motivation
203
- : filter.jobType,
204
- )
205
- .join(', ')}
206
- </div>
207
- )}
208
- {ceiling && (
209
- <div className="xynolog-collaboration-panel__engine-limits">
210
- {ceiling}
211
- </div>
212
- )}
213
- </div>
214
- );
215
- })}
216
- </div>
217
- )}
218
-
219
- {/* Sharing Section - Placeholder for future */}
220
- <div className="xynolog-collaboration-panel__section xynolog-collaboration-panel__section--bordered">
221
- <h3 className="xynolog-collaboration-panel__heading">{t('sharing')}</h3>
222
- <p className="xynolog-collaboration-panel__description">
223
- {t('collaborationComingSoon')}
224
- </p>
225
- </div>
226
- </div>
227
- );
228
- }