Skip to content

~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.

feat(zotero): add inline collection picker (#5254)

March-770b0d0eeabdc7
diff --git a/changelog.d/5254.feature.md b/changelog.d/5254.feature.md
new file mode 100644
index 0000000000..3cc3aa437d
--- /dev/null
+++ b/changelog.d/5254.feature.md
@@ -0,0 +1 @@
+Add an inline, name-based Zotero collection picker with an explicit entire-library option.
diff --git a/src/local_deep_research/web/templates/pages/zotero.html b/src/local_deep_research/web/templates/pages/zotero.html
index 8a89f8a6e7..a6f8bd6174 100644
--- a/src/local_deep_research/web/templates/pages/zotero.html
+++ b/src/local_deep_research/web/templates/pages/zotero.html
@@ -45,6 +45,20 @@
.ldr-zotero-check { display: flex; align-items: center; gap: 9px; font-size: .9rem; cursor: pointer; }
.ldr-zotero-check input { width: 16px; height: 16px; flex: 0 0 auto; }
.ldr-zotero-row { display: grid; grid-template-columns: 170px 1fr; gap: 12px; }
+.ldr-zotero-collection-picker {
+ display: grid; gap: 8px; margin: 8px 0;
+ padding: 10px; border: 1px solid var(--border-color); border-radius: 6px;
+}
+.ldr-zotero-collection-picker[hidden] { display: none; }
+.ldr-zotero-collection-options { display: grid; gap: 8px; }
+.ldr-zotero-collection-option {
+ display: flex; align-items: flex-start; gap: 9px; font-size: .9rem;
+}
+.ldr-zotero-collection-option input { width: 16px; height: 16px; margin-top: 2px; flex: 0 0 auto; }
+.ldr-zotero-collection-key {
+ color: var(--text-secondary, #999); font-family: monospace; font-size: .78rem;
+}
+.ldr-zotero-collection-fallback { margin-top: 10px; }
table.ldr-zotero-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
table.ldr-zotero-table th, table.ldr-zotero-table td {
@@ -153,8 +167,17 @@ table.ldr-zotero-table th, table.ldr-zotero-table td {
</div>
<div class="ldr-zotero-field">
<label for="zt-collections">Collections</label>
- <input type="text" id="zt-collections" class="ldr-zotero-input" placeholder="Collection keys, comma-separated (blank = entire library)">
- <div class="ldr-zotero-hint">Use “List collections” below to add keys. Remember to Save — Sync uses the saved value.</div>
+ <div class="ldr-zotero-collection-fallback">
+ <div id="zotero-collection-picker" class="ldr-zotero-collection-picker" hidden>
+ <label class="ldr-zotero-collection-option">
+ <input type="checkbox" id="zt-entire-library">
+ <span>Entire library</span>
+ </label>
+ <div id="zotero-collection-options" class="ldr-zotero-collection-options"></div>
+ </div>
+ <input type="text" id="zt-collections" class="ldr-zotero-input" placeholder="Collection keys, comma-separated (blank = entire library)">
+ <div class="ldr-zotero-hint">Advanced fallback: enter collection keys manually when the collection list cannot be loaded.</div>
+ </div>
</div>
<div class="ldr-zotero-field">
<label for="zt-tags">Only import items tagged (optional)</label>
@@ -193,15 +216,6 @@ table.ldr-zotero-table th, table.ldr-zotero-table td {
</table>
</div>
- <div class="ldr-zotero-card ldr-zotero-collections" id="zotero-collections-card" style="display:none;">
- <h2>Zotero collections</h2>
- <p class="ldr-zotero-empty">Click a key to add it to the Collections field above.</p>
- <table class="ldr-zotero-table">
- <thead><tr><th>Name</th><th>Key</th></tr></thead>
- <tbody id="zotero-collections-body"></tbody>
- </table>
- </div>
-
<div class="ldr-zotero-card">
<h2>Sync status
<button type="button" id="zotero-refresh" class="ldr-zotero-linkbtn" title="Refresh sync status"><i class="fas fa-rotate-right"></i> Refresh</button>
@@ -279,12 +293,37 @@ table.ldr-zotero-table th, table.ldr-zotero-table td {
});
}
+ function collectionKeysFromField() {
+ return $('zt-collections').value
+ .split(',')
+ .map((key) => key.trim())
+ .filter(Boolean);
+ }
+
+ function syncCollectionPickerFromField() {
+ const selected = new Set(collectionKeysFromField());
+ $('zt-entire-library').checked = selected.size === 0;
+ document.querySelectorAll('.ldr-zotero-collection-choice').forEach((input) => {
+ input.checked = selected.has(input.dataset.key);
+ });
+ }
+
+ function saveCollectionChoices() {
+ const keys = Array.from(
+ document.querySelectorAll('.ldr-zotero-collection-choice:checked')
+ ).map((input) => input.dataset.key);
+ $('zt-collections').value = keys.join(', ');
+ $('zt-entire-library').checked = keys.length === 0;
+ autosave();
+ }
+
function fillForm(c) {
$('zt-enabled').checked = !!c.enabled;
$('zt-local').checked = !!c.use_local_api;
$('zt-library-type').value = c.library_type || 'user';
$('zt-library-id').value = c.library_id || '';
$('zt-collections').value = (c.collection_keys || []).join(', ');
+ syncCollectionPickerFromField();
$('zt-api-key').value = ''; // write-only: never populate the secret
$('zt-api-key').placeholder = c.has_api_key
? '•••••••• saved — leave blank to keep' : 'Zotero API key';
@@ -413,10 +452,25 @@ table.ldr-zotero-table th, table.ldr-zotero-table td {
// Every field saves on change; Enter in a text field saves too.
['zt-enabled', 'zt-local', 'zt-library-type', 'zt-library-id', 'zt-api-key',
- 'zt-collections', 'zt-without-pdf', 'zt-annotations', 'zt-tags',
+ 'zt-without-pdf', 'zt-annotations', 'zt-tags',
'zt-pdf-storage', 'zt-auto-sync', 'zt-interval'].forEach((id) => {
$(id).addEventListener('change', () => { autosave(); });
});
+ $('zt-collections').addEventListener('change', () => {
+ syncCollectionPickerFromField();
+ autosave();
+ });
+ $('zt-entire-library').addEventListener('change', () => {
+ if ($('zt-entire-library').checked) {
+ document.querySelectorAll('.ldr-zotero-collection-choice').forEach((input) => {
+ input.checked = false;
+ });
+ $('zt-collections').value = '';
+ autosave();
+ } else {
+ syncCollectionPickerFromField();
+ }
+ });
$('zotero-config-form').addEventListener('submit', (e) => { e.preventDefault(); autosave(); });
// ---- Sync status ----------------------------------------------------
@@ -497,8 +551,8 @@ table.ldr-zotero-table th, table.ldr-zotero-table td {
async function loadCollectionsList(interactive) {
// interactive=true: user clicked the button (messages + scroll).
- // interactive=false: silent auto-load — populate the card if there
- // is anything to show, never nag on failure.
+ // interactive=false: silent auto-load — populate the inline picker
+ // without nagging on failure.
const listBtn = $('zotero-list');
if (interactive) { listBtn.disabled = true; setSaveMsg('Loading collections…'); }
try {
@@ -508,24 +562,25 @@ table.ldr-zotero-table th, table.ldr-zotero-table td {
return;
}
const items = r.collections || [];
- const body = $('zotero-collections-body');
- body.innerHTML = items.map(c =>
- `<tr><td>${esc(c.name) || '(untitled)'}</td><td><button type="button" class="ldr-zotero-keybtn" title="Add to Collections" data-key="${esc(c.key)}">${esc(c.key)}</button></td></tr>`
- ).join('') || '<tr><td colspan="2" class="ldr-zotero-empty">No collections found.</td></tr>';
- const card = $('zotero-collections-card');
- if (interactive || items.length) card.style.display = '';
- if (interactive) card.scrollIntoView({ behavior: 'smooth', block: 'nearest' });
- body.querySelectorAll('.ldr-zotero-keybtn').forEach(btn => {
- btn.addEventListener('click', () => {
- // Add the clicked key to the Collections field (dedup).
- const field = $('zt-collections');
- const keys = field.value.split(',').map(k => k.trim()).filter(Boolean);
- if (!keys.includes(btn.dataset.key)) keys.push(btn.dataset.key);
- field.value = keys.join(', ');
- $('zt-advanced').open = true; // the field lives in Advanced
- autosave();
- });
+ const options = $('zotero-collection-options');
+ options.innerHTML = items.map((c) => `
+ <label class="ldr-zotero-collection-option">
+ <input type="checkbox" class="ldr-zotero-collection-choice" data-key="${esc(c.key)}">
+ <span>
+ ${esc(c.name) || '(untitled)'}
+ <span class="ldr-zotero-collection-key">${esc(c.key)}</span>
+ </span>
+ </label>
+ `).join('') || '<div class="ldr-zotero-empty">No collections found.</div>';
+ $('zotero-collection-picker').hidden = false;
+ syncCollectionPickerFromField();
+ options.querySelectorAll('.ldr-zotero-collection-choice').forEach((input) => {
+ input.addEventListener('change', saveCollectionChoices);
});
+ if (interactive) {
+ $('zt-advanced').open = true;
+ $('zotero-collection-picker').scrollIntoView({ behavior: 'smooth', block: 'nearest' });
+ }
if (interactive) setSaveMsg(`Found ${items.length} collections.`, true);
} catch (e) {
if (interactive) setSaveMsg('Failed to list collections.', false);
diff --git a/tests/ui_tests/test_zotero_integration_ci.js b/tests/ui_tests/test_zotero_integration_ci.js
index 4bebada449..c278e0a7a0 100644
--- a/tests/ui_tests/test_zotero_integration_ci.js
+++ b/tests/ui_tests/test_zotero_integration_ci.js
@@ -87,7 +87,8 @@ const ZoteroPageTests = {
const result = await page.evaluate(() => {
const ids = ['zt-enabled', 'zt-local', 'zt-library-type', 'zt-library-id', 'zt-api-key',
- 'zt-collections', 'zt-without-pdf', 'zt-annotations', 'zt-tags', 'zt-pdf-storage',
+ 'zt-collections', 'zt-entire-library', 'zotero-collection-picker',
+ 'zotero-collection-options', 'zt-without-pdf', 'zt-annotations', 'zt-tags', 'zt-pdf-storage',
'zt-auto-sync', 'zt-interval'];
const missing = ids.filter((id) => !document.getElementById(id));
return {
@@ -172,7 +173,7 @@ const ZoteroPageTests = {
return !!el && (el.getAttribute('aria-live') === 'polite' || el.getAttribute('role') === 'status');
};
const controls = ['zt-enabled', 'zt-local', 'zt-library-type', 'zt-library-id', 'zt-api-key',
- 'zt-collections', 'zt-without-pdf', 'zt-annotations', 'zt-tags', 'zt-pdf-storage',
+ 'zt-collections', 'zt-entire-library', 'zt-without-pdf', 'zt-annotations', 'zt-tags', 'zt-pdf-storage',
'zt-auto-sync', 'zt-interval'];
return {
unnamed: controls.filter((id) => !hasName(id)),
@@ -189,7 +190,7 @@ const ZoteroPageTests = {
};
},
- async pickerCardsHiddenInitially(page, baseUrl) {
+ async collectionPickerIsInline(page, baseUrl) {
await navigateTo(page, zoteroUrl(baseUrl));
const result = await page.evaluate(() => {
@@ -197,20 +198,28 @@ const ZoteroPageTests = {
const el = document.getElementById(id);
return !el || getComputedStyle(el).display === 'none';
};
+ const picker = document.getElementById('zotero-collection-picker');
+ const field = document.getElementById('zt-collections');
return {
hasGroups: !!document.getElementById('zotero-groups-card'),
- hasCollections: !!document.getElementById('zotero-collections-card'),
+ hasPicker: !!picker,
+ hasEntireLibrary: !!document.getElementById('zt-entire-library'),
+ hasRawFallback: !!field,
+ pickerSharesField: !!picker && !!field && picker.parentElement === field.parentElement,
+ hasLegacyCard: !!document.getElementById('zotero-collections-card'),
groupsHidden: isHidden('zotero-groups-card'),
- collectionsHidden: isHidden('zotero-collections-card'),
+ pickerHidden: isHidden('zotero-collection-picker'),
};
});
- const passed = result.hasGroups && result.hasCollections && result.groupsHidden && result.collectionsHidden;
+ const passed = result.hasGroups && result.hasPicker && result.hasEntireLibrary
+ && result.hasRawFallback && result.pickerSharesField && !result.hasLegacyCard
+ && result.groupsHidden && result.pickerHidden;
return {
passed,
message: passed
- ? 'Groups + collections picker cards exist and are hidden until their buttons are clicked'
- : `Picker card visibility wrong (${JSON.stringify(result)})`,
+ ? 'Collection picker is inline with an Entire library choice and raw-key fallback'
+ : `Inline collection picker structure wrong (${JSON.stringify(result)})`,
};
},
@@ -523,7 +532,7 @@ async function main() {
await run('Page', 'API Key Field Write-Only', (p, u) => ZoteroPageTests.apiKeyFieldWriteOnly(p, u));
await run('Page', 'Interval Input Matches Backend Constraints', (p, u) => ZoteroPageTests.intervalInputMatchesBackendConstraints(p, u));
await run('Page', 'Form Accessibility (names + aria-live)', (p, u) => ZoteroPageTests.formAccessibility(p, u));
- await run('Page', 'Picker Cards Hidden Initially', (p, u) => ZoteroPageTests.pickerCardsHiddenInitially(p, u));
+ await run('Page', 'Collection Picker Is Inline', (p, u) => ZoteroPageTests.collectionPickerIsInline(p, u));
await run('Page', 'No Console Errors', (p, u) => ZoteroPageTests.noConsoleErrors(p, u));
log.section('Zotero APIs');