fix(ext): !stop getActiveSessionId stale primitive — use step-probe getter #task-410

This commit is contained in:
Variet Worker
2026-03-18 08:34:58 +09:00
parent 07bbb626a6
commit ab0c116c9e
3 changed files with 79 additions and 67 deletions

View File

@@ -2,7 +2,7 @@
"name": "gravity-bridge",
"displayName": "Gravity Bridge",
"description": "Antigravity ↔ Discord 브리지 연동 확장",
"version": "0.4.5",
"version": "0.4.6",
"publisher": "variet",
"engines": {
"vscode": "^1.100.0"

View File

@@ -16,7 +16,7 @@ import * as path from 'path';
import * as os from 'os';
import * as cp from 'child_process';
import { WSBridgeClient, WSResponseData, WSCommandData } from './ws-client';
import { initStepProbe, BridgeContext, writePendingApproval, tryApprovalStrategies, writeRegistration, getApprovalContext, resetPendingState, handleDiffReviewResponse } from './step-probe';
import { initStepProbe, BridgeContext, writePendingApproval, tryApprovalStrategies, writeRegistration, getApprovalContext, resetPendingState, handleDiffReviewResponse, getActiveSessionId as getStepProbeSessionId } from './step-probe';
import { startHttpBridge, getDeterministicPort, HttpBridgeContext } from './http-bridge';
import { setupApprovalObserver } from './html-patcher';
import { watchCommandsDir, handleWSCommand, disposeCommandsWatcher, CommandHandlerContext } from './command-handler';
@@ -430,7 +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,
getActiveSessionId: () => getStepProbeSessionId(),
}, data);
},
onInstanceUpdate: (count, instances) => {
@@ -560,7 +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,
getActiveSessionId: () => getStepProbeSessionId(),
});
// Response watcher is now initialized by initStepProbe() above

View File

@@ -52,6 +52,18 @@ export function getApprovalContext(): { sessionId: string; stepIndex: number } {
};
}
/**
* Get the active session ID tracked by step-probe polling.
* Used by command-handler (via extension.ts) for !stop → CancelCascadeInvocation.
*
* CRITICAL: extension.ts must use this getter instead of its own module-level
* `activeSessionId` variable, which is a stale primitive copy that never updates
* when step-probe discovers new sessions.
*/
export function getActiveSessionId(): string {
return ctx?.activeSessionId || '';
}
/**
* Reset pending state after successful approval.
* Called after WS response triggers approval in extension.ts.