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

address review (codex): retry transient load errors; run-scoped notifications

Adam Eivyd37ba586642f
diff --git a/client/src/components/creative-commission/RenderHistory.jsx b/client/src/components/creative-commission/RenderHistory.jsx
index 9f34f4400b..583382681c 100644
--- a/client/src/components/creative-commission/RenderHistory.jsx
+++ b/client/src/components/creative-commission/RenderHistory.jsx
@@ -15,7 +15,7 @@
* degrades to a status-only card — the "View output" link still works.
*/
-import { useMemo, useState } from 'react';
+import { useEffect, useMemo, useState } from 'react';
import { Link } from 'react-router-dom';
import { ExternalLink, Film, ThumbsUp, ThumbsDown } from 'lucide-react';
import ProjectPreview from '../creative-director/ProjectPreview.jsx';
@@ -28,7 +28,7 @@ const STATUS_CLASS = {
failed: 'text-port-error',
};
-export default function RenderHistory({ runs, feedback, projectsById, projectsLoading, onRate }) {
+export default function RenderHistory({ runs, feedback, projectsById, projectsLoading, focusRunId, onRate }) {
// Newest-first, memoized so the copy+reverse doesn't run on every render.
const orderedRuns = useMemo(() => [...(runs || [])].reverse(), [runs]);
// Latest reaction per run (last write wins), so the run reflects its most
@@ -39,6 +39,16 @@ export default function RenderHistory({ runs, feedback, projectsById, projectsLo
return map;
}, [feedback]);
+ // Scroll the deep-linked run (`?run=<id>` from a scheduled-run notification)
+ // into view once its card has rendered. Keyed on the run set too, so a card
+ // that only appears after the run list loads still gets focused.
+ const hasFocusRun = !!focusRunId && orderedRuns.some((r) => r.id === focusRunId);
+ useEffect(() => {
+ if (!hasFocusRun) return;
+ const el = document.getElementById(`commission-run-${focusRunId}`);
+ if (el) el.scrollIntoView({ behavior: 'smooth', block: 'center' });
+ }, [hasFocusRun, focusRunId]);
+
if (orderedRuns.length === 0) {
return (
<div className="border border-dashed border-port-border rounded-lg p-10 text-center">
@@ -55,8 +65,13 @@ export default function RenderHistory({ runs, feedback, projectsById, projectsLo
<div className="grid grid-cols-1 sm:grid-cols-2 xl:grid-cols-3 gap-4">
{orderedRuns.map((r) => {
const project = r.projectId ? projectsById.get(r.projectId) : null;
+ const focused = r.id === focusRunId;
return (
- <div key={r.id} className="bg-port-card border border-port-border rounded-lg overflow-hidden flex flex-col">
+ <div
+ key={r.id}
+ id={`commission-run-${r.id}`}
+ className={`bg-port-card border rounded-lg overflow-hidden flex flex-col ${focused ? 'border-port-accent ring-1 ring-port-accent' : 'border-port-border'}`}
+ >
{/* Produced-media preview (or a status-only placeholder). */}
{project ? (
<ProjectPreview project={project} to={`/creative-director/${encodeURIComponent(r.projectId)}`} />
diff --git a/client/src/pages/CreativeCommissionDetail.jsx b/client/src/pages/CreativeCommissionDetail.jsx
index 4797c2c0ef..b5fb4bea0a 100644
--- a/client/src/pages/CreativeCommissionDetail.jsx
+++ b/client/src/pages/CreativeCommissionDetail.jsx
@@ -13,7 +13,7 @@
*/
import { useEffect, useMemo, useRef, useState, useCallback } from 'react';
-import { useNavigate, useParams, useLocation, Link } from 'react-router-dom';
+import { useNavigate, useParams, useLocation, useSearchParams, Link } from 'react-router-dom';
import { ArrowLeft, Sparkles, Clock, Cpu, Zap, Pause, Play, Trash2 } from 'lucide-react';
import toast from '../components/ui/Toast';
import ConfirmButtonPair from '../components/ui/ConfirmButtonPair';
@@ -33,9 +33,16 @@ export default function CreativeCommissionDetail() {
const navigate = useNavigate();
const location = useLocation();
const { id } = useParams();
+ const [searchParams] = useSearchParams();
+ // The run this page was deep-linked to (a scheduled-run notification carries
+ // `?run=<runId>`), so the gallery can focus that render rather than whatever is
+ // newest by the time the user opens it.
+ const focusRunId = searchParams.get('run');
const [commission, setCommission] = useState(null);
const [loading, setLoading] = useState(true);
const [notFound, setNotFound] = useState(false);
+ const [loadError, setLoadError] = useState(null);
+ const [reloadNonce, setReloadNonce] = useState(0);
const [form, setForm] = useState(() => toForm({}));
const [saving, setSaving] = useState(false);
const [running, setRunning] = useState(false);
@@ -45,7 +52,8 @@ export default function CreativeCommissionDetail() {
// Load (and refresh) the deep-linked commission. `location.key` is a dep so a
// notification deep link to THIS already-open page (a same-path push) still
- // refetches and pulls in a just-fired run.
+ // refetches and pulls in a just-fired run. `reloadNonce` lets the error-state
+ // Retry button re-run the load.
useEffect(() => {
let cancelled = false;
setLoading(true);
@@ -54,11 +62,19 @@ export default function CreativeCommissionDetail() {
if (cancelled) return;
setCommission(fresh);
setNotFound(false);
+ setLoadError(null);
+ })
+ .catch((err) => {
+ if (cancelled) return;
+ // Only a real 404 means the commission is gone. A transient failure
+ // (network, 5xx, auth) must NOT be misreported as "deleted" — surface it
+ // as a retryable error instead (absent-vs-unreachable, per CLAUDE.md).
+ if (err?.status === 404) { setNotFound(true); setLoadError(null); }
+ else setLoadError(err?.message || 'Failed to load commission');
})
- .catch(() => { if (!cancelled) setNotFound(true); })
.finally(() => { if (!cancelled) setLoading(false); });
return () => { cancelled = true; };
- }, [id, location.key]);
+ }, [id, location.key, reloadNonce]);
// Sync the form to the loaded record ONLY when the target id first resolves —
// never on the in-place record swaps that rating / Run Now / save trigger, or
@@ -175,11 +191,11 @@ export default function CreativeCommissionDetail() {
}
};
- if (loading) {
+ if (loading && !commission) {
return <div className="max-w-6xl mx-auto text-gray-500 text-sm">Loading…</div>;
}
- if (notFound || !commission) {
+ if (notFound) {
return (
<div className="max-w-6xl mx-auto text-center py-16">
<p className="text-gray-300 mb-3">That commission no longer exists.</p>
@@ -190,6 +206,28 @@ export default function CreativeCommissionDetail() {
);
}
+ // A transient load failure (network / 5xx / auth) with no cached record — offer
+ // a retry rather than claiming the commission was deleted.
+ if (!commission) {
+ return (
+ <div className="max-w-6xl mx-auto text-center py-16">
+ <p className="text-gray-300 mb-1">Couldn’t load this commission.</p>
+ <p className="text-gray-500 text-sm mb-4">{loadError || 'Please try again.'}</p>
+ <div className="flex items-center justify-center gap-2">
+ <button
+ onClick={() => setReloadNonce((n) => n + 1)}
+ className="inline-flex items-center gap-2 bg-port-accent text-white px-3 py-1.5 rounded text-sm"
+ >
+ Retry
+ </button>
+ <Link to="/creative-commission" className="inline-flex items-center gap-2 text-gray-400 hover:text-gray-200 px-3 py-1.5 text-sm">
+ <ArrowLeft className="w-4 h-4" /> Back to commissions
+ </Link>
+ </div>
+ </div>
+ );
+ }
+
return (
<div className="max-w-6xl mx-auto space-y-6">
{/* Header */}
@@ -267,6 +305,7 @@ export default function CreativeCommissionDetail() {
feedback={commission.feedback}
projectsById={projectsById}
projectsLoading={projectsLoading}
+ focusRunId={focusRunId}
onRate={handleRate}
/>
</section>
diff --git a/server/services/creativeCommissions/surface.js b/server/services/creativeCommissions/surface.js
index 86edf0d500..b01b102039 100644
--- a/server/services/creativeCommissions/surface.js
+++ b/server/services/creativeCommissions/surface.js
@@ -36,7 +36,13 @@
*/
export async function surfaceCommissionRun(commission, run) {
if (!commission?.id || !run) return;
- const link = `/creative-commission/${encodeURIComponent(commission.id)}`;
+ // Scope the deep link to THIS run (`?run=<runId>`) so the detail page focuses
+ // the render this notification announced — the gallery is newest-first, so
+ // without the param a later run would have pushed the announced render down by
+ // the time the user opens it.
+ const link = run.id
+ ? `/creative-commission/${encodeURIComponent(commission.id)}?run=${encodeURIComponent(run.id)}`
+ : `/creative-commission/${encodeURIComponent(commission.id)}`;
const ability = commission.targetAbility || 'video';
const name = commission.name || 'Commission';
diff --git a/server/services/creativeCommissions/surface.test.js b/server/services/creativeCommissions/surface.test.js
index 3b83503f94..a92b2f1a66 100644
--- a/server/services/creativeCommissions/surface.test.js
+++ b/server/services/creativeCommissions/surface.test.js
@@ -21,7 +21,7 @@ describe('surfaceCommissionRun', () => {
await surfaceCommissionRun(commission, run);
expect(addNotificationMock).toHaveBeenCalledWith(expect.objectContaining({
type: 'creative_commission',
- link: '/creative-commission/commission-1',
+ link: '/creative-commission/commission-1?run=run-A',
metadata: expect.objectContaining({ commissionId: 'commission-1', runId: 'run-A', projectId: 'cd-1' }),
}));
});