@goplasmatic/dataflow-ui 2.0.12 → 2.0.13

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/index.cjs CHANGED
@@ -584,6 +584,15 @@ const initialState = {
584
584
  executionError: null,
585
585
  skipFailedConditions: false
586
586
  };
587
+ function getFilteredStepIndices(trace, skipFailedConditions) {
588
+ if (!trace || trace.steps.length === 0) {
589
+ return [];
590
+ }
591
+ if (!skipFailedConditions) {
592
+ return trace.steps.map((_2, i) => i);
593
+ }
594
+ return trace.steps.map((step, i) => ({ step, index: i })).filter(({ step }) => step.result !== "skipped").map(({ index: index2 }) => index2);
595
+ }
587
596
  function debuggerReducer(state, action) {
588
597
  switch (action.type) {
589
598
  case "ACTIVATE":
@@ -656,34 +665,54 @@ function debuggerReducer(state, action) {
656
665
  if (!state.trace || state.trace.steps.length === 0) {
657
666
  return state;
658
667
  }
659
- let nextIndex = state.currentStepIndex + 1;
660
- if (state.skipFailedConditions) {
661
- while (nextIndex < state.trace.steps.length && state.trace.steps[nextIndex].result === "skipped") {
662
- nextIndex++;
663
- }
668
+ const filteredIndices = getFilteredStepIndices(state.trace, state.skipFailedConditions);
669
+ if (filteredIndices.length === 0) {
670
+ return state;
664
671
  }
665
- if (nextIndex >= state.trace.steps.length) {
672
+ const currentFilteredPos = filteredIndices.findIndex((i) => i === state.currentStepIndex);
673
+ let nextIndex;
674
+ if (state.currentStepIndex === -1) {
675
+ nextIndex = filteredIndices[0];
676
+ } else if (currentFilteredPos === -1) {
677
+ nextIndex = filteredIndices[0];
678
+ } else if (currentFilteredPos >= filteredIndices.length - 1) {
666
679
  return {
667
680
  ...state,
668
- currentStepIndex: state.trace.steps.length - 1,
669
- // Go to last step
670
681
  playbackState: "paused"
671
- // Auto-pause at end
672
682
  };
683
+ } else {
684
+ nextIndex = filteredIndices[currentFilteredPos + 1];
673
685
  }
674
686
  return {
675
687
  ...state,
676
688
  currentStepIndex: nextIndex
677
689
  };
678
690
  }
679
- case "STEP_BACKWARD":
680
- if (state.currentStepIndex <= -1) return state;
691
+ case "STEP_BACKWARD": {
692
+ if (!state.trace || state.currentStepIndex <= -1) {
693
+ return state;
694
+ }
695
+ const filteredIndices = getFilteredStepIndices(state.trace, state.skipFailedConditions);
696
+ if (filteredIndices.length === 0) {
697
+ return {
698
+ ...state,
699
+ currentStepIndex: -1,
700
+ playbackState: "paused"
701
+ };
702
+ }
703
+ const currentFilteredPos = filteredIndices.findIndex((i) => i === state.currentStepIndex);
704
+ let prevIndex;
705
+ if (currentFilteredPos <= 0) {
706
+ prevIndex = -1;
707
+ } else {
708
+ prevIndex = filteredIndices[currentFilteredPos - 1];
709
+ }
681
710
  return {
682
711
  ...state,
683
- currentStepIndex: state.currentStepIndex - 1,
712
+ currentStepIndex: prevIndex,
684
713
  playbackState: "paused"
685
- // Pause on manual step
686
714
  };
715
+ }
687
716
  case "GO_TO_STEP":
688
717
  if (!state.trace || action.index < 0 || action.index >= state.trace.steps.length) return state;
689
718
  return {
@@ -697,11 +726,25 @@ function debuggerReducer(state, action) {
697
726
  ...state,
698
727
  playbackSpeed: Math.max(100, Math.min(2e3, action.speed))
699
728
  };
700
- case "SET_SKIP_FAILED_CONDITIONS":
729
+ case "SET_SKIP_FAILED_CONDITIONS": {
730
+ if (action.skip && state.trace && state.currentStepIndex >= 0) {
731
+ const currentStep = state.trace.steps[state.currentStepIndex];
732
+ if (currentStep && currentStep.result === "skipped") {
733
+ const filteredIndices = getFilteredStepIndices(state.trace, true);
734
+ const nextValidIndex = filteredIndices.find((i) => i > state.currentStepIndex);
735
+ const prevValidIndex = [...filteredIndices].reverse().find((i) => i < state.currentStepIndex);
736
+ return {
737
+ ...state,
738
+ skipFailedConditions: action.skip,
739
+ currentStepIndex: nextValidIndex ?? prevValidIndex ?? -1
740
+ };
741
+ }
742
+ }
701
743
  return {
702
744
  ...state,
703
745
  skipFailedConditions: action.skip
704
746
  };
747
+ }
705
748
  default:
706
749
  return state;
707
750
  }
@@ -801,11 +844,13 @@ function DebuggerProvider({
801
844
  const currentStep = state.trace && state.currentStepIndex >= 0 ? state.trace.steps[state.currentStepIndex] : null;
802
845
  const currentMessage = state.trace && state.currentStepIndex >= 0 ? getMessageAtStep(state.trace, state.currentStepIndex) : null;
803
846
  const currentChanges = state.trace && state.currentStepIndex >= 0 ? getChangesAtStep(state.trace, state.currentStepIndex) : [];
804
- const totalSteps = state.trace ? state.trace.steps.length : 0;
847
+ const filteredStepIndices = getFilteredStepIndices(state.trace, state.skipFailedConditions);
848
+ const totalSteps = filteredStepIndices.length;
849
+ const currentFilteredPos = state.currentStepIndex >= 0 ? filteredStepIndices.findIndex((i) => i === state.currentStepIndex) : -1;
805
850
  const isAtStart = state.currentStepIndex <= -1;
806
- const isAtEnd = state.currentStepIndex >= totalSteps - 1 && state.currentStepIndex >= 0;
851
+ const isAtEnd = currentFilteredPos >= totalSteps - 1 && currentFilteredPos >= 0;
807
852
  const hasTrace = state.trace !== null && totalSteps > 0;
808
- const progress = totalSteps > 0 && state.currentStepIndex >= 0 ? (state.currentStepIndex + 1) / totalSteps : 0;
853
+ const progress = totalSteps > 0 && currentFilteredPos >= 0 ? (currentFilteredPos + 1) / totalSteps : 0;
809
854
  const value = {
810
855
  state,
811
856
  dispatch: dispatch2,
@@ -833,6 +878,8 @@ function DebuggerProvider({
833
878
  hasTrace,
834
879
  progress,
835
880
  totalSteps,
881
+ currentFilteredPosition: currentFilteredPos,
882
+ filteredStepIndices,
836
883
  isEngineReady,
837
884
  skipFailedConditions: state.skipFailedConditions
838
885
  };
@@ -21122,11 +21169,13 @@ function IntegratedDebugToolbar({
21122
21169
  isAtEnd,
21123
21170
  hasTrace,
21124
21171
  totalSteps,
21172
+ currentFilteredPosition,
21173
+ filteredStepIndices,
21125
21174
  isEngineReady,
21126
21175
  skipFailedConditions,
21127
21176
  setSkipFailedConditions
21128
21177
  } = useDebugger();
21129
- const { playbackState, currentStepIndex, isExecuting, executionError, trace } = state;
21178
+ const { playbackState, isExecuting, executionError, trace } = state;
21130
21179
  const lastExecutionRef = require$$0.useRef(null);
21131
21180
  const handleExecute = require$$0.useCallback(async () => {
21132
21181
  var _a, _b;
@@ -21171,10 +21220,10 @@ function IntegratedDebugToolbar({
21171
21220
  }
21172
21221
  }, [hasTrace, stop]);
21173
21222
  const goToLast = require$$0.useCallback(() => {
21174
- if (hasTrace && totalSteps > 0) {
21175
- goToStep(totalSteps - 1);
21223
+ if (hasTrace && filteredStepIndices.length > 0) {
21224
+ goToStep(filteredStepIndices[filteredStepIndices.length - 1]);
21176
21225
  }
21177
- }, [hasTrace, totalSteps, goToStep]);
21226
+ }, [hasTrace, filteredStepIndices, goToStep]);
21178
21227
  require$$0.useEffect(() => {
21179
21228
  if (!autoExecute || !isEngineReady || workflows.length === 0) return;
21180
21229
  const timeoutId = setTimeout(() => {
@@ -21259,10 +21308,10 @@ function IntegratedDebugToolbar({
21259
21308
  if (!hasTrace) {
21260
21309
  return "Ready";
21261
21310
  }
21262
- if (currentStepIndex < 0) {
21311
+ if (currentFilteredPosition < 0) {
21263
21312
  return "Ready";
21264
21313
  }
21265
- return `Step ${currentStepIndex + 1} / ${totalSteps}`;
21314
+ return `Step ${currentFilteredPosition + 1} / ${totalSteps}`;
21266
21315
  };
21267
21316
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `df-debug-toolbar-integrated ${className}`, children: [
21268
21317
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "df-debug-toolbar-status", children: [
package/dist/index.d.ts CHANGED
@@ -197,6 +197,10 @@ declare interface DebuggerContextValue {
197
197
  hasTrace: boolean;
198
198
  progress: number;
199
199
  totalSteps: number;
200
+ /** Current position within filtered steps (0-indexed), -1 if at ready state */
201
+ currentFilteredPosition: number;
202
+ /** Array of actual step indices that are shown (for navigation) */
203
+ filteredStepIndices: number[];
200
204
  isEngineReady: boolean;
201
205
  skipFailedConditions: boolean;
202
206
  }
package/dist/index.js CHANGED
@@ -582,6 +582,15 @@ const initialState = {
582
582
  executionError: null,
583
583
  skipFailedConditions: false
584
584
  };
585
+ function getFilteredStepIndices(trace, skipFailedConditions) {
586
+ if (!trace || trace.steps.length === 0) {
587
+ return [];
588
+ }
589
+ if (!skipFailedConditions) {
590
+ return trace.steps.map((_2, i) => i);
591
+ }
592
+ return trace.steps.map((step, i) => ({ step, index: i })).filter(({ step }) => step.result !== "skipped").map(({ index: index2 }) => index2);
593
+ }
585
594
  function debuggerReducer(state, action) {
586
595
  switch (action.type) {
587
596
  case "ACTIVATE":
@@ -654,34 +663,54 @@ function debuggerReducer(state, action) {
654
663
  if (!state.trace || state.trace.steps.length === 0) {
655
664
  return state;
656
665
  }
657
- let nextIndex = state.currentStepIndex + 1;
658
- if (state.skipFailedConditions) {
659
- while (nextIndex < state.trace.steps.length && state.trace.steps[nextIndex].result === "skipped") {
660
- nextIndex++;
661
- }
666
+ const filteredIndices = getFilteredStepIndices(state.trace, state.skipFailedConditions);
667
+ if (filteredIndices.length === 0) {
668
+ return state;
662
669
  }
663
- if (nextIndex >= state.trace.steps.length) {
670
+ const currentFilteredPos = filteredIndices.findIndex((i) => i === state.currentStepIndex);
671
+ let nextIndex;
672
+ if (state.currentStepIndex === -1) {
673
+ nextIndex = filteredIndices[0];
674
+ } else if (currentFilteredPos === -1) {
675
+ nextIndex = filteredIndices[0];
676
+ } else if (currentFilteredPos >= filteredIndices.length - 1) {
664
677
  return {
665
678
  ...state,
666
- currentStepIndex: state.trace.steps.length - 1,
667
- // Go to last step
668
679
  playbackState: "paused"
669
- // Auto-pause at end
670
680
  };
681
+ } else {
682
+ nextIndex = filteredIndices[currentFilteredPos + 1];
671
683
  }
672
684
  return {
673
685
  ...state,
674
686
  currentStepIndex: nextIndex
675
687
  };
676
688
  }
677
- case "STEP_BACKWARD":
678
- if (state.currentStepIndex <= -1) return state;
689
+ case "STEP_BACKWARD": {
690
+ if (!state.trace || state.currentStepIndex <= -1) {
691
+ return state;
692
+ }
693
+ const filteredIndices = getFilteredStepIndices(state.trace, state.skipFailedConditions);
694
+ if (filteredIndices.length === 0) {
695
+ return {
696
+ ...state,
697
+ currentStepIndex: -1,
698
+ playbackState: "paused"
699
+ };
700
+ }
701
+ const currentFilteredPos = filteredIndices.findIndex((i) => i === state.currentStepIndex);
702
+ let prevIndex;
703
+ if (currentFilteredPos <= 0) {
704
+ prevIndex = -1;
705
+ } else {
706
+ prevIndex = filteredIndices[currentFilteredPos - 1];
707
+ }
679
708
  return {
680
709
  ...state,
681
- currentStepIndex: state.currentStepIndex - 1,
710
+ currentStepIndex: prevIndex,
682
711
  playbackState: "paused"
683
- // Pause on manual step
684
712
  };
713
+ }
685
714
  case "GO_TO_STEP":
686
715
  if (!state.trace || action.index < 0 || action.index >= state.trace.steps.length) return state;
687
716
  return {
@@ -695,11 +724,25 @@ function debuggerReducer(state, action) {
695
724
  ...state,
696
725
  playbackSpeed: Math.max(100, Math.min(2e3, action.speed))
697
726
  };
698
- case "SET_SKIP_FAILED_CONDITIONS":
727
+ case "SET_SKIP_FAILED_CONDITIONS": {
728
+ if (action.skip && state.trace && state.currentStepIndex >= 0) {
729
+ const currentStep = state.trace.steps[state.currentStepIndex];
730
+ if (currentStep && currentStep.result === "skipped") {
731
+ const filteredIndices = getFilteredStepIndices(state.trace, true);
732
+ const nextValidIndex = filteredIndices.find((i) => i > state.currentStepIndex);
733
+ const prevValidIndex = [...filteredIndices].reverse().find((i) => i < state.currentStepIndex);
734
+ return {
735
+ ...state,
736
+ skipFailedConditions: action.skip,
737
+ currentStepIndex: nextValidIndex ?? prevValidIndex ?? -1
738
+ };
739
+ }
740
+ }
699
741
  return {
700
742
  ...state,
701
743
  skipFailedConditions: action.skip
702
744
  };
745
+ }
703
746
  default:
704
747
  return state;
705
748
  }
@@ -799,11 +842,13 @@ function DebuggerProvider({
799
842
  const currentStep = state.trace && state.currentStepIndex >= 0 ? state.trace.steps[state.currentStepIndex] : null;
800
843
  const currentMessage = state.trace && state.currentStepIndex >= 0 ? getMessageAtStep(state.trace, state.currentStepIndex) : null;
801
844
  const currentChanges = state.trace && state.currentStepIndex >= 0 ? getChangesAtStep(state.trace, state.currentStepIndex) : [];
802
- const totalSteps = state.trace ? state.trace.steps.length : 0;
845
+ const filteredStepIndices = getFilteredStepIndices(state.trace, state.skipFailedConditions);
846
+ const totalSteps = filteredStepIndices.length;
847
+ const currentFilteredPos = state.currentStepIndex >= 0 ? filteredStepIndices.findIndex((i) => i === state.currentStepIndex) : -1;
803
848
  const isAtStart = state.currentStepIndex <= -1;
804
- const isAtEnd = state.currentStepIndex >= totalSteps - 1 && state.currentStepIndex >= 0;
849
+ const isAtEnd = currentFilteredPos >= totalSteps - 1 && currentFilteredPos >= 0;
805
850
  const hasTrace = state.trace !== null && totalSteps > 0;
806
- const progress = totalSteps > 0 && state.currentStepIndex >= 0 ? (state.currentStepIndex + 1) / totalSteps : 0;
851
+ const progress = totalSteps > 0 && currentFilteredPos >= 0 ? (currentFilteredPos + 1) / totalSteps : 0;
807
852
  const value = {
808
853
  state,
809
854
  dispatch: dispatch2,
@@ -831,6 +876,8 @@ function DebuggerProvider({
831
876
  hasTrace,
832
877
  progress,
833
878
  totalSteps,
879
+ currentFilteredPosition: currentFilteredPos,
880
+ filteredStepIndices,
834
881
  isEngineReady,
835
882
  skipFailedConditions: state.skipFailedConditions
836
883
  };
@@ -21120,11 +21167,13 @@ function IntegratedDebugToolbar({
21120
21167
  isAtEnd,
21121
21168
  hasTrace,
21122
21169
  totalSteps,
21170
+ currentFilteredPosition,
21171
+ filteredStepIndices,
21123
21172
  isEngineReady,
21124
21173
  skipFailedConditions,
21125
21174
  setSkipFailedConditions
21126
21175
  } = useDebugger();
21127
- const { playbackState, currentStepIndex, isExecuting, executionError, trace } = state;
21176
+ const { playbackState, isExecuting, executionError, trace } = state;
21128
21177
  const lastExecutionRef = useRef(null);
21129
21178
  const handleExecute = useCallback(async () => {
21130
21179
  var _a, _b;
@@ -21169,10 +21218,10 @@ function IntegratedDebugToolbar({
21169
21218
  }
21170
21219
  }, [hasTrace, stop]);
21171
21220
  const goToLast = useCallback(() => {
21172
- if (hasTrace && totalSteps > 0) {
21173
- goToStep(totalSteps - 1);
21221
+ if (hasTrace && filteredStepIndices.length > 0) {
21222
+ goToStep(filteredStepIndices[filteredStepIndices.length - 1]);
21174
21223
  }
21175
- }, [hasTrace, totalSteps, goToStep]);
21224
+ }, [hasTrace, filteredStepIndices, goToStep]);
21176
21225
  useEffect(() => {
21177
21226
  if (!autoExecute || !isEngineReady || workflows.length === 0) return;
21178
21227
  const timeoutId = setTimeout(() => {
@@ -21257,10 +21306,10 @@ function IntegratedDebugToolbar({
21257
21306
  if (!hasTrace) {
21258
21307
  return "Ready";
21259
21308
  }
21260
- if (currentStepIndex < 0) {
21309
+ if (currentFilteredPosition < 0) {
21261
21310
  return "Ready";
21262
21311
  }
21263
- return `Step ${currentStepIndex + 1} / ${totalSteps}`;
21312
+ return `Step ${currentFilteredPosition + 1} / ${totalSteps}`;
21264
21313
  };
21265
21314
  return /* @__PURE__ */ jsxs("div", { className: `df-debug-toolbar-integrated ${className}`, children: [
21266
21315
  /* @__PURE__ */ jsxs("div", { className: "df-debug-toolbar-status", children: [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@goplasmatic/dataflow-ui",
3
- "version": "2.0.12",
3
+ "version": "2.0.13",
4
4
  "type": "module",
5
5
  "description": "React visualization library for dataflow-rs workflow engine",
6
6
  "author": "Plasmatic Engineering <shankar@goplasmatic.io>",