diff --git a/CHANGELOG.md b/CHANGELOG.md index f7fa897..f8a5715 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,41 @@ # Changelog +## 0.15.2 + +On a Mac the menus are in the menu bar only, the agent and Preferences buttons sit at the top right as in FormPortal, Preferences floats over the window as in FormVis, a row in Items opens its details again, and an arXiv paper comes with its PDF. + +### Fixed +- **Clicking an item showed "No item selected".** The list keeps spare row boxes for scrolling. A style rule kept them laid out although they were hidden, so on the first screen they lay on top of the real rows and took the click. Hidden rows now take no room and no clicks, and a click or the arrow keys select the item and show its details. +- **On a Mac the window showed a menu bar of its own under the window buttons, and the system menu bar was missing the Library menu.** The system menu bar is now the only one on a Mac. It is built from the same list as the window's bar: FormCite, File, Edit, View, Library, Window and Help. One item the system refuses no longer stops the whole menu being set. If the system menu cannot be built at all, FormCite no longer opens a bar in the window in its place, so 0.15.0's note that it would no longer holds; the keys keep working. View, Menus in Window still puts the bar in the window, from the next start. Windows and Linux keep the bar in the window. If you turned on Menus in Window in 0.15.0, turn it off in View to get the menu bar back. +- **A broken or cut-off answer from a lookup service** is now reported as a network error and listed in Recent calls, where it could stop the engine's answer with an internal error. + +### New +- **The paper itself.** Adding an arXiv paper also downloads its open-access PDF from arxiv.org and attaches it, when lookups are allowed and the arXiv service is on. The download is listed in Recent calls as arxiv-pdf, has its own switch in Preferences, Network, and stops at 100 MB or two minutes. If it fails, the item is still added. The details pane has **Open PDF**, which opens it in FormPDF when installed and otherwise in the system viewer, and **Open on arXiv**, which opens the paper's page in your browser. An arXiv item that has no PDF yet shows **Get PDF** in the same place. +- **The details pane is a compact inspector:** Info, Abstract, Tags, Files and Notes, one at a time, with their counts on the tabs. It fits at 1440 by 900 and at 1280 by 800 without scrolling. +- **Agent and Preferences buttons at the top right,** beside Add, with FormPortal's icons, size and spacing. The agent button opens and closes the agent dock and stays lit while it is open. The sidebar head holds only the app icon, name and version. +- **Preferences floats over the window,** as in FormVis: a dimmed window, the section rail at the dialog's left with a line drawn from the chosen section to the dialog, one section at a time, Esc or a click outside to close. It shows and hides at once, with no fade, as in the other Form apps. The gear, the sidebar's Preferences item, Cmd+, (Ctrl+, elsewhere) and the app menu all open it. Every setting is where it was. +- **Empty states with their main actions** in the details pane, an empty list, Duplicates, Trash and Needs a title, so no main area is an empty rectangle. + +### Improved +- The list's columns follow its width, so titles have more room on smaller windows. +- **The sidebar no longer scrolls as one long column:** the views stay in place, and Collections and Tags each fold (remembered) and scroll within their own share, with tags shown as chips. +- On a Mac the top-left inset also drops in a window that opens in full screen. + +### Known issues +- The open-access PDF attachment through Crossref, for papers known only by a DOI, is not in this release: Crossref points at publishers' own hosts, which FormCite does not call. arXiv papers, including DOIs of the form 10.48550/arXiv.*, get their PDF. +- Not yet seen on a real Mac: the system menu bar, the window buttons and full screen were checked in a stand-in of the Mac shell. + +### Under the hood +- `net.fetch_to_file` streams a download to disk with a content type, size, host and time limit. Redirects for the PDF may reach only arxiv.org, and Recent calls lists the last hop. Gzip answers are inflated with a cap. New routes: `GET /api/library/items/{id}/fulltext`, `POST /api/library/items/{id}/fulltext/pdf` and `POST /api/library/items/{id}/open-arxiv`. +- Checked for this version, on Linux x64, on 1 December 2026 (EST): + - the window's type check and production build; + - the backend compile and the style regression set, 12 of 12; + - live arXiv adds with the PDF attached, Get PDF, the switches, and a concurrent Get PDF giving one download; + - fault probes for size, type, gzip, slow and cut-off answers; + - the built window in headless Chrome at four times slower CPU with a stand-in for the Mac desktop shell: the menus, the top bar, Preferences, the details pane and the empty states at 1440 by 900 and 1280 by 800, with no layout shift; + - the Linux desktop shell built and run under a virtual display, where Tauri accepted the full FormCite menu list when the Mac menu path was forced on. + Not run: a build or launch on macOS or Windows. + ## 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. diff --git a/README.md b/README.md index 3cffa14..5fb3036 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@

