fix(sessions): honor offline settings in background catalog refresher

The background model catalog refresher always requested a network refresh,
so sessiond fetched provider catalogs on a schedule even when the operator
set PI_OFFLINE or PI_WEB_OFFLINE. Before the refresher existed, those
settings made every runtime refresh local-only.

Add `offlineModeEnabled()` to the config module and inject the resulting
flag from sessiond's frozen daemon environment, so the refresher schedules
nothing and ignores auth-triggered requests in offline mode. The narrower
PI_SKIP_VERSION_CHECK / PI_WEB_SKIP_VERSION_CHECK keys are deliberately not
included: they only suppress release lookups.
This commit is contained in:
Federico Jaramillo Martinez
2026-07-25 12:40:33 +02:00
parent ed9c2f65bb
commit acda1cc0be
5 changed files with 84 additions and 8 deletions
+15
View File
@@ -266,6 +266,21 @@ export function subsessionsEnabled(env: NodeJS.ProcessEnv = process.env, config:
return config.subsessions ?? false;
}
const OFFLINE_ENV_KEYS = ["PI_WEB_OFFLINE", "PI_OFFLINE"] as const;
/**
* Whether the operator asked PI WEB (or pi itself) to stay offline, meaning
* background network access must be skipped. Matches the "set and non-empty"
* semantics used for the other runtime-only env switches.
*
* Deliberately narrower than `piWebStatus`'s update-check suppression: the
* `*_SKIP_VERSION_CHECK` keys only silence release lookups, while these keys ask
* for no background network at all.
*/
export function offlineModeEnabled(env: NodeJS.ProcessEnv = process.env): boolean {
return OFFLINE_ENV_KEYS.some((key) => isEnvSet(env[key]));
}
function parseString(value: unknown, key: string, path: string): string {
if (typeof value !== "string" || value === "") throw new Error(`PI WEB config ${key} must be a non-empty string: ${path}`);
return value;