feat(plugins): run lifecycle events, run.stop, configuration upsert, Java debug attach, log tail tabs and console toolbar (API 1.21) (#7776)

Plugin API 1.21:
- run-started events, and run-exited for user-launched plugin configurations (plugins on API 1.21 only).
- run.stop(id) for runs of the plugin's own configurations; run.upsert-configuration and run.open-edit-configurations for the plugin's own run configuration types.
- prepareCommand receives the run/debug mode; plugin configurations can declare a loopback JDWP attach target.
- runConfigTypes.ownsBeforeLaunch, log file tabs in the run console (plugin_run_log_tail, authorised by the plugin's project.read / fs.read grants), and the runConsole.toolbar menu in the Run and Debug consoles.

Review fixes: RunView log tab state keyed by the string session id, tail chunks cut on a UTF-8 boundary, user-run exits gated to API 1.21.

Co-authored-by: RuyimgByCN <[email protected]>
Цей коміт міститься в:
RuyimgByCN authored and GitHub committed 2026-12-03 20:29:31 +08:00
1 джерело f213999338
коміт b83c1a60c2
218 files changed
+1794 -289

No files matched your search

+54 -1
Переглянути файл
@@ -19,7 +19,8 @@ import {
optsOutOfAttach,
} from "@/platform/javaLaunch";
import { applyBuildPolicyToCommand } from "./buildCommand";
import { startRun, useRun } from "./store";
import { parsePluginJavaDebug } from "@/workbench/contributions";
import { startRun, useRun, type RunSession } from "./store";
import { isJunitRunner } from "./application";
import { DELEGATED_ATTACH_LISTENER, DELEGATED_DEBUG, DELEGATED_MAIN } from "./gradleRun";
import { isWindows } from "./jvmTypes";
@@ -214,3 +215,55 @@ export async function debugWithAgent(config: RunConfig, show?: boolean): Promise
waiting.splice(0).forEach(attach);
return true;
}
/** Starts a plugin configuration and attaches Java JDWP over loopback once listening (API 1.21). */
export async function debugPluginJava(
config: RunConfig,
options: {
origin?: RunConfig;
show?: boolean;
prepared?: boolean;
typePrepared?: boolean;
onExit?: (code: number | null, stopped: boolean) => void;
} = {},
): Promise<RunSession | null> {
const target = parsePluginJavaDebug(config);
if (!target) return null;
if (!(await attachDebuggerReady(config, options.show))) return null;
let sessionId: string | null = null;
let attachedPort: number | null = null;
const waiting: number[] = [];
const attach = (port: number) => {
if (attachedPort !== null) return;
attachedPort = port;
const runId = useRun.getState().sessions.find((s) => s.id === sessionId)?.runId ?? null;
void executeAction("debug.attach", {
name: config.name,
module: config.module ?? config.cwd ?? "",
hostName: target.host,
port,
process: runId,
runConfig: options.origin ?? config,
show: options.show,
});
};
const session = await startRun(config, undefined, undefined, {
show: options.show,
prepared: options.prepared,
typePrepared: options.typePrepared,
onExit: options.onExit,
onLine: (line) => {
const port = jdwpListeningPort(line);
if (port === null) return;
if (sessionId) attach(port);
else waiting.push(port);
},
});
if (!session) return null;
sessionId = session.id;
const detected = waiting.shift() ?? target.port;
if (detected !== undefined) {
attach(detected);
}
return session;
}