From 3e2f7fb33c1a725f480996b44a9404ee123ee271 Mon Sep 17 00:00:00 2001 From: Bogdan Abaev Date: Mon, 14 Sep 2026 16:09:56 -0700 Subject: [PATCH] minor cleanup of prefs UI - hide the diagnostics by default - do not show the chunks count next to progress bars to avoid confusion - shorten labels to be more concise --- .../preferences/embeddingsEndpoint.xhtml | 179 +++++++++--------- .../preferences/preferences_advanced.js | 29 ++- .../preferences/preferences_advanced.xhtml | 72 +++---- chrome/content/zotero/xpcom/embeddings.js | 3 +- chrome/locale/en-US/zotero/preferences.ftl | 12 +- scss/preferences/_advanced.scss | 108 +++++++---- test/tests/embeddingsTest.js | 9 + 7 files changed, 237 insertions(+), 175 deletions(-) diff --git a/chrome/content/zotero/preferences/embeddingsEndpoint.xhtml b/chrome/content/zotero/preferences/embeddingsEndpoint.xhtml index 012a322794..cbb7de95eb 100644 --- a/chrome/content/zotero/preferences/embeddingsEndpoint.xhtml +++ b/chrome/content/zotero/preferences/embeddingsEndpoint.xhtml @@ -33,7 +33,7 @@ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:html="http://www.w3.org/1999/xhtml" data-l10n-id="preferences-advanced-semantic-search-endpoint-dialog" - onload="Zotero_EmbeddingsEndpointDialog.init()"> + onload="init()"> diff --git a/chrome/content/zotero/preferences/preferences_advanced.js b/chrome/content/zotero/preferences/preferences_advanced.js index 2e0f74b54e..5cbd885a42 100644 --- a/chrome/content/zotero/preferences/preferences_advanced.js +++ b/chrome/content/zotero/preferences/preferences_advanced.js @@ -113,6 +113,15 @@ Zotero_Preferences.Advanced = { document.getElementById('semantic-search-endpoint-configure').addEventListener('command', () => { this.openSemanticSearchEndpointDialog(); }); + + let diagnostics = document.getElementById('semantic-search-diagnostics'); + let toggle = document.getElementById('semantic-search-diagnostics-toggle'); + toggle.addEventListener('command', () => { + diagnostics.hidden = !diagnostics.hidden; + document.l10n.setAttributes(toggle, diagnostics.hidden + ? 'preferences-advanced-semantic-search-diagnostics-show' + : 'preferences-advanced-semantic-search-diagnostics-hide'); + }); // The endpoint's stored verdict is read lazily; have it in memory // before the status line first renders Zotero.Embeddings.Endpoint.load().then(() => { @@ -166,12 +175,11 @@ Zotero_Preferences.Advanced = { statusBox.hidden = !status.enabled; // Fulltext indexing only means something with a model selected document.getElementById('semantic-search-index-fulltext').disabled = !status.enabled; + this.updateSemanticSearchEndpointUI(status.endpoint, status.enabled); if (!status.enabled) { return; } - this.updateSemanticSearchEndpointUI(status.endpoint); - // Phase / status message let phaseLabel = document.getElementById('semantic-search-phase'); let hasRemaining = status.items.done < status.items.total @@ -242,15 +250,16 @@ Zotero_Preferences.Advanced = { document.getElementById('semantic-search-attachments-row').hidden = !Zotero.Prefs.get('embeddings.indexFulltext'); this._updateSemanticSearchBar('attachments', status.chunks); - this._updateSemanticSearchDiagnostics(status.diagnostics, status.eta); + this._updateSemanticSearchDiagnostics(status); }, // Whether the active model can be served at all, and how the configured // server stands (see Zotero.Embeddings.Endpoint.getStatus()) - updateSemanticSearchEndpointUI: function (endpoint) { + updateSemanticSearchEndpointUI: function (endpoint, enabled) { let row = document.getElementById('semantic-search-endpoint-row'); - row.hidden = !Zotero.Embeddings.Endpoint.isSupported(); + // Nothing can be said about serving without a model + row.hidden = !enabled || !Zotero.Embeddings.Endpoint.isSupported(); if (row.hidden) { return; } @@ -281,7 +290,7 @@ Zotero_Preferences.Advanced = { // Key/value rows of pipeline diagnostics for developers, so the labels // are plain English rather than localized - _updateSemanticSearchDiagnostics: function (diagnostics, eta) { + _updateSemanticSearchDiagnostics: function ({ items, chunks: indexed, diagnostics, eta }) { let n = (value, digits = 0) => (value ?? 0).toLocaleString(undefined, { maximumFractionDigits: digits, minimumFractionDigits: digits }); @@ -301,6 +310,8 @@ Zotero_Preferences.Advanced = { let rows = []; let { window, run, engine, processes, slice, chunks } = diagnostics; + rows.push(['Items indexed', `${n(items.done)} / ${n(items.total)}`]); + rows.push(['Attachment chunks indexed', `${n(indexed.done)} / ${n(indexed.total)}`]); rows.push(['ETA', eta === null ? '—' : duration(eta)]); rows.push(['Throughput (2 min)', window ? speed(window) : '—']); rows.push(['Inference speed (run)', run ? speed(run) : '—']); @@ -341,8 +352,8 @@ Zotero_Preferences.Advanced = { }, - // Fill one progress row with done out of total. The percentage is - // rounded down, so it reads 100% only when everything is done. + // Fill one progress bar. The percentage is rounded down, so it reads + // 100% only when everything is done. _updateSemanticSearchBar: function (name, { done, total }) { let bar = document.getElementById(`semantic-search-${name}-progress`); bar.max = Math.max(total, 1); @@ -350,7 +361,7 @@ Zotero_Preferences.Advanced = { document.l10n.setAttributes( document.getElementById(`semantic-search-${name}-value`), 'preferences-advanced-semantic-search-progress-value', - { done, total, percent: total ? Math.floor(done / total * 100) : 0 } + { percent: total ? Math.floor(done / total * 100) : 0 } ); }, diff --git a/chrome/content/zotero/preferences/preferences_advanced.xhtml b/chrome/content/zotero/preferences/preferences_advanced.xhtml index d76a66a8be..8984bb303a 100644 --- a/chrome/content/zotero/preferences/preferences_advanced.xhtml +++ b/chrome/content/zotero/preferences/preferences_advanced.xhtml @@ -309,37 +309,27 @@ - - - - - - + + + +