Skip to content

Commit b4f871a

Browse files
committed
fix: load multiple workflows
1 parent eb161c2 commit b4f871a

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

ui/src/components/settings.tsx

+14-8
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ interface ConfigFormProps {
110110
}
111111

112112
function ConfigForm({ config, onSubmit }: ConfigFormProps) {
113-
const [prompts, setPrompts] = useState<any>(null);
113+
const [prompts, setPrompts] = useState<any[]>([]);
114114
const [videoDevices, setVideoDevices] = useState<VideoDevice[]>([]);
115115
const [audioDevices, setAudioDevices] = useState<VideoDevice[]>([]);
116116
const [selectedDevice, setSelectedDevice] = useState<string>("");
@@ -191,15 +191,20 @@ function ConfigForm({ config, onSubmit }: ConfigFormProps) {
191191
});
192192
};
193193

194-
const handlePromptsChange = async (e: any) => {
195-
const file = e.target.files[0];
196-
if (!file) return;
194+
const handlePromptsChange = async (e: React.ChangeEvent<HTMLInputElement>) => {
195+
if (!e.target.files?.length) return;
197196

198197
try {
199-
const text = await file.text();
200-
setPrompts(JSON.parse(text));
198+
const files = Array.from(e.target.files);
199+
const fileReads = files.map(async (file) => {
200+
const text = await file.text();
201+
return JSON.parse(text);
202+
});
203+
204+
const allPrompts = await Promise.all(fileReads);
205+
setPrompts(allPrompts);
201206
} catch (err) {
202-
console.error(err);
207+
console.error("Failed to parse one or more JSON files.", err);
203208
}
204209
};
205210

@@ -274,8 +279,9 @@ function ConfigForm({ config, onSubmit }: ConfigFormProps) {
274279
id="video-workflow"
275280
type="file"
276281
accept=".json"
282+
multiple
277283
onChange={handlePromptsChange}
278-
></Input>
284+
/>
279285
</div>
280286

281287
<Button type="submit" className="w-full mt-4 mb-4">

0 commit comments

Comments
 (0)