feat(models): admin drag-and-drop sort order for the model picker - #1248
Merged
Merged
Conversation
Models were listed newest-first everywhere, so the chat picker's order was an accident of creation time. Admins can now drag rows on the Manage Models page to set the order both the admin list and the chat picker use. - ManagedModel gains a read-only `sortOrder`, written only by the new `PUT /admin/managed-models/order` (full catalog of ids; a partial or stale list is a 409). Unordered models sort after ordered ones, newest first, so an uncurated catalog keeps today's order. - Sorting happens in the shared list path, so /models and the admin list agree and the SPA renders server order as-is. - Manage Models: CDK drag handle per row, keyboard reorder (arrows, Home/End) with a live-region announcement, disabled while filtered. Saves are optimistic, serialized and coalesced; a failure reloads. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
The chat model picker shows models newest-first, so its order depends on when each model happened to be added. Admins had no way to put the models they want people to choose at the top.
What changed
Backend
ManagedModelhas a new read-only field,sortOrder(optional int). Only the new endpoint writes it. Create and update never touch it, so saving the model form can't undo a drag.PUT /admin/managed-models/ordertakes{ "modelIds": [...] }, the full list of model IDs in order, and sets each model's position.PUT /managed-models/{model_id}, soorderisn't treated as a model ID. A test covers this._list_managed_models_cloud: ordered models first, lowest number first, then unordered models newest first./modelsand the admin list therefore return the same order, and the picker keeps rendering what the server sends.Frontend (Manage Models page)
cdkDropList/cdkDrag, locked to the vertical axis).ManagedModelsService.reorderModelsupdates the list immediately. Saves go out one at a time, and moves made while a save is in flight are merged into one follow-up save of the latest order, so a late response can't overwrite a newer local order. If a save fails, the list reloads from the server.isDefault. It doesn't depend on list position, so reordering doesn't change anyone's default model.Testing
tests/routes,tests/sharedandtests/architecturepass..envwas copied into the worktree to run a local server. They pass 40/40 with that file moved aside. It's a local-environment issue, not caused by this PR.ManagedModelsServicespecs (optimistic update, coalescing, reload on failure). The manage-models, model picker (model-dropdown) and model-service specs pass (104).ng buildis clean.🤖 Generated with Claude Code