diff --git a/extension/src/command-handler.ts b/extension/src/command-handler.ts index ca9ee30..b0106e2 100644 --- a/extension/src/command-handler.ts +++ b/extension/src/command-handler.ts @@ -25,6 +25,8 @@ export interface CommandHandlerContext { onAutoApproveChanged: (enabled: boolean) => void; /** Track recently sent Discord→AG texts to avoid echo relay */ recentDiscordSentTexts: Map; + /** Get the active cascade/session ID from step-probe polling state */ + getActiveSessionId: () => string; } // ─── File-based command watcher ─── @@ -127,10 +129,12 @@ export function handleWSCommand(ctx: CommandHandlerContext, data: { text?: strin * This is the same mechanism AG's native red ■ stop button uses. */ async function _cancelCurrentCascade(ctx: CommandHandlerContext) { - // 1. Get the active cascade ID from SDK titles manager - const cascadeId = ctx.sdk?.titles?.getActiveCascadeId?.(); + // 1. Get the active cascade ID from extension state (step-probe polling) + // NOTE: ctx.sdk.titles.getActiveCascadeId() is renderer-only (DOM scraping) + // and always returns undefined from extension host. Use activeSessionId instead. + const cascadeId = ctx.getActiveSessionId(); if (!cascadeId) { - ctx.logToFile('[STOP] No active cascade to cancel (getActiveCascadeId returned null)'); + ctx.logToFile('[STOP] No active cascade — no session tracked yet'); return; } diff --git a/extension/src/extension.ts b/extension/src/extension.ts index 2fbe548..b33c407 100644 --- a/extension/src/extension.ts +++ b/extension/src/extension.ts @@ -430,6 +430,7 @@ export async function activate(context: vscode.ExtensionContext) { bridgePath, projectName, sdk, ls: sdk?.ls, autoApproveEnabled, logToFile, onAutoApproveChanged: (enabled: boolean) => { autoApproveEnabled = enabled; }, recentDiscordSentTexts, + getActiveSessionId: () => activeSessionId, }, data); }, onInstanceUpdate: (count, instances) => { @@ -559,6 +560,7 @@ export async function activate(context: vscode.ExtensionContext) { bridgePath, projectName, sdk, ls: sdk?.ls, autoApproveEnabled, logToFile, onAutoApproveChanged: (enabled: boolean) => { autoApproveEnabled = enabled; }, recentDiscordSentTexts, + getActiveSessionId: () => activeSessionId, }); // Response watcher is now initialized by initStepProbe() above