# Implementation Plan ## [Overview] Remove the DNS Resolution Service background functionality while preserving manual DNS resolution capabilities. The current DNS system includes both background automatic resolution that runs periodically and manual user-triggered resolution. This implementation will remove all background resolution components including the DNS service lifecycle, caching system, automatic refresh intervals, and service toggle functionality. Manual DNS resolution will be preserved and simplified to work without caching, making DNS resolution purely on-demand when users explicitly trigger it via the refresh DNS action (Ctrl+R). ## [Types] Simplify DNS-related data structures by removing background service state management. **DNSService class modifications:** - Remove `_background_task: Optional[asyncio.Task]` field - Remove `_stop_event: asyncio.Event` field - Remove `_resolution_cache: Dict[str, DNSResolution]` field - Remove `_update_callback: Optional[Callable]` field - Remove `update_interval: int` parameter and field - Keep `enabled: bool` and `timeout: float` for manual resolution control - Remove cache-related methods: `get_cached_resolution()`, `clear_cache()`, `get_cache_stats()` **Configuration type changes:** - Remove `dns_resolution.interval` setting - Remove `dns_resolution.cache_ttl` setting - Keep `dns_resolution.enabled` and `dns_resolution.timeout` for manual resolution ## [Files] Remove background DNS service components across multiple files. **Files to be modified:** - `src/hosts/core/dns.py` - Remove background service, caching, and lifecycle management - `src/hosts/tui/app.py` - Remove background service initialization and toggle functionality - `src/hosts/core/config.py` - Remove background resolution configuration options - `src/hosts/tui/keybindings.py` - Remove DNS service toggle keybinding - `tests/test_dns.py` - Update tests to reflect manual-only functionality - `tests/test_config.py` - Remove tests for background DNS configuration **No new files to be created** **No files to be deleted** ## [Functions] Remove background service functions and simplify DNS resolution interface. **Functions to be removed from DNSService:** - `start_background_resolution()` - Background service startup - `stop_background_resolution()` - Background service shutdown - `_background_worker()` - Background resolution worker loop - `_resolve_and_cache()` - Background resolution with caching - `set_update_callback()` - Callback registration for background updates - `get_cached_resolution()` - Cache retrieval method - `clear_cache()` - Cache clearing method - `get_cache_stats()` - Cache statistics method **Functions to be modified:** - `__init__()` - Remove update_interval, cache, background task initialization - `resolve_entry_async()` - Remove cache logic, perform direct resolution - `resolve_entry()` - Remove cache logic and background task scheduling - `refresh_entry()` - Simplify to direct resolution without cache management - `refresh_all_entries()` - Simplify to direct batch resolution without caching **Functions to be removed from HostsManagerApp:** - `action_toggle_dns_service()` - DNS service toggle functionality **Configuration functions to be removed:** - `get_dns_resolution_interval()` - Background interval setting - `set_dns_resolution_interval()` - Background interval configuration - `get_dns_cache_ttl()` - Cache TTL setting ## [Classes] Simplify DNSService class by removing background service capabilities. **Modified classes:** - **DNSService** (src/hosts/core/dns.py): - Remove background service state management - Remove caching infrastructure - Remove callback system for background updates - Simplify constructor to only accept `enabled` and `timeout` parameters - Keep manual resolution methods: `resolve_entry_async()`, `refresh_entry()`, `refresh_all_entries()` **No new classes to be created** **No classes to be removed** ## [Dependencies] No changes to external dependencies required. All required dependencies for manual DNS resolution (asyncio, socket) remain unchanged. Background service removal eliminates some asyncio usage but doesn't require dependency modifications. ## [Testing] Update existing DNS tests to focus on manual resolution functionality. **Test modifications required:** - Remove background service lifecycle tests from `TestDNSService` - Remove cache-related tests: cache hit/miss, cache operations, cache stats - Remove background worker and callback tests - Keep and update manual resolution tests - Update configuration tests to remove background DNS settings - Simplify DNSService initialization tests to reflect new constructor **Test files to modify:** - `tests/test_dns.py` - Remove ~15 background service and cache tests - `tests/test_config.py` - Remove background DNS configuration tests ## [Implementation Order] Sequential implementation to minimize conflicts and ensure system stability. 1. **Update DNSService class** - Remove background service infrastructure and caching 2. **Update configuration system** - Remove background DNS settings and related methods 3. **Remove keybinding** - Remove DNS service toggle from keybindings 4. **Update main application** - Remove background service initialization and toggle action 5. **Update tests** - Remove background service tests and update remaining tests 6. **Verify manual DNS resolution** - Test that manual refresh functionality still works 7. **Test complete removal** - Ensure no background DNS activity occurs