@iblai/iblai-js 2.70.0 → 2.71.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.
- package/dist/web-containers/source/_virtual/index2.js +2 -2
- package/dist/web-containers/source/_virtual/index3.js +2 -2
- package/dist/web-containers/source/chat-input-form/use-overflow-fit.js +7 -5
- package/dist/web-containers/source/chat-input-form/use-overflow-fit.js.map +1 -1
- package/dist/web-containers/source/classifier-panel.js +401 -0
- package/dist/web-containers/source/classifier-panel.js.map +1 -0
- package/dist/web-containers/source/components/chat-input-form/use-overflow-fit.js +7 -5
- package/dist/web-containers/source/components/chat-input-form/use-overflow-fit.js.map +1 -1
- package/dist/web-containers/source/components/mentors/mentor-selection-grid.js +5 -2
- package/dist/web-containers/source/components/mentors/mentor-selection-grid.js.map +1 -1
- package/dist/web-containers/source/components/modals/user-profile-modal.js +3 -0
- package/dist/web-containers/source/components/modals/user-profile-modal.js.map +1 -1
- package/dist/web-containers/source/components/workflows/classifier-panel.js +401 -0
- package/dist/web-containers/source/components/workflows/classifier-panel.js.map +1 -0
- package/dist/web-containers/source/components/workflows/delete-workflow-modal.js +4 -3
- package/dist/web-containers/source/components/workflows/delete-workflow-modal.js.map +1 -1
- package/dist/web-containers/source/components/workflows/insert-reference.js +81 -0
- package/dist/web-containers/source/components/workflows/insert-reference.js.map +1 -0
- package/dist/web-containers/source/components/workflows/node-config-panel.js +135 -71
- package/dist/web-containers/source/components/workflows/node-config-panel.js.map +1 -1
- package/dist/web-containers/source/components/workflows/panel-fields.js +125 -0
- package/dist/web-containers/source/components/workflows/panel-fields.js.map +1 -0
- package/dist/web-containers/source/components/workflows/shortcuts.js +77 -0
- package/dist/web-containers/source/components/workflows/shortcuts.js.map +1 -0
- package/dist/web-containers/source/components/workflows/tool-dialogs.js +11 -11
- package/dist/web-containers/source/components/workflows/tool-dialogs.js.map +1 -1
- package/dist/web-containers/source/components/workflows/workflow-canvas.js +874 -278
- package/dist/web-containers/source/components/workflows/workflow-canvas.js.map +1 -1
- package/dist/web-containers/source/components/workflows/workflow-definition.js +220 -8
- package/dist/web-containers/source/components/workflows/workflow-definition.js.map +1 -1
- package/dist/web-containers/source/components/workflows/workflow-editor.js +495 -84
- package/dist/web-containers/source/components/workflows/workflow-editor.js.map +1 -1
- package/dist/web-containers/source/components/workflows/workflow-preview-chat.js +4 -0
- package/dist/web-containers/source/components/workflows/workflow-preview-chat.js.map +1 -1
- package/dist/web-containers/source/components/workflows/workflow-sidebar.js +6 -11
- package/dist/web-containers/source/components/workflows/workflow-sidebar.js.map +1 -1
- package/dist/web-containers/source/components/workflows/workflow-switch.js +13 -0
- package/dist/web-containers/source/components/workflows/workflow-switch.js.map +1 -0
- package/dist/web-containers/source/components/workflows/workflow-textarea.js +168 -0
- package/dist/web-containers/source/components/workflows/workflow-textarea.js.map +1 -0
- package/dist/web-containers/source/delete-workflow-modal.js +4 -3
- package/dist/web-containers/source/delete-workflow-modal.js.map +1 -1
- package/dist/web-containers/source/en.json.js +138 -9
- package/dist/web-containers/source/en.json.js.map +1 -1
- package/dist/web-containers/source/es.json.js +135 -6
- package/dist/web-containers/source/es.json.js.map +1 -1
- package/dist/web-containers/source/fr.json.js +135 -6
- package/dist/web-containers/source/fr.json.js.map +1 -1
- package/dist/web-containers/source/i18n/messages/en.json.js +138 -9
- package/dist/web-containers/source/i18n/messages/en.json.js.map +1 -1
- package/dist/web-containers/source/i18n/messages/es.json.js +135 -6
- package/dist/web-containers/source/i18n/messages/es.json.js.map +1 -1
- package/dist/web-containers/source/i18n/messages/fr.json.js +135 -6
- package/dist/web-containers/source/i18n/messages/fr.json.js.map +1 -1
- package/dist/web-containers/source/i18n/messages/zh.json.js +135 -6
- package/dist/web-containers/source/i18n/messages/zh.json.js.map +1 -1
- package/dist/web-containers/source/index2.js +2 -2
- package/dist/web-containers/source/index3.js +2 -2
- package/dist/web-containers/source/insert-reference.js +81 -0
- package/dist/web-containers/source/insert-reference.js.map +1 -0
- package/dist/web-containers/source/mentor-selection-grid.js +5 -2
- package/dist/web-containers/source/mentor-selection-grid.js.map +1 -1
- package/dist/web-containers/source/mentors/mentor-selection-grid.js +5 -2
- package/dist/web-containers/source/mentors/mentor-selection-grid.js.map +1 -1
- package/dist/web-containers/source/messages/en.json.js +138 -9
- package/dist/web-containers/source/messages/en.json.js.map +1 -1
- package/dist/web-containers/source/messages/es.json.js +135 -6
- package/dist/web-containers/source/messages/es.json.js.map +1 -1
- package/dist/web-containers/source/messages/fr.json.js +135 -6
- package/dist/web-containers/source/messages/fr.json.js.map +1 -1
- package/dist/web-containers/source/messages/zh.json.js +135 -6
- package/dist/web-containers/source/messages/zh.json.js.map +1 -1
- package/dist/web-containers/source/modals/user-profile-modal.js +3 -0
- package/dist/web-containers/source/modals/user-profile-modal.js.map +1 -1
- package/dist/web-containers/source/node-config-panel.js +135 -71
- package/dist/web-containers/source/node-config-panel.js.map +1 -1
- package/dist/web-containers/source/node_modules/.pnpm/css-mediaquery@0.1.2/node_modules/css-mediaquery/index.js +1 -1
- package/dist/web-containers/source/node_modules/.pnpm/matchmediaquery@0.4.2/node_modules/matchmediaquery/index.js +1 -1
- package/dist/web-containers/source/node_modules/.pnpm/prop-types@15.8.1/node_modules/prop-types/index.js +1 -1
- package/dist/web-containers/source/panel-fields.js +125 -0
- package/dist/web-containers/source/panel-fields.js.map +1 -0
- package/dist/web-containers/source/shortcuts.js +77 -0
- package/dist/web-containers/source/shortcuts.js.map +1 -0
- package/dist/web-containers/source/tool-dialogs.js +11 -11
- package/dist/web-containers/source/tool-dialogs.js.map +1 -1
- package/dist/web-containers/source/tsconfig.build.tsbuildinfo +1 -1
- package/dist/web-containers/source/use-overflow-fit.js +7 -5
- package/dist/web-containers/source/use-overflow-fit.js.map +1 -1
- package/dist/web-containers/source/user-profile-modal.js +3 -0
- package/dist/web-containers/source/user-profile-modal.js.map +1 -1
- package/dist/web-containers/source/web-containers/tsconfig.build.tsbuildinfo +1 -1
- package/dist/web-containers/source/workflow-canvas.js +874 -278
- package/dist/web-containers/source/workflow-canvas.js.map +1 -1
- package/dist/web-containers/source/workflow-definition.js +220 -8
- package/dist/web-containers/source/workflow-definition.js.map +1 -1
- package/dist/web-containers/source/workflow-editor.js +495 -84
- package/dist/web-containers/source/workflow-editor.js.map +1 -1
- package/dist/web-containers/source/workflow-preview-chat.js +4 -0
- package/dist/web-containers/source/workflow-preview-chat.js.map +1 -1
- package/dist/web-containers/source/workflow-sidebar.js +6 -11
- package/dist/web-containers/source/workflow-sidebar.js.map +1 -1
- package/dist/web-containers/source/workflow-switch.js +13 -0
- package/dist/web-containers/source/workflow-switch.js.map +1 -0
- package/dist/web-containers/source/workflow-textarea.js +168 -0
- package/dist/web-containers/source/workflow-textarea.js.map +1 -0
- package/dist/web-containers/source/workflows/classifier-panel.js +401 -0
- package/dist/web-containers/source/workflows/classifier-panel.js.map +1 -0
- package/dist/web-containers/source/workflows/delete-workflow-modal.js +4 -3
- package/dist/web-containers/source/workflows/delete-workflow-modal.js.map +1 -1
- package/dist/web-containers/source/workflows/insert-reference.js +81 -0
- package/dist/web-containers/source/workflows/insert-reference.js.map +1 -0
- package/dist/web-containers/source/workflows/node-config-panel.js +135 -71
- package/dist/web-containers/source/workflows/node-config-panel.js.map +1 -1
- package/dist/web-containers/source/workflows/panel-fields.js +125 -0
- package/dist/web-containers/source/workflows/panel-fields.js.map +1 -0
- package/dist/web-containers/source/workflows/shortcuts.js +77 -0
- package/dist/web-containers/source/workflows/shortcuts.js.map +1 -0
- package/dist/web-containers/source/workflows/tool-dialogs.js +11 -11
- package/dist/web-containers/source/workflows/tool-dialogs.js.map +1 -1
- package/dist/web-containers/source/workflows/workflow-canvas.js +874 -278
- package/dist/web-containers/source/workflows/workflow-canvas.js.map +1 -1
- package/dist/web-containers/source/workflows/workflow-definition.js +220 -8
- package/dist/web-containers/source/workflows/workflow-definition.js.map +1 -1
- package/dist/web-containers/source/workflows/workflow-editor.js +495 -84
- package/dist/web-containers/source/workflows/workflow-editor.js.map +1 -1
- package/dist/web-containers/source/workflows/workflow-preview-chat.js +4 -0
- package/dist/web-containers/source/workflows/workflow-preview-chat.js.map +1 -1
- package/dist/web-containers/source/workflows/workflow-sidebar.js +6 -11
- package/dist/web-containers/source/workflows/workflow-sidebar.js.map +1 -1
- package/dist/web-containers/source/workflows/workflow-switch.js +13 -0
- package/dist/web-containers/source/workflows/workflow-switch.js.map +1 -0
- package/dist/web-containers/source/workflows/workflow-textarea.js +168 -0
- package/dist/web-containers/source/workflows/workflow-textarea.js.map +1 -0
- package/dist/web-containers/source/zh.json.js +135 -6
- package/dist/web-containers/source/zh.json.js.map +1 -1
- package/package.json +5 -5
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
|
-
import { useState, useMemo, useEffect, useRef, useCallback } from 'react';
|
|
2
|
+
import { useState, useMemo, useEffect, useRef, useCallback, Fragment as Fragment$1 } from 'react';
|
|
3
3
|
import { useT } from '../../i18n/context.js';
|
|
4
4
|
import '../../packages/i18n/dist/index.esm.js';
|
|
5
5
|
import { Button } from '../ui/button.js';
|
|
6
6
|
import { Input } from '../ui/input.js';
|
|
7
7
|
import { WorkflowPreviewChat } from './workflow-preview-chat.js';
|
|
8
8
|
import { WorkflowCanvas } from './workflow-canvas.js';
|
|
9
|
-
import { migrateWorkflowDefinition, withoutNoteConnectivityWarnings } from './workflow-definition.js';
|
|
9
|
+
import { IBLAI_DECISION_MODEL, migrateWorkflowDefinition, isAuthoredInstructions, withoutNoteConnectivityWarnings, startVariableDefaults, CLASSIFIER_HANDLES } from './workflow-definition.js';
|
|
10
|
+
import { useOverflowFit } from '../chat-input-form/use-overflow-fit.js';
|
|
11
|
+
import { ActionTooltip } from './action-tooltip.js';
|
|
12
|
+
import { ariaShortcut, withShortcut } from './shortcuts.js';
|
|
10
13
|
import { WorkflowSidebar } from './workflow-sidebar.js';
|
|
11
14
|
import { DeleteWorkflowModal } from './delete-workflow-modal.js';
|
|
12
|
-
import { useGetWorkflowQuery, useGetNodeTypesQuery, useLazyGetMentorSettingsQuery, usePatchWorkflowMutation, usePublishWorkflowMutation, useDeactivateWorkflowMutation, useValidateWorkflowMutation, useActivateWorkflowMutation, useDeleteWorkflowMutation } from '@iblai/data-layer';
|
|
13
|
-
import { DropdownMenu, DropdownMenuTrigger, DropdownMenuContent
|
|
15
|
+
import { useGetWorkflowQuery, useGetNodeTypesQuery, useLazyGetMentorSettingsQuery, usePatchWorkflowMutation, usePublishWorkflowMutation, useDeactivateWorkflowMutation, useValidateWorkflowMutation, useActivateWorkflowMutation, useDeleteWorkflowMutation, useTestWorkflowClassifierMutation } from '@iblai/data-layer';
|
|
16
|
+
import { DropdownMenuItem, DropdownMenu, DropdownMenuTrigger, DropdownMenuContent } from '../ui/dropdown-menu.js';
|
|
14
17
|
import { Collapsible, CollapsibleTrigger, CollapsibleContent } from '../ui/collapsible.js';
|
|
18
|
+
import { Sheet, SheetContent, SheetHeader, SheetTitle, SheetDescription } from '../ui/sheet.js';
|
|
15
19
|
import { toast } from 'sonner';
|
|
16
20
|
import { useDebounce as a } from '../../node_modules/.pnpm/use-debounce@10.0.4_react@19.1.0/node_modules/use-debounce/dist/index.module.js';
|
|
17
21
|
import LoaderCircle from '../../node_modules/.pnpm/lucide-react@0.528.0_react@19.1.0/node_modules/lucide-react/dist/esm/icons/loader-circle.js';
|
|
@@ -20,13 +24,17 @@ import ChevronLeft from '../../node_modules/.pnpm/lucide-react@0.528.0_react@19.
|
|
|
20
24
|
import Pencil from '../../node_modules/.pnpm/lucide-react@0.528.0_react@19.1.0/node_modules/lucide-react/dist/esm/icons/pencil.js';
|
|
21
25
|
import X from '../../node_modules/.pnpm/lucide-react@0.528.0_react@19.1.0/node_modules/lucide-react/dist/esm/icons/x.js';
|
|
22
26
|
import RotateCcw from '../../node_modules/.pnpm/lucide-react@0.528.0_react@19.1.0/node_modules/lucide-react/dist/esm/icons/rotate-ccw.js';
|
|
23
|
-
import
|
|
27
|
+
import Eye from '../../node_modules/.pnpm/lucide-react@0.528.0_react@19.1.0/node_modules/lucide-react/dist/esm/icons/eye.js';
|
|
24
28
|
import Power from '../../node_modules/.pnpm/lucide-react@0.528.0_react@19.1.0/node_modules/lucide-react/dist/esm/icons/power.js';
|
|
25
29
|
import Trash2 from '../../node_modules/.pnpm/lucide-react@0.528.0_react@19.1.0/node_modules/lucide-react/dist/esm/icons/trash-2.js';
|
|
26
|
-
import
|
|
27
|
-
import
|
|
30
|
+
import Save from '../../node_modules/.pnpm/lucide-react@0.528.0_react@19.1.0/node_modules/lucide-react/dist/esm/icons/save.js';
|
|
31
|
+
import Upload from '../../node_modules/.pnpm/lucide-react@0.528.0_react@19.1.0/node_modules/lucide-react/dist/esm/icons/upload.js';
|
|
32
|
+
import Ellipsis from '../../node_modules/.pnpm/lucide-react@0.528.0_react@19.1.0/node_modules/lucide-react/dist/esm/icons/ellipsis.js';
|
|
33
|
+
import ListChecks from '../../node_modules/.pnpm/lucide-react@0.528.0_react@19.1.0/node_modules/lucide-react/dist/esm/icons/list-checks.js';
|
|
28
34
|
import ChevronUp from '../../node_modules/.pnpm/lucide-react@0.528.0_react@19.1.0/node_modules/lucide-react/dist/esm/icons/chevron-up.js';
|
|
29
35
|
import ChevronDown from '../../node_modules/.pnpm/lucide-react@0.528.0_react@19.1.0/node_modules/lucide-react/dist/esm/icons/chevron-down.js';
|
|
36
|
+
import TriangleAlert from '../../node_modules/.pnpm/lucide-react@0.528.0_react@19.1.0/node_modules/lucide-react/dist/esm/icons/triangle-alert.js';
|
|
37
|
+
import Plus from '../../node_modules/.pnpm/lucide-react@0.528.0_react@19.1.0/node_modules/lucide-react/dist/esm/icons/plus.js';
|
|
30
38
|
|
|
31
39
|
function getCategoryConfig(t) {
|
|
32
40
|
return {
|
|
@@ -39,25 +47,228 @@ function getCategoryConfig(t) {
|
|
|
39
47
|
const nodeCategoryOverride = {
|
|
40
48
|
note: 'core', // API has it in 'visual' but UI shows it in 'Core'
|
|
41
49
|
};
|
|
42
|
-
|
|
43
|
-
|
|
50
|
+
function stepsOf(nodes) {
|
|
51
|
+
const byId = new Map(nodes.map((node) => [node.id, node]));
|
|
52
|
+
return { find: (id) => byId.get(id), at: (index) => nodes[index] };
|
|
53
|
+
}
|
|
54
|
+
const stepName = (steps, id) => { var _a, _b; return ((_b = (_a = steps.find(id)) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.label) || id; };
|
|
55
|
+
const BRANCH_NAME_KEYS = new Map([
|
|
56
|
+
[CLASSIFIER_HANDLES.yes, 'workflowsWorkflowCanvas.classifierYes'],
|
|
57
|
+
[CLASSIFIER_HANDLES.no, 'workflowsWorkflowCanvas.classifierNo'],
|
|
58
|
+
[CLASSIFIER_HANDLES.next, 'workflowsWorkflowCanvas.classifierNext'],
|
|
59
|
+
[CLASSIFIER_HANDLES.fallback, 'workflowsWorkflowCanvas.classifierFallback'],
|
|
60
|
+
]);
|
|
61
|
+
function branchName(step, handle, t) {
|
|
62
|
+
var _a, _b;
|
|
63
|
+
const category = (_b = (_a = step === null || step === void 0 ? void 0 : step.data) === null || _a === void 0 ? void 0 : _a.categories) === null || _b === void 0 ? void 0 : _b.find((candidate) => candidate.id === handle);
|
|
64
|
+
if (category === null || category === void 0 ? void 0 : category.label)
|
|
65
|
+
return category.label;
|
|
66
|
+
const key = BRANCH_NAME_KEYS.get(handle);
|
|
67
|
+
return key ? t(key) : handle;
|
|
68
|
+
}
|
|
69
|
+
// The backend words these in terms of mentors and internal step ids, and
|
|
70
|
+
// repeats the runtime and entry-agent checks once per Agent step.
|
|
44
71
|
const MENTOR_MESSAGES = [
|
|
45
|
-
|
|
46
|
-
/^Mentor existence will be validated at runtime/,
|
|
47
|
-
'workflowsWorkflowEditor.agentCheckedAtRuntime',
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
'
|
|
52
|
-
|
|
72
|
+
{
|
|
73
|
+
pattern: /^Mentor existence will be validated at runtime/,
|
|
74
|
+
key: 'workflowsWorkflowEditor.agentCheckedAtRuntime',
|
|
75
|
+
aboutEveryStep: true,
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
pattern: /^Node 'mentor' missing required field 'mentor_id'/,
|
|
79
|
+
key: 'workflowsWorkflowEditor.agentStepMissingAgent',
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
pattern: /^Mentor step needs a mentor/,
|
|
83
|
+
key: 'workflowsWorkflowEditor.agentStepMissingAgent',
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
pattern: /^A mentor step cannot use this workflow's own entry mentor/,
|
|
87
|
+
key: 'workflowsWorkflowEditor.agentStepUsesEntryAgent',
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
pattern: /^Mentor step '(.+?)' uses a mentor that does not exist on this platform/,
|
|
91
|
+
key: 'workflowsWorkflowEditor.agentStepAgentMissing',
|
|
92
|
+
params: (match, steps) => ({ name: stepName(steps, match[1]) }),
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
pattern: /^Mentor step 'output_variable' must start with a letter/,
|
|
96
|
+
key: 'workflowsWorkflowEditor.agentStepOutputVariableInvalid',
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
pattern: /^Classifier '(.+?)' route '(.+?)' goes straight to End/,
|
|
100
|
+
key: 'workflowsWorkflowEditor.classifierRouteToEnd',
|
|
101
|
+
params: (match, steps, t) => ({
|
|
102
|
+
name: stepName(steps, match[1]),
|
|
103
|
+
path: branchName(steps.find(match[1]), match[2], t),
|
|
104
|
+
}),
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
// Only the nodes[<index>] location says which step stores the variable.
|
|
108
|
+
pattern: /^(?:Mentor step|Classifier) 'output_variable' '(.+?)' is a variable .+? \('(.+?)'\); this step replaces it with its result at nodes\[(\d+)\]\.data\b/,
|
|
109
|
+
key: 'workflowsWorkflowEditor.outputVariableClash',
|
|
110
|
+
params: (match, steps) => {
|
|
111
|
+
var _a;
|
|
112
|
+
const step = steps.at(Number(match[3]));
|
|
113
|
+
if (!step)
|
|
114
|
+
return null;
|
|
115
|
+
return {
|
|
116
|
+
name: ((_a = step.data) === null || _a === void 0 ? void 0 : _a.label) || step.id,
|
|
117
|
+
variable: match[1],
|
|
118
|
+
setter: stepName(steps, match[2]),
|
|
119
|
+
};
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
pattern: /^(?:Mentor step|Classifier) 'output_variable' '(.+?)' is a variable .+? \('(.+?)'\); this step replaces it/,
|
|
124
|
+
key: 'workflowsWorkflowEditor.outputVariableClashUnknownStep',
|
|
125
|
+
params: (match, steps) => ({ variable: match[1], setter: stepName(steps, match[2]) }),
|
|
126
|
+
locationOnly: true,
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
// The model is named as resolved, so "ibl.ai Default" shows up as a slug
|
|
130
|
+
// the author never picked; staff switch decision models on per deployment.
|
|
131
|
+
pattern: /^Classifier '(.+?)' uses '.+?', (?:and ':|which isn't an enabled|which is not a decision)/,
|
|
132
|
+
key: 'workflowsWorkflowEditor.classifierModelUnavailable',
|
|
133
|
+
params: (match, steps) => ({ name: stepName(steps, match[1]) }),
|
|
134
|
+
},
|
|
53
135
|
];
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
136
|
+
// The backend ends each message with where it found the problem, e.g.
|
|
137
|
+
// "at nodes[2].data (field: instructions)" or "at workflow_loops (field: edges)".
|
|
138
|
+
const NODE_LOCATION = / at nodes\[(\d+)\](\.data)?(?: \(field: ([^()]+)\))?$/;
|
|
139
|
+
const WORKFLOW_LOCATION = / at workflow_\w+(?: \(field: [^()]+\))?$/;
|
|
140
|
+
const QUOTED = /'([^'\s]+)'/g;
|
|
141
|
+
function problemTarget(message, steps, locationOnly = false) {
|
|
142
|
+
if (WORKFLOW_LOCATION.test(message))
|
|
143
|
+
return {};
|
|
144
|
+
// The location names the step at fault; a quoted id in the same message can
|
|
145
|
+
// be another step, such as the one that also sets a variable.
|
|
146
|
+
const location = NODE_LOCATION.exec(message);
|
|
147
|
+
if (location) {
|
|
148
|
+
const step = steps.at(Number(location[1]));
|
|
149
|
+
if (!step)
|
|
150
|
+
return {};
|
|
151
|
+
// Outside the step's data the field is its id or type, which no setting shows.
|
|
152
|
+
const field = location[2] ? location[3] : undefined;
|
|
153
|
+
return field ? { stepId: step.id, field } : { stepId: step.id };
|
|
154
|
+
}
|
|
155
|
+
if (locationOnly)
|
|
156
|
+
return {};
|
|
157
|
+
for (const [, quoted] of message.matchAll(QUOTED)) {
|
|
158
|
+
if (steps.find(quoted))
|
|
159
|
+
return { stepId: quoted };
|
|
160
|
+
}
|
|
161
|
+
return {};
|
|
162
|
+
}
|
|
163
|
+
function toProblem(message, t, steps) {
|
|
164
|
+
for (const { pattern, key, params, aboutEveryStep, locationOnly } of MENTOR_MESSAGES) {
|
|
165
|
+
const match = pattern.exec(message);
|
|
166
|
+
if (!match)
|
|
167
|
+
continue;
|
|
168
|
+
const values = params === null || params === void 0 ? void 0 : params(match, steps, t);
|
|
169
|
+
if (values === null)
|
|
170
|
+
continue;
|
|
171
|
+
const text = t(key, values);
|
|
172
|
+
return aboutEveryStep ? { text } : { text, ...problemTarget(message, steps, locationOnly) };
|
|
173
|
+
}
|
|
174
|
+
return { text: message, ...problemTarget(message, steps) };
|
|
175
|
+
}
|
|
176
|
+
const distinct = (lines) => Array.from(new Set(lines));
|
|
177
|
+
// A repeated line shows once and goes to the first step it was reported for;
|
|
178
|
+
// once that step is fixed, the next check moves it to the next one.
|
|
179
|
+
const distinctProblems = (problems) => problems.filter((problem, index) => problems.findIndex((other) => other.text === problem.text) === index);
|
|
180
|
+
const PROBLEM_LINK = 'cursor-pointer text-left underline-offset-2 hover:underline focus-visible:underline focus-visible:outline-none';
|
|
181
|
+
// A placeholder line's first group becomes {placeholder}, quotes included.
|
|
182
|
+
const CLASSIFIER_TRY_MESSAGES = [
|
|
183
|
+
{
|
|
184
|
+
pattern: /^Classifier needs instructions/,
|
|
185
|
+
key: 'workflowsClassifierPanel.instructionsRequired',
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
pattern: /^Category \d+ needs a 'label'/,
|
|
189
|
+
key: 'workflowsClassifierPanel.tryErrorCategoryLabel',
|
|
190
|
+
},
|
|
191
|
+
{ pattern: /^Level \d+ needs a 'label'/, key: 'workflowsClassifierPanel.tryErrorLevelLabel' },
|
|
192
|
+
{ pattern: /^Duplicate level label/, key: 'workflowsClassifierPanel.tryErrorDuplicateLevel' },
|
|
193
|
+
{
|
|
194
|
+
pattern: /^('\{\{[^{}]+\}\}') names no step/,
|
|
195
|
+
key: 'workflowsClassifierPanel.tryErrorPlaceholderStep',
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
pattern: /^('\{\{[^{}]+\}\}') is not a valid variable name/,
|
|
199
|
+
key: 'workflowsClassifierPanel.tryErrorPlaceholderVariableName',
|
|
200
|
+
},
|
|
201
|
+
{
|
|
202
|
+
pattern: /^('\{\{[^{}]+\}\}') names a variable the Start node does not declare/,
|
|
203
|
+
key: 'workflowsClassifierPanel.tryErrorPlaceholderUnknownVariable',
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
pattern: /^('\{\{[^{}]+\}\}') is not a placeholder/,
|
|
207
|
+
key: 'workflowsClassifierPanel.tryErrorNotPlaceholder',
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
pattern: /^('\{\{[^{}]+\}\}') is always empty/,
|
|
211
|
+
key: 'workflowsClassifierPanel.tryErrorPlaceholderEmpty',
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
pattern: /^Example \d+ needs 'text' and a 'category'/,
|
|
215
|
+
key: 'workflowsClassifierPanel.tryErrorExample',
|
|
216
|
+
},
|
|
217
|
+
];
|
|
218
|
+
const CLASSIFIER_MODEL_ERROR = /^Classifier '.+?' uses '.+?', /;
|
|
219
|
+
function classifierErrorText(line, t) {
|
|
220
|
+
if (CLASSIFIER_MODEL_ERROR.test(line))
|
|
221
|
+
return t('workflowsClassifierPanel.tryModelUnavailable');
|
|
222
|
+
for (const { pattern, key } of CLASSIFIER_TRY_MESSAGES) {
|
|
223
|
+
const match = pattern.exec(line);
|
|
224
|
+
if (match)
|
|
225
|
+
return t(key, match[1] ? { placeholder: match[1] } : undefined);
|
|
226
|
+
}
|
|
227
|
+
return t('workflowsClassifierPanel.tryErrorOther');
|
|
228
|
+
}
|
|
229
|
+
function classifierTryFailure(error, t) {
|
|
230
|
+
const { status, data } = (error !== null && error !== void 0 ? error : {});
|
|
231
|
+
switch (status) {
|
|
232
|
+
case 400: {
|
|
233
|
+
const rawErrors = data === null || data === void 0 ? void 0 : data.errors;
|
|
234
|
+
const lines = Array.isArray(rawErrors)
|
|
235
|
+
? rawErrors.filter((line) => typeof line === 'string')
|
|
236
|
+
: [];
|
|
237
|
+
if (lines.length === 0) {
|
|
238
|
+
// The panel refuses an empty sample itself, so an `input` error is
|
|
239
|
+
// the 20000-character limit.
|
|
240
|
+
if (Array.isArray(data === null || data === void 0 ? void 0 : data.input))
|
|
241
|
+
return { ok: false, reason: 'too-long' };
|
|
242
|
+
if (Array.isArray(data === null || data === void 0 ? void 0 : data.variables))
|
|
243
|
+
return { ok: false, reason: 'variables-too-long' };
|
|
244
|
+
return { ok: false, reason: 'other' };
|
|
245
|
+
}
|
|
246
|
+
if (lines.every((line) => CLASSIFIER_MODEL_ERROR.test(line))) {
|
|
247
|
+
return { ok: false, reason: 'model-unavailable' };
|
|
248
|
+
}
|
|
249
|
+
return {
|
|
250
|
+
ok: false,
|
|
251
|
+
reason: 'invalid',
|
|
252
|
+
errors: distinct(lines.map((line) => classifierErrorText(line, t))),
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
case 402:
|
|
256
|
+
return { ok: false, reason: 'credits' };
|
|
257
|
+
case 403:
|
|
258
|
+
return { ok: false, reason: 'not-allowed' };
|
|
259
|
+
case 429:
|
|
260
|
+
return { ok: false, reason: 'spend-cap' };
|
|
261
|
+
case 502: {
|
|
262
|
+
const detail = data === null || data === void 0 ? void 0 : data.detail;
|
|
263
|
+
const unavailable = typeof detail === 'string' &&
|
|
264
|
+
/not enabled for this account|not available for this account/.test(detail);
|
|
265
|
+
return { ok: false, reason: unavailable ? 'model-unavailable' : 'model-failed' };
|
|
266
|
+
}
|
|
267
|
+
default:
|
|
268
|
+
return { ok: false, reason: 'other' };
|
|
269
|
+
}
|
|
60
270
|
}
|
|
271
|
+
const graphString = ({ nodes, edges }) => JSON.stringify({ nodes, edges });
|
|
61
272
|
function transformNodeTypesToSections(nodeTypes, t) {
|
|
62
273
|
if (!(nodeTypes === null || nodeTypes === void 0 ? void 0 : nodeTypes.node_types))
|
|
63
274
|
return undefined;
|
|
@@ -70,6 +281,9 @@ function transformNodeTypesToSections(nodeTypes, t) {
|
|
|
70
281
|
// The canvas adds the Start step to every workflow itself.
|
|
71
282
|
if (nodeId === 'start')
|
|
72
283
|
return;
|
|
284
|
+
// The backend can't run these yet, and publish refuses one that is connected.
|
|
285
|
+
if (nodeInfo.status === 'planned')
|
|
286
|
+
return;
|
|
73
287
|
const targetCategory = nodeCategoryOverride[nodeId] || nodeInfo.category;
|
|
74
288
|
const section = categoryMap.get(targetCategory);
|
|
75
289
|
if (section) {
|
|
@@ -86,6 +300,32 @@ function transformNodeTypesToSections(nodeTypes, t) {
|
|
|
86
300
|
.map(([, section]) => section)
|
|
87
301
|
.filter((section) => section.items.length > 0);
|
|
88
302
|
}
|
|
303
|
+
// Most important first: as the header narrows, the "…" menu takes them from
|
|
304
|
+
// the end, so Delete and Activate / Deactivate go first and Publish last.
|
|
305
|
+
const HEADER_ACTIONS = ['publish', 'save', 'preview', 'status', 'delete'];
|
|
306
|
+
// Widths to assume for a button that has not been measured inline yet.
|
|
307
|
+
const HEADER_ACTION_ESTIMATES = {
|
|
308
|
+
publish: 80,
|
|
309
|
+
save: 64,
|
|
310
|
+
preview: 104,
|
|
311
|
+
status: 116,
|
|
312
|
+
delete: 92,
|
|
313
|
+
};
|
|
314
|
+
// Until the header has a measured width: Publish, Save and Preview inline.
|
|
315
|
+
const HEADER_UNMEASURED_INLINE = 3;
|
|
316
|
+
// The header's gap-2 and its h-9 w-9 "…" button.
|
|
317
|
+
const HEADER_FIT_OPTIONS = { gap: 8, triggerWidth: 36 };
|
|
318
|
+
const HEADER_BUTTON = 'h-9 gap-1.5 has-[>svg]:px-2.5';
|
|
319
|
+
const HEADER_OUTLINE_BUTTON = `${HEADER_BUTTON} border-border hover:bg-accent bg-transparent`;
|
|
320
|
+
const HEADER_PRIMARY_BUTTON = `${HEADER_BUTTON} bg-[#38A1E5] text-white hover:bg-[#38A1E5]/90`;
|
|
321
|
+
// Long names wrap rather than push the buttons off the header.
|
|
322
|
+
const HEADER_NAME = 'text-foreground min-w-0 font-medium [overflow-wrap:anywhere]';
|
|
323
|
+
// Keeps the label's width while the spinner shows, so the button doesn't
|
|
324
|
+
// shrink and pull its neighbours in and out of the "…" menu.
|
|
325
|
+
function BusyLabel({ busy, children }) {
|
|
326
|
+
return (jsxs("span", { className: "relative inline-flex items-center justify-center", children: [jsx("span", { className: busy ? 'invisible' : undefined, children: children }), busy && jsx(LoaderCircle, { className: "absolute animate-spin" })] }));
|
|
327
|
+
}
|
|
328
|
+
const HEADER_GHOST_BUTTON = `${HEADER_BUTTON} text-foreground hover:text-foreground hover:bg-accent`;
|
|
89
329
|
function WorkflowEditor({ tenantKey, workflowId, username, axdToken, baseWsUrl, redirectToAuthSpa, onBack, onDeleted, onOpenAgentSettings, agentSettings, }) {
|
|
90
330
|
var _a, _b, _c, _d, _e, _f;
|
|
91
331
|
const t = useT();
|
|
@@ -104,14 +344,13 @@ function WorkflowEditor({ tenantKey, workflowId, username, axdToken, baseWsUrl,
|
|
|
104
344
|
return;
|
|
105
345
|
const nodeData = node.data;
|
|
106
346
|
const mentorId = (nodeData === null || nodeData === void 0 ? void 0 : nodeData.mentor_id) ||
|
|
107
|
-
(nodeData === null || nodeData === void 0 ? void 0 : nodeData.entry_mentor_id)
|
|
108
|
-
entryMentorId;
|
|
347
|
+
(nodeData === null || nodeData === void 0 ? void 0 : nodeData.entry_mentor_id);
|
|
109
348
|
if (mentorId) {
|
|
110
349
|
ids.add(mentorId);
|
|
111
350
|
}
|
|
112
351
|
});
|
|
113
352
|
return Array.from(ids);
|
|
114
|
-
}, [(_b = workflow === null || workflow === void 0 ? void 0 : workflow.definition) === null || _b === void 0 ? void 0 : _b.nodes
|
|
353
|
+
}, [(_b = workflow === null || workflow === void 0 ? void 0 : workflow.definition) === null || _b === void 0 ? void 0 : _b.nodes]);
|
|
115
354
|
const missingMentorIds = useMemo(() => mentorIdsFromDefinition.filter((mentorId) => !Object.prototype.hasOwnProperty.call(mentorSettingsById, mentorId)), [mentorIdsFromDefinition, mentorSettingsById]);
|
|
116
355
|
useEffect(() => {
|
|
117
356
|
if (!tenantKey || !username || missingMentorIds.length === 0)
|
|
@@ -150,7 +389,12 @@ function WorkflowEditor({ tenantKey, workflowId, username, axdToken, baseWsUrl,
|
|
|
150
389
|
isActive = false;
|
|
151
390
|
};
|
|
152
391
|
}, [missingMentorIds, fetchMentorSettings, tenantKey, username]);
|
|
153
|
-
|
|
392
|
+
// Once the canvas is open, an agent picked for a step loads in the
|
|
393
|
+
// background: the spinner would unmount the canvas, closing the open panel
|
|
394
|
+
// and losing undo history, the view and edits not yet saved.
|
|
395
|
+
const canvasShownRef = useRef(false);
|
|
396
|
+
const isWaitingForMentorSettings = !canvasShownRef.current &&
|
|
397
|
+
mentorIdsFromDefinition.length > 0 &&
|
|
154
398
|
(!username || missingMentorIds.length > 0 || isMentorSettingsLoading);
|
|
155
399
|
const [patchWorkflow, { isLoading: isSaving }] = usePatchWorkflowMutation();
|
|
156
400
|
const [publishWorkflow, { isLoading: isPublishing }] = usePublishWorkflowMutation();
|
|
@@ -158,21 +402,31 @@ function WorkflowEditor({ tenantKey, workflowId, username, axdToken, baseWsUrl,
|
|
|
158
402
|
const [validateWorkflow] = useValidateWorkflowMutation();
|
|
159
403
|
const [activateWorkflow, { isLoading: isActivating }] = useActivateWorkflowMutation();
|
|
160
404
|
const [deleteWorkflow, { isLoading: isDeleting }] = useDeleteWorkflowMutation();
|
|
405
|
+
const [testWorkflowClassifier] = useTestWorkflowClassifierMutation();
|
|
161
406
|
const [workflowName, setWorkflowName] = useState('');
|
|
162
407
|
const [isEditingName, setIsEditingName] = useState(false);
|
|
163
408
|
const [isDeleteModalOpen, setIsDeleteModalOpen] = useState(false);
|
|
164
409
|
const [draggedItem, setDraggedItem] = useState(null);
|
|
165
410
|
const [clickedItem, setClickedItem] = useState(null);
|
|
166
411
|
const [isPreviewMode, setIsPreviewMode] = useState(false);
|
|
412
|
+
const [isStepListOpen, setIsStepListOpen] = useState(false);
|
|
167
413
|
const [previewKey, setPreviewKey] = useState(0);
|
|
168
414
|
const [newChatSignal, setNewChatSignal] = useState(0);
|
|
169
415
|
const [workflowData, setWorkflowData] = useState(null);
|
|
170
416
|
const [hasUnsavedChanges, setHasUnsavedChanges] = useState(false);
|
|
171
417
|
const [validationResult, setValidationResult] = useState(null);
|
|
172
418
|
const [isValidationBannerOpen, setIsValidationBannerOpen] = useState(true);
|
|
419
|
+
const [stepFocusRequest, setStepFocusRequest] = useState();
|
|
173
420
|
const isInitialLoad = useRef(true);
|
|
421
|
+
// An auto-save landing during a delete would PATCH the workflow being deleted.
|
|
422
|
+
const deleteStartedRef = useRef(false);
|
|
174
423
|
const [debouncedWorkflowData] = a(workflowData, 1000);
|
|
175
424
|
const nodeTypeSections = useMemo(() => transformNodeTypesToSections(nodeTypesData, t), [nodeTypesData, t]);
|
|
425
|
+
const classifierModels = useMemo(() => {
|
|
426
|
+
var _a, _b, _c, _d;
|
|
427
|
+
const suggestions = (_d = (_c = (_b = (_a = nodeTypesData === null || nodeTypesData === void 0 ? void 0 : nodeTypesData.node_types) === null || _a === void 0 ? void 0 : _a.classifier) === null || _b === void 0 ? void 0 : _b.config_schema) === null || _c === void 0 ? void 0 : _c.model) === null || _d === void 0 ? void 0 : _d.suggestions;
|
|
428
|
+
return (suggestions === null || suggestions === void 0 ? void 0 : suggestions.length) ? suggestions : [IBLAI_DECISION_MODEL];
|
|
429
|
+
}, [nodeTypesData]);
|
|
176
430
|
// Never overwrite an in-progress rename with a cache refetch
|
|
177
431
|
const syncedNameRef = useRef(null);
|
|
178
432
|
useEffect(() => {
|
|
@@ -192,9 +446,16 @@ function WorkflowEditor({ tenantKey, workflowId, username, axdToken, baseWsUrl,
|
|
|
192
446
|
const definitionNeedsSaveRef = useRef(false);
|
|
193
447
|
const savedDefinitionRef = useRef(workflow === null || workflow === void 0 ? void 0 : workflow.definition);
|
|
194
448
|
savedDefinitionRef.current = workflow === null || workflow === void 0 ? void 0 : workflow.definition;
|
|
449
|
+
// What the canvas last reported, so a save that lands after newer edits
|
|
450
|
+
// leaves them marked Unsaved.
|
|
451
|
+
const latestGraphRef = useRef(null);
|
|
452
|
+
// `nodes` is the definition the result was checked against: the backend
|
|
453
|
+
// locates problems by position in it.
|
|
195
454
|
const showValidation = (result, nodes) => {
|
|
196
|
-
const
|
|
197
|
-
const
|
|
455
|
+
const steps = stepsOf(nodes);
|
|
456
|
+
const problems = (messages) => distinctProblems(messages.map((message) => toProblem(message, t, steps)));
|
|
457
|
+
const errors = problems(result.errors);
|
|
458
|
+
const warnings = problems(withoutNoteConnectivityWarnings(result.warnings, nodes));
|
|
198
459
|
if (errors.length === 0 && warnings.length === 0) {
|
|
199
460
|
setValidationResult(null);
|
|
200
461
|
return;
|
|
@@ -205,19 +466,35 @@ function WorkflowEditor({ tenantKey, workflowId, username, axdToken, baseWsUrl,
|
|
|
205
466
|
const showValidationRef = useRef(showValidation);
|
|
206
467
|
showValidationRef.current = showValidation;
|
|
207
468
|
useEffect(() => {
|
|
208
|
-
if (!debouncedWorkflowData || !workflow) {
|
|
469
|
+
if (!debouncedWorkflowData || !workflow || deleteStartedRef.current) {
|
|
209
470
|
return;
|
|
210
471
|
}
|
|
211
|
-
const currentDataStr =
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
472
|
+
const currentDataStr = graphString(debouncedWorkflowData);
|
|
473
|
+
// A refetch re-runs this with the delayed graph, which can be older than
|
|
474
|
+
// one Try, Save or Preview has just saved; the newer graph gets its own run.
|
|
475
|
+
if (latestGraphRef.current !== null && currentDataStr !== latestGraphRef.current)
|
|
476
|
+
return;
|
|
477
|
+
const validate = async () => {
|
|
478
|
+
try {
|
|
479
|
+
const result = await validateWorkflow({
|
|
480
|
+
org: tenantKey,
|
|
481
|
+
uniqueId: workflowId,
|
|
482
|
+
}).unwrap();
|
|
483
|
+
showValidationRef.current(result, debouncedWorkflowData.nodes);
|
|
484
|
+
}
|
|
485
|
+
catch (_a) {
|
|
486
|
+
// Silent fail for validation
|
|
487
|
+
}
|
|
488
|
+
};
|
|
215
489
|
if (isInitialLoad.current) {
|
|
490
|
+
isInitialLoad.current = false;
|
|
216
491
|
if (currentDataStr === initialWorkflowDataRef.current) {
|
|
217
|
-
|
|
492
|
+
// A converted definition is checked once it is saved: until then the
|
|
493
|
+
// server still holds the old field names.
|
|
494
|
+
if (!definitionNeedsSaveRef.current)
|
|
495
|
+
validate();
|
|
218
496
|
return;
|
|
219
497
|
}
|
|
220
|
-
isInitialLoad.current = false;
|
|
221
498
|
}
|
|
222
499
|
if (currentDataStr === initialWorkflowDataRef.current) {
|
|
223
500
|
return;
|
|
@@ -235,21 +512,13 @@ function WorkflowEditor({ tenantKey, workflowId, username, axdToken, baseWsUrl,
|
|
|
235
512
|
uniqueId: workflowId,
|
|
236
513
|
data: patchData,
|
|
237
514
|
}).unwrap();
|
|
238
|
-
setHasUnsavedChanges(false);
|
|
239
515
|
definitionNeedsSaveRef.current = false;
|
|
240
516
|
initialWorkflowDataRef.current = currentDataStr;
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
uniqueId: workflowId,
|
|
245
|
-
}).unwrap();
|
|
246
|
-
showValidationRef.current(result, debouncedWorkflowData.nodes);
|
|
247
|
-
}
|
|
248
|
-
catch (_a) {
|
|
249
|
-
// Silent fail for validation
|
|
250
|
-
}
|
|
517
|
+
if (latestGraphRef.current === currentDataStr)
|
|
518
|
+
setHasUnsavedChanges(false);
|
|
519
|
+
await validate();
|
|
251
520
|
}
|
|
252
|
-
catch (
|
|
521
|
+
catch (_a) {
|
|
253
522
|
// Silent fail for auto-save, user can manually save
|
|
254
523
|
}
|
|
255
524
|
};
|
|
@@ -266,24 +535,22 @@ function WorkflowEditor({ tenantKey, workflowId, username, axdToken, baseWsUrl,
|
|
|
266
535
|
clearTimeout(clickedItemTimerRef.current);
|
|
267
536
|
clickedItemTimerRef.current = setTimeout(() => setClickedItem(null), 100);
|
|
268
537
|
};
|
|
269
|
-
const currentNodes = () => {
|
|
270
|
-
|
|
271
|
-
return (_a = workflowData === null || workflowData === void 0 ? void 0 : workflowData.nodes) !== null && _a !== void 0 ? _a : ((_c = (_b = workflow === null || workflow === void 0 ? void 0 : workflow.definition) === null || _b === void 0 ? void 0 : _b.nodes) !== null && _c !== void 0 ? _c : []);
|
|
272
|
-
};
|
|
273
|
-
const markDefinitionSaved = (data) => {
|
|
274
|
-
setHasUnsavedChanges(false);
|
|
538
|
+
const currentNodes = () => { var _a, _b, _c; return (_a = workflowData === null || workflowData === void 0 ? void 0 : workflowData.nodes) !== null && _a !== void 0 ? _a : ((_c = (_b = workflow === null || workflow === void 0 ? void 0 : workflow.definition) === null || _b === void 0 ? void 0 : _b.nodes) !== null && _c !== void 0 ? _c : []); };
|
|
539
|
+
const markDefinitionSaved = (saved) => {
|
|
275
540
|
definitionNeedsSaveRef.current = false;
|
|
276
|
-
initialWorkflowDataRef.current =
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
});
|
|
541
|
+
initialWorkflowDataRef.current = saved;
|
|
542
|
+
if (latestGraphRef.current === saved)
|
|
543
|
+
setHasUnsavedChanges(false);
|
|
280
544
|
};
|
|
281
|
-
// Activate and
|
|
282
|
-
// the canvas shows (e.g. old field names converted on open).
|
|
545
|
+
// Activate, Preview and Try run what the server holds, which must match
|
|
546
|
+
// what the canvas shows (e.g. old field names converted on open). Decided by
|
|
547
|
+
// content: an auto-save can still be on its way, or have landed after
|
|
548
|
+
// newer edits.
|
|
283
549
|
const saveDefinitionIfNeeded = async () => {
|
|
284
550
|
if (!workflowData)
|
|
285
551
|
return;
|
|
286
|
-
|
|
552
|
+
const current = graphString(workflowData);
|
|
553
|
+
if (!definitionNeedsSaveRef.current && current === initialWorkflowDataRef.current)
|
|
287
554
|
return;
|
|
288
555
|
await patchWorkflow({
|
|
289
556
|
org: tenantKey,
|
|
@@ -292,8 +559,31 @@ function WorkflowEditor({ tenantKey, workflowId, username, axdToken, baseWsUrl,
|
|
|
292
559
|
definition: { nodes: workflowData.nodes, edges: workflowData.edges },
|
|
293
560
|
},
|
|
294
561
|
}).unwrap();
|
|
295
|
-
markDefinitionSaved(
|
|
562
|
+
markDefinitionSaved(current);
|
|
563
|
+
};
|
|
564
|
+
// The backend tries the saved step, so the canvas is saved first.
|
|
565
|
+
const tryClassifier = async (nodeId, input) => {
|
|
566
|
+
try {
|
|
567
|
+
await saveDefinitionIfNeeded();
|
|
568
|
+
}
|
|
569
|
+
catch (_a) {
|
|
570
|
+
return { ok: false, reason: 'save' };
|
|
571
|
+
}
|
|
572
|
+
try {
|
|
573
|
+
const result = await testWorkflowClassifier({
|
|
574
|
+
org: tenantKey,
|
|
575
|
+
uniqueId: workflowId,
|
|
576
|
+
data: { node_id: nodeId, input, variables: startVariableDefaults(currentNodes()) },
|
|
577
|
+
}).unwrap();
|
|
578
|
+
return { ok: true, output: result.output, model: result.model };
|
|
579
|
+
}
|
|
580
|
+
catch (err) {
|
|
581
|
+
return classifierTryFailure(err, t);
|
|
582
|
+
}
|
|
296
583
|
};
|
|
584
|
+
const tryClassifierRef = useRef(tryClassifier);
|
|
585
|
+
tryClassifierRef.current = tryClassifier;
|
|
586
|
+
const handleTryClassifier = useCallback((nodeId, input) => tryClassifierRef.current(nodeId, input), []);
|
|
297
587
|
const handlePreviewClick = async () => {
|
|
298
588
|
try {
|
|
299
589
|
await saveDefinitionIfNeeded();
|
|
@@ -306,14 +596,18 @@ function WorkflowEditor({ tenantKey, workflowId, username, axdToken, baseWsUrl,
|
|
|
306
596
|
};
|
|
307
597
|
const handleClosePreview = () => setIsPreviewMode(false);
|
|
308
598
|
const handleNewChat = () => setNewChatSignal((signal) => signal + 1);
|
|
599
|
+
// Preview hides step settings (and, on a phone, the whole canvas), so
|
|
600
|
+
// going to a step leaves it.
|
|
601
|
+
const handleShowStep = (nodeId, field) => {
|
|
602
|
+
setIsPreviewMode(false);
|
|
603
|
+
setStepFocusRequest((previous) => { var _a; return ({ nodeId, field, nonce: ((_a = previous === null || previous === void 0 ? void 0 : previous.nonce) !== null && _a !== void 0 ? _a : 0) + 1 }); });
|
|
604
|
+
};
|
|
309
605
|
const handleWorkflowStateChange = useCallback((state) => {
|
|
310
606
|
var _a, _b;
|
|
311
607
|
setWorkflowData(state);
|
|
608
|
+
latestGraphRef.current = graphString(state);
|
|
312
609
|
if (initialWorkflowDataRef.current === null) {
|
|
313
|
-
initialWorkflowDataRef.current =
|
|
314
|
-
nodes: state.nodes,
|
|
315
|
-
edges: state.edges,
|
|
316
|
-
});
|
|
610
|
+
initialWorkflowDataRef.current = latestGraphRef.current;
|
|
317
611
|
const saved = savedDefinitionRef.current;
|
|
318
612
|
const savedNodes = ((_a = saved === null || saved === void 0 ? void 0 : saved.nodes) !== null && _a !== void 0 ? _a : []);
|
|
319
613
|
const savedEdges = ((_b = saved === null || saved === void 0 ? void 0 : saved.edges) !== null && _b !== void 0 ? _b : []);
|
|
@@ -354,13 +648,66 @@ function WorkflowEditor({ tenantKey, workflowId, username, axdToken, baseWsUrl,
|
|
|
354
648
|
uniqueId: workflowId,
|
|
355
649
|
data: patchData,
|
|
356
650
|
}).unwrap();
|
|
357
|
-
markDefinitionSaved(workflowData);
|
|
651
|
+
markDefinitionSaved(graphString(workflowData));
|
|
358
652
|
toast.success(t('workflowsWorkflowEditor.workflowSaved'));
|
|
359
653
|
}
|
|
360
654
|
catch (_a) {
|
|
361
655
|
toast.error(t('workflowsWorkflowEditor.failedToSaveWorkflow'));
|
|
362
656
|
}
|
|
363
657
|
};
|
|
658
|
+
const saveShortcutRef = useRef(() => { });
|
|
659
|
+
const shortcutSaveWaitingRef = useRef(false);
|
|
660
|
+
useEffect(() => {
|
|
661
|
+
saveShortcutRef.current = () => {
|
|
662
|
+
if (isPreviewMode)
|
|
663
|
+
return;
|
|
664
|
+
// Clicking Save blurs the name field, which saves the name; a key press
|
|
665
|
+
// leaves it focused.
|
|
666
|
+
if (isEditingName)
|
|
667
|
+
void handleNameSave();
|
|
668
|
+
// An auto-save or rename shares the request: save once it lands rather
|
|
669
|
+
// than drop the press.
|
|
670
|
+
if (isSaving) {
|
|
671
|
+
shortcutSaveWaitingRef.current = true;
|
|
672
|
+
return;
|
|
673
|
+
}
|
|
674
|
+
void handleSave();
|
|
675
|
+
};
|
|
676
|
+
});
|
|
677
|
+
useEffect(() => {
|
|
678
|
+
if (isSaving || !shortcutSaveWaitingRef.current)
|
|
679
|
+
return;
|
|
680
|
+
shortcutSaveWaitingRef.current = false;
|
|
681
|
+
saveShortcutRef.current();
|
|
682
|
+
}, [isSaving]);
|
|
683
|
+
// Cmd+S (Ctrl+S off a Mac) would otherwise open the browser's Save Page
|
|
684
|
+
// dialog; people press it out of habit to save their work.
|
|
685
|
+
useEffect(() => {
|
|
686
|
+
const onKeyDown = (event) => {
|
|
687
|
+
if (!(event.metaKey || event.ctrlKey) || event.shiftKey || event.altKey)
|
|
688
|
+
return;
|
|
689
|
+
if (event.isComposing)
|
|
690
|
+
return;
|
|
691
|
+
// The physical S key only counts on layouts without Latin letters; on
|
|
692
|
+
// Dvorak it types "o" and Cmd+O must stay Open.
|
|
693
|
+
const isS = /^[a-z]$/i.test(event.key)
|
|
694
|
+
? event.key.toLowerCase() === 's'
|
|
695
|
+
: event.code === 'KeyS';
|
|
696
|
+
if (!isS)
|
|
697
|
+
return;
|
|
698
|
+
event.preventDefault();
|
|
699
|
+
if (event.repeat)
|
|
700
|
+
return;
|
|
701
|
+
// Another window, such as Edit Agent, may be open over the editor.
|
|
702
|
+
const active = document.activeElement;
|
|
703
|
+
if (active === null || active === void 0 ? void 0 : active.closest('[role="dialog"], [role="alertdialog"]'))
|
|
704
|
+
return;
|
|
705
|
+
saveShortcutRef.current();
|
|
706
|
+
};
|
|
707
|
+
window.addEventListener('keydown', onKeyDown);
|
|
708
|
+
return () => window.removeEventListener('keydown', onKeyDown);
|
|
709
|
+
}, []);
|
|
710
|
+
const headerFit = useOverflowFit(HEADER_ACTIONS.map((key) => ({ key, estimate: HEADER_ACTION_ESTIMATES[key] })), [], HEADER_FIT_OPTIONS);
|
|
364
711
|
const handlePublish = async () => {
|
|
365
712
|
const data = workflowData
|
|
366
713
|
? { definition: { nodes: workflowData.nodes, edges: workflowData.edges } }
|
|
@@ -372,7 +719,7 @@ function WorkflowEditor({ tenantKey, workflowId, username, axdToken, baseWsUrl,
|
|
|
372
719
|
data,
|
|
373
720
|
}).unwrap();
|
|
374
721
|
if (workflowData)
|
|
375
|
-
markDefinitionSaved(workflowData);
|
|
722
|
+
markDefinitionSaved(graphString(workflowData));
|
|
376
723
|
setValidationResult(null);
|
|
377
724
|
toast.success(t('workflowsWorkflowEditor.workflowPublished'));
|
|
378
725
|
}
|
|
@@ -435,6 +782,7 @@ function WorkflowEditor({ tenantKey, workflowId, username, axdToken, baseWsUrl,
|
|
|
435
782
|
}
|
|
436
783
|
};
|
|
437
784
|
const handleDeleteConfirm = async () => {
|
|
785
|
+
deleteStartedRef.current = true;
|
|
438
786
|
try {
|
|
439
787
|
await deleteWorkflow({
|
|
440
788
|
org: tenantKey,
|
|
@@ -445,14 +793,15 @@ function WorkflowEditor({ tenantKey, workflowId, username, axdToken, baseWsUrl,
|
|
|
445
793
|
onDeleted();
|
|
446
794
|
}
|
|
447
795
|
catch (_a) {
|
|
796
|
+
deleteStartedRef.current = false;
|
|
448
797
|
toast.error(t('workflowsWorkflowEditor.failedToDeleteWorkflow'));
|
|
449
798
|
}
|
|
450
799
|
};
|
|
451
800
|
if (isLoading || isWaitingForMentorSettings) {
|
|
452
|
-
return (jsx("div", { className: "flex h-
|
|
801
|
+
return (jsx("div", { className: "flex h-full items-center justify-center", children: jsx(LoaderCircle, { className: "h-8 w-8 animate-spin text-gray-400" }) }));
|
|
453
802
|
}
|
|
454
803
|
if (error || !workflow) {
|
|
455
|
-
return (jsx("div", { className: "flex h-
|
|
804
|
+
return (jsx("div", { className: "flex h-full items-center justify-center", children: jsxs("div", { className: "text-center", children: [jsx(CircleAlert, { className: "mx-auto mb-4 h-12 w-12 text-red-500" }), jsx("p", { className: "mb-4 text-gray-600", children: t('workflowsWorkflowEditor.failedToLoadWorkflow') }), jsxs(Button, { variant: "outline", className: "h-9 has-[>svg]:px-3", onClick: () => onBack(), children: [jsx(ChevronLeft, { className: "mr-2 h-4 w-4" }), t('workflowsWorkflowEditor.goBack')] })] }) }));
|
|
456
805
|
}
|
|
457
806
|
// Workflows saved with the builder's old field names open with the names
|
|
458
807
|
// the backend reads; the next save stores them.
|
|
@@ -461,23 +810,29 @@ function WorkflowEditor({ tenantKey, workflowId, username, axdToken, baseWsUrl,
|
|
|
461
810
|
const nodeData = n.data;
|
|
462
811
|
if (n.type === 'mentor') {
|
|
463
812
|
const mentorId = (nodeData === null || nodeData === void 0 ? void 0 : nodeData.mentor_id) ||
|
|
464
|
-
(nodeData === null || nodeData === void 0 ? void 0 : nodeData.entry_mentor_id)
|
|
465
|
-
entryMentorId;
|
|
813
|
+
(nodeData === null || nodeData === void 0 ? void 0 : nodeData.entry_mentor_id);
|
|
466
814
|
const mentorData = mentorId ? mentorSettingsById[mentorId] : null;
|
|
815
|
+
const systemPrompt = mentorData === null || mentorData === void 0 ? void 0 : mentorData.system_prompt;
|
|
816
|
+
// Earlier builds saved the agent's own prompt, or a placeholder, as the
|
|
817
|
+
// step's instructions; the backend ignores both, so neither is shown or
|
|
818
|
+
// saved again.
|
|
819
|
+
const { instructions: _ignoredInstructions, ...withoutInstructions } = nodeData;
|
|
820
|
+
const stepData = isAuthoredInstructions(nodeData.instructions, typeof systemPrompt === 'string' ? systemPrompt : undefined)
|
|
821
|
+
? nodeData
|
|
822
|
+
: withoutInstructions;
|
|
467
823
|
return {
|
|
468
824
|
...n,
|
|
469
825
|
draggable: true,
|
|
470
826
|
selectable: true,
|
|
471
827
|
connectable: true,
|
|
472
828
|
data: {
|
|
473
|
-
...
|
|
829
|
+
...stepData,
|
|
474
830
|
...(mentorId ? { entry_mentor_id: mentorId } : {}),
|
|
475
|
-
// The agent's current
|
|
831
|
+
// The agent's current name and model win over what the step saved.
|
|
476
832
|
...(mentorData && {
|
|
477
833
|
label: mentorData.display_name ||
|
|
478
834
|
mentorData.mentor_name ||
|
|
479
835
|
(nodeData === null || nodeData === void 0 ? void 0 : nodeData.label),
|
|
480
|
-
instructions: mentorData.system_prompt || (nodeData === null || nodeData === void 0 ? void 0 : nodeData.instructions),
|
|
481
836
|
model: mentorData.llm_name || (nodeData === null || nodeData === void 0 ? void 0 : nodeData.model),
|
|
482
837
|
}),
|
|
483
838
|
},
|
|
@@ -491,14 +846,63 @@ function WorkflowEditor({ tenantKey, workflowId, username, axdToken, baseWsUrl,
|
|
|
491
846
|
};
|
|
492
847
|
});
|
|
493
848
|
const initialEdges = definition.edges;
|
|
494
|
-
|
|
849
|
+
// The backend also reports a workflow that was never published as changed.
|
|
850
|
+
const hasUnpublishedChanges = workflow.has_unpublished_changes === true && Boolean(workflow.published_at);
|
|
851
|
+
const unpublishedMarker = hasUnpublishedChanges && (jsx("span", { "data-testid": "workflow-unpublished-changes", className: "text-muted-foreground text-xs", children: t('workflowsWorkflowEditor.unpublishedChanges') }));
|
|
852
|
+
// Named from the canvas as it is now: a step deleted since the check has
|
|
853
|
+
// nothing to show, and a renamed one shows its new name.
|
|
854
|
+
const shownSteps = stepsOf(currentNodes());
|
|
855
|
+
const problemLine = ({ text, stepId, field }) => {
|
|
856
|
+
var _a;
|
|
857
|
+
const step = stepId ? shownSteps.find(stepId) : undefined;
|
|
858
|
+
if (!step)
|
|
859
|
+
return jsx("span", { children: text });
|
|
860
|
+
return (jsx(ActionTooltip, { label: t('workflowsWorkflowEditor.goToStep', { name: ((_a = step.data) === null || _a === void 0 ? void 0 : _a.label) || step.id }), children: jsx("button", { type: "button", className: PROBLEM_LINK, onClick: () => handleShowStep(step.id, field), children: text }) }));
|
|
861
|
+
};
|
|
862
|
+
canvasShownRef.current = true;
|
|
863
|
+
return (
|
|
864
|
+
// Hosts render the editor below their own top bar: a window-tall editor
|
|
865
|
+
// ran past it and the host cut off the preview's message box.
|
|
866
|
+
jsxs("div", { className: "flex h-full flex-col bg-white", children: [jsxs("div", { className: `bg-background border-border flex items-center justify-between gap-4 border-b px-4 py-3 ${isPreviewMode ? 'max-md:flex-wrap max-md:gap-y-2' : ''}`, children: [jsx("div", { className: "flex min-w-0 items-center gap-3", children: isPreviewMode ? (jsxs("div", { className: "flex min-w-0 items-center gap-2", children: [jsx("h1", { className: HEADER_NAME, children: workflowName }), jsx("span", { className: `shrink-0 rounded-md px-2 py-0.5 text-xs whitespace-nowrap ${workflow.is_active ? 'bg-green-100 text-green-700' : 'bg-muted text-muted-foreground'}`, children: workflow.is_active
|
|
495
867
|
? t('workflowsWorkflowEditor.statusActive')
|
|
496
|
-
: t('workflowsWorkflowEditor.statusDraft') })] })) : (
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
868
|
+
: t('workflowsWorkflowEditor.statusDraft') }), unpublishedMarker] })) : (jsx(Fragment, { children: jsxs("div", { className: "flex min-w-0 items-center gap-2", children: [isEditingName ? (jsx(Input, { value: workflowName, onChange: (e) => setWorkflowName(e.target.value), onBlur: handleNameSave, onKeyDown: (e) => e.key === 'Enter' && handleNameSave(), className: "text-foreground h-9 w-[200px] min-w-0 font-medium", autoFocus: true, "aria-label": t('workflowsWorkflowEditor.enterWorkflowNameLabel') })) : (jsxs("div", { className: "flex min-w-0 items-center gap-1", children: [jsx("h1", { className: HEADER_NAME, children: workflowName }), jsx(ActionTooltip, { label: t('workflowsWorkflowEditor.editWorkflowNameLabel'), children: jsx(Button, { variant: "ghost", size: "icon", className: "h-9 w-9 shrink-0 text-muted-foreground hover:text-foreground [&_svg]:size-3.5", onClick: () => setIsEditingName(true), "aria-label": t('workflowsWorkflowEditor.editWorkflowNameLabel'), children: jsx(Pencil, { strokeWidth: 2.25 }) }) })] })), jsx("span", { className: `shrink-0 rounded-md px-2 py-0.5 text-xs whitespace-nowrap ${workflow.is_active ? 'bg-green-100 text-green-700' : 'bg-muted text-muted-foreground'}`, children: workflow.is_active
|
|
869
|
+
? t('workflowsWorkflowEditor.statusActive')
|
|
870
|
+
: t('workflowsWorkflowEditor.statusDraft') }), unpublishedMarker, hasUnsavedChanges ? (jsx("span", { className: "text-muted-foreground shrink-0 text-xs whitespace-nowrap", children: t('workflowsWorkflowEditor.unsaved') })) : (
|
|
871
|
+
// Holds the marker's width so the header's buttons don't move
|
|
872
|
+
// in and out of the "…" menu around every edit and auto-save.
|
|
873
|
+
jsx("span", { "aria-hidden": "true", "data-label": t('workflowsWorkflowEditor.unsaved'), className: "invisible shrink-0 text-xs whitespace-nowrap after:content-[attr(data-label)]" }))] }) })) }), jsx("div", { ref: headerFit.rootRef, "data-testid": "workflow-header-actions", "data-fit": headerFit.visibleCount === null ? 'pending' : 'done',
|
|
874
|
+
// In Preview the three buttons keep their width and their words: the
|
|
875
|
+
// name wraps beside them, and below md they take a row of their own.
|
|
876
|
+
// The edit actions must shrink for the "…" menu to measure.
|
|
877
|
+
className: `flex flex-1 items-center justify-end gap-2 ${isPreviewMode ? 'min-w-fit max-md:basis-full max-md:justify-start' : 'min-w-9'}`, children: isPreviewMode ? (jsxs(Fragment, { children: [jsxs(Button, { variant: "ghost", size: "sm", className: HEADER_GHOST_BUTTON, onClick: handleClosePreview, children: [jsx(X, {}), t('workflowsWorkflowEditor.closePreview')] }), jsxs(Button, { variant: "ghost", size: "sm", className: HEADER_GHOST_BUTTON, onClick: handleNewChat, "aria-label": t('workflowsWorkflowEditor.newChatLabel'), children: [jsx(RotateCcw, {}), t('workflowsWorkflowEditor.newChat')] }), jsx(Button, { size: "sm", className: HEADER_PRIMARY_BUTTON, onClick: handlePublish, disabled: isPublishing, "aria-busy": isPublishing, children: jsx(BusyLabel, { busy: isPublishing, children: t('workflowsWorkflowEditor.publish') }) })] })) : ((() => {
|
|
878
|
+
var _a;
|
|
879
|
+
const inlineCount = (_a = headerFit.visibleCount) !== null && _a !== void 0 ? _a : HEADER_UNMEASURED_INLINE;
|
|
880
|
+
const menuActions = HEADER_ACTIONS.slice(inlineCount);
|
|
881
|
+
const inlineActions = HEADER_ACTIONS.slice(0, inlineCount).reverse();
|
|
882
|
+
const statusLabel = workflow.is_active
|
|
883
|
+
? t('workflowsWorkflowEditor.deactivate')
|
|
884
|
+
: isActivating
|
|
885
|
+
? t('workflowsWorkflowEditor.activating')
|
|
886
|
+
: t('workflowsWorkflowEditor.activate');
|
|
887
|
+
const onStatus = workflow.is_active ? handleDeactivate : handleActivate;
|
|
888
|
+
const statusDisabled = !workflow.is_active && isActivating;
|
|
889
|
+
const inlineButton = {
|
|
890
|
+
delete: (jsxs(Button, { variant: "outline", size: "sm", className: `${HEADER_OUTLINE_BUTTON} text-red-600 hover:text-red-700`, onClick: () => setIsDeleteModalOpen(true), children: [jsx(Trash2, {}), t('workflowsWorkflowEditor.delete')] })),
|
|
891
|
+
status: (jsxs(Button, { variant: "outline", size: "sm", className: `${HEADER_OUTLINE_BUTTON} text-foreground`, onClick: onStatus, disabled: statusDisabled, children: [jsx(Power, {}), statusLabel] })),
|
|
892
|
+
preview: (jsxs(Button, { variant: "outline", size: "sm", className: `${HEADER_OUTLINE_BUTTON} text-foreground`, onClick: handlePreviewClick, children: [jsx(Eye, {}), t('workflowsWorkflowEditor.preview')] })),
|
|
893
|
+
save: (jsx(ActionTooltip, { label: withShortcut(t('workflowsWorkflowEditor.save'), 'save'), children: jsx(Button, { size: "sm", className: HEADER_PRIMARY_BUTTON, onClick: handleSave, disabled: isSaving, "aria-busy": isSaving, "aria-keyshortcuts": ariaShortcut('save'), children: jsx(BusyLabel, { busy: isSaving, children: t('workflowsWorkflowEditor.save') }) }) })),
|
|
894
|
+
publish: (jsx(Button, { size: "sm", className: HEADER_PRIMARY_BUTTON, onClick: handlePublish, disabled: isPublishing, "aria-busy": isPublishing, children: jsx(BusyLabel, { busy: isPublishing, children: t('workflowsWorkflowEditor.publish') }) })),
|
|
895
|
+
};
|
|
896
|
+
const menuItem = {
|
|
897
|
+
publish: (jsxs(DropdownMenuItem, { onClick: handlePublish, disabled: isPublishing, children: [jsx(Upload, {}), t('workflowsWorkflowEditor.publish')] })),
|
|
898
|
+
save: (jsxs(DropdownMenuItem, { onClick: handleSave, disabled: isSaving, children: [jsx(Save, {}), t('workflowsWorkflowEditor.save')] })),
|
|
899
|
+
preview: (jsxs(DropdownMenuItem, { onClick: handlePreviewClick, children: [jsx(Eye, {}), t('workflowsWorkflowEditor.preview')] })),
|
|
900
|
+
status: (jsxs(DropdownMenuItem, { onClick: onStatus, disabled: statusDisabled, children: [jsx(Power, {}), statusLabel] })),
|
|
901
|
+
delete: (jsxs(DropdownMenuItem, { onClick: () => setIsDeleteModalOpen(true), className: "text-red-600", children: [jsx(Trash2, {}), t('workflowsWorkflowEditor.delete')] })),
|
|
902
|
+
};
|
|
903
|
+
return (jsxs(Fragment, { children: [menuActions.length > 0 && (jsxs(DropdownMenu, { children: [jsx(ActionTooltip, { label: t('workflowsWorkflowEditor.moreOptionsLabel'), children: jsx(DropdownMenuTrigger, { asChild: true, children: jsx(Button, { variant: "ghost", size: "icon", className: "h-9 w-9 shrink-0 text-muted-foreground hover:text-foreground", "aria-label": t('workflowsWorkflowEditor.moreOptionsLabel'), children: jsx(Ellipsis, {}) }) }) }), jsx(DropdownMenuContent, { align: "end", children: menuActions.map((key) => (jsx(Fragment$1, { children: menuItem[key] }, key))) })] })), inlineActions.map((key) => (jsx("div", { ref: headerFit.itemRef(key), "data-header-action": key, className: "shrink-0", children: inlineButton[key] }, key)))] }));
|
|
904
|
+
})()) })] }), validationResult &&
|
|
905
|
+
(validationResult.errors.length > 0 || validationResult.warnings.length > 0) && (jsx(Collapsible, { open: isValidationBannerOpen, onOpenChange: setIsValidationBannerOpen, children: jsxs("div", { className: "border-border bg-background border-b px-4 py-2", children: [jsx(CollapsibleTrigger, { asChild: true, children: jsxs("button", { className: "flex w-full items-center justify-between gap-2 text-sm", children: [jsxs("div", { className: "flex min-w-0 flex-wrap items-center gap-x-2 text-left", children: [jsx(ListChecks, { className: "text-muted-foreground h-4 w-4 shrink-0" }), jsx("span", { className: "text-foreground font-medium", children: t('workflowsWorkflowEditor.problemsTitle') }), jsx("span", { "aria-hidden": "true", className: "text-muted-foreground", children: "\u00B7" }), jsxs("span", { className: "text-muted-foreground", children: [validationResult.errors.length > 0 &&
|
|
502
906
|
t('workflowsWorkflowEditor.validationErrors', {
|
|
503
907
|
count: validationResult.errors.length,
|
|
504
908
|
}), validationResult.errors.length > 0 &&
|
|
@@ -506,7 +910,7 @@ function WorkflowEditor({ tenantKey, workflowId, username, axdToken, baseWsUrl,
|
|
|
506
910
|
', ', validationResult.warnings.length > 0 &&
|
|
507
911
|
t('workflowsWorkflowEditor.validationWarnings', {
|
|
508
912
|
count: validationResult.warnings.length,
|
|
509
|
-
})] })] }), jsxs("div", { className: "flex items-center gap-2", children: [isValidationBannerOpen ? (jsx(ChevronUp, { className: "text-muted-foreground h-4 w-4" })) : (jsx(ChevronDown, { className: "text-muted-foreground h-4 w-4" })), jsx("span", { role: "button", tabIndex: 0, className: "text-muted-foreground hover:text-foreground", onClick: (e) => {
|
|
913
|
+
})] })] }), jsxs("div", { className: "flex shrink-0 items-center gap-2", children: [isValidationBannerOpen ? (jsx(ChevronUp, { className: "text-muted-foreground h-4 w-4" })) : (jsx(ChevronDown, { className: "text-muted-foreground h-4 w-4" })), jsx("span", { role: "button", tabIndex: 0, className: "text-muted-foreground hover:text-foreground", onClick: (e) => {
|
|
510
914
|
e.stopPropagation();
|
|
511
915
|
setValidationResult(null);
|
|
512
916
|
}, onKeyDown: (e) => {
|
|
@@ -514,7 +918,14 @@ function WorkflowEditor({ tenantKey, workflowId, username, axdToken, baseWsUrl,
|
|
|
514
918
|
e.stopPropagation();
|
|
515
919
|
setValidationResult(null);
|
|
516
920
|
}
|
|
517
|
-
}, children: jsx(X, { className: "h-4 w-4" }) })] })] }) }), jsx(CollapsibleContent, { children: jsxs("div", { className: "mt-2 space-y-1 pb-1", children: [validationResult.errors.map((error, i) => (jsxs("div", { className: "flex items-start gap-2 text-sm text-red-600", children: [jsx(CircleAlert, { className: "mt-0.5 h-3.5 w-3.5 shrink-0" }),
|
|
921
|
+
}, children: jsx(X, { className: "h-4 w-4" }) })] })] }) }), jsx(CollapsibleContent, { children: jsxs("div", { "data-testid": "workflow-validation-list", className: "mt-2 max-h-40 space-y-1 overflow-y-auto pb-1", children: [validationResult.errors.map((error, i) => (jsxs("div", { className: "flex items-start gap-2 text-sm text-red-600", children: [jsx(CircleAlert, { className: "mt-0.5 h-3.5 w-3.5 shrink-0" }), problemLine(error)] }, `error-${i}`))), validationResult.warnings.map((warning, i) => (jsxs("div", { className: "flex items-start gap-2 text-sm text-amber-600", children: [jsx(TriangleAlert, { className: "mt-0.5 h-3.5 w-3.5 shrink-0" }), problemLine(warning)] }, `warning-${i}`)))] }) })] }) })), jsxs("div", { className: "flex flex-1 overflow-hidden", children: [!isPreviewMode && (jsx(WorkflowSidebar, { className: "hidden md:block", onDragStart: setDraggedItem, onItemClick: handleItemClick, nodeTypes: nodeTypeSections })), jsxs("div", { className: isPreviewMode
|
|
922
|
+
? // Kept mounted on phones so Close Preview returns to the same
|
|
923
|
+
// view and undo history.
|
|
924
|
+
'hidden h-full md:block md:w-[60%] md:border-r md:border-gray-200'
|
|
925
|
+
: 'relative h-full min-w-0 flex-1', children: [jsx(WorkflowCanvas, { onDraggedItem: isPreviewMode ? null : draggedItem, onClickedItem: isPreviewMode ? null : clickedItem, previewMode: isPreviewMode, initialNodes: initialNodes, initialEdges: initialEdges, onStateChange: handleWorkflowStateChange, org: tenantKey, defaultMentorId: entryMentorId, username: username, onOpenAgentSettings: onOpenAgentSettings, agentSettings: agentSettings, classifierModels: classifierModels, onTryClassifier: handleTryClassifier, focusRequest: stepFocusRequest }), !isPreviewMode && (jsxs(Button, { variant: "outline", size: "sm", className: "bg-card border-border absolute top-3 left-3 z-10 h-9 gap-1.5 shadow-sm md:hidden", onClick: () => setIsStepListOpen(true), children: [jsx(Plus, {}), t('workflowsWorkflowEditor.addStep')] }))] }), isPreviewMode && (jsx("div", { className: "flex h-full w-full flex-col bg-white md:w-[40%]", children: jsx(WorkflowPreviewChat, { tenantKey: tenantKey, mentorId: entryMentorId, username: username, axdToken: axdToken, baseWsUrl: baseWsUrl, redirectToAuthSpa: redirectToAuthSpa, newChatSignal: newChatSignal }, previewKey) }))] }), jsx(Sheet, { open: isStepListOpen, onOpenChange: setIsStepListOpen, children: jsxs(SheetContent, { side: "bottom", className: "max-h-[80dvh] gap-0 rounded-t-xl p-0", children: [jsxs(SheetHeader, { className: "border-border border-b p-4", children: [jsx(SheetTitle, { children: t('workflowsWorkflowEditor.addStep') }), jsx(SheetDescription, { className: "sr-only", children: t('workflowsWorkflowEditor.addStepDescription') })] }), jsx(WorkflowSidebar, { className: "min-h-0 w-full border-r-0", onDragStart: setDraggedItem, onItemClick: (item) => {
|
|
926
|
+
handleItemClick(item);
|
|
927
|
+
setIsStepListOpen(false);
|
|
928
|
+
}, nodeTypes: nodeTypeSections })] }) }), jsx(DeleteWorkflowModal, { isOpen: isDeleteModalOpen, onClose: () => setIsDeleteModalOpen(false), onConfirm: handleDeleteConfirm, isDeleting: isDeleting, workflowName: workflow.name })] }));
|
|
518
929
|
}
|
|
519
930
|
|
|
520
931
|
export { WorkflowEditor };
|