Skip to content

The open source AI video agent: turns any coding agent into a video agent, with an editor to change anything it makes.

Studio: a refused key says why under its own field (#11)

riverisbuilding70602ab4bef7
diff --git a/.changeset/provider-key-error.md b/.changeset/provider-key-error.md
new file mode 100644
index 0000000..c9fd91a
--- /dev/null
+++ b/.changeset/provider-key-error.md
@@ -0,0 +1,5 @@
+---
+"openfilm": patch
+---
+
+Studio: a key that Settings → Providers refuses says why under its own field, not at the bottom of the list past every provider.
diff --git a/packages/openfilm/studio/ui/src/components/settings/ProvidersSection.tsx b/packages/openfilm/studio/ui/src/components/settings/ProvidersSection.tsx
index 6823136..f7ca1da 100644
--- a/packages/openfilm/studio/ui/src/components/settings/ProvidersSection.tsx
+++ b/packages/openfilm/studio/ui/src/components/settings/ProvidersSection.tsx
@@ -27,7 +27,8 @@ export function ProvidersSection() {
<SettingsGroup footnote={t('settings.providers.keyNote')}>
{rows.map((provider) => <KeyRow key={provider.id} provider={provider} hook={providers} />)}
</SettingsGroup>
- {providers.problem ? <p className={settingsError}>{providers.problem}</p> : null}
+ {/* a key that was refused says why under its own field (KeyRow), not down here past the list */}
+ {providers.problem && !rows.some((p) => p.id === providers.problemFor) ? <p className={settingsError}>{providers.problem}</p> : null}
</SettingsPage>
);
}
@@ -111,6 +112,7 @@ function KeyRow({ provider, hook }: { provider: OwnProvider; hook: ProvidersHook
<SettingsButton variant="quiet" onClick={close}>{t('settings.providers.cancel')}</SettingsButton>
<SettingsButton type="submit" variant="primary" disabled={!draft.trim() || saving}>{t('settings.providers.save')}</SettingsButton>
</div>
+ {hook.problem && hook.problemFor === provider.id ? <p className={settingsError} role="alert">{hook.problem}</p> : null}
{/* the environment has a key for it: connect with that one, nothing to paste */}
{provider.envKey ? (
<button type="button" disabled={saving} onClick={() => void hook.useEnvKey(provider.id).then((ok) => { if (ok) close(); })} className={`${settingsLink} self-start text-[14.5px]`}>
diff --git a/packages/openfilm/studio/ui/src/i18n/en.ts b/packages/openfilm/studio/ui/src/i18n/en.ts
index 392bed1..d5a82c4 100644
--- a/packages/openfilm/studio/ui/src/i18n/en.ts
+++ b/packages/openfilm/studio/ui/src/i18n/en.ts
@@ -1390,7 +1390,7 @@ export const en = {
connected: 'Connected',
and: 'and',
keyNote: 'Your key pays the service directly. It stays on this computer and goes only to its own service.',
- getKey: 'Get a {name} key',
+ getKey: 'Get your {name} key',
pasteKey: 'Paste your {name} API key',
save: 'Save',
cancel: 'Cancel',
diff --git a/packages/openfilm/studio/ui/src/lib/providers.ts b/packages/openfilm/studio/ui/src/lib/providers.ts
index 36a3f7e..6f6d90c 100644
--- a/packages/openfilm/studio/ui/src/lib/providers.ts
+++ b/packages/openfilm/studio/ui/src/lib/providers.ts
@@ -60,6 +60,8 @@ async function call<T = ProvidersState>(path: string, init?: { method: string; j
export interface ProvidersHook {
state: ProvidersState | null;
problem: string | null;
+ /** the provider or kind of media the last change that failed was for (null: loading failed) */
+ problemFor: string | null;
/** the provider or kind of media a change is being saved for */
busy: string | null;
/** keep a key; resolves whether it was kept */
@@ -74,6 +76,7 @@ export interface ProvidersHook {
export function useProviders(): ProvidersHook {
const [state, setState] = React.useState<ProvidersState | null>(null);
const [problem, setProblem] = React.useState<string | null>(null);
+ const [problemFor, setProblemFor] = React.useState<string | null>(null);
const [busy, setBusy] = React.useState<string | null>(null);
React.useEffect(() => {
@@ -82,7 +85,7 @@ export function useProviders(): ProvidersHook {
/* asked again a few times when it fails: Studio restarting, or busy for a moment, must not leave Settings empty */
const load = (attempt: number) => {
call('').then(
- (next) => { if (live) { setState(next); setProblem(null); } },
+ (next) => { if (live) { setState(next); setProblem(null); setProblemFor(null); } },
(e: Error) => {
if (!live) return;
if (attempt < 4) timer = window.setTimeout(() => load(attempt + 1), 1000 * 2 ** attempt);
@@ -98,12 +101,12 @@ export function useProviders(): ProvidersHook {
setBusy(what);
setProblem(null);
try { setState(await call(path, init)); return true; }
- catch (e) { setProblem(e instanceof Error ? e.message : String(e)); return false; }
+ catch (e) { setProblem(e instanceof Error ? e.message : String(e)); setProblemFor(what); return false; }
finally { setBusy(null); }
}, []);
return {
- state, problem, busy,
+ state, problem, problemFor, busy,
saveKey: (id, key) => change(id, `/${encodeURIComponent(id)}/key`, { method: 'PUT', json: { key } }),
removeKey: async (id) => { await change(id, `/${encodeURIComponent(id)}/key`, { method: 'DELETE' }); },
useEnvKey: (id) => change(id, `/${encodeURIComponent(id)}/key`, { method: 'PUT', json: { env: true } }),