fix(site): use search params for model edit/add navigation#23277
fix(site): use search params for model edit/add navigation#23277DanielleMaywood merged 1 commit intomainfrom
Conversation
033b963 to
107b5b7
Compare
2e48bcb to
7413555
Compare
7413555 to
7fb5efd
Compare
7fb5efd to
1de324d
Compare
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
The detail panel is now rendered only when selectedUserQuery returns data, so any getUser failure (temporary 5xx, auth mismatch, etc.) silently drops back to the list even though ?user= is set and the summary query may still be valid. This makes row clicks appear broken and removes any visible error/retry path for the profile fetch; the detail mode should be keyed off selectedUsername, with profile errors handled inside that mode.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
site/src/pages/AgentsPage/ChatModelAdminPanel/ModelsSection.tsx
Outdated
Show resolved
Hide resolved
b1b84e0 to
f1bc254
Compare
The models, providers, and usage sections under /agents/settings used local useState to toggle between list and detail/form views. Because no URL change occurred, the browser back button skipped over forms entirely and returned the user to whatever page they were on before the settings page. Replace local view state with URL search params in all three sections: Models: ?model=<id> (edit) | ?newModel=<provider> (add) Providers: ?provider=<name> (detail) Usage: ?user=<username> (user detail) Clicking a row now pushes a history entry so the browser back button returns to the list. Create and delete use navigate(-1) to pop the stale form entry, since going back to a blank add form or a deleted resource would be confusing. The usage section uses a dedicated react-query call to fetch the selected user's rollup by username, so the detail header works even when the user is on a different page of results.
f1bc254 to
bb34e1f
Compare
🤖 This PR was written by Coder Agent on behalf of Danielle Maywood.
Problem
The models, providers, and usage sections under
/agents/settingsused localuseStateto toggle between list and detail/form views. Because no URL change occurred, the browser back button skipped over forms entirely and returned the user to whatever page they were on before the settings page.Solution
Replace local view state with URL search params in all three sections:
?model=<id>(edit),?newModel=<provider>(add)?provider=<name>(detail)?user=<username>(user detail)Clicking a row now pushes a history entry so the browser back button returns to the list.
History management per action:
navigate(-1)navigate(-1)Changes
api.ts: AddedgetUser(userIdOrName)method wrappingGET /api/v2/users/{user}.queries/users.ts: AddeduserByNameKeyanduserByName(username)query.ModelsSection.tsx: SwappeduseState<ModelView>foruseSearchParamswithuseMemo-derived view. AddedclearModelView()helper that removes only model-related params.ProvidersSection.tsx: Same pattern — swappeduseState<ProviderView>foruseSearchParamswithuseMemo-derived view. Provider disappearance is now handled naturally by the derivation falling back to list mode.SettingsPageContent.tsx: SwappeduseState<ChatCostUserRollup | null>foruseSearchParams. Uses the newuserByNamequery to fetch the selected user's profile for the detail header, independent of pagination state.SettingsPageContent.stories.tsx: Added 4 new stories for the usage tab: user list, empty state, user drill-in, and drill-in-and-back navigation.