From 80d9c05648e69296e91c645bac6b353f2194360a Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Mon, 20 Jul 2026 23:08:11 -0400 Subject: [PATCH] Show a Stopping state while indexing finishes its current batch A requested stop only takes effect between batches, so the Stop button looked unresponsive. Report the stop request in the status line and disable the button until the batch finishes. --- .../zotero/preferences/preferences_advanced.js | 11 +++++++++-- chrome/content/zotero/xpcom/embeddings.js | 2 ++ chrome/locale/en-US/zotero/preferences.ftl | 1 + 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/chrome/content/zotero/preferences/preferences_advanced.js b/chrome/content/zotero/preferences/preferences_advanced.js index c2ba90ce31..4459f7f119 100644 --- a/chrome/content/zotero/preferences/preferences_advanced.js +++ b/chrome/content/zotero/preferences/preferences_advanced.js @@ -109,6 +109,9 @@ Zotero_Preferences.Advanced = { if (status.error) { document.l10n.setAttributes(phaseLabel, 'preferences-advanced-semantic-search-error', { error: status.error }); } + else if (status.stopping) { + document.l10n.setAttributes(phaseLabel, 'preferences-advanced-semantic-search-stopping'); + } else if (status.phase === 'downloading') { document.l10n.setAttributes(phaseLabel, 'preferences-advanced-semantic-search-downloading'); } @@ -128,8 +131,12 @@ Zotero_Preferences.Advanced = { document.getElementById('semantic-search-resume').hidden = status.indexing || !(status.error || status.paused || hasRemaining); - // Offer to stop indexing while it's running - document.getElementById('semantic-search-stop').hidden = !status.indexing; + // Offer to stop indexing while it's running; a requested stop takes + // effect once the current batch finishes, so disable the button in + // the meantime + let stopButton = document.getElementById('semantic-search-stop'); + stopButton.hidden = !status.indexing; + stopButton.disabled = !!status.stopping; // Per-library "indexed / total" counts let grid = document.getElementById('semantic-search-libraries'); diff --git a/chrome/content/zotero/xpcom/embeddings.js b/chrome/content/zotero/xpcom/embeddings.js index 4cd7760300..0c92df706c 100644 --- a/chrome/content/zotero/xpcom/embeddings.js +++ b/chrome/content/zotero/xpcom/embeddings.js @@ -1250,6 +1250,8 @@ Zotero.Embeddings.Indexing = new function () { enabled: Zotero.Embeddings.isEnabled(), model: Zotero.Embeddings.getModelName(), indexing: _indexing, + // A stop has been requested but the current batch is still finishing + stopping: _indexing && _stopping, paused: this.isPaused(), phase: _phase, error: _lastError ? (_lastError.message || String(_lastError)) : null, diff --git a/chrome/locale/en-US/zotero/preferences.ftl b/chrome/locale/en-US/zotero/preferences.ftl index cd8b932ba6..531fd0b753 100644 --- a/chrome/locale/en-US/zotero/preferences.ftl +++ b/chrome/locale/en-US/zotero/preferences.ftl @@ -102,6 +102,7 @@ preferences-advanced-semantic-search-multilingual = .label = Multilingual preferences-advanced-semantic-search-downloading = Downloading model… preferences-advanced-semantic-search-indexing = Indexing… +preferences-advanced-semantic-search-stopping = Stopping… preferences-advanced-semantic-search-idle = Up to date preferences-advanced-semantic-search-paused = Indexing paused preferences-advanced-semantic-search-error = Indexing stopped: { $error }