From 5d632ef11db3667133fd794f2f1885ca7ef24949 Mon Sep 17 00:00:00 2001 From: Federico Jaramillo Martinez Date: Sat, 25 Jul 2026 13:32:21 +0200 Subject: [PATCH] test(sessions): make the offline-runtime regression test discriminating The reworked assertion ran under the file-level PI_OFFLINE=1 stub, so the runtime was offline whether or not createOfflineModelRuntime forced it and the test passed with the fix fully removed. Clear the stub for that case, and rewrap a docblock line. --- src/server/sessions/authService.test.ts | 3 +++ src/server/sessions/modelCatalogRefresher.ts | 7 ++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/server/sessions/authService.test.ts b/src/server/sessions/authService.test.ts index f4fb9bc..2cb00ce 100644 --- a/src/server/sessions/authService.test.ts +++ b/src/server/sessions/authService.test.ts @@ -474,6 +474,9 @@ describe("createModelRuntimeForAgentDir", () => { it("keeps runtime-owned refreshes local so request paths cannot stall", async () => { // reloadConfig() is the request-path call site that regressed: it refreshes // with allowNetwork = the construction-time network flag and no abort signal. + // The ambient PI_OFFLINE=1 stub has to go, or the runtime would be offline + // whether or not the helper forces it and this would assert nothing. + vi.stubEnv("PI_OFFLINE", undefined); const agentDir = await tempAgentDir(); const runtime = await createModelRuntimeForAgentDir(agentDir); const refresh = vi.spyOn(runtime, "refresh"); diff --git a/src/server/sessions/modelCatalogRefresher.ts b/src/server/sessions/modelCatalogRefresher.ts index a3c191e..b3d9f29 100644 --- a/src/server/sessions/modelCatalogRefresher.ts +++ b/src/server/sessions/modelCatalogRefresher.ts @@ -73,9 +73,10 @@ const noopLogger: ModelCatalogRefresherLogger = { * own refreshes never touch the network and stay fast on request paths. This * refresher is the single place that deliberately performs network refreshes — * bounded by an abort timeout, serialized through one in-flight run, stopped by - * `dispose()` even mid-flight, and off any request path. `requestRefresh()` additionally asks for a prompt forced - * refresh after events that change what should be listed, such as provider - * logins, where the cached catalog is known to be wrong. + * `dispose()` even mid-flight, and off any request path. `requestRefresh()` + * additionally asks for a prompt forced refresh after events that change what + * should be listed, such as provider logins, where the cached catalog is known + * to be wrong. * * When the operator asked for offline behavior (`PI_OFFLINE` / `PI_WEB_OFFLINE`), * the refresher performs no network I/O at all and the cached catalogs in