fix(run): Run starts another instance of a configuration that allows multiple instances (#4187)

run.run reran the selected configuration's running session even with Allow multiple instances, stopping the process. As in IDEA (Rerun/Stop only for configurations that don't run in parallel), such a configuration keeps Run/Debug in the toolbar and Run starts another instance; a tab's Rerun still restarts its session.

Fixes #4148
This commit is contained in:
l0ng-ai
2026-11-18 16:39:53 +08:00
committed by GitHub
parent 923325aeae
commit 23739c90c7
3 changed files with 16 additions and 2 deletions
+10
View File
@@ -116,6 +116,16 @@ it("reruns and stops the selected configuration among several running sessions",
expect(useRun.getState().sessions.map((s) => !!s.stopped)).toEqual([true, false]);
});
it("offers Run for another instance of a running configuration that allows multiple instances", () => {
const parallel = { ...app, allowParallel: true };
useRun.setState({ configs: [parallel, npm], sessions: [run(parallel)] });
render(<RunWidget />);
expect(screen.getByRole("button", { name: `Run '${app.name}'` })).toBeTruthy();
expect(screen.getByRole("button", { name: `Debug '${app.name}'` })).toBeTruthy();
expect(screen.queryByRole("button", { name: /Rerun/ })).toBeNull();
expect(screen.getByRole("button", { name: `Stop '${app.name}'` })).toBeTruthy();
});
it("offers Run/Debug for an idle selection and Stop for the other process", () => {
useRun.setState({ sessions: [run(npm)] });
render(<RunWidget />);
+1 -1
View File
@@ -110,7 +110,7 @@ export function RunWidget() {
/>
)}
</>
) : active ? (
) : active && !selected?.allowParallel ? (
<>
{target?.paused && (
<IconButton
+5 -1
View File
@@ -157,7 +157,11 @@ async function runSelected() {
useRun.setState({ chooserOpen: true, chooserMode: "run" });
return;
}
const target = selectedTarget(config.id, useRun.getState().sessions, useDebugRunSessions.getState().sessions);
// As in IDEA, Run starts another instance of a configuration that allows multiple instances;
// otherwise it restarts the running one.
const target = config.allowParallel
? null
: selectedTarget(config.id, useRun.getState().sessions, useDebugRunSessions.getState().sessions);
if (target) {
target.rerun?.();
return;