@@ -7,13 +7,7 @@ import { Alert, AlertDescription } from "#/components/Alert/Alert";
77import { ErrorAlert } from "#/components/Alert/ErrorAlert" ;
88import { Button } from "#/components/Button/Button" ;
99import { Label } from "#/components/Label/Label" ;
10- import {
11- Select ,
12- SelectContent ,
13- SelectItem ,
14- SelectTrigger ,
15- SelectValue ,
16- } from "#/components/Select/Select" ;
10+ import { OrganizationAutocomplete } from "#/components/OrganizationAutocomplete/OrganizationAutocomplete" ;
1711import { useDashboard } from "#/modules/dashboard/useDashboard" ;
1812import { docs } from "#/utils/docs" ;
1913import { useFileAttachments } from "../hooks/useFileAttachments" ;
@@ -196,10 +190,10 @@ export const AgentCreateForm: FC<AgentCreateFormProps> = ({
196190 return localStorage . getItem ( selectedWorkspaceIdStorageKey ) || null ;
197191 } ,
198192 ) ;
199- const [ selectedOrganizationId , setSelectedOrganizationId ] = useState <
200- string | null
201- > ( organizations [ 0 ] ?. id ?? null ) ;
202- const organizationId = selectedOrganizationId ?? organizations [ 0 ] ?. id ?? "" ;
193+ const [ selectedOrg , setSelectedOrg ] = useState < TypesGen . Organization | null > (
194+ organizations [ 0 ] ?? null ,
195+ ) ;
196+ const organizationId = selectedOrg ?. id ?? organizations [ 0 ] ?. id ?? "" ;
203197 const hasModelOptions = modelOptions . length > 0 ;
204198 const hasConfiguredModels = hasConfiguredModelsInCatalog ( modelCatalog ) ;
205199 const hasUserFixableModelProviders = hasUserFixableProviders ( modelCatalog ) ;
@@ -364,24 +358,13 @@ export const AgentCreateForm: FC<AgentCreateFormProps> = ({
364358 { showOrganizations && (
365359 < div className = "flex flex-col gap-2" >
366360 < Label htmlFor = "organization" > Organization</ Label >
367- { /* TODO: Replace with controlled OrganizationAutocomplete
368- once it supports a value prop.
369- See: https://github.com/coder/internal/issues/1440 */ }
370- < Select
371- value = { organizationId }
372- onValueChange = { setSelectedOrganizationId }
373- >
374- < SelectTrigger id = "organization" >
375- < SelectValue placeholder = "Select an organization…" />
376- </ SelectTrigger >
377- < SelectContent >
378- { organizations . map ( ( org ) => (
379- < SelectItem key = { org . id } value = { org . id } >
380- { org . display_name || org . name }
381- </ SelectItem >
382- ) ) }
383- </ SelectContent >
384- </ Select >
361+ < OrganizationAutocomplete
362+ id = "organization"
363+ required
364+ value = { selectedOrg }
365+ options = { [ ...organizations ] }
366+ onChange = { setSelectedOrg }
367+ />
385368 </ div >
386369 ) }
387370 < AgentChatInput
0 commit comments