- version 0.15.1 + version 0.15.2 TypeScript Python 3.12 or later macOS, Windows, Linux diff --git a/backend/HASHOUT_LOG.md b/backend/HASHOUT_LOG.md index 513de27..e3df1ee 100644 --- a/backend/HASHOUT_LOG.md +++ b/backend/HASHOUT_LOG.md @@ -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.1 +Current build version: v0.15.2 Last updated: 2026-11-27 (US Eastern) · the lean rows route for the window's list and opening an attachment --- @@ -1744,3 +1744,42 @@ Before, quoted from `fetch`: `answer = parse(net.fetch_text(SERVICE, QUERY_URL, ## 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):`. + +## app/services/fulltext.py, app/net/fetch.py, app/lookup/arxiv.py, app/services/lookup.py, app/routers/library.py · the paper itself, attached {#app-fulltext-pdf} + +New in v0.15.2 (2026-12-01, EST). The owner added arXiv 2402.06196 and had no way to read the paper. Adding an arXiv item now also attaches its open-access PDF from `https://arxiv.org/pdf/`. It is fetched through `net` like every other call, so it needs lookups allowed and the `arxiv` service on (`net.check(arxiv.SERVICE)`), and it is its own registered service, `arxiv-pdf` on `arxiv.org`, with its own switch, 3 s pace and a row in Recent calls. `fetch.py` gains `fetch_bytes(service, url, limit=...)`; `_read`, `_once`, `_call` and `_request` take a `limit` (default the old 5 MB) and `_read` now refuses early on a `Content-Length` over it. The PDF limit is 100 MB, the same as `routers/upload.py` `MAX_BYTES` for a dropped PDF. The body must start with `%PDF-`. It is written to a temporary file and stored with `library.attachment_add(..., "copy", "arXiv-.pdf")`, the existing content-addressed store, and the temporary file is removed. An item that already has a PDF attachment is left as it is. + +`lookup.add` calls `fulltext.try_fetch_pdf` after the item's transaction and session are closed (the library session lock is not re-entrant), only for `source.kind == "arxiv"`, and returns its result as `pdf`: `{"attached": true, "attachment": ...}` or `{"attached": false, "error": "..."}`. A failure never undoes the add. New routes: `GET /api/library/items/{id}/fulltext` (`arxiv_id`, `arxiv_url`, `pdf_attachment_id`, `can_fetch_pdf`) and `POST /api/library/items/{id}/fulltext/pdf` (the window key guard covers the POST). The arXiv id comes from the record's `number` (`arXiv:...`), an arxiv.org abs or pdf URL, or a `10.48550/arXiv.*` DOI, read with `arxiv_id.clean`. + +Not done: an open-access PDF from Crossref for other DOIs. Crossref's `link` entries point at publisher hosts (for example `dx.plos.org` with `intended-application: similarity-checking` for 10.1371/journal.pone.0000308), and FormCite only calls hosts a registered service declares, so following them would mean declaring arbitrary publisher hosts; that is not simple, so it was left out. Checked live: adding 2402.06196 attached `arXiv-2402.06196.pdf` (4,882,035 bytes) in about 1 s, Recent calls listed `arxiv-pdf arxiv.org /pdf/2402.06196 200`; with `arxiv-pdf` switched off, adding hep-th/9901001 still added the item and returned the switch-off message as `pdf.error`, and `fulltext/pdf` attached it once switched back on. + +`services/opener.py` `open_arxiv(item_id)` and `routers/window.py` `POST /api/library/items/{id}/open-arxiv` (behind `window_only`, like opening an attachment): the URL is only ever `https://arxiv.org/abs/` built from the item's own arXiv id through `fulltext.links`, never a URL from the request, and it is opened with `open` on macOS, `xdg-open` on Linux and `os.startfile` on Windows. + +### The engine-tests review of the PDF fetch, and what changed (v0.15.2, 2026-12-01, EST) +The engine-tests role found seven faults in 2700267 (E1 to E7 in `handoff/fc152-requests.md`). All seven are fixed: +- **E1, two attachments from a double click.** `fetch_pdf` now runs under a per-item `threading.Lock` (`_item_lock`) and checks for a PDF again inside the lock. Two threads at once gave one download and `already: [False, True]`. +- **E2, a redirect to any declared host.** `_next_url` takes `hosts`, and `fetch_to_file` passes `PDF_HOSTS` (`arxiv.org`, `export.arxiv.org`), so the PDF call can never land on Crossref, PubMed and the like. +- **E3, Recent calls named only the first URL.** `_call` collects every hop in `hops`, and `_request` records the last one. +- **E4, no content-type check.** The streaming reader requires `Content-Type: application/pdf` before reading a byte, then `%PDF-` on the file. +- **E5, gzip inflated in full before the cap.** `_read` inflates through `zlib.decompressobj(...).decompress(body, limit + 1)` and refuses on an unconsumed tail. The streaming path asks for `Accept-Encoding: identity` and refuses any other encoding. +- **E6, the whole PDF in memory.** `net.fetch_to_file` streams 1 MiB chunks into the `mkstemp` file, counts the bytes against the 100 MB cap, and `fulltext` checks the magic on the file before `attachment_add`. +- **E7, no overall time limit.** The urllib timeout is now 30 s per read, and the chunk loop also stops at a 120 s total. + +`fetch_bytes` is gone. `_once` and `_call` now take a `read` callable instead of `limit`. The text and JSON paths use `_read` as before. + +Checked: 2402.06196 attached through the stream (Recent calls `arxiv-pdf /pdf/2402.06196 200`), nature12373 added through the JSON path, and no `formcite-pdf-*` file was left. + +**E7, re-check.** The engine-tests re-check found the deadline still checked only once per full MiB: `HTTPResponse.read(n)` waits for all n bytes, up to 30 s on each socket read. A server sending 1 byte every 0.5 s held a 3 s deadline for 12 s. The chunk loop now calls `response.read1(CHUNK)`, which returns after one socket read, so the deadline is checked each time data arrives (3.0 s in the same test). Before: `chunk = response.read(CHUNK)`. + +**E10.** `read1` returns `b""` when a length-delimited body ends early, so a cut-off PDF passed. The loop now raises "the download stopped early, after N of M bytes" when a declared `Content-Length` was not reached. + +**E11.** `http.client.HTTPException`, for example `IncompleteRead` from a broken chunked body, escaped `_once`. That meant a 500, no Recent calls row, and an Add that answered 500 after committing its item. `_once` now turns it into a `NetworkError`, for the text and JSON lookups as well. + +**E9 (cosmetic) is left as it is:** `get_content_type()` reports `text/plain` for an answer with no type, so it is refused with that wording. + +**E8, not in 0.15.2:** Crossref open-access PDFs. + +Before, quoted: +- `body = gzip.decompress(body)`; +- `body = net.fetch_bytes(arxiv.PDF_SERVICE, f"{arxiv.PDF_URL}{identifier}", limit=MAX_BYTES, accept=PDF_MIME)`; +- `with os.fdopen(fd, "wb") as handle: handle.write(body)`. diff --git a/backend/app/__init__.py b/backend/app/__init__.py index 903e77c..c0d4999 100644 --- a/backend/app/__init__.py +++ b/backend/app/__init__.py @@ -1 +1 @@ -__version__ = "0.15.1" +__version__ = "0.15.2" diff --git a/backend/app/lookup/arxiv.py b/backend/app/lookup/arxiv.py index 1419cd8..eb7f605 100644 --- a/backend/app/lookup/arxiv.py +++ b/backend/app/lookup/arxiv.py @@ -10,11 +10,15 @@ KIND = "arxiv" SERVICE = "arxiv" OAI_SERVICE = "arxiv-oai" -SERVICES = (SERVICE, OAI_SERVICE) +PDF_SERVICE = "arxiv-pdf" +SERVICES = (SERVICE, OAI_SERVICE, PDF_SERVICE) HOST = "export.arxiv.org" OAI_HOST = "oaipmh.arxiv.org" +PDF_HOST = "arxiv.org" QUERY_URL = f"https://{HOST}/api/query" OAI_URL = f"https://{OAI_HOST}/oai" +PDF_URL = f"https://{PDF_HOST}/pdf/" +ABS_URL = f"https://{PDF_HOST}/abs/" INTERVAL_SECONDS = 3.0 net.register( @@ -31,6 +35,13 @@ "https://info.arxiv.org/help/oa/index.html", interval=INTERVAL_SECONDS, ) +net.register( + PDF_SERVICE, + PDF_HOST, + "Download a preprint's open-access PDF from arXiv to attach it to the item, only while the arxiv service is also on.", + "https://info.arxiv.org/help/bulk_data.html", + interval=INTERVAL_SECONDS, +) __all__ = ["KIND", "SERVICES", "clean", "fetch"] diff --git a/backend/app/net/__init__.py b/backend/app/net/__init__.py index b3ea429..6d41f77 100644 --- a/backend/app/net/__init__.py +++ b/backend/app/net/__init__.py @@ -1,6 +1,6 @@ from app.net.errors import NetworkError, NetworkOff, RemoteNotFound -from app.net.fetch import fetch_json, fetch_text +from app.net.fetch import fetch_json, fetch_text, fetch_to_file from app.net.services import register -from app.net.switches import contact +from app.net.switches import check, contact -__all__ = ["NetworkError", "NetworkOff", "RemoteNotFound", "contact", "fetch_json", "fetch_text", "register"] +__all__ = ["NetworkError", "NetworkOff", "RemoteNotFound", "check", "contact", "fetch_json", "fetch_text", "fetch_to_file", "register"] diff --git a/backend/app/net/fetch.py b/backend/app/net/fetch.py index e70019e..0b51e1a 100644 --- a/backend/app/net/fetch.py +++ b/backend/app/net/fetch.py @@ -1,11 +1,12 @@ -import gzip +import http.client import json import socket import time import urllib.error import urllib.parse import urllib.request -from typing import Any +import zlib +from typing import Any, Callable from app.core.config import APP_TITLE, VERSION from app.net import calllog, pace, services, switches @@ -14,6 +15,7 @@ USER_AGENT = f"{APP_TITLE}/{VERSION} (+https://github.com/nodemode-dev/formcite)" MAX_BYTES = 5 * 1024 * 1024 +CHUNK = 1024 * 1024 MAX_REDIRECTS = 3 REDIRECTS = (301, 302, 303, 307, 308) @@ -49,48 +51,97 @@ def _with_params(url: str, params: dict | None) -> str: return url + ("&" if "?" in url else "?") + query -def _read(response) -> bytes: - body = response.read(MAX_BYTES + 1) - if len(body) > MAX_BYTES: - raise NetworkError("the answer was larger than 5 MB, so FormCite stopped reading it") +def _read(response, limit: int = MAX_BYTES) -> bytes: + too_big = f"the answer was larger than {limit // (1024 * 1024)} MB, so FormCite stopped reading it" + declared = response.headers.get("Content-Length") or "" + if declared.isdigit() and int(declared) > limit: + raise NetworkError(too_big) + body = response.read(limit + 1) + if len(body) > limit: + raise NetworkError(too_big) if (response.headers.get("Content-Encoding") or "").lower() == "gzip": - body = gzip.decompress(body) - if len(body) > MAX_BYTES: - raise NetworkError("the answer was larger than 5 MB, so FormCite stopped reading it") + inflate = zlib.decompressobj(16 + zlib.MAX_WBITS) + try: + body = inflate.decompress(body, limit + 1) + except zlib.error as exc: + raise NetworkError(f"the answer was not gzip FormCite could read ({exc})") from None + if len(body) > limit or inflate.unconsumed_tail: + raise NetworkError(too_big) return body +def _stream_to(path: str, limit: int, want_type: str, deadline: float) -> Callable[[Any], int]: + def read(response) -> int: + too_big = f"the file was larger than {limit // (1024 * 1024)} MB, so FormCite stopped reading it" + got_type = (response.headers.get_content_type() or "").lower() + if want_type and got_type != want_type: + raise NetworkError(f"the answer was {got_type or 'of no stated type'}, not {want_type}") + if (response.headers.get("Content-Encoding") or "identity").lower() != "identity": + raise NetworkError("the answer came compressed although FormCite asked for it plain") + declared = response.headers.get("Content-Length") or "" + if declared.isdigit() and int(declared) > limit: + raise NetworkError(too_big) + total = 0 + with open(path, "wb") as handle: + while True: + if time.monotonic() > deadline: + raise NetworkError("the download did not finish in time, so FormCite stopped it") + chunk = response.read1(CHUNK) + if not chunk: + if declared.isdigit() and total != int(declared): + raise NetworkError(f"the download stopped early, after {total} of {declared} bytes") + return total + total += len(chunk) + if total > limit: + raise NetworkError(too_big) + handle.write(chunk) + + return read + + def _with_status(exc: Exception, status: int) -> Exception: exc.status = status return exc -def _request(service_name: str, url: str, params: dict | None, headers: dict | None, timeout: float, accept: str) -> tuple[bytes, str]: +def _request( + service_name: str, + url: str, + params: dict | None, + headers: dict | None, + timeout: float, + accept: str, + read: Callable[[Any], Any] | None = None, + hosts: tuple[str, ...] | None = None, +) -> tuple[Any, str]: service = services.get(service_name) url = _with_params(url, params) _check_url(service, url) switches.check(service.name) pace.wait_turn(service.name, service.interval) - sent = {"User-Agent": user_agent(), "Accept": accept, "Accept-Encoding": "gzip"} + sent = {"User-Agent": user_agent(), "Accept": accept, "Accept-Encoding": "gzip" if read is None else "identity"} sent.update(headers or {}) started = time.monotonic() status: int | None = None + hops: list[str] = [url] try: - body, charset, status = _call(service, url, sent, timeout) + body, charset, status = _call(service, url, sent, timeout, read or _read, hosts, hops) except (Invalid, NotFound) as exc: - calllog.record(service.name, url, status=status or getattr(exc, "status", None), error=str(exc), ms=(time.monotonic() - started) * 1000) + calllog.record(service.name, hops[-1], status=status or getattr(exc, "status", None), error=str(exc), ms=(time.monotonic() - started) * 1000) raise - calllog.record(service.name, url, status=status, error=None, ms=(time.monotonic() - started) * 1000) + calllog.record(service.name, hops[-1], status=status, error=None, ms=(time.monotonic() - started) * 1000) return body, charset -def _next_url(service: services.Service, url: str, location: str | None) -> str: +def _next_url(service: services.Service, url: str, location: str | None, hosts: tuple[str, ...] | None = None) -> str: if not location: raise NetworkError(f"{service.name} sent a redirect without an address.") target = urllib.parse.urljoin(url, location) parts = urllib.parse.urlsplit(target) if parts.scheme != "https": raise NetworkError(f"{service.name} redirected to an address that is not https, so FormCite stopped.") + if hosts is not None and (parts.hostname or "").lower() not in hosts: + raise NetworkError(f"{service.name} redirected to {parts.hostname}, which is not a host this call may reach, so FormCite stopped.") if (parts.hostname or "").lower() not in services.hosts(): raise NetworkError(f"{service.name} redirected to {parts.hostname}, a host no FormCite service declares, so FormCite stopped.") landed = services.by_host((parts.hostname or "").lower()) @@ -103,14 +154,17 @@ def _next_url(service: services.Service, url: str, location: str | None) -> str: return target -def _call(service: services.Service, url: str, sent: dict, timeout: float) -> tuple[bytes, str, int]: +def _call( + service: services.Service, url: str, sent: dict, timeout: float, read: Callable[[Any], Any], hosts: tuple[str, ...] | None, hops: list[str] +) -> tuple[Any, str, int]: for _ in range(MAX_REDIRECTS + 1): try: - return _once(service, url, sent, timeout) + return _once(service, url, sent, timeout, read) except urllib.error.HTTPError as exc: if exc.code not in REDIRECTS: raise _from_status(service, exc) from None - url = _next_url(service, url, exc.headers.get("Location")) + url = _next_url(service, url, exc.headers.get("Location"), hosts) + hops.append(url) exc.close() raise NetworkError(f"{service.name} redirected more than {MAX_REDIRECTS} times, so FormCite stopped.") @@ -121,11 +175,11 @@ def _from_status(service: services.Service, exc: urllib.error.HTTPError) -> Exce return _with_status(NetworkError(f"{service.name} answered with status {exc.code} {exc.reason}."), exc.code) -def _once(service: services.Service, url: str, sent: dict, timeout: float) -> tuple[bytes, str, int]: +def _once(service: services.Service, url: str, sent: dict, timeout: float, read: Callable[[Any], Any]) -> tuple[Any, str, int]: request = urllib.request.Request(url, headers=sent, method="GET") try: with _OPENER.open(request, timeout=timeout) as response: - return _read(response), response.headers.get_content_charset() or "utf-8", response.status + return read(response), response.headers.get_content_charset() or "utf-8", response.status except urllib.error.HTTPError as exc: if exc.code in REDIRECTS: raise @@ -144,6 +198,8 @@ def _once(service: services.Service, url: str, sent: dict, timeout: float) -> tu raise NetworkError(f"{service.name}: {exc}.") from None except (OSError, EOFError) as exc: raise NetworkError(f"The connection to {service.name} failed: {exc}.") from None + except http.client.HTTPException as exc: + raise NetworkError(f"The connection to {service.name} broke off: {exc!r}.") from None def fetch_text(service: str, url: str, *, params: dict | None = None, headers: dict | None = None, timeout: float = 10.0) -> str: @@ -154,6 +210,14 @@ def fetch_text(service: str, url: str, *, params: dict | None = None, headers: d return body.decode("utf-8", errors="replace") +def fetch_to_file( + service: str, url: str, path: str, *, limit: int, want_type: str, hosts: tuple[str, ...], timeout: float = 30.0, total: float = 120.0 +) -> int: + reader = _stream_to(path, limit, want_type, time.monotonic() + total) + size, _ = _request(service, url, None, None, timeout, want_type or "*/*", reader, hosts) + return size + + def fetch_json(service: str, url: str, *, params: dict | None = None, headers: dict | None = None, timeout: float = 10.0) -> Any: body, charset = _request(service, url, params, headers, timeout, "application/json") try: diff --git a/backend/app/routers/library.py b/backend/app/routers/library.py index 57347a7..a7fb553 100644 --- a/backend/app/routers/library.py +++ b/backend/app/routers/library.py @@ -3,6 +3,7 @@ from fastapi import APIRouter, HTTPException, Query from pydantic import BaseModel +from app.services import fulltext from app.services import library as svc from app.store import files, libraries from app.store.errors import Invalid, NotFound @@ -182,6 +183,16 @@ def attachment_remove(attachment_id: str) -> dict: return _run(svc.attachment_remove, attachment_id) +@router.get("/items/{item_id}/fulltext") +def item_fulltext(item_id: str) -> dict: + return _run(lambda: fulltext.links(svc.item_show(item_id))) + + +@router.post("/items/{item_id}/fulltext/pdf") +def item_fetch_pdf(item_id: str) -> dict: + return _run(fulltext.fetch_pdf, item_id) + + @router.get("/collections") def collection_list(tree: bool = False) -> list[dict]: return _run(svc.collection_list, tree) diff --git a/backend/app/routers/window.py b/backend/app/routers/window.py index 0c33c2b..621d6c2 100644 --- a/backend/app/routers/window.py +++ b/backend/app/routers/window.py @@ -71,3 +71,8 @@ def row(item_id: str) -> dict: @router.post("/attachments/{attachment_id}/open", dependencies=[Depends(window_only)]) def open_attachment(attachment_id: str) -> dict: return _run(opener.open_attachment, attachment_id) + + +@router.post("/items/{item_id}/open-arxiv", dependencies=[Depends(window_only)]) +def open_arxiv(item_id: str) -> dict: + return _run(opener.open_arxiv, item_id) diff --git a/backend/app/services/fulltext.py b/backend/app/services/fulltext.py new file mode 100644 index 0000000..f35681c --- /dev/null +++ b/backend/app/services/fulltext.py @@ -0,0 +1,108 @@ +import os +import re +import tempfile +import threading +from pathlib import Path + +from app import net +from app.lookup import arxiv +from app.lookup.arxiv_id import base, clean +from app.services import library +from app.store.errors import Invalid, NotFound + +MAX_BYTES = 100 * 1024 * 1024 +PDF_MIME = "application/pdf" +PDF_MAGIC = b"%PDF-" +ARXIV_DOI = re.compile(r"^10\.48550/arxiv\.(.+)$", re.IGNORECASE) +ARXIV_ADDRESS = re.compile(r"arxiv\.org/(?:abs|pdf)/", re.IGNORECASE) +PDF_HOSTS = ("arxiv.org", "export.arxiv.org") +_LOCKS: dict[str, threading.Lock] = {} +_LOCKS_GUARD = threading.Lock() + + +def _candidates(item: dict) -> list[str]: + csl = item.get("csl") or {} + out = [] + number = str(csl.get("number") or "") + if number.lower().startswith("arxiv:"): + out.append(number) + for url in (csl.get("URL"), item.get("url")): + if isinstance(url, str) and ARXIV_ADDRESS.search(url): + out.append(url) + for doi in (csl.get("DOI"), item.get("doi")): + found = ARXIV_DOI.match(str(doi or "").strip()) + if found: + out.append(found.group(1)) + return out + + +def arxiv_id(item: dict) -> str | None: + for text in _candidates(item): + try: + return clean(text) + except Invalid: + continue + return None + + +def _has_pdf(item: dict) -> dict | None: + for found in item.get("attachments") or []: + if found.get("mime") == PDF_MIME: + return found + return None + + +def _item(item_id: str) -> dict: + with library.session() as (_, conn): + return library.detail(conn, item_id) + + +def links(item: dict) -> dict: + identifier = arxiv_id(item) + pdf = _has_pdf(item) + return { + "arxiv_id": identifier, + "arxiv_url": f"{arxiv.ABS_URL}{identifier}" if identifier else None, + "pdf_attachment_id": pdf["id"] if pdf else None, + "can_fetch_pdf": bool(identifier) and pdf is None, + } + + +def _item_lock(item_id: str) -> threading.Lock: + with _LOCKS_GUARD: + return _LOCKS.setdefault(item_id, threading.Lock()) + + +def fetch_pdf(item_id: str) -> dict: + with _item_lock(item_id): + return _fetch_pdf(item_id) + + +def _fetch_pdf(item_id: str) -> dict: + item = _item(item_id) + held = _has_pdf(item) + if held is not None: + return {"attached": True, "attachment": held, "already": True} + identifier = arxiv_id(item) + if identifier is None: + raise NotFound("this item has no arXiv identifier, so there is no open-access PDF FormCite knows where to find") + net.check(arxiv.SERVICE) + name = f"arXiv-{base(identifier).replace('/', '-')}.pdf" + fd, staged = tempfile.mkstemp(prefix="formcite-pdf-", suffix=".pdf") + os.close(fd) + try: + net.fetch_to_file(arxiv.PDF_SERVICE, f"{arxiv.PDF_URL}{identifier}", staged, limit=MAX_BYTES, want_type=PDF_MIME, hosts=PDF_HOSTS) + with open(staged, "rb") as handle: + if handle.read(len(PDF_MAGIC)) != PDF_MAGIC: + raise net.NetworkError(f"arXiv did not answer with a PDF for {identifier}") + made = library.attachment_add(item_id, staged, "copy", name) + finally: + Path(staged).unlink(missing_ok=True) + return {"attached": True, "attachment": made, "already": False} + + +def try_fetch_pdf(item_id: str) -> dict: + try: + return fetch_pdf(item_id) + except (Invalid, NotFound) as exc: + return {"attached": False, "error": str(exc)} diff --git a/backend/app/services/lookup.py b/backend/app/services/lookup.py index bdf427d..b661e4a 100644 --- a/backend/app/services/lookup.py +++ b/backend/app/services/lookup.py @@ -1,5 +1,5 @@ from app import lookup -from app.services import duplicates +from app.services import duplicates, fulltext from app.services.library import detail, session from app.store import batches, db, items from app.store.errors import Invalid @@ -39,5 +39,7 @@ def add(text: str, *, on_duplicate: str = "skip", kind: str | None = None) -> di with db.tx(conn): batch = batches.create(conn, source["kind"], source["value"]) made = items.create(conn, found["record"], batch_id=batch["id"]) + pdf = fulltext.try_fetch_pdf(made["id"]) if source["kind"] == "arxiv" else None + with session() as (_, conn): return {"added": True, "duplicate_of": None, "batch_id": batch["id"], - "item": detail(conn, made["id"]), "source": source} + "item": detail(conn, made["id"]), "source": source, "pdf": pdf} diff --git a/backend/app/services/opener.py b/backend/app/services/opener.py index d74b8dc..38d4828 100644 --- a/backend/app/services/opener.py +++ b/backend/app/services/opener.py @@ -3,6 +3,7 @@ import sys from pathlib import Path +from app.services.library import detail as library_detail from app.services.library import session from app.store import attachments, files from app.store.errors import Invalid, NotFound @@ -60,6 +61,25 @@ def formpdf_argv(install: str, path: Path) -> list[str]: return [install, str(path)] +def open_arxiv(item_id: str) -> dict: + from app.services import fulltext + + with session() as (_, conn): + found = fulltext.links(library_detail(conn, item_id)) + url = found["arxiv_url"] + if not url: + raise NotFound("this item has no arXiv identifier") + argv = None if sys.platform.startswith("win") else (["open", url] if sys.platform == "darwin" else ["xdg-open", url]) + try: + if argv is None: + os.startfile(url) + else: + subprocess.Popen(argv, stdin=subprocess.DEVNULL, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, start_new_session=True) + except (OSError, AttributeError) as exc: + raise Invalid(f"the web browser could not be started: {exc}") from exc + return {"id": item_id, "url": url} + + def hand_to_formpdf(install: str, path: Path) -> str | None: try: proc = subprocess.Popen( diff --git a/frontend/HASHOUT_LOG.md b/frontend/HASHOUT_LOG.md index 00ee8bd..2c2fc9f 100644 --- a/frontend/HASHOUT_LOG.md +++ b/frontend/HASHOUT_LOG.md @@ -581,3 +581,132 @@ Removed, quoted: `const CHEV = ...`; the section head ``; `grid-template-columns: 20px minmax(0, 1fr) auto var(--ctl-sm); ... padding: 0 var(--space-2) 0 var(--space-4);`; `.fc-sb-head > .fc-sb-live { grid-row: 1; grid-column: 3; }`; `.fc-tt-btn { ... width: var(--ctl-sm); height: var(--ctl-sm); ... }`, `.fc-tt-btn:hover { ... }`, `.fc-tt-btn[aria-pressed="true"] { ... }`, `.fc-sb-head > .fc-sb-dock { grid-row: 1; grid-column: 4; }`. + +Traffic lights: the pre-paint in `index.html` and the two inset rules are unchanged (78 px on the head when `data-fc-menubar="native"`, on the in-window bar when `"window"`, none when `data-fc-lights="full"`). `watchTrafficLights` now also asks once at start, so a window restored straight into full screen drops the inset without waiting for a resize; when it is not full screen the answer equals the pre-paint value and nothing is written. + +Checked in a production build served by the engine, headless Chrome, CPU 4x, with a stand-in macOS shell (`MacIntel`, a stub `__TAURI_INTERNALS__` whose menu calls succeed): native menus, in-window bar 0 px; head padding 78, icon 78 to 98, name 106 to 192, version 200 to 248 of 264; top bar Add 1278 to 1350, agent 1362 to 1392, gear 1398 to 1428 at 1440 by 900 (1202 and 1238 at 1280 by 800), all 30 by 30 at y 7. Button, Cmd+J and View, Agent Dock each opened and closed the dock with `aria-pressed` following; the gear opened Preferences, which has Agents and "Show the agent dock". Full screen: inset 78 to 16 and back. Layout shift 0 on load, on both dock toggles and on opening Preferences, in dark and light. + +## src/ui/menus.ts, src/ui/native-menu.ts · on a Mac the menus stay in the menu bar, never a second bar in the window {#src-menus-mac-only-bar} + +New in v0.15.2 (2026-12-01, EST). The owner's 0.15.1 Mac app showed Tauri's own default menu bar (FormCite, File, Edit, View, Window, Help: no Library, so none of FormCite's menus) and, under the traffic lights, the in-window row FormCite File Edit View Library Window Help. On a Mac the page can show that row in only two ways: the person turned on View, Menus in Window (`formcite.menusInWindow` is `'1'`, written by the shell pref or by the pre-paint from the engine's `window-look.json` `menus: "window"`; the default is `bar`, unchanged), or `mountMenus`'s catch after `NativeMenus.build()` rejected. With the default stored, it was the catch: the system menu bar was never replaced, which is what a rejected build leaves, and the catch then set `data-fc-menubar="window"`, which opens the 0 px row to 40 px after first paint (a layout shift as well) and mounted the in-window bar. The 0.15.1 commits did not touch the menu modules or `wantsNativeMenus()`; the `data-fc-lights` pre-paint only made the row start at 78 px, so it reads as sitting under the traffic lights. One failing `plugin:menu|new` call was enough to reject the whole build, because every item was awaited in one `Promise.all` with no catch. Which call the real shell refused cannot be seen from Linux; the stand-in bridge accepts every payload the module sends (see below). + +FormVis's rule is followed: on macOS a failed build never brings the in-window bar (`ui/native-menu.ts` there: `native.build().catch(() => undefined)`). Here the catch logs the error and binds the page's own `Mod+` keys (`bindKeys`, invisible), so the shortcuts still work under the system's default menu; `data-fc-menubar` stays `native` and the row stays 0 px. Before, quoted: `void native.build().catch(() => { document.documentElement.dataset.fcMenubar = 'window'; new MenuBar(host, src, IN_WINDOW); bindKeys(src); });`. In `NativeMenus.build`, each item now goes through `make`, which wraps the old body (renamed `create`) in a catch: an item the shell refuses is left out and logged, and the rest of the menu bar is still set, as FormLedger and FormVis already do for an accelerator Tauri cannot read. The app menu's fixed items (About, Services, Hide, Hide Others, Show All, Quit, separators) go through the same kind of catch (`fixed`) and are created together in order with one `Promise.all` instead of one after another. Before, quoted: `const make = async (spec: MenuItem): Promise => {` and `const app = await api.Submenu.new({ text: 'FormCite', items: [` `await api.PredefinedMenuItem.new({ item: { About: { name: 'FormCite', version: VERSION, ... } }, text: 'About FormCite' }),` `await api.PredefinedMenuItem.new({ item: 'Separator' }),` `...((await Promise.all(this.appMenu.map(make))).filter(Boolean)),` then one `await api.PredefinedMenuItem.new({ item: ... })` each for Separator, Services, Separator, Hide, HideOthers, ShowAll, Separator, Quit, `] as never[] });`. + +Checked (verified under throttling, CPU 4x, headless Chrome at 1440 by 900, a production build of this tree served statically, no engine) with a stand-in macOS shell: `navigator.platform` `MacIntel` and a stub `__TAURI_INTERNALS__` that checks each `plugin:menu|new` payload the way the shell's types do (predefined names, `text` a string, `checked` a boolean for check items, children by resource id) and records `set_as_app_menu`. Default: `data-fc-menubar` `native`, the bar host 0 px in every frame sampled from the first, no `.fc-menubar` buttons, and the menu set holds FormCite, File, Edit, View, Library, Window and Help with every item and its accelerator (Preferences CmdOrCtrl+,; Library's four item commands off with nothing selected; Menus in Window a check item, off). The stub's Preferences item opened the Preferences dialog; its Duplicates item switched the view. Set refused: no bar in the window, host 0 px, the error logged. One item refused (Services): the rest of the menu set. `formcite.menusInWindow` `'1'`: the in-window bar with Window, 40 px from the first frame, no system menu call. Plain browser (Linux, Windows): the in-window bar, 40 px. Not checked: a real Mac, so which shell call failed for the owner is not known; that the native About panel and the predefined Edit and Window items behave on macOS. + +Enabled state: the Library menu's item commands (`ITEM_COMMANDS`) are enabled only while an item is selected, in the system menu and the in-window bar alike (before, they were always enabled and did nothing without a selection), and the system menu refreshes on the library's `selected` event as well as on pointer, key and focus. Before, quoted: `enabled: (id) => { const b = BUILT_IN[id]; if (b) return b.enabled ? b.enabled() : true; return isEnabled ? isEnabled(id) : true; },`. + +Unchanged: `MENUS` is the one list for both bars; the system menu adds the app menu (About as the native panel with version and licence, Home, Preferences with Cmd+,, Services, Hide, Hide Others, Show All, Quit) and the in-window bar adds its FormCite menu; Edit and Window items are Tauri predefined items, so text fields get the standard selectors without the Rust `text_edit` call FormVis needs for its own Edit commands. Windows and Linux keep the in-window bar. View, Menus in Window is a check item on macOS only and applies at the next start. No Rust file changed. + +## src/ui/preferences.ts, src/styles/preferences.css, src/ui/connections.ts · Preferences floats over the window as FormVis's dialog with the wire {#src-prefs-floating-dialog} + +New in v0.15.2 (2026-12-01, EST), prefs. The owner: 0.15.1's Preferences opened as a page in the main view (a `.fc-pane.fc-view[data-pane="preferences"]` holding the rail and one card side by side), where every other Form app floats it over the window. Standard line 2. Supersedes the page layout of 5d4bc97; the section content is unchanged. + +Ported by hand from FormVis 2.9.0 (`ui/app-dialogs.ts` 829 to 880 and 1026 to 1110, `ui/dialogs.ts` the scrim, Esc and pointerdown-outside, `styles/dialogs.css` 155 to 194) and checked against FormPortal's `extensions/prefs/index.ts`, which keeps the `cv-prefs-*` names in its own app; FormCite keeps them too for the shell (scrim, frame, head, rail, nav, rail tabs, fold, wire, port, pages, foot) so the Form apps share one vocabulary, and the section content keeps its `fc-pr-*` classes. `mountPreferences(engine)` builds the dialog once, hidden, into `#overlay-root`; `openPreferences(section?)` shows it. The frame is FormVis's: `margin-left: 240px`, `width: min(840px, 100vw - 280px)`, `height: min(86vh, 780px)`, the rail absolutely placed `right: calc(100% + 28px)`, 232 px (76 px folded, kept in `formcite.prefsRailCollapsed`), so the rail's left edge is never left of the window. The wire is FormVis's `drawWire`, run in one `requestAnimationFrame` (`queueWire`) on open, on a section change, on fold, on the frame's ResizeObserver and on window resize: from the active tab's right edge along a trunk in the gap to the port at the head's bottom edge; only the two paths' `d` and the port's `transform` are written, and only when they change. One section is shown at a time, as in 0.15.1 (`hidden` on the other cards, roving `tabindex`, arrows, Home and End), so FormVis's scroll spy and card folding are not ported. + +Open, close, keys: the gear (`[data-prefs-open]`, whose `aria-expanded` follows), the sidebar's Preferences item, Cmd/Ctrl+, and the app menu's Preferences item all run `app.preferences`, whose hook is now `openPreferences()`. The sidebar branch in the nav click of `connections.ts` dispatches it instead of switching the view, so the main view stays where it was; `'preferences'` leaves `ViewId`. Esc, the close box, Done and a pointerdown on the dimmed window close it; focus goes to the active tab on open and back where it was on close; Tab and Shift+Tab cycle inside the frame (rail included) and a `focusin` outside pulls focus back while open; keys inside do not reach the window's shortcuts. FormVis 2.9.0 and FormPortal have no open or close animation in their source (FormVis toggles `hidden`, FormPortal calls `showModal`), so the one here is opacity on the scrim and opacity plus `translateY(8px)` on the frame, 160 ms in and 120 ms out, transform and opacity only; the close waits for the scrim's `animationend`, or hides at once when no animation runs. z-index: the scrim `--z-modal`, rail tabs and fold `--z-raised`, wire `--z-base`, port `--z-sticky`, all inside the scrim. Removed, quoted: `.fc-pr { ... display: grid; grid-template-columns: var(--fc-pr-rail-w) minmax(0, var(--fc-pr-dlg-w)); ... }`, `.fc-pr-dlg { display: grid; grid-template-rows: 44px minmax(0, 1fr); ... }`, the `@media (max-width: 1180px)` icon-only rail, `

`, and the `engine.library.events.on('view', ...)` that loaded Network and Libraries when the page was shown (now on open). The dock hint reads "the agent button at the top right". + +Checked (verified under throttling, CPU 4x, headless Chrome, a production build served by the engine, dark at 1440 by 900 and light at 1280 by 800): Ctrl+,, the gear, the sidebar item and FormCite, Preferences in the in-window menu each open it with the view unchanged; each of the five rail tabs shows its card alone and moves the wire (tab centre y 37, 81, 125, 169, 213; port fixed at 45), frame rect unchanged; Network lists the 9 services and Recent calls, Libraries lists the library; 80 Tab and Shift+Tab presses stayed inside; Esc, outside and Done close it and `aria-expanded` returns to false. Layout shift: 0 on load, open, close and every section switch; the only entry is the fold toggle (rail width, `hadRecentInput` true). Not checked: the Menus section, which shows on a Mac desktop only, and a real Mac window. + +## src/ui/app.ts, src/styles/shell.css · the in-page Preferences view leaves the shell {#src-shell-prefs-dialog} + +New in v0.15.2 (2026-12-01, EST), topbar, at the prefs role's request. Preferences is now a dialog that `mountPreferences(engine)` mounts into `#overlay-root` (#src-prefs-floating-dialog above), so the shell no longer has a page for it. `app.ts` imports `openPreferences`, which the `preferences:` hook (the gear, Cmd or Ctrl+, and the menus) already calls; `mountPreferences` loses its host argument. Removed, quoted: `Preferences` from `.fc-tb-title`; the pane `

${icon('sliders', 14)}Preferences

`; `mountPreferences(engine, at('preferences'));`; and in `shell.css` the selectors `.fc-panes[data-view="preferences"] .fc-tb-title > [data-v="preferences"]` and `.fc-panes[data-view="preferences"] > .fc-view[data-pane="preferences"]`, the rest of both rules kept. Nothing on screen moves: the removed pane was `display: none` outside its own view. + +## src/ui/start.ts, src/ui/itemlist.ts, src/ui/duplicates.ts, src/ui/trash.ts, src/ui/titles.ts, src/styles/itemlist.css, src/styles/detail.css, src/styles/review.css, src/styles/home.css · every view fits and none is an empty rectangle {#src-views-line-7} + +New in v0.15.2 (2026-12-01, EST), layout. This is standard line 7. On the owner's MacBook Air, Items showed one row beside a large pane that said only "No item selected." Duplicates, Trash and Needs a title put one grey sentence under their bar and left the rest of the sheet blank. Home scrolled by 60 px at 1280 by 800, and so did the details pane, by 11 px. + +Empty states (`ui/start.ts`, new): one `.fc-start` block holds an icon, a title, a line of text and the main actions. The actions are Add by identifier, Import a file and Choose a PDF, the same three as Home's hero, with the hint "Paste an arXiv id such as arXiv:2402.06196, a DOI, an ISBN or a PubMed ID". There are three uses: +- `DETAIL_START`, which topbar put in the app.ts SHELL (e1c5ffd). Its root keeps `fc-empty fc-empty-center`, so `mountDetail` hides and shows it as before. +- The list's block, which `mountItemList` builds. It replaces the SHELL's one-line `

` before `revealApp`, so nothing changes after first paint. +- `reviewStart` in Duplicates, Trash and Needs a title, with Open Items, plus Import a file in Needs a title. + +The list block has three texts (library empty, collection or Unfiled empty, no search match), and the details block has two (nothing selected, list empty). Each text sits in the same grid cell (`grid-area: 1 / 1`), and only `visibility` changes, so a block's size never depends on its state. `mountItemList` sets `.fc-panes[data-fc-list="empty"|"some"]`. While the list itself shows the actions, the details block shows what can be pasted (arXiv, DOI, ISBN, PubMed, files) in place of a second copy of them. These forms are the ones `backend/app/lookup/guess.py` accepts. One `bindStart` listener on `.fc-panes` runs every `[data-start]` button and `.fc-start-pick` input, and opens the add panel the way `ui/home.ts` does. + +Removed, quoted: +- `itemlist.ts`: `const empty = host.querySelector('.fc-empty');` and `if (empty) { empty.classList.add('fc-il-empty'); setHidden(empty, true); scroll.append(empty); }`, and in `reset`, `if (empty) { setText(empty, lib.query ? 'No items match this search.' : 'No items here yet.'); setHidden(empty, total > 0); }`. +- `duplicates.ts`: `showNote(groups.length || quiet || !loadedOnce ? '' : 'Nothing here. Items that share a DOI, or a title, year and first creator, would be listed.');`. +- `trash.ts`: `showNote(items.length || quiet ? '' : (loadedOnce ? 'Nothing here. Items you move to the trash wait here until you delete them for good.' : ''));`. +- `titles.ts`: `if (!items.length && loadedOnce) showNote('Nothing here. Imported entries without a title wait here until you give them one.');`. + +The note line itself stays for loading and errors. + +Split and fit: +- The list's columns now follow the list's own width, through a `fc-list` container query, in place of the window width. Removed, quoted from `itemlist.css`: `@media (max-width: 1250px) { .fc-il { --il-col-creator: 120px; --il-col-type: 0px; --il-col-added: 100px; } .fc-il-head > :nth-child(4), .fc-il-row > :nth-child(4) { visibility: hidden; padding: 0; overflow: hidden; } }`. Under 700 px the Type column folds; under 560 px, Added does too. At 1440 the split is 748 by 420, with all five columns. At 1280 it is 624 by 384: Type folds and the title gets about 330 px, where it had about 200. +- The detail tabs share the row (`flex: 1 1 auto`, padding `--space-1h`). Before, `.fc-dt-tabs` had `gap: var(--space-1)` and each tab `padding: 0 var(--space-2)`, so at 384 px "Notes" was cut off. +- Below 860 px of height, the creators box goes from 144 to 120 px, and Home's padding and gaps go to `--space-4`. +- While the details empty state shows, its pane body is `overflow: hidden`, so the hidden inspector under it cannot scroll it. + +Checked (verified under throttling, CPU 4x, headless Chrome, production build served by the engine, the urban-heat demo and an empty library, 1440 by 900 and 1280 by 800, dark and light): +- Items, the details pane, Home, Duplicates, Trash and Needs a title have scrollHeight equal to clientHeight. +- The layout shift is 0 on load, on each view switch, on selecting an item, on each detail tab and on selecting another item. A probe shift was caught, so the observer was live. +- Each start button opens the add panel on the right tab, Choose a PDF opens a multi-file chooser, and Open Items goes to Items. + +Not in these files: the sidebar's Collections and Tags still scroll (1017 px of content in 692 at 1280 by 800). Fixed next, in #src-side-fold. + +## src/ui/side.ts, src/styles/side.css · the navigation stays put, Collections and Tags fold and scroll on their own {#src-side-fold} + +New in v0.15.2 (2026-12-01, EST), layout, assigned by the coordinator. This is standard line 7. With the 260-item demo, the whole sidebar was one scroll of 1017 px in 692 (1280 by 800), so scrolling down to the tags took the navigation (Home to Preferences) off screen. + +Now: +- `.fc-side > .fc-pane-body` is a flex column with `overflow: hidden`, and `.fc-nav` is `flex: none`, so the navigation never scrolls. +- The Collections and Tags sections share what is left (`flex: 0 1 auto`, so the share goes by content). Each scrolls inside its own `.fc-side-scroll` and keeps at least its head and three rows. +- At mount, before `revealApp`, `mountSide` wraps each section's content in that region. It turns the head into a disclosure button (`.fc-section-toggle`, `aria-expanded`, `aria-controls`), FormVis's panel-head pattern: a chevron turned -90 degrees when shut. +- The open state is saved in `localStorage` under `formcite.side.open` and applied at mount, so first paint already has it. A shut section gives its height to the other one. + +Tags are a wrapping row of chips: the name and a fixed 30 px count slot, no icon, and the chip style of the details pane's tags. +- On hover, rename and delete take the place of the count, in an opaque overlay of the same width, so nothing moves. +- Rename covers the chip's whole line from inside the list: the row is `position: static; contain: none`, the input keeps its inline static position for its top, and `left` and `right` place it against the list. + +Removed, quoted: `.fc-side-tags { max-height: calc(var(--fc-side-row-h) * 12); overflow-y: auto; overscroll-behavior: contain; }`. The section's own region replaces that inner 12-row scroll. `.fc-section > .fc-side-msg` no longer matches anything. The message's indent moved to `.fc-side-scroll > .fc-side-msg`. + +Checked (verified under throttling, CPU 4x, headless Chrome, production build served by the engine, urban-heat demo, 1440 by 900 and 1280 by 800, dark and light): +- The sidebar body is 792 of 792 and 692 of 692. The nav top stays at 84 after scrolling Tags to the end and clicking the last tag. +- Collections shows 272 of 336 px and Tags 182 of 228 at 1440; Collections 213 of 336 and Tags 141 of 228 at 1280. With Collections shut, Tags shows all 228. +- Shut stays shut after a reload. Layout shift is 0 on load and on reload with a section shut. The only entry is opening a section by hand (0.017 to 0.019, `hadRecentInput` true), where the other section moves by design. + +## src/styles/itemlist.css, src/styles/side.css · the dock opens and closes with no layout shift {#src-dock-zero-shift} + +New in v0.15.2 (2026-12-01, EST), lead, taken over from layout for verify's V1 (standard line 6). Verify measured a layout shift on every toggle of the agent dock on Items, from three sources: +- **The details pane's empty state re-centred** in the shorter pane: `.fc-start` used `place-items: center`, so `.fc-start-box` moved from y 299 to 159. Shifts of 0.027 to 0.039. It now sits at the top with fixed padding: `place-items: start center; align-content: start; padding: var(--space-8) var(--space-4) var(--space-6)`. +- **The list's empty error line moved with the list's bottom edge:** `.fc-il-error` is bottom-anchored and painted even when empty (0.002 to 0.005, already in 0.15.1). It is now `visibility: hidden` while empty (`.fc-il-error:empty`), so it neither paints nor counts. +- **The sidebar's Collections and Tags were re-shared** when the dock shortened the sidebar, because each `.fc-side-pane > .fc-section` was `flex: 0 1 auto`, and the Tags section moved (0.002 to 0.010). Each section now has a fixed size, `flex: none`, with its height capped at the head plus six rows (204 px). Content past that scrolls inside the section, as before, and the dock covers the sidebar's foot instead of reflowing it. + +Measured with verify's script `/tmp/fc152v/dockcls.py` on a build of this tree, CPU 4x, stand-in macOS shell, urban-heat demo, at 1440 by 900 and 1280 by 800, with nothing selected, an item selected and Home: 0 on every open and every close. The sidebar fits at both sizes: the pane body is 832 of 832 and 732 of 732. The sections start at y 309 and 513, 204 px each, and Collections (336 in 168) and Tags (228 in 167) scroll inside. + +Before, quoted: +- `.fc-start { ... display: grid; place-items: center; padding: var(--space-6) var(--space-4); ... }` +- `.fc-side-pane > .fc-section { flex: 0 1 auto; ... }` + +## src/styles/preferences.css · Preferences shows and hides at once, as in FormVis {#src-prefs-no-animation} + +New in v0.15.2 (2026-12-01, EST), by the lead on the coordinator's decision, in the prefs role's file. FormVis 2.9.0, FormPortal and FormLedger 0.15.1 have no open or close animation on their dialogs. The prefs role had added a 160 ms fade-and-rise in and a 120 ms fade-out, and these are removed, so the dialog appears and disappears in the same frame. + +`ui/preferences.ts` is unchanged. Its `close()` already calls `finish()` at once when `scrim.getAnimations()` is empty, and the `is-closing` class is now only a flag that no rule styles. + +Checked on a build of this tree with CPU 4x and the stand-in macOS shell. The gear showed the dialog at opacity 1 with no running animations 30 ms after the click. Esc hid it within 30 ms, and so did a click outside. Layout shift was 0. + +Removed, quoted: +- `animation: cv-prefs-scrim-in 160ms var(--ease-glass) both;` on `.cv-prefs-scrim`; +- `.cv-prefs-scrim.is-closing { pointer-events: none; animation: cv-prefs-scrim-out 120ms ease-in both; }`; +- `.cv-prefs-scrim > .cv-prefs-dlg { animation: cv-prefs-dlg-in 160ms var(--ease-glass) both; }`; +- `.cv-prefs-scrim.is-closing > .cv-prefs-dlg { animation: cv-prefs-dlg-out 120ms ease-in both; }`; +- the four `@keyframes`, `cv-prefs-scrim-in`, `cv-prefs-scrim-out`, `cv-prefs-dlg-in` and `cv-prefs-dlg-out`. diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 40ca10b..ae636f7 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -1,12 +1,12 @@ { "name": "formcite", - "version": "0.15.1", + "version": "0.15.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "formcite", - "version": "0.15.1", + "version": "0.15.2", "license": "GPL-3.0-only", "dependencies": { "@tauri-apps/api": "2.12.5", diff --git a/frontend/package.json b/frontend/package.json index e4015f5..58f2e2e 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -1,7 +1,7 @@ { "name": "formcite", "private": true, - "version": "0.15.1", + "version": "0.15.2", "description": "FormCite: a local-first personal research library from the Form family", "license": "GPL-3.0-only", "type": "module", diff --git a/frontend/src/engine/library.ts b/frontend/src/engine/library.ts index e6b0531..b9724ec 100644 --- a/frontend/src/engine/library.ts +++ b/frontend/src/engine/library.ts @@ -8,7 +8,7 @@ export interface Sort { key: SortKey; desc: boolean } export interface Counts { shown: number; total: number } -export type ViewId = 'library' | 'connections' | 'duplicates' | 'trash' | 'preferences'; +export type ViewId = 'library' | 'connections' | 'duplicates' | 'trash'; export interface LibraryEvents { 'view': ViewId; diff --git a/frontend/src/io/detail.ts b/frontend/src/io/detail.ts index c5c7e90..6ea03bd 100644 --- a/frontend/src/io/detail.ts +++ b/frontend/src/io/detail.ts @@ -16,6 +16,8 @@ export interface ItemDetail { trashed_at?: string | null; } +export interface Fulltext { arxiv_id: string | null; arxiv_url: string | null; pdf_attachment_id: string | null; can_fetch_pdf: boolean } + export interface OpenResult { opened_with?: string; via?: string; [k: string]: unknown } async function patch(path: string, body: unknown): Promise { @@ -56,6 +58,9 @@ export const detailApi = { removeTags: (id: string, names: string[]) => delWith<{ item_id: string; tags: string[] }>(`/library/items/${enc(id)}/tags`, { names }), trash: (id: string) => api.post(`/library/items/${enc(id)}/trash`, {}), openAttachment: (attachmentId: string) => api.post(`/library/attachments/${enc(attachmentId)}/open`, {}), + fulltext: (id: string, signal?: AbortSignal) => api.get(`/library/items/${enc(id)}/fulltext`, signal), + fetchPdf: (id: string) => api.post<{ attached: boolean; attachment: Attachment }>(`/library/items/${enc(id)}/fulltext/pdf`, {}), + openArxiv: (id: string) => api.post<{ url: string }>(`/library/items/${enc(id)}/open-arxiv`, {}), noteAdd: (id: string, body: string) => api.post(`/library/items/${enc(id)}/notes`, { body }), noteEdit: (noteId: string, body: string) => patch(`/library/notes/${enc(noteId)}`, { body }), noteDelete: (noteId: string) => delWith(`/library/notes/${enc(noteId)}`, {}), diff --git a/frontend/src/styles/detail.css b/frontend/src/styles/detail.css index e9690f6..37e42fc 100644 --- a/frontend/src/styles/detail.css +++ b/frontend/src/styles/detail.css @@ -14,10 +14,23 @@ font-size: var(--fs-12); } .fc-dt.is-empty { visibility: hidden; } +.fc-detail > .fc-pane-body:has(> .fc-start:not([hidden])) { overflow: hidden; } .fc-dt.is-loading .fc-dt-fields, .fc-dt.is-loading .fc-dt-sec { opacity: 0.6; transition: opacity 0.2s 0.3s; } -.fc-dt-head { display: flex; align-items: center; justify-content: space-between; height: var(--dt-row-h); } -.fc-dt-status { color: var(--text-muted); min-width: 0; } +.fc-dt-head { display: flex; align-items: center; gap: var(--space-1); height: var(--dt-row-h); } +.fc-dt-status { flex: 1 1 auto; color: var(--text-muted); min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; } +.fc-dt-btn { flex: none; } +.fc-dt-btn.is-off { visibility: hidden; } +.fc-dt-pdf-text { display: inline-grid; } +.fc-dt-pdf-text::after { content: "Getting PDF"; grid-area: 1 / 1; visibility: hidden; height: 0; } +.fc-dt-tabs { display: flex; flex: none; gap: 0; height: var(--dt-row-h); border-bottom: 1px solid var(--line-1); } +.fc-dt-tab { flex: 1 1 auto; justify-content: center; min-width: 0; display: inline-flex; align-items: center; gap: var(--space-1); height: var(--dt-row-h); padding: 0 var(--space-1h); border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--text-secondary); font: inherit; cursor: pointer; } +.fc-dt-tab:hover { color: var(--text-primary); } +.fc-dt-tab.is-on { border-bottom-color: var(--accent); color: var(--text-primary); } +.fc-dt-tab:focus-visible { outline: 1px solid var(--accent-color); outline-offset: -1px; } +.fc-dt-tab-count { min-width: 2ch; color: var(--text-muted); } +.fc-dt-page { display: flex; flex-direction: column; gap: var(--space-1); min-height: 0; } +.fc-dt-page[hidden] { display: none; } .fc-dt-error { height: var(--dt-error-h); line-height: var(--dt-error-h); margin: 0; color: var(--danger-text); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; } .fc-dt-btn { display: inline-flex; align-items: center; gap: var(--space-1); height: var(--dt-row-h); padding: 0 var(--space-2); border: 1px solid var(--line-2); border-radius: var(--radius-sm); background: var(--surface-2); color: var(--text-primary); font: inherit; cursor: pointer; } @@ -61,6 +74,9 @@ .fc-dt-cr { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) var(--dt-cr-role-w) repeat(4, var(--dt-cr-btn)); grid-template-rows: var(--dt-row-h); grid-template-areas: "fam giv role single up down x"; } .fc-dt-cr.is-single .fc-dt-cr-family { grid-column: 1 / 3; } } +@media (max-height: 860px) { + .fc-dt-cr-sec { --dt-cr-h: 120px; } +} .fc-dt-cr-family { grid-area: fam; } .fc-dt-cr-given { grid-area: giv; } .fc-dt-cr-role { grid-area: role; } diff --git a/frontend/src/styles/home.css b/frontend/src/styles/home.css index f9fa880..404ecaa 100644 --- a/frontend/src/styles/home.css +++ b/frontend/src/styles/home.css @@ -51,6 +51,12 @@ button.fc-home-tile:hover { border-color: var(--line-3); background: var(--bg-ho .fc-home-none[hidden] { display: none; } .fc-home-error { margin: 0; min-height: 20px; color: var(--danger-text); font-size: var(--fs-12); } +@media (max-height: 860px) { + .fc-home { row-gap: var(--space-4); padding: var(--space-4) var(--space-8) var(--space-4); } + .fc-home-brand { margin-bottom: var(--space-1); } + .fc-home-hero { padding: var(--space-4) var(--space-6); } +} + @media (max-width: 900px) { .fc-home { padding: var(--space-4); } .fc-home-hero { grid-template-columns: minmax(0, 1fr); row-gap: var(--space-4); } diff --git a/frontend/src/styles/itemlist.css b/frontend/src/styles/itemlist.css index bb56514..1a987e8 100644 --- a/frontend/src/styles/itemlist.css +++ b/frontend/src/styles/itemlist.css @@ -62,6 +62,7 @@ .fc-il-col.is-desc .fc-il-arrow { transform: none; } .fc-il-error { position: absolute; left: 0; right: 0; bottom: 0; z-index: var(--z-raised); height: var(--il-error-h); margin: 0; background: var(--sheet); pointer-events: none; padding: 0 var(--space-2); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: var(--danger-text); font-size: var(--fs-11); line-height: var(--il-error-h); } +.fc-il-error:empty { visibility: hidden; } .fc-il-scroll { position: relative; overflow-y: auto; overflow-x: hidden; outline: none; contain: strict; } .fc-il-spacer { position: relative; height: 0; contain: layout; } @@ -76,6 +77,7 @@ contain: strict; will-change: transform; } +.fc-il-row[hidden] { display: none; } .fc-il-row:hover { background: var(--hover); } .fc-il-row.is-selected { background: var(--accent-wash); } .fc-il-scroll:focus-visible .fc-il-row.is-selected { box-shadow: inset 2px 0 0 var(--accent); } @@ -84,7 +86,46 @@ .fc-il-row .fc-il-c-creator, .fc-il-row .fc-il-c-type, .fc-il-row .fc-il-c-added { color: var(--text-muted); } .fc-il-row .fc-il-c-year, .fc-il-row .fc-il-c-added { font-variant-numeric: tabular-nums; } .fc-il-empty { pointer-events: none; } -@media (max-width: 1250px) { - .fc-il { --il-col-creator: 120px; --il-col-type: 0px; --il-col-added: 100px; } +.fc-list > .fc-pane-body { container: fc-list / inline-size; } +@container fc-list (max-width: 700px) { + .fc-il { --il-col-creator: 140px; --il-col-type: 0px; --il-col-added: 104px; } .fc-il-head > :nth-child(4), .fc-il-row > :nth-child(4) { visibility: hidden; padding: 0; overflow: hidden; } } +@container fc-list (max-width: 560px) { + .fc-il { --il-col-creator: 112px; --il-col-added: 0px; } + .fc-il-head > :nth-child(5), .fc-il-row > :nth-child(5) { visibility: hidden; padding: 0; overflow: hidden; } +} + +.fc-start { --fc-start-w: 440px; container: fc-start / inline-size; display: grid; place-items: start center; align-content: start; padding: var(--space-8) var(--space-4) var(--space-6); color: var(--text-secondary); font-size: var(--fs-13); text-align: center; pointer-events: none; } +.fc-start[hidden] { display: none; } +.fc-start-box { display: grid; justify-items: center; row-gap: var(--space-3); width: min(100%, var(--fc-start-w)); pointer-events: auto; } +.fc-start-icon { display: inline-grid; place-items: center; width: 52px; height: 52px; margin-bottom: var(--space-1); border: 1px solid var(--line-2); border-radius: var(--radius-lg); background: radial-gradient(120% 120% at 0% 0%, var(--accent-wash), transparent 60%), var(--surface-raised); color: var(--accent-color); box-shadow: var(--shadow-inset-hl); } +.fc-start-glyph { grid-area: 1 / 1; display: inline-grid; } +.fc-start[data-kind="search"] .fc-start-glyph[data-for="add"], .fc-start:not([data-kind="search"]) .fc-start-glyph[data-for="search"] { visibility: hidden; } +.fc-start-says { display: grid; width: 100%; } +.fc-start-say { grid-area: 1 / 1; display: grid; align-content: start; row-gap: var(--space-1h); visibility: hidden; } +.fc-start-say[data-say="review"], +.fc-start[data-kind="library"] .fc-start-say[data-say="library"], +.fc-start[data-kind="scope"] .fc-start-say[data-say="scope"], +.fc-start[data-kind="search"] .fc-start-say[data-say="search"], +.fc-start[data-start-in="detail"] .fc-start-say[data-say="pick"] { visibility: visible; } +.fc-panes[data-fc-list="empty"] .fc-start[data-start-in="detail"] .fc-start-say[data-say="pick"] { visibility: hidden; } +.fc-panes[data-fc-list="empty"] .fc-start[data-start-in="detail"] .fc-start-say[data-say="wait"] { visibility: visible; } +.fc-start[data-kind="search"] :is(.fc-start-actions, .fc-start-hint) { visibility: hidden; } +.fc-start-swap { display: grid; width: 100%; } +.fc-start-do { grid-area: 1 / 1; display: grid; justify-items: center; row-gap: var(--space-3); } +.fc-start-forms { grid-area: 1 / 1; display: grid; grid-template-columns: auto minmax(0, 1fr); align-content: start; gap: var(--space-1h) var(--space-3); margin: var(--space-2) 0 0; padding: var(--space-3); border: 1px solid var(--line-1); border-radius: var(--radius-lg); background: var(--surface-2); font-size: var(--fs-12); line-height: 18px; text-align: start; visibility: hidden; } +.fc-start-forms dt { color: var(--text-primary); font-weight: var(--weight-medium); } +.fc-start-forms dd { margin: 0; color: var(--text-secondary); } +.fc-start-forms code, .fc-start-hint code { padding: 1px 5px; border: 1px solid var(--line-2); border-radius: var(--radius-sm); background: var(--surface-1); color: var(--text-primary); font-family: var(--font-mono); font-size: var(--fs-11); } +.fc-panes[data-fc-list="empty"] .fc-start[data-start-in="detail"] .fc-start-do { visibility: hidden; } +.fc-panes[data-fc-list="empty"] .fc-start[data-start-in="detail"] .fc-start-forms { visibility: visible; } +.fc-start-title { margin: 0; color: var(--text-primary); font-size: 15px; font-weight: var(--weight-semibold); line-height: 22px; letter-spacing: -0.01em; } +.fc-start-sub { margin: 0; color: var(--text-secondary); font-size: var(--fs-13); line-height: 20px; text-wrap: pretty; } +.fc-start-actions { display: grid; grid-auto-flow: column; justify-content: center; gap: var(--space-2); margin-top: var(--space-2); } +.fc-start-actions .fc-btn { display: inline-grid; grid-auto-flow: column; align-items: center; justify-content: start; column-gap: var(--space-2); height: 34px; padding: 0 var(--space-3); white-space: nowrap; box-sizing: border-box; } +.fc-start-pick { cursor: pointer; } +.fc-start-hint { margin: 0; color: var(--text-muted); font-size: var(--fs-12); line-height: 18px; } +@container fc-start (max-width: 520px) { + .fc-start-actions { grid-auto-flow: row; grid-template-columns: minmax(0, 220px); width: 100%; } +} diff --git a/frontend/src/styles/preferences.css b/frontend/src/styles/preferences.css index 3931579..b28cc88 100644 --- a/frontend/src/styles/preferences.css +++ b/frontend/src/styles/preferences.css @@ -6,25 +6,42 @@ --fc-pr-line-h: 20px; --fc-pr-text-line-h: 15px; --fc-pr-label-w: 200px; - --fc-pr-rail-w: 232px; - --fc-pr-dlg-w: 840px; - --fc-pr-dlg-h: 780px; - display: grid; grid-template-columns: var(--fc-pr-rail-w) minmax(0, var(--fc-pr-dlg-w)); grid-template-rows: minmax(0, var(--fc-pr-dlg-h)); justify-content: center; align-content: start; column-gap: var(--space-7); height: 100%; padding: var(--space-4); box-sizing: border-box; } -.fc-pr-rail { display: flex; flex-direction: column; gap: var(--space-2); min-height: 0; max-height: 100%; align-self: start; padding: var(--space-2); box-sizing: border-box; border: 1px solid var(--border-light); border-radius: var(--radius-xl); background: var(--bg-secondary); box-shadow: var(--shadow-window); } -.fc-pr-nav { display: flex; flex-direction: column; gap: var(--space-1); flex: 1 1 auto; min-height: 0; padding: 6px; border: 1px solid var(--border-color); border-radius: var(--radius-lg); background: var(--bg-primary); overflow-x: hidden; overflow-y: auto; scrollbar-width: none; } -.fc-pr-railtab { position: relative; z-index: var(--z-raised); display: flex; align-items: center; gap: 10px; flex: none; width: 100%; height: 40px; padding: 0 10px; box-sizing: border-box; border: 1px solid var(--border-soft); border-radius: var(--radius-lg); background: var(--bg-tertiary); box-shadow: var(--shadow-sm); color: var(--text-secondary); font: inherit; font-size: var(--fs-12); font-weight: 500; text-align: start; white-space: nowrap; cursor: pointer; } -.fc-pr-railtab:hover { background: var(--bg-hover); color: var(--text-primary); } -.fc-pr-railtab.is-active { border-color: var(--accent-color); background: var(--accent-color); color: var(--text-on-accent); } -.fc-pr-railtab:focus-visible { outline: 2px solid var(--accent-color); outline-offset: 1px; } -.fc-pr-tabicon, .fc-pr-secicon { display: inline-flex; flex: none; color: var(--accent-color); } -.fc-pr-railtab.is-active .fc-pr-tabicon { color: currentColor; } -.fc-pr-tablabel { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; } -.fc-pr-dlg { display: grid; grid-template-rows: 44px minmax(0, 1fr); min-width: 0; min-height: 0; border: 1px solid var(--border-light); border-radius: var(--radius-lg); background: var(--bg-secondary); box-shadow: var(--shadow-window); overflow: clip; } -.fc-pr-head { display: flex; align-items: center; gap: var(--space-2); padding: 0 var(--space-2) 0 var(--space-4); border-bottom: 1px solid var(--border-color); } -.fc-pr-headicon { display: inline-flex; flex: none; color: var(--text-secondary); } -.fc-pr-title { flex: 1 1 auto; margin: 0; color: var(--text-primary); font-size: var(--fs-14); font-weight: var(--weight-semibold); } -.fc-pr-pages { display: flex; flex-direction: column; gap: var(--space-3); min-height: 0; padding: var(--space-3) var(--space-4) var(--space-4); overflow-y: auto; scrollbar-gutter: stable; box-sizing: border-box; background: var(--bg-primary); } +.cv-prefs-scrim { position: fixed; inset: 0; z-index: var(--z-modal); display: flex; align-items: center; justify-content: center; background: var(--bg-scrim); } +.cv-prefs-scrim[hidden] { display: none; } +.cv-prefs-dlg { position: relative; display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: 44px minmax(0, 1fr) auto; width: min(840px, calc(100vw - 280px)); height: min(86vh, 780px); margin-left: 240px; box-sizing: border-box; border: 1px solid var(--border-light); border-radius: var(--radius-lg); background: var(--bg-secondary); box-shadow: var(--shadow-window); outline: none; } +.cv-prefs-head { display: flex; align-items: center; gap: var(--space-2); padding: 0 var(--space-2) 0 var(--space-4); border-bottom: 1px solid var(--border-color); } +.cv-prefs-headicon { display: inline-flex; flex: none; color: var(--text-secondary); } +.cv-prefs-title { flex: 1 1 auto; margin: 0; color: var(--text-primary); font-size: var(--fs-14); font-weight: var(--weight-semibold); } +.cv-prefs-close { display: inline-flex; align-items: center; justify-content: center; width: var(--ctl-md); height: var(--ctl-md); padding: 0; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--text-secondary); cursor: pointer; } +.cv-prefs-close:hover { background: var(--bg-hover); color: var(--text-primary); } +.cv-prefs-close:focus-visible, .cv-prefs-fold:focus-visible { outline: 2px solid var(--accent-color); outline-offset: 1px; } +.cv-prefs-pages { display: flex; flex-direction: column; gap: var(--space-3); min-height: 0; padding: var(--space-3) var(--space-4) var(--space-4); overflow-y: auto; scrollbar-gutter: stable; box-sizing: border-box; background: var(--bg-primary); } +.cv-prefs-foot { display: flex; justify-content: flex-end; gap: var(--space-2); padding: var(--space-3) var(--space-4); border-top: 1px solid var(--border-color); border-radius: 0 0 var(--radius-lg) var(--radius-lg); } +.cv-prefs-rail { position: absolute; top: 0; right: calc(100% + var(--space-7)); display: flex; flex-direction: column; gap: var(--space-2); width: 232px; max-height: 100%; padding: var(--space-2); box-sizing: border-box; border: 1px solid var(--border-light); border-radius: var(--radius-xl); background: var(--bg-secondary); box-shadow: var(--shadow-window); } +.cv-prefs-dlg.is-rail-collapsed .cv-prefs-rail { width: 76px; } +.cv-prefs-nav { display: flex; flex-direction: column; gap: var(--space-1); flex: 1 1 auto; min-height: 0; padding: 6px; border: 1px solid var(--border-color); border-radius: var(--radius-lg); background: var(--bg-primary); overflow-x: hidden; overflow-y: auto; scrollbar-width: none; } +.cv-prefs-dlg.is-rail-collapsed .cv-prefs-nav { align-items: center; } +.cv-prefs-railtab { position: relative; z-index: var(--z-raised); display: flex; align-items: center; gap: 10px; flex: none; width: 100%; height: 40px; padding: 0 10px; box-sizing: border-box; border: 1px solid var(--border-soft); border-radius: var(--radius-lg); background: var(--bg-tertiary); box-shadow: var(--shadow-sm); color: var(--text-secondary); font: inherit; font-size: var(--fs-12); font-weight: 500; text-align: start; white-space: nowrap; cursor: pointer; } +.cv-prefs-railtab:hover { background: var(--bg-hover); color: var(--text-primary); } +.cv-prefs-railtab.is-active { border-color: var(--accent-color); background: var(--accent-color); color: var(--text-on-accent); } +.cv-prefs-railtab:focus-visible { outline: 2px solid var(--accent-color); outline-offset: 1px; } +.cv-prefs-tabicon, .fc-pr-secicon { display: inline-flex; flex: none; color: var(--accent-color); } +.cv-prefs-railtab.is-active .cv-prefs-tabicon { color: currentColor; } +.cv-prefs-tablabel { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; } +.cv-prefs-dlg.is-rail-collapsed .cv-prefs-tablabel { display: none; } +.cv-prefs-dlg.is-rail-collapsed .cv-prefs-railtab { justify-content: center; width: 44px; height: 44px; padding: 0; } +.cv-prefs-fold { position: relative; z-index: var(--z-raised); flex: none; align-self: stretch; display: inline-flex; align-items: center; justify-content: center; height: 40px; padding: 0; border: 1px solid var(--border-color); border-radius: var(--radius-lg); background: var(--bg-primary); box-shadow: var(--shadow-sm); color: var(--text-secondary); cursor: pointer; } +.cv-prefs-dlg.is-rail-collapsed .cv-prefs-fold { align-self: center; width: 44px; height: 44px; } +.cv-prefs-fold:hover { background: var(--bg-hover); color: var(--text-primary); } +.cv-prefs-fold .icon { transition: rotate 180ms ease; } +.cv-prefs-dlg.is-rail-collapsed .cv-prefs-fold .icon { rotate: 180deg; } +.cv-prefs-wire { position: absolute; left: 0; top: 0; z-index: var(--z-base); width: 1px; height: 1px; overflow: visible; pointer-events: none; } +.cv-prefs-wire path { fill: none; stroke-linecap: round; } +.cv-prefs-wire-shade { stroke: #000; stroke-opacity: 0.45; stroke-width: 6px; transform: translateY(3px); } +.cv-prefs-wire-line { stroke: var(--text-muted); stroke-width: 2px; } +.cv-prefs-port { position: absolute; left: -7px; top: -7px; z-index: var(--z-sticky); width: 14px; height: 14px; box-sizing: border-box; border: 2px solid var(--text-muted); border-radius: var(--radius-pill); background: var(--bg-secondary); box-shadow: var(--shadow-sm); pointer-events: none; } +.cv-prefs-port::after { content: ""; position: absolute; inset: 2px; border-radius: var(--radius-pill); background: var(--text-muted); } .fc-pr-sec { flex: none; border-radius: var(--radius-xl); background: var(--bg-secondary); box-shadow: var(--shadow-md), 0 0 0 1px color-mix(in srgb, var(--accent-color) 55%, transparent); overflow: hidden; transition: opacity 120ms linear; } .fc-pr-sec[hidden] { display: none; } .fc-pr-sec.is-busy { opacity: 0.6; } @@ -33,12 +50,6 @@ .fc-pr-secbody { display: flex; flex-direction: column; gap: 10px; padding: 0 14px 14px; } .fc-pr-group { display: grid; align-content: start; row-gap: var(--space-2); min-width: 0; padding: var(--space-3) var(--space-3h, 14px) var(--space-3h, 14px); border-radius: var(--radius-md); background: color-mix(in srgb, var(--bg-tertiary) 55%, var(--bg-secondary)); box-shadow: var(--shadow-sm); } .fc-pr-glabel { margin: 0; color: var(--accent-color); font-size: var(--fs-11); font-weight: var(--weight-semibold); letter-spacing: 0.07em; text-transform: uppercase; } -@media (max-width: 1180px) { - .fc-pr { --fc-pr-rail-w: 76px; column-gap: var(--space-4); } - .fc-pr-nav { align-items: center; } - .fc-pr-railtab { justify-content: center; width: 44px; height: 44px; padding: 0; } - .fc-pr-tablabel { display: none; } -} .fc-pr-note { margin: 0; min-height: calc(var(--fc-pr-line-h) * 2); color: var(--text-secondary); font-size: var(--fs-13); line-height: var(--fc-pr-line-h); } .fc-pr-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; column-gap: var(--space-3); min-height: var(--fc-pr-row-h); } .fc-pr-row:has(> .fc-pr-input) { grid-template-columns: var(--fc-pr-label-w) minmax(0, 1fr); } diff --git a/frontend/src/styles/review.css b/frontend/src/styles/review.css index 69ee444..ad9afc4 100644 --- a/frontend/src/styles/review.css +++ b/frontend/src/styles/review.css @@ -15,6 +15,7 @@ .fc-rv-bar-act { display: grid; grid-auto-flow: column; column-gap: var(--space-2); align-items: center; justify-content: end; min-width: var(--rv-act); } .fc-rv-note { position: absolute; inset: var(--rv-bar) 0 auto 0; padding: var(--space-4); text-align: center; pointer-events: none; font-size: var(--fs-12); color: var(--text-muted); } .fc-rv-note:empty { display: none; } +.fc-rv-empty { position: absolute; inset: var(--rv-bar) 0 0 0; } .fc-rv-note.is-error { color: var(--danger-text); } .fc-rv-list { overflow-y: auto; min-height: 0; position: relative; } .fc-rv-btn { height: var(--rv-btn); padding: 0 var(--space-3); border: 1px solid var(--line-2); border-radius: var(--radius-sm); background: var(--surface-2); color: var(--text-primary); font: inherit; font-size: var(--fs-12); cursor: pointer; white-space: nowrap; } diff --git a/frontend/src/styles/shell.css b/frontend/src/styles/shell.css index a458b92..40fcb68 100644 --- a/frontend/src/styles/shell.css +++ b/frontend/src/styles/shell.css @@ -14,13 +14,8 @@ body { font-size: var(--fs-12); line-height: 1.35; } .fc-app > .fc-status { grid-row: 3; } .fc-app { display: grid; grid-template-rows: var(--fc-menu-row) minmax(0, 1fr) var(--fc-status-h); height: 100%; overflow: clip; background: var(--ground); color: var(--text); user-select: none; -webkit-user-select: none; } -.fc-sb-head { display: grid; grid-template-columns: 20px minmax(0, 1fr) auto var(--ctl-sm); align-items: center; column-gap: var(--space-2); height: var(--topbar-h); padding: 0 var(--space-2) 0 var(--space-4); } +.fc-sb-head { display: grid; grid-template-columns: 20px minmax(0, 1fr) auto; align-items: center; column-gap: var(--space-2); height: var(--topbar-h); padding: 0 var(--space-4); } :root[data-fc-lights="inset"][data-fc-menubar="native"] .fc-sb-head { padding-inline-start: var(--fc-traffic-w); } -.fc-sb-head > .fc-sb-live { grid-row: 1; grid-column: 3; } -.fc-tt-btn { display: inline-grid; place-items: center; width: var(--ctl-sm); height: var(--ctl-sm); padding: 0; border: 1px solid var(--line-2); border-radius: var(--radius); background: var(--surface-1); color: var(--text-secondary); cursor: pointer; } -.fc-tt-btn:hover { color: var(--text-primary); background: var(--surface-raised); } -.fc-tt-btn[aria-pressed="true"] { border-color: var(--accent-line); background: var(--accent-soft); color: var(--accent-color); } -.fc-sb-head > .fc-sb-dock { grid-row: 1; grid-column: 4; } :root[data-fc-lights="inset"][data-fc-menubar="window"] .fc-menubar-host { padding-inline-start: var(--fc-traffic-w); } .fc-sb-icon { display: block; width: 20px; height: 20px; border-radius: var(--radius-xs, 4px); } .fc-brand-name { color: var(--text); font-size: var(--text-md); font-weight: var(--weight-semibold); letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } @@ -33,24 +28,27 @@ body { font-size: var(--fs-12); line-height: 1.35; } .fc-detail { grid-column: 3; border-radius: 0 var(--radius-sheet) var(--radius-sheet) 0; } .fc-list, .fc-detail, .fc-panes > .fc-view { box-shadow: var(--shadow-sheet); overflow: clip; } .fc-panes > .fc-view, .fc-panes > .fc-conn { border-radius: var(--radius-sheet); box-shadow: var(--shadow-sheet); overflow: clip; } -.fc-topbar { grid-row: 1; grid-column: 2 / -1; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; column-gap: var(--space-3); min-width: 0; padding: 0 var(--space-1) 0 var(--space-4); } +.fc-topbar { grid-row: 1; grid-column: 2 / -1; display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; column-gap: var(--space-3); min-width: 0; padding: 0 var(--space-1) 0 var(--space-4); } .fc-tb-title { min-width: 0; color: var(--text); font-size: var(--text-md); font-weight: var(--weight-semibold); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .fc-tb-title > span { display: none; } .fc-topbar .fc-add-open { border-color: var(--accent); background: var(--accent); color: var(--on-accent); font-weight: var(--weight-medium); } .fc-topbar .fc-add-open:hover:not(:disabled) { background: var(--accent-color-hover); } +.fc-tb-icons { display: flex; align-items: center; justify-content: flex-end; gap: var(--space-1h); height: 100%; } +.fc-topbar .icon-btn { position: relative; display: inline-grid; place-items: center; inline-size: 30px; block-size: 30px; padding: 0; border: 1px solid var(--line-2); border-radius: 7px; background: var(--surface-1); color: var(--text-secondary); cursor: pointer; } +.fc-topbar .icon-btn > .ic { display: block; inline-size: var(--icon); block-size: var(--icon); flex: none; } +.fc-topbar .icon-btn:focus-visible { outline: 2px solid var(--accent-color); outline-offset: 2px; } +.fc-topbar .icon-btn[aria-pressed="true"] { border-color: var(--accent-line); background: var(--accent-soft); color: var(--accent-color); } .fc-panes[data-view="library"] .fc-tb-title > [data-v="library"], .fc-panes[data-view="duplicates"] .fc-tb-title > [data-v="duplicates"], .fc-panes[data-view="trash"] .fc-tb-title > [data-v="trash"], .fc-panes[data-view="titles"] .fc-tb-title > [data-v="titles"], -.fc-panes[data-view="connections"] .fc-tb-title > [data-v="connections"], -.fc-panes[data-view="preferences"] .fc-tb-title > [data-v="preferences"] { display: inline; } +.fc-panes[data-view="connections"] .fc-tb-title > [data-v="connections"] { display: inline; } .fc-pane-head { display: grid; grid-template-columns: var(--size-icon-sm) minmax(0, 1fr); align-items: center; column-gap: var(--space-2); padding: 0 var(--space-3); border-bottom: 1px solid var(--line-0); color: var(--text-secondary); font-size: var(--fs-12); font-weight: 600; white-space: nowrap; overflow: hidden; } .fc-pane-body { position: relative; min-height: 0; overflow: auto; } .fc-tools { display: flex; align-items: center; justify-content: flex-end; gap: var(--space-2); min-width: 0; height: 100%; } .fc-panes > .fc-view { display: none; grid-column: 2 / -1; } .fc-panes[data-view="duplicates"] > .fc-view[data-pane="duplicates"], -.fc-panes[data-view="trash"] > .fc-view[data-pane="trash"], -.fc-panes[data-view="preferences"] > .fc-view[data-pane="preferences"] { display: grid; } +.fc-panes[data-view="trash"] > .fc-view[data-pane="trash"] { display: grid; } .fc-panes:not([data-view="library"]) > .fc-list, .fc-panes:not([data-view="library"]) > .fc-detail { display: none; } .fc-st-count { flex: none; width: var(--size-st-count); margin-left: auto; text-align: right; font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; } diff --git a/frontend/src/styles/side.css b/frontend/src/styles/side.css index ea14af0..bb1835f 100644 --- a/frontend/src/styles/side.css +++ b/frontend/src/styles/side.css @@ -11,7 +11,34 @@ .fc-sb-dot[data-state="down"] { background: var(--danger); } .fc-side-list { list-style: none; margin: 0; padding: 0; } -.fc-side-tags { max-height: calc(var(--fc-side-row-h) * 12); overflow-y: auto; overscroll-behavior: contain; } +.fc-side > .fc-pane-body { display: flex; flex-direction: column; overflow: hidden; } +.fc-side > .fc-pane-body > .fc-nav { flex: none; } +.fc-side-pane { flex: 1 1 auto; display: flex; flex-direction: column; min-height: 0; } +.fc-side-pane > .fc-section { flex: none; display: grid; grid-template-rows: var(--fc-section-head-h) minmax(0, 1fr); min-height: calc(var(--fc-section-head-h) + var(--fc-side-row-h) * 3); max-height: calc(var(--fc-section-head-h) + var(--fc-side-row-h) * 6 + var(--space-1)); padding-bottom: var(--space-1); } +.fc-side-pane > .fc-section + .fc-section { border-top: 1px solid var(--line-0); } +.fc-side-pane > .fc-section.is-shut { flex: none; grid-template-rows: var(--fc-section-head-h); min-height: 0; padding-bottom: 0; } +.fc-side-pane > .fc-section.is-shut > .fc-side-scroll { display: none; } +.fc-side-scroll { min-height: 0; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; } +.fc-side-pane .fc-section-head { display: block; margin: 0; padding: 0 var(--space-2); } +.fc-section-toggle { display: grid; grid-template-columns: var(--size-icon-sm) var(--size-icon-sm) minmax(0, 1fr); align-items: center; column-gap: var(--space-1h); width: 100%; height: 100%; padding: 0 var(--space-1); border: 0; border-radius: var(--radius-sm); background: transparent; color: inherit; font: inherit; letter-spacing: inherit; text-transform: inherit; text-align: start; cursor: pointer; } +.fc-section-toggle:hover { color: var(--text-secondary); } +.fc-section-chevron { width: var(--size-icon-sm); height: var(--size-icon-sm); transition: transform var(--transition-fast); } +.fc-section-toggle[aria-expanded="false"] .fc-section-chevron { transform: rotate(-90deg); } +.fc-side-scroll > .fc-side-msg { padding: 0 var(--space-3) 0 calc(var(--space-3) + var(--size-icon-sm) + var(--space-2)); } + +.fc-side-pane { --fc-side-chip-h: 24px; --fc-side-chip-count: 30px; } +.fc-side-tags { position: relative; display: flex; flex-wrap: wrap; align-content: flex-start; gap: var(--space-1); padding: var(--space-1) var(--space-3); } +.fc-side-tags > .fc-side-row { position: static; contain: none; max-width: 100%; height: var(--fc-side-chip-h); line-height: var(--fc-side-chip-h); } +.fc-side-tags .fc-side-entry { display: inline-grid; grid-template-columns: minmax(0, auto) var(--fc-side-chip-count); column-gap: var(--space-1); width: auto; max-width: 100%; height: var(--fc-side-chip-h); padding: 0 0 0 var(--space-2); border: 1px solid var(--line-2); border-radius: var(--radius-pill); background: var(--surface-2); line-height: normal; vertical-align: top; } +.fc-side-tags .fc-side-entry > .fc-side-icon { display: none; } +.fc-side-tags .fc-side-count { padding-right: var(--space-2); } +.fc-side-tags .fc-side-row:hover > .fc-side-entry { border-color: var(--line-3); background: var(--surface-2); } +.fc-side-tags .fc-side-row.is-active > .fc-side-entry { border-color: var(--accent-line); background: var(--accent-soft); box-shadow: none; } +.fc-side-tags .fc-side-row.is-active > .fc-side-actions { background: var(--accent-soft); } +.fc-side-tags .fc-side-actions { display: inline-grid; top: auto; bottom: auto; right: auto; width: var(--fc-side-chip-count); height: calc(var(--fc-side-chip-h) - 2px); margin: 1px 0 0 calc(-1 * var(--fc-side-chip-count) - 1px); border-radius: 0 var(--radius-pill) var(--radius-pill) 0; background: var(--surface-2); vertical-align: top; } +.fc-side-tags .fc-side-act { height: calc(var(--fc-side-chip-h) - 4px); } +.fc-side-tags .fc-side-act .fc-side-icon { width: 11px; height: 11px; } +.fc-side-tags .fc-side-edit { top: auto; bottom: auto; left: var(--space-3); right: var(--space-3); height: var(--fc-side-chip-h); box-sizing: border-box; vertical-align: top; } .fc-side-row.is-pending { pointer-events: none; } .fc-side-row { diff --git a/frontend/src/ui/app.ts b/frontend/src/ui/app.ts index 8292037..d2bef01 100644 --- a/frontend/src/ui/app.ts +++ b/frontend/src/ui/app.ts @@ -7,7 +7,8 @@ import { el, mountOnce, q, revealApp, setClass } from './dom'; import { mountDuplicates } from './duplicates'; import { icon } from './icons'; import { mountItemList } from './itemlist'; -import { mountPreferences } from './preferences'; +import { mountPreferences, openPreferences } from './preferences'; +import { DETAIL_START } from './start'; import { mountSide } from './side'; import { mountTrash } from './trash'; import { mountTitles } from './titles'; @@ -26,7 +27,7 @@ const SHELL = `

-
-

HomeItemsDuplicatesTrashNeeds a titleConnectionsPreferences

-
+
+

HomeItemsDuplicatesTrashNeeds a titleConnections

+
+
+ + +

${icon('viewList', 14)}Items

@@ -51,7 +56,7 @@ const SHELL = `
${CONNECTIONS_PANE}

${icon('duplicates', 14)}Duplicates

@@ -69,10 +74,6 @@ const SHELL = `

${HOME_ICON}Home

-
-

${icon('sliders', 14)}Preferences

-
-
`); } +const DT_TABS: Array<[string, string]> = [['info', 'Info'], ['abstract', 'Abstract'], ['tags', 'Tags'], ['files', 'Files'], ['notes', 'Notes']]; + const SHELL = `
+ +
-
-
-

Tags

+
${DT_TABS.map(([id, label], i) => ``).join('')}
+
+ + -
+ -
+

+ ${reviewStart('duplicates', 'No duplicates found', 'Items that share a DOI, or a title, year and first creator, show here side by side, so you can keep one and merge the rest into it.', OPEN_ITEMS)} `; function memberNode(m: DupMember, name: string): HTMLElement { @@ -42,6 +44,7 @@ export function mountDuplicates(engine: Engine, host: HTMLElement): void { const list = q(root, '[data-list="groups"]'); const summary = q(root, '.fc-rv-summary'); const note = q(root, '.fc-rv-note'); + const none = q(root, '.fc-rv-empty'); const keeps = new Map(); let groups: Group[] = []; let loadedOnce = false; @@ -86,7 +89,8 @@ export function mountDuplicates(engine: Engine, host: HTMLElement): void { const paint = (): void => { setText(summary, groups.length ? plural(groups.length, 'set of duplicates', 'sets of duplicates') : 'No duplicates found'); const quiet = !!list.querySelector('.is-gone'); - showNote(groups.length || quiet || !loadedOnce ? '' : 'Nothing here. Items that share a DOI, or a title, year and first creator, would be listed.'); + showNote(''); + setHidden(none, groups.length > 0 || quiet || !loadedOnce); }; const render = (): void => { diff --git a/frontend/src/ui/itemlist.ts b/frontend/src/ui/itemlist.ts index 56e757d..263abd1 100644 --- a/frontend/src/ui/itemlist.ts +++ b/frontend/src/ui/itemlist.ts @@ -3,6 +3,7 @@ import type { SortKey } from '../engine/library'; import { ItemListModel, PAGE } from '../engine/itemlist'; import type { Row } from '../io/itemlist'; import { delayedIndicator, el, q, setClass, setHidden, setText, type Disposer } from './dom'; +import { bindStart, listStart, markList } from './start'; const ROW_H = 28; const OVERSCAN = 6; @@ -61,7 +62,9 @@ export function mountItemList(engine: Engine, host: HTMLElement): void { const busy = q(root, '.fc-il-busy'); const errorLine = q(root, '.fc-il-error'); const heads = Array.from(root.querySelectorAll('.fc-il-col')); - const empty = host.querySelector('.fc-empty'); + const placeholder = host.querySelector('.fc-empty'); + const empty = listStart(); + const panes = host.closest('.fc-panes'); const status = document.querySelector('.fc-st-count'); const poolSize = Math.ceil(Math.max(window.screen.height, 1200) / ROW_H) + OVERSCAN * 2; @@ -72,7 +75,9 @@ export function mountItemList(engine: Engine, host: HTMLElement): void { spacer.append(r); } host.append(root); - if (empty) { empty.classList.add('fc-il-empty'); setHidden(empty, true); scroll.append(empty); } + placeholder?.remove(); + scroll.append(empty); + bindStart(engine, panes ?? host); let stopBusy: Disposer | null = null; let frame = 0; @@ -82,10 +87,10 @@ export function mountItemList(engine: Engine, host: HTMLElement): void { reset(total) { spacer.style.height = `${total * ROW_H}px`; if (scroll.scrollTop > Math.max(0, total * ROW_H - scroll.clientHeight)) scroll.scrollTop = 0; - if (empty) { - setText(empty, lib.query ? 'No items match this search.' : 'No items here yet.'); - setHidden(empty, total > 0); - } + markList(empty, lib.query ? 'search' : lib.scope.kind === 'all' ? 'library' : 'scope'); + setHidden(empty, total > 0); + const shown = total === 0 && !lib.query ? 'empty' : 'some'; + if (panes && panes.dataset.fcList !== shown) panes.dataset.fcList = shown; setText(status, `${total.toLocaleString('en-US')} ${total === 1 ? 'item' : 'items'}`); setText(errorLine, ''); paint(); diff --git a/frontend/src/ui/menus.ts b/frontend/src/ui/menus.ts index 72c2644..6cecd96 100644 --- a/frontend/src/ui/menus.ts +++ b/frontend/src/ui/menus.ts @@ -109,7 +109,7 @@ function makeSource(run: (id: string) => void, isEnabled?: (id: string) => boole has: (id) => id in ENTRIES && (BUILT_IN[id] ? BUILT_IN[id].has() : id === 'view.menus-in-window' ? isMacShell() : true), label: (id) => ENTRIES[id]?.label ?? id, keys: (id) => ENTRIES[id]?.keys, - enabled: (id) => { const b = BUILT_IN[id]; if (b) return b.enabled ? b.enabled() : true; return isEnabled ? isEnabled(id) : true; }, + enabled: (id) => { const b = BUILT_IN[id]; if (b) return b.enabled ? b.enabled() : true; if ((ITEM_COMMANDS as readonly string[]).includes(id) && !bound?.library.selected) return false; return isEnabled ? isEnabled(id) : true; }, checked: (id) => (id === 'view.menus-in-window' ? menusInWindow() : BUILT_IN[id]?.checked?.()), run: (id) => { const b = BUILT_IN[id]; if (b) b.run(); else run(id); }, }; @@ -153,7 +153,8 @@ export function mountMenus(host: HTMLElement, run: (id: string) => void, isEnabl const src = makeSource(run, isEnabled); if (wantsNativeMenus()) { const native = new NativeMenus(src, () => MENUS, APP_MENU); - void native.build().catch(() => { document.documentElement.dataset.fcMenubar = 'window'; new MenuBar(host, src, IN_WINDOW); bindKeys(src); }); + void native.build().catch((e: unknown) => { console.error('[menus] the macOS menu bar could not be built:', e); bindKeys(src); }); + bound?.library.events.on('selected', () => native.refresh()); return; } new MenuBar(host, src, IN_WINDOW.filter((def) => (typeof def.items === 'function' ? def.items() : def.items).some((i) => i !== '-' && (typeof i !== 'string' || src.has(i))))); diff --git a/frontend/src/ui/native-menu.ts b/frontend/src/ui/native-menu.ts index 289f1f5..d885350 100644 --- a/frontend/src/ui/native-menu.ts +++ b/frontend/src/ui/native-menu.ts @@ -48,7 +48,8 @@ export class NativeMenus { try { const api: Api = await import('@tauri-apps/api/menu'); const items: typeof this.items = []; - const make = async (spec: MenuItem): Promise => { + const make = (spec: MenuItem): Promise => create(spec).catch((e: unknown) => { console.error('[menus] left out of the menu bar:', typeof spec === 'object' ? spec.label : spec, e); return null; }); + const create = async (spec: MenuItem): Promise => { if (spec === '-') return api.PredefinedMenuItem.new({ item: 'Separator' }); if (typeof spec === 'object') return api.Submenu.new({ text: spec.label, items: (await Promise.all(spec.items.map(make))).filter(Boolean) as never[] }); const pre = PREDEFINED[spec]; @@ -67,19 +68,20 @@ export class NativeMenus { items.push({ id: spec, item }); return item; }; - const app = await api.Submenu.new({ text: 'FormCite', items: [ - await api.PredefinedMenuItem.new({ item: { About: { name: 'FormCite', version: VERSION, copyright: 'Copyright (C) 2026 NodeAgentc, Inc.', license: 'GPL-3.0-only' } }, text: 'About FormCite' }), - await api.PredefinedMenuItem.new({ item: 'Separator' }), - ...((await Promise.all(this.appMenu.map(make))).filter(Boolean)), - await api.PredefinedMenuItem.new({ item: 'Separator' }), - await api.PredefinedMenuItem.new({ item: 'Services' }), - await api.PredefinedMenuItem.new({ item: 'Separator' }), - await api.PredefinedMenuItem.new({ item: 'Hide' }), - await api.PredefinedMenuItem.new({ item: 'HideOthers' }), - await api.PredefinedMenuItem.new({ item: 'ShowAll' }), - await api.PredefinedMenuItem.new({ item: 'Separator' }), - await api.PredefinedMenuItem.new({ item: 'Quit' }), - ] as never[] }); + const fixed = (opts: Parameters[0]): Promise => api.PredefinedMenuItem.new(opts).catch((e: unknown) => { console.error('[menus] left out of the menu bar:', opts?.item, e); return null; }); + const app = await api.Submenu.new({ text: 'FormCite', items: (await Promise.all([ + fixed({ item: { About: { name: 'FormCite', version: VERSION, copyright: 'Copyright (C) 2026 NodeAgentc, Inc.', license: 'GPL-3.0-only' } }, text: 'About FormCite' }), + fixed({ item: 'Separator' }), + ...this.appMenu.map(make), + fixed({ item: 'Separator' }), + fixed({ item: 'Services' }), + fixed({ item: 'Separator' }), + fixed({ item: 'Hide' }), + fixed({ item: 'HideOthers' }), + fixed({ item: 'ShowAll' }), + fixed({ item: 'Separator' }), + fixed({ item: 'Quit' }), + ])).filter(Boolean) as never[] }); const top: unknown[] = [app]; for (const def of this.menus()) { const list = typeof def.items === 'function' ? def.items() : def.items; diff --git a/frontend/src/ui/preferences.ts b/frontend/src/ui/preferences.ts index 75c3d9f..143e8ee 100644 --- a/frontend/src/ui/preferences.ts +++ b/frontend/src/ui/preferences.ts @@ -4,7 +4,7 @@ import { type ShellPref, } from '../engine/preferences'; import type { LibraryInfo, NetOverview, NetService } from '../io/preferences'; -import { delayedIndicator, el, escapeHtml, isMac, mountOnce, patchList, q, setChecked, setClass, setDisabled, setHidden, setText, setTitle, setValue } from './dom'; +import { delayedIndicator, el, escapeHtml, isMac, patchList, q, setChecked, setClass, setDisabled, setHidden, setText, setTitle, setValue } from './dom'; import { icon } from './icons'; import { loadWindowKey } from '../io/window-key'; import { mountDetailPrefs } from './pref-detail'; @@ -30,6 +30,8 @@ const RAIL_ICONS: Record = { menus: ``, agents: ``, }; +const FOLD_ICON = ``; +const RAIL_KEY = 'formcite.prefsRailCollapsed'; const railIcon = (id: string, size: number): string => (RAIL_ICONS[id] ? `` : icon(id === 'appearance' ? 'sliders' : id === 'network' ? 'link' : 'library', size)); interface PrSection { id: string; label: string; body: string } @@ -74,16 +76,19 @@ function shell(withMenus: boolean): string {
Menus in WindowTakes effect at the next start.
${SWITCH}

Off puts FormCite's menus in the macOS menu bar at the top of the screen. On keeps them in a bar inside the window, as on Linux and Windows.

`) }] : []), { id: 'agents', label: 'Agents', body: group('Dock', ` -
Show the agent dockAlso the Agents button at the top left, View, Agent Dock, or ${isMac ? 'Cmd' : 'Ctrl'}+J.
${SWITCH}
+
Show the agent dockAlso the agent button at the top right, View, Agent Dock, or ${isMac ? 'Cmd' : 'Ctrl'}+J.
${SWITCH}

The dock holds the agent terminals beside your library. Apps that ask to use the library are answered under Connections.

`) }, ]; - const tabs = sections.map((s) => ``).join(''); + const tabs = sections.map((s) => ``).join(''); return ` -
-
-
-
${icon('settings', 16)}

Preferences

-
${sections.map(section).join('')}
+`; } @@ -101,11 +106,74 @@ function libRow(l: LibraryInfo): HTMLElement { return row; } -function mountRail(root: HTMLElement): void { - const tabs = Array.from(root.querySelectorAll('.fc-pr-railtab')); - const secs = Array.from(root.querySelectorAll('.fc-pr-sec')); - const pages = q(root, '.fc-pr-pages'); +export interface PrefsDialog { + open(section?: string): void; + close(): void; + isOpen(): boolean; +} + +let dialog: PrefsDialog | null = null; + +export function openPreferences(section?: string): void { + dialog?.open(section); +} + +function pressOpeners(on: boolean): void { + for (const b of document.querySelectorAll('[data-prefs-open]')) if (b.getAttribute('aria-expanded') !== String(on)) b.setAttribute('aria-expanded', String(on)); +} + +function mountDialog(scrim: HTMLElement, onOpen: () => void): PrefsDialog { + const frame = q(scrim, '.cv-prefs-dlg'); + const rail = q(frame, '.cv-prefs-rail'); + const nav = q(frame, '.cv-prefs-nav'); + const head = q(frame, '.cv-prefs-head'); + const pages = q(frame, '.cv-prefs-pages'); + const fold = q(frame, '.cv-prefs-fold'); + const port = q(frame, '.cv-prefs-port'); + const shade = q(frame, '.cv-prefs-wire-shade'); + const line = q(frame, '.cv-prefs-wire-line'); + const tabs = Array.from(nav.querySelectorAll('.cv-prefs-railtab')); + const secs = Array.from(frame.querySelectorAll('.fc-pr-sec')); let shown = ''; + let wireRaf = 0; + let wireD = ''; + let portY = -1; + let lastFocus: HTMLElement | null = null; + const closing = (): boolean => scrim.classList.contains('is-closing'); + const isOpen = (): boolean => !scrim.hidden && !closing(); + + const drawWire = (): void => { + if (scrim.hidden) return; + const F = frame.getBoundingClientRect(); + const tab = tabs.find((t) => t.dataset.go === shown); + if (!F.width || !tab) return; + const N = nav.getBoundingClientRect(); + let T = tab.getBoundingClientRect(); + if (T.top < N.top || T.bottom > N.bottom) { + nav.scrollTop += T.top < N.top ? T.top - N.top - 6 : T.bottom - N.bottom + 6; + T = tab.getBoundingClientRect(); + } + const R = rail.getBoundingClientRect(); + const H = head.getBoundingClientRect(); + const toY = Math.round(H.bottom - F.top); + const fromX = Math.round(T.right - F.left); + const fromY = Math.round(T.top - F.top + T.height / 2); + const edge = R.right - F.left; + const trunk = Math.round(edge - edge * 0.45); + const dy = toY - fromY; + const r = 10; + const dir = dy > 0 ? 1 : -1; + const d = Math.abs(dy) < 2 * r + ? `M ${fromX} ${fromY} H ${trunk} V ${toY} H -7` + : `M ${fromX} ${fromY} H ${trunk - r} a ${r} ${r} 0 0 ${dir > 0 ? 1 : 0} ${r} ${dir * r} V ${toY - dir * r} a ${r} ${r} 0 0 ${dir > 0 ? 0 : 1} ${r} ${dir * r} H -7`; + if (d !== wireD) { wireD = d; shade.setAttribute('d', d); line.setAttribute('d', d); } + if (toY !== portY) { portY = toY; port.style.transform = `translateY(${toY}px)`; } + }; + const queueWire = (): void => { + if (wireRaf) return; + wireRaf = requestAnimationFrame(() => { wireRaf = 0; drawWire(); }); + }; + const show = (id: string): void => { if (id === shown || !secs.some((s) => s.dataset.sec === id)) return; shown = id; @@ -118,12 +186,13 @@ function mountRail(root: HTMLElement): void { } for (const s of secs) setHidden(s, s.dataset.sec !== id); if (pages.scrollTop !== 0) pages.scrollTop = 0; + queueWire(); }; - root.addEventListener('click', (ev) => { - const tab = ev.target instanceof Element ? ev.target.closest('.fc-pr-railtab') : null; + nav.addEventListener('click', (ev) => { + const tab = ev.target instanceof Element ? ev.target.closest('.cv-prefs-railtab') : null; if (tab?.dataset.go) show(tab.dataset.go); }); - q(root, '.fc-pr-nav').addEventListener('keydown', (ev) => { + nav.addEventListener('keydown', (ev) => { const at = tabs.findIndex((t) => t.dataset.go === shown); const next = ev.key === 'ArrowDown' ? at + 1 : ev.key === 'ArrowUp' ? at - 1 : ev.key === 'Home' ? 0 : ev.key === 'End' ? tabs.length - 1 : null; if (next === null) return; @@ -132,7 +201,72 @@ function mountRail(root: HTMLElement): void { show(tab.dataset.go ?? ''); tab.focus(); }); + + let collapsed = false; + try { collapsed = localStorage.getItem(RAIL_KEY) === '1'; } catch { collapsed = false; } + const paintRail = (): void => { + setClass(frame, 'is-rail-collapsed', collapsed); + const label = collapsed ? 'Expand tabs' : 'Collapse tabs'; + setTitle(fold, label); + if (fold.getAttribute('aria-label') !== label) fold.setAttribute('aria-label', label); + if (fold.getAttribute('aria-expanded') !== String(!collapsed)) fold.setAttribute('aria-expanded', String(!collapsed)); + }; + fold.addEventListener('click', () => { + collapsed = !collapsed; + try { localStorage.setItem(RAIL_KEY, collapsed ? '1' : '0'); } catch (e) { console.error('[prefs] rail save failed:', e); } + paintRail(); + queueWire(); + }); + paintRail(); + + const focusables = (): HTMLElement[] => Array.from(frame.querySelectorAll('button, input, select, textarea, [tabindex]')) + .filter((n) => n.tabIndex >= 0 && !(n as HTMLButtonElement).disabled && n.getClientRects().length > 0); + const finish = (): void => { setClass(scrim, 'is-closing', false); setHidden(scrim, true); }; + const close = (): void => { + if (!isOpen()) return; + setClass(scrim, 'is-closing', true); + pressOpeners(false); + const back = lastFocus; + lastFocus = null; + if (scrim.contains(document.activeElement)) (document.activeElement as HTMLElement).blur(); + if (back?.isConnected) back.focus({ preventScroll: true }); + if (scrim.getAnimations().length === 0) finish(); + }; + const open = (section?: string): void => { + if (section) show(section); + if (isOpen()) { queueWire(); return; } + if (closing()) setClass(scrim, 'is-closing', false); + else lastFocus = document.activeElement instanceof HTMLElement ? document.activeElement : null; + setHidden(scrim, false); + pressOpeners(true); + onOpen(); + (tabs.find((t) => t.dataset.go === shown) ?? frame).focus({ preventScroll: true }); + queueWire(); + }; + + scrim.addEventListener('animationend', (ev) => { if (ev.target === scrim && closing()) finish(); }); + scrim.addEventListener('pointerdown', (ev) => { if (ev.target === scrim) close(); }); + scrim.addEventListener('keydown', (ev) => { + ev.stopPropagation(); + if (ev.key === 'Escape') { ev.preventDefault(); close(); return; } + if (ev.key !== 'Tab' || ev.altKey || ev.ctrlKey || ev.metaKey) return; + const list = focusables(); + const first = list[0]; + const last = list[list.length - 1]; + const at = document.activeElement; + if (!first || !last) { ev.preventDefault(); frame.focus(); return; } + if (ev.shiftKey && (at === first || at === frame || !frame.contains(at))) { ev.preventDefault(); last.focus(); } + else if (!ev.shiftKey && (at === last || !frame.contains(at))) { ev.preventDefault(); first.focus(); } + }); + document.addEventListener('focusin', (ev) => { + if (isOpen() && ev.target instanceof Node && !scrim.contains(ev.target)) frame.focus({ preventScroll: true }); + }); + q(frame, '[data-act="close"]').addEventListener('click', close); + q(frame, '[data-act="done"]').addEventListener('click', close); + new ResizeObserver(queueWire).observe(frame); + window.addEventListener('resize', queueWire); show(secs[0]?.dataset.sec ?? ''); + return { open, close, isOpen }; } function mountShellSwitches(root: HTMLElement): void { @@ -149,10 +283,16 @@ function mountShellSwitches(root: HTMLElement): void { onShellPref((pref, on) => { const box = boxes.get(pref); if (box) setChecked(box, on); }); } -export function mountPreferences(engine: Engine, host: HTMLElement): void { - mountOnce(host, shell(desktopMac())); - const root = q(host, '.fc-pr'); - mountRail(root); +export function mountPreferences(engine: Engine): void { + if (dialog) return; + const scrim = el(shell(desktopMac())); + (document.getElementById('overlay-root') ?? document.body).append(scrim); + const root = q(scrim, '.fc-pr'); + dialog = mountDialog(scrim, () => { + showAppearance(); + void loadNetwork(); + void loadLibraries(); + }); mountShellSwitches(root); mountDetailPrefs(q(root, '.fc-pref-slot[data-slot="detail"]'), engine); const theme = q(root, '#fc-pr-theme'); @@ -377,11 +517,5 @@ export function mountPreferences(engine: Engine, host: HTMLElement): void { }); engine.events.on('theme:changed', (id) => showAppearance(id)); - engine.library.events.on('view', (view) => { - if (view !== 'preferences') return; - showAppearance(); - void loadNetwork(); - void loadLibraries(); - }); showAppearance(); } diff --git a/frontend/src/ui/side.ts b/frontend/src/ui/side.ts index b3ec3a0..17bb5cc 100644 --- a/frontend/src/ui/side.ts +++ b/frontend/src/ui/side.ts @@ -16,6 +16,42 @@ const SIDE_ICONS: Record = { tag: ``, }; +const OPEN_KEY = 'formcite.side.open'; +const CHEVRON = ``; + +function readOpen(): Record { + try { + const v = JSON.parse(localStorage.getItem(OPEN_KEY) || 'null') as unknown; + return v && typeof v === 'object' ? (v as Record) : {}; + } catch { return {}; } +} + +function saveOpen(id: string, open: boolean): void { + try { localStorage.setItem(OPEN_KEY, JSON.stringify({ ...readOpen(), [id]: open })); } catch (e) { console.error('[side] save failed:', e); } +} + +function foldable(sec: HTMLElement): void { + const id = sec.dataset.section ?? ''; + const head = q(sec, '.fc-section-head'); + const body = el(`
`); + body.append(...Array.from(sec.children).filter((c) => c !== head)); + sec.append(body); + const open = readOpen()[id] !== false; + const btn = el(``); + btn.append(...Array.from(head.childNodes)); + head.append(btn); + setClass(sec, 'is-shut', !open); +} + +function toggleSection(btn: HTMLElement): void { + const sec = btn.closest('.fc-section'); + if (!sec) return; + const open = btn.getAttribute('aria-expanded') !== 'true'; + btn.setAttribute('aria-expanded', String(open)); + setClass(sec, 'is-shut', !open); + saveOpen(sec.dataset.section ?? '', open); +} + function sideIcon(name: string): string { return ``; } @@ -452,12 +488,16 @@ export function mountSide(engine: Engine, host: HTMLElement): void { setText(tagMsg, ''); const tags = el('
    '); tagMsg.before(tags); + foldable(collSec); + foldable(tagSec); const pane: Pane = { engine, fixed, tree, collMsg, tags, tagMsg, collapsed: new Set(), want: { coll: 0, tags: 0 }, pending: new Map() }; tree.addEventListener('keydown', (ev) => treeKey(pane, ev)); host.addEventListener('click', (ev) => { const target = ev.target as HTMLElement; + const fold = target.closest('.fc-section-toggle'); + if (fold) { toggleSection(fold); return; } const act = target.closest('.fc-side-act'); const actRow = act?.closest('.fc-side-row'); if (act && actRow) { diff --git a/frontend/src/ui/start.ts b/frontend/src/ui/start.ts new file mode 100644 index 0000000..9eeba59 --- /dev/null +++ b/frontend/src/ui/start.ts @@ -0,0 +1,103 @@ +import type { Engine } from '../engine'; +import { Adding } from '../engine/add'; +import { el } from './dom'; +import { icon } from './icons'; +import { toast } from './toast'; + +const S = 'viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"'; +const glyph = (size: number, paths: string): string => ``; +const INBOX = glyph(22, ''); +const SEARCH = glyph(22, ''); +const PLUS = glyph(14, ''); +const UPLOAD = glyph(14, ''); +const PDF = glyph(14, ''); + +const ACTIONS = `
    + + + +
    +

    Paste an arXiv id such as arXiv:2402.06196, a DOI, an ISBN or a PubMed ID.

    `; + +const say = (key: string, title: string, sub: string): string => `

    ${title}

    ${sub}

    `; + +export const DETAIL_START = `
    +
    + ${icon('panelRight', 22)} +
    + ${say('pick', 'No item selected', 'Select an item in the list to see its abstract, identifiers and files here. The arrow keys move through the list.')} + ${say('wait', 'Details show here', 'Once the list has items, the one you select opens here with its abstract, identifiers, files and notes.')} +
    +
    +
    ${ACTIONS}
    +
    +
    arXiv
    arXiv:2402.06196, the bare id or an arxiv.org link
    +
    DOI
    10. and the rest, or a doi.org link
    +
    ISBN
    10 or 13 digits, with or without hyphens
    +
    PubMed
    a PMID or a PubMed link
    +
    Files
    BibTeX, RIS, CSL-JSON and PDF
    +
    +
    +
    +
    `; + +const LIST_START = ``; + +export function reviewStart(glyphName: string, title: string, sub: string, actions: string): string { + return ``; +} + +export const OPEN_ITEMS = ''; +export const IMPORT_FILE = ``; + +export type ListKind = 'library' | 'scope' | 'search'; + +export function listStart(): HTMLElement { + return el(LIST_START); +} + +export function markList(node: HTMLElement, kind: ListKind): void { + if (node.dataset.kind !== kind) node.dataset.kind = kind; +} + +export function bindStart(engine: Engine, scope: HTMLElement): void { + const adding = new Adding(engine.library); + const openAdd = (tab: 'id' | 'import'): void => { + document.querySelector(`.fc-add-tab[data-tab="${tab}"]`)?.click(); + document.querySelector('.fc-add-open')?.click(); + }; + scope.addEventListener('click', (e) => { + const a = (e.target as Element).closest('.fc-start [data-start]')?.dataset.start; + if (a === 'add') openAdd('id'); + else if (a === 'import') openAdd('import'); + else if (a === 'items') document.querySelector('.fc-nav-item[data-view="library"]')?.click(); + }); + scope.addEventListener('change', (e) => { + const pick = e.target instanceof HTMLInputElement && e.target.closest('.fc-start-pick') ? e.target : null; + if (!pick) return; + const files = Array.from(pick.files ?? []); + pick.value = ''; + void (async () => { + for (const f of files) { + const r = await adding.identify(f); + toast(`${f.name}: ${r.text}`, r.ok ? 'info' : 'error'); + } + })(); + }); +} diff --git a/frontend/src/ui/titles.ts b/frontend/src/ui/titles.ts index 67cfea9..a8a634f 100644 --- a/frontend/src/ui/titles.ts +++ b/frontend/src/ui/titles.ts @@ -4,6 +4,7 @@ import { checkTitle, knownLine, MAX_SUGGESTIONS, TitleQueue } from '../engine/ti import { titlesApi, type Suggestion, type UntitledItem } from '../io/titles'; import { icon } from './icons'; import { el, patchList, q, setClass, setHidden, setText, setTitle } from './dom'; +import { IMPORT_FILE, OPEN_ITEMS, reviewStart } from './start'; import { toast } from './toast'; const VIEW = 'titles' as ViewId; @@ -14,6 +15,7 @@ const SHELL = `

    + ${reviewStart('info', 'Every entry has a title', 'Imported entries that arrive without a title wait here, with suggestions, until you give them one.', IMPORT_FILE + OPEN_ITEMS)}
    `; function rowNode(item: UntitledItem): HTMLElement { @@ -54,6 +56,7 @@ export function mountTitles(engine: Engine, host: HTMLElement): void { const list = q(root, '[data-list="titles"]'); const summary = q(root, '.fc-rv-summary'); const note = q(root, '.fc-rv-note'); + const none = q(root, '.fc-rv-empty'); const queue = new TitleQueue(); const panes = host.closest('.fc-panes'); const trashNav = document.querySelector('.fc-nav-item[data-view="trash"]'); @@ -85,7 +88,7 @@ export function mountTitles(engine: Engine, host: HTMLElement): void { update: fillRow, }); setText(summary, queue.count ? `${plural(queue.count, 'entry needs a title', 'entries need a title')}. Type one or pick a suggestion, then press Enter.` : 'Every entry has a title'); - if (!items.length && loadedOnce) showNote('Nothing here. Imported entries without a title wait here until you give them one.'); + setHidden(none, items.length > 0 || !loadedOnce); }; const load = async (): Promise => { diff --git a/frontend/src/ui/traffic-lights.ts b/frontend/src/ui/traffic-lights.ts index cf2cedc..1f56728 100644 --- a/frontend/src/ui/traffic-lights.ts +++ b/frontend/src/ui/traffic-lights.ts @@ -16,4 +16,5 @@ export function watchTrafficLights(): void { .catch(() => undefined); }; window.addEventListener('resize', check, { passive: true }); + check(); } diff --git a/frontend/src/ui/trash.ts b/frontend/src/ui/trash.ts index 669a6a0..5f43576 100644 --- a/frontend/src/ui/trash.ts +++ b/frontend/src/ui/trash.ts @@ -3,6 +3,7 @@ import { plural } from '../engine/review'; import { emptyTrash, loadTrash, purgeItem, restoreItem, type TrashedItem } from '../io/review'; import { detailApi } from '../io/detail'; import { delayedIndicator, el, patchList, q, setClass, setDisabled, setHidden, setText } from './dom'; +import { OPEN_ITEMS, reviewStart } from './start'; import { toast } from './toast'; const SHELL = ` @@ -17,6 +18,7 @@ const SHELL = `

    + ${reviewStart('trash', 'The trash is empty', 'Items you move to the trash wait here until you restore them or delete them for good.', OPEN_ITEMS)} `; function rowNode(item: TrashedItem): HTMLElement { @@ -55,6 +57,7 @@ export function mountTrash(engine: Engine, host: HTMLElement): void { const list = q(root, '[data-list="trash"]'); const summary = q(root, '.fc-rv-summary'); const note = q(root, '.fc-rv-note'); + const none = q(root, '.fc-rv-empty'); const emptyBtn = q(root, '[data-act="empty"]'); const yes = q(root, '[data-act="empty-yes"]'); const no = q(root, '[data-act="empty-no"]'); @@ -78,7 +81,8 @@ export function mountTrash(engine: Engine, host: HTMLElement): void { emptyBtn.disabled = items.length === 0; if (!items.length) askEmpty(false); const quiet = !!list.querySelector('.is-gone'); - showNote(items.length || quiet ? '' : (loadedOnce ? 'Nothing here. Items you move to the trash wait here until you delete them for good.' : '')); + showNote(''); + setHidden(none, items.length > 0 || quiet || !loadedOnce); }; const render = (): void => { diff --git a/frontend/src/version.ts b/frontend/src/version.ts index 4763743..7d28ef8 100644 --- a/frontend/src/version.ts +++ b/frontend/src/version.ts @@ -1 +1 @@ -export const VERSION = '0.15.1'; +export const VERSION = '0.15.2'; diff --git a/native/formcite-style/Cargo.lock b/native/formcite-style/Cargo.lock index 52936fb..f8eff85 100644 --- a/native/formcite-style/Cargo.lock +++ b/native/formcite-style/Cargo.lock @@ -81,7 +81,7 @@ dependencies = [ [[package]] name = "formcite-style" -version = "0.15.1" +version = "0.15.2" dependencies = [ "hayagriva", "pyo3", diff --git a/native/formcite-style/Cargo.toml b/native/formcite-style/Cargo.toml index 1889fb1..3526b56 100644 --- a/native/formcite-style/Cargo.toml +++ b/native/formcite-style/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "formcite-style" -version = "0.15.1" +version = "0.15.2" edition = "2024" rust-version = "1.95" license = "Apache-2.0" diff --git a/native/formcite-style/pyproject.toml b/native/formcite-style/pyproject.toml index 86d914c..56f6fbc 100644 --- a/native/formcite-style/pyproject.toml +++ b/native/formcite-style/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "maturin" [project] name = "formcite-style" -version = "0.15.1" +version = "0.15.2" description = "FormCite citation style engine for the FormCite engine service" license = { text = "Apache-2.0" } requires-python = ">=3.10" diff --git a/setup/HASHOUT_LOG.md b/setup/HASHOUT_LOG.md index b8d003a..0f5280c 100644 --- a/setup/HASHOUT_LOG.md +++ b/setup/HASHOUT_LOG.md @@ -2,7 +2,7 @@ Living log of all comment content, explainers, rationale, TODOs, and removed code for the root launcher scripts and the `setup/` suite. The scripts stay comment-free; everything they would have said lives here, indexed. Read this first, then edit the scripts surgically. -Current build version: v0.15.1 +Current build version: v0.15.2 Last updated: 2026-11-27 · initial port of the launcher and setup suite --- diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index 39e55e3..e7ac005 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -918,7 +918,7 @@ dependencies = [ [[package]] name = "formcite" -version = "0.15.1" +version = "0.15.2" dependencies = [ "fontdb", "objc2", diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index ca295fe..df9212d 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "formcite" -version = "0.15.1" +version = "0.15.2" description = "FormCite desktop shell" authors = ["NodeAgentc, Inc."] license = "GPL-3.0-only" diff --git a/src-tauri/HASHOUT_LOG.md b/src-tauri/HASHOUT_LOG.md index 3e75fdd..6b6a303 100644 --- a/src-tauri/HASHOUT_LOG.md +++ b/src-tauri/HASHOUT_LOG.md @@ -2,7 +2,7 @@ Living log of all comment content, explainers, rationale, TODOs, & removed (hashed-out) code for the desktop shell 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.1 +Current build version: v0.15.2 Last updated: 2026-11-26 (US Eastern) · Tauri 2 shell ported from FormTxt, renamed, launch code added --- diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index d61e77a..ca2a324 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -1,7 +1,7 @@ { "$schema": "https://schema.tauri.app/config/2", "productName": "FormCite", - "version": "0.15.1", + "version": "0.15.2", "identifier": "ai.nodemode.formcite", "build": { "devUrl": "http://localhost:5330",