@morscherlab/mint-sdk 1.2.0-beta.9 → 1.2.0

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 (152) hide show
  1. package/README.md +30 -0
  2. package/dist/{ExperimentPopover-oL0fg_A0.js → ExperimentPopover-CJdNlCZb.js} +21 -14
  3. package/dist/ExperimentPopover-CJdNlCZb.js.map +1 -0
  4. package/dist/{ExperimentSelectorModal-BeEOomw_.js → ExperimentSelectorModal-DCXmwKNS.js} +5 -5
  5. package/dist/{ExperimentSelectorModal-BeEOomw_.js.map → ExperimentSelectorModal-DCXmwKNS.js.map} +1 -1
  6. package/dist/{SettingsModal-Dphh3RrI.js → SettingsModal-BYR20I4c.js} +5 -5
  7. package/dist/{SettingsModal-Dphh3RrI.js.map → SettingsModal-BYR20I4c.js.map} +1 -1
  8. package/dist/{Skeleton-DxtwJ5gt.js → Skeleton-BAF3CKY7.js} +3 -3
  9. package/dist/{Skeleton-DxtwJ5gt.js.map → Skeleton-BAF3CKY7.js.map} +1 -1
  10. package/dist/__tests__/apiErrors.test.d.ts +1 -0
  11. package/dist/__tests__/components/FileBrowserModal.test.d.ts +1 -0
  12. package/dist/__tests__/components/FilePicker.state.test.d.ts +1 -0
  13. package/dist/__tests__/components/FilePicker.test.d.ts +1 -0
  14. package/dist/__tests__/components/PlotlyChart.test.d.ts +1 -0
  15. package/dist/__tests__/components/iconButtonIconSizing.test.d.ts +1 -0
  16. package/dist/__tests__/composables/useFileBrowser.test.d.ts +1 -0
  17. package/dist/__tests__/composables/usePlatformFilePickerAdapter.test.d.ts +1 -0
  18. package/dist/apiErrors.d.ts +26 -0
  19. package/dist/components/BaseInput.vue.d.ts +1 -1
  20. package/dist/components/BaseSelect.vue.d.ts +1 -1
  21. package/dist/components/BaseTextarea.vue.d.ts +1 -1
  22. package/dist/components/BioTemplateExperimentWorkspaceView.vue.d.ts +2 -2
  23. package/dist/components/BioTemplatePackWorkspaceView.vue.d.ts +2 -2
  24. package/dist/components/ConcentrationInput.vue.d.ts +1 -1
  25. package/dist/components/DatePicker.vue.d.ts +1 -1
  26. package/dist/components/DateTimePicker.vue.d.ts +1 -1
  27. package/dist/components/FileBrowserModal.vue.d.ts +99 -0
  28. package/dist/components/FilePicker.vue.d.ts +32 -0
  29. package/dist/components/FileUploader.vue.d.ts +5 -2
  30. package/dist/components/FormulaInput.vue.d.ts +1 -1
  31. package/dist/components/GeneratedPlotlyResult.vue.d.ts +1 -3
  32. package/dist/components/MobileSupportGate.vue.d.ts +1 -1
  33. package/dist/components/MoleculeInput.vue.d.ts +1 -1
  34. package/dist/components/NumberInput.vue.d.ts +1 -1
  35. package/dist/components/PlotlyChart.vue.d.ts +59 -0
  36. package/dist/components/ResourceCard.vue.d.ts +1 -1
  37. package/dist/components/SecretInput.vue.d.ts +1 -1
  38. package/dist/components/SequenceInput.vue.d.ts +1 -1
  39. package/dist/components/StatusIndicator.vue.d.ts +1 -1
  40. package/dist/components/TagsInput.vue.d.ts +1 -1
  41. package/dist/components/TimePicker.vue.d.ts +1 -1
  42. package/dist/components/TimeRangeInput.vue.d.ts +1 -1
  43. package/dist/components/UnitInput.vue.d.ts +1 -1
  44. package/dist/components/WellPlate.vue.d.ts +1 -1
  45. package/dist/components/fileBrowserPresentation.d.ts +10 -0
  46. package/dist/components/index.d.ts +4 -0
  47. package/dist/components/index.js +8 -8
  48. package/dist/components/internal/FileBrowserDialogInternal.vue.d.ts +34 -0
  49. package/dist/components/internal/FileBrowserListingInternal.vue.d.ts +25 -0
  50. package/dist/components/internal/FileBrowserToolbarInternal.vue.d.ts +26 -0
  51. package/dist/components/internal/FilePickerPreviewInternal.vue.d.ts +18 -0
  52. package/dist/components/internal/FilePickerTreeInternal.vue.d.ts +31 -0
  53. package/dist/{components-CgAUzF8F.js → components-DIum5hkx.js} +4286 -1866
  54. package/dist/components-DIum5hkx.js.map +1 -0
  55. package/dist/composables/filePicker/localFiles.d.ts +3 -0
  56. package/dist/composables/filePicker/usePickerNavigation.d.ts +96 -0
  57. package/dist/composables/filePicker/usePickerSelection.d.ts +31 -0
  58. package/dist/composables/filePicker/validation.d.ts +5 -0
  59. package/dist/composables/index.d.ts +2 -0
  60. package/dist/composables/index.js +10 -10
  61. package/dist/composables/useApi.d.ts +14 -7
  62. package/dist/composables/useFileBrowser.d.ts +55 -0
  63. package/dist/composables/useFilePicker.d.ts +189 -0
  64. package/dist/composables/usePlatformFilePickerAdapter.d.ts +11 -0
  65. package/dist/{composables-B_pia3hO.js → composables-mFXsTA4g.js} +300 -11
  66. package/dist/composables-mFXsTA4g.js.map +1 -0
  67. package/dist/{errors-_W0-LbA6.js → errors-BLuqMee5.js} +78 -15
  68. package/dist/errors-BLuqMee5.js.map +1 -0
  69. package/dist/{experiment-Cwl9AYxw.js → experiment-CVDRAnqp.js} +2 -2
  70. package/dist/{experiment-Cwl9AYxw.js.map → experiment-CVDRAnqp.js.map} +1 -1
  71. package/dist/{experiment-utils-DV3DrvE_.js → experiment-utils-CV2Wza3z.js} +1 -1
  72. package/dist/{experiment-utils-DV3DrvE_.js.map → experiment-utils-CV2Wza3z.js.map} +1 -1
  73. package/dist/index.d.ts +1 -0
  74. package/dist/index.js +15 -15
  75. package/dist/install.js +2 -2
  76. package/dist/stores/index.js +2 -2
  77. package/dist/styles.css +2369 -1377
  78. package/dist/templates/index.js +2 -2
  79. package/dist/{templates-Qq113pyZ.js → templates-CmGfmBRA.js} +2 -2
  80. package/dist/{templates-Qq113pyZ.js.map → templates-CmGfmBRA.js.map} +1 -1
  81. package/dist/types/fileBrowserTypes.d.ts +77 -0
  82. package/dist/types/filePicker.d.ts +77 -0
  83. package/dist/types/index.d.ts +2 -0
  84. package/dist/{useControlSchema-aMZlb4Sc.js → useControlSchema-DldpxNOP.js} +42 -37
  85. package/dist/useControlSchema-DldpxNOP.js.map +1 -0
  86. package/dist/{useDropdownState-DitCtrTT.js → useDropdownState-C7hRiVQf.js} +2 -2
  87. package/dist/{useDropdownState-DitCtrTT.js.map → useDropdownState-C7hRiVQf.js.map} +1 -1
  88. package/dist/{useExperimentSelector-I8HC8hUu.js → useExperimentSelector-CEcIaueJ.js} +4 -4
  89. package/dist/{useExperimentSelector-I8HC8hUu.js.map → useExperimentSelector-CEcIaueJ.js.map} +1 -1
  90. package/dist/{useFormBuilder-TCxNnqeb.js → useFormBuilder-z5L_dUIy.js} +2 -2
  91. package/dist/{useFormBuilder-TCxNnqeb.js.map → useFormBuilder-z5L_dUIy.js.map} +1 -1
  92. package/dist/{useProtocolTemplates-BmX_iVBR.js → validation-uwoJGEb6.js} +53 -8
  93. package/dist/validation-uwoJGEb6.js.map +1 -0
  94. package/package.json +1 -1
  95. package/src/__tests__/apiErrors.test.ts +81 -0
  96. package/src/__tests__/components/ExperimentPopover.test.ts +30 -0
  97. package/src/__tests__/components/FileBrowserModal.test.ts +460 -0
  98. package/src/__tests__/components/FilePicker.state.test.ts +287 -0
  99. package/src/__tests__/components/FilePicker.test.ts +487 -0
  100. package/src/__tests__/components/GeneratedPlotlyResult.test.ts +52 -5
  101. package/src/__tests__/components/PlotlyChart.test.ts +305 -0
  102. package/src/__tests__/components/SegmentedControl.test.ts +19 -0
  103. package/src/__tests__/components/iconButtonIconSizing.test.ts +18 -0
  104. package/src/__tests__/composables/useApi.test.ts +92 -9
  105. package/src/__tests__/composables/useFileBrowser.test.ts +305 -0
  106. package/src/__tests__/composables/useGeneratedAnalysis.test.ts +7 -2
  107. package/src/__tests__/composables/usePlatformFilePickerAdapter.test.ts +67 -0
  108. package/src/__tests__/composables/usePluginClient.test.ts +3 -0
  109. package/src/apiErrors.ts +85 -0
  110. package/src/components/ExperimentPopover.vue +10 -2
  111. package/src/components/FileBrowserModal.story.vue +203 -0
  112. package/src/components/FileBrowserModal.vue +384 -0
  113. package/src/components/FilePicker.story.vue +44 -0
  114. package/src/components/FilePicker.vue +284 -0
  115. package/src/components/FileUploader.vue +32 -14
  116. package/src/components/GeneratedPlotlyResult.vue +34 -69
  117. package/src/components/GeneratedResultRenderer.vue +0 -5
  118. package/src/components/PlotlyChart.story.vue +61 -0
  119. package/src/components/PlotlyChart.vue +233 -0
  120. package/src/components/SegmentedControl.vue +2 -2
  121. package/src/components/fileBrowserPresentation.ts +39 -0
  122. package/src/components/index.ts +5 -0
  123. package/src/components/internal/FileBrowserDialogInternal.vue +75 -0
  124. package/src/components/internal/FileBrowserListingInternal.vue +197 -0
  125. package/src/components/internal/FileBrowserToolbarInternal.vue +136 -0
  126. package/src/components/internal/FilePickerPreviewInternal.vue +100 -0
  127. package/src/components/internal/FilePickerTreeInternal.vue +238 -0
  128. package/src/composables/filePicker/localFiles.ts +58 -0
  129. package/src/composables/filePicker/usePickerNavigation.ts +220 -0
  130. package/src/composables/filePicker/usePickerSelection.ts +259 -0
  131. package/src/composables/filePicker/validation.ts +41 -0
  132. package/src/composables/index.ts +7 -0
  133. package/src/composables/useApi.ts +57 -13
  134. package/src/composables/useFileBrowser.ts +314 -0
  135. package/src/composables/useFilePicker.ts +366 -0
  136. package/src/composables/useGeneratedAnalysis.ts +10 -17
  137. package/src/composables/usePlatformFilePickerAdapter.ts +104 -0
  138. package/src/composables/usePluginClient.ts +3 -0
  139. package/src/index.ts +3 -0
  140. package/src/styles/components/file-browser-modal.css +489 -0
  141. package/src/styles/components/file-picker.css +502 -0
  142. package/src/styles/components/icon-button.css +9 -0
  143. package/src/styles/index.css +3 -0
  144. package/src/types/fileBrowserTypes.ts +85 -0
  145. package/src/types/filePicker.ts +72 -0
  146. package/src/types/index.ts +14 -0
  147. package/dist/ExperimentPopover-oL0fg_A0.js.map +0 -1
  148. package/dist/components-CgAUzF8F.js.map +0 -1
  149. package/dist/composables-B_pia3hO.js.map +0 -1
  150. package/dist/errors-_W0-LbA6.js.map +0 -1
  151. package/dist/useControlSchema-aMZlb4Sc.js.map +0 -1
  152. package/dist/useProtocolTemplates-BmX_iVBR.js.map +0 -1
