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

fix: show the quota hold on queued renders and write it once per window

[._.]/ Adam Eivy1de8f454a8fa
diff --git a/client/src/components/media/MediaJobsQueue.jsx b/client/src/components/media/MediaJobsQueue.jsx
index 0e3e2bfed9..52f510bd9d 100644
--- a/client/src/components/media/MediaJobsQueue.jsx
+++ b/client/src/components/media/MediaJobsQueue.jsx
@@ -574,6 +574,9 @@ function JobRow({ job, onCancel, onRetry, onRunNow, onDelete }) {
{job.status === 'failed' && job.error && (
<div role="status" className="text-xs text-port-error mt-2 truncate" title={job.error}>{job.error}</div>
)}
+ {job.status === 'queued' && job.statusMsg && (
+ <div role="status" className="text-xs text-port-warning-text mt-2 truncate" title={job.statusMsg}>{job.statusMsg}</div>
+ )}
{job.status === 'running' && (
<div className="mt-2 space-y-1">
<div className="flex items-center justify-between gap-2 text-xs text-port-text-muted">
diff --git a/client/src/components/media/MediaJobsQueue.test.jsx b/client/src/components/media/MediaJobsQueue.test.jsx
index b7ca67dd2c..c90feff73b 100644
--- a/client/src/components/media/MediaJobsQueue.test.jsx
+++ b/client/src/components/media/MediaJobsQueue.test.jsx
@@ -188,6 +188,24 @@ describe('MediaJobsQueue — Creative Director renders', () => {
});
});
+describe('MediaJobsQueue — queued status', () => {
+ it('shows why a queued render is waiting', async () => {
+ listQueueMediaJobs.mockResolvedValue([{
+ id: 'quotawait0000beef',
+ kind: 'image',
+ status: 'queued',
+ position: 1,
+ statusMsg: 'Waiting for codex quota — resumes at 3:00 PM',
+ queuedAt: '2026-06-19T10:00:00Z',
+ params: { prompt: 'a fox', mode: 'codex' },
+ }]);
+
+ render(<MediaJobsQueue kind="image" />);
+
+ expect(await screen.findByText('Waiting for codex quota — resumes at 3:00 PM')).toBeInTheDocument();
+ });
+});
+
describe('MediaJobsQueue — video render lanes', () => {
it('files each job under the lane the server scheduled it into', async () => {
// The lane comes from the server's own classifier (`executionLane`), so a
diff --git a/server/services/mediaJobQueue/index.js b/server/services/mediaJobQueue/index.js
index a3aaf71b3e..831799ec5b 100644
--- a/server/services/mediaJobQueue/index.js
+++ b/server/services/mediaJobQueue/index.js
@@ -658,7 +658,8 @@ function trimArchiveForSnapshot() {
const quotaCooldowns = new Map();
/** Remaining cooldown for a job's backend, 0 when it is clear to dispatch. */
-function quotaCooldownRemaining(job, now = Date.now()) {
+/** The reset instant for a job's backend, or 0 when it is clear to dispatch. */
+function quotaCooldownResumeAt(job, now = Date.now()) {
const mode = job?.params?.mode;
if (!mode) return 0;
const resumeAt = quotaCooldowns.get(mode);
@@ -669,7 +670,7 @@ function quotaCooldownRemaining(job, now = Date.now()) {
quotaCooldowns.delete(mode);
return 0;
}
- return resumeAt - now;
+ return resumeAt;
}
/**
@@ -690,6 +691,15 @@ function recordQuotaCooldown(job, errorText) {
console.warn(`⏳ media-job: ${mode} quota exhausted — holding queued ${mode} renders for ${formatDeferral(deferral.resetsInMs)}`);
}
+// Derived from the ABSOLUTE reset so the message is constant for the whole
+// window: a countdown would change every tick and force a full-queue snapshot
+// per held job each time it did.
+const QUOTA_WAIT_PATTERN = /^Waiting for \S+ quota — resumes at /;
+function quotaWaitMessage(mode, resumeAt) {
+ const at = new Date(resumeAt).toLocaleTimeString([], { hour: 'numeric', minute: '2-digit' });
+ return `Waiting for ${mode} quota — resumes at ${at}`;
+}
+
/** Snapshot shape: [[mode, resumeAt], ...], dropping anything already expired. */
function snapshotQuotaCooldowns(now = Date.now()) {
return [...quotaCooldowns.entries()].filter(([, resumeAt]) => resumeAt > now);
@@ -1008,6 +1018,9 @@ function startLaneJob(job, { lane }) {
job.startedAt = new Date().toISOString();
job.position = 1;
job.progress = typeof job.progress === 'number' && Number.isFinite(job.progress) ? job.progress : 0;
+ // A quota wait describes the queued state only; a persisted one also
+ // survives a restart that outlasts the cooldown.
+ if (QUOTA_WAIT_PATTERN.test(job.statusMsg || '')) job.statusMsg = '';
job.statusMsg = job.statusMsg || 'Starting';
if (lane === 'cloud') {
cloudRunning.push(job);
@@ -1157,18 +1170,19 @@ async function drainLoop() {
cloud: limits.cloud - cloudRunning.length,
remote: limits.remote - remoteRunning.length,
};
+ let quotaWaitChanged = false;
for (const job of candidates) {
if (job.status !== 'queued' || job.hold || job.admitting) continue;
// The provider told us when it recovers; dispatching before then just
// converts a queued job into a failed one. Hold rather than fail, and say
// when it resumes — `statusMsg` is in the persisted field whitelist, so
// the Render Queue shows the wait across a restart too.
- const cooling = quotaCooldownRemaining(job);
- if (cooling > 0) {
- const waiting = `Waiting for ${job.params.mode} quota — resumes in ${formatDeferral(cooling)}`;
+ const resumeAt = quotaCooldownResumeAt(job);
+ if (resumeAt) {
+ const waiting = quotaWaitMessage(job.params.mode, resumeAt);
if (job.statusMsg !== waiting) {
job.statusMsg = waiting;
- persist().catch((e) => console.error(`❌ media-job [${job.id.slice(0, 8)}] mediaJobQueue persist on quota hold failed: ${e.message}`));
+ quotaWaitChanged = true;
}
continue;
}
@@ -1181,6 +1195,10 @@ async function drainLoop() {
slots[lane] -= 1;
if (Object.values(slots).every((remaining) => remaining <= 0)) break;
}
+ // One snapshot for every hold this scan changed, not one per job.
+ if (quotaWaitChanged) {
+ persist().catch((e) => console.error(`❌ media-job mediaJobQueue persist on quota hold failed: ${e.message}`));
+ }
await sleep(150);
}
}
diff --git a/server/services/mediaJobQueue/index.test.js b/server/services/mediaJobQueue/index.test.js
index 620576be9d..7e6d1b7c72 100644
--- a/server/services/mediaJobQueue/index.test.js
+++ b/server/services/mediaJobQueue/index.test.js
@@ -3901,7 +3901,32 @@ describe('provider quota cooldowns', () => {
// The point of the whole change: it is still queued, not burned.
expect(mediaJobQueue.getJob(second.jobId).status).toBe('queued');
expect(stubs.generateImageCodex).toHaveBeenCalledTimes(1);
- expect(mediaJobQueue.getJob(second.jobId).statusMsg).toMatch(/resumes in 2h2[56]m/);
+ expect(mediaJobQueue.getJob(second.jobId).statusMsg).toMatch(/resumes at /);
+ });
+
+ it('keeps one hold message for the window, then promotes the job without it once the reset passes', async () => {
+ // Resolve so the first render releases its cloud slot once it fails.
+ stubs.generateImageCodex.mockResolvedValue({ jobId: 'codex-job' });
+ const first = await mediaJobQueue.enqueueJob({ kind: 'image', params: { mode: 'codex', prompt: 'page 1' } });
+ await waitFor(() => stubs.generateImageCodex.mock.calls.length === 1);
+ imageGenEvents.emit('failed', { generationId: first.jobId, error: QUOTA_ERROR });
+ await waitFor(() => mediaJobQueue.getJob(first.jobId)?.status === 'failed');
+
+ const second = await mediaJobQueue.enqueueJob({ kind: 'image', params: { mode: 'codex', prompt: 'page 2' } });
+ await waitFor(() => (mediaJobQueue.getJob(second.jobId)?.statusMsg || '').startsWith('Waiting for codex quota'));
+ const waiting = mediaJobQueue.getJob(second.jobId).statusMsg;
+ // A later scan in the same window must not rewrite (and re-persist) it.
+ await new Promise((resolve) => setTimeout(resolve, 400));
+ expect(mediaJobQueue.getJob(second.jobId).statusMsg).toBe(waiting);
+
+ const realNow = Date.now();
+ const clock = vi.spyOn(Date, 'now').mockImplementation(() => realNow + 3 * 60 * 60 * 1000);
+ try {
+ await waitFor(() => mediaJobQueue.getJob(second.jobId)?.status === 'running');
+ expect(mediaJobQueue.getJob(second.jobId).statusMsg).toBe('Starting');
+ } finally {
+ clock.mockRestore();
+ }
});
it('leaves a different backend free to run during another backend\'s cooldown', async () => {