The folder automation re-admitted a file every minute when the user had removed its jobs while a hoster was still missing, because nothing recorded the removal. Removing automatic jobs (selected, all, per hoster or through MCP) now stores the file path and identity in automation-dismissals.json. The automation skips such files until the file changes or the user adds it manually again. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
13178512bf
commit
f64fe23019
8 files changed
+176
-11
No files matched your search
@@ -211,6 +211,56 @@
|
||||
});
|
||||
}
|
||||
|
||||
function normalizeAutomationDismissal(value) {
|
||||
const row = asObject(value);
|
||||
const path = String(row.path || '').trim();
|
||||
const fileIdentity = typeof row.fileIdentity === 'string' ? row.fileIdentity.trim() : '';
|
||||
const dismissedAt = Number(row.dismissedAt);
|
||||
if (!path || !fileIdentity) return null;
|
||||
return { path, fileIdentity, dismissedAt: Number.isFinite(dismissedAt) && dismissedAt >= 0 ? Math.trunc(dismissedAt) : 0 };
|
||||
}
|
||||
|
||||
function mergeAutomationDismissals(existing, incoming, maxEntries = 5000) {
|
||||
const merged = new Map();
|
||||
for (const source of [asArray(existing), asArray(incoming)]) {
|
||||
for (const value of source) {
|
||||
const row = normalizeAutomationDismissal(value);
|
||||
if (!row) continue;
|
||||
const key = normalizePath(row.path);
|
||||
merged.delete(key);
|
||||
merged.set(key, row);
|
||||
}
|
||||
}
|
||||
const limit = Number.isFinite(Number(maxEntries)) ? Math.max(1, Math.floor(Number(maxEntries))) : 5000;
|
||||
const rows = [...merged.values()];
|
||||
return rows.slice(Math.max(0, rows.length - limit));
|
||||
}
|
||||
|
||||
function removeAutomationDismissals(existing, paths) {
|
||||
const removed = new Set(asArray(paths).map(normalizePath).filter(Boolean));
|
||||
return mergeAutomationDismissals(existing, []).filter(row => !removed.has(normalizePath(row.path)));
|
||||
}
|
||||
|
||||
function automationDismissalsForRemovedJobs(jobs, now = Date.now()) {
|
||||
return mergeAutomationDismissals([], asArray(jobs)
|
||||
.filter(job => job && job.automationAdmission === true && job.status !== 'done')
|
||||
.map(job => ({ path: job.file, fileIdentity: job.sourceFileIdentity, dismissedAt: now })));
|
||||
}
|
||||
|
||||
function classifyAutomationDismissals(input = {}) {
|
||||
const value = asObject(input);
|
||||
const rows = new Map(mergeAutomationDismissals(value.dismissals, []).map(row => [normalizePath(row.path), row]));
|
||||
const dismissedPaths = [];
|
||||
const stalePaths = [];
|
||||
for (const candidate of asArray(value.candidates)) {
|
||||
const row = rows.get(normalizePath(candidate?.path));
|
||||
if (!row || typeof candidate.fileIdentity !== 'string' || !candidate.fileIdentity) continue;
|
||||
if (candidate.fileIdentity === row.fileIdentity) dismissedPaths.push(candidate.path);
|
||||
else stalePaths.push(row.path);
|
||||
}
|
||||
return { dismissedPaths, stalePaths };
|
||||
}
|
||||
|
||||
function classifyAutomationCompletionLedger(input = {}) {
|
||||
const value = asObject(input);
|
||||
const rows = new Map();
|
||||
@@ -341,6 +391,11 @@
|
||||
createAutomationCompletionWriter,
|
||||
normalizeAutomationCompletion,
|
||||
mergeAutomationCompletions,
|
||||
removeAutomationCompletions
|
||||
removeAutomationCompletions,
|
||||
normalizeAutomationDismissal,
|
||||
mergeAutomationDismissals,
|
||||
removeAutomationDismissals,
|
||||
automationDismissalsForRemovedJobs,
|
||||
classifyAutomationDismissals
|
||||
};
|
||||
});
|
||||
Reference in new issue
Block a user