@@ -0,0 +1,305 @@
1
+ import { describe, expect, it, vi, beforeEach } from 'vitest'
2
+
3
+ const mockGet = vi.fn()
4
+ vi.mock('../../composables/useApi', () => ({
5
+ useApi: () => ({ get: mockGet }),
6
+ }))
7
+
8
+ import { effectScope, nextTick, ref } from 'vue'
9
+
10
+ import { useFileBrowser } from '../../composables/useFileBrowser'
11
+
12
+ const MOUNTS = {
13
+ mounts: [
14
+ { id: 'seq', label: '/mnt/sequencer-01', available: false },
15
+ { id: 'qe', label: '/mnt/instrument-qe', available: true },
16
+ ],
17
+ }
18
+
19
+ const LISTING = {
20
+ mount_id: 'qe',
21
+ path: 'raw',
22
+ parent: '',
23
+ breadcrumbs: [{ label: '/mnt/instrument-qe', path: '' }, { label: 'raw', path: 'raw' }],
24
+ entries: [
25
+ { name: 'blanks', path: 'raw/blanks', kind: 'directory', child_count: 6 },
26
+ { name: 'a.raw', path: 'raw/a.raw', kind: 'file', size_bytes: 10, extension: '.raw' },
27
+ ],
28
+ total_count: 2,
29
+ match_count: 1,
30
+ }
31
+
32
+ beforeEach(() => {
33
+ mockGet.mockReset()
34
+ })
35
+
36
+ describe('useFileBrowser', () => {
37
+ it('should load the configured mounts', async () => {
38
+ mockGet.mockResolvedValueOnce(MOUNTS).mockResolvedValueOnce(LISTING)
39
+ const browser = useFileBrowser()
40
+ await browser.init()
41
+
42
+ expect(browser.mounts.value.map(m => m.id)).toEqual(['seq', 'qe'])
43
+ })
44
+
45
+ // An offline mount must not be the one we open on.
46
+ it('should open the first available mount', async () => {
47
+ mockGet.mockResolvedValueOnce(MOUNTS).mockResolvedValueOnce(LISTING)
48
+ const browser = useFileBrowser()
49
+ await browser.init()
50
+
51
+ expect(mockGet.mock.calls[1][0]).toContain('mount_id=qe')
52
+ })
53
+
54
+ // 'nas' is listed after 'qe', so choosing it proves the preference is honoured
55
+ // rather than the first-available fallback happening to win.
56
+ it('should honour an explicit initial mount when it is reachable', async () => {
57
+ mockGet
58
+ .mockResolvedValueOnce({ mounts: [...MOUNTS.mounts, { id: 'nas', label: '/mnt/nas', available: true }] })
59
+ .mockResolvedValueOnce(LISTING)
60
+ const browser = useFileBrowser({ initialMountId: 'nas' })
61
+ await browser.init()
62
+
63
+ expect(mockGet.mock.calls[1][0]).toContain('mount_id=nas')
64
+ })
65
+
66
+ it('should expose the listing entries', async () => {
67
+ mockGet.mockResolvedValue(LISTING)
68
+ const browser = useFileBrowser()
69
+ await browser.navigate({ mount_id: 'qe', path: 'raw' })
70
+
71
+ expect(browser.entries.value.map(e => e.name)).toEqual(['blanks', 'a.raw'])
72
+ })
73
+
74
+ it('should expose the breadcrumb trail', async () => {
75
+ mockGet.mockResolvedValue(LISTING)
76
+ const browser = useFileBrowser()
77
+ await browser.navigate({ mount_id: 'qe', path: 'raw' })
78
+
79
+ expect(browser.breadcrumbs.value.map(c => c.label)).toEqual(['/mnt/instrument-qe', 'raw'])
80
+ })
81
+
82
+ it('should send the configured type rules', async () => {
83
+ mockGet.mockResolvedValue(LISTING)
84
+ const browser = useFileBrowser({ typeRules: ['.raw', '.mzML'] })
85
+ await browser.navigate({ mount_id: 'qe', path: 'raw' })
86
+
87
+ expect(mockGet.mock.calls[0][0]).toContain('type_rules=.raw&type_rules=.mzML')
88
+ })
89
+
90
+ it('should surface a listing failure', async () => {
91
+ mockGet.mockRejectedValue(new Error('Mount is offline'))
92
+ const browser = useFileBrowser()
93
+ await browser.navigate({ mount_id: 'qe', path: 'raw' })
94
+
95
+ expect(browser.error.value).toContain('Mount is offline')
96
+ })
97
+
98
+ it('should empty the listing when a request fails', async () => {
99
+ mockGet.mockRejectedValue(new Error('nope'))
100
+ const browser = useFileBrowser()
101
+ await browser.navigate({ mount_id: 'qe', path: 'raw' })
102
+
103
+ expect(browser.entries.value).toEqual([])
104
+ })
105
+
106
+ // A slow response for the folder you left must not overwrite the one you are in.
107
+ it('should ignore a superseded listing response', async () => {
108
+ let resolveSlow: (value: unknown) => void = () => {}
109
+ const slow = new Promise(resolve => { resolveSlow = resolve })
110
+ mockGet.mockReturnValueOnce(slow).mockResolvedValueOnce(LISTING)
111
+
112
+ const browser = useFileBrowser()
113
+ const first = browser.navigate({ mount_id: 'qe', path: 'stale' })
114
+ await browser.navigate({ mount_id: 'qe', path: 'raw' })
115
+ resolveSlow({ ...LISTING, path: 'stale', entries: [] })
116
+ await first
117
+
118
+ expect(browser.path.value).toBe('raw')
119
+ })
120
+
121
+ it('should take the current folder into the selection', async () => {
122
+ mockGet.mockResolvedValue(LISTING)
123
+ const browser = useFileBrowser()
124
+ await browser.navigate({ mount_id: 'qe', path: 'raw' })
125
+ browser.selectCurrentFolder()
126
+
127
+ expect(browser.selected.value).toMatchObject([{ mount_id: 'qe', path: 'raw', kind: 'directory' }])
128
+ })
129
+
130
+ it('should not take the same folder twice', async () => {
131
+ mockGet.mockResolvedValue(LISTING)
132
+ const browser = useFileBrowser()
133
+ await browser.navigate({ mount_id: 'qe', path: 'raw' })
134
+ browser.selectCurrentFolder()
135
+ browser.selectCurrentFolder()
136
+
137
+ expect(browser.selected.value).toHaveLength(1)
138
+ })
139
+
140
+ it('should clear the selection', async () => {
141
+ mockGet.mockResolvedValue(LISTING)
142
+ const browser = useFileBrowser()
143
+ await browser.navigate({ mount_id: 'qe', path: 'raw' })
144
+ browser.selectCurrentFolder()
145
+ browser.clear()
146
+
147
+ expect(browser.selected.value).toEqual([])
148
+ })
149
+
150
+ it('should report the unfiltered total count', async () => {
151
+ mockGet.mockResolvedValue(LISTING)
152
+ const browser = useFileBrowser()
153
+ await browser.navigate({ mount_id: 'qe', path: 'raw' })
154
+
155
+ expect(browser.totalCount.value).toBe(2)
156
+ })
157
+
158
+ it('should not be loading once a request settles', async () => {
159
+ mockGet.mockResolvedValue(LISTING)
160
+ const browser = useFileBrowser()
161
+ await browser.navigate({ mount_id: 'qe', path: 'raw' })
162
+
163
+ expect(browser.isLoading.value).toBe(false)
164
+ })
165
+ })
166
+
167
+ describe('useFileBrowser review fixes', () => {
168
+ it('should skip an offline mount even when named as the initial one', async () => {
169
+ mockGet.mockResolvedValueOnce(MOUNTS).mockResolvedValueOnce(LISTING)
170
+ const browser = useFileBrowser({ initialMountId: 'seq' })
171
+ await browser.init()
172
+
173
+ expect(mockGet.mock.calls[1][0]).toContain('mount_id=qe')
174
+ })
175
+
176
+ // No configured mounts means the routes are absent, not that browsing failed.
177
+ it('should treat a 404 mount list as no mounts configured', async () => {
178
+ mockGet.mockRejectedValue({ response: { status: 404 } })
179
+ const browser = useFileBrowser()
180
+ await browser.init()
181
+
182
+ expect(browser.error.value).toBeNull()
183
+ })
184
+
185
+ it('should leave the mount list empty when none are configured', async () => {
186
+ mockGet.mockRejectedValue({ response: { status: 404 } })
187
+ const browser = useFileBrowser()
188
+ await browser.init()
189
+
190
+ expect(browser.mounts.value).toEqual([])
191
+ })
192
+
193
+ it('should surface the API error detail rather than the status code', async () => {
194
+ mockGet.mockRejectedValue({
195
+ response: { status: 404, data: { detail: "Mount 'nas' is not available" } },
196
+ message: 'Request failed with status code 404',
197
+ })
198
+ const browser = useFileBrowser()
199
+ await browser.navigate({ mount_id: 'nas', path: '' })
200
+
201
+ expect(browser.error.value).toBe("Mount 'nas' is not available")
202
+ })
203
+
204
+ it('should refetch when the sort changes', async () => {
205
+ mockGet.mockResolvedValue(LISTING)
206
+ const browser = useFileBrowser()
207
+ await browser.navigate({ mount_id: 'qe', path: 'raw' })
208
+ const before = mockGet.mock.calls.length
209
+ browser.sort.value = 'size'
210
+ await new Promise(resolve => setTimeout(resolve, 0))
211
+
212
+ expect(mockGet.mock.calls.length).toBeGreaterThan(before)
213
+ })
214
+
215
+ it('should refetch when the search changes', async () => {
216
+ mockGet.mockResolvedValue(LISTING)
217
+ const browser = useFileBrowser()
218
+ await browser.navigate({ mount_id: 'qe', path: 'raw' })
219
+ const before = mockGet.mock.calls.length
220
+ browser.search.value = 'hela'
221
+ await new Promise(resolve => setTimeout(resolve, 400))
222
+
223
+ expect(mockGet.mock.calls.length).toBeGreaterThan(before)
224
+ })
225
+
226
+ it('should expose how many rows the listing carries', async () => {
227
+ mockGet.mockResolvedValue({ ...LISTING, shown_count: 2 })
228
+ const browser = useFileBrowser()
229
+ await browser.navigate({ mount_id: 'qe', path: 'raw' })
230
+
231
+ expect(browser.shownCount.value).toBe(2)
232
+ })
233
+
234
+ it('should expose a truncated listing', async () => {
235
+ mockGet.mockResolvedValue({ ...LISTING, truncated: true })
236
+ const browser = useFileBrowser()
237
+ await browser.navigate({ mount_id: 'qe', path: 'raw' })
238
+
239
+ expect(browser.truncated.value).toBe(true)
240
+ })
241
+ })
242
+
243
+
244
+ describe('useFileBrowser selection and request lifecycle', () => {
245
+ it('never selects an uninitialized or failed directory', async () => {
246
+ const browser = useFileBrowser()
247
+ browser.selectCurrentFolder()
248
+ expect(browser.selected.value).toEqual([])
249
+ mockGet.mockRejectedValueOnce(new Error('offline'))
250
+ await browser.navigate({ mount_id: 'nas', path: 'runs' })
251
+ browser.selectCurrentFolder()
252
+ expect(browser.selected.value).toEqual([])
253
+ })
254
+
255
+ it('retries the failed destination rather than returning to the previous folder', async () => {
256
+ mockGet.mockResolvedValueOnce(LISTING).mockRejectedValueOnce(new Error('offline')).mockResolvedValueOnce({ ...LISTING, path: 'new' })
257
+ const browser = useFileBrowser()
258
+ await browser.navigate({ mount_id: 'qe', path: 'raw' })
259
+ await browser.navigate({ mount_id: 'qe', path: 'new' })
260
+ await browser.refresh()
261
+ expect(mockGet.mock.calls.at(-1)?.[0]).toContain('path=new')
262
+ })
263
+
264
+ it('does not let obsolete requests keep the current directory loading', async () => {
265
+ let finish!: (value: unknown) => void
266
+ mockGet.mockReturnValueOnce(new Promise(resolve => { finish = resolve })).mockResolvedValueOnce(LISTING)
267
+ const browser = useFileBrowser()
268
+ const old = browser.navigate({ mount_id: 'qe', path: 'old' })
269
+ await browser.navigate({ mount_id: 'qe', path: 'raw' })
270
+ expect(browser.isLoading.value).toBe(false)
271
+ finish(LISTING)
272
+ await old
273
+ })
274
+
275
+ it('refreshes when reactive type rules change', async () => {
276
+ mockGet.mockResolvedValue(LISTING)
277
+ const typeRules = ref(['.raw'])
278
+ const scope = effectScope()
279
+ const browser = scope.run(() => useFileBrowser({ typeRules }))!
280
+ await browser.navigate({ mount_id: 'qe', path: 'raw' })
281
+ typeRules.value = ['.mzML']
282
+ await nextTick()
283
+ expect(mockGet.mock.calls.at(-1)?.[0]).toContain('type_rules=.mzML')
284
+ scope.stop()
285
+ })
286
+
287
+ it('disposes a pending search without issuing another request', async () => {
288
+ vi.useFakeTimers()
289
+ const scope = effectScope()
290
+ try {
291
+ mockGet.mockResolvedValue(LISTING)
292
+ const browser = scope.run(() => useFileBrowser())!
293
+ await browser.navigate({ mount_id: 'qe', path: 'raw' })
294
+ browser.search.value = 'abc'
295
+ await nextTick()
296
+ const calls = mockGet.mock.calls.length
297
+ scope.stop()
298
+ await vi.advanceTimersByTimeAsync(300)
299
+ expect(mockGet).toHaveBeenCalledTimes(calls)
300
+ } finally {
301
+ scope.stop()
302
+ vi.useRealTimers()
303
+ }
304
+ })
305
+ })
@@ -2,6 +2,7 @@ import { effectScope } from 'vue'
2
2
  import { describe, expect, it, vi } from 'vitest'
