refactor(web): two panels on the left, the work on the right
Four panels became three, and the arrangement carries the change: everything that organises or configures is stacked in one narrow column, and the whole of the rest is one surface for looking at images. Collections is a LIST, not a grid of covers — it sits in a narrow column beside the gallery, where two cards per row meant four collections visible. A row is a name, a count, and rename/delete on hover. Create is a dialog rather than an always-present input, and a filter field replaces it in that space, since finding one is the frequent act and making one is not. Selecting a collection now shows it in the GALLERY. It used to replace the list inside its own panel, which meant the selector disappeared the moment it was used, and both panels kept their own copy of one collection's images and disagreed after any edit. `?collection=` is read by the gallery now; the collections hook stopped fetching detail entirely. Deleting asks the question that cannot be undone: keep the images, or delete them too. That needed a server route — DELETE /collections/:id?images=delete — which reads the members BEFORE the collection goes, since deleting it takes the memberships with it. Unchecked by default: the recoverable answer is the one you get by pressing Enter without reading. Providers stopped being a panel. It was a card per provider, each with a key field and three buttons, filling a quarter of the screen for something set once — it is a dropdown at the top of Generate now, listing "adapter · model" with a delete on each, and adding one opens a dialog. The form and the dropdown share one provider list (useProviders); they were two fetches, so adding a provider left the form showing the old models until a reload.
This commit is contained in:
@@ -7,11 +7,15 @@ export const SIZES = ['auto', '1024x1024', '1536x1024', '1024x1536'] as const;
|
||||
export const QUALITIES = ['auto', 'low', 'medium', 'high'] as const;
|
||||
export const BACKGROUNDS = ['auto', 'transparent', 'opaque'] as const;
|
||||
|
||||
export const useGenerateManager = () => {
|
||||
/**
|
||||
* The form. Providers are passed IN rather than fetched here — `useProviders` owns them, because the
|
||||
* dropdown above this form and the model list inside it have to be the same list. They were two
|
||||
* fetches, and adding a provider left the form showing the old models until the page was reloaded.
|
||||
*/
|
||||
export const useGenerateManager = (providers: ProviderStatus[]) => {
|
||||
const client = useAtelierClient();
|
||||
const [, bumpRefresh] = useAtelierRefresh();
|
||||
|
||||
const [providers, setProviders] = useState<ProviderStatus[]>([]);
|
||||
const [model, setModel] = useState('');
|
||||
const [prompt, setPrompt] = useState('');
|
||||
const [n, setN] = useState(1);
|
||||
@@ -23,21 +27,15 @@ export const useGenerateManager = () => {
|
||||
const [running, setRunning] = useState(false);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
|
||||
// Follow the provider list: pick the default's model, and only overwrite a choice the user made if
|
||||
// the provider behind it has gone away.
|
||||
useEffect(() => {
|
||||
client
|
||||
.listProviders()
|
||||
.then((rows) => {
|
||||
setProviders(rows);
|
||||
const usable =
|
||||
rows.find((row) => row.is_default && row.configured && row.enabled) ??
|
||||
rows.find((row) => row.configured && row.enabled);
|
||||
if (usable) setModel(usable.model);
|
||||
})
|
||||
.catch((err: Error) => setError(err.message));
|
||||
// Loaded once on mount — the Providers panel is where they
|
||||
// are managed, and this panel does not need to react to edits made there in real time.
|
||||
const usable = providers.filter((row) => row.configured && row.enabled);
|
||||
if (usable.length === 0) return;
|
||||
if (model && usable.some((row) => row.model === model)) return;
|
||||
setModel((usable.find((row) => row.is_default) ?? usable[0]!).model);
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, []);
|
||||
}, [providers]);
|
||||
|
||||
// Derived in the hook, not in the component.
|
||||
const usableProviders = providers.filter((provider) => provider.configured && provider.enabled);
|
||||
|
||||
Reference in New Issue
Block a user