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: hold Generate while a Remix handoff is still resolving its record

[._.]/ Adam Eivyc78045ecf7c8
diff --git a/client/src/hooks/useMediaPreviewActions.test.jsx b/client/src/hooks/useMediaPreviewActions.test.jsx
index a41716aba2..13917db643 100644
--- a/client/src/hooks/useMediaPreviewActions.test.jsx
+++ b/client/src/hooks/useMediaPreviewActions.test.jsx
@@ -48,13 +48,6 @@ describe('useMediaPreviewActions.handleRemix', () => {
expect([...params.keys()]).toEqual(['remix']);
});
- it('percent-encodes a record id so an id with URL punctuation survives the handoff', () => {
- const { result } = renderHook(() => useMediaPreviewActions());
- result.current.handleRemix({ kind: 'video', id: 'vid 1&x=2' });
- const { params } = parseNav();
- expect(params.get('remix')).toBe('vid 1&x=2');
- });
-
// Records that never got an id (and links already out in the wild) keep the
// legacy field bundle. It is deliberately not extended with new fields.
it('falls back to the legacy field bundle for a video with no record id', () => {
diff --git a/client/src/pages/VideoGen.jsx b/client/src/pages/VideoGen.jsx
index b3709072ea..4be1408392 100644
--- a/client/src/pages/VideoGen.jsx
+++ b/client/src/pages/VideoGen.jsx
@@ -452,6 +452,14 @@ export default function VideoGen() {
// otherwise replay it over a form the user has been editing the whole time.
const remixHandoffId = searchParams.get('remix');
const settledRemixHandoffRef = useRef(null);
+ // The restore waits on a history round trip, so unlike the old URL bundle
+ // (applied synchronously on mount) there is a window in which the form still
+ // holds the page defaults and is about to be replaced wholesale. Announce it
+ // and hold Generate: rendering here would spend GPU time on the defaults while
+ // the user believes they are looking at the clip's settings.
+ // Only Retry puts `historyLoad` back to 'loading' after it has settled, and
+ // that is exactly a re-pending handoff — so the two conditions are enough.
+ const remixHandoffPending = !!remixHandoffId && historyLoad === 'loading';
// 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);
@@ -970,7 +978,7 @@ export default function VideoGen() {
// A federated render answers to the PEER’s readiness, not to this machine’s
// runtime gates — none of the local probes below describe the hardware it
// will actually run on.
- const canEnqueue = prompt.trim() && (remoteTarget.isRemote
+ const canEnqueue = prompt.trim() && !remixHandoffPending && (remoteTarget.isRemote
? remoteBlocked === null
: (isGrok || isFal || isReactor || (!notConnected && !extendModeBlocked
&& !a2vModeBlocked && !icLoraModeBlocked && !byovGateBlocked
@@ -1123,6 +1131,11 @@ export default function VideoGen() {
would be the worst outcome here: the user pressed Remix, landed on
a form holding whatever it held before, and would start a render
with the wrong settings believing they were the clip's. */}
+ {remixHandoffPending && (
+ <p role="status" className="rounded-lg border border-port-border bg-port-bg px-3 py-2 text-xs text-gray-400">
+ Restoring this render's settings — the form below is about to be replaced with them.
+ </p>
+ )}
{remixHandoffProblem && (
<div
role="status"
diff --git a/client/src/pages/VideoGen.remix.test.jsx b/client/src/pages/VideoGen.remix.test.jsx
index 69a3287c93..e9ba9c988e 100644
--- a/client/src/pages/VideoGen.remix.test.jsx
+++ b/client/src/pages/VideoGen.remix.test.jsx
@@ -122,6 +122,11 @@ describe('VideoGen cross-page Remix handoff', () => {
state.attach.mockResolvedValue({ filename: 'example.mp4' });
state.availableLoras = [LORA];
state.listVideoHistory.mockResolvedValue([RECORD, LEGACY_RECORD]);
+ // Every weight cached — a ready install. Without this the Generate button
+ // is disabled by the weights gate no matter what, which would let the
+ // "held while the handoff is pending" assertion pass for the wrong reason.
+ state.getModelStatus = () => ({ cached: true });
+ state.modelDownloadExtra = { textEncoder: { cached: true } };
});
it('restores the same settings from a History handoff as from the in-page gallery', async () => {
@@ -198,9 +203,18 @@ describe('VideoGen cross-page Remix handoff', () => {
expect(screen.queryByText(/no longer in your history/)).toBeNull();
expect(screen.queryByText(/Couldn't load your render history/)).toBeNull();
+ // It IS announced, and Generate is held: the form still shows the page
+ // defaults and is about to be replaced wholesale, so a render started here
+ // would spend GPU time on the wrong settings under the clip's name.
+ screen.getByText(/Restoring this render's settings/);
+ fireEvent.change(screen.getByLabelText('Prompt'), { target: { value: 'anything at all' } });
+ expect(screen.getByRole('button', { name: /Generate/ })).toBeDisabled();
+
await act(async () => { settleHistory([RECORD]); });
await waitFor(() => expect(screen.getByLabelText('Prompt')).toHaveValue(RECORD.prompt));
expect(screen.queryByText(/no longer in your history/)).toBeNull();
+ expect(screen.queryByText(/Restoring this render's settings/)).toBeNull();
+ expect(screen.getByRole('button', { name: /Generate/ })).toBeEnabled();
});
it('offers a retry when the history fetch fails, and restores once it succeeds', async () => {
diff --git a/client/src/test/videoGenPageMocks.jsx b/client/src/test/videoGenPageMocks.jsx
index 3cdf6e8b3a..946a27b33d 100644
--- a/client/src/test/videoGenPageMocks.jsx
+++ b/client/src/test/videoGenPageMocks.jsx
@@ -53,6 +53,8 @@ export const state = {
activeJob: null,
/** Cache-status entries keyed by download id, read by the default `getModelStatus`. */
modelStatuses: {},
+ /** `useModelDownloadStatus().extra` — carries the SHARED text encoder's cache status. */
+ modelDownloadExtra: {},
/** Override to answer ids the map cannot (e.g. the `__text_encoder_option__:` prefix). */
getModelStatus: (id) => state.modelStatuses[id] ?? null,
start: vi.fn(),
@@ -97,6 +99,7 @@ export function resetVideoGenMockState() {
state.peers = [];
state.activeJob = null;
state.modelStatuses = {};
+ state.modelDownloadExtra = {};
state.getModelStatus = (id) => state.modelStatuses[id] ?? null;
state.queuedModelId = null;
state.runtimeInstallComplete = null;
@@ -197,7 +200,7 @@ vi.mock('../hooks/useModelDownloadStatus', () => ({
TEXT_ENCODER_DOWNLOAD_ID: '__text_encoder__',
textEncoderDownloadId: (id) => `__text_encoder_option__:${id}`,
useModelDownloadStatus: () => ({
- extra: {},
+ extra: state.modelDownloadExtra,
loading: false,
statusError: null,
activeModelId: null,