feat: auto_resolved sync + expired card update + DOM step_index

This commit is contained in:
2026-03-10 13:52:27 +09:00
parent 93439d2f1c
commit 048ffd90a3
4 changed files with 49 additions and 7 deletions

View File

@@ -498,6 +498,7 @@ function startObserverHttpBridge() {
project_name: projectName,
auto_detected: true,
source: 'dom_observer',
step_index: lastPendingStepIndex >= 0 ? lastPendingStepIndex : undefined,
};
// File permission: inject multi-choice buttons
const cmdLower = (data.command || '').toLowerCase();
@@ -1589,14 +1590,20 @@ function setupMonitor() {
try {
const pendingFiles = fs.readdirSync(path.join(bridgePath, 'pending'))
.filter((f) => f.endsWith('.json'));
const nowMs = Date.now();
for (const pf of pendingFiles) {
const pfPath = path.join(bridgePath, 'pending', pf);
const pd = JSON.parse(fs.readFileSync(pfPath, 'utf-8'));
if (pd.status === 'pending' && pd.step_index === lastPendingStepIndex) {
if (pd.status !== 'pending')
continue;
// Match by step_index OR by recency (< 60s, any source)
const ageMs = nowMs - (pd.timestamp * 1000);
const isMatch = pd.step_index === lastPendingStepIndex
|| (ageMs < 60_000 && ageMs >= 0);
if (isMatch) {
pd.status = 'auto_resolved';
fs.writeFileSync(pfPath, JSON.stringify(pd, null, 2), 'utf-8');
logToFile(`[AUTO-RESOLVE] step=${lastPendingStepIndex} progressed → marked ${pf}`);
break;
logToFile(`[AUTO-RESOLVE] step=${lastPendingStepIndex} progressed → marked ${pf} (age=${Math.round(ageMs / 1000)}s)`);
}
}
}