Skip to content

refactor: make OrganizationAutocomplete accept readonly Organization[] #24285

Description

@johnstcn

Problem

OrganizationAutocomplete declares its options prop as mutable Organization[]:

// site/src/components/OrganizationAutocomplete/OrganizationAutocomplete.tsx:24
options: Organization[];

useDashboard().organizations returns readonly Organization[]. Callers that pass this value must spread into a new array to satisfy the type:

options={[...organizations]}

This creates a new array identity every render, defeating React memoization for no reason. The component never mutates the array.

Fix

Change the prop type to readonly Organization[]:

- options: Organization[];
+ options: readonly Organization[];

Then remove the unnecessary spread in AgentCreateForm.tsx:382:

- options={[...organizations]}
+ options={organizations}

Context

Found during review of #23827 — the spread was flagged as unnecessary but turned out to be required by the current type signature.

🤖

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions