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: gate Image Gen implicit submit on the backend probe (#5671)

Adam Eivyb71ed5122e13
diff --git a/client/src/pages/ImageGen.jsx b/client/src/pages/ImageGen.jsx
index 438a5a1f73..a1edde672a 100644
--- a/client/src/pages/ImageGen.jsx
+++ b/client/src/pages/ImageGen.jsx
@@ -983,6 +983,11 @@ export default function ImageGen() {
// fires onSubmit — gate here too so an edit-only model without a source image
// (or codex text-to-image with no prompt) hits the inline hint, not a 400 toast.
if (editImageMissing || cloudNeedsPrompt) return;
+ // Same reason, for the backend probe: the form stays typable while the status
+ // pill is still checking, so an implicit submit must not dispatch against a
+ // backend we haven't confirmed. A remote target runs on the peer, so the
+ // LOCAL probe result doesn't gate it — mirror the submit button exactly.
+ if (statusLoading || (!remoteTargetActive && notConnected)) return;
// The button reading is as old as the last render and a capacity window
// expires on the clock, so an enabled button can already be pointing at a
// lapsed peer. Re-derive here and say so, rather than letting the server
diff --git a/client/src/pages/ImageGen.probeGating.test.jsx b/client/src/pages/ImageGen.probeGating.test.jsx
index 23f3644c05..1883e2d05e 100644
--- a/client/src/pages/ImageGen.probeGating.test.jsx
+++ b/client/src/pages/ImageGen.probeGating.test.jsx
@@ -1,17 +1,17 @@
import { beforeEach, describe, expect, it, vi } from 'vitest';
-import { act, render, screen, waitFor } from '@testing-library/react';
+import { act, fireEvent, render, screen, waitFor } from '@testing-library/react';
import { MemoryRouter } from 'react-router';
const MODEL = { id: 'dev', name: 'FLUX.1 Dev', runner: 'mflux', steps: 20, guidance: 3.5 };
// The backend probe is held open on purpose: an unconfigured `external` SD API
// URL times out, and that window used to grey out the whole form.
-const state = vi.hoisted(() => ({ resolveStatus: null, statusPromise: null }));
+const state = vi.hoisted(() => ({ resolveStatus: null, statusPromise: null, generateImage: vi.fn() }));
vi.mock('../services/api', () => ({
getInstances: vi.fn(async () => ({ peers: [] })),
getImageGenStatus: vi.fn(() => state.statusPromise),
- generateImage: vi.fn(async () => ({ jobId: 'job-1' })),
+ generateImage: (...args) => state.generateImage(...args),
generateImageMultipart: vi.fn(async () => ({})),
listImageModels: vi.fn(async () => [MODEL]),
listLorasFull: vi.fn(async () => []),
@@ -82,6 +82,7 @@ const mount = async () => {
describe('ImageGen backend-probe gating', () => {
beforeEach(() => {
+ state.generateImage.mockReset().mockResolvedValue({ jobId: 'job-1' });
state.statusPromise = new Promise((resolve) => { state.resolveStatus = resolve; });
});
@@ -108,4 +109,17 @@ describe('ImageGen backend-probe gating', () => {
expect(screen.getByLabelText('Prompt')).not.toBeDisabled();
expect(screen.getByLabelText('Negative Prompt')).not.toBeDisabled();
});
+
+ // A live form has a live implicit submit: Enter inside a number input fires
+ // onSubmit even when the default button is disabled, so the handler carries
+ // the same probe gate the button does.
+ it('refuses an implicit submit fired while the probe is still in flight', async () => {
+ await mount();
+
+ const prompt = await screen.findByLabelText('Prompt');
+ fireEvent.change(prompt, { target: { value: 'a lighthouse at dusk' } });
+ await act(async () => { fireEvent.submit(prompt.closest('form')); });
+
+ expect(state.generateImage).not.toHaveBeenCalled();
+ });
});