@semiont/react-ui 0.2.34-build.91 → 0.2.34-build.93

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 (195) hide show
  1. package/dist/{EventBusContext-BmzEcGHZ.d.mts → EventBusContext-DMI4uwYk.d.mts} +2 -2
  2. package/dist/{PdfAnnotationCanvas.client-VLNA5O5M.mjs → PdfAnnotationCanvas.client-HNYRKFDS.mjs} +10 -9
  3. package/dist/PdfAnnotationCanvas.client-HNYRKFDS.mjs.map +1 -0
  4. package/dist/{ar-4ZEORRW2.mjs → ar-MDB7HC5S.mjs} +45 -49
  5. package/dist/ar-MDB7HC5S.mjs.map +1 -0
  6. package/dist/{bn-SEDE5BQJ.mjs → bn-3SAV2ZEM.mjs} +45 -49
  7. package/dist/bn-3SAV2ZEM.mjs.map +1 -0
  8. package/dist/{chunk-C63BARI7.mjs → chunk-3FIQXKQF.mjs} +31 -31
  9. package/dist/{chunk-D7NBW4RV.mjs → chunk-JH7BXE2P.mjs} +45 -49
  10. package/dist/chunk-JH7BXE2P.mjs.map +1 -0
  11. package/dist/{chunk-M7SZRRIE.mjs → chunk-MWQ5CNKW.mjs} +13 -13
  12. package/dist/chunk-MWQ5CNKW.mjs.map +1 -0
  13. package/dist/{chunk-ULIET3MW.mjs → chunk-YI5IX5ZA.mjs} +1 -1
  14. package/dist/{chunk-ULIET3MW.mjs.map → chunk-YI5IX5ZA.mjs.map} +1 -1
  15. package/dist/{cs-7W4WF5WD.mjs → cs-AWCETEUV.mjs} +45 -49
  16. package/dist/cs-AWCETEUV.mjs.map +1 -0
  17. package/dist/{da-75XGBCBK.mjs → da-UZZHXYLC.mjs} +45 -49
  18. package/dist/da-UZZHXYLC.mjs.map +1 -0
  19. package/dist/{de-ODJVFLHM.mjs → de-LQFWN6S5.mjs} +45 -49
  20. package/dist/de-LQFWN6S5.mjs.map +1 -0
  21. package/dist/{el-C4PM4WB3.mjs → el-IWOETBJ7.mjs} +45 -49
  22. package/dist/el-IWOETBJ7.mjs.map +1 -0
  23. package/dist/{en-KJCJQ4OO.mjs → en-XWEPVTB4.mjs} +2 -6
  24. package/dist/{es-WD33R7QL.mjs → es-726NTS53.mjs} +45 -49
  25. package/dist/es-726NTS53.mjs.map +1 -0
  26. package/dist/{fa-2BP6V56P.mjs → fa-BVEJZT5S.mjs} +45 -49
  27. package/dist/fa-BVEJZT5S.mjs.map +1 -0
  28. package/dist/{fi-USRRW24J.mjs → fi-JBNCGGA6.mjs} +45 -49
  29. package/dist/fi-JBNCGGA6.mjs.map +1 -0
  30. package/dist/{fr-EC5S6WVF.mjs → fr-OLH7PNGI.mjs} +45 -49
  31. package/dist/fr-OLH7PNGI.mjs.map +1 -0
  32. package/dist/{he-7TBVIKAA.mjs → he-KOJQ4HMA.mjs} +45 -49
  33. package/dist/he-KOJQ4HMA.mjs.map +1 -0
  34. package/dist/{hi-FO4VIZLA.mjs → hi-BKJFZXAY.mjs} +45 -49
  35. package/dist/hi-BKJFZXAY.mjs.map +1 -0
  36. package/dist/{id-7U7GGVWY.mjs → id-DPLHJVNP.mjs} +45 -49
  37. package/dist/id-DPLHJVNP.mjs.map +1 -0
  38. package/dist/index.css +80 -80
  39. package/dist/index.css.map +1 -1
  40. package/dist/index.d.mts +215 -201
  41. package/dist/index.mjs +812 -752
  42. package/dist/index.mjs.map +1 -1
  43. package/dist/{it-Y4OPL6I2.mjs → it-JXHAM7NL.mjs} +45 -49
  44. package/dist/it-JXHAM7NL.mjs.map +1 -0
  45. package/dist/{ja-PK7SQL55.mjs → ja-DQRAO3PU.mjs} +45 -49
  46. package/dist/ja-DQRAO3PU.mjs.map +1 -0
  47. package/dist/{ko-L25PXMYD.mjs → ko-6IFCOP6F.mjs} +45 -49
  48. package/dist/ko-6IFCOP6F.mjs.map +1 -0
  49. package/dist/{ms-STH777QM.mjs → ms-KF5S2TLL.mjs} +45 -49
  50. package/dist/ms-KF5S2TLL.mjs.map +1 -0
  51. package/dist/{nl-Y7LECDDR.mjs → nl-2GUUZLQM.mjs} +45 -49
  52. package/dist/nl-2GUUZLQM.mjs.map +1 -0
  53. package/dist/{no-KEKCEWU6.mjs → no-2IBCZGEF.mjs} +45 -49
  54. package/dist/no-2IBCZGEF.mjs.map +1 -0
  55. package/dist/{pl-7A7OC75O.mjs → pl-ZEUBJ7YU.mjs} +45 -49
  56. package/dist/pl-ZEUBJ7YU.mjs.map +1 -0
  57. package/dist/{pt-35HTM7RA.mjs → pt-WLAFIZWQ.mjs} +45 -49
  58. package/dist/pt-WLAFIZWQ.mjs.map +1 -0
  59. package/dist/{ro-VAWL5KQA.mjs → ro-K56IXFGU.mjs} +45 -49
  60. package/dist/ro-K56IXFGU.mjs.map +1 -0
  61. package/dist/{sv-7ZK5EQEB.mjs → sv-VFJLMJRY.mjs} +45 -49
  62. package/dist/sv-VFJLMJRY.mjs.map +1 -0
  63. package/dist/test-utils.d.mts +2 -2
  64. package/dist/test-utils.mjs +3 -3
  65. package/dist/{th-UDWZ4X34.mjs → th-RICLQ2GW.mjs} +45 -49
  66. package/dist/th-RICLQ2GW.mjs.map +1 -0
  67. package/dist/{tr-4WMPK3UX.mjs → tr-SALXWE2M.mjs} +45 -49
  68. package/dist/tr-SALXWE2M.mjs.map +1 -0
  69. package/dist/{uk-SSLASQYJ.mjs → uk-3U3T3O2E.mjs} +45 -49
  70. package/dist/uk-3U3T3O2E.mjs.map +1 -0
  71. package/dist/{vi-IF42Z5PU.mjs → vi-LIVNZXOB.mjs} +45 -49
  72. package/dist/vi-LIVNZXOB.mjs.map +1 -0
  73. package/dist/{zh-HRQTNTAI.mjs → zh-KDUAZPX3.mjs} +45 -49
  74. package/dist/zh-KDUAZPX3.mjs.map +1 -0
  75. package/package.json +1 -1
  76. package/src/components/AnnotateReferencesProgressWidget.tsx +113 -0
  77. package/src/components/CodeMirrorRenderer.tsx +9 -27
  78. package/src/components/Toolbar.tsx +2 -2
  79. package/src/components/annotation/AnnotateToolbar.tsx +9 -9
  80. package/src/components/annotation/__tests__/AnnotateToolbar.test.tsx +17 -17
  81. package/src/components/image-annotation/AnnotationOverlay.tsx +13 -11
  82. package/src/components/image-annotation/SvgDrawingCanvas.tsx +8 -4
  83. package/src/components/pdf-annotation/PdfAnnotationCanvas.tsx +11 -9
  84. package/src/components/pdf-annotation/__tests__/PdfAnnotationCanvas.test.tsx +1 -1
  85. package/src/components/resource/AnnotateView.tsx +17 -12
  86. package/src/components/resource/BrowseView.tsx +19 -50
  87. package/src/components/resource/ResourceViewer.tsx +28 -24
  88. package/src/components/resource/__tests__/BrowseView.test.tsx +27 -27
  89. package/src/components/resource/panels/AssessmentEntry.tsx +1 -1
  90. package/src/components/resource/panels/AssessmentPanel.tsx +16 -16
  91. package/src/components/resource/panels/{DetectSection.css → AssistSection.css} +79 -79
  92. package/src/components/resource/panels/{DetectSection.tsx → AssistSection.tsx} +46 -46
  93. package/src/components/resource/panels/CommentEntry.tsx +1 -1
  94. package/src/components/resource/panels/CommentsPanel.tsx +16 -16
  95. package/src/components/resource/panels/HighlightEntry.tsx +1 -1
  96. package/src/components/resource/panels/HighlightPanel.tsx +14 -14
  97. package/src/components/resource/panels/ReferenceEntry.tsx +5 -5
  98. package/src/components/resource/panels/ReferencesPanel.tsx +90 -103
  99. package/src/components/resource/panels/ResourceInfoPanel.tsx +2 -2
  100. package/src/components/resource/panels/TagEntry.tsx +1 -1
  101. package/src/components/resource/panels/TaggingPanel.tsx +53 -53
  102. package/src/components/resource/panels/UnifiedAnnotationsPanel.tsx +12 -20
  103. package/src/components/resource/panels/__tests__/AssessmentPanel.test.tsx +12 -12
  104. package/src/components/resource/panels/__tests__/{DetectSection.test.tsx → AssistSection.test.tsx} +109 -108
  105. package/src/components/resource/panels/__tests__/CommentEntry.test.tsx +8 -8
  106. package/src/components/resource/panels/__tests__/CommentsPanel.test.tsx +3 -3
  107. package/src/components/resource/panels/__tests__/{HighlightPanel.detectionProgress.test.tsx → HighlightPanel.annotationProgress.test.tsx} +56 -56
  108. package/src/components/resource/panels/__tests__/ReferencesPanel.test.tsx +98 -95
  109. package/src/components/resource/panels/__tests__/ResourceInfoPanel.test.tsx +3 -3
  110. package/src/components/resource/panels/__tests__/TaggingPanel.test.tsx +16 -16
  111. package/src/components/settings/SettingsPanel.tsx +29 -1
  112. package/src/features/resource-compose/components/ResourceComposePage.tsx +3 -0
  113. package/src/features/resource-viewer/__tests__/AnnotationCreationPending.test.tsx +36 -26
  114. package/src/features/resource-viewer/__tests__/AnnotationDeletionIntegration.test.tsx +26 -16
  115. package/src/features/resource-viewer/__tests__/{DetectionProgressDismissal.test.tsx → AnnotationProgressDismissal.test.tsx} +48 -38
  116. package/src/features/resource-viewer/__tests__/DetectionFlowBug.test.tsx +59 -49
  117. package/src/features/resource-viewer/__tests__/DetectionFlowIntegration.test.tsx +55 -33
  118. package/src/features/resource-viewer/__tests__/GenerationFlowIntegration.test.tsx +24 -16
  119. package/src/features/resource-viewer/__tests__/ResolutionFlowIntegration.test.tsx +41 -31
  120. package/src/features/resource-viewer/__tests__/ResourceMutations.test.tsx +10 -10
  121. package/src/features/resource-viewer/__tests__/ToastNotifications.test.tsx +196 -0
  122. package/src/features/resource-viewer/__tests__/{detection-progress-flow.test.tsx → annotation-progress-flow.test.tsx} +51 -28
  123. package/src/features/resource-viewer/components/ResourceViewerPage.tsx +56 -45
  124. package/src/styles/core/buttons.css +3 -3
  125. package/src/styles/core/forms.css +2 -2
  126. package/src/styles/index.css +1 -1
  127. package/src/styles/motivations/motivation-assessment.css +9 -9
  128. package/src/styles/motivations/motivation-comment.css +9 -9
  129. package/src/styles/motivations/motivation-highlight.css +9 -9
  130. package/src/styles/motivations/motivation-reference.css +9 -9
  131. package/src/styles/motivations/motivation-tag.css +9 -9
  132. package/src/styles/utilities/focus-extended.css +6 -6
  133. package/translations/ar.json +44 -44
  134. package/translations/bn.json +44 -44
  135. package/translations/cs.json +44 -44
  136. package/translations/da.json +44 -44
  137. package/translations/de.json +44 -44
  138. package/translations/el.json +44 -44
  139. package/translations/en.json +44 -44
  140. package/translations/es.json +44 -44
  141. package/translations/fa.json +44 -44
  142. package/translations/fi.json +44 -44
  143. package/translations/fr.json +44 -44
  144. package/translations/he.json +44 -44
  145. package/translations/hi.json +44 -44
  146. package/translations/id.json +44 -44
  147. package/translations/it.json +44 -44
  148. package/translations/ja.json +44 -44
  149. package/translations/ko.json +44 -44
  150. package/translations/ms.json +44 -44
  151. package/translations/nl.json +44 -44
  152. package/translations/no.json +44 -44
  153. package/translations/pl.json +44 -44
  154. package/translations/pt.json +44 -44
  155. package/translations/ro.json +44 -44
  156. package/translations/sv.json +44 -44
  157. package/translations/th.json +44 -44
  158. package/translations/tr.json +44 -44
  159. package/translations/uk.json +44 -44
  160. package/translations/vi.json +44 -44
  161. package/translations/zh.json +44 -44
  162. package/dist/PdfAnnotationCanvas.client-VLNA5O5M.mjs.map +0 -1
  163. package/dist/ar-4ZEORRW2.mjs.map +0 -1
  164. package/dist/bn-SEDE5BQJ.mjs.map +0 -1
  165. package/dist/chunk-D7NBW4RV.mjs.map +0 -1
  166. package/dist/chunk-M7SZRRIE.mjs.map +0 -1
  167. package/dist/cs-7W4WF5WD.mjs.map +0 -1
  168. package/dist/da-75XGBCBK.mjs.map +0 -1
  169. package/dist/de-ODJVFLHM.mjs.map +0 -1
  170. package/dist/el-C4PM4WB3.mjs.map +0 -1
  171. package/dist/es-WD33R7QL.mjs.map +0 -1
  172. package/dist/fa-2BP6V56P.mjs.map +0 -1
  173. package/dist/fi-USRRW24J.mjs.map +0 -1
  174. package/dist/fr-EC5S6WVF.mjs.map +0 -1
  175. package/dist/he-7TBVIKAA.mjs.map +0 -1
  176. package/dist/hi-FO4VIZLA.mjs.map +0 -1
  177. package/dist/id-7U7GGVWY.mjs.map +0 -1
  178. package/dist/it-Y4OPL6I2.mjs.map +0 -1
  179. package/dist/ja-PK7SQL55.mjs.map +0 -1
  180. package/dist/ko-L25PXMYD.mjs.map +0 -1
  181. package/dist/ms-STH777QM.mjs.map +0 -1
  182. package/dist/nl-Y7LECDDR.mjs.map +0 -1
  183. package/dist/no-KEKCEWU6.mjs.map +0 -1
  184. package/dist/pl-7A7OC75O.mjs.map +0 -1
  185. package/dist/pt-35HTM7RA.mjs.map +0 -1
  186. package/dist/ro-VAWL5KQA.mjs.map +0 -1
  187. package/dist/sv-7ZK5EQEB.mjs.map +0 -1
  188. package/dist/th-UDWZ4X34.mjs.map +0 -1
  189. package/dist/tr-4WMPK3UX.mjs.map +0 -1
  190. package/dist/uk-SSLASQYJ.mjs.map +0 -1
  191. package/dist/vi-IF42Z5PU.mjs.map +0 -1
  192. package/dist/zh-HRQTNTAI.mjs.map +0 -1
  193. package/src/components/DetectionProgressWidget.tsx +0 -113
  194. /package/dist/{chunk-C63BARI7.mjs.map → chunk-3FIQXKQF.mjs.map} +0 -0
  195. /package/dist/{en-KJCJQ4OO.mjs.map → en-XWEPVTB4.mjs.map} +0 -0
