@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,207 +0,0 @@
1
- /**
2
- * The delegated job's id goes where its progress goes: to the panel of the
3
- * delegated motivation, whose cancel control names that job. Every motivation
4
- * a person can delegate has the control, from the moment the queue has named
5
- * the job; before that there is none.
6
- */
7
- import React from 'react';
8
- import { describe, it, expect, vi, afterEach } from 'vitest';
9
- import { screen, fireEvent } from '@testing-library/react';
10
- import { renderInEnglish } from '../../../../test-utils';
11
- import '@testing-library/jest-dom';
12
- import {
13
- createMarkStateUnit,
14
- type MarkStateUnit,
15
- type XynologSession,
16
- } from '@xynolog/sdk';
17
- import { createTestSession } from '@xynolog/sdk/testing';
18
- import type {
19
- LinkComponentProps,
20
- RouteBuilder,
21
- } from '../../../../contexts/RoutingContext';
22
- import { UnifiedAnnotationsPanel } from '../UnifiedAnnotationsPanel';
23
- import {
24
- ANNOTATORS,
25
- annotatorKeyForMotivation,
26
- type AnnotatorKey,
27
- } from '../../../../lib/annotation-registry';
28
- import { jobId, resourceId, type JobId, type Motivation } from '@xynolog/core';
29
-
30
- const TestLink = ({ href, children, ...rest }: LinkComponentProps) => (
31
- <a href={href} {...rest}>
32
- {children}
33
- </a>
34
- );
35
- const testRoutes: RouteBuilder = { resourceDetail: (id) => `/r/${id}` };
36
-
37
- type PanelProps = React.ComponentProps<typeof UnifiedAnnotationsPanel>;
38
-
39
- const sessions: XynologSession[] = [];
40
- const marks: MarkStateUnit[] = [];
41
-
42
- afterEach(() => {
43
- vi.restoreAllMocks();
44
- for (const mark of marks.splice(0)) mark.dispose();
45
- for (const session of sessions.splice(0)) {
46
- session.client.dispose();
47
- session.dispose();
48
- }
49
- // The panel restores a resource's last tab from storage, over `initialTab`.
50
- localStorage.clear();
51
- });
52
-
53
- function harness() {
54
- const { session, client } = createTestSession();
55
- sessions.push(session);
56
- const mark = createMarkStateUnit(client, resourceId('res-1'));
57
- marks.push(mark);
58
- const cancel = vi.spyOn(client.job, 'cancel').mockResolvedValue(true);
59
- return { session, mark, cancel };
60
- }
61
-
62
- const delegating = (
63
- session: XynologSession,
64
- mark: MarkStateUnit,
65
- motivation: Motivation,
66
- tab: AnnotatorKey,
67
- job: JobId | null,
68
- ): PanelProps => ({
69
- session,
70
- mark,
71
- annotations: [],
72
- annotators: ANNOTATORS,
73
- annotateMode: true,
74
- allEntityTypes: [],
75
- pendingAnnotation: null,
76
- delegatingMotivation: motivation,
77
- progress: { percentage: 10 },
78
- progressMotivation: motivation,
79
- jobId: job,
80
- cancelled: false,
81
- resourceId: resourceId('res-1'),
82
- initialTab: tab,
83
- Link: TestLink,
84
- routes: testRoutes,
85
- });
86
-
87
- // Every motivation the registry knows is one a person can delegate.
88
- const motivations = Object.values(ANNOTATORS).map(({ motivation }) => {
89
- const tab = annotatorKeyForMotivation(motivation);
90
- if (!tab) throw new Error(`the registry names no panel for ${motivation}`);
91
- return { tab, motivation };
92
- });
93
-
94
- describe('UnifiedAnnotationsPanel: the delegated job', () => {
95
- it.each(motivations)(
96
- "gives a $motivation job's id to its panel, whose control cancels that job",
97
- ({ tab, motivation }) => {
98
- const { session, mark, cancel } = harness();
99
- renderInEnglish(
100
- <UnifiedAnnotationsPanel
101
- {...delegating(session, mark, motivation, tab, jobId('job-1'))}
102
- />,
103
- );
104
-
105
- fireEvent.click(screen.getByTestId('xynolog-delegate-control'));
106
- expect(cancel).toHaveBeenCalledExactlyOnceWith('job-1');
107
- },
108
- );
109
-
110
- it.each(motivations)(
111
- 'shows a $motivation job no control before the queue has named it',
112
- ({ tab, motivation }) => {
113
- const { session, mark } = harness();
114
- renderInEnglish(
115
- <UnifiedAnnotationsPanel
116
- {...delegating(session, mark, motivation, tab, null)}
117
- />,
118
- );
119
-
120
- // The display is there; only its control is not.
121
- expect(screen.getByTestId('xynolog-delegate-status')).toBeInTheDocument();
122
- expect(screen.queryByTestId('xynolog-delegate-control')).toBeNull();
123
- },
124
- );
125
-
126
- it("shows the references panel no control for another motivation's job", () => {
127
- const { session, mark } = harness();
128
- renderInEnglish(
129
- <UnifiedAnnotationsPanel
130
- {...delegating(
131
- session,
132
- mark,
133
- 'highlighting',
134
- 'reference',
135
- jobId('job-1'),
136
- )}
137
- />,
138
- );
139
-
140
- expect(screen.queryByTestId('xynolog-delegate-control')).toBeNull();
141
- });
142
- });
143
-
144
- /**
145
- * A delegated job that has ended: nothing is delegating, and its progress
146
- * stays with the motivation it is of until it is dismissed.
147
- */
148
- const ended = (
149
- session: XynologSession,
150
- mark: MarkStateUnit,
151
- motivation: Motivation,
152
- tab: AnnotatorKey,
153
- cancelled: boolean,
154
- ): PanelProps => ({
155
- ...delegating(session, mark, motivation, tab, null),
156
- delegatingMotivation: null,
157
- cancelled,
158
- });
159
-
160
- describe('UnifiedAnnotationsPanel: a delegated job that has ended', () => {
161
- it.each(motivations)(
162
- "keeps a finished $motivation job's display in its panel, whose Close asks the mark unit to dismiss it",
163
- ({ tab, motivation }) => {
164
- const { session, mark } = harness();
165
- const dismissProgress = vi.spyOn(mark, 'dismissProgress');
166
- renderInEnglish(
167
- <UnifiedAnnotationsPanel
168
- {...ended(session, mark, motivation, tab, false)}
169
- />,
170
- );
171
-
172
- expect(screen.getByTestId('xynolog-delegate-status')).toBeInTheDocument();
173
- expect(
174
- screen.getByTestId('xynolog-delegate-control'),
175
- ).toHaveAccessibleName('Close');
176
- fireEvent.click(screen.getByTestId('xynolog-delegate-control'));
177
- expect(dismissProgress).toHaveBeenCalledOnce();
178
- },
179
- );
180
-
181
- it.each(motivations)(
182
- 'says a cancelled $motivation job was cancelled',
183
- ({ tab, motivation }) => {
184
- const { session, mark } = harness();
185
- renderInEnglish(
186
- <UnifiedAnnotationsPanel
187
- {...ended(session, mark, motivation, tab, true)}
188
- />,
189
- );
190
-
191
- expect(screen.getByTestId('xynolog-delegate-status').textContent).toBe(
192
- 'Cancelled',
193
- );
194
- },
195
- );
196
-
197
- it("shows a finished job's display in no other motivation's panel", () => {
198
- const { session, mark } = harness();
199
- renderInEnglish(
200
- <UnifiedAnnotationsPanel
201
- {...ended(session, mark, 'highlighting', 'reference', false)}
202
- />,
203
- );
204
-
205
- expect(screen.queryByTestId('xynolog-delegate-status')).toBeNull();
206
- });
207
- });
@@ -1,89 +0,0 @@
1
- /**
2
- * The annotations panel must be able to say the annotations failed to load.
3
- *
4
- * Every tab in this panel derives from one `annotations` array. When that load
5
- * fails terminally (B15) the array is empty — indistinguishable from a
6
- * resource that genuinely has no annotations, so the panel cheerfully reports
7
- * "no highlights" for a resource full of them. That is the same
8
- * apparent-data-loss shape as the PDF-annotations bug, arrived at from a
9
- * different direction.
10
- */
11
- import React from 'react';
12
- import { describe, it, expect, vi } from 'vitest';
13
- import { screen, fireEvent } from '@testing-library/react';
14
- import { renderInEnglish } from '../../../../test-utils';
15
- import '@testing-library/jest-dom';
16
- import type { XynologSession } from '@xynolog/sdk';
17
- import type {
18
- LinkComponentProps,
19
- RouteBuilder,
20
- } from '../../../../contexts/RoutingContext';
21
- import { UnifiedAnnotationsPanel } from '../UnifiedAnnotationsPanel';
22
- import { ANNOTATORS } from '../../../../lib/annotation-registry';
23
- import { resourceId, EventBus } from '@xynolog/core';
24
-
25
- const TestLink = ({ href, children, ...rest }: LinkComponentProps) => (
26
- <a href={href} {...rest}>
27
- {children}
28
- </a>
29
- );
30
- const testRoutes: RouteBuilder = { resourceDetail: (id) => `/r/${id}` };
31
-
32
- function fakeSession(): XynologSession {
33
- return {
34
- client: {
35
- bus: new EventBus(),
36
- browse: { click: vi.fn() },
37
- beckon: { hover: vi.fn() },
38
- },
39
- } as unknown as XynologSession;
40
- }
41
-
42
- type PanelProps = React.ComponentProps<typeof UnifiedAnnotationsPanel>;
43
-
44
- const base = (): PanelProps => ({
45
- session: fakeSession(),
46
- mark: undefined,
47
- annotations: [],
48
- annotators: ANNOTATORS,
49
- allEntityTypes: [],
50
- pendingAnnotation: null,
51
- resourceId: resourceId('res-1'),
52
- Link: TestLink,
53
- routes: testRoutes,
54
- });
55
-
56
- describe('UnifiedAnnotationsPanel — annotations load failure', () => {
57
- it('reports the failure rather than presenting an empty annotation set as fact', () => {
58
- renderInEnglish(
59
- <UnifiedAnnotationsPanel
60
- {...base()}
61
- annotationsError={new Error('Resource not found')}
62
- />,
63
- );
64
-
65
- expect(screen.getByText(/Could not load annotations/)).toBeInTheDocument();
66
- });
67
-
68
- it('offers a retry that calls back', () => {
69
- const onRetryAnnotations = vi.fn();
70
- renderInEnglish(
71
- <UnifiedAnnotationsPanel
72
- {...base()}
73
- annotationsError={new Error('boom')}
74
- onRetryAnnotations={onRetryAnnotations}
75
- />,
76
- );
77
-
78
- fireEvent.click(screen.getByRole('button', { name: 'Try again' }));
79
- expect(onRetryAnnotations).toHaveBeenCalledTimes(1);
80
- });
81
-
82
- it('says nothing about failure when the annotations are merely empty', () => {
83
- renderInEnglish(<UnifiedAnnotationsPanel {...base()} />);
84
-
85
- expect(
86
- screen.queryByText(/Could not load annotations/),
87
- ).not.toBeInTheDocument();
88
- });
89
- });
@@ -1,136 +0,0 @@
1
- import { describe, it, expect } from 'vitest';
2
- import {
3
- creatorName,
4
- renderAgentLabel,
5
- renderAgentLabels,
6
- } from '../agent-label';
7
- import type { components } from '@xynolog/core';
8
-
9
- type Agent = components['schemas']['Agent'];
10
-
11
- describe('renderAgentLabel', () => {
12
- describe('Software peers', () => {
13
- it('is labeled by its name, then the provider and model it runs', () => {
14
- const agent: Agent = {
15
- '@type': 'Software',
16
- '@id': 'did:web:example.com:agents:xynolog-worker',
17
- name: 'my-highlighter',
18
- provider: 'ollama',
19
- model: 'gemma2:27b',
20
- };
21
- expect(renderAgentLabel(agent)).toBe(
22
- 'my-highlighter (ollama gemma2:27b)',
23
- );
24
- });
25
-
26
- it('is labeled by its name and its model when it states no provider', () => {
27
- const agent: Agent = {
28
- '@type': 'Software',
29
- name: 'my-highlighter',
30
- model: 'gpt-4',
31
- };
32
- expect(renderAgentLabel(agent)).toBe('my-highlighter (gpt-4)');
33
- });
34
-
35
- it('is labeled by its name and its provider when it states no model', () => {
36
- const agent: Agent = {
37
- '@type': 'Software',
38
- name: 'my-highlighter',
39
- provider: 'anthropic',
40
- };
41
- expect(renderAgentLabel(agent)).toBe('my-highlighter (anthropic)');
42
- });
43
-
44
- it('is labeled by its provider and model when it has no profile', () => {
45
- const agent: Agent = {
46
- '@type': 'Software',
47
- '@id': 'did:web:example.com:agents:xynolog-worker',
48
- provider: 'ollama',
49
- model: 'gemma2:27b',
50
- };
51
- expect(renderAgentLabel(agent)).toBe('ollama gemma2:27b');
52
- });
53
-
54
- it('is labeled by its model alone when it has no profile and states no provider', () => {
55
- const agent: Agent = {
56
- '@type': 'Software',
57
- model: 'gpt-4',
58
- };
59
- expect(renderAgentLabel(agent)).toBe('gpt-4');
60
- });
61
-
62
- it('falls back to name when both provider and model are absent', () => {
63
- const agent: Agent = {
64
- '@type': 'Software',
65
- name: 'Some Software',
66
- };
67
- expect(renderAgentLabel(agent)).toBe('Some Software');
68
- });
69
-
70
- it('falls back to its DID when it says nothing of itself, as a generator the record supplies', () => {
71
- const agent: Agent = {
72
- '@type': 'Software',
73
- '@id': 'did:web:example.com:agents:xynolog-worker',
74
- };
75
- expect(renderAgentLabel(agent)).toBe(
76
- 'did:web:example.com:agents:xynolog-worker',
77
- );
78
- });
79
- });
80
-
81
- describe('Person and Organization peers', () => {
82
- it('renders Person name', () => {
83
- const agent: Agent = {
84
- '@type': 'Person',
85
- '@id': 'did:web:example.com:users:alice%40example.com',
86
- name: 'Alice',
87
- };
88
- expect(renderAgentLabel(agent)).toBe('Alice');
89
- });
90
-
91
- it('renders Organization name', () => {
92
- const agent: Agent = {
93
- '@type': 'Organization',
94
- name: 'Acme Corp',
95
- };
96
- expect(renderAgentLabel(agent)).toBe('Acme Corp');
97
- });
98
- });
99
-
100
- describe('Degraded shapes', () => {
101
- it('falls back to @id when name is empty', () => {
102
- const agent = {
103
- '@type': 'Person',
104
- '@id': 'did:web:example.com:users:bob%40example.com',
105
- name: '',
106
- } as unknown as Agent;
107
- expect(renderAgentLabel(agent)).toBe(
108
- 'did:web:example.com:users:bob%40example.com',
109
- );
110
- });
111
-
112
- it('has no label when nothing identifies the agent', () => {
113
- const agent = { '@type': 'Person', name: '' } as unknown as Agent;
114
- expect(renderAgentLabel(agent)).toBeUndefined();
115
- });
116
- });
117
- });
118
-
119
- describe('an agent that names itself in no way', () => {
120
- const nameless = { '@type': 'Person' } as Agent;
121
-
122
- it('is left out of a list of labels', () => {
123
- const alice = { '@type': 'Person', name: 'Alice' } as Agent;
124
-
125
- expect(renderAgentLabels([alice, nameless])).toBe('Alice');
126
- expect(renderAgentLabels(nameless)).toBe('');
127
- });
128
-
129
- it('has no creator name', () => {
130
- expect(creatorName(nameless)).toBeUndefined();
131
- expect(creatorName(undefined)).toBeUndefined();
132
- expect(creatorName('did:web:example.com:users:bob')).toBe(
133
- 'did:web:example.com:users:bob',
134
- );
135
- });
136
- });
@@ -1,35 +0,0 @@
1
- import type { components } from '@xynolog/core';
2
-
3
- type Agent = components['schemas']['Agent'];
4
-
5
- /**
6
- * Compose a display label for an Agent at render time. An agent's `name`
7
- * is what its profile says it is called, filled in when the record is read.
8
- * A Software agent is labeled by its name followed by the provider and model
9
- * it says it runs, `my-highlighter (anthropic claude-haiku-4-5)`, and by
10
- * whichever of these it has when it lacks the others. Every agent falls back
11
- * to its `@id`. An agent with none of these has no label.
12
- */
13
- export function renderAgentLabel(agent: Agent): string | undefined {
14
- if (agent['@type'] === 'Software') {
15
- const engine = [agent.provider, agent.model].filter(Boolean).join(' ');
16
- if (agent.name && engine) return `${agent.name} (${engine})`;
17
- return agent.name || engine || agent['@id'];
18
- }
19
- return agent.name || agent['@id'];
20
- }
21
-
22
- /** The labels of one agent or of several, joined. Empty when none of them has a label. */
23
- export function renderAgentLabels(agents: Agent | Agent[]): string {
24
- return (Array.isArray(agents) ? agents : [agents])
25
- .map(renderAgentLabel)
26
- .filter((label) => label !== undefined)
27
- .join(', ');
28
- }
29
-
30
- /** The name an annotation's creator goes by, when it has one. */
31
- export function creatorName(
32
- creator: Agent | string | undefined,
33
- ): string | undefined {
34
- return typeof creator === 'string' ? creator : creator?.name;
35
- }