Extracts common model fetching logic into shared method to prevent duplicate API calls
Improves error handling and caching for model retrieval by:
- Creating a centralized fetchWithDeduplication method
- Adding model type filtering in cache update
- Resetting fallback notice flag during cache clearing
Enhances reliability of model list retrieval across multiple service methods
Adds deduplication of concurrent API calls to prevent redundant requests
Enhances error handling by preferring stale cache over hardcoded fallback models
Introduces new getStaleCacheModels method to provide more robust model retrieval
Prevents multiple simultaneous model fetch attempts with in-flight request tracking
Adds a session-based flag to prevent repeated fallback notices during API failures
Implements model list deduplication to handle potential duplicate entries
Prevents spamming users with repeated error notifications
Resets notice flag on successful model fetches to allow future warnings
Improves model retrieval by adding API key validation check for both model fetching methods
Adds fallback to predefined models when no API key is present
Sorts model lists alphabetically by display name for consistent presentation
Enhances robustness of model service handling
Updates error notification to provide clearer feedback when API model retrieval fails
Enhances user experience by making the fallback model list error message more descriptive and informative
Replace hardcoded model list with dynamic API-based model fetching
that queries the Anthropic models endpoint. Implements 24-hour caching
with automatic fallback to hardcoded models if API is unavailable.
Changes:
- Add ModelService to fetch and cache available models from API
- Implement 24-hour TTL cache persisted in plugin data
- Update AnthropicClient with fetchModels() method
- Modify settings UI to load models asynchronously with loading states
- Auto-refresh models when API key is entered or changed
- Display model names using display_name field from API
- Preserve user's selected model across updates and restarts
- Show notice when falling back to hardcoded model list
- Change model type from strict enum to string for dynamic support
Technical details:
- New ModelInfo and ModelsListResponse interfaces for API response
- ModelCache interface with timestamp for TTL validation
- FreewritingPromptsData extends settings to include cache
- Settings dropdown disabled during model fetch/refresh
- Fallback to ANTHROPIC_MODELS constant on API failure
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>