Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
# Changelog

## 0.15.1

The desktop app opens in a few seconds instead of twenty or more, the Mac window's buttons no longer sit on the FormCite name, arXiv lookups work again, Preferences looks and works like the other Form apps, and the agent dock has its button at the top left.

### Fixed
- **The desktop app took 20 to 30 seconds to open.** The window waited for a signal from the page that it had drawn, and the page never sent it, so every launch sat out a 20 second fallback after the engine was already up. The page sends it again, and the window opens once it has drawn and the splash has had its 2.6 seconds. The engine itself starts in under a second.
- **On a Mac the red, yellow and green window buttons covered "FormCite"** at the top left, in every view including Preferences. The top left now leaves room for them from the first frame (beside the brand when the menus are in the menu bar, before the menus when they are in the window), and gives the room back in full screen, where the buttons are hidden.
- **arXiv lookups failed** with "arxiv answered with status ..." in Recent calls. arXiv's search API is under heavy load and refuses some callers outright. FormCite now asks arXiv's OAI-PMH service for the same record when the search API refuses or does not answer. It is listed as its own service, arxiv-oai, with its own switch; switching arXiv off still keeps arXiv off.
- **Recent calls cut the answer short.** The status or error now reads in full, and hovering a row shows the whole call.
- **Pasting an arXiv id** in any common form now works and says what it found: `arXiv:2402.06196`, `arxiv:2402.06196v2`, `2402.06196`, `https://arxiv.org/abs/2402.06196`, `https://arxiv.org/pdf/2402.06196v1` and old ids such as `hep-th/9901001`, as well as `doi:` and doi.org links, ISBNs with hyphens and `PMID: 123`. Press Enter to add it. Home and the Add dialog now say you can paste one.

### Improved
- **Preferences in the Form apps' form:** the sections stand in their own rail to the left of a Preferences card, and the card shows only the section you pick. Every setting is where it was.
- **An Agents button at the top left** opens and closes the agent dock and stays lit while it is open, as in the other Form apps. Preferences, Agents keeps the switch to show the dock.

### Under the hood
- Checked for this version, on Linux x64, on 1 December 2026 (EST): the window's type check and production build; the engine from source and frozen as onefile and onedir (each answered in under a second, three runs each); arXiv lookups of 2402.06196, hep-th/9901001 and 0704.0001v2 against the live services; identifier detection for every form above; and the built window in headless Chrome at four times slower CPU with a stand-in for the Mac desktop shell: the reveal signal sent once, the room for the window buttons on the first frame, the Agents button following the dock, and no layout shift switching Preferences sections. Not run: a build or launch on macOS or Windows, so the opening time and the window buttons were not seen on a real Mac.

## 0.15.0

FormCite now builds into a desktop app for macOS, Windows and Linux, and the window gains a menu bar, a Home screen, Preferences in sections, a right-click menu on items, an agent dock, and three demo libraries with templates to start from.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</p>

<p align="center">
<img alt="version 0.15.0" src="https://img.shields.io/badge/version-0.15.0-eef0f4?style=flat-square">
<img alt="version 0.15.1" src="https://img.shields.io/badge/version-0.15.1-eef0f4?style=flat-square">
<img alt="TypeScript" src="https://img.shields.io/badge/TypeScript-Vite-3178c6?style=flat-square&logo=typescript&logoColor=white">
<img alt="Python 3.12 or later" src="https://img.shields.io/badge/Python-FastAPI-3776ab?style=flat-square&logo=python&logoColor=white">
<img alt="macOS, Windows, Linux" src="https://img.shields.io/badge/macOS%20%C2%B7%20Windows%20%C2%B7%20Linux-desktop-2f7bf5?style=flat-square">
Expand Down
14 changes: 13 additions & 1 deletion backend/HASHOUT_LOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Living log of all comment content, explainers, rationale, TODOs, & removed (hashed-out) code for this side of the repo. Source files stay comment-free per dev-rules `sub-skills/hashout-log/SUB-SKILL.md`; everything they would have said lives here, indexed. This file is also the compressed contextual map of this side: read it first, then edit code surgically.

Current build version: v0.15.0
Current build version: v0.15.1
Last updated: 2026-11-27 (US Eastern) · the lean rows route for the window's list and opening an attachment

---
Expand Down Expand Up @@ -1732,3 +1732,15 @@ New in v0.15.0 (2026-12-01 EST, agent `cite-home`). No engine feature was added.
Templates: 40 independent styles from citation-style-language/styles `master` at 38e17c7 (2026-12-01), unmodified (CC BY-SA 3.0, `templates/CREDITS.md`), and FormCite's own `formcite-plain-author-date.csl`, copied from `app/style/regression/custom/`. 41 candidates were fetched, and `bibtex.csl` was dropped because it writes BibTeX rather than a citation style. Ten starters: thesis, grant, course, systematic-review, journal-article, book-project, lab-group, conference-talk, teaching-portfolio and policy-brief. `templates/index.json` lists all 51.

Checked: each demo copied into a fresh data folder, registered with `library new` and listed with the CLI (260, 215 and 240 items). In the built window under 4x CPU throttling, switching to each in Preferences showed its item count, its own collections and tags in Items. Every style rendered the 20 regression references (bibliography complete, citations non-empty) through `render_with_style` and formatted three demo items through `./formcite cli format --style-file` (41 of 41). Every starter opened with its collection and tag counts as listed in its about.json. The style engine came from the 0.14.0 abi3 wheel C1 built (`formcite_style`, Hayagriva 0.10.1).

## app/lookup/arxiv.py, app/lookup/arxiv_oai.py · arXiv lookups fall back to arXiv's OAI-PMH service {#app-arxiv-oai}

New in v0.15.1 (2026-12-01, EST). The owner's Recent calls showed every arXiv call failing with "arxiv answered with status ..." for `export.arxiv.org/api/query?id_list=2402.06196&max_results=1`. The request itself is right: https, `id_list`, the documented query API, FormCite's descriptive User-Agent, redirects followed only to https hosts FormCite declares. Tested from this machine on 2026-12-01: `https://export.arxiv.org/api/query?...` answered 403 Forbidden (Fastly, HTML body) to every variation tried: FormCite's User-Agent with and without a mailto, a browser User-Agent, curl's default, Python-urllib, HTTP/1.1, no gzip, `Accept: application/atom+xml`. `http://` answers 301 to the same https address, and `https://arxiv.org/api/query` 302s to the http export address, so neither is a way round. The rest of arXiv answered 200 from the same address (`arxiv.org/abs/2402.06196`, `export.arxiv.org/`, `oaipmh.arxiv.org/oai`), so it is the query API that refuses, not the network. arXiv's API group (May 2026) says the query API is under very high load, rate limits are being held where they are, 429 blocks expire on their own, and a replacement platform with keys is planned. So any one address may get 403, 429 or 503 there for a while, which is what the owner saw.

`fetch` still asks the query API first (it carries affiliations and the first-version date). When that call ends in a `NetworkError` (any non-404 status, a timeout, an unreachable host), it asks arXiv's OAI-PMH service for the same record: `GetRecord`, `identifier=oai:arXiv.org:<id without version>`, `metadataPrefix=arXiv`. That is a second registered service, `arxiv-oai` on `oaipmh.arxiv.org`, so it has its own switch, its own 3 s pace and its own rows in Recent calls. A `NetworkOff` from `arxiv` (the service switched off) does not fall back: turning arXiv off keeps arXiv off. If the OAI service is switched off the first error stands; if it also fails, both messages are given. `arxiv_oai.parse` reads the OAI answer with the same guards as the Atom parser (2 MB, no DOCTYPE or entities), maps `idDoesNotExist` to not found, checks that the record's id matches the one asked for, and fills the same entry shape `arxiv_map.to_csl` already takes: title, abstract, authors as forenames plus keyname, categories (first is taken as primary), journal-ref, comments, doi. OAI's `created` can be a later version's date (2402.06196 says 2025-03-23 for a February 2024 paper), so the issued date is `created` only when it falls in the year and month the identifier carries, and otherwise the first of that month. Checked live: 2402.06196, hep-th/9901001 and 0704.0001v2 all came back with title, authors, date and categories through the OAI service after the query API's 403, and Recent calls listed the 403 and the 200.

Before, quoted from `fetch`: `answer = parse(net.fetch_text(SERVICE, QUERY_URL, params={"id_list": identifier, "max_results": "1"}))`, `errors = [e for e in answer["entries"] if e["error"]]`, `if errors:`, `message = errors[0]["summary"] or "no message"`, `raise Invalid(f"arXiv refused the identifier {identifier}: {message}.")`, `record = normalize(to_csl(_pick(answer["entries"], identifier), identifier))`; and `SERVICES = (SERVICE,)`.

## app/lookup/guess.py · old-style arXiv ids and a kind word followed by a space {#app-guess-forms}

New in v0.15.1 (2026-12-01, EST). Checked every form the owner listed against `guess`: `arXiv:2402.06196`, `arxiv:2402.06196v2`, `2402.06196`, `https://arxiv.org/abs/2402.06196`, `https://arxiv.org/pdf/2402.06196v1` (and `.pdf`), `doi:10.x/...`, `https://doi.org/10.x/...`, hyphenated ISBNs and `PMID: 123` were already detected. Two were not: a bare old-style id (`hep-th/9901001` answered "cannot tell what kind of identifier") and a kind word followed by a space instead of a colon (`arXiv 2402.06196`, `DOI 10.1038/...`). `guess` now also tries `ARXIV_OLD` (the pattern `_clean` already used) after the URL and new-style checks, and `PREFIX` takes a space as well as `:` or `=` after the kind word. `ISBN-13: ...` still goes through `ISBN_SHAPE`, since `PREFIX` needs the bare word. Before: `PREFIX = re.compile(r"^\s*(doi|arxiv|isbn|pmid|pubmed)\s*[=:]\s*(.+?)\s*$", re.IGNORECASE)` and `if ARXIV_URL.match(raw) or ARXIV_NEW.match(raw):`.
2 changes: 1 addition & 1 deletion backend/app/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.15.0"
__version__ = "0.15.1"
37 changes: 33 additions & 4 deletions backend/app/lookup/arxiv.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,19 @@
from app.record.normalize import normalize, validate
from app.store.errors import Invalid, NotFound

from . import arxiv_oai
from .arxiv_atom import parse
from .arxiv_id import base, clean
from .arxiv_map import to_csl

KIND = "arxiv"
SERVICE = "arxiv"
SERVICES = (SERVICE,)
OAI_SERVICE = "arxiv-oai"
SERVICES = (SERVICE, OAI_SERVICE)
HOST = "export.arxiv.org"
OAI_HOST = "oaipmh.arxiv.org"
QUERY_URL = f"https://{HOST}/api/query"
OAI_URL = f"https://{OAI_HOST}/oai"
INTERVAL_SECONDS = 3.0

net.register(
Expand All @@ -20,6 +24,13 @@
"https://info.arxiv.org/help/api/user-manual.html",
interval=INTERVAL_SECONDS,
)
net.register(
OAI_SERVICE,
OAI_HOST,
"Look up the same preprint record from arXiv's OAI-PMH service when arXiv's search API refuses or is busy.",
"https://info.arxiv.org/help/oa/index.html",
interval=INTERVAL_SECONDS,
)

__all__ = ["KIND", "SERVICES", "clean", "fetch"]

Expand All @@ -32,13 +43,31 @@ def _pick(entries: list[dict], identifier: str) -> dict:
raise NotFound(f"arXiv has no article with the identifier {identifier}.")


def fetch(value: str) -> dict:
identifier = clean(value)
def _from_oai(identifier: str, first: Exception) -> dict:
try:
text = net.fetch_text(OAI_SERVICE, OAI_URL, params={"verb": "GetRecord", "identifier": f"oai:arXiv.org:{base(identifier)}", "metadataPrefix": "arXiv"})
except net.NetworkOff:
raise first from None
except net.NetworkError as exc:
raise net.NetworkError(f"{first} The OAI service did not answer either: {exc}") from None
return arxiv_oai.parse(text, identifier)


def _from_api(identifier: str) -> dict:
answer = parse(net.fetch_text(SERVICE, QUERY_URL, params={"id_list": identifier, "max_results": "1"}))
errors = [e for e in answer["entries"] if e["error"]]
if errors:
message = errors[0]["summary"] or "no message"
raise Invalid(f"arXiv refused the identifier {identifier}: {message}.")
record = normalize(to_csl(_pick(answer["entries"], identifier), identifier))
return _pick(answer["entries"], identifier)


def fetch(value: str) -> dict:
identifier = clean(value)
try:
entry = _from_api(identifier)
except net.NetworkError as exc:
entry = _from_oai(identifier, exc)
record = normalize(to_csl(entry, identifier))
validate(record)
return record
85 changes: 85 additions & 0 deletions backend/app/lookup/arxiv_oai.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
import re
import xml.etree.ElementTree as ET

from app.store.errors import Invalid, NotFound

from .arxiv_id import base

OAI = "{http://www.openarchives.org/OAI/2.0/}"
META = "{http://arxiv.org/OAI/arXiv/}"
MAX_BYTES = 2_000_000
FORBIDDEN = re.compile(r"<!(?:DOCTYPE|ENTITY)", re.IGNORECASE)
NEW_ID = re.compile(r"^(\d{2})(\d{2})\.")
OLD_ID = re.compile(r"^[a-z.-]+/(\d{2})(\d{2})", re.IGNORECASE)


def _fold(text: str | None) -> str:
return re.sub(r"\s+", " ", text or "").strip()


def _root(xml_text: str) -> ET.Element:
if len(xml_text.encode("utf-8", errors="replace")) > MAX_BYTES:
raise Invalid("arXiv's OAI service answered with more than 2 MB, which is far more than one record; FormCite did not read it.")
if FORBIDDEN.search(xml_text):
raise Invalid("arXiv's OAI answer declared a document type or entities, which FormCite does not read.")
try:
return ET.fromstring(xml_text, parser=ET.XMLParser())
except ET.ParseError as exc:
raise Invalid(f"arXiv's OAI answer was not XML FormCite could read: {exc}.") from None


def _month_of(identifier: str) -> tuple[int, int] | None:
found = NEW_ID.match(identifier) or OLD_ID.match(identifier)
if not found:
return None
yy, mm = int(found.group(1)), int(found.group(2))
return (1900 + yy if yy >= 91 else 2000 + yy), mm


def _published(created: str, identifier: str) -> str:
month = _month_of(identifier)
stamp = re.match(r"^(\d{4})-(\d{2})-\d{2}", created or "")
if stamp and (month is None or (int(stamp.group(1)), int(stamp.group(2))) == month):
return stamp.group(0)
if month is None:
return ""
return f"{month[0]:04d}-{month[1]:02d}-01"


def _name(author: ET.Element) -> str:
parts = [_fold(author.findtext(f"{META}{tag}")) for tag in ("forenames", "keyname")]
return " ".join(p for p in parts if p)


def parse(xml_text: str, identifier: str) -> dict:
root = _root(xml_text)
if root.tag != f"{OAI}OAI-PMH":
raise Invalid("arXiv's OAI answer was not an OAI-PMH document.")
error = root.find(f"{OAI}error")
if error is not None:
if error.get("code") == "idDoesNotExist":
raise NotFound(f"arXiv has no article with the identifier {identifier}.")
raise Invalid(f"arXiv's OAI service refused the identifier {identifier}: {_fold(error.text) or error.get('code', 'no message')}.")
node = root.find(f"{OAI}GetRecord/{OAI}record/{OAI}metadata/{META}arXiv")
if node is None:
raise NotFound(f"arXiv has no article with the identifier {identifier}.")
found = _fold(node.findtext(f"{META}id"))
if base(found) != base(identifier):
raise NotFound(f"arXiv has no article with the identifier {identifier}.")
categories = _fold(node.findtext(f"{META}categories")).split()
return {
"id": found,
"arxiv_id": found,
"error": False,
"title": _fold(node.findtext(f"{META}title")),
"summary": _fold(node.findtext(f"{META}abstract")),
"authors": [{"name": _name(a), "affiliations": []} for a in node.findall(f"{META}authors/{META}author") if _name(a)],
"published": _published(_fold(node.findtext(f"{META}created")), found),
"updated": _fold(node.findtext(f"{META}updated")),
"primary_category": categories[0] if categories else "",
"categories": categories,
"journal_ref": _fold(node.findtext(f"{META}journal-ref")),
"comment": _fold(node.findtext(f"{META}comments")),
"doi": _fold(node.findtext(f"{META}doi")),
"links": [],
}
4 changes: 2 additions & 2 deletions backend/app/lookup/guess.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from app.store.errors import Invalid

PREFIX = re.compile(r"^\s*(doi|arxiv|isbn|pmid|pubmed)\s*[=:]\s*(.+?)\s*$", re.IGNORECASE)
PREFIX = re.compile(r"^\s*(doi|arxiv|isbn|pmid|pubmed)(?:\s*[=:]\s*|\s+)(.+?)\s*$", re.IGNORECASE)
DOI_URL = re.compile(r"^(?:https?://)?(?:dx\.)?doi\.org/(.+)$", re.IGNORECASE)
DOI = re.compile(r"^10\.\d{4,9}/\S+$")
ARXIV_URL = re.compile(r"^(?:https?://)?(?:www\.|export\.)?arxiv\.org/(?:abs|pdf)/(.+?)(?:\.pdf)?/?$", re.IGNORECASE)
Expand Down Expand Up @@ -67,7 +67,7 @@ def guess(text: str) -> tuple[str, str]:
return "pubmed", _clean("pubmed", pmid.group(1))
if DOI_URL.match(raw) or raw.startswith("10."):
return "doi", _clean("doi", raw)
if ARXIV_URL.match(raw) or ARXIV_NEW.match(raw):
if ARXIV_URL.match(raw) or ARXIV_NEW.match(raw) or ARXIV_OLD.match(raw):
return "arxiv", _clean("arxiv", raw)
if PUBMED_URL.match(raw):
return "pubmed", _clean("pubmed", raw)
Expand Down
Loading
Loading