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 (claude): block deleting the project an in-flight import targets

[._.]/ Adam Eivyc08666fb2e33
diff --git a/client/src/pages/MusicVideo.jsx b/client/src/pages/MusicVideo.jsx
index ebdb6747c0..4c9b087fa0 100644
--- a/client/src/pages/MusicVideo.jsx
+++ b/client/src/pages/MusicVideo.jsx
@@ -184,6 +184,13 @@ export default function MusicVideo() {
};
const handleDelete = (id) => {
+ // Same hazard selectProject guards against: deleting the project an
+ // in-flight edit-surface import targets would still finish server-side
+ // and try to PATCH a now-deleted project.
+ if (ytImportEdit.active && id === selectedId) {
+ toast.error('Finish or cancel the in-progress YouTube import before deleting this project');
+ return;
+ }
deleteMusicVideoProject(id)
.then(() => {
setProjects((prev) => prev.filter((p) => p.id !== id));
diff --git a/client/src/pages/MusicVideo.test.jsx b/client/src/pages/MusicVideo.test.jsx
index 6d46b3e705..8b2d81ddc0 100644
--- a/client/src/pages/MusicVideo.test.jsx
+++ b/client/src/pages/MusicVideo.test.jsx
@@ -70,7 +70,9 @@ vi.mock('../components/ui/Toast', () => ({ default: { success: vi.fn(), error: v
vi.mock('../components/PageHeader', () => ({ default: ({ title }) => <div>{title}</div> }));
import MusicVideo from './MusicVideo.jsx';
-import { listMusicVideoProjects, renderMusicVideoProject, planMusicVideoProject, updateMusicVideoProject } from '../services/apiMusicVideo.js';
+import {
+ listMusicVideoProjects, renderMusicVideoProject, planMusicVideoProject, updateMusicVideoProject, deleteMusicVideoProject,
+} from '../services/apiMusicVideo.js';
import { importTrackFromYoutube, trackImportEventsUrl } from '../services/apiTracks.js';
const PROJECT_ANALYZED = {
@@ -231,4 +233,17 @@ describe('MusicVideo YouTube audio import (#1945)', () => {
expect(toast.error).toHaveBeenCalledWith(expect.stringMatching(/before switching projects/i));
expect(listBtnA).toHaveClass('border-port-accent');
});
+
+ 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)
+ .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());
+
+ fireEvent.click(screen.getByTitle('Delete project'));
+ expect(toast.error).toHaveBeenCalledWith(expect.stringMatching(/before deleting this project/i));
+ expect(deleteMusicVideoProject).not.toHaveBeenCalled();
+ });
});