From bdb82bcf492c8df361256bf84f2e165b5d5758ee Mon Sep 17 00:00:00 2001 From: Dave Date: Sat, 27 Dec 2025 19:30:17 +0000 Subject: [PATCH] Story 23: Alphabetize LLM dropdown list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit User Story: As a user, I want the LLM model dropdown to be alphabetically sorted so I can quickly find the model I'm looking for. Implementation: - Added alphabetical sorting with case-insensitive comparison - Used localeCompare() for proper string comparison - Sort happens immediately after fetching models from backend - Currently selected model remains selected after sorting Technical Details: - Sort logic: models.sort((a, b) => a.toLowerCase().localeCompare(b.toLowerCase())) - Frontend-only change, no backend modifications needed - Sorting preserves model selection state Acceptance Criteria Met: ✅ Models sorted alphabetically (case-insensitive) ✅ Selected model remains selected after sorting ✅ Works for all models from Ollama ✅ Updates correctly when models change Files Changed: - src/components/Chat.tsx: Added sorting logic to model fetch - .living_spec/stories/23_alphabetize_llm_dropdown.md: Marked complete --- .living_spec/stories/23_alphabetize_llm_dropdown.md | 8 ++++---- src/components/Chat.tsx | 6 +++++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/.living_spec/stories/23_alphabetize_llm_dropdown.md b/.living_spec/stories/23_alphabetize_llm_dropdown.md index d467f2f..8e5d66f 100644 --- a/.living_spec/stories/23_alphabetize_llm_dropdown.md +++ b/.living_spec/stories/23_alphabetize_llm_dropdown.md @@ -4,10 +4,10 @@ As a user, I want the LLM model dropdown to be alphabetically sorted so I can quickly find the model I'm looking for. ## Acceptance Criteria -- [ ] The model dropdown list is sorted alphabetically (case-insensitive) -- [ ] The currently selected model remains selected after sorting -- [ ] The sorting works for all models returned from Ollama -- [ ] The sorted list updates correctly when models are added/removed +- [x] The model dropdown list is sorted alphabetically (case-insensitive) +- [x] The currently selected model remains selected after sorting +- [x] The sorting works for all models returned from Ollama +- [x] The sorted list updates correctly when models are added/removed ## Out of Scope - Grouping models by type or provider diff --git a/src/components/Chat.tsx b/src/components/Chat.tsx index f1f753a..3dbd4e9 100644 --- a/src/components/Chat.tsx +++ b/src/components/Chat.tsx @@ -84,7 +84,11 @@ export function Chat({ projectPath, onCloseProject }: ChatProps) { invoke("get_ollama_models") .then(async (models) => { if (models.length > 0) { - setAvailableModels(models); + // Sort models alphabetically (case-insensitive) + const sortedModels = models.sort((a, b) => + a.toLowerCase().localeCompare(b.toLowerCase()), + ); + setAvailableModels(sortedModels); // Check backend store for saved model try {