@marktoflow/gui 2.0.0-alpha.5 → 2.0.2

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 (162) hide show
  1. package/README.md +48 -180
  2. package/dist/client/assets/index-DQeR1ew6.css +1 -0
  3. package/dist/client/assets/index-LbIVPHbD.js +833 -0
  4. package/dist/client/assets/index-LbIVPHbD.js.map +1 -0
  5. package/dist/client/index.html +2 -2
  6. package/dist/client/marktoflow-logo.png +0 -0
  7. package/dist/server/index.js +31 -5
  8. package/dist/server/index.js.map +1 -1
  9. package/dist/server/routes/admin.js +95 -0
  10. package/dist/server/routes/admin.js.map +1 -0
  11. package/dist/server/routes/ai.js +2 -2
  12. package/dist/server/routes/ai.js.map +1 -1
  13. package/dist/server/routes/collaboration.js +104 -0
  14. package/dist/server/routes/collaboration.js.map +1 -0
  15. package/dist/server/routes/execute.js +181 -14
  16. package/dist/server/routes/execute.js.map +1 -1
  17. package/dist/server/routes/form.js +160 -0
  18. package/dist/server/routes/form.js.map +1 -0
  19. package/dist/server/routes/settings.js +90 -0
  20. package/dist/server/routes/settings.js.map +1 -0
  21. package/dist/server/routes/templates.js +106 -0
  22. package/dist/server/routes/templates.js.map +1 -0
  23. package/dist/server/routes/versions.js +101 -0
  24. package/dist/server/routes/versions.js.map +1 -0
  25. package/dist/server/services/AIService.js +85 -2
  26. package/dist/server/services/AIService.js.map +1 -1
  27. package/dist/server/services/ExecutionManager.js +571 -0
  28. package/dist/server/services/ExecutionManager.js.map +1 -0
  29. package/dist/server/services/VersionService.js +65 -0
  30. package/dist/server/services/VersionService.js.map +1 -0
  31. package/dist/server/services/WorkflowService.js +8 -2
  32. package/dist/server/services/WorkflowService.js.map +1 -1
  33. package/dist/server/services/agents/copilot-provider.js +32 -0
  34. package/dist/server/services/agents/copilot-provider.js.map +1 -1
  35. package/dist/server/websocket/index.js +42 -0
  36. package/dist/server/websocket/index.js.map +1 -1
  37. package/dist/shared/constants.js +9 -0
  38. package/dist/shared/constants.js.map +1 -1
  39. package/dist/shared/settings.js +51 -0
  40. package/dist/shared/settings.js.map +1 -0
  41. package/package.json +14 -10
  42. package/public/marktoflow-logo.png +0 -0
  43. package/tests/integration/fixtures/test-workflow.md +6 -0
  44. package/.turbo/turbo-build.log +0 -42
  45. package/dist/client/assets/index-CM44OayM.js +0 -704
  46. package/dist/client/assets/index-CM44OayM.js.map +0 -1
  47. package/dist/client/assets/index-Dru63gi6.css +0 -1
  48. package/marktoflow-gui-2.0.0-alpha.5.tgz +0 -0
  49. package/playwright.config.ts +0 -27
  50. package/postcss.config.js +0 -6
  51. package/src/client/App.tsx +0 -520
  52. package/src/client/components/Canvas/Canvas.tsx +0 -425
  53. package/src/client/components/Canvas/ExecutionOverlay.tsx +0 -935
  54. package/src/client/components/Canvas/ForEachNode.tsx +0 -152
  55. package/src/client/components/Canvas/IfElseNode.tsx +0 -141
  56. package/src/client/components/Canvas/NodeContextMenu.tsx +0 -192
  57. package/src/client/components/Canvas/OutputNode.tsx +0 -111
  58. package/src/client/components/Canvas/ParallelNode.tsx +0 -157
  59. package/src/client/components/Canvas/StepNode.tsx +0 -106
  60. package/src/client/components/Canvas/SubWorkflowNode.tsx +0 -141
  61. package/src/client/components/Canvas/SwitchNode.tsx +0 -185
  62. package/src/client/components/Canvas/Toolbar.tsx +0 -227
  63. package/src/client/components/Canvas/TransformNode.tsx +0 -194
  64. package/src/client/components/Canvas/TriggerNode.tsx +0 -128
  65. package/src/client/components/Canvas/TryCatchNode.tsx +0 -164
  66. package/src/client/components/Canvas/WhileNode.tsx +0 -161
  67. package/src/client/components/Canvas/index.ts +0 -24
  68. package/src/client/components/Debug/VariableInspector.tsx +0 -148
  69. package/src/client/components/Editor/InputsEditor.tsx +0 -458
  70. package/src/client/components/Editor/NewStepWizard.tsx +0 -344
  71. package/src/client/components/Editor/StepEditor.tsx +0 -532
  72. package/src/client/components/Editor/YamlEditor.tsx +0 -160
  73. package/src/client/components/Panels/PropertiesPanel.tsx +0 -589
  74. package/src/client/components/Prompt/ChangePreview.tsx +0 -281
  75. package/src/client/components/Prompt/PromptHistoryPanel.tsx +0 -209
  76. package/src/client/components/Prompt/PromptInput.tsx +0 -110
  77. package/src/client/components/Settings/ProviderSwitcher.tsx +0 -228
  78. package/src/client/components/Sidebar/ImportDialog.tsx +0 -257
  79. package/src/client/components/Sidebar/Sidebar.tsx +0 -362
  80. package/src/client/components/common/Breadcrumb.tsx +0 -40
  81. package/src/client/components/common/Button.tsx +0 -68
  82. package/src/client/components/common/ContextMenu.tsx +0 -202
  83. package/src/client/components/common/KeyboardShortcuts.tsx +0 -149
  84. package/src/client/components/common/Modal.tsx +0 -93
  85. package/src/client/components/common/Tabs.tsx +0 -57
  86. package/src/client/components/common/ThemeToggle.tsx +0 -63
  87. package/src/client/components/index.ts +0 -32
  88. package/src/client/hooks/index.ts +0 -4
  89. package/src/client/hooks/useAIPrompt.ts +0 -108
  90. package/src/client/hooks/useCanvas.ts +0 -247
  91. package/src/client/hooks/useWebSocket.ts +0 -164
  92. package/src/client/hooks/useWorkflow.ts +0 -138
  93. package/src/client/main.tsx +0 -10
  94. package/src/client/stores/agentStore.ts +0 -109
  95. package/src/client/stores/canvasStore.ts +0 -348
  96. package/src/client/stores/editorStore.ts +0 -133
  97. package/src/client/stores/executionStore.ts +0 -502
  98. package/src/client/stores/index.ts +0 -4
  99. package/src/client/stores/layoutStore.ts +0 -103
  100. package/src/client/stores/navigationStore.ts +0 -49
  101. package/src/client/stores/promptStore.ts +0 -113
  102. package/src/client/stores/themeStore.ts +0 -75
  103. package/src/client/stores/workflowStore.ts +0 -185
  104. package/src/client/styles/globals.css +0 -452
  105. package/src/client/utils/cn.ts +0 -9
  106. package/src/client/utils/index.ts +0 -4
  107. package/src/client/utils/platform.ts +0 -46
  108. package/src/client/utils/serviceIcons.tsx +0 -97
  109. package/src/client/utils/stepValidation.ts +0 -155
  110. package/src/client/utils/workflowToGraph.ts +0 -523
  111. package/src/server/index.ts +0 -137
  112. package/src/server/routes/ai.ts +0 -91
  113. package/src/server/routes/execute.ts +0 -71
  114. package/src/server/routes/executions.ts +0 -136
  115. package/src/server/routes/tools.ts +0 -970
  116. package/src/server/routes/workflows.ts +0 -147
  117. package/src/server/services/AIService.ts +0 -105
  118. package/src/server/services/FileWatcher.ts +0 -69
  119. package/src/server/services/WorkflowService.ts +0 -601
  120. package/src/server/services/agents/claude-code-provider.ts +0 -320
  121. package/src/server/services/agents/claude-provider.ts +0 -248
  122. package/src/server/services/agents/codex-provider.ts +0 -398
  123. package/src/server/services/agents/copilot-provider.ts +0 -311
  124. package/src/server/services/agents/demo-provider.ts +0 -184
  125. package/src/server/services/agents/index.ts +0 -31
  126. package/src/server/services/agents/ollama-provider.ts +0 -267
  127. package/src/server/services/agents/prompts.ts +0 -509
  128. package/src/server/services/agents/registry.ts +0 -310
  129. package/src/server/services/agents/types.ts +0 -146
  130. package/src/server/websocket/index.ts +0 -117
  131. package/src/shared/constants.ts +0 -180
  132. package/src/shared/types.ts +0 -179
  133. package/tailwind.config.ts +0 -73
  134. package/tests/e2e/app.spec.ts +0 -90
  135. package/tests/e2e/canvas.spec.ts +0 -128
  136. package/tests/e2e/workflow.spec.ts +0 -185
  137. package/tests/integration/api.test.ts +0 -452
  138. package/tests/integration/testApp.ts +0 -31
  139. package/tests/setup.ts +0 -72
  140. package/tests/unit/ForEachNode.test.tsx +0 -308
  141. package/tests/unit/IfElseNode.test.tsx +0 -235
  142. package/tests/unit/ParallelNode.test.tsx +0 -344
  143. package/tests/unit/SwitchNode.test.tsx +0 -327
  144. package/tests/unit/TransformNode.test.tsx +0 -386
  145. package/tests/unit/TryCatchNode.test.tsx +0 -243
  146. package/tests/unit/WhileNode.test.tsx +0 -230
  147. package/tests/unit/agentStore.test.ts +0 -218
  148. package/tests/unit/canvasStore.test.ts +0 -502
  149. package/tests/unit/codexProvider.test.ts +0 -399
  150. package/tests/unit/components.test.tsx +0 -151
  151. package/tests/unit/executionStore.test.ts +0 -567
  152. package/tests/unit/layoutStore.test.ts +0 -194
  153. package/tests/unit/navigationStore.test.ts +0 -152
  154. package/tests/unit/platform.test.ts +0 -118
  155. package/tests/unit/serviceIcons.test.ts +0 -197
  156. package/tests/unit/stepValidation.test.ts +0 -226
  157. package/tests/unit/themeStore.test.ts +0 -141
  158. package/tests/unit/workflowToGraph.test.ts +0 -311
  159. package/tsconfig.json +0 -29
  160. package/tsconfig.server.json +0 -28
  161. package/vite.config.ts +0 -31
  162. package/vitest.config.ts +0 -26
