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
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
fix: show live LLM runs and loaded Ollama models on dashboard (#10535)
Adam Eivyaab8e04c8245
diff --git a/client/src/components/dashboard/ActiveProcessingWidget.jsx b/client/src/components/dashboard/ActiveProcessingWidget.jsxindex ce7015ee66..b2b3c09ba0 100644--- a/client/src/components/dashboard/ActiveProcessingWidget.jsx+++ b/client/src/components/dashboard/ActiveProcessingWidget.jsx@@ -2,19 +2,22 @@ import { memo, useEffect, useRef, useState } from 'react';import { Link } from 'react-router';import { AudioLines, Bot, Brain, Cpu, ExternalLink, Film, Image as ImageIcon, Layers3, Package, X } from 'lucide-react';import * as api from '../../services/api';+import { formatBytes, formatCount } from '../../utils/formatters';+import { useTimeTick } from '../../hooks/useTimeTick';import { useAutoRefetch } from '../../hooks/useAutoRefetch';import { sameProcessingSnapshot, useSystemActivity } from '../../hooks/useSystemActivity';export { sameProcessingSnapshot };-// nvidia-smi has no lifecycle event, so utilization cannot ride the activity+// nvidia-smi and external Ollama loads have no lifecycle event, so telemetry cannot ride the activity// invalidation. Poll it only while this inspector intersects the viewport;// useAutoRefetch also pauses while the tab is hidden. The activity snapshot// itself is not polled.const GPU_SAMPLE_MS = 3000;const sameGpuSample = (a, b) => a?.gpu?.status === b?.gpu?.status&& a?.gpu?.laneBusy === b?.gpu?.laneBusy- && a?.gpu?.gpus?.[0]?.utilizationPercent === b?.gpu?.gpus?.[0]?.utilizationPercent;+ && a?.gpu?.gpus?.[0]?.utilizationPercent === b?.gpu?.gpus?.[0]?.utilizationPercent+ && JSON.stringify(a?.ollama) === JSON.stringify(b?.ollama);function useElementVisible() {const ref = useRef(null);@@ -76,7 +79,7 @@ function LaneRow({ to, icon: Icon, label, detail }) {return (<Link to={to} className="mt-1.5 flex items-center gap-2 rounded-lg border border-port-border bg-port-bg/60 px-2.5 py-2 text-xs text-gray-300 hover:border-port-accent/50"><Icon size={14} className="text-port-accent" />- <span className="min-w-0 flex-1 truncate">{label}</span>+ <span className="min-w-0 flex-1 truncate" title={label}>{label}</span>{detail ? <span className="shrink-0 font-mono text-gray-500">{detail}</span> : null}<ExternalLink size={13} className="shrink-0 text-gray-500" /></Link>@@ -99,6 +102,9 @@ function ActiveProcessingWidget() {const gpu = telemetry?.gpu;const imageTo3d = data?.extras?.imageTo3d || [];const mind = data?.mind;+ const llm = data?.llm;+ const now = useTimeTick(1000);+ const ollama = telemetry?.ollama ?? data?.ollama;const appOperations = data?.appOperations || [];const activeAgents = data?.agents?.active || 0;// Derived server-side (server/lib/systemIdle.js) and rendered as sent: the@@ -120,9 +126,13 @@ function ActiveProcessingWidget() {<span className={`rounded-full px-2 py-1 text-[10px] font-medium uppercase tracking-wider ${idle ? 'bg-port-border/60 text-gray-500' : 'bg-port-accent/15 text-port-accent'}`}>{!confirmed ? 'unknown' : idle ? 'idle' : `${activity.activeCount} active${activity.queuedCount ? ` · ${activity.queuedCount} queued` : ''}`}</span></div>{!confirmed && !data ? <p className="text-xs text-gray-500">Checking render lanes…</p> : !data ? <p className="text-xs text-gray-500">Activity unknown</p> : <>- {!idle ? <div className="mb-3 grid grid-cols-2 gap-1.5 text-center @xs:grid-cols-4"><Metric icon={Bot} value={activeAgents} label="agents" /><Metric icon={Layers3} value={runningJobs} label="rendering" /><Metric icon={Brain} value={mind?.thinking ? 'yes' : 'no'} label="thinking" /><Metric icon={Cpu} value={gpu?.laneBusy ? 'busy' : 'ready'} label="GPU" /></div> : null}+ {!idle ? <div className="mb-3 grid grid-cols-2 gap-1.5 text-center @xs:grid-cols-5"><Metric icon={Bot} value={activeAgents} label="agents" /><Metric icon={Layers3} value={runningJobs} label="rendering" /><Metric icon={Cpu} value={llm?.trusted === false ? '?' : formatCount(llm?.active || 0)} label="LLM" /><Metric icon={Brain} value={mind?.thinking ? 'yes' : 'no'} label="thinking" /><Metric icon={Cpu} value={gpu?.laneBusy ? 'busy' : 'ready'} label="GPU" /></div> : null}{idle ? <Link to="/system-resources/overview" className="flex items-center justify-between rounded-lg border border-port-border bg-port-bg px-3 py-3 text-xs text-gray-400 transition-colors hover:border-port-accent/50 hover:text-gray-200"><span>Nothing is running</span><span>GPU {gpu?.status === 'available' ? 'ready' : gpu?.status || 'unknown'} →</span></Link> : null}<div className="space-y-1.5">{jobs.map((job) => <JobRow key={job.id} job={job} onCancel={cancel} />)}</div>+ {(llm?.runs || []).map((run) => <LaneRow key={`llm-${run.runId}`} to={`/cos/runs?run=${encodeURIComponent(run.runId)}`} icon={Cpu} label={`${run.providerId || 'LLM'} · ${run.model || 'default model'} · ${run.source || 'run'}`} detail={elapsed(run.startedAt, now)} />)}+ {llm?.active > (llm?.runs?.length || 0) ? <LaneRow to="/cos/runs" icon={Cpu} label="Additional LLM runs" detail={formatCount(llm.active - (llm?.runs?.length || 0))} /> : null}+ {(ollama?.models || []).map((model) => <LaneRow key={`ollama-${model.id}`} to="/models/llms" icon={Cpu} label={`Ollama loaded · ${model.name || model.id}`} detail={[model.size == null ? 'size unknown' : formatBytes(model.size), model.sizeVram == null ? 'processor unknown' : model.sizeVram === 0 ? 'CPU' : model.size != null && model.sizeVram >= model.size ? 'GPU' : 'GPU/CPU'].join(' · ')} />)}+ {ollama?.trusted === false ? <p className="mt-1.5 text-xs text-gray-500">Ollama residency unavailable</p> : null}{imageTo3d.map((item) => <LaneRow key={`3d-${item.id}`} to="/3d" icon={Layers3} label={`Image-to-3D · ${item.name}`} />)}{/* Counts and lifecycle only — never what the mind is thinking ABOUT. */}{mind?.thinking || mind?.queued ? (diff --git a/client/src/components/dashboard/ActiveProcessingWidget.test.jsx b/client/src/components/dashboard/ActiveProcessingWidget.test.jsxindex 752a1fdace..6e196ffcb9 100644--- a/client/src/components/dashboard/ActiveProcessingWidget.test.jsx+++ b/client/src/components/dashboard/ActiveProcessingWidget.test.jsx@@ -106,6 +106,28 @@ describe('ActiveProcessingWidget', () => {expect(await screen.findByRole('link', { name: /Example App · update/ })).toHaveAttribute('href', '/apps');});+ it('shows LLM model/source, elapsed time, a run deep link and Ollama residency', async () => {+ mockGetSystemActivity.mockResolvedValue({+ ...idle,+ llm: { trusted: true, active: 1, runs: [{ runId: 'run-1', providerId: 'ollama', model: 'example:7b', source: 'music-video-document', startedAt: new Date(Date.now() - 125000).toISOString() }] },+ ollama: { trusted: true, models: [{ id: 'example:7b', name: 'example:7b', size: 1073741824, sizeVram: 1073741824 }] },+ activity: { idle: false, activeCount: 1, queuedCount: 0, blockers: [] },+ });+ renderWidget();+ expect(await screen.findByRole('link', { name: /ollama · example:7b · music-video-document/ })).toHaveAttribute('href', '/cos/runs?run=run-1');+ expect(screen.getByText('2:05')).toBeInTheDocument();+ expect(screen.getByText('LLM')).toBeInTheDocument();+ expect(screen.getByRole('link', { name: /Ollama loaded · example:7b/ })).toHaveTextContent('1 GB · GPU');+ // Replacing one active run with another must repaint even when count stays 1.+ expect(sameProcessingSnapshot({ llm: { active: 1, runs: [{ runId: 'a' }] } }, { llm: { active: 1, runs: [{ runId: 'b' }] } })).toBe(false);+ });++ it('shows external Ollama loads from telemetry even when PortOS is idle', async () => {+ mockGetGpuTelemetry.mockResolvedValue({ ollama: { trusted: true, models: [{ id: 'external', name: 'external', size: 1073741824, sizeVram: 0 }] } });+ renderWidget();+ expect(await screen.findByRole('link', { name: /Ollama loaded · external/ })).toHaveTextContent('1 GB · CPU');+ });+it('cancels a live job from its row', async () => {mockGetSystemActivity.mockResolvedValue({jobs: [{ id: 'image-1', kind: 'image', status: 'running', progress: 0.5, startedAt: new Date().toISOString(), params: { prompt: 'Example image' } }],diff --git a/client/src/hooks/useSystemActivity.js b/client/src/hooks/useSystemActivity.jsindex 631e09ab32..04f010d625 100644--- a/client/src/hooks/useSystemActivity.js+++ b/client/src/hooks/useSystemActivity.js@@ -34,6 +34,8 @@ export const sameProcessingSnapshot = (a, b) => {&& a.mind?.trusted === b.mind?.trusted&& a.llm?.active === b.llm?.active&& a.llm?.trusted === b.llm?.trusted+ && JSON.stringify(a.llm?.runs) === JSON.stringify(b.llm?.runs)+ && JSON.stringify(a.ollama) === JSON.stringify(b.ollama)&& a.backup?.inProgress === b.backup?.inProgress&& a.update?.inProgress === b.update?.inProgress&& a.activity?.idle === b.activity?.idlediff --git a/server/lib/aiToolkit/runner.js b/server/lib/aiToolkit/runner.jsindex c34589ca03..8f0e59bb36 100644--- a/server/lib/aiToolkit/runner.js+++ b/server/lib/aiToolkit/runner.js@@ -1106,6 +1106,24 @@ export function createRunnerService(config = {}) {return externalRuns.has(runId) || activeRuns.has(runId);},+ // Activity projection only: never return the persisted prompt, output,+ // workspace, or error fields. Bound I/O to the live registry, not history.+ async getActiveRunSummaries(limit = 50) {+ const ids = [...new Set([...activeRuns.keys(), ...externalRuns.keys()])].slice(0, limit);+ const runs = await Promise.all(ids.map(async (runId) => {+ const metadata = safeJsonParse(await readFile(join(RUNS_PATH, runId, 'metadata.json'), 'utf8').catch(() => '{}'));+ const text = (value) => typeof value === 'string' ? value.slice(0, 200) : null;+ return {+ runId,+ providerId: text(metadata.providerId),+ model: text(metadata.model),+ source: text(metadata.source),+ startedAt: text(metadata.startTime),+ };+ }));+ return runs.filter(({ runId }) => activeRuns.has(runId) || externalRuns.has(runId));+ },+/*** How many runs this instance is tracking right now — API-based* (`activeRuns`) and host-spawned CLI/TUI (`externalRuns`) alike. A countdiff --git a/server/lib/aiToolkit/runner.test.js b/server/lib/aiToolkit/runner.test.jsindex ced1a5db77..74ae9f71b1 100644--- a/server/lib/aiToolkit/runner.test.js+++ b/server/lib/aiToolkit/runner.test.js@@ -1876,6 +1876,28 @@ describe('AI Toolkit runner — declared extension points', () => {// getActiveRunCount is the surface the host's system-idle gate reads — it// must count BOTH tracking maps (API runs and host-spawned CLI/TUI runs),// since a host runner never populates the other one for the same run.+ it('projects bounded live metadata without prompts, output or workspace content', async () => {+ const dir = await mkdtemp(join(tmpdir(), 'runner-activity-'));+ try {+ const runner = createRunnerService({ dataDir: dir });+ await mkdir(join(dir, 'runs', 'external-1'), { recursive: true });+ await writeFile(join(dir, 'runs', 'external-1', 'metadata.json'), JSON.stringify({+ providerId: 'ollama', model: 'example:7b', source: 'music-video-document', startTime: '2026-01-01T00:00:00Z',+ prompt: 'private prompt', output: 'private output', workspacePath: '/private', error: 'private error',+ }));+ runner.registerExternalRun('external-1', externalChild());+ runner.registerExternalRun('missing-record', externalChild());+ expect(await runner.getActiveRunSummaries(1)).toEqual([{+ runId: 'external-1', providerId: 'ollama', model: 'example:7b', source: 'music-video-document', startedAt: '2026-01-01T00:00:00Z',+ }]);+ expect((await runner.getActiveRunSummaries())[1]).toEqual({ runId: 'missing-record', providerId: null, model: null, source: null, startedAt: null });+ runner.unregisterExternalRun('external-1');+ expect(await runner.getActiveRunSummaries()).toHaveLength(1);+ } finally {+ await rm(dir, { recursive: true, force: true });+ }+ });+it('getActiveRunCount sums external and internally-tracked runs', async () => {const runner = createRunnerService({ dataDir: './data' });expect(await runner.getActiveRunCount()).toBe(0);diff --git a/server/routes/systemActivity.js b/server/routes/systemActivity.jsindex 3646ff7b06..85cf087700 100644--- a/server/routes/systemActivity.js+++ b/server/routes/systemActivity.js@@ -8,7 +8,7 @@ const router = Router();// backup, and update state. No GPU shell-out. Clients read it once on subscribe// and again when `system:activity` invalidates, including after a reconnect.router.get('/activity', asyncHandler(async (_req, res) => {- res.json(await getSystemActivity());+ res.json(await getSystemActivity({ includeOllama: true }));}));// nvidia-smi samples. No event source — the live-activity inspector polls thisdiff --git a/server/routes/systemActivity.test.js b/server/routes/systemActivity.test.jsindex 9341ac3e4c..328bf38131 100644--- a/server/routes/systemActivity.test.js+++ b/server/routes/systemActivity.test.js@@ -2,33 +2,58 @@ import { beforeEach, describe, expect, it, vi } from 'vitest';import express from 'express';import { request } from '../lib/testHelper.js';-const activity = vi.hoisted(() => ({- getSystemActivity: vi.fn(),- getGpuTelemetry: vi.fn(),-}));-vi.mock('../services/activeProcessing.js', () => activity);--const { default: routes } = await import('./systemActivity.js');--const app = express();-app.use('/api/system', routes);+const deps = vi.hoisted(() => ({ loaded: vi.fn(), loadedError: vi.fn(), runs: vi.fn(), count: vi.fn() }));+vi.mock('../lib/cudaCapability.js', () => ({ getCudaCapability: async () => ({ status: 'absent', gpus: [] }) }));+vi.mock('../services/mediaJobQueue/index.js', () => ({ listJobs: () => [], getRunningJob: () => null }));+vi.mock('../services/imageTo3d/models.js', () => ({ listGeneratingModelSummaries: async () => [] }));+vi.mock('../services/ollamaManager.js', () => ({ getLoadedModels: deps.loaded, getLastLoadedModelsError: deps.loadedError }));+vi.mock('../services/cos.js', () => ({ getPendingTaskIds: async () => [], getAgents: async () => [] }));+vi.mock('../services/cosState.js', () => ({ readPersistentMindStateForSafetyCheck: async () => ({ trusted: true }) }));+vi.mock('../services/appOperations.js', () => ({ listActiveAppOperations: () => [] }));+vi.mock('../services/updateChecker.js', () => ({ isUpdateInProgress: () => false }));+vi.mock('../services/runner.js', () => ({ getActiveRunCount: deps.count, getActiveRunSummaries: deps.runs }));+vi.mock('../services/backup.js', () => ({ isBackupInProgress: () => false }));+let app;describe('system activity routes', () => {- beforeEach(() => vi.clearAllMocks());+ beforeEach(async () => {+ vi.resetModules();+ vi.resetAllMocks();+ deps.count.mockResolvedValue(1);+ deps.runs.mockResolvedValue([{ runId: 'run-1', providerId: 'ollama', model: 'example:7b', source: 'music-video-document', startedAt: '2026-01-01T00:00:00Z' }]);+ deps.loaded.mockResolvedValue([{ id: 'example:7b', name: 'example:7b', size: 1000, sizeVram: 1000, expiresAt: null }]);+ deps.loadedError.mockReturnValue(null);+ app = express();+ const { default: routes } = await import('./systemActivity.js');+ app.use('/api/system', routes);+ });++ it('serves run metadata and cached Ollama residency through the activity route', async () => {+ const response = await request(app).get('/api/system/activity');+ expect(response.status).toBe(200);+ expect(response.body.llm).toEqual({ trusted: true, active: 1, runs: await deps.runs() });+ expect(response.body.llm.runs[0]).not.toHaveProperty('prompt');+ expect(response.body.ollama).toMatchObject({ trusted: true, models: [{ name: 'example:7b' }] });+ expect(response.body.activity.idle).toBe(false);+ await request(app).get('/api/system/gpu-telemetry');+ expect(deps.loaded).toHaveBeenCalledTimes(1);+ expect(deps.loaded).toHaveBeenCalledWith({ timeout: 1500 });+ });- it('serves the bounded activity snapshot without GPU telemetry', async () => {- activity.getSystemActivity.mockResolvedValue({ activity: { idle: true } });+ it('keeps the snapshot successful and active when Ollama is unreachable', async () => {+ deps.loaded.mockRejectedValue(new Error('daemon unavailable'));const response = await request(app).get('/api/system/activity');expect(response.status).toBe(200);- expect(response.body.activity.idle).toBe(true);- expect(activity.getGpuTelemetry).not.toHaveBeenCalled();+ expect(response.body.llm.active).toBe(1);+ expect(response.body.ollama).toEqual({ trusted: false, models: [] });+ expect(response.body.activity.idle).toBe(false);});- it('serves GPU samples from their own route', async () => {- activity.getGpuTelemetry.mockResolvedValue({ gpu: { status: 'available', laneBusy: false, gpus: [] } });+ it('does not confuse a failed residency read with an empty daemon', async () => {+ deps.loaded.mockResolvedValue([]);+ deps.loadedError.mockReturnValue('residency probe failed');const response = await request(app).get('/api/system/gpu-telemetry');expect(response.status).toBe(200);- expect(response.body.gpu.status).toBe('available');- expect(activity.getSystemActivity).not.toHaveBeenCalled();+ expect(response.body.ollama).toEqual({ trusted: false, models: [] });});});diff --git a/server/services/activeProcessing.js b/server/services/activeProcessing.jsindex a45845fc56..f572e54d0f 100644--- a/server/services/activeProcessing.js+++ b/server/services/activeProcessing.js@@ -4,7 +4,7 @@ import { runningAgentsByTaskId, unclaimedTaskIds } from '../lib/cosSpawnWindow.jimport { listJobs, getRunningJob } from './mediaJobQueue/index.js';import { sanitizeJob } from './mediaJobQueue/sanitizeJob.js';import { listGeneratingModelSummaries } from './imageTo3d/models.js';-import { getLoadedModels } from './ollamaManager.js';+import { getLoadedModels, getLastLoadedModelsError } from './ollamaManager.js';import { listActiveAppOperations } from './appOperations.js';import { readPersistentMindStateForSafetyCheck } from './cosState.js';import { isUpdateInProgress } from './updateChecker.js';@@ -19,6 +19,26 @@ import * as cos from './cos.js';const importRunner = () => import('./runner.js');const importBackup = () => import('./backup.js');+// Ollama has no lifecycle callback for external loads/evictions. Shared cache+// also coalesces simultaneous telemetry and initial inspector reads.+let ollamaSample = null;+let ollamaSampleAt = 0;+let ollamaRead = null;+async function getOllamaTelemetry() {+ if (ollamaSample && Date.now() - ollamaSampleAt < 3000) return ollamaSample;+ if (!ollamaRead) {+ ollamaRead = getLoadedModels({ timeout: 1500 }).then((models) => ({+ trusted: !getLastLoadedModelsError(),+ models: models.slice(0, 50),+ })).catch(() => ({ trusted: false, models: [] })).then((sample) => {+ ollamaSample = sample;+ ollamaSampleAt = Date.now();+ return sample;+ }).finally(() => { ollamaRead = null; });+ }+ return ollamaRead;+}+const LIVE_STATUSES = new Set(['queued', 'running']);/**@@ -103,11 +123,11 @@ function agentCounts(agents, cosStatus, pendingTaskIds) {** Split out because two callers — `GET /api/update/auto` and the auto-update* tick — want only `activity`, and the full snapshot also shells out to- * nvidia-smi and makes an HTTP request to Ollama, whose latency is unbounded- * when the daemon is wedged. Neither feeds the verdict.+ * nvidia-smi and reads Ollama residency. Neither feeds the verdict.+ * The HTTP inspector opts into cached residency; safety checks omit it.*/-export async function getSystemActivity() {- const [jobs, models, pendingTaskIds, agents, mindState, activeRunCount, backupInProgress] = await Promise.all([+export async function getSystemActivity({ includeOllama = false } = {}) {+ const [jobs, models, pendingTaskIds, agents, mindState, llmState, backupInProgress, ollama] = await Promise.all([Promise.resolve(listJobs()).then((items) => items.filter((job) => LIVE_STATUSES.has(job.status))),// `null` = the read FAILED, distinct from `[]` = read fine, nothing// building. Both of these degrade to the value that unlocks a restart, so@@ -121,12 +141,16 @@ export async function getSystemActivity() {// than an empty mind, so an unreadable state cannot read as an idle one.readPersistentMindStateForSafetyCheck().catch(() => ({ trusted: false, persistentMind: null })),// Same contract again: a failed read degrades to `null`, not 0.- importRunner().then((m) => m.getActiveRunCount()).catch(() => null),+ importRunner().then(async (m) => {+ const [count, runs] = await Promise.all([m.getActiveRunCount(), m.getActiveRunSummaries().catch(() => null)]);+ return { ...llmRunState(count), runs };+ }).catch(() => ({ trusted: false, active: 0, runs: null })),// The only way this rejects is the lazy import itself failing (the module// is otherwise a synchronous, no-I/O flag read) — an anomaly rare enough// that it is itself reason to refuse rather than read as "no backup// running", the same fail-closed direction every other slice here takes.importBackup().then((m) => m.isBackupInProgress()).catch(() => true),+ includeOllama ? getOllamaTelemetry() : null,]);const cosStatus = agents === null ? await cos.getStatus().catch(() => null) : null;const slices = {@@ -140,7 +164,7 @@ export async function getSystemActivity() {// process — activity in exactly the sense the updater must not restart// through, and distinct from a CoS agent (its own slice above, spawned// through a different path entirely).- llm: llmRunState(activeRunCount),+ llm: llmState,// An App Management update/standardize holds a checkout and restarts PM2// processes — activity in exactly the sense that matters to a caller// deciding whether it may restart the install.@@ -149,7 +173,7 @@ export async function getSystemActivity() {// No trusted contract needed: an in-process flag with no I/O once loaded.backup: { inProgress: backupInProgress },};- return { ...slices, activity: summarizeSystemActivity(slices) };+ return { ...slices, ...(includeOllama ? { ollama } : {}), activity: summarizeSystemActivity(slices) };}/**@@ -163,6 +187,7 @@ export async function getGpuTelemetry() {const running = getRunningJob();return {updatedAt: new Date().toISOString(),+ ollama: await getOllamaTelemetry(),gpu: {status: capability.status,laneBusy: Boolean(running),@@ -178,15 +203,14 @@ export async function getGpuTelemetry() {}export async function getActiveProcessing() {- const [telemetry, activity, loadedModels] = await Promise.all([+ const [telemetry, activity] = await Promise.all([getGpuTelemetry(),getSystemActivity(),- getLoadedModels().catch(() => []),]);return {...activity,updatedAt: telemetry.updatedAt,gpu: telemetry.gpu,- extras: { ...activity.extras, ollama: loadedModels },+ extras: { ...activity.extras, ollama: telemetry.ollama.models },};}diff --git a/server/services/activeProcessing.test.js b/server/services/activeProcessing.test.jsindex 496eb2eddf..8c9dc93f1c 100644--- a/server/services/activeProcessing.test.js+++ b/server/services/activeProcessing.test.js@@ -8,15 +8,19 @@ vi.mock('../lib/cudaCapability.js', () => ({ getCudaCapability: deps.capability,vi.mock('./mediaJobQueue/index.js', () => ({ listJobs: deps.jobs, getRunningJob: deps.running }));vi.mock('./mediaJobQueue/sanitizeJob.js', () => ({ sanitizeJob: (job) => ({ id: job.id, kind: job.kind, status: job.status, params: { musicStudio: job.params.musicStudio } }) }));vi.mock('./imageTo3d/models.js', () => ({ listGeneratingModelSummaries: deps.models }));-vi.mock('./ollamaManager.js', () => ({ getLoadedModels: deps.loaded }));+vi.mock('./ollamaManager.js', () => ({ getLoadedModels: deps.loaded, getLastLoadedModelsError: () => null }));vi.mock('./cos.js', () => ({ getPendingTaskIds: deps.tasks, getStatus: deps.status, getAgents: deps.agents }));vi.mock('./cosState.js', () => ({ readPersistentMindStateForSafetyCheck: deps.mind }));vi.mock('./appOperations.js', () => ({ listActiveAppOperations: deps.operations }));vi.mock('./updateChecker.js', () => ({ isUpdateInProgress: deps.updating }));-vi.mock('./runner.js', () => ({ getActiveRunCount: deps.runCount }));+vi.mock('./runner.js', () => ({ getActiveRunCount: deps.runCount, getActiveRunSummaries: async () => [] }));vi.mock('./backup.js', () => ({ isBackupInProgress: deps.backupRunning }));-const { getActiveProcessing } = await import('./activeProcessing.js');+let getActiveProcessing;+beforeEach(async () => {+ vi.resetModules();+ ({ getActiveProcessing } = await import('./activeProcessing.js'));+});describe('active processing snapshot', () => {beforeEach(() => {@@ -247,7 +251,7 @@ describe('LLM run and backup snapshot activity', () => {deps.runCount.mockResolvedValue(1);deps.backupRunning.mockReturnValue(false);const snapshot = await getActiveProcessing();- expect(snapshot.llm).toEqual({ trusted: true, active: 1 });+ expect(snapshot.llm).toMatchObject({ trusted: true, active: 1 });expect(snapshot.activity.idle).toBe(false);expect(snapshot.activity.blockers.map(b => b.kind)).toContain('llm-running');});@@ -259,7 +263,7 @@ describe('LLM run and backup snapshot activity', () => {deps.runCount.mockRejectedValue(new Error('toolkit unavailable'));deps.backupRunning.mockReturnValue(false);const snapshot = await getActiveProcessing();- expect(snapshot.llm).toEqual({ trusted: false, active: 0 });+ expect(snapshot.llm).toMatchObject({ trusted: false, active: 0 });expect(snapshot.activity.idle).toBe(false);expect(snapshot.activity.blockers.map(b => b.kind)).toContain('llm-unreadable');});@@ -268,7 +272,7 @@ describe('LLM run and backup snapshot activity', () => {deps.runCount.mockResolvedValue(0);deps.backupRunning.mockReturnValue(false);const snapshot = await getActiveProcessing();- expect(snapshot.llm).toEqual({ trusted: true, active: 0 });+ expect(snapshot.llm).toMatchObject({ trusted: true, active: 0 });expect(snapshot.activity.idle).toBe(true);});diff --git a/server/services/ollamaManager.js b/server/services/ollamaManager.jsindex 679274d505..e8e4777eac 100644--- a/server/services/ollamaManager.js+++ b/server/services/ollamaManager.js@@ -1325,8 +1325,8 @@ async function getEmbeddings(text, options = {}) {* manager's availability cache or error state.* @returns {Promise<{models:Array<{id,name,size,sizeVram,expiresAt}>,error:string|null}>}*/-async function getLoadedModelsAt(baseUrl) {- const data = await ollamaRequestAt(baseUrl, '/api/ps').catch((err) => ({ _err: err.message }))+async function getLoadedModelsAt(baseUrl, options = {}) {+ const data = await ollamaRequestAt(baseUrl, '/api/ps', options).catch((err) => ({ _err: err.message }))if (!Array.isArray(data?.models)) {return { models: [], error: data?._err || 'Ollama residency endpoint returned no model list' }}@@ -1348,12 +1348,12 @@ async function getLoadedModelsAt(baseUrl) {* occupy memory until it's referenced by a request.* @returns {Promise<Array<{ id, name, size, sizeVram, expiresAt }>>}*/-async function getLoadedModels() {+async function getLoadedModels(options = {}) {if (!(await checkOllamaAvailable())) {lastLoadedModelsError = status.lastError || 'Ollama is unavailable'return []}- const result = await getLoadedModelsAt(config.baseUrl)+ const result = await getLoadedModelsAt(config.baseUrl, options)lastLoadedModelsError = result.errorreturn result.models}diff --git a/server/services/runner.js b/server/services/runner.jsindex edb9c0ebbf..d3210b098e 100644--- a/server/services/runner.js+++ b/server/services/runner.js@@ -770,3 +770,8 @@ export async function isRunActive(runId) {export async function getActiveRunCount() {return getAIToolkitInstance()?.services?.runner?.getActiveRunCount?.() ?? null;}++/** Bounded, content-free detail for the system activity inspector. */+export async function getActiveRunSummaries() {+ return getAIToolkitInstance()?.services?.runner?.getActiveRunSummaries?.() ?? null;+}