mirror of
https://github.com/nesquena/hermes-webui.git
synced 2026-05-24 18:50:15 +00:00
c98fff79c2
Pre-release Opus review on PR #1345 (Finding #3) flagged that get_cli_sessions() was calling ensure_cron_project() once per cron session in the loop — N lock acquires + N disk reads of projects.json for N cron sessions per sidebar refresh. Hoist a per-scan lazy memoizer (_cron_pid()) so we pay the resolution cost at most once per get_cli_sessions() call. The memoizer is local to the function (closure) so it's naturally scoped to a single scan and doesn't leak across calls. Could also have made ensure_cron_project() module-memoized, but that would need invalidation on project deletion — the per-scan cache is simpler and correct without coordination.