fix: stop command uses activeSessionId instead of renderer-only getActiveCascadeId #task-411
This commit is contained in:
@@ -25,6 +25,8 @@ export interface CommandHandlerContext {
|
|||||||
onAutoApproveChanged: (enabled: boolean) => void;
|
onAutoApproveChanged: (enabled: boolean) => void;
|
||||||
/** Track recently sent Discord→AG texts to avoid echo relay */
|
/** Track recently sent Discord→AG texts to avoid echo relay */
|
||||||
recentDiscordSentTexts: Map<string, number>;
|
recentDiscordSentTexts: Map<string, number>;
|
||||||
|
/** Get the active cascade/session ID from step-probe polling state */
|
||||||
|
getActiveSessionId: () => string;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ─── File-based command watcher ───
|
// ─── 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.
|
* This is the same mechanism AG's native red ■ stop button uses.
|
||||||
*/
|
*/
|
||||||
async function _cancelCurrentCascade(ctx: CommandHandlerContext) {
|
async function _cancelCurrentCascade(ctx: CommandHandlerContext) {
|
||||||
// 1. Get the active cascade ID from SDK titles manager
|
// 1. Get the active cascade ID from extension state (step-probe polling)
|
||||||
const cascadeId = ctx.sdk?.titles?.getActiveCascadeId?.();
|
// 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) {
|
if (!cascadeId) {
|
||||||
ctx.logToFile('[STOP] No active cascade to cancel (getActiveCascadeId returned null)');
|
ctx.logToFile('[STOP] No active cascade — no session tracked yet');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -430,6 +430,7 @@ export async function activate(context: vscode.ExtensionContext) {
|
|||||||
bridgePath, projectName, sdk, ls: sdk?.ls, autoApproveEnabled, logToFile,
|
bridgePath, projectName, sdk, ls: sdk?.ls, autoApproveEnabled, logToFile,
|
||||||
onAutoApproveChanged: (enabled: boolean) => { autoApproveEnabled = enabled; },
|
onAutoApproveChanged: (enabled: boolean) => { autoApproveEnabled = enabled; },
|
||||||
recentDiscordSentTexts,
|
recentDiscordSentTexts,
|
||||||
|
getActiveSessionId: () => activeSessionId,
|
||||||
}, data);
|
}, data);
|
||||||
},
|
},
|
||||||
onInstanceUpdate: (count, instances) => {
|
onInstanceUpdate: (count, instances) => {
|
||||||
@@ -559,6 +560,7 @@ export async function activate(context: vscode.ExtensionContext) {
|
|||||||
bridgePath, projectName, sdk, ls: sdk?.ls, autoApproveEnabled, logToFile,
|
bridgePath, projectName, sdk, ls: sdk?.ls, autoApproveEnabled, logToFile,
|
||||||
onAutoApproveChanged: (enabled: boolean) => { autoApproveEnabled = enabled; },
|
onAutoApproveChanged: (enabled: boolean) => { autoApproveEnabled = enabled; },
|
||||||
recentDiscordSentTexts,
|
recentDiscordSentTexts,
|
||||||
|
getActiveSessionId: () => activeSessionId,
|
||||||
});
|
});
|
||||||
|
|
||||||
// Response watcher is now initialized by initStepProbe() above
|
// Response watcher is now initialized by initStepProbe() above
|
||||||
|
|||||||
Reference in New Issue
Block a user