Skip to content

fix(site): use search params for model edit/add navigation#23277

Merged
DanielleMaywood merged 1 commit intomainfrom
dm/fix-models-back-nav
Mar 19, 2026
Merged

fix(site): use search params for model edit/add navigation#23277
DanielleMaywood merged 1 commit intomainfrom
dm/fix-models-back-nav

Conversation

@DanielleMaywood
Copy link
Contributor

@DanielleMaywood DanielleMaywood commented Mar 19, 2026

🤖 This PR was written by Coder Agent on behalf of Danielle Maywood.


Problem

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.

Solution

Replace local view state with URL search params in all three sections:

Section Search params
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.

History management per action:

Action Mechanism Why
Click row push New history entry for the form
Back / Cancel push (clear params) Back returns to form you just left
Update push (clear params) Back returns to form with saved state
Create navigate(-1) Blank add form is stale after creation
Delete navigate(-1) Resource no longer exists

Changes

  • api.ts: Added getUser(userIdOrName) method wrapping GET /api/v2/users/{user}.
  • queries/users.ts: Added userByNameKey and userByName(username) query.
  • ModelsSection.tsx: Swapped useState<ModelView> for useSearchParams with useMemo-derived view. Added clearModelView() helper that removes only model-related params.
  • ProvidersSection.tsx: Same pattern — swapped useState<ProviderView> for useSearchParams with useMemo-derived view. Provider disappearance is now handled naturally by the derivation falling back to list mode.
  • SettingsPageContent.tsx: Swapped useState<ChatCostUserRollup | null> for useSearchParams. Uses the new userByName query 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.

@github-actions github-actions bot added the community Pull Requests and issues created by the community. label Mar 19, 2026
@DanielleMaywood DanielleMaywood force-pushed the dm/fix-models-back-nav branch 5 times, most recently from 033b963 to 107b5b7 Compare March 19, 2026 11:29
@DanielleMaywood DanielleMaywood marked this pull request as ready for review March 19, 2026 11:37
@DanielleMaywood DanielleMaywood marked this pull request as draft March 19, 2026 11:41
@DanielleMaywood DanielleMaywood force-pushed the dm/fix-models-back-nav branch 9 times, most recently from 2e48bcb to 7413555 Compare March 19, 2026 12:41
@DanielleMaywood DanielleMaywood removed the community Pull Requests and issues created by the community. label Mar 19, 2026
@DanielleMaywood DanielleMaywood force-pushed the dm/fix-models-back-nav branch from 7413555 to 7fb5efd Compare March 19, 2026 12:45
@DanielleMaywood DanielleMaywood marked this pull request as ready for review March 19, 2026 12:52
@DanielleMaywood DanielleMaywood marked this pull request as draft March 19, 2026 12:52
@DanielleMaywood DanielleMaywood force-pushed the dm/fix-models-back-nav branch from 7fb5efd to 1de324d Compare March 19, 2026 12:55
@DanielleMaywood DanielleMaywood marked this pull request as ready for review March 19, 2026 13:03
@ibetitsmike
Copy link
Collaborator

@codex review

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review


P2 Badge Drive usage drill-in from selected username, not profile data

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".

@DanielleMaywood DanielleMaywood force-pushed the dm/fix-models-back-nav branch 2 times, most recently from b1b84e0 to f1bc254 Compare March 19, 2026 13:39
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.
@DanielleMaywood DanielleMaywood merged commit 84f032d into main Mar 19, 2026
27 checks passed
@DanielleMaywood DanielleMaywood deleted the dm/fix-models-back-nav branch March 19, 2026 16:50
@github-actions github-actions bot locked and limited conversation to collaborators Mar 19, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants