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
Prevents duplicate API calls by tracking in-flight requests
Ensures consistent prompt generation under high concurrency
Mitigates potential race conditions in prompt retrieval
Improves performance and reliability of prompt generation service
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
Trims generated prompts to requested count
Ensures consistent user experience by slicing array if model over-generates
Prevents potential cache key mismatches due to inconsistent prompt counts
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
Introduces ModelId type alias to clarify model ID intent
Refines prompt generator type to support specific prompt types
Improves type safety for model and prompt configuration
Enforces Claude model selection as a mandatory setting
Prevents configuration submission without specifying a valid Claude model to ensure proper API interaction and prevent potential errors
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>
Prevents errors when attempting to process an empty cache.
Deletes the cache entry if it is empty to avoid repeatedly
attempting to process an invalid cache entry.
Updates prompt generation to use the model type directly, removing the need for casting.
This change streamlines the prompt generation process and enhances type safety.
Initial implementation of the Freewriting Prompts plugin.
This commit introduces the core functionality for generating
AI-powered writing prompts using Anthropic's Claude API.
It includes:
- API client for interacting with the Anthropic API
- Services for generating and caching prompts
- Commands for displaying staggered prompts and appending prompts to notes
- Settings tab for configuring the plugin