feat: auto_resolved sync + expired card update + DOM step_index
This commit is contained in:
@@ -477,6 +477,7 @@ function startObserverHttpBridge(): Promise<number> {
|
||||
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();
|
||||
@@ -1572,14 +1573,19 @@ function setupMonitor() {
|
||||
try {
|
||||
const pendingFiles = fs.readdirSync(path.join(bridgePath, 'pending'))
|
||||
.filter((f: string) => 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)`);
|
||||
}
|
||||
}
|
||||
} catch (e: any) { logToFile(`[AUTO-RESOLVE] error: ${e.message}`); }
|
||||
|
||||
Reference in New Issue
Block a user