Autogenerate citation key from author/year (#35577)

* Autogenerate citation key from author/year

* Fix abort handling and error fallback in citation key suggestions

* Apply suggestions from code review

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* Always fall back to a generated key on suggestion failure

* Make citation-key suggestion location-aware (project vs library), fix validation timing and duplicate-key edge cases, and consolidate the resolution logic

* Update citation key helper/error copy and hide the autogenerate hint while its error is showing

* Refactor comments: significantly shorten and remove unnecessary

* Fix error logic: if empty show error on save. If invalid entry, show onBlur

* Error refactoring

GitOrigin-RevId: 0cd919c9224731f1d5694204e8cdb03288ade04b
This commit is contained in:
Tom Wells
2026-09-17 11:34:40 +00:00
committed by Copybot
co-authored by Copilot Autofix powered by AI
parent 4d1e9677e1
commit c88544c290
3 changed files with 30 additions and 0 deletions
@@ -295,6 +295,7 @@
"choose_which_experiments": "",
"choose_word_document": "",
"citation": "",
"citation_key_autogenerate_helper": "",
"citation_key_helper": "",
"cite_a_reference_from_your_reference_manager_to_automatically_add_it_to_your_bib_file": "",
"cite_directly_or_import_references": "",
+1
View File
@@ -382,6 +382,7 @@
"choose_word_document": "Choose Word document",
"choose_your_plan": "Choose your plan",
"citation": "Citation",
"citation_key_autogenerate_helper": "Auto-generated from the author and year, if left blank",
"citation_key_helper": "Unique key for citations, no spaces or special characters",
"cite_a_reference_from_your_reference_manager_to_automatically_add_it_to_your_bib_file": "Cite a reference from your reference manager to automatically add it to your .bib file.",
"cite_directly_or_import_references": "Cite directly or import references",
@@ -0,0 +1,28 @@
import Helpers from './lib/helpers.mjs'
const tags = ['saas', 'auxiliary']
// Backs an exact/prefix-range lookup on the raw citation key, used to suggest
// a unique citation key when auto-generating one from author/year.
const newIndexes = [
{
key: { userId: 1, key: 1 },
name: 'userId_1_key_1',
},
]
const migrate = async client => {
const { db } = client
await Helpers.addIndexesToCollection(db.libraryReferences, newIndexes)
}
const rollback = async client => {
const { db } = client
await Helpers.dropIndexesFromCollection(db.libraryReferences, newIndexes)
}
export default {
tags,
migrate,
rollback,
}