@antelopejs/dms-automation 0.2.6 → 0.3.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 (312) hide show
  1. package/README.md +46 -2
  2. package/dist/data/procedures-table.d.ts +38 -4
  3. package/dist/data/procedures-table.js +264 -82
  4. package/dist/data/procedures-table.js.map +1 -1
  5. package/dist/data/runs-table.d.ts +19 -3
  6. package/dist/data/runs-table.js +254 -19
  7. package/dist/data/runs-table.js.map +1 -1
  8. package/dist/db/index.d.ts +1 -2
  9. package/dist/db/index.js +1 -2
  10. package/dist/db/index.js.map +1 -1
  11. package/dist/db/models/automation_template.model.d.ts +16 -1
  12. package/dist/db/models/automation_template.model.js +31 -11
  13. package/dist/db/models/automation_template.model.js.map +1 -1
  14. package/dist/db/models/index.d.ts +1 -1
  15. package/dist/db/models/index.js +1 -1
  16. package/dist/db/models/procedure.model.d.ts +1 -0
  17. package/dist/db/models/procedure.model.js +7 -0
  18. package/dist/db/models/procedure.model.js.map +1 -1
  19. package/dist/db/models/procedure_run.model.d.ts +16 -9
  20. package/dist/db/models/procedure_run.model.js +96 -17
  21. package/dist/db/models/procedure_run.model.js.map +1 -1
  22. package/dist/db/models/stats.model.d.ts +60 -61
  23. package/dist/db/models/stats.model.js +189 -236
  24. package/dist/db/models/stats.model.js.map +1 -1
  25. package/dist/db/models/type_switch.model.d.ts +25 -0
  26. package/dist/db/models/type_switch.model.js +25 -0
  27. package/dist/db/models/type_switch.model.js.map +1 -0
  28. package/dist/db/tables/index.d.ts +1 -2
  29. package/dist/db/tables/index.js +1 -2
  30. package/dist/db/tables/index.js.map +1 -1
  31. package/dist/db/tables/procedure.table.d.ts +6 -0
  32. package/dist/db/tables/procedure.table.js +24 -0
  33. package/dist/db/tables/procedure.table.js.map +1 -1
  34. package/dist/db/tables/procedure_run.table.d.ts +15 -1
  35. package/dist/db/tables/procedure_run.table.js +54 -0
  36. package/dist/db/tables/procedure_run.table.js.map +1 -1
  37. package/dist/db/tables/type_switch.table.d.ts +8 -0
  38. package/dist/db/tables/{trigger_type_config.table.js → type_switch.table.js} +16 -15
  39. package/dist/db/tables/type_switch.table.js.map +1 -0
  40. package/dist/displays/index.d.ts +14 -0
  41. package/dist/displays/index.js +23 -0
  42. package/dist/displays/index.js.map +1 -0
  43. package/dist/index.d.ts +7 -0
  44. package/dist/index.js +8 -0
  45. package/dist/index.js.map +1 -1
  46. package/dist/pages/builder.d.ts +1 -1
  47. package/dist/pages/builder.js +10 -3
  48. package/dist/pages/builder.js.map +1 -1
  49. package/dist/pages/index.d.ts +2 -1
  50. package/dist/pages/index.js +2 -1
  51. package/dist/pages/index.js.map +1 -1
  52. package/dist/pages/library.d.ts +2 -1
  53. package/dist/pages/library.js +54 -4
  54. package/dist/pages/library.js.map +1 -1
  55. package/dist/pages/overview.d.ts +6 -1
  56. package/dist/pages/overview.js +121 -2
  57. package/dist/pages/overview.js.map +1 -1
  58. package/dist/pages/procedures.js +106 -16
  59. package/dist/pages/procedures.js.map +1 -1
  60. package/dist/pages/runs.d.ts +4 -1
  61. package/dist/pages/runs.js +109 -13
  62. package/dist/pages/runs.js.map +1 -1
  63. package/dist/pages/shared.d.ts +18 -0
  64. package/dist/pages/shared.js +238 -0
  65. package/dist/pages/shared.js.map +1 -0
  66. package/dist/pages/trace.d.ts +10 -0
  67. package/dist/pages/trace.js +41 -0
  68. package/dist/pages/trace.js.map +1 -0
  69. package/dist/realtime.d.ts +3 -0
  70. package/dist/realtime.js +14 -0
  71. package/dist/realtime.js.map +1 -0
  72. package/dist/routes/action-types.d.ts +2 -14
  73. package/dist/routes/action-types.js +2 -32
  74. package/dist/routes/action-types.js.map +1 -1
  75. package/dist/routes/deleteConfirm.d.ts +3 -0
  76. package/dist/routes/deleteConfirm.js +64 -0
  77. package/dist/routes/deleteConfirm.js.map +1 -0
  78. package/dist/routes/graphSchema.d.ts +3 -90
  79. package/dist/routes/graphSchema.js +36 -9
  80. package/dist/routes/graphSchema.js.map +1 -1
  81. package/dist/routes/index.d.ts +1 -0
  82. package/dist/routes/index.js +1 -0
  83. package/dist/routes/index.js.map +1 -1
  84. package/dist/routes/library.d.ts +40 -0
  85. package/dist/routes/library.js +147 -0
  86. package/dist/routes/library.js.map +1 -0
  87. package/dist/routes/procedureChecks.d.ts +16 -0
  88. package/dist/routes/procedureChecks.js +72 -0
  89. package/dist/routes/procedureChecks.js.map +1 -0
  90. package/dist/routes/procedureRuns.d.ts +21 -0
  91. package/dist/routes/procedureRuns.js +45 -0
  92. package/dist/routes/procedureRuns.js.map +1 -0
  93. package/dist/routes/procedureSchemas.d.ts +107 -0
  94. package/dist/routes/procedureSchemas.js +61 -0
  95. package/dist/routes/procedureSchemas.js.map +1 -0
  96. package/dist/routes/procedures.d.ts +125 -7
  97. package/dist/routes/procedures.js +363 -67
  98. package/dist/routes/procedures.js.map +1 -1
  99. package/dist/routes/requests.d.ts +15 -0
  100. package/dist/routes/requests.js +35 -0
  101. package/dist/routes/requests.js.map +1 -0
  102. package/dist/routes/runs.d.ts +107 -2
  103. package/dist/routes/runs.js +340 -37
  104. package/dist/routes/runs.js.map +1 -1
  105. package/dist/routes/stats.d.ts +19 -1
  106. package/dist/routes/stats.js +160 -4
  107. package/dist/routes/stats.js.map +1 -1
  108. package/dist/routes/templates.d.ts +6 -2
  109. package/dist/routes/templates.js +106 -36
  110. package/dist/routes/templates.js.map +1 -1
  111. package/dist/routes/trigger-types.d.ts +2 -15
  112. package/dist/routes/trigger-types.js +2 -32
  113. package/dist/routes/trigger-types.js.map +1 -1
  114. package/dist/routes/typeConfigShared.d.ts +7 -11
  115. package/dist/routes/typeConfigShared.js +25 -15
  116. package/dist/routes/typeConfigShared.js.map +1 -1
  117. package/dist/runtime/armErrors.d.ts +16 -0
  118. package/dist/runtime/armErrors.js +69 -0
  119. package/dist/runtime/armErrors.js.map +1 -0
  120. package/dist/runtime/boundRunLog.d.ts +24 -0
  121. package/dist/runtime/boundRunLog.js +202 -10
  122. package/dist/runtime/boundRunLog.js.map +1 -1
  123. package/dist/runtime/builtins/actions/http.d.ts +10 -1
  124. package/dist/runtime/builtins/actions/http.js +306 -19
  125. package/dist/runtime/builtins/actions/http.js.map +1 -1
  126. package/dist/runtime/builtins/actions/log.js +2 -2
  127. package/dist/runtime/builtins/actions/log.js.map +1 -1
  128. package/dist/runtime/builtins/data/boolean.d.ts +1 -0
  129. package/dist/runtime/builtins/data/boolean.js +18 -10
  130. package/dist/runtime/builtins/data/boolean.js.map +1 -1
  131. package/dist/runtime/builtins/data/compare.js +60 -11
  132. package/dist/runtime/builtins/data/compare.js.map +1 -1
  133. package/dist/runtime/builtins/data/constant.js +9 -12
  134. package/dist/runtime/builtins/data/constant.js.map +1 -1
  135. package/dist/runtime/builtins/data/json.js +4 -4
  136. package/dist/runtime/builtins/data/json.js.map +1 -1
  137. package/dist/runtime/builtins/data/math.js +44 -24
  138. package/dist/runtime/builtins/data/math.js.map +1 -1
  139. package/dist/runtime/builtins/data/object.js +10 -10
  140. package/dist/runtime/builtins/data/object.js.map +1 -1
  141. package/dist/runtime/builtins/data/string.js +31 -20
  142. package/dist/runtime/builtins/data/string.js.map +1 -1
  143. package/dist/runtime/builtins/nodes/action.js +4 -0
  144. package/dist/runtime/builtins/nodes/action.js.map +1 -1
  145. package/dist/runtime/builtins/nodes/delay.js +1 -1
  146. package/dist/runtime/builtins/nodes/delay.js.map +1 -1
  147. package/dist/runtime/builtins/nodes/forRange.d.ts +1 -1
  148. package/dist/runtime/builtins/nodes/forRange.js +10 -4
  149. package/dist/runtime/builtins/nodes/forRange.js.map +1 -1
  150. package/dist/runtime/builtins/nodes/if.js +2 -1
  151. package/dist/runtime/builtins/nodes/if.js.map +1 -1
  152. package/dist/runtime/builtins/nodes/parallel.js +9 -2
  153. package/dist/runtime/builtins/nodes/parallel.js.map +1 -1
  154. package/dist/runtime/builtins/nodes/retry.js +1 -1
  155. package/dist/runtime/builtins/nodes/retry.js.map +1 -1
  156. package/dist/runtime/builtins/nodes/setVariable.js +1 -3
  157. package/dist/runtime/builtins/nodes/setVariable.js.map +1 -1
  158. package/dist/runtime/builtins/triggers/cron.d.ts +3 -0
  159. package/dist/runtime/builtins/triggers/cron.js +21 -7
  160. package/dist/runtime/builtins/triggers/cron.js.map +1 -1
  161. package/dist/runtime/builtins/triggers/manual.js +2 -2
  162. package/dist/runtime/builtins/triggers/manual.js.map +1 -1
  163. package/dist/runtime/builtins/triggers/webhook.d.ts +14 -1
  164. package/dist/runtime/builtins/triggers/webhook.js +116 -30
  165. package/dist/runtime/builtins/triggers/webhook.js.map +1 -1
  166. package/dist/runtime/describe.d.ts +23 -0
  167. package/dist/runtime/describe.js +114 -0
  168. package/dist/runtime/describe.js.map +1 -0
  169. package/dist/runtime/executionResult.d.ts +1 -0
  170. package/dist/runtime/executor.js +82 -5
  171. package/dist/runtime/executor.js.map +1 -1
  172. package/dist/runtime/graphIssues.d.ts +20 -0
  173. package/dist/runtime/graphIssues.js +290 -0
  174. package/dist/runtime/graphIssues.js.map +1 -0
  175. package/dist/runtime/graphVersion.d.ts +2 -0
  176. package/dist/runtime/graphVersion.js +43 -0
  177. package/dist/runtime/graphVersion.js.map +1 -0
  178. package/dist/runtime/nodeKinds.d.ts +4 -4
  179. package/dist/runtime/nodeKinds.js +1 -2
  180. package/dist/runtime/nodeKinds.js.map +1 -1
  181. package/dist/runtime/registry.d.ts +2 -1
  182. package/dist/runtime/registry.js +1 -2
  183. package/dist/runtime/registry.js.map +1 -1
  184. package/dist/runtime/resolveInputs.d.ts +3 -1
  185. package/dist/runtime/resolveInputs.js +12 -2
  186. package/dist/runtime/resolveInputs.js.map +1 -1
  187. package/dist/runtime/resolveSubgraph.d.ts +12 -1
  188. package/dist/runtime/resolveSubgraph.js +36 -0
  189. package/dist/runtime/resolveSubgraph.js.map +1 -1
  190. package/dist/runtime/retention.d.ts +6 -0
  191. package/dist/runtime/retention.js +54 -0
  192. package/dist/runtime/retention.js.map +1 -0
  193. package/dist/runtime/runProcedure.d.ts +12 -0
  194. package/dist/runtime/runProcedure.js +130 -0
  195. package/dist/runtime/runProcedure.js.map +1 -0
  196. package/dist/runtime/schedule.d.ts +2 -0
  197. package/dist/runtime/schedule.js +139 -0
  198. package/dist/runtime/schedule.js.map +1 -0
  199. package/dist/runtime/subscriptions.d.ts +11 -1
  200. package/dist/runtime/subscriptions.js +91 -125
  201. package/dist/runtime/subscriptions.js.map +1 -1
  202. package/dist/runtime/subwalk.js +2 -3
  203. package/dist/runtime/subwalk.js.map +1 -1
  204. package/dist/runtime/templateUsages.d.ts +4 -0
  205. package/dist/runtime/templateUsages.js +102 -0
  206. package/dist/runtime/templateUsages.js.map +1 -0
  207. package/dist/runtime/topo.d.ts +1 -0
  208. package/dist/runtime/topo.js +23 -0
  209. package/dist/runtime/topo.js.map +1 -1
  210. package/dist/runtime/trace.d.ts +44 -0
  211. package/dist/runtime/trace.js +240 -0
  212. package/dist/runtime/trace.js.map +1 -0
  213. package/dist/runtime/typeSwitches.d.ts +3 -0
  214. package/dist/runtime/typeSwitches.js +27 -0
  215. package/dist/runtime/typeSwitches.js.map +1 -0
  216. package/dist/runtime/validate.d.ts +11 -0
  217. package/dist/runtime/validate.js +118 -61
  218. package/dist/runtime/validate.js.map +1 -1
  219. package/dist/runtime/webhookRoutes.d.ts +4 -0
  220. package/dist/runtime/webhookRoutes.js +68 -0
  221. package/dist/runtime/webhookRoutes.js.map +1 -0
  222. package/dist/runtime/withTimeout.d.ts +1 -0
  223. package/dist/runtime/withTimeout.js +17 -0
  224. package/dist/runtime/withTimeout.js.map +1 -0
  225. package/dist/runtime/wording.d.ts +10 -0
  226. package/dist/runtime/wording.js +118 -0
  227. package/dist/runtime/wording.js.map +1 -0
  228. package/dist/stats/health-banner.d.ts +13 -0
  229. package/dist/stats/health-banner.js +149 -0
  230. package/dist/stats/health-banner.js.map +1 -0
  231. package/dist/stats/health.d.ts +49 -0
  232. package/dist/stats/health.js +130 -0
  233. package/dist/stats/health.js.map +1 -0
  234. package/dist/stats/kpi.d.ts +21 -0
  235. package/dist/stats/kpi.js +101 -0
  236. package/dist/stats/kpi.js.map +1 -0
  237. package/dist/stats/overview.d.ts +94 -0
  238. package/dist/stats/overview.js +244 -0
  239. package/dist/stats/overview.js.map +1 -0
  240. package/dist/types/constants.d.ts +0 -1
  241. package/dist/types/constants.js +1 -2
  242. package/dist/types/constants.js.map +1 -1
  243. package/dist/types/runLog.d.ts +2 -0
  244. package/dist/types/runLog.js +4 -0
  245. package/dist/types/runLog.js.map +1 -1
  246. package/frontend-vue/app/components/AttentionList.vue +276 -0
  247. package/frontend-vue/app/components/Catalog/SchemaTable.vue +127 -0
  248. package/frontend-vue/app/components/Catalog.vue +457 -0
  249. package/frontend-vue/app/components/Editor/BottomDock.vue +188 -0
  250. package/frontend-vue/app/components/Editor/BuilderPalette.vue +105 -44
  251. package/frontend-vue/app/components/Editor/GraphCanvas.vue +822 -207
  252. package/frontend-vue/app/components/Editor/GroupPortEditor.vue +29 -18
  253. package/frontend-vue/app/components/Editor/JsonField.vue +3 -3
  254. package/frontend-vue/app/components/Editor/NewProcedureDialog.vue +108 -0
  255. package/frontend-vue/app/components/Editor/NodeInspector.vue +382 -104
  256. package/frontend-vue/app/components/Editor/ProcedureSwitcher.vue +147 -0
  257. package/frontend-vue/app/components/Editor/RunNowDialog.vue +145 -0
  258. package/frontend-vue/app/components/Editor/WiredField.vue +3 -3
  259. package/frontend-vue/app/components/Editor/nodes/GenericNode.vue +97 -91
  260. package/frontend-vue/app/components/Editor/nodes/GroupNode.vue +5 -6
  261. package/frontend-vue/app/components/Editor/nodes/GroupSentinel.vue +3 -2
  262. package/frontend-vue/app/components/Editor/nodes/styles.ts +14 -18
  263. package/frontend-vue/app/components/Editor.vue +1894 -705
  264. package/frontend-vue/app/components/IconPicker.vue +122 -0
  265. package/frontend-vue/app/components/LiveTopics.vue +20 -0
  266. package/frontend-vue/app/components/Run/RunCompare.vue +115 -0
  267. package/frontend-vue/app/components/Run/RunFailure.vue +54 -0
  268. package/frontend-vue/app/components/Run/RunLogList.vue +167 -0
  269. package/frontend-vue/app/components/Run/RunPathTaken.vue +139 -0
  270. package/frontend-vue/app/components/Run/RunPayload.vue +85 -0
  271. package/frontend-vue/app/components/Run/RunWaterfall.vue +374 -0
  272. package/frontend-vue/app/components/RunPeek.vue +132 -0
  273. package/frontend-vue/app/components/RunTrace.vue +462 -0
  274. package/frontend-vue/app/components/Templates.vue +382 -537
  275. package/frontend-vue/app/components/WebhookEndpoint.vue +81 -0
  276. package/frontend-vue/app/composables/useAutomationNodeKinds.ts +23 -6
  277. package/frontend-vue/app/composables/useAutomationRuns.ts +160 -25
  278. package/frontend-vue/app/composables/useGraphConnect.ts +103 -51
  279. package/frontend-vue/app/composables/useRunActions.ts +60 -0
  280. package/frontend-vue/app/plugins/cell-displays.ts +169 -0
  281. package/frontend-vue/app/utils/automation.ts +4 -36
  282. package/frontend-vue/app/utils/describe.ts +252 -0
  283. package/frontend-vue/app/utils/redactedHeaders.ts +31 -0
  284. package/frontend-vue/dms.frontend.build.ts +7 -0
  285. package/frontend-vue/dms.frontend.ts +7 -4
  286. package/frontend-vue/i18n/locales/dms-automation-en-GB.json +1149 -309
  287. package/frontend-vue/i18n/locales/dms-automation-fr-FR.json +1154 -314
  288. package/frontend-vue/package.json +1 -1
  289. package/package.json +8 -5
  290. package/dist/db/models/type_config.model.d.ts +0 -47
  291. package/dist/db/models/type_config.model.js +0 -51
  292. package/dist/db/models/type_config.model.js.map +0 -1
  293. package/dist/db/tables/action_type_config.table.d.ts +0 -7
  294. package/dist/db/tables/action_type_config.table.js +0 -35
  295. package/dist/db/tables/action_type_config.table.js.map +0 -1
  296. package/dist/db/tables/trigger_type_config.table.d.ts +0 -7
  297. package/dist/db/tables/trigger_type_config.table.js.map +0 -1
  298. package/frontend-vue/app/components/Actions.vue +0 -151
  299. package/frontend-vue/app/components/Catalog/TypeConfigForm.vue +0 -166
  300. package/frontend-vue/app/components/Catalog/TypeList.vue +0 -198
  301. package/frontend-vue/app/components/DataNodes.vue +0 -272
  302. package/frontend-vue/app/components/Editor/ProcedureList.vue +0 -156
  303. package/frontend-vue/app/components/Editor/RunsDrawer.vue +0 -312
  304. package/frontend-vue/app/components/Library.vue +0 -69
  305. package/frontend-vue/app/components/Overview.vue +0 -503
  306. package/frontend-vue/app/components/RunDetailDrawer.vue +0 -165
  307. package/frontend-vue/app/components/RunFireTree.vue +0 -170
  308. package/frontend-vue/app/components/RunTraceDrawer.vue +0 -59
  309. package/frontend-vue/app/components/RunsStats.vue +0 -126
  310. package/frontend-vue/app/components/RunsTimelineDisplay.vue +0 -287
  311. package/frontend-vue/app/components/Triggers.vue +0 -147
  312. package/frontend-vue/app/plugins/runs-timeline-display.client.ts +0 -16
@@ -1,6 +1,8 @@
1
1
  <script setup lang="ts">
2
2
  import { computed, markRaw, nextTick, ref, watch } from 'vue'
3
3
  import { newId } from '../../utils/automation'
4
+ import { roleOf, summarizeNode, type WordedTrigger } from '../../utils/describe'
5
+ import type { NodeRunState } from './nodes/GenericNode.vue'
4
6
  // The canvas chrome (dotted DMS background, zoom controls, themed
5
7
  // node/handle/edge styling, pan/zoom + fit-view) now comes from the shared
6
8
  // DmsFlowCanvas wrapper (dms ≥0.0.25). We only keep the @vue-flow/core bits
@@ -41,25 +43,20 @@ import type {
41
43
  DataNodeType,
42
44
  JsonSchema,
43
45
  GroupPort,
46
+ ConnectResult,
44
47
  } from '../../composables/useGraphConnect'
45
- import type {
46
- NodeKindEntry,
47
- NodeKindUI,
48
+ import {
49
+ PALETTE_DRAG_TYPE,
50
+ type NodeKindEntry,
51
+ type NodeKindUI,
52
+ type PaletteBlock,
53
+ type TemplateSummary,
48
54
  } from '../../composables/useAutomationNodeKinds'
49
55
 
50
- // Minimal shape of a workspace template surfaced in the palette. Mirrors the
51
- // `TemplateRow` interface in Templates.vue but only the fields the palette
52
- // actually needs (id, name, icon, ports). `ports` is deep-cloned (JSON
53
- // round-trip) onto each new template-instance group node so future template
54
- // edits don't retroactively mutate the instance's port list (the resolved
55
- // subgraph still updates live — that's the live-link model).
56
- interface TemplateSummary {
57
- _id: string
58
- name: string
59
- icon?: string
60
- ports: GroupPort[]
61
- }
62
-
56
+ // A template's `ports` are deep-cloned (JSON round-trip) onto each new
57
+ // template-instance group node so future template edits don't retroactively
58
+ // mutate the instance's port list (the resolved subgraph still updates live —
59
+ // that's the live-link model).
63
60
  const props = defineProps<{
64
61
  graph: ProcedureGraph
65
62
  triggerTypes: TriggerType[]
@@ -74,8 +71,6 @@ const props = defineProps<{
74
71
  nodeKinds: NodeKindEntry[]
75
72
  canUndo?: boolean
76
73
  canRedo?: boolean
77
- isDirty?: boolean
78
- applying?: boolean
79
74
  // When the canvas is showing a group's inner subgraph, these are the
80
75
  // parent group's declared ports — the sentinel nodes (groupInput /
81
76
  // groupOutput) render handles derived from this list rather than
@@ -88,8 +83,37 @@ const props = defineProps<{
88
83
  // User can still pan / zoom / select / inspect, just not connect,
89
84
  // move, delete, or edit. The "Apply / Cancel" buttons are hidden too.
90
85
  readOnly?: boolean
86
+ /** Outcome of each node in the run shown over the canvas (a test run, a debugged run). */
87
+ runStates?: Record<string, NodeRunState>
88
+ /** The problem of each node the validator named. */
89
+ issues?: Record<string, NodeIssue>
90
+ /**
91
+ * The node the editor has selected (inspector, dock "Select node", a
92
+ * `?node=` link): the canvas selects it too and brings it into view.
93
+ */
94
+ selectedNodeId?: string | null
95
+ /**
96
+ * Names the graph shown (the procedure, the group entered): a new key
97
+ * fits the new graph into view.
98
+ */
99
+ viewKey?: string
100
+ /**
101
+ * An element drawn over the canvas's right edge (the inspector on narrow
102
+ * screens): fitting and centring keep the nodes out from under it.
103
+ */
104
+ coveredBy?: HTMLElement | null
105
+ /** The draft's triggers, worded by the server: a schedule reads in words. */
106
+ triggers?: WordedTrigger[]
91
107
  }>()
92
108
 
109
+ interface NodeIssue {
110
+ severity: 'error' | 'warning'
111
+ message: string
112
+ /** Problem code, translated as `dms_automation.editor.problems.codes.<code>`. */
113
+ code?: string
114
+ params?: Record<string, unknown>
115
+ }
116
+
93
117
  const emit = defineEmits<{
94
118
  (e: 'update:graph', g: ProcedureGraph): void
95
119
  (e: 'select:node', id: string | null): void
@@ -100,8 +124,6 @@ const emit = defineEmits<{
100
124
  (e: 'selection-change', payload: { ids: string[] }): void
101
125
  (e: 'undo'): void
102
126
  (e: 'redo'): void
103
- (e: 'cancel'): void
104
- (e: 'apply'): void
105
127
  // Bubbles up GroupNode's @dblclick — Editor.vue uses this to push the
106
128
  // group onto the subgraph navigation path. Filtered by kind here so
107
129
  // the parent doesn't need to look the node up itself.
@@ -109,6 +131,20 @@ const emit = defineEmits<{
109
131
  }>()
110
132
 
111
133
  const toast = useToast()
134
+ const { processI18n } = useTranslation()
135
+ const { processText } = useComposedText()
136
+ const { t, te } = useI18n()
137
+
138
+ // Fit view never zooms past 100% (a lone trigger would fill the canvas) and
139
+ // may go down to 10% so a large graph fits whole.
140
+ const FIT_PADDING = 0.15
141
+ const FIT_MAX_ZOOM = 1
142
+ const MIN_ZOOM = 0.1
143
+ const MAX_ZOOM = 1.5
144
+ // Room left around a new node, and the size assumed for a node not drawn
145
+ // yet (GenericNode's width, a typical height).
146
+ const NODE_GAP = 60
147
+ const NEW_NODE_SIZE = { width: 230, height: 90 }
112
148
 
113
149
  const nodeTypes = markRaw({
114
150
  genericNode: GenericNode,
@@ -162,6 +198,22 @@ function lookupTypeBySpec(spec: NodeKindUI, typeId: string | undefined) {
162
198
  return null
163
199
  }
164
200
 
201
+ // A schedule in words, once the server has worded its current expression.
202
+ function scheduleTextOf(node: AppGraphNode): string | undefined {
203
+ const cron = node.config?.cron
204
+ const worded = props.triggers?.find((tr) => tr.nodeId === node.id && tr.cron === cron)
205
+ return worded ? processText(worded.text) : undefined
206
+ }
207
+
208
+ // The validator's problem on a node, in the reader's language (its English
209
+ // message when this version has no text for the code).
210
+ function issueOf(id: string): NodeIssue | null {
211
+ const issue = props.issues?.[id]
212
+ if (!issue) return null
213
+ const key = `dms_automation.editor.problems.codes.${issue.code}`
214
+ return issue.code && te(key) ? { ...issue, message: t(key, issue.params ?? {}) } : issue
215
+ }
216
+
165
217
  // Build the GenericNode `data` payload from a graph node. For every kind
166
218
  // with `ui` metadata (every kind except group + sentinels), one
167
219
  // data-driven resolver applies: combine `spec` from the backend with the
@@ -187,7 +239,9 @@ function dataFor(node: AppGraphNode) {
187
239
  }
188
240
  | null
189
241
  if (type) {
190
- if (spec.labelFromType) label = type.name ?? label
242
+ // Type names may be `$`-prefixed DMS i18n keys; plain text passes through.
243
+ if (spec.labelFromType && type.name !== undefined)
244
+ label = processI18n(type.name)
191
245
  if (spec.iconFromType) icon = type.icon ?? icon
192
246
  if (spec.categoryFromType) category = type.category
193
247
  if (spec.dataInsFromTypeSchema)
@@ -203,8 +257,16 @@ function dataFor(node: AppGraphNode) {
203
257
  : []
204
258
  const triggerOuts = [...dynPorts, ...spec.staticTriggerOuts]
205
259
 
260
+ const own = (node as AppGraphNode & { label?: string }).label
261
+ const module = (type as { module?: string } | null)?.module
206
262
  return {
207
- label,
263
+ label: own || label,
264
+ typeName: label,
265
+ role: roleOf(node.kind, spec.category),
266
+ module,
267
+ summary: summarizeNode(node.kind, node.typeId, node.config, processI18n, scheduleTextOf(node)),
268
+ run: props.runStates?.[node.id] ?? null,
269
+ issue: issueOf(node.id),
208
270
  icon,
209
271
  category,
210
272
  typeId: node.typeId,
@@ -223,12 +285,17 @@ function dataFor(node: AppGraphNode) {
223
285
  // GroupNode interface) — surface them so the renderer can display
224
286
  // handles, linked badges, etc.
225
287
  const g = node as AppGraphNode & {
288
+ label?: string
226
289
  ports?: unknown
227
290
  templateId?: string
228
291
  subgraph?: unknown
229
292
  }
293
+ // Step name (`label`) first, as for any node; `config.name` is the name
294
+ // the group or its template was created with.
230
295
  return {
231
- label: node.config?.name ?? 'Group',
296
+ label: g.label || (node.config?.name as string | undefined) || t('dms_automation.nodes.role.group'),
297
+ run: props.runStates?.[node.id] ?? null,
298
+ issue: issueOf(node.id),
232
299
  ports: Array.isArray(g.ports) ? g.ports : [],
233
300
  templateId: g.templateId,
234
301
  subgraph: g.subgraph,
@@ -251,16 +318,39 @@ function dataFor(node: AppGraphNode) {
251
318
  return {}
252
319
  }
253
320
 
321
+ // What a screen reader announces for a node: its type when the node has a
322
+ // name of its own, its name, and what it does.
323
+ function ariaLabelOf(data: { label?: string; typeName?: string; summary?: string }) {
324
+ if (!data.label) return undefined
325
+ const type = data.typeName && data.typeName !== data.label ? `${data.typeName}: ` : ''
326
+ return `${type}${data.label}${data.summary ? `, ${data.summary}` : ''}`
327
+ }
328
+
254
329
  const vfNodes = computed(() =>
255
- props.graph.nodes.map((n) => ({
256
- id: n.id,
257
- type: vfTypeFor(n.kind),
258
- position: n.position,
259
- data: dataFor(n),
260
- sourcePosition: Position.Bottom,
261
- targetPosition: Position.Top,
262
- })),
330
+ props.graph.nodes.map((n) => {
331
+ const data = dataFor(n)
332
+ return {
333
+ id: n.id,
334
+ type: vfTypeFor(n.kind),
335
+ position: n.position,
336
+ data,
337
+ ariaLabel: SENTINEL_KINDS.has(n.kind)
338
+ ? t(n.kind === 'groupInput' ? 'dms_automation.nodes.groupInput' : 'dms_automation.nodes.groupOutput')
339
+ : ariaLabelOf(data),
340
+ sourcePosition: Position.Bottom,
341
+ targetPosition: Position.Top,
342
+ }
343
+ }),
344
+ )
345
+
346
+ // How the canvas names a node in its messages: its label, else (a group's
347
+ // sentinels) the group role.
348
+ const nodeNames = computed(
349
+ () => new Map(vfNodes.value.map((n) => [n.id, (n.data as { label?: string }).label])),
263
350
  )
351
+ function nodeName(id: string): string {
352
+ return nodeNames.value.get(id) || t('dms_automation.nodes.role.group')
353
+ }
264
354
 
265
355
  // Look up the kind of an edge endpoint by node id — needed for the group
266
356
  // handle-id derivation below. Sentinels and groups have richer handle
@@ -317,6 +407,17 @@ function dataTargetHandle(e: DataEdge, targetKind: NodeKind | undefined): string
317
407
  return `data-in-${e.to.field}`
318
408
  }
319
409
 
410
+ // After a run, the edges it took are drawn solid and the one into the failing
411
+ // step red; the others fade.
412
+ function edgeClass(from: string, to: string): string {
413
+ const runs = props.runStates
414
+ if (!runs) return 'edge-trigger'
415
+ const target = runs[to]?.status
416
+ const taken = runs[from] && target && target !== 'skipped'
417
+ if (taken && target === 'failed') return 'edge-trigger edge-failed'
418
+ return taken ? 'edge-trigger edge-taken' : 'edge-trigger edge-idle'
419
+ }
420
+
320
421
  // Edge styling lives in <style> (.edge-trigger / .edge-data) so the
321
422
  // `.selected` highlight can win without `!important`. Inline `style`
322
423
  // on a vue-flow edge defeats the .selected rule — documented gotcha.
@@ -329,7 +430,8 @@ const vfEdges = computed(() => {
329
430
  sourceHandle: triggerSourceHandle(e, kinds.get(e.from.node)),
330
431
  targetHandle: triggerTargetHandle(e, kinds.get(e.to.node)),
331
432
  data: { kind: 'trigger' as const },
332
- class: 'edge-trigger',
433
+ ariaLabel: `${menuName(e.from.node)} → ${menuName(e.to.node)}`,
434
+ class: edgeClass(e.from.node, e.to.node),
333
435
  }))
334
436
  const dataEdges = props.graph.dataEdges.map((e) => ({
335
437
  id: e.id,
@@ -338,6 +440,7 @@ const vfEdges = computed(() => {
338
440
  sourceHandle: dataSourceHandle(e, kinds.get(e.from.node)),
339
441
  targetHandle: dataTargetHandle(e, kinds.get(e.to.node)),
340
442
  data: { kind: 'data' as const },
443
+ ariaLabel: `${menuName(e.from.node)} · ${e.from.port} → ${menuName(e.to.node)} · ${e.to.field}`,
341
444
  class: 'edge-data',
342
445
  }))
343
446
  return [...triggerEdges, ...dataEdges]
@@ -348,10 +451,166 @@ function emitGraph(g: ProcedureGraph) {
348
451
  emit('update:graph', g)
349
452
  }
350
453
 
351
- function defaultPos() {
352
- // Stagger new nodes a bit so they don't all stack.
353
- const n = props.graph.nodes.length
354
- return { x: 120 + (n % 5) * 40, y: 120 + n * 40 }
454
+ interface XY {
455
+ x: number
456
+ y: number
457
+ }
458
+ interface Rect extends XY {
459
+ width: number
460
+ height: number
461
+ }
462
+
463
+ function nodeRects(): Rect[] {
464
+ return props.graph.nodes.map((n) => {
465
+ const size = flowRef.value?.findNode(n.id)?.dimensions
466
+ return {
467
+ ...n.position,
468
+ width: size?.width || NEW_NODE_SIZE.width,
469
+ height: size?.height || NEW_NODE_SIZE.height,
470
+ }
471
+ })
472
+ }
473
+
474
+ function overlaps(a: Rect, b: Rect): boolean {
475
+ const gap = NODE_GAP / 2
476
+ return a.x < b.x + b.width + gap && b.x < a.x + a.width + gap && a.y < b.y + b.height + gap && b.y < a.y + a.height + gap
477
+ }
478
+
479
+ // The first place at or below `pos` where a new node covers no other one.
480
+ function freeSpot(pos: XY): XY {
481
+ const rects = nodeRects()
482
+ const spot: Rect = { ...pos, ...NEW_NODE_SIZE }
483
+ for (let hit = rects.find((r) => overlaps(spot, r)); hit; hit = rects.find((r) => overlaps(spot, r))) {
484
+ spot.y = hit.y + hit.height + NODE_GAP
485
+ }
486
+ return { x: Math.round(spot.x), y: Math.round(spot.y) }
487
+ }
488
+
489
+ // A new step goes right of the selected one, else in the middle of what the
490
+ // canvas shows.
491
+ function newNodePosition(anchor: AppGraphNode | undefined): XY {
492
+ const flow = flowRef.value
493
+ if (anchor) {
494
+ const width = flow?.findNode(anchor.id)?.dimensions.width || NEW_NODE_SIZE.width
495
+ return freeSpot({ x: anchor.position.x + width + NODE_GAP, y: anchor.position.y })
496
+ }
497
+ if (!flow) return freeSpot({ x: 0, y: 0 })
498
+ const { x, y, zoom } = flow.viewport
499
+ return freeSpot({
500
+ x: (flow.dimensions.width / 2 - x) / zoom - NEW_NODE_SIZE.width / 2,
501
+ y: (flow.dimensions.height / 2 - y) / zoom - NEW_NODE_SIZE.height / 2,
502
+ })
503
+ }
504
+
505
+ // The node a new step follows: the one selected last on this canvas.
506
+ function anchorNode(): AppGraphNode | undefined {
507
+ const id = props.selectedNodeId ?? canvasSelection.value[canvasSelection.value.length - 1]
508
+ return props.graph.nodes.find((n) => n.id === id)
509
+ }
510
+
511
+ interface Port {
512
+ /** Vue Flow handle id. */
513
+ id: string
514
+ /** Port name ('' for the single trigger input of a step). */
515
+ name: string
516
+ }
517
+ interface NodeHandles {
518
+ triggerIns: Port[]
519
+ triggerOuts: Port[]
520
+ dataIns: Port[]
521
+ dataOuts: Port[]
522
+ }
523
+
524
+ // The handles a node draws, named as its renderer names them (see the
525
+ // handle prefix table in useGraphConnect).
526
+ function handlesOf(node: AppGraphNode): NodeHandles {
527
+ if (node.kind === 'group' || SENTINEL_KINDS.has(node.kind)) {
528
+ const ports =
529
+ node.kind === 'group'
530
+ ? ((node as AppGraphNode & { ports?: GroupPort[] }).ports ?? [])
531
+ : (props.parentGroupPorts ?? [])
532
+ const pick = (kind: GroupPort['kind'], direction: GroupPort['direction'], prefix: string) =>
533
+ ports
534
+ .filter((p) => p.kind === kind && p.direction === direction)
535
+ .map((p) => ({ id: `${prefix}${p.name}`, name: p.name }))
536
+ if (node.kind === 'group') {
537
+ return {
538
+ triggerIns: pick('trigger', 'in', 'group-trigger-in-'),
539
+ triggerOuts: pick('trigger', 'out', 'group-trigger-out-'),
540
+ dataIns: pick('data', 'in', 'group-data-in-'),
541
+ dataOuts: pick('data', 'out', 'group-data-out-'),
542
+ }
543
+ }
544
+ // The sentinels face inwards: the group's inputs leave groupInput, its
545
+ // outputs enter groupOutput.
546
+ if (node.kind === 'groupInput') {
547
+ return {
548
+ triggerIns: [],
549
+ triggerOuts: pick('trigger', 'in', 'groupInput-trigger-out-'),
550
+ dataIns: [],
551
+ dataOuts: pick('data', 'in', 'groupInput-data-out-'),
552
+ }
553
+ }
554
+ return {
555
+ triggerIns: pick('trigger', 'out', 'groupOutput-trigger-in-'),
556
+ triggerOuts: [],
557
+ dataIns: pick('data', 'out', 'groupOutput-data-in-'),
558
+ dataOuts: [],
559
+ }
560
+ }
561
+ const data = dataFor(node) as {
562
+ hasTriggerIn?: boolean
563
+ hasMainTriggerOut?: boolean
564
+ triggerOuts?: string[]
565
+ dataIns?: Array<{ name: string }>
566
+ dataOuts?: Array<{ name: string }>
567
+ }
568
+ const branches = [...(data.hasMainTriggerOut === false ? [] : ['main']), ...(data.triggerOuts ?? [])]
569
+ return {
570
+ triggerIns: data.hasTriggerIn === false ? [] : [{ id: 'trigger-in', name: '' }],
571
+ triggerOuts: branches.map((name) => ({ id: `trigger-out-${name}`, name })),
572
+ dataIns: (data.dataIns ?? []).map((p) => ({ id: `data-in-${p.name}`, name: p.name })),
573
+ dataOuts: (data.dataOuts ?? []).map((p) => ({ id: `data-out-${p.name}`, name: p.name })),
574
+ }
575
+ }
576
+
577
+ function check(graph: ProcedureGraph, conn: Connection) {
578
+ return canConnect(
579
+ graph,
580
+ props.nodeKinds,
581
+ props.triggerTypes,
582
+ props.actionTypes,
583
+ props.dataNodeTypes,
584
+ conn,
585
+ { parentGroupPorts: props.parentGroupPorts },
586
+ )
587
+ }
588
+
589
+ // The link from `from`'s main output to `to`, when that output is free and
590
+ // `to` has an input that accepts it.
591
+ function nextStepConnection(graph: ProcedureGraph, from: AppGraphNode, to: AppGraphNode): Connection | null {
592
+ const out = handlesOf(from).triggerOuts.find((p) => p.name === 'main')
593
+ const ins = handlesOf(to).triggerIns
594
+ const into = ins.find((p) => p.name === 'main' || p.name === '') ?? ins[0]
595
+ if (!out || !into) return null
596
+ if (graph.triggerEdges.some((e) => e.from.node === from.id && (e.from.branch ?? 'main') === 'main')) return null
597
+ const conn: Connection = { source: from.id, sourceHandle: out.id, target: to.id, targetHandle: into.id }
598
+ return check(graph, conn).ok ? conn : null
599
+ }
600
+
601
+ // The node to select and bring into view once drawn: one just added, or one
602
+ // the editor points at (`readable`).
603
+ let revealPending: { id: string; readable: boolean } | null = null
604
+
605
+ // Add a node where it was dropped, or next to the selected node and linked
606
+ // from it (one undo step for both).
607
+ function insertNode(node: AppGraphNode, at?: XY) {
608
+ const anchor = at ? undefined : anchorNode()
609
+ const placed = { ...node, position: at ? freeSpot(at) : newNodePosition(anchor) }
610
+ const graph = { ...props.graph, nodes: [...props.graph.nodes, placed] }
611
+ const link = anchor ? nextStepConnection(graph, anchor, placed) : null
612
+ emitGraph(link ? (withConnection(graph, link)?.graph ?? graph) : graph)
613
+ revealPending = { id: placed.id, readable: false }
355
614
  }
356
615
 
357
616
  function defaultsFromSchema(schema: JsonSchema | undefined): Record<string, unknown> {
@@ -388,18 +647,17 @@ function defaultConfigFor(kind: NodeKind, typeId?: string): Record<string, unkno
388
647
  : {}
389
648
  }
390
649
 
391
- function addNode(kind: NodeKind, typeId?: string) {
392
- const node: AppGraphNode = {
393
- id: newId(),
394
- kind,
395
- typeId,
396
- config: defaultConfigFor(kind, typeId),
397
- position: defaultPos(),
398
- }
399
- emitGraph({
400
- ...props.graph,
401
- nodes: [...props.graph.nodes, node],
402
- })
650
+ function addNode(kind: NodeKind, typeId?: string, at?: XY) {
651
+ insertNode(
652
+ {
653
+ id: newId(),
654
+ kind,
655
+ typeId,
656
+ config: defaultConfigFor(kind, typeId),
657
+ position: { x: 0, y: 0 },
658
+ },
659
+ at,
660
+ )
403
661
  }
404
662
 
405
663
  // Drop a template-instance group node into the current graph. The instance
@@ -411,7 +669,7 @@ function addNode(kind: NodeKind, typeId?: string) {
411
669
  // (the "live link" model); the port list is cloned so a port rename on
412
670
  // the template doesn't silently invalidate the outer wiring on this
413
671
  // instance (the user can manually re-sync by forking + re-saving).
414
- function addTemplateInstance(template: TemplateSummary) {
672
+ function addTemplateInstance(template: TemplateSummary, at?: XY) {
415
673
  const node: AppGraphNode & {
416
674
  ports: GroupPort[]
417
675
  templateId: string
@@ -419,41 +677,204 @@ function addTemplateInstance(template: TemplateSummary) {
419
677
  id: newId(),
420
678
  kind: 'group',
421
679
  config: { name: template.name },
422
- position: defaultPos(),
680
+ position: { x: 0, y: 0 },
423
681
  templateId: template._id,
424
682
  // JSON round-trip strips Vue's reactive proxy that wraps the template
425
683
  // passed from the palette; structuredClone throws on proxies.
426
684
  ports: JSON.parse(JSON.stringify(template.ports ?? [])) as GroupPort[],
427
685
  }
428
- emitGraph({
429
- ...props.graph,
430
- nodes: [...props.graph.nodes, node],
431
- })
686
+ insertNode(node, at)
432
687
  }
433
688
 
434
689
  // Node creation is driven from the left BuilderPalette (in Editor.vue) — expose
435
690
  // the two add helpers so the palette's events can reach the graph mutation.
436
691
  defineExpose({ addNode, addTemplateInstance })
437
692
 
693
+ // A block dragged from the palette lands where it is dropped.
694
+ function onDragOver(event: DragEvent) {
695
+ if (props.readOnly || !event.dataTransfer?.types.includes(PALETTE_DRAG_TYPE)) return
696
+ event.preventDefault()
697
+ event.dataTransfer.dropEffect = 'copy'
698
+ }
699
+
700
+ function onDrop(event: DragEvent) {
701
+ const raw = event.dataTransfer?.getData(PALETTE_DRAG_TYPE)
702
+ const flow = flowRef.value
703
+ if (props.readOnly || !raw || !flow) return
704
+ event.preventDefault()
705
+ const point = flow.screenToFlowCoordinate({ x: event.clientX, y: event.clientY })
706
+ const at = { x: point.x - NEW_NODE_SIZE.width / 2, y: point.y - NEW_NODE_SIZE.height / 2 }
707
+ const block = JSON.parse(raw) as PaletteBlock
708
+ if (block.template) addTemplateInstance(block.template, at)
709
+ else if (block.kind) addNode(block.kind, block.typeId, at)
710
+ }
711
+
438
712
  // DmsFlowCanvas owns the VueFlow store (it calls `useVueFlow(flowId)` with a
439
713
  // private id and `defineExpose`s the resulting controller). We grab that
440
714
  // controller through a template ref instead of calling `useVueFlow()` here —
441
715
  // a bare `useVueFlow()` would resolve to the DEFAULT store, which is NOT the
442
716
  // one DmsFlowCanvas drives, so zoom/fit/updateNodeInternals would silently
443
717
  // no-op. Only the handful of imperative methods we actually use are typed.
718
+ interface FlowNodeState {
719
+ id: string
720
+ selected?: boolean
721
+ computedPosition: XY
722
+ dimensions: { width: number; height: number }
723
+ }
444
724
  interface FlowController {
445
725
  zoomIn: () => void
446
726
  zoomOut: () => void
447
- fitView: () => void
448
727
  zoomTo: (zoom: number) => void
728
+ setViewport: (viewport: XY & { zoom: number }, options?: { duration?: number }) => Promise<boolean>
729
+ screenToFlowCoordinate: (position: XY) => XY
730
+ findNode: (id: string) => FlowNodeState | undefined
731
+ addSelectedNodes: (nodes: FlowNodeState[]) => void
732
+ removeSelectedNodes: (nodes: FlowNodeState[]) => void
449
733
  updateNodeInternals: (ids?: string | string[]) => void
450
734
  // DmsFlowCanvas `defineExpose`s the VueFlow controller; Vue's expose proxy
451
735
  // unwraps the `viewport` ref, so consumers read `.viewport.zoom` directly
452
736
  // (NOT `.viewport.value.zoom` — that extra `.value` is undefined and pinned
453
- // the zoom readout at 100%).
454
- viewport: { zoom: number }
737
+ // the zoom readout at 100%). Same for the refs below.
738
+ viewport: XY & { zoom: number }
739
+ /** Size of the canvas on screen. */
740
+ dimensions: { width: number; height: number }
741
+ getSelectedNodes: FlowNodeState[]
742
+ getSelectedEdges: Array<{ id: string }>
743
+ /** 'invalid' while the link being drawn hovers a port that refuses it. */
744
+ connectionStatus: 'valid' | 'invalid' | null
455
745
  }
456
746
  const flowRef = ref<FlowController | null>(null)
747
+ const wrapRef = ref<HTMLElement | null>(null)
748
+
749
+ // The width of the canvas the inspector covers when it is drawn over it.
750
+ function coveredRight(): number {
751
+ const cover = props.coveredBy?.getBoundingClientRect()
752
+ const own = wrapRef.value?.getBoundingClientRect()
753
+ if (!cover?.width || !own) return 0
754
+ return Math.max(0, Math.min(own.right, cover.right) - Math.max(own.left, cover.left))
755
+ }
756
+
757
+ // Fit every node into the part of the canvas left visible.
758
+ function fitView() {
759
+ const flow = flowRef.value
760
+ if (!flow) return
761
+ const nodes = props.graph.nodes
762
+ .map((n) => flow.findNode(n.id))
763
+ .filter((n): n is FlowNodeState => !!n?.dimensions.width)
764
+ if (nodes.length === 0) return
765
+ const left = Math.min(...nodes.map((n) => n.computedPosition.x))
766
+ const top = Math.min(...nodes.map((n) => n.computedPosition.y))
767
+ const width = Math.max(...nodes.map((n) => n.computedPosition.x + n.dimensions.width)) - left
768
+ const height = Math.max(...nodes.map((n) => n.computedPosition.y + n.dimensions.height)) - top
769
+ const visible = flow.dimensions.width - coveredRight()
770
+ const room = 1 + FIT_PADDING
771
+ const fit = Math.min(visible / (width * room), flow.dimensions.height / (height * room))
772
+ const zoom = Math.min(Math.max(fit, MIN_ZOOM), FIT_MAX_ZOOM)
773
+ flow.setViewport({
774
+ x: (visible - width * zoom) / 2 - left * zoom,
775
+ y: (flow.dimensions.height - height * zoom) / 2 - top * zoom,
776
+ zoom,
777
+ })
778
+ }
779
+
780
+ // Select a node and bring it into the visible part of the canvas. A node the
781
+ // editor points at (a link, a problem) is also shown at a readable zoom; a
782
+ // new node keeps the zoom.
783
+ function focusNode(id: string, readable = false) {
784
+ const flow = flowRef.value
785
+ const node = flow?.findNode(id)
786
+ if (!flow || !node) return
787
+ if (!node.selected) flow.addSelectedNodes([node])
788
+ // Selecting opens the inspector, which narrows or covers the canvas:
789
+ // look once it is drawn (two frames).
790
+ requestAnimationFrame(() => requestAnimationFrame(() => panTo(id, readable)))
791
+ }
792
+
793
+ function panTo(id: string, readable: boolean) {
794
+ const flow = flowRef.value
795
+ const node = flow?.findNode(id)
796
+ if (!flow || !node) return
797
+ const visible = flow.dimensions.width - coveredRight()
798
+ const zoom = readable ? Math.max(flow.viewport.zoom, 1) : flow.viewport.zoom
799
+ const left = node.computedPosition.x * zoom + flow.viewport.x
800
+ const top = node.computedPosition.y * zoom + flow.viewport.y
801
+ const inSight =
802
+ left >= 0 &&
803
+ top >= 0 &&
804
+ left + node.dimensions.width * zoom <= visible &&
805
+ top + node.dimensions.height * zoom <= flow.dimensions.height
806
+ if (inSight && zoom === flow.viewport.zoom) return
807
+ flow.setViewport(
808
+ {
809
+ x: visible / 2 - (node.computedPosition.x + node.dimensions.width / 2) * zoom,
810
+ y: flow.dimensions.height / 2 - (node.computedPosition.y + node.dimensions.height / 2) * zoom,
811
+ zoom,
812
+ },
813
+ // A node pointed at is shown at once; a new one slides into view.
814
+ { duration: readable ? 0 : 200 },
815
+ )
816
+ }
817
+
818
+ // A new graph on the canvas (first load, another procedure, a group entered
819
+ // or left) is fitted into view; a node just added or pointed at is shown.
820
+ // Both wait until every node is measured and the panels around the canvas
821
+ // have settled (two frames): Vue Flow keeps the measures of nodes whose id
822
+ // the previous graph shared, so it does not always report them again.
823
+ let fitPending = true
824
+ let settleQueued = false
825
+ function settleView() {
826
+ if (settleQueued) return
827
+ settleQueued = true
828
+ requestAnimationFrame(() =>
829
+ requestAnimationFrame(() => {
830
+ settleQueued = false
831
+ const flow = flowRef.value
832
+ if (!flow || !props.graph.nodes.every((n) => flow.findNode(n.id)?.dimensions.width)) return
833
+ if (fitPending) {
834
+ fitPending = false
835
+ fitView()
836
+ // The node the editor points at stays the one shown.
837
+ if (props.selectedNodeId) revealPending ??= { id: props.selectedNodeId, readable: true }
838
+ }
839
+ if (revealPending) {
840
+ const { id, readable } = revealPending
841
+ revealPending = null
842
+ focusNode(id, readable)
843
+ }
844
+ }),
845
+ )
846
+ }
847
+
848
+ // Vue Flow emits this once every node on the canvas has been measured.
849
+ function onNodesInitialized() {
850
+ settleView()
851
+ }
852
+
853
+ watch(
854
+ () => props.viewKey,
855
+ () => {
856
+ fitPending = true
857
+ nextTick(settleView)
858
+ },
859
+ )
860
+
861
+ watch(
862
+ () => props.selectedNodeId,
863
+ (id) => {
864
+ const flow = flowRef.value
865
+ // The editor closed its inspector: the canvas lets go of the node too.
866
+ if (!id) {
867
+ if (flow?.getSelectedNodes.length) flow.removeSelectedNodes(flow.getSelectedNodes)
868
+ return
869
+ }
870
+ // A node selected on the canvas itself is already where the user looks.
871
+ if (flow?.findNode(id)?.selected) return
872
+ revealPending = { id, readable: true }
873
+ nextTick(settleView)
874
+ },
875
+ // The editor may name a node (a `?node=` link) before the canvas exists.
876
+ { immediate: true },
877
+ )
457
878
 
458
879
  // Vue Flow caches each node's handle bounding boxes in its internal store and
459
880
  // only re-measures when `updateNodeInternals(id)` is called. When a port is
@@ -505,27 +926,12 @@ function resetZoom() {
505
926
  flowRef.value?.zoomTo(1)
506
927
  }
507
928
 
508
- function onConnect(conn: Connection) {
509
- if (props.readOnly) return
929
+ // The graph once `conn` is drawn, and the link it took the place of.
930
+ function withConnection(
931
+ graph: ProcedureGraph,
932
+ conn: Connection,
933
+ ): { graph: ProcedureGraph; added: TriggerEdge | DataEdge; replaced?: TriggerEdge | DataEdge } | null {
510
934
  const kind = connectionKind(conn.sourceHandle)
511
- const result = canConnect(
512
- props.graph,
513
- props.nodeKinds,
514
- props.triggerTypes,
515
- props.actionTypes,
516
- props.dataNodeTypes,
517
- conn,
518
- { parentGroupPorts: props.parentGroupPorts },
519
- )
520
- if (!result.ok) {
521
- toast.add({
522
- title: 'Cannot connect',
523
- description: result.reason,
524
- color: 'warning',
525
- icon: 'i-ph-warning',
526
- })
527
- return
528
- }
529
935
  if (kind === 'trigger') {
530
936
  const branch = parseSourceBranch(conn.sourceHandle)
531
937
  const toBranch = parseTargetBranch(conn.targetHandle)
@@ -540,48 +946,196 @@ function onConnect(conn: Connection) {
540
946
  // Connecting again replaces any existing edge from that source/branch.
541
947
  // (Branching across if/switch named branches still works because each
542
948
  // branch has its own `from.branch` and only conflicts with itself.)
543
- const remaining = props.graph.triggerEdges.filter(
544
- (e) =>
545
- !(
546
- e.from.node === conn.source &&
547
- (e.from.branch ?? 'main') === branch
548
- ),
949
+ const replaced = graph.triggerEdges.find(
950
+ (e) => e.from.node === conn.source && (e.from.branch ?? 'main') === branch,
549
951
  )
550
- emitGraph({
551
- ...props.graph,
552
- triggerEdges: [...remaining, newEdge],
553
- })
554
- } else if (kind === 'data') {
555
- const port = parseDataPort(conn.sourceHandle)
556
- const field = parseDataField(conn.targetHandle)
557
- if (!port || !field) return
558
- const newEdge: DataEdge = {
559
- id: newId(),
560
- from: { node: conn.source, port },
561
- to: { node: conn.target, field },
952
+ return {
953
+ graph: { ...graph, triggerEdges: [...graph.triggerEdges.filter((e) => e !== replaced), newEdge] },
954
+ added: newEdge,
955
+ replaced,
562
956
  }
563
- // Overwrite: if the target field is already wired, drop the existing
564
- // data edge before adding the new one.
565
- const remaining = props.graph.dataEdges.filter(
566
- (e) => !(e.to.node === conn.target && e.to.field === field),
567
- )
568
- emitGraph({
569
- ...props.graph,
570
- dataEdges: [...remaining, newEdge],
957
+ }
958
+ if (kind !== 'data') return null
959
+ const port = parseDataPort(conn.sourceHandle)
960
+ const field = parseDataField(conn.targetHandle)
961
+ if (!port || !field) return null
962
+ const newEdge: DataEdge = {
963
+ id: newId(),
964
+ from: { node: conn.source, port },
965
+ to: { node: conn.target, field },
966
+ }
967
+ // Overwrite: a field reads from one output only.
968
+ const replaced = graph.dataEdges.find((e) => e.to.node === conn.target && e.to.field === field)
969
+ return {
970
+ graph: { ...graph, dataEdges: [...graph.dataEdges.filter((e) => e !== replaced), newEdge] },
971
+ added: newEdge,
972
+ replaced,
973
+ }
974
+ }
975
+
976
+ function refusalText(result: ConnectResult): string {
977
+ return result.ok ? '' : t(`dms_automation.editor.canvas.connect.${result.code}`, result.params ?? {})
978
+ }
979
+
980
+ // Undo of a replacement: the new link goes, the old one comes back — unless
981
+ // the new link is gone already, or an end of the old one was deleted since.
982
+ function restoreLink(added: TriggerEdge | DataEdge, old: TriggerEdge | DataEdge) {
983
+ const graph = props.graph
984
+ const ids = new Set(graph.nodes.map((n) => n.id))
985
+ const back = ids.has(old.from.node) && ids.has(old.to.node)
986
+ if ('port' in added.from) {
987
+ if (!graph.dataEdges.some((e) => e.id === added.id)) return
988
+ const edges = graph.dataEdges.filter((e) => e.id !== added.id)
989
+ emitGraph({ ...graph, dataEdges: back ? [...edges, old as DataEdge] : edges })
990
+ } else {
991
+ if (!graph.triggerEdges.some((e) => e.id === added.id)) return
992
+ const edges = graph.triggerEdges.filter((e) => e.id !== added.id)
993
+ emitGraph({ ...graph, triggerEdges: back ? [...edges, old as TriggerEdge] : edges })
994
+ }
995
+ }
996
+
997
+ // Drawing over an existing link replaces it: say which one, with an undo of
998
+ // that replacement only.
999
+ function notifyReplaced(added: TriggerEdge | DataEdge, old: TriggerEdge | DataEdge, conn: Connection) {
1000
+ let description: string
1001
+ if ('port' in old.from) {
1002
+ const port = parseDataPort(conn.sourceHandle)
1003
+ if (old.from.node === conn.source && old.from.port === port) return
1004
+ description = t('dms_automation.editor.canvas.replaced.data', {
1005
+ field: (old as DataEdge).to.field,
1006
+ step: menuName(conn.target),
1007
+ source: `${menuName(conn.source)} · ${port}`,
1008
+ previous: `${menuName(old.from.node)} · ${old.from.port}`,
1009
+ })
1010
+ } else {
1011
+ if (old.to.node === conn.target) return
1012
+ description = t('dms_automation.editor.canvas.replaced.trigger', {
1013
+ source: menuName(conn.source),
1014
+ target: menuName(conn.target),
1015
+ previous: menuName(old.to.node),
1016
+ })
1017
+ }
1018
+ toast.add({
1019
+ title: t('dms_automation.editor.canvas.replaced.title'),
1020
+ description,
1021
+ color: 'info',
1022
+ icon: 'i-ph-arrows-left-right',
1023
+ actions: [{ label: t('dms_automation.editor.canvas.undo'), onClick: () => restoreLink(added, old) }],
1024
+ })
1025
+ }
1026
+
1027
+ function onConnect(conn: Connection) {
1028
+ if (props.readOnly) return
1029
+ const result = check(props.graph, conn)
1030
+ if (!result.ok) {
1031
+ toast.add({
1032
+ title: t('dms_automation.editor.canvas.connect.title'),
1033
+ description: refusalText(result),
1034
+ color: 'warning',
1035
+ icon: 'i-ph-warning',
571
1036
  })
1037
+ return
572
1038
  }
1039
+ const next = withConnection(props.graph, conn)
1040
+ if (!next) return
1041
+ emitGraph(next.graph)
1042
+ if (next.replaced) notifyReplaced(next.added, next.replaced, conn)
573
1043
  }
574
1044
 
1045
+ // Why the port under a link being drawn refuses it, shown while it hovers.
1046
+ const refusal = ref('')
1047
+ const refusalShown = computed(() => flowRef.value?.connectionStatus === 'invalid' && refusal.value !== '')
1048
+
575
1049
  function isValidConnection(conn: Connection): boolean {
576
- return canConnect(
577
- props.graph,
578
- props.nodeKinds,
579
- props.triggerTypes,
580
- props.actionTypes,
581
- props.dataNodeTypes,
582
- conn,
583
- { parentGroupPorts: props.parentGroupPorts },
584
- ).ok
1050
+ const result = check(props.graph, conn)
1051
+ refusal.value = refusalText(result)
1052
+ return result.ok
1053
+ }
1054
+
1055
+ // Released over a port that refuses the link: keep the reason on screen.
1056
+ function onConnectEnd() {
1057
+ if (refusalShown.value) {
1058
+ toast.add({
1059
+ title: t('dms_automation.editor.canvas.connect.title'),
1060
+ description: refusal.value,
1061
+ color: 'warning',
1062
+ icon: 'i-ph-warning',
1063
+ })
1064
+ }
1065
+ refusal.value = ''
1066
+ }
1067
+
1068
+ // Without a mouse: every link the selected step can make, from the canvas
1069
+ // toolbar (WCAG 2.5.7).
1070
+
1071
+ // Two steps with the same name are told apart by the end of their id (link
1072
+ // menu, replacement toast, links read aloud).
1073
+ function menuName(id: string): string {
1074
+ const name = nodeName(id)
1075
+ const twins = props.graph.nodes.filter((n) => nodeName(n.id) === name).length
1076
+ return twins > 1 ? `${name} #${id.slice(-4)}` : name
1077
+ }
1078
+ interface LinkItem {
1079
+ label: string
1080
+ connection: Connection
1081
+ }
1082
+
1083
+ const linkGroups = computed(() => {
1084
+ const id = canvasSelection.value.length === 1 ? canvasSelection.value[0] : undefined
1085
+ const node = props.graph.nodes.find((n) => n.id === id)
1086
+ if (!node || props.readOnly) return []
1087
+ const mine = handlesOf(node)
1088
+ const next: LinkItem[] = []
1089
+ const send: LinkItem[] = []
1090
+ const read: LinkItem[] = []
1091
+ const wired = (target: string, field: string) =>
1092
+ props.graph.dataEdges.some((e) => e.to.node === target && e.to.field === field)
1093
+ const add = (into: LinkItem[], label: string, connection: Connection) => {
1094
+ if (check(props.graph, connection).ok) into.push({ label, connection })
1095
+ }
1096
+ for (const other of props.graph.nodes) {
1097
+ if (other.id === node.id) continue
1098
+ const theirs = handlesOf(other)
1099
+ const name = menuName(other.id)
1100
+ for (const out of mine.triggerOuts) {
1101
+ const current = props.graph.triggerEdges.find(
1102
+ (e) => e.from.node === node.id && (e.from.branch ?? 'main') === out.name,
1103
+ )
1104
+ if (current?.to.node === other.id) continue
1105
+ // The output already leads somewhere: the menu says what goes.
1106
+ const replaces = current ? ` (${t('dms_automation.editor.canvas.link.replaces', { name: menuName(current.to.node) })})` : ''
1107
+ for (const into of theirs.triggerIns) {
1108
+ const branch = out.name === 'main' ? '' : `${out.name} `
1109
+ const port = into.name && into.name !== 'main' ? ` · ${into.name}` : ''
1110
+ add(next, `${branch}→ ${name}${port}${replaces}`, { source: node.id, sourceHandle: out.id, target: other.id, targetHandle: into.id })
1111
+ }
1112
+ }
1113
+ for (const out of mine.dataOuts) {
1114
+ for (const into of theirs.dataIns) {
1115
+ if (wired(other.id, into.name)) continue
1116
+ add(send, `${out.name} → ${name} · ${into.name}`, { source: node.id, sourceHandle: out.id, target: other.id, targetHandle: into.id })
1117
+ }
1118
+ }
1119
+ for (const out of theirs.dataOuts) {
1120
+ for (const into of mine.dataIns) {
1121
+ if (wired(node.id, into.name)) continue
1122
+ add(read, `${name} · ${out.name} → ${into.name}`, { source: other.id, sourceHandle: out.id, target: node.id, targetHandle: into.id })
1123
+ }
1124
+ }
1125
+ }
1126
+ const group = (key: string, items: LinkItem[]) =>
1127
+ items.length ? [{ type: 'label' as const, label: t(`dms_automation.editor.canvas.link.${key}`) }, ...items] : []
1128
+ return [group('next', next), group('send', send), group('read', read)].filter((g) => g.length > 0)
1129
+ })
1130
+
1131
+ // The link menu is offered for a single selected step of an editable graph.
1132
+ const canLink = computed(() => !props.readOnly && canvasSelection.value.length === 1)
1133
+
1134
+ // The menu is an action, not a field: it never keeps a value.
1135
+ const linkChoice = ref<LinkItem | null>(null)
1136
+ function onLink(item: LinkItem | null) {
1137
+ if (item?.connection) onConnect(item.connection)
1138
+ linkChoice.value = null
585
1139
  }
586
1140
 
587
1141
  // Multi-selection tracking — Vue Flow emits one NodeSelectionChange per
@@ -591,6 +1145,9 @@ function isValidConnection(conn: Connection): boolean {
591
1145
  // fold a sentinel into a new group). The single-node `select:node` event
592
1146
  // is preserved for the inspector (it expects exactly one node id).
593
1147
  const selectedNodeIds = new Set<string>()
1148
+ // The same set, reactive (sentinels included), for the toolbar's link menu
1149
+ // and the placement of new nodes.
1150
+ const canvasSelection = ref<string[]>([])
594
1151
 
595
1152
  // Drop any tracked ids that no longer exist in the current graph (e.g.
596
1153
  // after navigating to a different procedure / subgraph, or after the
@@ -614,6 +1171,7 @@ watch(
614
1171
  const n = nodes.find((nn) => nn.id === id)
615
1172
  return n ? !SENTINEL_KINDS.has(n.kind) : false
616
1173
  })
1174
+ canvasSelection.value = [...selectedNodeIds]
617
1175
  emit('selection-change', { ids })
618
1176
  }
619
1177
  },
@@ -631,10 +1189,13 @@ function onNodesChange(changes: NodeChange[]) {
631
1189
  // can show node details; suppress position drag and delete.
632
1190
  if (props.readOnly && c.type !== 'select') continue
633
1191
  if (c.type === 'position' && c.position) {
634
- const pos = c.position
635
- nextNodes = nextNodes.map((n) =>
636
- n.id === c.id ? { ...n, position: { x: pos.x, y: pos.y } } : n,
637
- )
1192
+ // Positions are stored as whole pixels, and a click that moves a
1193
+ // node by less than one (a select, not a drag) changes nothing:
1194
+ // otherwise selecting a node would count as an unsaved change.
1195
+ const pos = { x: Math.round(c.position.x), y: Math.round(c.position.y) }
1196
+ const current = nextNodes.find((n) => n.id === c.id)
1197
+ if (current && current.position.x === pos.x && current.position.y === pos.y) continue
1198
+ nextNodes = nextNodes.map((n) => (n.id === c.id ? { ...n, position: pos } : n))
638
1199
  changed = true
639
1200
  } else if (c.type === 'remove') {
640
1201
  // Sentinel nodes (groupInput / groupOutput) are auto-managed by
@@ -677,6 +1238,7 @@ function onNodesChange(changes: NodeChange[]) {
677
1238
  const n = props.graph.nodes.find((nn) => nn.id === id)
678
1239
  return n ? !SENTINEL_KINDS.has(n.kind) : false
679
1240
  })
1241
+ canvasSelection.value = [...selectedNodeIds]
680
1242
  emit('selection-change', { ids })
681
1243
  }
682
1244
 
@@ -729,6 +1291,18 @@ function onEdgesChange(changes: EdgeChange[]) {
729
1291
  }
730
1292
  }
731
1293
 
1294
+ // The DMS canvas deletes the selected nodes on Delete / Backspace, not the
1295
+ // selected links: remove those here (a deleted node takes its links along).
1296
+ function onKeydown(event: KeyboardEvent) {
1297
+ if (props.readOnly || (event.key !== 'Delete' && event.key !== 'Backspace')) return
1298
+ const target = event.target
1299
+ if (target instanceof HTMLElement && (target.isContentEditable || ['INPUT', 'TEXTAREA', 'SELECT'].includes(target.tagName))) return
1300
+ const flow = flowRef.value
1301
+ if (!flow || flow.getSelectedNodes.length > 0 || flow.getSelectedEdges.length === 0) return
1302
+ event.preventDefault()
1303
+ onEdgesChange(flow.getSelectedEdges.map((e) => ({ type: 'remove', id: e.id }) as EdgeChange))
1304
+ }
1305
+
732
1306
  // Edge-update flow (drag an existing edge's endpoint to reattach or delete):
733
1307
  // 1. @edge-update-start clears the success flag.
734
1308
  // 2. @edge-update fires only if the user drops on a valid target — mark
@@ -815,7 +1389,11 @@ function onEdgeUpdateEnd(payload: { event: MouseEvent; edge: VfEdge }) {
815
1389
 
816
1390
  <template>
817
1391
  <div
818
- class="graph-canvas-wrap relative w-full h-full border border-default rounded-lg overflow-hidden"
1392
+ ref="wrapRef"
1393
+ class="graph-canvas-wrap @container relative w-full h-full border border-default rounded-lg overflow-hidden"
1394
+ @keydown="onKeydown"
1395
+ @dragover="onDragOver"
1396
+ @drop="onDrop"
819
1397
  >
820
1398
  <DmsFlowCanvas
821
1399
  ref="flowRef"
@@ -829,7 +1407,12 @@ function onEdgeUpdateEnd(payload: { event: MouseEvent; edge: VfEdge }) {
829
1407
  :elements-selectable="true"
830
1408
  :edges-updatable="!readOnly"
831
1409
  :deletable-nodes="!readOnly"
1410
+ :fit-view-on-init="false"
1411
+ :min-zoom="MIN_ZOOM"
1412
+ :max-zoom="MAX_ZOOM"
1413
+ @nodes-initialized="onNodesInitialized"
832
1414
  @connect="onConnect"
1415
+ @connect-end="onConnectEnd"
833
1416
  @nodes-change="onNodesChange"
834
1417
  @delete-nodes="onDeleteNodes"
835
1418
  @edges-change="onEdgesChange"
@@ -838,90 +1421,96 @@ function onEdgeUpdateEnd(payload: { event: MouseEvent; edge: VfEdge }) {
838
1421
  @edge-update-end="onEdgeUpdateEnd"
839
1422
  @node-double-click="onNodeDoubleClick"
840
1423
  >
841
- <!-- Toolbar. While editable: Add Node / Undo / Redo / group
842
- actions / Cancel / Apply. Read-only template-instance view:
843
- only the group actions (Fork) survive, in a bare card. The two
844
- branches share DmsFlowCanvas's single `top-right` Panel slot. -->
845
- <template v-if="!readOnly || $slots.groupActions" #top-right>
846
- <div
847
- v-if="!readOnly"
848
- class="flex items-center gap-1 rounded-lg border border-default bg-elevated p-1 shadow-md flex-wrap"
849
- >
850
- <UButton
851
- size="sm"
852
- variant="ghost"
853
- color="neutral"
854
- icon="i-ph-arrow-counter-clockwise"
855
- :aria-label="$t('dms_automation.editor.canvas.undo')"
856
- :disabled="!canUndo"
857
- @click="emit('undo')"
858
- />
859
- <UButton
860
- size="sm"
861
- variant="ghost"
862
- color="neutral"
863
- icon="i-ph-arrow-clockwise"
864
- :aria-label="$t('dms_automation.editor.canvas.redo')"
865
- :disabled="!canRedo"
866
- @click="emit('redo')"
867
- />
868
- <!-- Group-related actions slotted in by Editor.vue: Group
869
- selection, Save as template, Fork to local group, Enter
870
- group. Kept inside the canvas toolbar so they sit next
871
- to Add Node / Undo / Redo instead of in a separate card. -->
872
- <template v-if="$slots.groupActions">
873
- <div class="w-px h-5 bg-default mx-1" />
874
- <slot name="groupActions" />
875
- </template>
876
- <div class="mx-1 h-5 w-px bg-default" />
877
- <UButton
878
- size="sm"
879
- variant="ghost"
880
- color="neutral"
881
- :label="$t('dms_automation.editor.canvas.cancel')"
882
- :disabled="!isDirty || applying"
883
- @click="emit('cancel')"
884
- />
885
- <UButton
886
- size="sm"
887
- color="primary"
888
- :label="$t('dms_automation.editor.canvas.apply')"
889
- :disabled="!isDirty"
890
- :loading="applying"
891
- @click="emit('apply')"
892
- />
893
- </div>
894
- <!-- Read-only fallback: Fork stays reachable from the
895
- template-instance inner-subgraph view. -->
896
- <div
897
- v-else-if="$slots.groupActions"
898
- class="flex items-center gap-1 rounded-lg border border-default bg-elevated p-1 shadow-md flex-wrap"
899
- >
900
- <slot name="groupActions" />
901
- </div>
902
- </template>
903
-
904
- <!-- The #top-left slot is provided UNCONDITIONALLY (inner v-if gates
905
- the content). DmsFlowCanvas computes its active panel positions
906
- once from a non-reactive useSlots() snapshot, so a panel slot
907
- added later (e.g. when a node is first selected) would never
908
- render. Providing it from first render keeps the inspector panel
909
- alive; it just shows nothing until a node is selected. The real
910
- fix belongs upstream in DmsFlowCanvas (make panel detection
911
- reactive); this is a consumer workaround. -->
1424
+ <!-- One row along the top edge: the breadcrumb (shrinks, truncated by
1425
+ its owner) and the toolbar (Undo / Redo, the link menu and the
1426
+ selection's group actions; saving lives in the editor's bar). A
1427
+ read-only template-instance view keeps only the group actions
1428
+ (Fork). The row lets pointer events through between the two.
1429
+ Provided unconditionally: DmsFlowCanvas reads its panel slots
1430
+ once, so a slot added later would never render. -->
912
1431
  <template #top-left>
913
- <div
914
- v-if="$slots.inspector"
915
- class="w-[320px] max-h-[calc(100vh-16rem)] overflow-y-auto shadow-md rounded-lg"
916
- >
917
- <slot name="inspector" />
1432
+ <div class="pointer-events-none flex w-[calc(100cqw-1.5rem)] items-start justify-between gap-2">
1433
+ <!-- The breadcrumb takes what the toolbar leaves (6rem at least),
1434
+ the toolbar wraps only past that. -->
1435
+ <div class="min-w-24 flex-1 basis-0">
1436
+ <div class="pointer-events-auto w-fit max-w-full">
1437
+ <slot name="breadcrumb" />
1438
+ </div>
1439
+ </div>
1440
+ <div
1441
+ v-if="canLink || $slots.groupActions"
1442
+ class="pointer-events-auto flex min-w-0 flex-wrap items-center justify-end gap-1 rounded-lg border border-default bg-elevated p-1 shadow-md"
1443
+ >
1444
+ <template v-if="canLink">
1445
+ <!-- Links the selected step can make, for keyboard users: an
1446
+ icon, so the row stays on one line. -->
1447
+ <UTooltip :text="$t('dms_automation.editor.canvas.link.label')">
1448
+ <USelectMenu
1449
+ :model-value="linkChoice"
1450
+ :items="linkGroups"
1451
+ size="sm"
1452
+ variant="ghost"
1453
+ icon="i-ph-flow-arrow"
1454
+ :aria-label="$t('dms_automation.editor.canvas.link.label')"
1455
+ :search-input="{ placeholder: $t('dms_automation.editor.canvas.link.search') }"
1456
+ :content="{ align: 'end' }"
1457
+ :ui="{ content: 'min-w-72', base: 'ps-1.5 pe-1.5', leading: 'static p-0', placeholder: 'hidden', trailing: 'hidden' }"
1458
+ @update:model-value="onLink"
1459
+ >
1460
+ <template #empty>
1461
+ {{ $t('dms_automation.editor.canvas.link.empty') }}
1462
+ </template>
1463
+ </USelectMenu>
1464
+ </UTooltip>
1465
+ <div v-if="$slots.groupActions" class="mx-1 h-5 w-px bg-default" />
1466
+ </template>
1467
+ <!-- Group-related actions slotted in by Editor.vue: Group
1468
+ selection, Save as template, Fork to local group, Enter
1469
+ group. -->
1470
+ <slot name="groupActions" />
1471
+ </div>
918
1472
  </div>
919
1473
  </template>
920
1474
 
921
1475
  <template #bottom-center>
1476
+ <p
1477
+ v-if="refusalShown"
1478
+ role="status"
1479
+ class="mx-auto mb-2 flex w-fit max-w-sm items-center gap-1.5 rounded-md border border-warning/40 bg-elevated px-2 py-1 text-xs text-warning shadow-md"
1480
+ >
1481
+ <UIcon name="i-ph-prohibit" class="size-3.5 shrink-0" />
1482
+ {{ refusal }}
1483
+ </p>
922
1484
  <div
923
- class="flex items-center gap-1 rounded-lg border border-default bg-elevated p-1 shadow-md"
1485
+ class="mx-auto flex w-fit items-center gap-1 rounded-lg border border-default bg-elevated p-1 shadow-md"
924
1486
  >
1487
+ <!-- Undo / Redo sit with the view controls, leaving the top row
1488
+ to the selection's actions. -->
1489
+ <template v-if="!readOnly">
1490
+ <UTooltip :text="$t('dms_automation.editor.canvas.undo')" :kbds="['meta', 'z']">
1491
+ <UButton
1492
+ size="sm"
1493
+ variant="ghost"
1494
+ color="neutral"
1495
+ icon="i-ph-arrow-counter-clockwise"
1496
+ :aria-label="$t('dms_automation.editor.canvas.undo')"
1497
+ :disabled="!canUndo"
1498
+ @click="emit('undo')"
1499
+ />
1500
+ </UTooltip>
1501
+ <UTooltip :text="$t('dms_automation.editor.canvas.redo')" :kbds="['meta', 'shift', 'z']">
1502
+ <UButton
1503
+ size="sm"
1504
+ variant="ghost"
1505
+ color="neutral"
1506
+ icon="i-ph-arrow-clockwise"
1507
+ :aria-label="$t('dms_automation.editor.canvas.redo')"
1508
+ :disabled="!canRedo"
1509
+ @click="emit('redo')"
1510
+ />
1511
+ </UTooltip>
1512
+ <div class="mx-1 h-5 w-px bg-default" />
1513
+ </template>
925
1514
  <UButton
926
1515
  size="sm"
927
1516
  variant="ghost"
@@ -953,7 +1542,7 @@ function onEdgeUpdateEnd(payload: { event: MouseEvent; edge: VfEdge }) {
953
1542
  color="neutral"
954
1543
  icon="i-ph-arrows-out"
955
1544
  :aria-label="$t('dms_automation.editor.canvas.fitView')"
956
- @click="flowRef?.fitView()"
1545
+ @click="fitView"
957
1546
  />
958
1547
  </div>
959
1548
  </template>
@@ -962,33 +1551,59 @@ function onEdgeUpdateEnd(payload: { event: MouseEvent; edge: VfEdge }) {
962
1551
  </template>
963
1552
 
964
1553
  <style>
965
- /* DmsFlowCanvas imports the @vue-flow core/theme/controls/minimap CSS itself,
966
- so we only ship the editor's business edge palette here: trigger edges
967
- (control flow) read cyan, data edges (data flow) read green-dashed. The
968
- `.edge-*` class out-specifies DmsFlowCanvas's generic `.vue-flow__edge-path`
969
- rule, so these win without `!important`. */
1554
+ /* The top row spans the canvas: between the breadcrumb and the toolbar, the
1555
+ pane under it stays draggable. Vue Flow sets the panel's pointer-events
1556
+ inline, hence the !important. */
1557
+ .graph-canvas-wrap .vue-flow__panel.top.left {
1558
+ pointer-events: none !important;
1559
+ }
1560
+
1561
+ /* Ports keep their small dot but take a 24px target (WCAG 2.5.8). */
1562
+ .dms-automation-node .vue-flow__handle::before {
1563
+ content: '';
1564
+ position: absolute;
1565
+ inset: -8px;
1566
+ border-radius: 9999px;
1567
+ }
1568
+
1569
+ /* Trigger edges (control flow) take the info role, data edges the success
1570
+ role, dashed; theme tokens only (AU-15). The `.edge-*` class out-specifies
1571
+ DmsFlowCanvas's generic `.vue-flow__edge-path` rule. */
970
1572
  .vue-flow__edge.edge-trigger .vue-flow__edge-path {
971
- stroke: #2dc1cf;
1573
+ stroke: var(--ui-info);
972
1574
  stroke-width: 2;
973
1575
  }
974
1576
 
975
1577
  .vue-flow__edge.edge-data .vue-flow__edge-path {
976
- stroke: #10b981;
1578
+ stroke: var(--ui-success);
977
1579
  stroke-width: 2;
978
1580
  stroke-dasharray: 4 4;
979
1581
  }
980
1582
 
981
- /* Selected / focused edge highlight (amber). The doubled `.edge-*` class lifts
982
- specificity above DmsFlowCanvas's own `.dms-flow-canvas .vue-flow__edge.selected`
983
- rule, which would otherwise repaint the edge in the DMS accent and erase the
984
- trigger-vs-data distinction. */
1583
+ .vue-flow__edge.edge-trigger.edge-taken .vue-flow__edge-path {
1584
+ stroke: var(--ui-success);
1585
+ stroke-width: 2.5;
1586
+ }
1587
+
1588
+ .vue-flow__edge.edge-trigger.edge-failed .vue-flow__edge-path {
1589
+ stroke: var(--ui-error);
1590
+ stroke-width: 2.5;
1591
+ }
1592
+
1593
+ .vue-flow__edge.edge-trigger.edge-idle .vue-flow__edge-path {
1594
+ opacity: 0.35;
1595
+ }
1596
+
1597
+ /* Selected / focused edge highlight. The doubled `.edge-*` class lifts
1598
+ specificity above DmsFlowCanvas's own selected rule, which would repaint the
1599
+ edge in the accent and erase the trigger-vs-data distinction. */
985
1600
  .vue-flow__edge.edge-trigger.selected .vue-flow__edge-path,
986
1601
  .vue-flow__edge.edge-data.selected .vue-flow__edge-path,
987
1602
  .vue-flow__edge.edge-trigger:focus .vue-flow__edge-path,
988
1603
  .vue-flow__edge.edge-data:focus .vue-flow__edge-path,
989
1604
  .vue-flow__edge.edge-trigger:focus-visible .vue-flow__edge-path,
990
1605
  .vue-flow__edge.edge-data:focus-visible .vue-flow__edge-path {
991
- stroke: #f59e0b;
1606
+ stroke: var(--ui-warning);
992
1607
  stroke-width: 3;
993
1608
  }
994
1609
  </style>