Skip to content

Commit ded4755

Browse files
committed
chore: stop sessions by id
1 parent 2d1a7ee commit ded4755

File tree

4 files changed

+38
-27
lines changed

4 files changed

+38
-27
lines changed

package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"publisher": "dkattan",
33
"name": "copilot-breakpoint-debugger",
44
"displayName": "Copilot Breakpoint Debugger",
5-
"version": "0.0.40",
5+
"version": "0.0.41",
66
"_versionComment": "Version is auto-generated by the CI auto-release workflow. Manual edits are overwritten.",
77
"description": "Use GitHub Copilot to automate starting, inspecting and resuming VS Code debug sessions with conditional breakpoints, exact numeric hit counts (hitCount), logpoints, and capture actions that interpolate variables inside log messages.",
88
"license": "MIT",
@@ -465,18 +465,18 @@
465465
"displayName": "Stop Debug Session",
466466
"toolReferenceName": "stopDebugSession",
467467
"canBeReferencedInPrompt": true,
468-
"userDescription": "Terminate one or more debug sessions matching a name (exit option).",
469-
"modelDescription": "Stop (terminate) all active debug sessions whose name matches the provided sessionName.",
468+
"userDescription": "Terminate one or more debug sessions by id (aligns with resumeDebugSession).",
469+
"modelDescription": "Stop (terminate) all active debug sessions whose id matches the provided sessionId.",
470470
"inputSchema": {
471471
"type": "object",
472472
"properties": {
473-
"sessionName": {
473+
"sessionId": {
474474
"type": "string",
475-
"description": "Name of the debug session to stop."
475+
"description": "Id of the debug session to stop."
476476
}
477477
},
478478
"required": [
479-
"sessionName"
479+
"sessionId"
480480
]
481481
}
482482
}

src/session.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2311,23 +2311,21 @@ export const startDebuggingAndWaitForStop = async (
23112311
};
23122312

23132313
/**
2314-
* Stop debug sessions that match the provided session name.
2314+
* Stop debug sessions that match the provided session id.
23152315
*
2316-
* @param params - Object containing the sessionName to stop.
2317-
* @param params.sessionName - Name of the debug session(s) to stop.
2316+
* @param params - Object containing the sessionId to stop.
2317+
* @param params.sessionId - ID of the debug session(s) to stop.
23182318
*/
2319-
export const stopDebugSession = async (params: { sessionName: string }) => {
2320-
const { sessionName } = params;
2321-
// Filter active sessions to find matching sessions.
2319+
export const stopDebugSession = async (params: { sessionId: string }) => {
2320+
const { sessionId } = params;
23222321
const matchingSessions = activeSessions.filter(
2323-
(session: vscode.DebugSession) => session.name === sessionName
2322+
(session: vscode.DebugSession) => session.id === sessionId
23242323
);
23252324

23262325
if (matchingSessions.length === 0) {
2327-
throw new Error(`No debug session(s) found with name '${sessionName}'.`);
2326+
throw new Error(`No debug session(s) found with id '${sessionId}'.`);
23282327
}
23292328

2330-
// Stop each matching debug session.
23312329
for (const session of matchingSessions) {
23322330
await vscode.debug.stopDebugging(session);
23332331
}

src/startDebuggerTool.ts

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -244,13 +244,26 @@ export class StartDebuggerTool
244244
const state = stopInfo.debuggerState;
245245
const sessionId = state.sessionId ?? "unknown";
246246
const sessionLabel = state.sessionName ?? sessionId ?? "unknown";
247+
const availableTools = "resumeDebugSession, getVariables, expandVariable, evaluateExpression, stopDebugSession";
247248
switch (state.status) {
248249
case "paused":
249-
return `Debugger State: paused on '${sessionLabel}' (id=${sessionId}). Available tools: resumeDebugSession, getVariables, expandVariable, evaluateExpression, stopDebugSession. Example: resumeDebugSession with debugSessionId='${sessionId}'.`;
250+
return [
251+
`Debugger State: paused on '${sessionLabel}' (id=${sessionId}).`,
252+
`Available tools: ${availableTools}.`,
253+
`Recommended tool: resumeDebugSession with sessionId='${sessionId}'.`,
254+
].join("\r\n");
250255
case "terminated":
251-
return "Debugger State: terminated. Available tool: startDebugSessionWithBreakpoints to begin a new session.";
256+
return [
257+
"Debugger State: terminated.",
258+
"Available tool: startDebugSessionWithBreakpoints to begin a new session.",
259+
"Recommended tool: startDebugSessionWithBreakpoints to create a new session.",
260+
].join("\r\n");
252261
case "running":
253-
return `Debugger State: running. (onHit 'captureAndContinue' continued session '${sessionLabel}'). Available tool: resumeDebugSession with new breakpoints.`;
262+
return [
263+
`Debugger State: running. (onHit 'captureAndContinue' continued session '${sessionLabel}').`,
264+
`Available tools: ${availableTools}.`,
265+
`Recommended tool: resumeDebugSession with sessionId='${sessionId}' to add breakpoints and continue.`,
266+
].join("\r\n");
254267
}
255268
})();
256269

