Skip to content

Commit

Permalink
- improve: added agent pre selection when it was recently added
Browse files Browse the repository at this point in the history
  • Loading branch information
agallardol committed Nov 9, 2023
1 parent 3f8f306 commit 77a67f2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion apps/shinkai-visor/src/components/add-agent/add-agent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export const AddAgent = () => {
});
const { mutateAsync: createAgent, isLoading } = useCreateAgent({
onSuccess: () => {
history.replace({ pathname: '/inboxes/create-job' });
history.replace({ pathname: '/inboxes/create-job' }, { agentName: form.getValues().agentName });
},
});
const modelOptions: { value: Models; label: string }[] = [
Expand Down
10 changes: 9 additions & 1 deletion apps/shinkai-visor/src/components/create-job/create-job.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ type FormSchemaType = z.infer<typeof formSchema>;
export const CreateJob = () => {
const history = useHistory();
const intl = useIntl();
const location = useLocation<{ files: File[] }>();
const location = useLocation<{ files: File[], agentName: string }>();
const query = useQuery();
const auth = useAuth((state) => state.auth);
const form = useForm<FormSchemaType>({
Expand Down Expand Up @@ -84,6 +84,14 @@ export const CreateJob = () => {
useEffect(() => {
form.setValue('files', location?.state?.files || []);
}, [location, form]);
useEffect(() => {
if (location?.state?.agentName) {
const agent = agents.find(agent => (agent.full_identity_name as any)?.subidentity_name === location.state.agentName);

Check warning on line 89 in apps/shinkai-visor/src/components/create-job/create-job.tsx

View workflow job for this annotation

GitHub Actions / health-checks (lint)

Unexpected any. Specify a different type
if (agent) {
form.setValue('agent', agent.id);
}
}
}, [form, location, agents]);
const submit = (values: FormSchemaType) => {
if (!auth) return;
let content = values.content;
Expand Down

0 comments on commit 77a67f2

Please sign in to comment.