fix step duplication

This commit is contained in:
Francesco Renzi
2026-01-22 11:42:34 +00:00
committed by GitHub
parent 514d122c9d
commit 7156f0a195
3 changed files with 198 additions and 1 deletions

View File

@@ -1770,8 +1770,8 @@ namespace GitHub.Runner.Worker.Dap
}
// Reset the step manipulator to match the restored state
// It will be re-initialized when the restored step starts
_stepManipulator?.ClearChanges();
_stepManipulator?.TrimCompletedSteps(checkpointIndex);
// Store restored checkpoint for StepsRunner to consume
_restoredCheckpoint = checkpoint;

View File

@@ -114,6 +114,13 @@ namespace GitHub.Runner.Worker.Dap.StepCommands
/// </summary>
void ClearChanges();
/// <summary>
/// Trims the completed steps list to the specified count.
/// Used when restoring a checkpoint to sync state with the debug session.
/// </summary>
/// <param name="count">The number of completed steps to keep.</param>
void TrimCompletedSteps(int count);
/// <summary>
/// Checks if a step with the given ID already exists.
/// </summary>
@@ -576,6 +583,17 @@ namespace GitHub.Runner.Worker.Dap.StepCommands
_originalSteps = null;
}
/// <inheritdoc/>
public void TrimCompletedSteps(int count)
{
var originalCount = _completedSteps.Count;
while (_completedSteps.Count > count)
{
_completedSteps.RemoveAt(_completedSteps.Count - 1);
}
Trace.Info($"Trimmed completed steps from {originalCount} to {_completedSteps.Count}");
}
/// <inheritdoc/>
public bool HasStepWithId(string id)
{