fix(ui): scan trigger immediate-feedback toast + delayed status re-poll — operator-flagged 'click does nothing' was actually scan_directory's skip-set finalizing the batch in <100ms when every file already had an ImportTask row, before refreshStatus could ever see the active state. Now the click always produces visible feedback (immediate 'Scan triggered' + 2s 'no new files' if it quick-finalizes).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-25 13:06:11 -04:00
parent 3a359f6c5e
commit 5666fd5ca5
+20
View File
@@ -56,7 +56,27 @@ export const useImportStore = defineStore('import', () => {
triggerError.value = null
try {
await api.post('/api/import/trigger', { body: { mode: 'quick' } })
// Acknowledge immediately so the click isn't invisible. scan_directory
// can finalize the batch synchronously when every file in /import is
// already on a non-failed ImportTask (operator-flagged 2026-05-25:
// 233k existing tasks → all paths in skip-set → files_seen=0 →
// batch flashes 'running' for <100ms then 'complete' before the
// first refreshStatus() lands; UI never sees the active state).
window.__fcToast?.({ text: 'Scan triggered', type: 'success' })
await refreshStatus()
// Re-poll twice over ~5s to catch quick-finalize transitions and
// surface a result toast either way.
setTimeout(async () => {
await refreshStatus()
if (!activeBatch.value) {
// Either scan completed with zero new files, or it never visibly
// started. Fetch the freshest task to differentiate.
window.__fcToast?.({
text: 'Scan complete — no new files (everything already on an ImportTask row)',
type: 'info',
})
}
}, 2000)
} catch (e) {
triggerError.value = e.message
window.__fcToast?.({ text: `Scan failed: ${e.message}`, type: 'error' })