@@ -1,502 +0,0 @@
1
- import { create } from 'zustand';
2
- import type { StepStatus, WorkflowStatus } from '@shared/types';
3
-
4
- export interface ExecutionStepResult {
5
- stepId: string;
6
- stepName: string;
7
- status: StepStatus;
8
- startTime?: string;
9
- endTime?: string;
10
- duration?: number;
11
- inputs?: Record<string, unknown>;
12
- output?: unknown;
13
- outputVariable?: string;
14
- error?: string;
15
- }
16
-
17
- export interface ExecutionRun {
18
- id: string;
19
- workflowId: string;
20
- workflowName: string;
21
- status: WorkflowStatus;
22
- startTime: string;
23
- endTime?: string;
24
- duration?: number;
25
- steps: ExecutionStepResult[];
26
- logs: string[];
27
- inputs?: Record<string, unknown>;
28
- outputs?: Record<string, unknown>;
29
- }
30
-
31
- export interface DebugState {
32
- enabled: boolean;
33
- breakpoints: Set<string>;
34
- currentStepId: string | null;
35
- pausedAtBreakpoint: boolean;
36
- stepOverPending: boolean;
37
- watchExpressions: string[];
38
- callStack: string[];
39
- }
40
-
41
- interface ExecutionState {
42
- runs: ExecutionRun[];
43
- currentRunId: string | null;
44
- isExecuting: boolean;
45
- isPaused: boolean;
46
- isLoadingHistory: boolean;
47
-
48
- // Debug mode state
49
- debug: DebugState;
50
-
51
- // Existing methods
52
- startExecution: (workflowId: string, workflowName: string, inputs?: Record<string, unknown>) => string;
53
- updateStepStatus: (runId: string, stepId: string, status: StepStatus, output?: unknown, error?: string, outputVariable?: string, inputs?: Record<string, unknown>) => void;
54
- completeExecution: (runId: string, status: WorkflowStatus, outputs?: Record<string, unknown>) => void;
55
- addLog: (runId: string, message: string) => void;
56
- pauseExecution: () => void;
57
- resumeExecution: () => void;
58
- cancelExecution: (runId: string) => void;
59
- clearHistory: () => void;
60
- getRun: (runId: string) => ExecutionRun | undefined;
61
-
62
- // API sync methods
63
- loadHistory: (workflowId?: string) => Promise<void>;
64
- syncRunWithBackend: (runId: string) => Promise<void>;
65
-
66
- // Debug mode methods
67
- enableDebugMode: () => void;
68
- disableDebugMode: () => void;
69
- toggleBreakpoint: (stepId: string) => void;
70
- hasBreakpoint: (stepId: string) => boolean;
71
- clearAllBreakpoints: () => void;
72
- stepOver: () => void;
73
- stepInto: () => void;
74
- stepOut: () => void;
75
- setCurrentDebugStep: (stepId: string | null) => void;
76
- addWatchExpression: (expression: string) => void;
77
- removeWatchExpression: (expression: string) => void;
78
- updateCallStack: (stack: string[]) => void;
79
- }
80
-
81
- const initialDebugState: DebugState = {
82
- enabled: false,
83
- breakpoints: new Set(),
84
- currentStepId: null,
85
- pausedAtBreakpoint: false,
86
- stepOverPending: false,
87
- watchExpressions: [],
88
- callStack: [],
89
- };
90
-
91
- export const useExecutionStore = create<ExecutionState>((set, get) => ({
92
- runs: [],
93
- currentRunId: null,
94
- isExecuting: false,
95
- isPaused: false,
96
- isLoadingHistory: false,
97
- debug: initialDebugState,
98
-
99
- startExecution: (workflowId, workflowName, inputs) => {
100
- const runId = 'run-' + Date.now() + '-' + Math.random().toString(36).slice(2, 8);
101
- const newRun: ExecutionRun = {
102
- id: runId,
103
- workflowId,
104
- workflowName,
105
- status: 'running',
106
- startTime: new Date().toISOString(),
107
- steps: [],
108
- logs: ['Starting workflow execution: ' + workflowName],
109
- inputs,
110
- };
111
-
112
- set({
113
- runs: [newRun, ...get().runs].slice(0, 50), // Keep last 50 runs
114
- currentRunId: runId,
115
- isExecuting: true,
116
- isPaused: false,
117
- });
118
-
119
- return runId;
120
- },
121
-
122
- updateStepStatus: (runId, stepId, status, output, error, outputVariable, inputs) => {
123
- const { debug } = get();
124
-
125
- // Check if we need to pause at breakpoint
126
- const shouldPauseAtBreakpoint = debug.enabled &&
127
- status === 'running' &&
128
- debug.breakpoints.has(stepId);
129
-
130
- set({
131
- runs: get().runs.map((run) => {
132
- if (run.id !== runId) return run;
133
-
134
- const existingStep = run.steps.find((s) => s.stepId === stepId);
135
- const now = new Date().toISOString();
136
-
137
- if (existingStep) {
138
- return {
139
- ...run,
140
- steps: run.steps.map((s) => {
141
- if (s.stepId !== stepId) return s;
142
- const endTime = status !== 'running' ? now : undefined;
143
- const duration = endTime && s.startTime
144
- ? new Date(endTime).getTime() - new Date(s.startTime).getTime()
145
- : undefined;
146
- return {
147
- ...s,
148
- status,
149
- endTime,
150
- duration,
151
- inputs: inputs ?? s.inputs,
152
- output: output ?? s.output,
153
- outputVariable: outputVariable ?? s.outputVariable,
154
- error: error ?? s.error,
155
- };
156
- }),
157
- };
158
- } else {
159
- return {
160
- ...run,
161
- steps: [
162
- ...run.steps,
163
- {
164
- stepId,
165
- stepName: stepId,
166
- status,
167
- startTime: now,
168
- inputs,
169
- output,
170
- outputVariable,
171
- error,
172
- },
173
- ],
174
- };
175
- }
176
- }),
177
- // Update debug state if pausing at breakpoint
178
- ...(shouldPauseAtBreakpoint ? {
179
- isPaused: true,
180
- debug: {
181
- ...get().debug,
182
- currentStepId: stepId,
183
- pausedAtBreakpoint: true,
184
- stepOverPending: false,
185
- },
186
- } : {
187
- debug: {
188
- ...get().debug,
189
- currentStepId: status === 'running' ? stepId : get().debug.currentStepId,
190
- },
191
- }),
192
- });
193
-
194
- // Log breakpoint pause
195
- if (shouldPauseAtBreakpoint) {
196
- get().addLog(runId, `⏸️ Paused at breakpoint: ${stepId}`);
197
- }
198
- },
199
-
200
- completeExecution: (runId, status, outputs) => {
201
- const now = new Date().toISOString();
202
- set({
203
- runs: get().runs.map((run) => {
204
- if (run.id !== runId) return run;
205
- const duration = new Date(now).getTime() - new Date(run.startTime).getTime();
206
- return {
207
- ...run,
208
- status,
209
- endTime: now,
210
- duration,
211
- outputs,
212
- logs: [
213
- ...run.logs,
214
- status === 'completed'
215
- ? 'Workflow completed successfully'
216
- : status === 'failed'
217
- ? 'Workflow execution failed'
218
- : 'Workflow execution cancelled',
219
- ],
220
- };
221
- }),
222
- currentRunId: null,
223
- isExecuting: false,
224
- isPaused: false,
225
- });
226
- },
227
-
228
- addLog: (runId, message) => {
229
- set({
230
- runs: get().runs.map((run) =>
231
- run.id === runId
232
- ? { ...run, logs: [...run.logs, '[' + new Date().toLocaleTimeString() + '] ' + message] }
233
- : run
234
- ),
235
- });
236
- },
237
-
238
- pauseExecution: () => {
239
- set({ isPaused: true });
240
- const { currentRunId, runs } = get();
241
- if (currentRunId) {
242
- const run = runs.find((r) => r.id === currentRunId);
243
- if (run) {
244
- get().addLog(currentRunId, 'Execution paused');
245
- }
246
- }
247
- },
248
-
249
- resumeExecution: () => {
250
- set({ isPaused: false });
251
- const { currentRunId } = get();
252
- if (currentRunId) {
253
- get().addLog(currentRunId, 'Execution resumed');
254
- }
255
- },
256
-
257
- cancelExecution: (runId) => {
258
- get().addLog(runId, 'Execution cancelled by user');
259
- get().completeExecution(runId, 'cancelled');
260
- },
261
-
262
- clearHistory: () => {
263
- set({ runs: [] });
264
- },
265
-
266
- getRun: (runId) => {
267
- return get().runs.find((r) => r.id === runId);
268
- },
269
-
270
- // Debug mode methods
271
- enableDebugMode: () => {
272
- set({
273
- debug: {
274
- ...get().debug,
275
- enabled: true,
276
- },
277
- });
278
- const { currentRunId } = get();
279
- if (currentRunId) {
280
- get().addLog(currentRunId, '🐛 Debug mode enabled');
281
- }
282
- },
283
-
284
- disableDebugMode: () => {
285
- set({
286
- debug: {
287
- ...initialDebugState,
288
- breakpoints: get().debug.breakpoints, // Preserve breakpoints
289
- },
290
- });
291
- const { currentRunId } = get();
292
- if (currentRunId) {
293
- get().addLog(currentRunId, '🐛 Debug mode disabled');
294
- }
295
- },
296
-
297
- toggleBreakpoint: (stepId) => {
298
- const { debug } = get();
299
- const newBreakpoints = new Set(debug.breakpoints);
300
- if (newBreakpoints.has(stepId)) {
301
- newBreakpoints.delete(stepId);
302
- } else {
303
- newBreakpoints.add(stepId);
304
- }
305
- set({
306
- debug: {
307
- ...debug,
308
- breakpoints: newBreakpoints,
309
- },
310
- });
311
- },
312
-
313
- hasBreakpoint: (stepId) => {
314
- return get().debug.breakpoints.has(stepId);
315
- },
316
-
317
- clearAllBreakpoints: () => {
318
- set({
319
- debug: {
320
- ...get().debug,
321
- breakpoints: new Set(),
322
- },
323
- });
324
- const { currentRunId } = get();
325
- if (currentRunId) {
326
- get().addLog(currentRunId, 'All breakpoints cleared');
327
- }
328
- },
329
-
330
- stepOver: () => {
331
- const { debug, currentRunId, isPaused } = get();
332
- if (!isPaused || !debug.enabled) return;
333
-
334
- set({
335
- isPaused: false,
336
- debug: {
337
- ...debug,
338
- stepOverPending: true,
339
- pausedAtBreakpoint: false,
340
- },
341
- });
342
-
343
- if (currentRunId) {
344
- get().addLog(currentRunId, '➡️ Step over');
345
- }
346
- },
347
-
348
- stepInto: () => {
349
- const { debug, currentRunId, isPaused } = get();
350
- if (!isPaused || !debug.enabled) return;
351
-
352
- set({
353
- isPaused: false,
354
- debug: {
355
- ...debug,
356
- stepOverPending: true,
357
- pausedAtBreakpoint: false,
358
- },
359
- });
360
-
361
- if (currentRunId) {
362
- get().addLog(currentRunId, '⬇️ Step into');
363
- }
364
- },
365
-
366
- stepOut: () => {
367
- const { debug, currentRunId, isPaused } = get();
368
- if (!isPaused || !debug.enabled) return;
369
-
370
- set({
371
- isPaused: false,
372
- debug: {
373
- ...debug,
374
- stepOverPending: false,
375
- pausedAtBreakpoint: false,
376
- },
377
- });
378
-
379
- if (currentRunId) {
380
- get().addLog(currentRunId, '⬆️ Step out');
381
- }
382
- },
383
-
384
- setCurrentDebugStep: (stepId) => {
385
- set({
386
- debug: {
387
- ...get().debug,
388
- currentStepId: stepId,
389
- },
390
- });
391
- },
392
-
393
- addWatchExpression: (expression) => {
394
- const { debug } = get();
395
- if (!debug.watchExpressions.includes(expression)) {
396
- set({
397
- debug: {
398
- ...debug,
399
- watchExpressions: [...debug.watchExpressions, expression],
400
- },
401
- });
402
- }
403
- },
404
-
405
- removeWatchExpression: (expression) => {
406
- const { debug } = get();
407
- set({
408
- debug: {
409
- ...debug,
410
- watchExpressions: debug.watchExpressions.filter((e) => e !== expression),
411
- },
412
- });
413
- },
414
-
415
- updateCallStack: (stack) => {
416
- set({
417
- debug: {
418
- ...get().debug,
419
- callStack: stack,
420
- },
421
- });
422
- },
423
-
424
- // API sync methods
425
- loadHistory: async (workflowId) => {
426
- set({ isLoadingHistory: true });
427
- try {
428
- const url = workflowId
429
- ? `/api/executions?workflowId=${encodeURIComponent(workflowId)}&limit=50`
430
- : '/api/executions?limit=50';
431
-
432
- const response = await fetch(url);
433
- if (!response.ok) {
434
- throw new Error('Failed to load execution history');
435
- }
436
-
437
- const executions = await response.json();
438
-
439
- // Convert backend ExecutionRecord format to ExecutionRun format
440
- const runs: ExecutionRun[] = executions.map((exec: any) => ({
441
- id: exec.runId,
442
- workflowId: exec.workflowId,
443
- workflowName: exec.workflowPath.split('/').pop()?.replace('.md', '') || exec.workflowId,
444
- status: exec.status,
445
- startTime: exec.startedAt,
446
- endTime: exec.completedAt || undefined,
447
- duration: exec.completedAt
448
- ? new Date(exec.completedAt).getTime() - new Date(exec.startedAt).getTime()
449
- : undefined,
450
- steps: [],
451
- logs: [],
452
- inputs: exec.inputs || undefined,
453
- outputs: exec.outputs || undefined,
454
- }));
455
-
456
- // Merge with existing runs, avoiding duplicates
457
- const existingRunIds = new Set(get().runs.map((r) => r.id));
458
- const newRuns = runs.filter((r) => !existingRunIds.has(r.id));
459
-
460
- set({
461
- runs: [...get().runs, ...newRuns].slice(0, 50),
462
- isLoadingHistory: false,
463
- });
464
- } catch (error) {
465
- console.error('Error loading execution history:', error);
466
- set({ isLoadingHistory: false });
467
- }
468
- },
469
-
470
- syncRunWithBackend: async (runId) => {
471
- // This would be called to persist a run to the backend
472
- // For now, the backend integration will happen via WebSocket events
473
- // This is a placeholder for future direct API sync
474
- console.log('Syncing run with backend:', runId);
475
- },
476
- }));
477
-
478
- // Helper to format duration
479
- export function formatDuration(ms: number): string {
480
- if (ms < 1000) return ms + 'ms';
481
- if (ms < 60000) return (ms / 1000).toFixed(1) + 's';
482
- const minutes = Math.floor(ms / 60000);
483
- const seconds = Math.floor((ms % 60000) / 1000);
484
- return minutes + 'm ' + seconds + 's';
485
- }
486
-
487
- // Helper to format relative time
488
- export function formatRelativeTime(isoString: string): string {
489
- const now = new Date();
490
- const then = new Date(isoString);
491
- const diffMs = now.getTime() - then.getTime();
492
- const diffSec = Math.floor(diffMs / 1000);
493
- const diffMin = Math.floor(diffSec / 60);
494
- const diffHour = Math.floor(diffMin / 60);
495
- const diffDay = Math.floor(diffHour / 24);
496
-
497
- if (diffSec < 60) return 'just now';
498
- if (diffMin < 60) return diffMin + ' min ago';
499
- if (diffHour < 24) return diffHour + ' hour' + (diffHour > 1 ? 's' : '') + ' ago';
500
- if (diffDay < 7) return diffDay + ' day' + (diffDay > 1 ? 's' : '') + ' ago';
501
- return then.toLocaleDateString();
502
- }
@@ -1,4 +0,0 @@
1
- export { useCanvasStore } from './canvasStore';
2
- export { useWorkflowStore } from './workflowStore';
3
- export { usePromptStore } from './promptStore';
4
- export { useEditorStore } from './editorStore';
@@ -1,103 +0,0 @@
1
- import { create } from 'zustand';
2
- import { persist } from 'zustand/middleware';
3
-
4
- export type Breakpoint = 'mobile' | 'tablet' | 'desktop';
5
-
6
- interface LayoutState {
7
- // Panel visibility
8
- sidebarOpen: boolean;
9
- propertiesPanelOpen: boolean;
10
-
11
- // Mobile menu
12
- mobileMenuOpen: boolean;
13
-
14
- // Current breakpoint (computed from window width)
15
- breakpoint: Breakpoint;
16
-
17
- // Actions
18
- toggleSidebar: () => void;
19
- setSidebarOpen: (open: boolean) => void;
20
- togglePropertiesPanel: () => void;
21
- setPropertiesPanelOpen: (open: boolean) => void;
22
- toggleMobileMenu: () => void;
23
- setMobileMenuOpen: (open: boolean) => void;
24
- setBreakpoint: (breakpoint: Breakpoint) => void;
25
-
26
- // Close all panels (useful for mobile)
27
- closeAllPanels: () => void;
28
- }
29
-
30
- // Breakpoint thresholds
31
- export const BREAKPOINTS = {
32
- mobile: 0,
33
- tablet: 768,
34
- desktop: 1024,
35
- } as const;
36
-
37
- export function getBreakpoint(width: number): Breakpoint {
38
- if (width >= BREAKPOINTS.desktop) return 'desktop';
39
- if (width >= BREAKPOINTS.tablet) return 'tablet';
40
- return 'mobile';
41
- }
42
-
43
- export const useLayoutStore = create<LayoutState>()(
44
- persist(
45
- (set, get) => ({
46
- // Default state - sidebar open on desktop, closed on mobile
47
- sidebarOpen: true,
48
- propertiesPanelOpen: true,
49
- mobileMenuOpen: false,
50
- breakpoint: 'desktop',
51
-
52
- toggleSidebar: () => set((state) => ({ sidebarOpen: !state.sidebarOpen })),
53
- setSidebarOpen: (open) => set({ sidebarOpen: open }),
54
-
55
- togglePropertiesPanel: () =>
56
- set((state) => ({ propertiesPanelOpen: !state.propertiesPanelOpen })),
57
- setPropertiesPanelOpen: (open) => set({ propertiesPanelOpen: open }),
58
-
59
- toggleMobileMenu: () =>
60
- set((state) => ({ mobileMenuOpen: !state.mobileMenuOpen })),
61
- setMobileMenuOpen: (open) => set({ mobileMenuOpen: open }),
62
-
63
- setBreakpoint: (breakpoint) => {
64
- const current = get();
65
- // Auto-manage panels based on breakpoint changes
66
- if (breakpoint === 'mobile') {
67
- set({
68
- breakpoint,
69
- sidebarOpen: false,
70
- propertiesPanelOpen: false,
71
- });
72
- } else if (breakpoint === 'tablet') {
73
- set({
74
- breakpoint,
75
- sidebarOpen: true,
76
- propertiesPanelOpen: false,
77
- });
78
- } else {
79
- set({
80
- breakpoint,
81
- sidebarOpen: true,
82
- propertiesPanelOpen: true,
83
- });
84
- }
85
- },
86
-
87
- closeAllPanels: () =>
88
- set({
89
- sidebarOpen: false,
90
- propertiesPanelOpen: false,
91
- mobileMenuOpen: false,
92
- }),
93
- }),
94
- {
95
- name: 'marktoflow-layout',
96
- partialize: (state) => ({
97
- // Don't persist breakpoint - it's computed from window
98
- sidebarOpen: state.sidebarOpen,
99
- propertiesPanelOpen: state.propertiesPanelOpen,
100
- }),
101
- }
102
- )
103
- );
@@ -1,49 +0,0 @@
1
- import { create } from 'zustand';
2
-
3
- export interface NavigationItem {
4
- id: string;
5
- name: string;
6
- path: string;
7
- }
8
-
9
- interface NavigationState {
10
- // Breadcrumb trail for sub-workflow navigation
11
- breadcrumbs: NavigationItem[];
12
-
13
- // Actions
14
- pushWorkflow: (item: NavigationItem) => void;
15
- popToIndex: (index: number) => void;
16
- popWorkflow: () => void;
17
- resetNavigation: () => void;
18
- setRootWorkflow: (item: NavigationItem) => void;
19
- }
20
-
21
- export const useNavigationStore = create<NavigationState>((set, get) => ({
22
- breadcrumbs: [],
23
-
24
- pushWorkflow: (item) => {
25
- set({ breadcrumbs: [...get().breadcrumbs, item] });
26
- },
27
-
28
- popToIndex: (index) => {
29
- const { breadcrumbs } = get();
30
- if (index >= 0 && index < breadcrumbs.length) {
31
- set({ breadcrumbs: breadcrumbs.slice(0, index + 1) });
32
- }
33
- },
34
-
35
- popWorkflow: () => {
36
- const { breadcrumbs } = get();
37
- if (breadcrumbs.length > 1) {
38
- set({ breadcrumbs: breadcrumbs.slice(0, -1) });
39
- }
40
- },
41
-
42
- resetNavigation: () => {
43
- set({ breadcrumbs: [] });
44
- },
45
-
46
- setRootWorkflow: (item) => {
47
- set({ breadcrumbs: [item] });
48
- },
49
- }));