Extracts common fallback model caching logic into a new private method `cacheFallbackModels()`
Reduces code duplication in model retrieval methods by centralizing fallback model caching
Improves code readability and maintainability by consolidating repetitive logic
Adds descriptive docstring to explain the purpose of the new helper method
Prevents notification fatigue during API failures by throttling error messages
Introduces new method to limit error notices to once per minute when fetching models fails
Refactors model fetching error handling to use a consistent conversion method
Improves user experience by reducing repetitive error notifications
Adds comprehensive documentation for all major classes and methods in the Freewriting Cleanup plugin
Improves code readability by:
- Adding detailed JSDoc comments explaining purpose and functionality
- Clarifying method behaviors and input/output expectations
- Providing inline context for complex operations
Standardizes error handling and adds more robust validation across services
Removes fallback to model ID for display names
Ensures consistent and user-friendly model representation
Improves model dropdown experience by requiring display names from API
Adds API key validation before fetching models
Ensures consistent fallback model caching on API errors or missing key
Reduces redundant code by centralizing fallback model caching logic
Relates to dynamic-models branch
Improves model retrieval strategy for scenarios with invalid/missing API keys
Adds immediate fallback model generation when API key is invalid
Ensures consistent model caching for both API and fallback scenarios
Sorts model options alphabetically for improved user experience
Introduces new getFallbackOptions() method for direct fallback access
Refactors model refresh and error handling to provide more robust model selection
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
- FreewritingCleanupData 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>