Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

refactor: reuse media queue capacity in system resources (#6755)

[._.]/ Adam Eivybeba1dfd0878
diff --git a/server/services/systemResources.js b/server/services/systemResources.js
index 60658ffe3d..7edf244c78 100644
--- a/server/services/systemResources.js
+++ b/server/services/systemResources.js
@@ -21,7 +21,7 @@ import { getDataOverview } from './dataManager.js';
import { listHfModelStorage, listLoraStorage } from './mediaModelStorage.js';
import * as ollamaManager from './ollamaManager.js';
import * as lmStudioManager from './lmStudioManager.js';
-import { listJobs } from './mediaJobQueue/index.js';
+import { getQueueCapacity } from './mediaJobQueue/index.js';
import * as cos from './cos.js';
import { getSettings } from './settings.js';
@@ -314,18 +314,14 @@ function loadedModelInventory({ ollamaLoaded, lmStudioLoaded }) {
];
}
-function mediaQueueSummary(jobs) {
- const live = jobs.filter((job) => job.status === 'queued' || job.status === 'running');
- const byKind = Object.fromEntries(['image', 'video', 'training', 'audio'].map((kind) => {
- const matching = live.filter((job) => job.kind === kind);
- return [kind, {
- queued: matching.filter((job) => job.status === 'queued').length,
- running: matching.filter((job) => job.status === 'running').length,
- }];
- }));
+function mediaQueueSummary(capacity) {
+ const byKind = Object.fromEntries(['image', 'video', 'training', 'audio'].map((kind) => [
+ kind,
+ capacity?.byKind?.[kind] || { queued: 0, running: 0 },
+ ]));
return {
- queued: live.filter((job) => job.status === 'queued').length,
- running: live.filter((job) => job.status === 'running').length,
+ queued: capacity?.totals?.queued || 0,
+ running: capacity?.totals?.running || 0,
byKind,
};
}
@@ -436,7 +432,7 @@ export async function buildSystemResourceReport() {
downloadedModels,
npmCacheBytes,
});
- const mediaQueue = mediaQueueSummary(listJobs());
+ const mediaQueue = mediaQueueSummary(getQueueCapacity());
const agentQueue = agentQueueSummary(cosTasks, cosStatus);
const modelBytes = sumKnownBytes([hf?.totalBytes, loraStorage?.totalBytes, ollamaBytes, lmStudioBytes]);
const storageAreas = [
diff --git a/server/services/systemResources.test.js b/server/services/systemResources.test.js
index 8cc64a9e2f..763a2cc7ff 100644
--- a/server/services/systemResources.test.js
+++ b/server/services/systemResources.test.js
@@ -71,10 +71,13 @@ vi.mock('./lmStudioManager.js', () => ({
getModelsDir: vi.fn(async () => '/example/lmstudio'),
}));
vi.mock('./mediaJobQueue/index.js', () => ({
- listJobs: vi.fn(() => [
- { id: 'image-1', kind: 'image', status: 'queued' },
- { id: 'video-1', kind: 'video', status: 'running' },
- ]),
+ getQueueCapacity: vi.fn(() => ({
+ totals: { queued: 1, running: 1 },
+ byKind: {
+ image: { queued: 1, running: 0 },
+ video: { queued: 0, running: 1 },
+ },
+ })),
}));
vi.mock('./cos.js', () => ({
getAllTasks: vi.fn(async () => ({