add more details to sharp + hopefully let me know if it's broken for people on linux.

This commit is contained in:
KingKDot
2026-04-23 12:19:00 -05:00
parent 8c3c6de1c3
commit 6ba468235b
3 changed files with 26 additions and 12 deletions
+11 -5
View File
@@ -4,12 +4,14 @@ import { digestData } from "./utils.js";
const POLL_INTERVAL_MS = 5000;
const FALLBACK_POLL_MS = 30000;
const PREF_REFRESH_KEY = "overlord_refresh_interval_seconds";
const THUMBNAIL_COOLDOWN_MS = 60000;
let pollTimer = null;
let render = () => {};
let dashboardWs = null;
let dashboardWsConnected = false;
let wsReconnectTimer = null;
const manuallyDisconnecting = new Set();
const thumbnailRequestedAt = new Map();
function moveClientCardImmediately(msg) {
const clientId = typeof msg?.clientId === "string" ? msg.clientId : "";
@@ -74,10 +76,7 @@ export async function loadWithOptions(options = {}) {
const pag = document.getElementById("pagination");
if (pag) pag.style.visibility = "";
if (!state.thumbnailsRequested) {
state.thumbnailsRequested = true;
requestThumbnailsForClients(data.items);
}
requestThumbnailsForClients(data.items);
} catch (err) {
console.error("load clients", err);
} finally {
@@ -93,8 +92,14 @@ export async function loadWithOptions(options = {}) {
}
async function requestThumbnailsForClients(items) {
const onlineClientsWithoutThumbnail = items.filter(c => c.online && !c.thumbnail);
const now = Date.now();
const onlineClientsWithoutThumbnail = items.filter(c => {
if (!c.online || c.thumbnail) return false;
const last = thumbnailRequestedAt.get(c.id);
return !last || now - last > THUMBNAIL_COOLDOWN_MS;
});
for (const client of onlineClientsWithoutThumbnail) {
thumbnailRequestedAt.set(client.id, now);
await requestThumbnail(client.id);
}
}
@@ -176,6 +181,7 @@ function connectDashboardWs() {
console.warn("[dashboard] ws closed");
dashboardWs = null;
dashboardWsConnected = false;
thumbnailRequestedAt.clear();
adjustPollingForWs();
scheduleDashboardReconnect();
};
-1
View File
@@ -11,5 +11,4 @@ export const state = {
isLoading: false,
pendingForce: false,
pendingReorder: false,
thumbnailsRequested: false,
};
+15 -6
View File
@@ -1,9 +1,17 @@
let _sharp: typeof import("sharp") extends { default: infer D } ? D : never;
async function getSharp() {
if (!_sharp) {
_sharp = (await import("sharp")).default;
let _sharp: (typeof import("sharp") extends { default: infer D } ? D : never) | null = null;
let _sharpLoadAttempted = false;
async function getSharp(): Promise<typeof import("sharp") extends { default: infer D } ? D : never> {
if (_sharp) return _sharp;
if (_sharpLoadAttempted) throw new Error("sharp module unavailable");
_sharpLoadAttempted = true;
try {
_sharp = (await import("sharp")).default as any;
return _sharp!;
} catch (err) {
console.error("[thumbnails] Failed to load sharp module. Thumbnails will be unavailable.", err);
throw err;
}
return _sharp;
}
const THUMBNAIL_WIDTH = Math.max(64, Number(process.env.OVERLORD_THUMBNAIL_WIDTH || 640));
@@ -80,7 +88,8 @@ export async function generateThumbnail(id: string): Promise<boolean> {
thumbnails.set(id, dataUrl);
latestFrames.delete(id);
return true;
} catch {
} catch (err) {
console.error(`[thumbnails] Failed to generate thumbnail for client ${id}:`, err);
return false;
}
}