From a55696a429267e2f0ce0623f2c6456438a4fc4f1 Mon Sep 17 00:00:00 2001 From: Francesco Renzi Date: Wed, 14 Jan 2026 21:05:55 +0000 Subject: [PATCH] Phase 3 complete --- .opencode/plans/dap-debugging.md | 2 +- src/Runner.Worker/StepsRunner.cs | 26 +++++++++++++++++++++++++- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/.opencode/plans/dap-debugging.md b/.opencode/plans/dap-debugging.md index 206b29f18..cac7d49cf 100644 --- a/.opencode/plans/dap-debugging.md +++ b/.opencode/plans/dap-debugging.md @@ -8,7 +8,7 @@ - [x] **Phase 1:** DAP Protocol Infrastructure (DapMessages.cs, DapServer.cs, basic DapDebugSession.cs) - [x] **Phase 2:** Debug Session Logic (DapVariableProvider.cs, variable inspection, step history tracking) -- [ ] **Phase 3:** StepsRunner Integration (pause hooks before/after step execution) +- [x] **Phase 3:** StepsRunner Integration (pause hooks before/after step execution) - [ ] **Phase 4:** Expression Evaluation & Shell (REPL) - [ ] **Phase 5:** Startup Integration (JobRunner.cs modifications) diff --git a/src/Runner.Worker/StepsRunner.cs b/src/Runner.Worker/StepsRunner.cs index 83ce87f64..a9125914d 100644 --- a/src/Runner.Worker/StepsRunner.cs +++ b/src/Runner.Worker/StepsRunner.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; @@ -10,6 +10,7 @@ using GitHub.DistributedTask.WebApi; using GitHub.Runner.Common; using GitHub.Runner.Common.Util; using GitHub.Runner.Sdk; +using GitHub.Runner.Worker.Dap; using GitHub.Runner.Worker.Expressions; namespace GitHub.Runner.Worker @@ -50,6 +51,12 @@ namespace GitHub.Runner.Worker jobContext.JobContext.Status = (jobContext.Result ?? TaskResult.Succeeded).ToActionResult(); var scopeInputs = new Dictionary(StringComparer.OrdinalIgnoreCase); bool checkPostJobActions = false; + + // Get debug session for DAP debugging support + // The session's IsActive property determines if debugging is actually enabled + var debugSession = HostContext.GetService(); + bool isFirstStep = true; + while (jobContext.JobSteps.Count > 0 || !checkPostJobActions) { if (jobContext.JobSteps.Count == 0 && !checkPostJobActions) @@ -181,6 +188,14 @@ namespace GitHub.Runner.Worker } } + // Pause for DAP debugger BEFORE step execution + // This happens after expression values are set up so the debugger can inspect variables + if (debugSession?.IsActive == true) + { + await debugSession.OnStepStartingAsync(step, jobContext, isFirstStep); + isFirstStep = false; + } + // Evaluate condition step.ExecutionContext.Debug($"Evaluating condition for step: '{step.DisplayName}'"); var conditionTraceWriter = new ConditionTraceWriter(Trace, step.ExecutionContext); @@ -253,8 +268,17 @@ namespace GitHub.Runner.Worker Trace.Info($"No need for updating job result with current step result '{step.ExecutionContext.Result}'."); } + // Notify DAP debugger AFTER step execution + if (debugSession?.IsActive == true) + { + debugSession.OnStepCompleted(step); + } + Trace.Info($"Current state: job state = '{jobContext.Result}'"); } + + // Notify DAP debugger that the job has completed + debugSession?.OnJobCompleted(); } private async Task RunStepAsync(IStep step, CancellationToken jobCancellationToken)