3
3
 
4
4
  import { useGeneratedAnalysis } from '../../composables/useGeneratedAnalysis'
5
+ import { MintApiError } from '../../apiErrors'
5
6
  import {
6
7
  createGeneratedAnalysisTransport,
7
8
  type GeneratedAnalysisTransport,
@@ -701,7 +702,10 @@ describe('useGeneratedAnalysis', () => {
701
702
  ])
702
703
  })
703
704
 
704
- it('should recreate an expired session and retry one job with the same request id', async () => {
705
+ it.each([
706
+ { detail: 'Session not found' },
707
+ { code: 'resource.not_found', message: 'Session not found', request_id: 'session-request' },
708
+ ])('should recreate an expired session and retry one job with the same request id (%j)', async (errorBody) => {
705
709
  const storage = memoryStorage()
706
710
  const createId = vi.fn()
707
711
  .mockReturnValueOnce('tab-1')
@@ -713,7 +717,7 @@ describe('useGeneratedAnalysis', () => {
713
717
  id: 'session-1', tab_id: 'tab-1', created_at: '', last_seen_at: '', active_job_ids: [],
714
718
  }))
715
719
  .mockResolvedValueOnce(response({ jobs: [] }))
716
- .mockResolvedValueOnce(response({ detail: 'Session not found' }, 404))
720
+ .mockResolvedValueOnce(response(errorBody, 404))
717
721
  .mockResolvedValueOnce(response({ sessions: [] }))
718
722
  .mockResolvedValueOnce(response({
719
723
  id: 'session-2', tab_id: 'tab-1', created_at: '', last_seen_at: '', active_job_ids: [],
@@ -796,6 +800,7 @@ describe('useGeneratedAnalysis', () => {
796
800
  scope.stop()
797
801
  }
798
802
 
803
+ expect(caught).toBeInstanceOf(MintApiError)
799
804
  expect({
800
805
  status: (caught as { status?: number } | undefined)?.status,
801
806
  message: caught instanceof Error ? caught.message : null,
@@ -0,0 +1,67 @@
1
+ import { beforeEach, expect, it, vi } from 'vitest'
2
+ const { get } = vi.hoisted(() => ({ get: vi.fn() }))
3
+ vi.mock('../../composables/useApi', () => ({ useApi: () => ({ get }) }))
4
+ import {
5
+ decodePlatformPickerPath,
6
+ encodePlatformPickerPath,
7
+ usePlatformFilePickerAdapter,
8
+ } from '../../composables/usePlatformFilePickerAdapter'
9
+
10
+ beforeEach(() => get.mockReset())
11
+ it('preserves mount and relative path identities with punctuation and Unicode', () => {
12
+ const path = '测试/one, [2] # ?.raw'
13
+ expect(decodePlatformPickerPath(encodePlatformPickerPath('instrument', path))).toEqual({
14
+ mountId: 'instrument',
15
+ path,
16
+ })
17
+ expect(() => decodePlatformPickerPath('["mount"]')).toThrow()
18
+ expect(() => decodePlatformPickerPath('["", "file"]')).toThrow()
19
+ })
20
+ it('passes cancellation, marks offline mounts, and maps compound extensions', async () => {
21
+ get
22
+ .mockResolvedValueOnce({
23
+ mounts: [
24
+ { id: 'online', label: 'Instrument', available: true },
25
+ { id: 'offline', label: 'NAS', available: false },
26
+ ],
27
+ })
28
+ .mockResolvedValueOnce({
29
+ entries: [{ kind: 'file', path: 'run.mzML.gz', name: 'run.mzML.gz', size_bytes: 7 }],
30
+ })
31
+ const adapter = usePlatformFilePickerAdapter({ apiBaseUrl: '/api' })
32
+ const signal = new AbortController().signal
33
+ const roots = await adapter.listRoot({ signal })
34
+ expect(roots[1]?.unavailableReason).toContain('offline')
35
+ const files = await adapter.listChildren(roots[0]!.path, { signal })
36
+ expect(files[0]).toMatchObject({
37
+ kind: 'file',
38
+ format: 'mzML.gz',
39
+ bytes: 7,
40
+ parentPath: roots[0]!.path,
41
+ })
42
+ expect(get.mock.calls.every((call) => call[1].signal === signal)).toBe(true)
43
+ })
44
+ it('refuses truncated listings rather than returning a partial folder selection', async () => {
45
+ get.mockResolvedValue({ truncated: true, entries: [] })
46
+ await expect(
47
+ usePlatformFilePickerAdapter({ apiBaseUrl: '/api' }).listChildren(
48
+ encodePlatformPickerPath('a'),
49
+ ),
50
+ ).rejects.toThrow('listing limit')
51
+ })
52
+ it('scopes shallow search to one level and recursive search skips offline mounts', async () => {
53
+ get.mockImplementation(async (url: string) =>
54
+ url === '/filesystem/mounts'
55
+ ? {
56
+ mounts: [
57
+ { id: 'a', label: 'Instrument', available: true },
58
+ { id: 'b', label: 'NAS', available: false },
59
+ ],
60
+ }
61
+ : { entries: [{ kind: 'file', path: 'run.raw', name: 'run.raw', size_bytes: 1 }] },
62
+ )
63
+ const adapter = usePlatformFilePickerAdapter({ apiBaseUrl: '/api' })
64
+ expect(await adapter.search('run', { path: '', recursive: false })).toEqual([])
65
+ expect(await adapter.search('run', { path: '', recursive: true })).toHaveLength(1)
66
+ expect(get.mock.calls.filter((call) => call[0].includes('/browse'))).toHaveLength(1)
67
+ })
@@ -184,6 +184,7 @@ describe('usePluginClient', () => {
184
184
 
185
185
  expect(requestConfigs[0]!.baseURL).toBe('/api/drp')
186
186
  expect(requestConfigs[0]!.url).toBe('/health')
187
+ expect(requestConfigs[0]).toMatchObject({ _mintTypedErrors: true })
187
188
  })
188
189
 
189
190
  it('omits MINT auth transport for a public generated endpoint', async () => {
@@ -396,6 +397,7 @@ describe('usePluginClient', () => {
396
397
  expect(requestConfigs[0]!.url).toBe('/schedule/import')
397
398
  expect(requestConfigs[0]!.params).toEqual({ instrument_id: 'orbitrap', mode: 'replace' })
398
399
  expect(requestConfigs[0]!.headers).toEqual({ 'Content-Type': undefined })
400
+ expect(requestConfigs[0]).toMatchObject({ _mintTypedErrors: true })
399
401
  expect(requestBodies[0]).toBeInstanceOf(FormData)
400
402
  const form = requestBodies[0] as FormData
401
403
  expect(form.get('file')).toBeInstanceOf(Blob)
@@ -462,6 +464,7 @@ describe('usePluginClient', () => {
462
464
  expect(requestConfigs[0]!.url).toBe('/schedule/export')
463
465
  expect(requestConfigs[0]!.params).toEqual({ instrument_id: 'orbitrap', start: '2026-05-27' })
464
466
  expect(requestConfigs[0]!.responseType).toBe('blob')
467
+ expect(requestConfigs[0]).toMatchObject({ _mintTypedErrors: true })
465
468
  })
466
469
 
467
470
  it('downloads generated POST endpoint blobs with the contract body and request options', async () => {
@@ -0,0 +1,85 @@
1
+ export interface MintApiErrorEnvelope {
2
+ code: string
3
+ message: string
4
+ status: number
5
+ request_id: string | null
6
+ details: unknown
7
+ detail?: unknown
8
+ }
9
+
10
+ const STATUS_MESSAGES: Readonly<Record<number, string>> = {
11
+ 400: 'Bad request',
12
+ 401: 'Authentication required',
13
+ 403: 'Permission denied',
14
+ 404: 'Resource not found',
15
+ 405: 'Method not allowed',
16
+ 409: 'Conflict',
17
+ 413: 'Payload too large',
18
+ 415: 'Unsupported media type',
19
+ 422: 'Validation error',
20
+ 429: 'Rate limit exceeded',
21
+ 500: 'Internal server error',
22
+ 502: 'Bad gateway',
23
+ 503: 'Service unavailable',
24
+ }
25
+
26
+ function asRecord(value: unknown): Record<string, unknown> | null {
27
+ if (!value || typeof value !== 'object' || Array.isArray(value)) return null
28
+ return value as Record<string, unknown>
29
+ }
30
+
31
+ /** Public error thrown by typed MINT SDK requests. */
32
+ export class MintApiError extends Error {
33
+ override readonly name: string = 'MintApiError'
34
+
35
+ constructor(
36
+ message: string,
37
+ readonly code: string,
38
+ readonly status: number,
39
+ readonly requestId: string | null,
40
+ readonly details: unknown,
41
+ readonly detail: unknown,
42
+ readonly body: unknown,
43
+ readonly cause?: unknown,
44
+ ) {
45
+ super(message)
46
+ }
47
+ }
48
+
49
+ export interface MintApiErrorOptions {
50
+ requestId?: string | null
51
+ cause?: unknown
52
+ }
53
+
54
+ /** Normalize current typed envelopes and the previous FastAPI detail shape. */
55
+ export function mintApiErrorFromResponse(
56
+ status: number,
57
+ payload: unknown,
58
+ options: MintApiErrorOptions = {},
59
+ ): MintApiError {
60
+ const body = asRecord(payload)
61
+ const legacyDetail = body?.detail
62
+ const inner = asRecord(legacyDetail) ?? body
63
+ const text = (value: unknown): string | undefined =>
64
+ typeof value === 'string' && value ? value : undefined
65
+ // Complete envelopes own the public code; older wrappers defer to the plugin payload.
66
+ const canonical = typeof body?.status === 'number' && text(body.code) && text(body.message)
67
+ const code = (canonical ? text(body.code) : text(inner?.error) ?? text(inner?.code))
68
+ ?? text(body?.code) ?? 'unknown'
69
+ const message = (canonical ? text(body.message) : text(inner?.message))
70
+ ?? text(body?.message) ?? text(legacyDetail)
71
+ ?? STATUS_MESSAGES[status] ?? `HTTP ${status}`
72
+ const details = body?.details ?? inner?.details ?? null
73
+ const requestId = text(body?.request_id) ?? text(inner?.request_id) ?? options.requestId ?? null
74
+
75
+ return new MintApiError(
76
+ message,
77
+ code,
78
+ status,
79
+ requestId,
80
+ details,
81
+ legacyDetail,
82
+ payload,
83
+ options.cause,
84
+ )
85
+ }
@@ -63,6 +63,14 @@ const { isOpen, rootRef: popoverRef, triggerRef, close, toggle } = useDropdownSt
63
63
  const showSuccess = ref(false)
64
64
  const showConfirm = ref(false)
65
65
 
66
+ function handleTriggerClick() {
67
+ if (!hasExperiment.value && !isUnresolved.value) {
68
+ handleSelect()
69
+ return
70
+ }
71
+ toggle()
72
+ }
73
+
66
74
  function handleSelect() {
67
75
  emit('select')
68
76
  close()
@@ -115,7 +123,7 @@ onUnmounted(() => {
115
123
  { 'mint-experiment-popover__split--with-save': showSave && experimentName },
116
124
  ]"
117
125
  >
118
- <!-- Left: experiment trigger (opens popover). Prefer the human-readable
126
+ <!-- Left: experiment trigger (selects when empty, otherwise opens popover). Prefer the human-readable
119
127
  name; the formal code, when present, stays in the detail panel. -->
120
128
  <button
121
129
  ref="triggerRef"
@@ -131,7 +139,7 @@ onUnmounted(() => {
131
139
  :aria-label="isUnresolved ? triggerLabel : undefined"
132
140
  :aria-busy="isResolving || undefined"
133
141
  :aria-expanded="isOpen"
134
- @click.stop="toggle"
142
+ @click.stop="handleTriggerClick"
135
143
  >
136
144
  <!-- Flask icon -->
137
145
  <svg class="mint-experiment-popover__trigger-icon" aria-hidden="true" fill="none" stroke="currentColor" viewBox="0 0 24 24">