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
address review (codex): scope progress to active ingest
[._.]/ Adam Eivy3dfc62880717
diff --git a/client/src/components/QuickBrainCapture.test.jsx b/client/src/components/QuickBrainCapture.test.jsxindex 7da5760698..fca498852d 100644--- a/client/src/components/QuickBrainCapture.test.jsx+++ b/client/src/components/QuickBrainCapture.test.jsx@@ -23,8 +23,8 @@ vi.mock('./ui/Toast', () => ({}));// jsdom has no EventSource, and once a kickoff resolves the real-// useSseProgress subscribes to one. A do-nothing stub keeps the hook wiring-// under test without inventing a fake transport — no test here drives frames.+// useSseProgress subscribes to one. This controllable stub lets the accessibility+// coverage drive realistic progress frames without opening a network transport.class StubEventSource {static CLOSED = 2;static instances = [];@@ -34,6 +34,10 @@ class StubEventSource {StubEventSource.instances.push(this);}emit(frame) { this.onmessage?.({ data: JSON.stringify(frame) }); }+ fail() {+ this.readyState = StubEventSource.CLOSED;+ this.onerror?.();+ }close() { this.readyState = StubEventSource.CLOSED; }}globalThis.EventSource = StubEventSource;@@ -372,6 +376,17 @@ describe('QuickBrainCapture', () => {act(() => StubEventSource.instances[0].emit({ type: 'metadata', title: 'Example Video' }));await waitFor(() => expect(progress).toHaveAttribute('aria-valuenow', '48'));expect(screen.getByText('video…')).toBeInTheDocument();++ act(() => StubEventSource.instances[0].fail());+ await waitFor(() => expect(screen.queryByRole('progressbar')).not.toBeInTheDocument());++ startYoutubeIngest.mockResolvedValueOnce({ jobId: 'job-2' });+ type(YT);+ fireEvent.click(screen.getByLabelText('Capture'));++ const retryProgress = await screen.findByRole('progressbar', { name: 'YouTube video ingest progress' });+ expect(retryProgress).toHaveAttribute('aria-valuenow', '0');+ expect(screen.getByText('starting…')).toHaveAttribute('aria-live', 'polite');});it('does not fetch ingest settings until a YouTube URL is typed', () => {diff --git a/client/src/hooks/useSseJobSlot.js b/client/src/hooks/useSseJobSlot.jsindex 241072e5e1..6a18660558 100644--- a/client/src/hooks/useSseJobSlot.js+++ b/client/src/hooks/useSseJobSlot.js@@ -57,19 +57,20 @@ export default function useSseJobSlot({const [job, setJob] = useState(null); // { jobId, context }const [pending, setPending] = useState(false);const [progress, setProgress] = useState({ percent: 0, stage: null });- const sse = useSseProgress(job ? eventsUrl(job.jobId) : null);+ const jobUrl = job ? eventsUrl(job.jobId) : null;+ const sse = useSseProgress(jobUrl);const latest = sse.latest;// Metadata and warning frames intentionally omit progress fields. Preserve the// last announced values across those sparse frames instead of flashing 0% /// "starting" between real progress updates.useEffect(() => {- if (!job || !latest) return;+ if (!job || !latest || sse.latestUrl !== jobUrl) return;setProgress((prev) => ({percent: Number.isFinite(latest.percent) ? Math.round(latest.percent) : prev.percent,stage: typeof latest.stage === 'string' && latest.stage ? latest.stage : prev.stage,}));- }, [latest, job]);+ }, [latest, job, jobUrl, sse.latestUrl]);useEffect(() => {if (!job || !latest) return;diff --git a/client/src/hooks/useSseProgress.js b/client/src/hooks/useSseProgress.jsindex bd62d16daf..b6678ee02b 100644--- a/client/src/hooks/useSseProgress.js+++ b/client/src/hooks/useSseProgress.js@@ -25,6 +25,7 @@ export const isTerminalSseFrame = (frame) => TERMINAL_TYPES.has(frame?.type);export function useSseProgress(url, { enabled = true } = {}) {const [frames, setFrames] = useState([]);const [latest, setLatest] = useState(null);+ const [latestUrl, setLatestUrl] = useState(null);const [isOpen, setIsOpen] = useState(false);// `closed` flips true when the stream ends for ANY reason — a terminal frame// OR a connection failure/404 (e.g. the server pruned a fast-completing job@@ -42,10 +43,12 @@ export function useSseProgress(url, { enabled = true } = {}) {// subscribe, tearing down the new stream before it can deliver progress.setIsOpen(false);setClosed(false);+ setLatestUrl(null);return undefined;}setFrames([]);setLatest(null);+ setLatestUrl(null);setIsOpen(false);setClosed(false);@@ -62,6 +65,7 @@ export function useSseProgress(url, { enabled = true } = {}) {}setFrames((prev) => [...prev, data]);setLatest(data);+ setLatestUrl(url);if (TERMINAL_TYPES.has(data?.type)) {es.close();setIsOpen(false); // the connection is now closed — keep isOpen honest@@ -85,5 +89,5 @@ export function useSseProgress(url, { enabled = true } = {}) {};}, [url, enabled]);- return { frames, latest, isOpen, closed, close: () => esRef.current?.close() };+ return { frames, latest, latestUrl, isOpen, closed, close: () => esRef.current?.close() };}diff --git a/client/src/hooks/useSseProgress.test.jsx b/client/src/hooks/useSseProgress.test.jsxindex 9a611676de..73de006661 100644--- a/client/src/hooks/useSseProgress.test.jsx+++ b/client/src/hooks/useSseProgress.test.jsx@@ -27,6 +27,7 @@ describe('useSseProgress', () => {});expect(result.current.frames).toHaveLength(2);expect(result.current.latest).toEqual({ type: 'progress', progress: 0.5 });+ expect(result.current.latestUrl).toBe('/x');expect(result.current.closed).toBe(false);});@@ -57,6 +58,7 @@ describe('useSseProgress', () => {rerender({ url: '/b' });expect(result.current.closed).toBe(false);expect(result.current.frames).toHaveLength(0);+ expect(result.current.latestUrl).toBeNull();expect(last().url).toBe('/b');});@@ -73,6 +75,7 @@ describe('useSseProgress', () => {rerender({ url: null });expect(result.current.closed).toBe(false);expect(result.current.latest).toEqual({ type: 'error', error: 'boom' });+ expect(result.current.latestUrl).toBeNull();});it('isTerminalSseFrame matches the terminal set and rejects others', () => {