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): re-assert the in-flight-import switch guard on URL nav
[._.]/ Adam Eivyb31a709ab073
diff --git a/client/src/pages/MusicVideo.jsx b/client/src/pages/MusicVideo.jsxindex f8101891b2..5eb0a9b275 100644--- a/client/src/pages/MusicVideo.jsx+++ b/client/src/pages/MusicVideo.jsx@@ -94,6 +94,11 @@ export default function MusicVideo() {const [arranging, setArranging] = useState(false);const [planning, setPlanning] = useState(false);const [form, setForm] = useState({ name: '', mode: 'director', trackId: '' });+ // The project a detail-view YouTube import is bound to (captured at kickoff).+ // The import's shared UI slot (progress button + disabled track controls)+ // belongs to this project; it backstops the URL-nav guard below so a deep+ // link / Back / ⌘K can't strand that slot's UI against another project.+ const [ytEditProjectId, setYtEditProjectId] = useState(null);const selected = projects.find((p) => p.id === selectedId) || null;// YouTube audio import (#1945): paste a URL, PortOS downloads + extracts the@@ -134,6 +139,24 @@ export default function MusicVideo() {}navigate(id ? `/media/music-video/${id}` : '/media/music-video');};+ // Drop the binding once the import settles (or is cancelled) so the backstop+ // below stops guarding a project the user is free to leave again.+ useEffect(() => { if (!ytImportEdit.active) setYtEditProjectId(null); }, [ytImportEdit.active]);+ // `selectProject` blocks project switches from the list buttons while an+ // import is in flight, but URL-driven selection (deep link, browser Back/+ // Forward, ⌘K / voice nav) changes `selectedId` without going through it. Re-+ // assert the same invariant here: while a detail-view import runs, bounce any+ // navigation away from its bound project back (replace, so history isn't+ // polluted). The import itself keeps running and still attaches to its bound+ // project (useYoutubeTrackImport captures the target at kickoff) — this only+ // keeps the shared progress UI from misattributing to another project.+ useEffect(() => {+ if (!ytImportEdit.active || !ytEditProjectId) return;+ if (routeProjectId !== ytEditProjectId) {+ toast.error('Finish or cancel the in-progress YouTube import before switching projects');+ navigate(`/media/music-video/${ytEditProjectId}`, { replace: true });+ }+ }, [routeProjectId, ytImportEdit.active, ytEditProjectId, navigate]);// Merge ONLY a scene's referenceImageId via a functional update so a render// that resolves after the user edited the board can't clobber those edits with// a stale project snapshot. Shared by the socket handler and the synchronous@@ -620,6 +643,7 @@ export default function MusicVideo() {toast.error('Wait for the current render to finish before changing the track');return;}+ setYtEditProjectId(selected.id);ytImportEdit.start(ytUrlEdit, selected.id);}}compactdiff --git a/client/src/pages/MusicVideo.test.jsx b/client/src/pages/MusicVideo.test.jsxindex 4d819095b2..87d80dee4e 100644--- a/client/src/pages/MusicVideo.test.jsx+++ b/client/src/pages/MusicVideo.test.jsx@@ -4,7 +4,7 @@*/import { describe, it, expect, vi, beforeEach } from 'vitest';import { render, screen, waitFor, fireEvent, within } from '@testing-library/react';-import { MemoryRouter, Routes, Route } from 'react-router-dom';+import { MemoryRouter, Routes, Route, useNavigate, useLocation } from 'react-router-dom';import toast from '../components/ui/Toast';const PROJECT_WITH_CLIP = {@@ -107,6 +107,28 @@ const openProject = async (project) => {fireEvent.click(btn);};+// Probes/harness for the URL-nav backstop test: a location readout plus a+// button that navigates via the router (standing in for a deep link / browser+// Back / ⌘K jump, which bypass the in-app selectProject guard).+function LocationProbe() {+ const loc = useLocation();+ return <div data-testid="loc">{loc.pathname}</div>;+}+function NavTo({ to }) {+ const navigate = useNavigate();+ return <button onClick={() => navigate(to)}>{`go-${to}`}</button>;+}+const renderMVWithNav = (to) => render(+ <MemoryRouter initialEntries={['/media/music-video']}>+ <LocationProbe />+ <NavTo to={to} />+ <Routes>+ <Route path="/media/music-video" element={<MusicVideo />} />+ <Route path="/media/music-video/:projectId" element={<MusicVideo />} />+ </Routes>+ </MemoryRouter>,+);+beforeEach(() => {vi.clearAllMocks();sseState.latest = null;@@ -251,6 +273,26 @@ describe('MusicVideo YouTube audio import (#1945)', () => {expect(listBtnA).toHaveClass('border-port-accent');});+ it('bounces URL-driven navigation (deep link / Back / ⌘K) away from a project with an in-flight import back to it', async () => {+ listMusicVideoProjects.mockResolvedValue([PROJECT_NO_CLIP]); // mv-2+ renderMVWithNav('/media/music-video/mv-3');+ // Open mv-2 and start its detail-view import.+ fireEvent.click(await screen.findByRole('button', { name: new RegExp(PROJECT_NO_CLIP.name) }));+ await waitFor(() => expect(screen.getByTestId('loc').textContent).toBe('/media/music-video/mv-2'));+ const editInput = screen.getAllByPlaceholderText(/Import audio from a YouTube URL/i)+ .find((el) => el.id !== 'mv-yt-create');+ fireEvent.change(editInput, { target: { value: 'https://youtu.be/xyz' } });+ fireEvent.click(within(editInput.closest('div')).getByRole('button', { name: /Import/i }));+ await waitFor(() => expect(importTrackFromYoutube).toHaveBeenCalled());++ // A router-driven jump to another project (not via the list buttons, so it+ // bypasses selectProject's guard) must be bounced back to the import's+ // project with the same guard message.+ fireEvent.click(screen.getByRole('button', { name: 'go-/media/music-video/mv-3' }));+ await waitFor(() => expect(toast.error).toHaveBeenCalledWith(expect.stringMatching(/before switching projects/i)));+ await waitFor(() => expect(screen.getByTestId('loc').textContent).toBe('/media/music-video/mv-2'));+ });+it('blocks deleting the selected project while its import is in flight', async () => {await openProject(PROJECT_NO_CLIP);const editInput = screen.getAllByPlaceholderText(/Import audio from a YouTube URL/i)