The rail keeps scan, Model Doctor and Current node (ui_rail_tools.js, which replaces ui_toolbox.js). The tools the toolbox held now sit where their things are: - Workflow share codes (AMB0/AMB1 import / export): the Workflows page's top bar, in place of the disabled "import" button. - Prompt Studio and Prompt Notes: the Material Library's top bar. - Model Sources: the end of the type chips on Models (library) and "where to download" in Model Doctor (the open workflow). Removed with it: the toolbox popover, its tool catalog and custom-item hook (no plugin used it), the generic tool dispatch (Home opens the doctor directly), the tour step, its styles and the toolbox and old "planned tools" strings. The scan button's tooltip no longer says "wizard". Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
45 lines
2.1 KiB
JavaScript
45 lines
2.1 KiB
JavaScript
/**
|
|
* Follows scans started anywhere (the scan page, a single model, another tab): shows their
|
|
* progress and result, turns the rail's scan button into a spinner, and reloads the models when done.
|
|
*/
|
|
|
|
import { translate as t } from './locales.js';
|
|
import { updateScanProgress, failScanProgress } from './scan_progress.js';
|
|
import { fetchLastScan, setScanButtonState, showScanResult } from './scan_runner.js';
|
|
|
|
const POLL_MS = 3000;
|
|
|
|
/** Starts polling; returns `isScanning()` for the rail's scan button. */
|
|
export function watchScans(owner) {
|
|
let scanning = false;
|
|
setInterval(async () => {
|
|
try {
|
|
let active = null;
|
|
if (owner.currentType) {
|
|
const params = new URLSearchParams({ type: owner.currentType, path_idx: owner.currentPathIdx || 0, subfolder: owner.currentSubfolder || '/' });
|
|
const local = await (await fetch(`/anomalous/scan_status?${params}`)).json();
|
|
if (local.scanning) active = local;
|
|
else if (local.interrupted) failScanProgress(t('scanProgressInterrupted'));
|
|
}
|
|
const global = await (await fetch('/anomalous/global_scan_status')).json();
|
|
if (global.scanning) active = global;
|
|
else if (global.interrupted) failScanProgress(t('scanProgressInterrupted'));
|
|
|
|
if (active) updateScanProgress(active);
|
|
const button = document.getElementById('anomalous-scan-btn');
|
|
if (active && !scanning) {
|
|
scanning = true;
|
|
if (button) setScanButtonState(button, true);
|
|
} else if (!active && scanning) {
|
|
scanning = false;
|
|
if (button) setScanButtonState(button, false);
|
|
showScanResult(owner, await fetchLastScan());
|
|
owner.loadModels();
|
|
owner.onScanFinished?.();
|
|
if (window.anomalous_reload_hashes) await window.anomalous_reload_hashes();
|
|
}
|
|
} catch (_) { /* the server may be restarting; the next poll tries again */ }
|
|
}, POLL_MS);
|
|
return () => scanning;
|
|
}
|