@@ -12,6 +12,7 @@ interface SettingsPanelProps {
12
12
  theme: 'light' | 'dark' | 'system';
13
13
  locale: string;
14
14
  isPendingLocaleChange?: boolean;
15
+ hoverDelayMs: number;
15
16
  }
16
17
 
17
18
  /**
@@ -20,12 +21,14 @@ interface SettingsPanelProps {
20
21
  * @emits settings:locale-changed - Locale changed by user. Payload: { locale: string }
21
22
  * @emits settings:line-numbers-toggled - Line numbers toggled on/off. Payload: undefined
22
23
  * @emits settings:theme-changed - Theme changed by user. Payload: { theme: 'light' | 'dark' | 'system' }
24
+ * @emits settings:hover-delay-changed - Hover delay changed by user. Payload: { hoverDelayMs: number }
23
25
  */
24
26
  export function SettingsPanel({
25
27
  showLineNumbers,
26
28
  theme,
27
29
  locale,
28
- isPendingLocaleChange = false
30
+ isPendingLocaleChange = false,
31
+ hoverDelayMs
29
32
  }: SettingsPanelProps) {
30
33
  const t = useTranslations('Settings');
31
34
  const eventBus = useEventBus();
@@ -154,6 +157,31 @@ export function SettingsPanel({
154
157
  </p>
155
158
  )}
156
159
  </div>
160
+
161
+ {/* Hover Delay Slider */}
162
+ <div className="semiont-settings-panel__field">
163
+ <label htmlFor="hover-delay-slider" className="semiont-form__label">
164
+ {t('hoverDelay')}
165
+ </label>
166
+ <input
167
+ id="hover-delay-slider"
168
+ type="range"
169
+ min="0"
170
+ max="500"
171
+ step="50"
172
+ value={hoverDelayMs}
173
+ onChange={(e) => eventBus.get('settings:hover-delay-changed').next({ hoverDelayMs: Number(e.target.value) })}
174
+ className="semiont-slider"
175
+ aria-describedby="hover-delay-description"
176
+ />
177
+ <div className="semiont-slider__labels">
178
+ <span>{t('hoverDelayFast')}</span>
179
+ <span>{t('hoverDelaySlow')}</span>
180
+ </div>
181
+ <p id="hover-delay-description" className="semiont-form__help">
182
+ {t('hoverDelayDescription', { delay: hoverDelayMs })}
183
+ </p>
184
+ </div>
157
185
  </div>
158
186
  </div>
159
187
  );
@@ -42,6 +42,7 @@ export interface ResourceComposePageProps {
42
42
  // UI state
43
43
  theme: 'light' | 'dark';
44
44
  showLineNumbers: boolean;
45
+ hoverDelayMs: number;
45
46
  activePanel: string | null;
46
47
 
47
48
  // Actions
@@ -110,6 +111,7 @@ export function ResourceComposePage({
110
111
  initialLocale,
111
112
  theme,
112
113
  showLineNumbers,
114
+ hoverDelayMs,
113
115
  activePanel,
114
116
  onSaveResource,
115
117
  onCancel,
@@ -527,6 +529,7 @@ export function ResourceComposePage({
527
529
  editable={!isCreating}
528
530
  sourceView={true}
529
531
  showLineNumbers={showLineNumbers}
532
+ hoverDelayMs={hoverDelayMs}
530
533
  onChange={(newContent) => setNewResourceContent(newContent)}
531
534
  />
532
535
  </div>
@@ -1,13 +1,13 @@
1
1
  /**
2
- * Regression test: pendingAnnotation cleared after annotation:create succeeds
2
+ * Regression test: pendingAnnotation cleared after annotate:createsucceeds
3
3
  *
4
- * Bug: handleAnnotationCreate in useDetectionFlow called the API and emitted
5
- * annotation:created, but never called setPendingAnnotation(null). The pending
4
+ * Bug: handleAnnotationCreate in useAnnotationFlow called the API and emitted
5
+ * annotate:created, but never called setPendingAnnotation(null). The pending
6
6
  * creation form (e.g. "Create Reference", "Save" assessment) remained visible
7
7
  * after the user clicked the confirm button.
8
8
  *
9
9
  * Fix: setPendingAnnotation(null) added in handleAnnotationCreate on success,
10
- * before emitting annotation:created.
10
+ * before emitting annotate:created.
11
11
  *
12
12
  * This test covers all four motivations that have a pending form:
13
13
  * - linking (ReferencesPanel: "Create Reference" button)
@@ -20,7 +20,7 @@ import React from 'react';
20
20
  import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
21
21
  import { render, screen, waitFor } from '@testing-library/react';
22
22
  import { act } from 'react';
23
- import { useDetectionFlow } from '../../../hooks/useDetectionFlow';
23
+ import { useAnnotationFlow } from '../../../hooks/useAnnotationFlow';
24
24
  import { EventBusProvider, useEventBus, resetEventBusForTesting } from '../../../contexts/EventBusContext';
25
25
  import { ApiClientProvider } from '../../../contexts/ApiClientContext';
26
26
  import { AuthTokenProvider } from '../../../contexts/AuthTokenContext';
@@ -28,6 +28,16 @@ import { SemiontApiClient } from '@semiont/api-client';
28
28
  import { resourceUri } from '@semiont/core';
29
29
  import type { Emitter } from 'mitt';
30
30
  import type { EventMap } from '@semiont/core';
31
+
32
+ // Mock Toast module to prevent "useToast must be used within a ToastProvider" errors
33
+ vi.mock('../../../components/Toast', () => ({
34
+ useToast: () => ({
35
+ showSuccess: vi.fn(),
36
+ showError: vi.fn(),
37
+ showInfo: vi.fn(),
38
+ showWarning: vi.fn(),
39
+ }),
40
+ }));
31
41
  import type { Motivation, Selector } from '@semiont/core';
32
42
 
33
43
  const TEST_URI = resourceUri('http://localhost:4000/resources/test-resource');
@@ -61,7 +71,7 @@ function renderDetectionFlow(testUri: string) {
61
71
  }
62
72
 
63
73
  function DetectionFlowHarness() {
64
- const { pendingAnnotation } = useDetectionFlow(testUri as any);
74
+ const { pendingAnnotation } = useAnnotationFlow(testUri as any);
65
75
  return (
66
76
  <div>
67
77
  <div data-testid="pending-motivation">
@@ -112,16 +122,16 @@ describe('Annotation creation clears pendingAnnotation', () => {
112
122
 
113
123
  // Set a pending annotation
114
124
  act(() => {
115
- emit('annotation:requested', { selector: TEXT_SELECTOR, motivation: 'linking' });
125
+ emit('annotate:requested', { selector: TEXT_SELECTOR, motivation: 'linking' });
116
126
  });
117
127
 
118
128
  await waitFor(() => {
119
129
  expect(screen.getByTestId('pending-motivation')).toHaveTextContent('linking');
120
130
  });
121
131
 
122
- // Emit annotation:create (what ReferencesPanel does when user clicks "Create Reference")
132
+ // Emit annotate:create(what ReferencesPanel does when user clicks "Create Reference")
123
133
  await act(async () => {
124
- emit('annotation:create', {
134
+ emit('annotate:create', {
125
135
  motivation: 'linking',
126
136
  selector: TEXT_SELECTOR,
127
137
  body: [{ type: 'TextualBody', value: 'Person', purpose: 'tagging' }],
@@ -140,7 +150,7 @@ describe('Annotation creation clears pendingAnnotation', () => {
140
150
  const { emit } = renderDetectionFlow(TEST_URI);
141
151
 
142
152
  act(() => {
143
- emit('annotation:requested', { selector: SVG_SELECTOR, motivation: 'assessing' });
153
+ emit('annotate:requested', { selector: SVG_SELECTOR, motivation: 'assessing' });
144
154
  });
145
155
 
146
156
  await waitFor(() => {
@@ -148,7 +158,7 @@ describe('Annotation creation clears pendingAnnotation', () => {
148
158
  });
149
159
 
150
160
  await act(async () => {
151
- emit('annotation:create', {
161
+ emit('annotate:create', {
152
162
  motivation: 'assessing',
153
163
  selector: SVG_SELECTOR,
154
164
  body: [{ type: 'TextualBody', value: 'Looks good', purpose: 'assessing' }],
@@ -164,7 +174,7 @@ describe('Annotation creation clears pendingAnnotation', () => {
164
174
  const { emit } = renderDetectionFlow(TEST_URI);
165
175
 
166
176
  act(() => {
167
- emit('annotation:requested', { selector: SVG_SELECTOR, motivation: 'assessing' });
177
+ emit('annotate:requested', { selector: SVG_SELECTOR, motivation: 'assessing' });
168
178
  });
169
179
 
170
180
  await waitFor(() => {
@@ -173,7 +183,7 @@ describe('Annotation creation clears pendingAnnotation', () => {
173
183
 
174
184
  // Empty body is valid for assessments
175
185
  await act(async () => {
176
- emit('annotation:create', {
186
+ emit('annotate:create', {
177
187
  motivation: 'assessing',
178
188
  selector: SVG_SELECTOR,
179
189
  body: [],
@@ -189,7 +199,7 @@ describe('Annotation creation clears pendingAnnotation', () => {
189
199
  const { emit } = renderDetectionFlow(TEST_URI);
190
200
 
191
201
  act(() => {
192
- emit('annotation:requested', { selector: TEXT_SELECTOR, motivation: 'commenting' });
202
+ emit('annotate:requested', { selector: TEXT_SELECTOR, motivation: 'commenting' });
193
203
  });
194
204
 
195
205
  await waitFor(() => {
@@ -197,7 +207,7 @@ describe('Annotation creation clears pendingAnnotation', () => {
197
207
  });
198
208
 
199
209
  await act(async () => {
200
- emit('annotation:create', {
210
+ emit('annotate:create', {
201
211
  motivation: 'commenting',
202
212
  selector: TEXT_SELECTOR,
203
213
  body: [{ type: 'TextualBody', value: 'Great point', purpose: 'commenting' }],
@@ -213,7 +223,7 @@ describe('Annotation creation clears pendingAnnotation', () => {
213
223
  const { emit } = renderDetectionFlow(TEST_URI);
214
224
 
215
225
  act(() => {
216
- emit('annotation:requested', { selector: SVG_SELECTOR, motivation: 'tagging' });
226
+ emit('annotate:requested', { selector: SVG_SELECTOR, motivation: 'tagging' });
217
227
  });
218
228
 
219
229
  await waitFor(() => {
@@ -221,7 +231,7 @@ describe('Annotation creation clears pendingAnnotation', () => {
221
231
  });
222
232
 
223
233
  await act(async () => {
224
- emit('annotation:create', {
234
+ emit('annotate:create', {
225
235
  motivation: 'tagging',
226
236
  selector: SVG_SELECTOR,
227
237
  body: [{ type: 'TextualBody', value: 'concept:trust', purpose: 'tagging' }],
@@ -233,20 +243,20 @@ describe('Annotation creation clears pendingAnnotation', () => {
233
243
  });
234
244
  });
235
245
 
236
- it('emits annotation:created after successful creation', async () => {
246
+ it('emits annotate:created after successful creation', async () => {
237
247
  const { emit, getEventBus } = renderDetectionFlow(TEST_URI);
238
248
 
239
249
  const createdListener = vi.fn();
240
250
  // Set listener after first render so eventBus is captured
241
251
  await waitFor(() => expect(getEventBus()).toBeDefined());
242
- const subscription = getEventBus().get('annotation:created').subscribe(createdListener);
252
+ const subscription = getEventBus().get('annotate:created').subscribe(createdListener);
243
253
 
244
254
  act(() => {
245
- emit('annotation:requested', { selector: TEXT_SELECTOR, motivation: 'linking' });
255
+ emit('annotate:requested', { selector: TEXT_SELECTOR, motivation: 'linking' });
246
256
  });
247
257
 
248
258
  await act(async () => {
249
- emit('annotation:create', {
259
+ emit('annotate:create', {
250
260
  motivation: 'linking',
251
261
  selector: TEXT_SELECTOR,
252
262
  body: [],
@@ -267,7 +277,7 @@ describe('Annotation creation clears pendingAnnotation', () => {
267
277
  const { emit } = renderDetectionFlow(TEST_URI);
268
278
 
269
279
  act(() => {
270
- emit('annotation:requested', { selector: TEXT_SELECTOR, motivation: 'linking' });
280
+ emit('annotate:requested', { selector: TEXT_SELECTOR, motivation: 'linking' });
271
281
  });
272
282
 
273
283
  await waitFor(() => {
@@ -275,7 +285,7 @@ describe('Annotation creation clears pendingAnnotation', () => {
275
285
  });
276
286
 
277
287
  await act(async () => {
278
- emit('annotation:create', {
288
+ emit('annotate:create', {
279
289
  motivation: 'linking',
280
290
  selector: TEXT_SELECTOR,
281
291
  body: [],
@@ -289,11 +299,11 @@ describe('Annotation creation clears pendingAnnotation', () => {
289
299
  });
290
300
  });
291
301
 
292
- it('clears pendingAnnotation on cancel (annotation:cancel-pending)', async () => {
302
+ it('clears pendingAnnotation on cancel (annotate:cancel-pending)', async () => {
293
303
  const { emit } = renderDetectionFlow(TEST_URI);
294
304
 
295
305
  act(() => {
296
- emit('annotation:requested', { selector: TEXT_SELECTOR, motivation: 'assessing' });
306
+ emit('annotate:requested', { selector: TEXT_SELECTOR, motivation: 'assessing' });
297
307
  });
298
308
 
299
309
  await waitFor(() => {
@@ -301,7 +311,7 @@ describe('Annotation creation clears pendingAnnotation', () => {
301
311
  });
302
312
 
303
313
  act(() => {
304
- emit('annotation:cancel-pending', undefined);
314
+ emit('annotate:cancel-pending', undefined);
305
315
  });
306
316
 
307
317
  await waitFor(() => {
@@ -4,7 +4,7 @@
4
4
  * Tests the COMPLETE annotation deletion flow with real component composition:
5
5
  * - EventBusProvider (REAL)
6
6
  * - ApiClientProvider (REAL, with MOCKED client)
7
- * - useDetectionFlow (REAL) — single registration point for useResolutionFlow
7
+ * - useAnnotationFlow (REAL) — single registration point for useResolutionFlow
8
8
  * - useEventSubscriptions (REAL)
9
9
  *
10
10
  * This test focuses on ARCHITECTURE and EVENT WIRING:
@@ -18,16 +18,26 @@
18
18
  * - useResolutionFlow called in more than one hook (causes duplicate subscriptions)
19
19
  * - Auth token missing from API calls (401 errors)
20
20
  *
21
- * ARCHITECTURE: useResolutionFlow is called ONLY in useDetectionFlow.
22
- * useDetectionFlow handles all detection state (manual annotation selection
21
+ * ARCHITECTURE: useResolutionFlow is called ONLY in useAnnotationFlow.
22
+ * useAnnotationFlow handles all detection state (manual annotation selection
23
23
  * and AI-driven SSE detection) plus all API operations via useResolutionFlow.
24
24
  */
25
25
 
26
26
  import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
27
27
  import { render, waitFor } from '@testing-library/react';
28
28
  import { act } from 'react';
29
- import { useDetectionFlow } from '../../../hooks/useDetectionFlow';
29
+ import { useAnnotationFlow } from '../../../hooks/useAnnotationFlow';
30
30
  import { EventBusProvider, useEventBus, resetEventBusForTesting } from '../../../contexts/EventBusContext';
31
+
32
+ // Mock Toast module to prevent "useToast must be used within a ToastProvider" errors
33
+ vi.mock('../../../components/Toast', () => ({
34
+ useToast: () => ({
35
+ showSuccess: vi.fn(),
36
+ showError: vi.fn(),
37
+ showInfo: vi.fn(),
38
+ showWarning: vi.fn(),
39
+ }),
40
+ }));
31
41
  import { ApiClientProvider } from '../../../contexts/ApiClientContext';
32
42
  import { AuthTokenProvider } from '../../../contexts/AuthTokenContext';
33
43
  import { SemiontApiClient } from '@semiont/api-client';
@@ -60,9 +70,9 @@ describe('Annotation Deletion - Feature Integration', () => {
60
70
 
61
71
  function TestComponent() {
62
72
  eventBusInstance = useEventBus();
63
- // useDetectionFlow is the single registration point for useResolutionFlow
64
- // (handles annotation:delete, annotation:create, detection:start, etc.)
65
- useDetectionFlow(testUri);
73
+ // useAnnotationFlow is the single registration point for useResolutionFlow
74
+ // (handles annotate:delete annotate:create annotate:detect-request, etc.)
75
+ useAnnotationFlow(testUri);
66
76
  return null;
67
77
  }
68
78
 
@@ -79,14 +89,14 @@ describe('Annotation Deletion - Feature Integration', () => {
79
89
  return {
80
90
  emitDelete: (annotationId: string) => {
81
91
  act(() => {
82
- eventBusInstance!.get('annotation:delete').next({ annotationId });
92
+ eventBusInstance!.get('annotate:delete').next({ annotationId });
83
93
  });
84
94
  },
85
95
  eventBus: eventBusInstance!,
86
96
  };
87
97
  }
88
98
 
89
- it('should call deleteAnnotation API exactly ONCE when annotation:delete event is emitted', async () => {
99
+ it('should call deleteAnnotation API exactly ONCE when annotate:deleteevent is emitted', async () => {
90
100
  const { emitDelete } = renderAnnotationFlow();
91
101
  const annotationId = 'annotation-123';
92
102
 
@@ -123,12 +133,12 @@ describe('Annotation Deletion - Feature Integration', () => {
123
133
  expect(callArgs[1].auth).toBe(accessToken(testToken));
124
134
  });
125
135
 
126
- it('should emit annotation:deleted event on successful deletion', async () => {
136
+ it('should emit annotate:deleted event on successful deletion', async () => {
127
137
  const { emitDelete, eventBus } = renderAnnotationFlow();
128
138
  const deletedListener = vi.fn();
129
139
 
130
140
  // Subscribe to success event
131
- eventBus.get('annotation:deleted').subscribe(deletedListener);
141
+ eventBus.get('annotate:deleted').subscribe(deletedListener);
132
142
 
133
143
  emitDelete('annotation-789');
134
144
 
@@ -145,7 +155,7 @@ describe('Annotation Deletion - Feature Integration', () => {
145
155
  });
146
156
  });
147
157
 
148
- it('should emit annotation:delete-failed event on API error', async () => {
158
+ it('should emit annotate:delete-failed event on API error', async () => {
149
159
  // Make API call fail
150
160
  deleteAnnotationSpy.mockRejectedValue(new Error('Network error'));
151
161
 
@@ -153,7 +163,7 @@ describe('Annotation Deletion - Feature Integration', () => {
153
163
  const failedListener = vi.fn();
154
164
 
155
165
  // Subscribe to failure event
156
- eventBus.get('annotation:delete-failed').subscribe(failedListener);
166
+ eventBus.get('annotate:delete-failed').subscribe(failedListener);
157
167
 
158
168
  emitDelete('annotation-error');
159
169
 
@@ -192,10 +202,10 @@ describe('Annotation Deletion - Feature Integration', () => {
192
202
  expect(deleteAnnotationSpy.mock.calls[1][0]).toContain('annotation-2');
193
203
  });
194
204
 
195
- it('ARCHITECTURE: useResolutionFlow is called in useDetectionFlow (single registration point)', async () => {
205
+ it('ARCHITECTURE: useResolutionFlow is called in useAnnotationFlow (single registration point)', async () => {
196
206
  /**
197
207
  * This test validates that there's only ONE event-driven deletion path:
198
- * - useDetectionFlow calls useResolutionFlow (the single registration point)
208
+ * - useAnnotationFlow calls useResolutionFlow (the single registration point)
199
209
  * - useResolutionFlow subscribes to annotation:delete
200
210
  *
201
211
  * If this test fails with 2 API calls, it means useResolutionFlow was added
@@ -219,7 +229,7 @@ describe('Annotation Deletion - Feature Integration', () => {
219
229
  * that bypassed the event bus.
220
230
  *
221
231
  * The correct pattern is event-driven only:
222
- * - UI emits annotation:delete event
232
+ * - UI emits annotate:deleteevent
223
233
  * - useResolutionFlow handles it
224
234
  * - No direct function calls
225
235
  */
@@ -8,26 +8,36 @@
8
8
  * 4. BUG: Progress modal stays visible showing "Processing: Location" indefinitely
9
9
  *
10
10
  * ROOT CAUSE:
11
- * - useDetectionFlow.ts (line 54-62): detection:complete clears `detectingMotivation` but keeps `detectionProgress`
12
- * - DetectSection.tsx (line 214): Shows progress UI whenever `detectionProgress` is not null
11
+ * - useAnnotationFlow.ts (line 54-62): annotate:assist-finished clears `assistingMotivation` but keeps `progress`
12
+ * - AssistSection.tsx (line 214): Shows progress UI whenever `progress` is not null
13
13
  * - No mechanism to auto-dismiss or manually close the progress display
14
14
  *
15
15
  * FIX OPTIONS:
16
16
  * A) Auto-dismiss after timeout (3s after completion)
17
17
  * B) Add "Close" button to progress display
18
- * C) Clear progress on next detection:start (already works but not ideal UX)
18
+ * C) Clear progress on next annotate:assist-request (already works but not ideal UX)
19
19
  */
20
20
 
21
21
  import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
22
22
  import { render, screen, waitFor } from '@testing-library/react';
23
23
  import { act } from 'react';
24
- import { useDetectionFlow } from '../../../hooks/useDetectionFlow';
24
+ import { useAnnotationFlow } from '../../../hooks/useAnnotationFlow';
25
25
  import { EventBusProvider, resetEventBusForTesting, useEventBus } from '../../../contexts/EventBusContext';
26
26
  import { ApiClientProvider } from '../../../contexts/ApiClientContext';
27
27
  import { AuthTokenProvider } from '../../../contexts/AuthTokenContext';
28
28
  import { SSEClient } from '@semiont/api-client';
29
29
  import { resourceUri } from '@semiont/core';
30
30
 
31
+ // Mock Toast module to prevent "useToast must be used within a ToastProvider" errors
32
+ vi.mock('../../../components/Toast', () => ({
33
+ useToast: () => ({
34
+ showSuccess: vi.fn(),
35
+ showError: vi.fn(),
36
+ showInfo: vi.fn(),
37
+ showWarning: vi.fn(),
38
+ }),
39
+ }));
40
+
31
41
  describe('Detection Progress Dismissal Bug', () => {
32
42
  let mockStream: any;
33
43
  const rUri = resourceUri('https://example.com/resources/test');
@@ -40,10 +50,10 @@ describe('Detection Progress Dismissal Bug', () => {
40
50
  close: vi.fn(),
41
51
  };
42
52
 
43
- vi.spyOn(SSEClient.prototype, 'detectReferences').mockReturnValue(mockStream);
44
- vi.spyOn(SSEClient.prototype, 'detectHighlights').mockReturnValue(mockStream);
45
- vi.spyOn(SSEClient.prototype, 'detectComments').mockReturnValue(mockStream);
46
- vi.spyOn(SSEClient.prototype, 'detectAssessments').mockReturnValue(mockStream);
53
+ vi.spyOn(SSEClient.prototype, 'annotateReferences').mockReturnValue(mockStream);
54
+ vi.spyOn(SSEClient.prototype, 'annotateHighlights').mockReturnValue(mockStream);
55
+ vi.spyOn(SSEClient.prototype, 'annotateComments').mockReturnValue(mockStream);
56
+ vi.spyOn(SSEClient.prototype, 'annotateAssessments').mockReturnValue(mockStream);
47
57
  });
48
58
 
49
59
  afterEach(() => {
@@ -55,13 +65,13 @@ describe('Detection Progress Dismissal Bug', () => {
55
65
 
56
66
  function TestHarness() {
57
67
  eventBusInstance = useEventBus();
58
- const { detectingMotivation, detectionProgress } = useDetectionFlow(rUri);
68
+ const { assistingMotivation, progress } = useAnnotationFlow(rUri);
59
69
 
60
70
  return (
61
71
  <div>
62
- <div data-testid="detecting">{detectingMotivation || 'none'}</div>
72
+ <div data-testid="detecting">{assistingMotivation || 'none'}</div>
63
73
  <div data-testid="progress">
64
- {detectionProgress ? detectionProgress.message || 'has progress' : 'no progress'}
74
+ {progress ? progress.message || 'has progress' : 'no progress'}
65
75
  </div>
66
76
  </div>
67
77
  );
@@ -81,9 +91,9 @@ describe('Detection Progress Dismissal Bug', () => {
81
91
  expect(screen.getByTestId('detecting')).toHaveTextContent('none');
82
92
  expect(screen.getByTestId('progress')).toHaveTextContent('no progress');
83
93
 
84
- // User clicks detect button (emits detection:start)
94
+ // User clicks detect button (emits annotate:assist-request)
85
95
  act(() => {
86
- eventBusInstance.get('detection:start').next({
96
+ eventBusInstance.get('annotate:assist-request').next({
87
97
  motivation: 'linking',
88
98
  options: { entityTypes: ['Location'] }
89
99
  });
@@ -96,7 +106,7 @@ describe('Detection Progress Dismissal Bug', () => {
96
106
 
97
107
  // SSE sends progress update
98
108
  act(() => {
99
- eventBusInstance.get('detection:progress').next({
109
+ eventBusInstance.get('annotate:progress').next({
100
110
  status: 'scanning',
101
111
  message: 'Processing: Location',
102
112
  currentEntityType: 'Location',
@@ -108,12 +118,12 @@ describe('Detection Progress Dismissal Bug', () => {
108
118
  expect(screen.getByTestId('progress')).toHaveTextContent('Processing: Location');
109
119
  });
110
120
 
111
- // Detection completes (SSE finishes, backend emits detection:complete)
121
+ // Detection completes (SSE finishes, backend emits annotate:assist-finished)
112
122
  act(() => {
113
- eventBusInstance.get('detection:complete').next({ motivation: 'linking' });
123
+ eventBusInstance.get('annotate:assist-finished').next({ motivation: 'linking' });
114
124
  });
115
125
 
116
- // detectingMotivation cleared immediately
126
+ // assistingMotivation cleared immediately
117
127
  await waitFor(() => {
118
128
  expect(screen.getByTestId('detecting')).toHaveTextContent('none');
119
129
  });
@@ -128,11 +138,11 @@ describe('Detection Progress Dismissal Bug', () => {
128
138
 
129
139
  function TestHarness() {
130
140
  eventBusInstance = useEventBus();
131
- const { detectionProgress } = useDetectionFlow(rUri);
141
+ const { progress } = useAnnotationFlow(rUri);
132
142
 
133
143
  return (
134
144
  <div data-testid="progress">
135
- {detectionProgress ? detectionProgress.message || 'has progress' : 'no progress'}
145
+ {progress ? progress.message || 'has progress' : 'no progress'}
136
146
  </div>
137
147
  );
138
148
  }
@@ -149,15 +159,15 @@ describe('Detection Progress Dismissal Bug', () => {
149
159
 
150
160
  // First detection with stuck progress
151
161
  act(() => {
152
- eventBusInstance.get('detection:start').next({ motivation: 'linking', options: {} });
162
+ eventBusInstance.get('annotate:assist-request').next({ motivation: 'linking', options: {} });
153
163
  });
154
164
 
155
165
  act(() => {
156
- eventBusInstance.get('detection:progress').next({ message: 'Old progress stuck here' });
166
+ eventBusInstance.get('annotate:progress').next({ message: 'Old progress stuck here' });
157
167
  });
158
168
 
159
169
  act(() => {
160
- eventBusInstance.get('detection:complete').next({ motivation: 'linking' });
170
+ eventBusInstance.get('annotate:assist-finished').next({ motivation: 'linking' });
161
171
  });
162
172
 
163
173
  await waitFor(() => {
@@ -166,7 +176,7 @@ describe('Detection Progress Dismissal Bug', () => {
166
176
 
167
177
  // WORKAROUND: Start new detection clears old progress
168
178
  act(() => {
169
- eventBusInstance.get('detection:start').next({ motivation: 'highlighting', options: {} });
179
+ eventBusInstance.get('annotate:assist-request').next({ motivation: 'highlighting', options: {} });
170
180
  });
171
181
 
172
182
  await waitFor(() => {
@@ -181,11 +191,11 @@ describe('Detection Progress Dismissal Bug', () => {
181
191
 
182
192
  function TestHarness() {
183
193
  eventBusInstance = useEventBus();
184
- const { detectionProgress } = useDetectionFlow(rUri);
194
+ const { progress } = useAnnotationFlow(rUri);
185
195
 
186
196
  return (
187
197
  <div data-testid="progress">
188
- {detectionProgress ? 'visible' : 'dismissed'}
198
+ {progress ? 'visible' : 'dismissed'}
189
199
  </div>
190
200
  );
191
201
  }
@@ -202,18 +212,18 @@ describe('Detection Progress Dismissal Bug', () => {
202
212
 
203
213
  // Show progress
204
214
  act(() => {
205
- eventBusInstance.get('detection:start').next({ motivation: 'linking', options: {} });
215
+ eventBusInstance.get('annotate:assist-request').next({ motivation: 'linking', options: {} });
206
216
  });
207
217
 
208
218
  act(() => {
209
- eventBusInstance.get('detection:progress').next({
219
+ eventBusInstance.get('annotate:progress').next({
210
220
  status: 'complete',
211
221
  message: 'Complete! Created 5 annotations'
212
222
  });
213
223
  });
214
224
 
215
225
  act(() => {
216
- eventBusInstance.get('detection:complete').next({ motivation: 'linking' });
226
+ eventBusInstance.get('annotate:assist-finished').next({ motivation: 'linking' });
217
227
  });
218
228
 
219
229
  // Progress visible initially
@@ -229,10 +239,10 @@ describe('Detection Progress Dismissal Bug', () => {
229
239
  });
230
240
  });
231
241
 
232
- it('FIXED: SSE emits final completion chunk data as detection:progress', async () => {
242
+ it('FIXED: SSE emits final completion chunk data as annotate:assist-progress', async () => {
233
243
  /**
234
- * This test verifies that SSE emits the final chunk as detection:progress
235
- * BEFORE emitting detection:complete.
244
+ * This test verifies that SSE emits the final chunk as annotate:assist-progress
245
+ * BEFORE emitting annotate:assist-finished.
236
246
  *
237
247
  * This ensures the UI can display the final completion message with status:'complete'.
238
248
  */
@@ -241,12 +251,12 @@ describe('Detection Progress Dismissal Bug', () => {
241
251
 
242
252
  function TestHarness() {
243
253
  eventBusInstance = useEventBus();
244
- const { detectionProgress } = useDetectionFlow(rUri);
254
+ const { progress } = useAnnotationFlow(rUri);
245
255
 
246
256
  return (
247
257
  <div>
248
- <div data-testid="progress-status">{detectionProgress?.status || 'none'}</div>
249
- <div data-testid="progress-message">{detectionProgress?.message || 'no message'}</div>
258
+ <div data-testid="progress-status">{progress?.status || 'none'}</div>
259
+ <div data-testid="progress-message">{progress?.message || 'no message'}</div>
250
260
  </div>
251
261
  );
252
262
  }
@@ -263,7 +273,7 @@ describe('Detection Progress Dismissal Bug', () => {
263
273
 
264
274
  // Start detection (triggers SSE stream creation)
265
275
  act(() => {
266
- eventBusInstance.get('detection:start').next({
276
+ eventBusInstance.get('annotate:assist-request').next({
267
277
  motivation: 'linking',
268
278
  options: { entityTypes: ['Location'] }
269
279
  });
@@ -271,7 +281,7 @@ describe('Detection Progress Dismissal Bug', () => {
271
281
 
272
282
  // Simulate SSE scanning chunk
273
283
  act(() => {
274
- eventBusInstance.get('detection:progress').next({
284
+ eventBusInstance.get('annotate:progress').next({
275
285
  status: 'scanning',
276
286
  message: 'Processing: Location',
277
287
  });
@@ -281,9 +291,9 @@ describe('Detection Progress Dismissal Bug', () => {
281
291
  expect(screen.getByTestId('progress-status')).toHaveTextContent('scanning');
282
292
  });
283
293
 
284
- // Simulate SSE emitting final chunk as detection:progress
294
+ // Simulate SSE emitting final chunk as annotate:assist-progress
285
295
  act(() => {
286
- eventBusInstance.get('detection:progress').next({
296
+ eventBusInstance.get('annotate:progress').next({
287
297
  status: 'complete',
288
298
  message: 'Complete! Found 5 entities',
289
299
  foundCount: 5,