@@ -265,25 +278,25 @@ export class StartDebuggerTool
265278
!hasConfiguredOnHit
266279
) {
267280
guidance.push(
268-
"Tip: No onHit behavior was set; consider onHit 'captureAndContinue' to keep the session alive and still collect data."
281+
"No onHit behavior was set; consider onHit 'captureAndContinue' to keep the session alive and still collect data."
269282
);
270283
}
271284

272285
if (!multipleBreakpoints) {
273286
guidance.push(
274-
"Tip: You can supply multiple breakpoints, each with its own onHit (e.g., trace with captureAndContinue, then stopDebugging at a later line)."
287+
"You can supply multiple breakpoints, each with its own onHit (e.g., trace with captureAndContinue, then stopDebugging at a later line)."
275288
);
276289
}
277290

278291
if (onHit === "captureAndContinue" && activeFilters.length === 0) {
279292
guidance.push(
280-
`Tip: captureAndContinue auto-captured ${totalVars} variable(s); set variableFilter to focus only the names you care about.`
293+
`captureAndContinue auto-captured ${totalVars} variable(s); set variableFilter to focus only the names you care about.`
281294
);
282295
}
283296

284297
if (truncatedVariables) {
285298
guidance.push(
286-
"Tip: Values were truncated to 100 characters. Provide variableFilter to return full values without truncation."
299+
"Values were truncated to 100 characters. Provide variableFilter to return full values without truncation."
287300
);
288301
}
289302

src/stopDebugSessionTool.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { LanguageModelTextPart, LanguageModelToolResult } from "vscode";
99
import { stopDebugSession } from "./session";
1010

1111
export interface StopDebugSessionToolParameters {
12-
sessionName: string; // Name of session to stop (supports multiple with same name)
12+
sessionId: string; // ID of session to stop (aligns with resumeDebugSession)
1313
}
1414

1515
export class StopDebugSessionTool
@@ -18,12 +18,12 @@ export class StopDebugSessionTool
1818
async invoke(
1919
options: LanguageModelToolInvocationOptions<StopDebugSessionToolParameters>
2020
): Promise<LanguageModelToolResult> {
21-
const { sessionName } = options.input;
21+
const { sessionId } = options.input;
2222
try {
23-
await stopDebugSession({ sessionName });
23+
await stopDebugSession({ sessionId });
2424
return new LanguageModelToolResult([
2525
new LanguageModelTextPart(
26-
`Stopped debug session(s) named '${sessionName}'.`
26+
`Stopped debug session(s) with id '${sessionId}'.`
2727
),
2828
]);
2929
} catch (error) {
@@ -41,7 +41,7 @@ export class StopDebugSessionTool
4141
options: LanguageModelToolInvocationPrepareOptions<StopDebugSessionToolParameters>
4242
): ProviderResult<vscode.PreparedToolInvocation> {
4343
return {
44-
invocationMessage: `Stopping debug session(s) named '${options.input.sessionName}'`,
44+
invocationMessage: `Stopping debug session(s) with id '${options.input.sessionId}'`,
4545
};
4646
}
4747
}

0 commit comments

Comments
 (0)