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: reset in-flight gen/view state on every selection change (#2025)

Adam Eivya37af8bf8c7a
diff --git a/client/src/components/music/AlbumsManager.jsx b/client/src/components/music/AlbumsManager.jsx
index bbd418cbda..3dcc78d480 100644
--- a/client/src/components/music/AlbumsManager.jsx
+++ b/client/src/components/music/AlbumsManager.jsx
@@ -126,23 +126,20 @@ export default function AlbumsManager() {
const startCreate = () => navigate('/music/albums/new');
// Hydrate the editor form from the URL-selected album. Keyed on the id so a
- // list refresh doesn't clobber the open form (see Authors.jsx for the pattern).
+ // list refresh doesn't clobber the open form; resets run for every selection
+ // change (incl. idle / not-found) so a stray render can't land on the previous
+ // album (see Authors.jsx for the base pattern).
const hydratedRef = useRef(null);
+ const selectionKey = id ?? null;
useEffect(() => {
if (loading) return;
- if (hydratedRef.current === id) return;
- if (isCreate) {
- setForm(emptyForm());
- } else if (selected) {
- setForm(formFromAlbum(selected));
- } else {
- hydratedRef.current = id || null;
- return;
- }
- hydratedRef.current = id;
+ if (hydratedRef.current === selectionKey) return;
+ hydratedRef.current = selectionKey;
setConfirmDelete(false);
clearGeneration();
- }, [id, isCreate, selected, loading]);
+ if (isCreate) setForm(emptyForm());
+ else if (selected) setForm(formFromAlbum(selected));
+ }, [selectionKey, isCreate, selected, loading]);
const handleGenerateCover = async () => {
if (isGenerating || uploadingCover) return;
diff --git a/client/src/components/music/ArtistsManager.jsx b/client/src/components/music/ArtistsManager.jsx
index 1bd1722507..96b25e1a1e 100644
--- a/client/src/components/music/ArtistsManager.jsx
+++ b/client/src/components/music/ArtistsManager.jsx
@@ -180,23 +180,20 @@ export default function ArtistsManager() {
const startCreate = () => navigate('/music/artists/new');
// Hydrate the editor form from the URL-selected artist. Keyed on the id so a
- // list refresh doesn't clobber the open form (see Authors.jsx for the pattern).
+ // list refresh doesn't clobber the open form; resets run for every selection
+ // change (incl. idle / not-found) so a stray render can't land on the previous
+ // artist (see Authors.jsx for the base pattern).
const hydratedRef = useRef(null);
+ const selectionKey = id ?? null;
useEffect(() => {
if (loading) return;
- if (hydratedRef.current === id) return;
- if (isCreate) {
- setForm(emptyForm());
- } else if (selected) {
- setForm(formFromArtist(selected));
- } else {
- hydratedRef.current = id || null;
- return;
- }
- hydratedRef.current = id;
+ if (hydratedRef.current === selectionKey) return;
+ hydratedRef.current = selectionKey;
setConfirmDelete(false);
clearGeneration();
- }, [id, isCreate, selected, loading]);
+ if (isCreate) setForm(emptyForm());
+ else if (selected) setForm(formFromArtist(selected));
+ }, [selectionKey, isCreate, selected, loading]);
const handleSave = async () => {
const name = form.name.trim();
diff --git a/client/src/components/music/TracksManager.jsx b/client/src/components/music/TracksManager.jsx
index 7700a2c00b..0ca879e29b 100644
--- a/client/src/components/music/TracksManager.jsx
+++ b/client/src/components/music/TracksManager.jsx
@@ -121,25 +121,20 @@ export default function TracksManager() {
// Hydrate the editor form from the URL-selected track. Keyed on the id so a
// list refresh (audio upload, generate, upsertLocal) doesn't clobber the open
// form; `selectedIdRef` is kept in sync so async handlers can still detect a
- // selection change that happened mid-round-trip (see Authors.jsx for the base
- // pattern).
+ // selection change that happened mid-round-trip. Per-track view state is reset
+ // for every selection change (incl. idle / not-found) so a modal/remix left
+ // open can't drive the previous track (see Authors.jsx for the base pattern).
const hydratedRef = useRef(null);
+ const selectionKey = id ?? null;
useEffect(() => {
if (loading) return;
- if (hydratedRef.current === id) return;
- if (isCreate) {
- setForm(emptyForm());
- } else if (selected) {
- setForm(formFromTrack(selected));
- } else {
- hydratedRef.current = id || null;
- selectedIdRef.current = id || null;
- return;
- }
- hydratedRef.current = id;
- selectedIdRef.current = id;
+ if (hydratedRef.current === selectionKey) return;
+ hydratedRef.current = selectionKey;
+ selectedIdRef.current = selectionKey;
resetTrackViewState();
- }, [id, isCreate, selected, loading]);
+ if (isCreate) setForm(emptyForm());
+ else if (selected) setForm(formFromTrack(selected));
+ }, [selectionKey, isCreate, selected, loading]);
const upsertLocal = (track) => {
setTracks((prev) => {
diff --git a/client/src/pages/Authors.jsx b/client/src/pages/Authors.jsx
index 49468df145..d7a757c0ef 100644
--- a/client/src/pages/Authors.jsx
+++ b/client/src/pages/Authors.jsx
@@ -203,24 +203,22 @@ export default function Authors() {
// Hydrate the editor form from the URL-selected author. Keyed on the id so a
// list refresh (create/update/delete mutating `authors`) doesn't clobber the
- // open form; `hydratedRef` tracks which selection is already loaded.
+ // open form; `hydratedRef` tracks which selection is already loaded. Resets
+ // (confirm-delete + any in-flight generation) run for EVERY selection change —
+ // including navigating to the idle index or a stale id — so a stray render
+ // can't land on the previous author after you've moved on.
const hydratedRef = useRef(null);
+ const selectionKey = authorId ?? null;
useEffect(() => {
if (loading) return;
- if (hydratedRef.current === authorId) return;
- if (isCreate) {
- setForm(emptyForm());
- } else if (selected) {
- setForm(formFromAuthor(selected));
- } else {
- // No selection or unknown id — don't hydrate (idle / not-found fallback).
- hydratedRef.current = authorId || null;
- return;
- }
- hydratedRef.current = authorId;
+ if (hydratedRef.current === selectionKey) return;
+ hydratedRef.current = selectionKey;
setConfirmDelete(false);
clearGeneration();
- }, [authorId, isCreate, selected, loading]);
+ if (isCreate) setForm(emptyForm());
+ else if (selected) setForm(formFromAuthor(selected));
+ // else: idle / not-found — leave the form; the fallback UI handles it.
+ }, [selectionKey, isCreate, selected, loading]);
const handleSave = async () => {
const name = form.name.trim();