Skip to content

Commit f5f4b5d

Browse files
committed
chore: group vars by scope
1 parent 8ace056 commit f5f4b5d

File tree

4 files changed

+43
-37
lines changed

4 files changed

+43
-37
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ dist
66
score_tally.txt
77
coverage
88
.nyc_output
9-
Issues.md
9+
Issues.md
10+
*.vsix

package.json

Lines changed: 1 addition & 1 deletion
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.22",
5+
"version": "0.0.40",
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",

src/generated-meta.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// Meta info
55
export const publisher = "dkattan"
66
export const name = "copilot-breakpoint-debugger"
7-
export const version = "0.0.22"
7+
export const version = "0.0.40"
88
export const displayName = "Copilot Breakpoint Debugger"
99
export const 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."
1010
export const extensionId = `${publisher}.${name}`

src/startDebuggerTool.ts

Lines changed: 39 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -159,26 +159,27 @@ export class StartDebuggerTool
159159
}
160160

161161
const filterSet = new Set(activeFilters);
162-
const flattened: Array<{
163-
name: string;
164-
value: string;
165-
scope: string;
166-
type?: string;
162+
const groupedVariables: Array<{
163+
scopeName: string;
164+
variables: Array<{ name: string; value: string; type?: string }>;
167165
}> = [];
168166
for (const scope of stopInfo.scopeVariables ?? []) {
169-
for (const variable of scope.variables) {
170-
if (filterSet.size === 0) {
171-
// No filters provided (non-capture breakpoint) => skip reporting variables to keep output concise.
172-
continue;
173-
}
174-
if (filterSet.has(variable.name)) {
175-
flattened.push({
176-
name: variable.name,
177-
value: variable.value,
178-
scope: scope.scopeName,
179-
type: variable.type,
180-
});
181-
}
167+
if (filterSet.size === 0) {
168+
// No filters provided (non-capture breakpoint) => skip reporting variables to keep output concise.
169+
continue;
170+
}
171+
const matchedVars = scope.variables
172+
.filter((variable) => filterSet.has(variable.name))
173+
.map((variable) => ({
174+
name: variable.name,
175+
value: variable.value,
176+
type: variable.type,
177+
}));
178+
if (matchedVars.length) {
179+
groupedVariables.push({
180+
scopeName: scope.scopeName,
181+
variables: matchedVars,
182+
});
182183
}
183184
}
184185

@@ -195,26 +196,29 @@ export class StartDebuggerTool
195196
}
196197
return val;
197198
};
198-
const variableStr = flattened
199-
.map((v) => {
200-
const typePart = v.type ? `:${v.type}` : "";
199+
const variableBlocks = groupedVariables.map((group) => {
200+
const header = `${group.scopeName ?? "Scope"}:`;
201+
const lines = group.variables.map((v) => {
202+
const typePart = v.type ? ` (${v.type})` : "";
201203
const displayValue = formatValue(v.value);
202-
return `${v.name}=${displayValue} (${v.scope}${typePart})`;
203-
})
204-
.join("; ");
204+
return `- ${v.name}=${displayValue}${typePart}`;
205+
});
206+
return [header, ...lines].join("\n");
207+
});
208+
const variableStr = variableBlocks.join("\n");
205209
const fileName = summary.file
206210
? summary.file.split(/[/\\]/).pop()
207211
: "unknown";
208212
const header = `Breakpoint ${fileName}:${summary.line} onHit=${onHit}`;
209213
let bodyVars: string;
210-
if (flattened.length) {
211-
bodyVars = `Vars: ${variableStr}`;
214+
const totalVars = groupedVariables.reduce(
215+
(count, group) => count + group.variables.length,
216+
0
217+
);
218+
if (totalVars) {
219+
bodyVars = `Vars:\n${variableStr}`;
212220
if (autoCapturedScope) {
213-
bodyVars += ` (auto-captured ${
214-
autoCapturedScope.count
215-
} variable(s) from scope '${
216-
autoCapturedScope.name ?? "unknown"
217-
}', cap=${maxAuto})`;
221+
bodyVars += `\n(auto-captured ${autoCapturedScope.count} variable(s) from scope '${autoCapturedScope.name ?? "unknown"}', cap=${maxAuto})`;
218222
}
219223
} else if (autoCapturedScope) {
220224
bodyVars = `Vars: <none> (auto-capture attempted from scope '${
@@ -234,10 +238,11 @@ export class StartDebuggerTool
234238
const timestampLine = `Timestamp: ${new Date().toISOString()}`;
235239
const debuggerStateLine = (() => {
236240
const state = stopInfo.debuggerState;
237-
const sessionLabel = state.sessionName ?? state.sessionId ?? "unknown";
241+
const sessionId = state.sessionId ?? "unknown";
242+
const sessionLabel = state.sessionName ?? sessionId ?? "unknown";
238243
switch (state.status) {
239244
case "paused":
240-
return `Debugger State: paused on '${sessionLabel}'. Recommended tools: resumeDebugSession, getVariables, expandVariable, evaluateExpression, stopDebugSession.`;
245+
return `Debugger State: paused on '${sessionLabel}' (id=${sessionId}). Recommended tools: resumeDebugSession, getVariables, expandVariable, evaluateExpression, stopDebugSession. Example: resumeDebugSession with debugSessionId='${sessionId}'.`;
241246
case "terminated":
242247
return "Debugger State: terminated. Recommended tool: startDebugSessionWithBreakpoints to begin a new session.";
243248
case "running":
@@ -268,7 +273,7 @@ export class StartDebuggerTool
268273

269274
if (onHit === "captureAndContinue" && activeFilters.length === 0) {
270275
guidance.push(
271-
`Tip: captureAndContinue auto-captured ${flattened.length} variable(s); set variableFilter to focus only the names you care about.`
276+
`Tip: captureAndContinue auto-captured ${totalVars} variable(s); set variableFilter to focus only the names you care about.`
272277
);
273278
}
274279

0 commit comments

Comments
 (0)