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
fix: label a Remix-restored LoRA when the library lands after the record
[._.]/ Adam Eivy42213294a388
diff --git a/client/src/hooks/useVideoGenForm.js b/client/src/hooks/useVideoGenForm.jsindex 2799e4b3da..0fb6abbb90 100644--- a/client/src/hooks/useVideoGenForm.js+++ b/client/src/hooks/useVideoGenForm.js@@ -545,6 +545,27 @@ export function useVideoGenForm({[availableLoras, loraFamily],);+ // `applyRemix` resolves each restored LoRA's DISPLAY NAME out of the installed+ // library at apply time, falling back to the raw filename. The cross-page+ // Remix handoff (#6290) can apply before that library has landed — the page+ // fetches the LoRA list and the history list as independent mount effects with+ // no ordering — so re-resolve once it arrives, or the picker sits on+ // `lora-example-v7.safetensors` for the session. Filename and scale (what the+ // payload is built from) are untouched; only the label is filled in.+ useEffect(() => {+ if (!availableLoras.length) return;+ setSelectedLoras((prev) => {+ let changed = false;+ const next = prev.map((selected) => {+ const name = availableLoras.find((l) => l.filename === selected.filename)?.name;+ if (!name || name === selected.name) return selected;+ changed = true;+ return { ...selected, name };+ });+ return changed ? next : prev;+ });+ }, [availableLoras]);+// Installed video LoRAs bucketed by family, regardless of the selected model.// One pass instead of one filter per family, and the source for the// "why is the picker gone" hint below.diff --git a/client/src/pages/VideoGen.jsx b/client/src/pages/VideoGen.jsxindex 486913a26f..b3709072ea 100644--- a/client/src/pages/VideoGen.jsx+++ b/client/src/pages/VideoGen.jsx@@ -439,22 +439,22 @@ export default function VideoGen() {// decode and LoRAs. `history` is the unfiltered load, so a hidden record// resolves too.//- // The ref (not the stripped param) is what makes this one-shot: the strip is- // an async router update, so a completion refresh landing in the same tick- // would otherwise re-apply the handoff over edits the user has since made.- // It records the settled ID rather than a boolean, so a SECOND handoff- // arriving on the same mount is still honored.+ // One ref carries the whole "has this handoff been dealt with?" question, and+ // it holds the handoff ID rather than a boolean, so a SECOND handoff arriving+ // on the same mount is still honored. It is what makes the restore one-shot —+ // not the stripped parameter, which lands on an async router update a+ // completion refresh in the same tick could beat, re-applying the handoff over+ // edits the user has made since.+ //+ // A FAILED fetch settles the handoff too, deliberately: the restore then waits+ // for the explicit Retry (which clears the ref) instead of riding in on the+ // next background refresh, since a render completing minutes later would+ // otherwise replay it over a form the user has been editing the whole time.const remixHandoffId = searchParams.get('remix');const settledRemixHandoffRef = useRef(null);// null while nothing is wrong; otherwise 'error' (the history fetch failed,// retryable) or 'missing' (history loaded and holds no such record).const [remixHandoffProblem, setRemixHandoffProblem] = useState(null);- // The handoff id whose fetch failed. That restore then waits for an explicit- // Retry instead of riding in on the next background refresh: a render- // completing minutes later would otherwise replay it over a form the user has- // been editing since the banner appeared. Holding the ID rather than a flag- // keeps the block on that one handoff — a later one resolves normally.- const [blockedRemixHandoffId, setBlockedRemixHandoffId] = useState(null);const consumeRemixHandoff = useCallback(() => {setSearchParams((prev) => {const next = new URLSearchParams(prev);@@ -463,28 +463,22 @@ export default function VideoGen() {}, { replace: true });}, [setSearchParams]);useEffect(() => {- // The retry-block belongs to ONE handoff. Once the URL moves off it — the- // param was consumed, or another record arrived — it is spent, so the same- // record can be handed over again later and resolve normally.- if (blockedRemixHandoffId && blockedRemixHandoffId !== remixHandoffId) setBlockedRemixHandoffId(null);// No handoff in the URL — including right after this one consumed its own.// Clearing the settled id here is what lets the NEXT handoff through, even// when it names the same record.if (!remixHandoffId) { settledRemixHandoffRef.current = null; return; }- if (settledRemixHandoffRef.current === remixHandoffId || blockedRemixHandoffId === remixHandoffId) return;+ if (settledRemixHandoffRef.current === remixHandoffId) return;// Still fetching: say nothing. Reporting "no such record" here would be a// lie every time the page is opened faster than the history round trip.// Any banner still up belongs to a previous handoff, so it goes.if (historyLoad === 'loading') { setRemixHandoffProblem(null); return; }+ settledRemixHandoffRef.current = remixHandoffId;if (historyLoad === 'error') {- // Keep the param so Retry can resolve it, and leave the handoff unsettled- // so that retry actually re-runs this effect.+ // Keep the param in the URL — Retry resolves this same handoff.setRemixHandoffProblem('error');- setBlockedRemixHandoffId(remixHandoffId);return;}const record = history.find((v) => String(v.id) === remixHandoffId);- settledRemixHandoffRef.current = remixHandoffId;if (record) {applyRemix(record);setRemixHandoffProblem(null);@@ -492,19 +486,18 @@ export default function VideoGen() {setRemixHandoffProblem('missing');}consumeRemixHandoff();- }, [remixHandoffId, historyLoad, history, blockedRemixHandoffId, applyRemix, consumeRemixHandoff]);+ }, [remixHandoffId, historyLoad, history, applyRemix, consumeRemixHandoff]);// Back to 'loading' first, so a retry that fails again still moves the state// ('loading' → 'error') and re-runs the effect above.const retryRemixHandoff = useCallback(() => {+ settledRemixHandoffRef.current = null;setHistoryLoad('loading');setRemixHandoffProblem(null);- setBlockedRemixHandoffId(null);refreshHistory();}, [refreshHistory]);const dismissRemixHandoff = useCallback(() => {settledRemixHandoffRef.current = remixHandoffId;setRemixHandoffProblem(null);- setBlockedRemixHandoffId(null);consumeRemixHandoff();}, [remixHandoffId, consumeRemixHandoff]);diff --git a/client/src/pages/VideoGen.remix.test.jsx b/client/src/pages/VideoGen.remix.test.jsxindex c9a3e76fe1..69a3287c93 100644--- a/client/src/pages/VideoGen.remix.test.jsx+++ b/client/src/pages/VideoGen.remix.test.jsx@@ -171,6 +171,23 @@ describe('VideoGen cross-page Remix handoff', () => {expect(restored.chunkPrompts).toEqual([]);});+ it('labels a restored LoRA even when the library lands after the record does', async () => {+ // The page fetches history and the LoRA library as independent mount+ // effects. A cross-page Remix restores as soon as HISTORY settles, so on+ // this ordering the names have nothing to resolve against yet — and a+ // one-shot resolve would leave the picker showing the raw filename.+ let settleLoras;+ state.listLorasFull.mockReturnValue(new Promise((resolve) => { settleLoras = resolve; }));+ await renderVideoGenPage(`/media/video?remix=${RECORD.id}`);+ await waitFor(() => expect(screen.getByLabelText('Prompt')).toHaveValue(RECORD.prompt));++ await act(async () => { settleLoras([LORA]); });++ await waitFor(() => expect(state.loraPicker?.selected).toEqual([+ { filename: LORA.filename, name: LORA.name, scale: 0.7 },+ ]));+ });+it('says nothing about a missing record while the history fetch is still in flight', async () => {let settleHistory;state.listVideoHistory.mockReturnValue(new Promise((resolve) => { settleHistory = resolve; }));diff --git a/client/src/test/videoGenPageMocks.jsx b/client/src/test/videoGenPageMocks.jsxindex cf7666554b..3cdf6e8b3a 100644--- a/client/src/test/videoGenPageMocks.jsx+++ b/client/src/test/videoGenPageMocks.jsx@@ -78,8 +78,10 @@ export const state = {galleryProps: null,/** `useMediaCompletionRefresh`'s options, so a suite can fire a completion refresh. */completionRefresh: null,- /** `listLorasFull` — the installed library the LoRA picker resolves names against. */+ /** The library `listLorasFull` resolves to by default; the LoRA picker reads names from it. */availableLoras: [],+ /** `listLorasFull`; a spy so a suite can defer it and land the library AFTER history. */+ listLorasFull: vi.fn(),/*** The mounted router's `navigate`, for a suite that needs a SECOND in-place* navigation — a URL handoff arriving while the page is already mounted,@@ -88,7 +90,7 @@ export const state = {navigate: null,};-const SPIES = ['getVideoGenStatus', 'getVideoGenModelContext', 'generateVideo', 'attach', 'start', 'startWhenIdle', 'repair', 'cancel', 'refresh', 'listVideoHistory'];+const SPIES = ['getVideoGenStatus', 'getVideoGenModelContext', 'generateVideo', 'attach', 'start', 'startWhenIdle', 'repair', 'cancel', 'refresh', 'listVideoHistory', 'listLorasFull'];/** Restore every documented default, including fresh spies. Call it first in `beforeEach`. */export function resetVideoGenMockState() {@@ -108,6 +110,7 @@ export function resetVideoGenMockState() {state.navigate = null;for (const key of SPIES) state[key].mockReset();state.listVideoHistory.mockResolvedValue([]);+ state.listLorasFull.mockImplementation(async () => state.availableLoras);}/** A video model as `GET /api/video-gen/status` reports it. */@@ -182,7 +185,7 @@ vi.mock('../services/api', () => ({getActiveVideoJob: vi.fn(async () => ({ activeJob: state.activeJob })),getSettings: vi.fn(async () => ({ imageGen: { grok: { enabled: false } } })),getVideoGenRuntimeStatus: vi.fn(async () => ({ installed: true, ready: true, current: true })),- listLorasFull: vi.fn(async () => state.availableLoras),+ listLorasFull: (...args) => state.listLorasFull(...args),// The prompt-enhancement controls mount useProviderModels, which fetches the// provider list from a mount effect. Unmocked it throws out of a passive// effect — the tests still pass, but the unhandled rejection fails the run.