fix: don't show "unloads in" when keep_alive=-1

With the radagast server flipped to OLLAMA_KEEP_ALIVE=-1, /api/ps
returns expires_at as year 4001 (effectively forever), which the
old code rendered as "Hot: gemma2:9b — unloads in 17500000h". Add
a 7-day threshold to formatRemaining(); anything beyond that just
shows the model name with no expiry suffix.
This commit is contained in:
João Pedro Battistella Nadas
2026-06-09 18:39:30 +02:00
parent d4a033e500
commit 0c9d5d730e
2 changed files with 7 additions and 0 deletions

View File

@@ -418,6 +418,10 @@
if (!expiresAt) return null;
const ms = new Date(expiresAt).getTime() - Date.now();
if (!isFinite(ms) || ms <= 0) return null;
// Ollama's keep_alive=-1 returns expires_at far in the future (year 4001).
// Any realistic finite keep_alive is hours at most, so treat >7 days
// as "never unloads" and drop the misleading suffix.
if (ms > 7 * 24 * 60 * 60 * 1000) return null;
const totalSec = Math.floor(ms / 1000);
const mins = Math.floor(totalSec / 60);
const secs = totalSec % 60;