From 1757d26e78483dfd4d7fdbeffd6082e9ac02715b Mon Sep 17 00:00:00 2001 From: l0ng-ai Date: Thu, 3 Dec 2026 18:01:23 +0800 Subject: [PATCH] fix(debug): rerun a debug session with its configuration as saved now (#7780) Rerun in the Debug tool window launched the configuration snapshot the session started with, so VM options edited since were ignored. It now launches the configuration saved under that id, or the snapshot when it was deleted. Closes #7750 --- src/features/debugger/__tests__/runOrigin.test.ts | 4 ++-- src/features/debugger/state.ts | 6 +++++- src/features/run/index.ts | 4 +++- src/features/run/remote.test.tsx | 12 ++++++++++++ 4 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/features/debugger/__tests__/runOrigin.test.ts b/src/features/debugger/__tests__/runOrigin.test.ts index eb22f2e6d..538f78d78 100644 --- a/src/features/debugger/__tests__/runOrigin.test.ts +++ b/src/features/debugger/__tests__/runOrigin.test.ts @@ -168,7 +168,7 @@ it("keeps the RunConfig through debug.startConfig and reruns through its debug p expect(useDebugRunSessions.getState().sessions[0]?.configId).toBe(config.id); await rerunSession(42); expect(ipc.debugStop).toHaveBeenCalledWith(42); - expect(restart).toHaveBeenCalledWith(config); + expect(restart).toHaveBeenCalledWith({ config, saved: true }); } finally { dispose(); unregister(); @@ -182,7 +182,7 @@ it("reruns a debug service in place without showing the Debug tool window", asyn try { await executeAction("debug.startConfig", config); await rerunSession(42, { show: false }); - expect(restart).toHaveBeenCalledWith({ config, show: false }); + expect(restart).toHaveBeenCalledWith({ config, saved: true, show: false }); } finally { dispose(); unregister(); diff --git a/src/features/debugger/state.ts b/src/features/debugger/state.ts index 643733ed2..ee990fb1a 100644 --- a/src/features/debugger/state.ts +++ b/src/features/debugger/state.ts @@ -1256,7 +1256,11 @@ export async function rerunSession(id: DebugSessionId, options: { show?: boolean // A session debugged in place from Services reruns there too. const show = options.show ?? (root.inPlace ? false : undefined); if (root.runConfig) - await executeAction("run.debugConfig", show === false ? { config: root.runConfig, show: false } : root.runConfig); + await executeAction("run.debugConfig", { + config: root.runConfig, + saved: true, + ...(show === false ? { show: false } : {}), + }); else await startSession(launch!, { show }); } finally { rerunOf = null; diff --git a/src/features/run/index.ts b/src/features/run/index.ts index 265ab46e8..41ddadacf 100644 --- a/src/features/run/index.ts +++ b/src/features/run/index.ts @@ -434,7 +434,9 @@ function configFromArg(arg: unknown): RunConfig | undefined { if (typeof arg === "string") return useRun.getState().configs.find((c) => c.id === arg); if (!arg || typeof arg !== "object") return undefined; if ("config" in arg) { - const { config, temporary } = arg as { config: RunConfig; temporary?: boolean }; + const { config, temporary, saved } = arg as { config: RunConfig; temporary?: boolean; saved?: boolean }; + // `saved`: a rerun launches the configuration as saved now, edited since it started. + if (saved) return useRun.getState().configs.find((c) => c.id === config.id) ?? config; return temporary ? adoptTemporary(config) : config; } return arg as RunConfig; diff --git a/src/features/run/remote.test.tsx b/src/features/run/remote.test.tsx index ca394a9e1..0bc5cee9b 100644 --- a/src/features/run/remote.test.tsx +++ b/src/features/run/remote.test.tsx @@ -638,6 +638,18 @@ describe("remote debugging", () => { await executeAction("run.debugConfig", local.id); expect(startConfig).toHaveBeenCalledWith(local); }); + + it("reruns the configuration as saved now, edited since the session started (#7750)", async () => { + const started = cfg("app", { debugAdapter: "debugpy" }); + const edited = { ...started, args: ["main.py", "--verbose"] }; + useRun.setState({ configs: [edited], loaded: true }); + await executeAction("run.debugConfig", { config: started, saved: true }); + expect(startConfig).toHaveBeenCalledWith(edited); + // One that was deleted since still reruns as it started. + useRun.setState({ configs: [], loaded: true }); + await executeAction("run.debugConfig", { config: started, saved: true }); + expect(startConfig).toHaveBeenLastCalledWith(started); + }); }); describe("coverage and profiling", () => {