Skip to content

Re-syncing Zotero without re-selecting a collection silently erases the saved collection association #20

Description

@inactinique

Summary

Re-syncing a Zotero bibliography without re-selecting a collection silently erases the collection association saved by a previous sync — no warning, no confirmation, just a quiet overwrite.

Found while auditing the ClioDeck wiki against the actual code (1.5-Zotero-Integration-Guide.md).

Current behavior (verified against code)

  • ZoteroImport.tsx:33 — the collection selector's state is const [selectedCollection, setSelectedCollection] = useState<string>(''). It resets to empty every time the sync dialog/component remounts (e.g., closing and reopening the sync panel).
  • ZoteroImport.tsx:226-231 — after every successful sync, the component writes:
    await window.electron.project.setBibliographySource({
      projectPath: projectJsonPath,
      type: 'zotero',
      filePath: bibFileName,
      zoteroCollection: selectedCollection || undefined,
    });
  • This is a full-object overwrite, not a merge, on the main-process side (project-manager.ts's setBibliographySource handler replaces project.bibliographySource wholesale).

Combine the two: sync once with a collection selected → zoteroCollection is saved. Close and reopen the sync dialog, sync again without re-picking a collection → selectedCollection is back to '', so zoteroCollection: undefined is written, silently overwriting the previously saved value.

Why this matters

Anything that reads bibliographySource.zoteroCollection (e.g., to remember which collection a project is scoped to) will lose that information after an innocuous, ordinary re-sync — the user did nothing wrong and gets no indication anything changed.

Suggested fix

Either:

  1. Persist the last-selected collection across dialog remounts (e.g., initialize selectedCollection from the project's existing bibliographySource.zoteroCollection when the dialog opens), or
  2. Merge rather than overwrite bibliographySource on save, only touching fields the user actually changed.

Option 1 is likely more correct — it also fixes the confusing UX of the selector silently forgetting your prior choice.

Evidence trail

  • src/renderer/src/components/Bibliography/ZoteroImport.tsx:33 — state reset on every mount.
  • src/renderer/src/components/Bibliography/ZoteroImport.tsx:226-231 — the overwrite-on-sync call.
  • Wiki page corrected in the same pass: 1.5-Zotero-Integration-Guide.md.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions