fix(tools): resolve the live plugin catalog once per plugins.list

The #119975 display-name lookup called get_live_catalog_entry() inside
the per-plugin loop of _plugin_rows, paying a full catalog resolution
(load_catalog_live: fetch or cache read + parse of every in-tree catalog
yaml, no memoization) once per installed plugin. plugins.manage list went
from O(1) to O(installed plugins) catalog resolutions, and a dead
catalog host cost one request timeout per plugin — the exact per-candidate
cost resolved_removed_entries() exists to eliminate.

Hoist the resolution next to pins/versions: catalog_titles() builds
{catalog_name: title} in one resolution and _plugin_server_rows reads
from the pre-resolved map, mirroring catalog_pins/catalog_versions.
Regression test counts load_catalog_live calls across a 3-plugin
listing: 3 before, 1 after.
This commit is contained in:
Brooklyn Nicholson
2026-09-25 19:20:51 -05:00
committed by brooklyn!
parent 76e2111c14
commit 31a68e9235
3 changed files with 74 additions and 7 deletions

View File

@@ -851,6 +851,16 @@ def catalog_pins() -> Dict[str, str]:
return {}
def catalog_titles() -> Dict[str, str]:
"""``{catalog_name: title}`` for entries that carry one — the Plugins hub server-sentence display
name. One resolution for a whole listing: callers that annotate every installed plugin must not
pay a live-catalog fetch per candidate (see ``resolved_removed_entries``); empty on failure."""
try:
return {e.name: e.title for e in load_catalog_live() if e.title}
except Exception:
return {}
def catalog_versions() -> Dict[str, str]:
"""``{catalog_name: version_label}`` for entries that carry one; empty on failure (best effort)."""
try: