Skip to content

perf(chat): derive upstreamModelId from providerGroups to eliminate duplicate fetch#607

Closed
HUQIANTAO wants to merge 1 commit into
op7418:mainfrom
HUQIANTAO:perf/11-avoid-duplicate-provider-models-fetch
Closed

perf(chat): derive upstreamModelId from providerGroups to eliminate duplicate fetch#607
HUQIANTAO wants to merge 1 commit into
op7418:mainfrom
HUQIANTAO:perf/11-avoid-duplicate-provider-models-fetch

Conversation

@HUQIANTAO
Copy link
Copy Markdown

Summary

ChatView was making a duplicate fetch('/api/providers/models') inside a useEffect solely to extract upstreamModelId for the context-window indicator — even though useProviderModels (called 20 lines above) already fetches the same endpoint and returns the full providerGroups array with upstreamModelId on every model row.

Change

Impact

  • Eliminates 1 network round-trip on every provider/model change
  • Zero behavioral change — same lookup logic, same return type
  • ~20 lines removed (net -10)

…cate fetch

useProviderModels already fetches /api/providers/models and returns
providerGroups with upstreamModelId on every model row. A separate
useEffect was making an identical network request solely to extract
this field, adding unnecessary latency on every provider/model change.

Replace the useEffect + useState + fetch with a useMemo that looks up
the matching group and model from the already-available providerGroups,
using the same findModelOption helper for canonical-id matching.
@vercel
Copy link
Copy Markdown

vercel Bot commented Jun 5, 2026

Someone is attempting to deploy a commit to the op7418's projects Team on Vercel.

A member of the Team first needs to authorize it.

@op7418
Copy link
Copy Markdown
Owner

op7418 commented Jun 8, 2026

Closing this PR as part of a batch of low-signal/bulk-generated submissions from the same account. Please open one focused PR with a clear problem statement, implementation rationale, and tests if this change is intentional.

@op7418 op7418 closed this Jun 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants