fix(observer): v9 - stop treating Running N commands as approval button, add DOM-climbing context extraction

This commit is contained in:
Variet Worker
2026-04-13 19:37:18 +09:00
parent 2a1ebf1020
commit a8d875167d
6 changed files with 119 additions and 18 deletions

View File

@@ -267,14 +267,16 @@ function _handlePending(req: any, res: any, ctx: HttpBridgeContext) {
return;
}
// "Run" button → step_probe handles these with full command detail
// Only let through if session is stalled AND step_probe hasn't created a pending yet
// Only filter when step_probe IS actively tracking a session
if (/^(?:Always\s*)?Run\b/i.test(cmd)) {
if (!ctx.sessionStalled || ctx.lastPendingStepIndex >= 0) {
ctx.logToFile(`[HTTP] filtered "Run" — ${!ctx.sessionStalled ? 'not stalled' : 'step_probe pending exists'}`);
if (ctx.activeSessionId && (!ctx.sessionStalled || ctx.lastPendingStepIndex >= 0)) {
ctx.logToFile(`[HTTP] filtered "Run" — ${!ctx.sessionStalled ? 'not stalled' : 'step_probe pending exists'} (session=${ctx.activeSessionId.substring(0, 8)})`);
res.writeHead(200, { 'Content-Type': 'application/json' });
res.end(JSON.stringify({ ok: false, filtered: true }));
return;
}
// v9: When step_probe has no active session, let DOM observer handle approval
ctx.logToFile(`[HTTP] allowing "Run" — step_probe has no active session`);
}
const rid = data.request_id || Date.now().toString();