@antelopejs/dms-automation 0.3.1 → 0.4.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.
@@ -1,5 +1,5 @@
1
1
  <script setup lang="ts">
2
- import { computed, nextTick, onBeforeUnmount, onMounted, ref, watch } from 'vue'
2
+ import { computed, nextTick, onBeforeUnmount, onMounted, ref, type Ref, watch } from 'vue'
3
3
  import { type RunDetail, type TraceStep, useAutomationRuns } from '../composables/useAutomationRuns'
4
4
  import type { NodeRunState } from './Editor/nodes/GenericNode.vue'
5
5
  import type { DockIssue, DockRun, DockTab } from './Editor/BottomDock.vue'
@@ -123,42 +123,39 @@ const running = ref(false)
123
123
  const templatePorts = ref<GroupPort[]>([])
124
124
  // Kept as loaded: saving the template from the editor must not reset its icon.
125
125
  const templateIcon = ref<string>('i-ph-package')
126
- const templateLoadKey = ref<string | null>(null)
127
126
 
128
- const triggerTypes = ref<TriggerType[]>([])
129
- const actionTypes = ref<ActionType[]>([])
130
- const dataNodeTypes = ref<DataNodeType[]>([])
127
+ // The palette's catalogs, read with the page. They are optional for
128
+ // editing: one the server cannot answer is an empty list.
129
+ const triggerTypesRead = useApiData<TriggerType[]>('/api/automation/trigger-types')
130
+ const actionTypesRead = useApiData<ActionType[]>('/api/automation/action-types')
131
+ const dataNodeTypesRead = useApiData<DataNodeType[]>('/api/automation/data-node-types')
131
132
  // Per-NodeKind UI metadata served by the backend
132
133
  // (`/api/automation/node-kinds`). Drives the editor's GenericNode renderer
133
134
  // so the frontend doesn't need to know about specific kinds.
134
- const nodeKinds = ref<NodeKindEntry[]>([])
135
-
136
- // Workspace-global templates surfaced in the canvas's node palette.
137
- // Fetched once on mount alongside the type catalogs. Empty list → palette
138
- // section hidden (handled inside BuilderPalette).
135
+ const nodeKindsRead = useAutomationNodeKinds()
136
+ const triggerTypes = computed(() => triggerTypesRead.data.value ?? [])
137
+ const actionTypes = computed(() => actionTypesRead.data.value ?? [])
138
+ const dataNodeTypes = computed(() => dataNodeTypesRead.data.value ?? [])
139
+ const nodeKinds = computed(() => nodeKindsRead.data.value ?? [])
140
+
141
+ // Workspace-global templates surfaced in the canvas's node palette. Empty
142
+ // list → palette section hidden (handled inside BuilderPalette).
139
143
  //
140
- // Only the fields the palette + template-instance creation need are kept on
141
- // the client (id, name, icon, ports). The list endpoint still returns full
142
- // rows (description, usageCount, hydrated subgraph); the `.map()` below
143
- // simply discards the extra fields after the fetch.
144
- const templates = ref<TemplateSummary[]>([])
145
- const templatesLoadError = ref<string | null>(null)
146
-
147
- async function loadTemplates() {
148
- try {
149
- const { results } = await $authFetch<{ results: TemplateSummary[] }>('/api/automation/templates')
150
- templates.value = results.map((t) => ({
144
+ // Only the fields the palette + template-instance creation need are kept,
145
+ // and handed over with the page: the list endpoint also returns the
146
+ // description, the usage count and the hydrated subgraph. Under a key of its
147
+ // own, apart from the library's full rows of the same URL.
148
+ const templatesRead = useApiData<TemplateSummary[]>('/api/automation/templates', {
149
+ key: 'dms-automation-palette-templates',
150
+ transform: (value) =>
151
+ (value as { results: TemplateSummary[] }).results.map((t) => ({
151
152
  _id: t._id,
152
153
  name: t.name,
153
154
  icon: t.icon,
154
155
  ports: Array.isArray(t.ports) ? t.ports : [],
155
- }))
156
- templatesLoadError.value = null
157
- } catch (e) {
158
- templatesLoadError.value = describeApiError(e)
159
- templates.value = []
160
- }
161
- }
156
+ })),
157
+ })
158
+ const templates = computed(() => templatesRead.data.value ?? [])
162
159
 
163
160
  // Hide the palette section while editing a template (self-edit). The
164
161
  // server's cycle check would still catch any reference cycle, but blocking
@@ -333,56 +330,25 @@ function initHistoryAndSaved() {
333
330
 
334
331
  const PROCEDURES_PAGE_SIZE = 200
335
332
 
336
- async function loadList() {
337
- loading.value = true
338
- loadError.value = null
339
- try {
333
+ // What the builder opens, read with the page: every procedure, or the
334
+ // template `?template=` names. The editor works on its own copy of what they
335
+ // answered (`procedures`), which its drafts change.
336
+ const procedureListRead = useApiData<ProcedureRecord[]>(
337
+ () => (editorMode.value === 'procedure' ? 'dms-automation-builder-procedures' : null),
338
+ async ({ $authFetch, signal }) => {
340
339
  // The API serves pages of PROCEDURES_PAGE_SIZE at most: read them all.
341
340
  const list: ProcedureRecord[] = []
342
341
  for (let page = 0; ; page++) {
343
342
  const { results } = await $authFetch<{ results: ProcedureRecord[] }>(
344
343
  `/api/automation/procedures?limit=${PROCEDURES_PAGE_SIZE}&page=${page}`,
344
+ { signal },
345
345
  )
346
346
  list.push(...results)
347
347
  if (results.length < PROCEDURES_PAGE_SIZE) break
348
348
  }
349
- procedures.value = list
350
- if (
351
- selectedId.value &&
352
- !procedures.value.some((p) => p._id === selectedId.value)
353
- ) {
354
- selectedId.value = null
355
- }
356
- const requested = queryValue('selected')
357
- if (requested && procedures.value.some((p) => p._id === requested)) {
358
- selectedId.value = requested
359
- } else if (requested && !selectedId.value) {
360
- // A link to a deleted procedure opens none: the builder says so
361
- // and offers the switcher (see onMounted).
362
- missingProcedureId.value = requested
363
- return
364
- }
365
- if (!selectedId.value && procedures.value.length > 0) {
366
- const first = procedures.value[0]
367
- selectedId.value = first ? first._id : null
368
- }
369
- } catch (e) {
370
- loadError.value = describeApiError(e)
371
- } finally {
372
- loading.value = false
373
- }
374
- }
375
-
376
- async function loadTypeCatalogs() {
377
- try {
378
- triggerTypes.value = await $authFetch<TriggerType[]>('/api/automation/trigger-types')
379
- actionTypes.value = await $authFetch<ActionType[]>('/api/automation/action-types')
380
- dataNodeTypes.value = await $authFetch<DataNodeType[]>('/api/automation/data-node-types')
381
- nodeKinds.value = await useAutomationNodeKinds().list()
382
- } catch {
383
- // Catalogs are optional for editing — silently ignore.
384
- }
385
- }
349
+ return list
350
+ },
351
+ )
386
352
 
387
353
  interface AutomationTemplateApi {
388
354
  _id: string
@@ -393,58 +359,96 @@ interface AutomationTemplateApi {
393
359
  subgraph: ProcedureGraph
394
360
  }
395
361
 
396
- async function loadTemplate(id: string) {
397
- loading.value = true
362
+ const templateRead = useApiData<AutomationTemplateApi>(() =>
363
+ editorTemplateId.value ? `/api/automation/templates/${editorTemplateId.value}` : null,
364
+ )
365
+
366
+ /** Opens what the procedure list answered: `?selected=`, else the procedure open, else the first. */
367
+ function openList() {
368
+ const error = procedureListRead.error.value
369
+ if (error) {
370
+ loadError.value = describeApiError(error)
371
+ return
372
+ }
398
373
  loadError.value = null
399
- try {
400
- templateNotFound.value = false
401
- const tpl = await $authFetch<AutomationTemplateApi>(
402
- `/api/automation/templates/${id}`,
403
- )
404
- // Adapt the template into the ProcedureRecord shape so the rest of
405
- // the editor (history, dirty-tracking, sentinel sync, group toolbar)
406
- // keeps working unchanged. `enabled` is meaningless for templates;
407
- // pin it to true so the "disabled" warning banner never appears.
408
- const adapted: ProcedureRecord = {
409
- _id: tpl._id,
410
- name: tpl.name,
411
- description: tpl.description ?? '',
412
- enabled: true,
413
- graph: tpl.subgraph,
414
- }
415
- procedures.value = [adapted]
416
- selectedId.value = adapted._id
417
- templateIcon.value = tpl.icon || 'i-ph-package'
418
- templatePorts.value = Array.isArray(tpl.ports)
419
- ? tpl.ports.map((p) => ({ ...p }))
420
- : []
421
- templateLoadKey.value = id
422
- } catch (e) {
423
- // Worded for users, the same on the server and in the browser (the
424
- // raw fetch error names an internal URL that differs between them).
425
- templateNotFound.value = apiErrorStatus(e) === 404
426
- loadError.value = templateNotFound.value ? t('dms_automation.editor.templateNotFound') : describeApiError(e)
427
- procedures.value = []
374
+ // Copies: a draft changes the editor's records, not the read's.
375
+ procedures.value = (procedureListRead.data.value ?? []).map((p) => ({ ...p }))
376
+ if (
377
+ selectedId.value &&
378
+ !procedures.value.some((p) => p._id === selectedId.value)
379
+ ) {
428
380
  selectedId.value = null
429
- templatePorts.value = []
430
- } finally {
431
- loading.value = false
432
381
  }
382
+ const requested = queryValue('selected')
383
+ if (requested && procedures.value.some((p) => p._id === requested)) {
384
+ selectedId.value = requested
385
+ } else if (requested && !selectedId.value) {
386
+ // A link to a deleted procedure opens none: the builder says so
387
+ // and offers the switcher (see onMounted).
388
+ missingProcedureId.value = requested
389
+ return
390
+ }
391
+ if (!selectedId.value && procedures.value.length > 0) {
392
+ const first = procedures.value[0]
393
+ selectedId.value = first ? first._id : null
394
+ }
395
+ }
396
+
397
+ /** Reads the procedure list again (one was created) and opens it. */
398
+ async function loadList() {
399
+ loading.value = true
400
+ await procedureListRead.refresh()
401
+ loading.value = false
402
+ openList()
433
403
  }
434
404
 
435
- if (editorMode.value === 'template') {
405
+ /** Opens what the template read answered, or says why there is none. */
406
+ function openTemplate() {
436
407
  const id = editorTemplateId.value
437
- if (id) {
438
- await loadTemplate(id)
439
- } else {
408
+ if (!id) {
440
409
  templateNotFound.value = true
441
410
  loadError.value = t('dms_automation.editor.templateNotFound')
411
+ return
442
412
  }
443
- } else {
444
- await loadList()
445
- }
446
- await loadTypeCatalogs()
447
- await loadTemplates()
413
+ const error = templateRead.error.value
414
+ const tpl = templateRead.data.value
415
+ if (error || !tpl) {
416
+ // Worded for users, the same on the server and in the browser (the
417
+ // raw fetch error names an internal URL that differs between them).
418
+ templateNotFound.value = apiErrorStatus(error) === 404
419
+ loadError.value = templateNotFound.value ? t('dms_automation.editor.templateNotFound') : describeApiError(error)
420
+ procedures.value = []
421
+ selectedId.value = null
422
+ templatePorts.value = []
423
+ return
424
+ }
425
+ templateNotFound.value = false
426
+ loadError.value = null
427
+ // Adapt the template into the ProcedureRecord shape so the rest of
428
+ // the editor (history, dirty-tracking, sentinel sync, group toolbar)
429
+ // keeps working unchanged. `enabled` is meaningless for templates;
430
+ // pin it to true so the "disabled" warning banner never appears.
431
+ const adapted: ProcedureRecord = {
432
+ _id: tpl._id,
433
+ name: tpl.name,
434
+ description: tpl.description ?? '',
435
+ enabled: true,
436
+ graph: tpl.subgraph,
437
+ }
438
+ procedures.value = [adapted]
439
+ selectedId.value = adapted._id
440
+ templateIcon.value = tpl.icon || 'i-ph-package'
441
+ templatePorts.value = Array.isArray(tpl.ports)
442
+ ? tpl.ports.map((p) => ({ ...p }))
443
+ : []
444
+ }
445
+
446
+ // What the builder opens is awaited: the server renders it, and the browser
447
+ // opens the same from the data handed over. The catalogs, the templates and
448
+ // the bar's figures are read meanwhile, in parallel.
449
+ await Promise.all([procedureListRead, templateRead])
450
+ if (editorMode.value === 'template') openTemplate()
451
+ else openList()
448
452
 
449
453
  const selected = computed<ProcedureRecord | null>(
450
454
  () => procedures.value.find((p) => p._id === selectedId.value) ?? null,
@@ -747,15 +751,16 @@ watch(selectedId, () => {
747
751
  seedSubgraphPath()
748
752
  })
749
753
 
750
- // Re-fetch when the route's `?template=<id>` changes between templates while
751
- // the editor is mounted. Editor is mounted once per route navigation so this
752
- // is mostly a guard for in-place query updates (e.g. catalog "Edit" buttons
753
- // using router.push).
754
- watch(templateQueryId, async (id) => {
755
- if (editorMode.value !== 'template') return
756
- if (!id || id === templateLoadKey.value) return
757
- await loadTemplate(id)
758
- })
754
+ // `?template=<id>` changed while the editor stayed mounted (Editor is
755
+ // mounted once per route navigation, so this is mostly a guard for in-place
756
+ // query updates, e.g. catalog "Edit" buttons using router.push): the template
757
+ // read follows the URL, and the editor opens what it answers.
758
+ watch(
759
+ () => templateRead.status.value,
760
+ (status) => {
761
+ if (editorMode.value === 'template' && (status === 'success' || status === 'error')) openTemplate()
762
+ },
763
+ )
759
764
 
760
765
  /** A group's name: its step name, else the name it was created with. */
761
766
  function groupName(node: GraphNode): string {
@@ -1608,15 +1613,12 @@ const procedureEnabled = computed<boolean>({
1608
1613
  // The builder's bar: state, saving, problems (AU-03, AU-04, AU-16)
1609
1614
  // ---------------------------------------------------------------------------
1610
1615
 
1611
- const summaries = ref<ProcedureSummaryRow[]>([])
1612
-
1613
- async function loadSummaries() {
1614
- try {
1615
- summaries.value = await $authFetch<ProcedureSummaryRow[]>(`${props.apiUrl}/procedures/summary`)
1616
- } catch {
1617
- summaries.value = []
1618
- }
1619
- }
1616
+ // Each procedure's state, for the bar's badge and the switcher (procedure
1617
+ // mode only).
1618
+ const summariesRead = useApiData<ProcedureSummaryRow[]>(() =>
1619
+ editorMode.value === 'procedure' ? `${props.apiUrl}/procedures/summary` : null,
1620
+ )
1621
+ const summaries = computed(() => summariesRead.data.value ?? [])
1620
1622
 
1621
1623
  const currentSummary = computed(() => summaries.value.find((s) => s.procedureId === selectedId.value) ?? null)
1622
1624
 
@@ -1685,14 +1687,18 @@ async function validateDraft() {
1685
1687
  }
1686
1688
  }
1687
1689
 
1690
+ function scheduleValidation() {
1691
+ clearTimeout(validateTimer)
1692
+ validateTimer = setTimeout(() => void validateDraft(), VALIDATE_DELAY_MS)
1693
+ }
1688
1694
  watch(
1689
1695
  () => (selected.value ? [structuralKey(selected.value.graph), selected.value.name, selected.value.enabled].join('|') : ''),
1690
- () => {
1691
- clearTimeout(validateTimer)
1692
- validateTimer = setTimeout(() => void validateDraft(), VALIDATE_DELAY_MS)
1693
- },
1694
- { immediate: true },
1696
+ scheduleValidation,
1695
1697
  )
1698
+ // The draft as opened is checked in the browser: a server render has no
1699
+ // draft to check, and its timer would outlive the render.
1700
+ onMounted(scheduleValidation)
1701
+ onBeforeUnmount(() => clearTimeout(validateTimer))
1696
1702
 
1697
1703
  const blockingIssues = computed(() => issues.value.filter((i) => i.severity === 'error'))
1698
1704
 
@@ -1775,18 +1781,28 @@ function selectNode(id: string) {
1775
1781
  interface ProcedureTriggers {
1776
1782
  triggers: Array<WordedTrigger & { nextAt: string | null }>
1777
1783
  }
1778
- const savedTriggers = ref<ProcedureTriggers['triggers']>([])
1779
1784
 
1780
- async function loadSavedTriggers() {
1781
- if (!selectedId.value || editorMode.value !== 'procedure') return
1782
- try {
1783
- const res = await $authFetch<ProcedureTriggers>(`${props.apiUrl}/procedures/${selectedId.value}/triggers`)
1784
- savedTriggers.value = res.triggers
1785
- } catch {
1786
- savedTriggers.value = []
1787
- }
1785
+ /**
1786
+ * A URL of the procedure open, for the reads that follow it: none in
1787
+ * template mode or while no procedure is open.
1788
+ */
1789
+ function selectedProcedureUrl(path: string): () => string | null {
1790
+ return () => (selectedId.value && editorMode.value === 'procedure' ? `${props.apiUrl}/procedures/${selectedId.value}/${path}` : null)
1788
1791
  }
1789
1792
 
1793
+ /**
1794
+ * Data of the procedure open, or nothing while another one's is still on
1795
+ * screen or once its read failed.
1796
+ */
1797
+ function ofSelected<T>(read: { data: Ref<T | null>; placeholder: Readonly<Ref<boolean>>; error: Ref<unknown> }): T | null {
1798
+ return read.placeholder.value || read.error.value ? null : read.data.value
1799
+ }
1800
+
1801
+ // The saved triggers: what a paused procedure will not fire, and what Run
1802
+ // now offers.
1803
+ const savedTriggersRead = useApiData<ProcedureTriggers>(selectedProcedureUrl('triggers'))
1804
+ const savedTriggers = computed(() => ofSelected(savedTriggersRead)?.triggers ?? [])
1805
+
1790
1806
  /** The banner of a disabled procedure names what will not fire (AU-16). */
1791
1807
  const pausedBanner = computed(() => {
1792
1808
  const current = selected.value
@@ -1824,8 +1840,7 @@ const saveState = computed(() => {
1824
1840
  // ---------------------------------------------------------------------------
1825
1841
 
1826
1842
  async function onCreated(id: string) {
1827
- await loadList()
1828
- await loadSummaries()
1843
+ await Promise.all([loadList(), summariesRead.refresh()])
1829
1844
  selectedId.value = id
1830
1845
  void router.replace(`${builderPath()}?selected=${id}`)
1831
1846
  }
@@ -1848,7 +1863,7 @@ async function onDelete() {
1848
1863
  selectedId.value = procedures.value[0]?._id ?? null
1849
1864
  void router.replace(selectedId.value ? `${builderPath()}?selected=${selectedId.value}` : builderPath())
1850
1865
  toast.add({ title: t('dms_automation.editor.deleted', { name }), color: 'success', icon: 'i-ph-check-circle' })
1851
- void loadSummaries()
1866
+ void summariesRead.refresh()
1852
1867
  },
1853
1868
  })
1854
1869
  }
@@ -2116,8 +2131,8 @@ async function onSave(): Promise<boolean> {
2116
2131
  icon: 'i-ph-check-circle',
2117
2132
  actions: [{ label: t('dms_automation.editor.testRun'), onClick: () => void onTestRun() }],
2118
2133
  })
2119
- void loadSummaries()
2120
- void loadSavedTriggers()
2134
+ void summariesRead.refresh()
2135
+ void savedTriggersRead.refresh()
2121
2136
  return true
2122
2137
  } catch (e) {
2123
2138
  if (editorMode.value === 'procedure' && apiErrorStatus(e) === 409) return await resolveStale(current, e)
@@ -2190,8 +2205,8 @@ async function reloadSelected() {
2190
2205
  initHistoryAndSaved()
2191
2206
  seedSubgraphPath()
2192
2207
  saveBlocked.value = false
2193
- void loadSummaries()
2194
- void loadSavedTriggers()
2208
+ void summariesRead.refresh()
2209
+ void savedTriggersRead.refresh()
2195
2210
  } catch (e) {
2196
2211
  toast.add({ title: t('dms_automation.editor.loadProceduresError'), description: describeApiError(e), color: 'error', icon: 'i-ph-warning' })
2197
2212
  }
@@ -2341,7 +2356,7 @@ async function submitSaveAsTemplate() {
2341
2356
  const linkOnly = !isDirty.value
2342
2357
  convertLocalGroupToTemplateInstance(n.id, created._id)
2343
2358
  saveAsTemplateOpen.value = false
2344
- void loadTemplates()
2359
+ void templatesRead.refresh()
2345
2360
  toast.add({
2346
2361
  title: t('dms_automation.templates.saved', { name }),
2347
2362
  description: linkOnly ? undefined : t('dms_automation.editor.saveTemplateModal.saveToLink'),
@@ -2712,17 +2727,13 @@ onBeforeUnmount(() => {
2712
2727
  // Runs over the canvas: Test run of the draft, debugging a stored run (AU-05)
2713
2728
  // ---------------------------------------------------------------------------
2714
2729
 
2715
- const recentRuns = ref<DockRun[]>([])
2716
-
2717
- async function loadRecentRuns() {
2718
- if (!selectedId.value || editorMode.value !== 'procedure') return
2719
- try {
2720
- const list = await $authFetch<DockRun[]>(`${props.apiUrl}/procedures/${selectedId.value}/runs?limit=8`)
2721
- recentRuns.value = Array.isArray(list) ? list.slice(0, 8) : []
2722
- } catch {
2723
- recentRuns.value = []
2724
- }
2725
- }
2730
+ // The dock's last runs: its tab counts the failed ones, folded too.
2731
+ const RECENT_RUNS = 8
2732
+ const recentRunsRead = useApiData<DockRun[]>(selectedProcedureUrl('runs'), { query: { limit: RECENT_RUNS } })
2733
+ const recentRuns = computed(() => {
2734
+ const list = ofSelected(recentRunsRead)
2735
+ return Array.isArray(list) ? list.slice(0, RECENT_RUNS) : []
2736
+ })
2726
2737
 
2727
2738
  /** The run shown over the canvas, and whether it is a test of the draft. */
2728
2739
  const overlayRun = ref<RunDetail | null>(null)
@@ -2734,20 +2745,23 @@ const testPayloadSource = ref<string | null>(null)
2734
2745
  // the draft's triggers at the end).
2735
2746
  const testTriggerNodeId = ref<string | undefined>(undefined)
2736
2747
 
2737
- async function loadTestPayload() {
2738
- if (!selectedId.value || editorMode.value !== 'procedure') return
2739
- const query = testTriggerNodeId.value ? `?triggerNodeId=${encodeURIComponent(testTriggerNodeId.value)}` : ''
2740
- try {
2741
- const res = await $authFetch<{ last: { runId: string; payload: unknown } | null }>(
2742
- `${props.apiUrl}/procedures/${selectedId.value}/last-payload${query}`,
2743
- )
2744
- testPayload.value = JSON.stringify(res.last?.payload ?? {}, null, 2)
2745
- testPayloadSource.value = res.last?.runId ?? null
2746
- } catch {
2747
- testPayload.value = '{}'
2748
- testPayloadSource.value = null
2749
- }
2750
- }
2748
+ // The last real payload of the trigger a Test run starts from, which fills
2749
+ // the test payload the user then edits. Left to the browser: it is shown
2750
+ // only once the dock's payload tab is opened, and may be large.
2751
+ const lastPayloadRead = useApiData<{ last: { runId: string; payload: unknown } | null }>(selectedProcedureUrl('last-payload'), {
2752
+ query: () => (testTriggerNodeId.value ? { triggerNodeId: testTriggerNodeId.value } : {}),
2753
+ server: false,
2754
+ // Copied into an editable field: the page's refreshes leave the draft alone.
2755
+ refreshOnPageRefresh: false,
2756
+ })
2757
+ // Each answer (or failure) of another procedure or trigger replaces the
2758
+ // payload; the previous procedure's, still on screen meanwhile, does not.
2759
+ watch([() => lastPayloadRead.data.value, () => lastPayloadRead.error.value], ([answer, error]) => {
2760
+ if (!error && lastPayloadRead.placeholder.value) return
2761
+ const last = error ? null : answer?.last
2762
+ testPayload.value = JSON.stringify(last?.payload ?? {}, null, 2)
2763
+ testPayloadSource.value = last?.runId ?? null
2764
+ })
2751
2765
 
2752
2766
  const runStates = computed<Record<string, NodeRunState> | undefined>(() => {
2753
2767
  const run = overlayRun.value
@@ -2883,7 +2897,7 @@ async function onTestRun() {
2883
2897
  await showRun(res.runId)
2884
2898
  dockTab.value = 'test'
2885
2899
  dockCollapsed.value = false
2886
- void loadRecentRuns()
2900
+ void recentRunsRead.refresh()
2887
2901
  } catch (e) {
2888
2902
  const refused = issuesOf(e)
2889
2903
  if (refused) {
@@ -2925,8 +2939,8 @@ async function openRunNow() {
2925
2939
  async function onRunStarted(runId: string) {
2926
2940
  const name = savedName.value
2927
2941
  const trace = { label: t('dms_automation.runs.trace'), onClick: () => void router.push(`${props.traceUrl}?run=${runId}`) }
2928
- void loadRecentRuns()
2929
- void loadSummaries()
2942
+ void recentRunsRead.refresh()
2943
+ void summariesRead.refresh()
2930
2944
  let run: RunDetail
2931
2945
  try {
2932
2946
  run = await showRun(runId)
@@ -3021,17 +3035,12 @@ function onWrapInRetry(payload: { id: string }) {
3021
3035
  // Loading what the bar and the dock show, per procedure
3022
3036
  // ---------------------------------------------------------------------------
3023
3037
 
3024
- watch(
3025
- selectedId,
3026
- (id) => {
3027
- if (id) missingProcedureId.value = null
3028
- overlayRun.value = null
3029
- void loadSavedTriggers()
3030
- void loadRecentRuns()
3031
- void loadTestPayload()
3032
- },
3033
- { immediate: true },
3034
- )
3038
+ // Another procedure opened: what the bar and the dock show follows it
3039
+ // through their reads' URLs.
3040
+ watch(selectedId, (id) => {
3041
+ if (id) missingProcedureId.value = null
3042
+ overlayRun.value = null
3043
+ })
3035
3044
 
3036
3045
  /** `?path=g1,g2`: the groups to enter, outermost first, before `?node=`. */
3037
3046
  function enterPathFromUrl(): boolean {
@@ -3045,7 +3054,6 @@ function enterPathFromUrl(): boolean {
3045
3054
  }
3046
3055
 
3047
3056
  onMounted(async () => {
3048
- await loadSummaries()
3049
3057
  if (missingProcedureId.value) switcherOpen.value = true
3050
3058
  const runId = queryValue('run')
3051
3059
  if (runId) await openRunFromUrl(runId)
@@ -3093,7 +3101,6 @@ watch(
3093
3101
  },
3094
3102
  { immediate: true },
3095
3103
  )
3096
- watch(testTriggerNodeId, () => void loadTestPayload())
3097
3104
 
3098
3105
  // Below xl the inspector floats over the canvas instead of narrowing it; the
3099
3106
  // palette can be put away. Remembered per browser.
@@ -1,5 +1,5 @@
1
1
  <script setup lang="ts">
2
- import { computed, ref, watch } from 'vue'
2
+ import { computed, ref } from 'vue'
3
3
  import { type LogEntry, type RunLog, useAutomationRuns } from '../../composables/useAutomationRuns'
4
4
  import { describeDuration, prettyJson, stepTitle, type StepName } from '../../utils/describe'
5
5
 
@@ -22,25 +22,12 @@ const { t } = useI18n()
22
22
  const runs = useAutomationRuns(props.apiUrl)
23
23
  const expanded = ref<Set<number>>(new Set())
24
24
 
25
- const fetched = ref<RunLog | null>(null)
26
- const loading = ref(false)
27
- const error = ref<string | null>(null)
28
- const log = computed(() => props.log ?? fetched.value)
29
-
30
- async function load() {
31
- if (props.log) return
32
- loading.value = true
33
- try {
34
- fetched.value = await runs.getLogs(props.runId)
35
- error.value = null
36
- } catch (e) {
37
- error.value = describeApiError(e)
38
- } finally {
39
- loading.value = false
40
- }
41
- }
42
-
43
- watch(() => props.runId, () => void load(), { immediate: true })
25
+ // The log a run did not come with, read once the list shows it. A stored
26
+ // run's log does not change: the page's refreshes leave it alone.
27
+ const logRead = runs.readLogs(() => (props.log ? null : props.runId), { refreshOnPageRefresh: false })
28
+ const log = computed(() => props.log ?? logRead.data.value)
29
+ const loading = computed(() => !props.log && logRead.pending.value)
30
+ const error = computed(() => (!props.log && logRead.error.value ? describeApiError(logRead.error.value) : null))
44
31
 
45
32
  const level = ref<'all' | 'problems' | 'errors'>('all')
46
33
  const stepMessagesOnly = ref(false)
@@ -1,5 +1,5 @@
1
1
  <script setup lang="ts">
2
- import { computed, ref, watch } from 'vue'
2
+ import { computed, ref } from 'vue'
3
3
  import { builderRunUrl, opensInBuilder, type RunDetail, useAutomationRuns } from '../composables/useAutomationRuns'
4
4
  import { useRunActions } from '../composables/useRunActions'
5
5
  import { describeDateTime, describeDuration } from '../utils/describe'
@@ -22,26 +22,14 @@ const { dateTimeFormat } = useRegionalFormat()
22
22
  const runs = useAutomationRuns(props.apiUrl)
23
23
  const { rerun, rerunning } = useRunActions({ apiUrl: props.apiUrl, traceUrl: props.traceUrl })
24
24
 
25
- const run = ref<RunDetail | null>(null)
26
- const loading = ref(true)
27
- const error = ref<string | null>(null)
25
+ // The run of the row opened, read once the drawer shows it. A run does not
26
+ // change once stored: the live page's refreshes leave it alone.
27
+ const runRead = runs.readRun(() => props.rowData?._id, { refreshOnPageRefresh: false })
28
+ const run = computed<RunDetail | null>(() => runRead.data.value)
29
+ const loading = computed(() => runRead.pending.value)
30
+ const error = computed(() => (runRead.error.value ? describeApiError(runRead.error.value) : null))
28
31
  const section = ref<'summary' | 'payload' | 'logs'>('summary')
29
32
 
30
- async function load(id: string | undefined) {
31
- if (!id) return
32
- loading.value = true
33
- try {
34
- run.value = await runs.getRun(id)
35
- error.value = null
36
- } catch (e) {
37
- error.value = describeApiError(e)
38
- } finally {
39
- loading.value = false
40
- }
41
- }
42
-
43
- watch(() => props.rowData?._id, (id) => void load(id), { immediate: true })
44
-
45
33
  const failed = computed(() => run.value?.status === 'failed')
46
34
  const procedureName = computed(
47
35
  () => run.value?.procedure?.name ?? run.value?.procedureName ?? t('dms_automation.feed.deletedProcedure'),