Skip to content

ref(seer): Refactor hooks related to the preferred agent option#112042

Merged
ryan953 merged 8 commits into
masterfrom
ryan953/ref-seer-preferred-agent
Apr 3, 2026
Merged

ref(seer): Refactor hooks related to the preferred agent option#112042
ryan953 merged 8 commits into
masterfrom
ryan953/ref-seer-preferred-agent

Conversation

@ryan953
Copy link
Copy Markdown
Member

@ryan953 ryan953 commented Apr 1, 2026

This makes this much easier to read/review and test. The stories are small and still work

The bigs wins are a) moving a lot of logic out of the component and into hooks, b) and then leveraging useQuery and select: () => ... inside those hooks to format the data.

Everything is more centered around type PreferredAgent, including the filename. i like how those things align tbh. And the tests are easier to read, and more plentiful, than before.

@ryan953 ryan953 requested review from a team as code owners April 1, 2026 20:52
@github-actions github-actions Bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Apr 1, 2026
This makes this much easier to read/review and test. The stories are small and still work
@@ -214,93 +214,6 @@ export function useMutateSelectedAgent({project}: {project: Project}) {
);
}

export function useBulkMutateSelectedAgent({projects}: {projects: Project[]}) {
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this big guy just moved over, only changes to the args/types.

Comment thread static/app/views/settings/seer/overview/utils/seerPreferredAgent.ts Outdated
Comment thread static/app/views/settings/seer/overview/autofixOverviewSection.tsx
Comment thread static/app/views/settings/seer/overview/utils/seerPreferredAgent.ts Outdated
Copy link
Copy Markdown
Collaborator

@TkDodo TkDodo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

}) {
return useQuery({
...organizationIntegrationsCodingAgents(organization),
select: (data): ReadonlyArray<SelectValue<PreferredAgent>> => {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could this type be inferred?

Suggested change
select: (data): ReadonlyArray<SelectValue<PreferredAgent>> => {
select: data => {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it wasn't working, i can look again though.

It seemed to need the SelectValue<> part in there so that the <Select> field treated it properly. But I was also playing with wrapping it in useCallback which also hurt types, so go at it again.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i tried to understand how this should work but I’m not sure I could wrap my head around it fully.

the value for the form seems to be either the string literal seer or an object with id, name etc . I’m surprised this even works with out select. Can we not get this into a unified structure?

also when using objects as value for a select, you basically have to provide the isValueEqual function to compare the ids. Otherwise, comparison of values happens with === internally, so values would never be seen as identical.

Comment thread static/app/views/settings/seer/overview/utils/seerPreferredAgent.ts
Comment thread static/app/views/settings/seer/overview/autofixOverviewSection.tsx
Copy link
Copy Markdown
Contributor

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

There are 3 total unresolved issues (including 1 from previous review).

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Comment thread static/app/views/settings/seer/overview/utils/seerPreferredAgent.spec.ts Outdated
schema={z.object({
integration: z.union([z.literal('seer'), z.custom<CodingAgentIntegration>()]),
})}
initialValue={initialValue}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Form shows wrong initial value after async load

High Severity

When the org has a non-seer preferred agent (via defaultCodingAgentIntegrationId), useFetchPreferredAgent introduces an async loading phase where data is undefined. During loading, initialValue falls back to 'seer', and AutoSaveForm mounts with defaultValues: {integration: 'seer'}. TanStack Form's defaultValues does not update after mount, so once loading completes the form state stays stuck on 'seer' even though the actual agent is different. The old code computed the value synchronously from org props with no loading state, so this is a regression.

Additional Locations (1)
Fix in Cursor Fix in Web

@ryan953 ryan953 merged commit 814605c into master Apr 3, 2026
81 of 83 checks passed
@ryan953 ryan953 deleted the ryan953/ref-seer-preferred-agent branch April 3, 2026 17:07
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 19, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants