Skip to content

AI media harness for planning, generating, and editing locally

TypeScript

Select default text encoder on its card

Bitti03bfc954851e
diff --git a/src/components/H3ComponentSettings.test.tsx b/src/components/H3ComponentSettings.test.tsx
index e6d40bf..d279231 100644
--- a/src/components/H3ComponentSettings.test.tsx
+++ b/src/components/H3ComponentSettings.test.tsx
@@ -49,18 +49,25 @@ it("creates named audio and video VAEs and persists edits", async () => {
it("selects a default text encoder for every H3 generator and keeps other families unchanged", async () => {
open();
+ const library = loadGeneratorTemplateSettings().h3Components!;
+ const previousDefault = library.templates.find((entry) => entry.id === library.defaultTextEncoderId)!;
+ expect(screen.queryByRole("combobox", { name: "Default Text Encoder" })).not.toBeInTheDocument();
+ expect(screen.queryByText("Default Text Encoder")).not.toBeInTheDocument();
+ expect(screen.queryByRole("button", { name: `Set ${previousDefault.name} as default` })).not.toBeInTheDocument();
const mossBefore = loadGeneratorTemplateSettings().templates.find((entry) => entry.modelType === "moss")!.paths.textEncoder;
fireEvent.click(screen.getByRole("button", { name: "New text encoder" }));
fireEvent.change(screen.getByRole("textbox", { name: "Text encoder name" }), { target: { value: "My encoder" } });
fireEvent.change(screen.getByRole("textbox", { name: "Weight path or URL" }), { target: { value: "D:/encoder.safetensors" } });
fireEvent.click(screen.getByRole("button", { name: "Save" }));
await waitFor(() => expect(screen.getByRole("button", { name: "Edit My encoder text encoder" })).toBeInTheDocument());
- pick("Default Text Encoder", "My encoder");
+ fireEvent.click(screen.getByRole("button", { name: "Set My encoder as default" }));
await waitFor(() => {
const settings = loadGeneratorTemplateSettings();
expect(settings.templates.filter((entry) => entry.modelType === "minimax-h3").every((entry) => entry.paths.textEncoder === "D:/encoder.safetensors")).toBe(true);
expect(settings.templates.find((entry) => entry.modelType === "moss")?.paths.textEncoder).toBe(mossBefore);
});
+ expect(screen.queryByRole("button", { name: "Set My encoder as default" })).not.toBeInTheDocument();
+ expect(screen.getByRole("button", { name: `Set ${previousDefault.name} as default` })).toBeInTheDocument();
});
it("preserves downloaded paths when a template is renamed during a download", async () => {
diff --git a/src/components/H3ComponentSettings.tsx b/src/components/H3ComponentSettings.tsx
index 4f0dbd7..45a1fe7 100644
--- a/src/components/H3ComponentSettings.tsx
+++ b/src/components/H3ComponentSettings.tsx
@@ -20,19 +20,16 @@ export function H3ComponentSettings({ settings, desktop }: { settings: Generator
const current = loadGeneratorTemplateSettings();
saveGeneratorTemplateSettings({ ...current, h3Components: { ...current.h3Components!, templates: current.h3Components!.templates.filter((entry) => entry.id !== id) } });
};
+ const makeDefault = (defaultTextEncoderId: string) => {
+ const current = loadGeneratorTemplateSettings();
+ saveGeneratorTemplateSettings({ ...current, h3Components: { ...current.h3Components!, defaultTextEncoderId } });
+ };
return <>
{([false, true] as const).map((encoders) => <SettingsGroup key={String(encoders)} heading={encoders ? "Text Encoders" : "VAEs"}>
<SettingsCard icon={<Add20 />} header={encoders ? "Add a text encoder" : "Add a VAE"}
description={encoders ? "The default text encoder is used whenever MiniMax H3 needs one. Missing files download with generators." : "Name video and audio VAEs, then select them in your generators."}>
<button type="button" className="secondary-button" onClick={() => add(encoders ? "textEncoder" : "video")}>{encoders ? "New text encoder" : "New VAE"}</button>
</SettingsCard>
- {encoders && <SettingsCard icon={<TextFile20 />} header="Default Text Encoder">
- <ComboBox aria-label="Default Text Encoder" value={library.defaultTextEncoderId} options={library.templates.filter((entry) => entry.type === "textEncoder").map((entry) => ({ value: entry.id, label: entry.name }))}
- onChange={(defaultTextEncoderId) => {
- const current = loadGeneratorTemplateSettings();
- saveGeneratorTemplateSettings({ ...current, h3Components: { ...current.h3Components!, defaultTextEncoderId } });
- }} />
- </SettingsCard>}
<div className="settings-card-list" role="list" aria-label={encoders ? "Text Encoders" : "VAEs"}>
{library.templates.filter((entry) => (entry.type === "textEncoder") === encoders).map((entry) => {
const active = download?.active && download.h3ComponentId === entry.id;
@@ -42,6 +39,7 @@ export function H3ComponentSettings({ settings, desktop }: { settings: Generator
openLabel={`Edit ${entry.name} ${encoders ? "text encoder" : "VAE"}`} onOpen={() => setEditing(entry)}
description={waiting ? "Queued for download" : active ? "Downloading…" : `${encoders ? entry.id === library.defaultTextEncoderId ? "Used by default" : "Text encoder" : entry.type === "video" ? "Video" : "Audio"} · ${ready ? "Available" : "Download required"}`}
actions={<>
+ {encoders && entry.id !== library.defaultTextEncoderId && <button type="button" className="secondary-button" aria-label={`Set ${entry.name} as default`} onClick={() => makeDefault(entry.id)}>Set as default</button>}
{!ready && <button type="button" className="icon-button" aria-label={`Download ${entry.name}`} disabled={!desktop || active || waiting || !entry.sources.length} onClick={() => void downloadH3Component(entry.id)}><Download16 /></button>}
<button type="button" className="icon-button" aria-label={`Remove ${entry.name} template`} data-tooltip={used(entry) ? "This template is in use" : "Remove template"}
disabled={used(entry) || Boolean(download?.active) || waiting} onClick={() => remove(entry.id)}><Delete16 /></button>