diff --git a/scene_search/web/index.html b/scene_search/web/index.html index b9a330c..020d2f8 100644 --- a/scene_search/web/index.html +++ b/scene_search/web/index.html @@ -17,6 +17,7 @@ input[type=text],input[type=password] { width:100%; padding:11px 12px; border-radius:9px; border:1px solid #3a414d; background:#101318; color:#fff; } button { padding:10px 14px; border:0; border-radius:9px; cursor:pointer; background:#3b82f6; color:white; font-weight:650; } button.secondary { background:#303642; } + button.danger { background:#7f1d1d; } button:disabled { opacity:.5; cursor:not-allowed; } .row { display:flex; gap:10px; align-items:center; flex-wrap:wrap; } .between { justify-content:space-between; } @@ -111,6 +112,7 @@
+
@@ -362,13 +364,20 @@ if (s.running) { const syncing = s.stage === 'syncing' || s.stage === 'sync'; - $('captionNow').disabled = syncing; + const stopping = !!s.stop_requested; + $('captionNow').disabled = syncing || stopping; $('captionNow').textContent = syncing ? 'Finishing...' - : ((s.paused || s.pause_requested) ? 'Resume' : 'Pause'); + : (stopping + ? 'Stopping...' + : ((s.paused || s.pause_requested) ? 'Resume' : 'Pause')); + $('captionStop').disabled = syncing || stopping; $('forceCaption').disabled = true; $('captionStatus').className = 'status'; - if (s.paused) { + if (stopping) { + $('captionStatus').textContent = 'Stop requested; finishing the current frame'; + $('captionDetail').textContent = s.title || ''; + } else if (s.paused) { $('captionStatus').textContent = 'Captioning paused'; $('captionDetail').textContent = (s.title ? s.title + (s.timestamp_ms != null ? ' at ' + formatTs(s.timestamp_ms) : '') : '') + @@ -395,6 +404,7 @@ } else if (s.stage === 'failed') { $('captionNow').disabled = false; $('captionNow').textContent = 'Start / resume captioning'; + $('captionStop').disabled = true; $('forceCaption').disabled = false; $('captionStatus').className = 'status error'; $('captionStatus').textContent = 'Failed: ' + (s.error || 'unknown error'); @@ -402,15 +412,26 @@ } else if (s.stage === 'complete') { $('captionNow').disabled = false; $('captionNow').textContent = 'Start / resume captioning'; + $('captionStop').disabled = true; $('forceCaption').disabled = false; $('captionStatus').className = 'status ok'; $('captionStatus').textContent = 'Complete: ' + (s.frames_completed || 0) + ' saved, ' + (s.failed || 0) + ' failed'; $('captionDetail').textContent = (s.retained || 0) + ' existing captions retained'; + } else if (s.stage === 'stopped') { + $('captionNow').disabled = false; + $('captionNow').textContent = 'Start / resume captioning'; + $('captionStop').disabled = true; + $('forceCaption').disabled = false; + $('captionStatus').className = 'status muted'; + $('captionStatus').textContent = 'Stopped'; + $('captionDetail').textContent = + (s.frames_completed || 0) + ' captions saved. Start / resume continues the remaining frames.'; } else { $('captionNow').disabled = false; $('captionNow').textContent = 'Start / resume captioning'; + $('captionStop').disabled = true; $('forceCaption').disabled = false; $('captionStatus').className = 'status muted'; $('captionStatus').textContent = 'Idle'; @@ -479,6 +500,20 @@ } } + async function stopCaption() { + if (!captionLastStatus || !captionLastStatus.running) return; + if (captionLastStatus.stage === 'syncing' || captionLastStatus.stage === 'sync') return; + + try { + const s = await api('/api/caption/stop', {method:'POST'}); + renderCaptionStatus(s); + lastCaptionRunning = !!s.running; + } catch (e) { + $('captionStatus').className = 'status error'; + $('captionStatus').textContent = e.message; + } + } + function formatTs(ms) { const seconds = Math.floor((ms || 0) / 1000); const h = Math.floor(seconds / 3600); @@ -542,6 +577,7 @@ $('applyLibraries').onclick = applyLibrarySelection; $('indexNow').onclick = startIndex; $('captionNow').onclick = captionAction; + $('captionStop').onclick = stopCaption; $('reportFailed').onclick = () => loadIndexReport('failed'); $('reportRemoved').onclick = () => loadIndexReport('removed'); $('reportIndexed').onclick = () => loadIndexReport('indexed');