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.
This commit is contained in:
Dan Stillman 2026-07-20 23:08:11 -04:00
parent 5d639d2242
commit 80d9c05648
3 changed files with 12 additions and 2 deletions

View file

@ -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');

View file

@ -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,

View file

@ -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 }