diff --git a/scene_search/web/index.html b/scene_search/web/index.html
index 5459c1d..dc0d65f 100644
--- a/scene_search/web/index.html
+++ b/scene_search/web/index.html
@@ -101,6 +101,7 @@
+
@@ -121,6 +122,7 @@
const $ = id => document.getElementById(id);
let statusTimer = null;
let captionTimer = null;
+ let captionLastStatus = null;
let thumbnailUrls = [];
$('apiKey').value = localStorage.getItem('sceneSearchApiKey') || '';
@@ -255,6 +257,7 @@
}
function renderCaptionStatus(s) {
+ captionLastStatus = s;
const percent = Number(s.percent || (s.stage === 'complete' ? 100 : 0));
$('captionProgress').value = percent;
$('captionText').textContent = percent.toFixed(1).replace('.0','') + '%';
@@ -262,8 +265,20 @@
if (s.running) {
$('captionNow').disabled = true;
+ $('captionPause').disabled = s.stage === 'syncing' || s.stage === 'sync';
+ $('captionPause').textContent = s.paused
+ ? 'Resume'
+ : (s.pause_requested ? 'Cancel pause' : 'Pause');
$('captionStatus').className = 'status';
- if (s.stage === 'routing') {
+ if (s.paused) {
+ $('captionStatus').textContent = 'Captioning paused';
+ $('captionDetail').textContent =
+ (s.title ? s.title + (s.timestamp_ms != null ? ' at ' + formatTs(s.timestamp_ms) : '') : '') +
+ (s.frames_completed != null ? ' ยท ' + s.frames_completed + '/' + (s.frames_total || 0) + ' frames saved' : '');
+ } else if (s.pause_requested) {
+ $('captionStatus').textContent = 'Pause requested; finishing the current frame';
+ $('captionDetail').textContent = s.title || '';
+ } else if (s.stage === 'routing') {
$('captionStatus').textContent = 'Routing frames to caption models';
$('captionDetail').textContent = (s.frames_selected || s.frames_total || 0) + ' frames selected';
} else if (s.stage === 'syncing' || s.stage === 'sync') {
@@ -281,11 +296,15 @@
}
} else if (s.stage === 'failed') {
$('captionNow').disabled = false;
+ $('captionPause').disabled = true;
+ $('captionPause').textContent = 'Pause';
$('captionStatus').className = 'status error';
$('captionStatus').textContent = 'Failed: ' + (s.error || 'unknown error');
$('captionDetail').textContent = '';
} else if (s.stage === 'complete') {
$('captionNow').disabled = false;
+ $('captionPause').disabled = true;
+ $('captionPause').textContent = 'Pause';
$('captionStatus').className = 'status ok';
$('captionStatus').textContent =
'Complete: ' + (s.frames_completed || 0) + ' saved, ' + (s.failed || 0) + ' failed';
@@ -293,6 +312,8 @@
(s.retained || 0) + ' existing captions retained';
} else {
$('captionNow').disabled = false;
+ $('captionPause').disabled = true;
+ $('captionPause').textContent = 'Pause';
$('captionStatus').className = 'status muted';
$('captionStatus').textContent = 'Idle';
$('captionDetail').textContent = '';
@@ -338,6 +359,20 @@
}
}
+ async function toggleCaptionPause() {
+ if (!captionLastStatus || !captionLastStatus.running) return;
+ const resume = captionLastStatus.paused || captionLastStatus.pause_requested;
+ try {
+ const s = await api(resume ? '/api/caption/resume' : '/api/caption/pause', {
+ method:'POST'
+ });
+ renderCaptionStatus(s);
+ } 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);
@@ -400,6 +435,7 @@
$('selectAll').onclick = () => document.querySelectorAll('.libraryCheck').forEach(x => x.checked = true);
$('indexNow').onclick = startIndex;
$('captionNow').onclick = startCaption;
+ $('captionPause').onclick = toggleCaptionPause;
$('searchButton').onclick = search;
$('searchQuery').addEventListener('keydown', e => { if (e.key === 'Enter') search(); });