Skip to content

Tui async improvements - #19

Merged
Minigrim0 merged 37 commits into
mainfrom
tui-async-improvements
Jul 13, 2025
Merged

Tui async improvements#19
Minigrim0 merged 37 commits into
mainfrom
tui-async-improvements

Conversation

@Minigrim0

Copy link
Copy Markdown
Owner

Major TUI overhaul fixing blocking I/O issues and implementing automated version management. Transforms the TUI from a blocking, single-threaded app to a responsive async-powered interface.

- Add TuiError enum with specific error types for TUI operations
- Add HomeDisplayError enum for core library operations
- Include error recovery detection and user-friendly messages
- Prepare for better error handling throughout the application
- Update workspace member from 'common' to 'homedisplay'
- Update crate name in homedisplay/Cargo.toml
- Prepare for import updates across all dependent crates
- Update Cargo.toml dependency from 'common' to 'homedisplay'
- Update all imports from 'common::' to 'homedisplay::'
- Add error module to main.rs module list
- Complete TUI crate migration to new naming
- Update Cargo.toml dependency from 'common' to 'homedisplay'
- Update all imports across currency, weather, and transport modules
- Complete frontend crate migration to new naming
- Update Cargo.toml dependency from 'common' to 'homedisplay'
- Update imports in main.rs and commands.rs
- Complete src-tauri crate migration to new naming
- Add error module to lib.rs exports
- Make HomeDisplayError available for dependent crates
- Complete error system integration
- Remove old common/ directory and all its contents
- Add new homedisplay/ directory with all moved files
- Update Cargo.lock to reflect new dependency paths
- Complete the physical file structure migration
- Replace String errors with TuiError in WeatherComponent
- Replace String errors with TuiError in CurrencyComponent
- Replace String errors with TuiError in TransportComponent
- Update App error handling to use TuiError types
- Add comprehensive documentation following existing patterns
- Improve error context with proper TuiError variants
- Replace String errors with TuiError in all utility functions
- Add comprehensive documentation for utility functions
- Update datetime component timezone error handling
- Improve error messages with proper context
- Use TuiError convenience methods for common error cases
- Improve error display with user-friendly messages
- Show detailed errors only in debug mode
- Add proper error titles for each component type
- Enhance transport component site-specific error handling
- Add comprehensive documentation to all App methods
- Update tui.rs with better function documentation
- Complete transition from String to TuiError throughout TUI crate
- Fix TuiError variant usage to use enum variants instead of non-existent methods
- Update remaining src-tauri command imports from common to homedisplay
- Remove unused TuiResult imports throughout TUI crate
- Ensure all code compiles successfully after error system migration
- Add #[cfg(feature = "network")] guards for Redis and reqwest error conversions
- Update is_retryable() method to handle network/non-network feature scenarios
- Add documentation for is_retryable() method
- Ensure compilation works with and without network feature enabled
- Test passes for --no-default-features, --features network, and workspace
- Create AsyncDataManager with single multi-threaded runtime
- Implement background tasks for weather, currency, and transport data
- Use std::sync::mpsc channels for UI thread communication
- Add concurrent data fetching with configurable refresh intervals
- Include proper error handling and logging throughout
- Support graceful shutdown with timeout
- Add comprehensive documentation following existing patterns

Architecture:
- Single runtime replaces 3 separate runtime creations
- Background tasks run continuously with intervals
- Non-blocking channel communication with UI thread
- Proper resource cleanup on shutdown
- Add AsyncDataManager integration to App struct
- Replace blocking refresh calls with non-blocking channel reception
- Use try_recv() to process async data updates without blocking UI
- Keep UI-specific updates (forecast cycling, timezone rotation)
- Remove old blocking utilities calls from update_state()
- Add proper error handling for async manager startup
- Update App to handle data_receiver channel

Changes:
- App now starts AsyncDataManager on initialization
- UI thread processes data via channels instead of blocking calls
- Background tasks handle all network operations concurrently
- UI remains responsive during data fetching operations
- Add deprecation warnings to old blocking refresh functions
- Fix AsyncDataManager lifecycle by storing in App struct instead of mem::forget
- Add Debug implementation for AsyncDataManager to support App::Debug
- Mark old utilities as deprecated with clear migration path
- Maintain backward compatibility while encouraging async usage

The old utilities are now deprecated but still functional for any external
consumers that might depend on them. New code should use AsyncDataManager.
- Add detailed logging to async task startup and execution
- Log data fetch attempts, successes, and failures with context
- Add logging for channel communication between async and UI threads
- Include data details in debug logs (temperature, currency rates, site counts)
- Add proper error context in transport task logging
- Log app lifecycle events (startup, main loop entry/exit)
- Add data update processing logs with counts

Logging levels:
- INFO: Task lifecycle, data fetch operations, UI events
- DEBUG: Data content details, update processing counts
- WARN: Recoverable errors, failed data updates
- ERROR: Critical failures, task communication errors

This will help debug TUI data flow and identify issues with async operations.
- Add detailed terminal initialization and cleanup logging
- Add application startup and shutdown logging in main.rs
- Add error display logging in all UI components (weather, currency, transport)
- Add keyboard event handling logging with user actions
- Add debug logging for unhandled key events
- Include proper error handling in terminal operations

Logging coverage now includes:
- Application lifecycle (startup, main loop, shutdown)
- Terminal operations (init, restore, errors)
- User interactions (key presses, exit commands)
- Component error displays (when errors are shown to user)
- Async data flow (already covered in previous commit)

This provides complete visibility into TUI application behavior for debugging.
- Change from new_current_thread() to new_multi_thread() in AsyncDataManager
- This allows background tasks to execute concurrently with the TUI event loop
- Resolves issue where async tasks were spawned but never executed
- Background data fetching should now work properly
- Updated build.yml for Raspberry Pi TUI-only builds
- Added build-x86_64.yml for x86_64 TUI and Tauri builds
- Added workflow_dispatch trigger for manual testing
- Separated concerns: RPi for TUI deployment, x86_64 for both variants
- Optimized dependencies: RPi only installs minimal build tools
- Added artifact uploads for CI builds and release assets
- Set up Cargo workspace version inheritance for all crates
- Created update-version.sh script for manual version updates
- Added GitHub Actions workflow for automated releases
- Updated build workflows to use workspace versions
- All crates now inherit version from workspace (0.7.1)
- Synchronized tauri.conf.json with workspace version
- Added comprehensive version management documentation

Features:
- Single source of truth for version numbers
- Automated version updates via script or GitHub Actions
- Consistent versioning across all project components
- Automatic changelog generation for releases
Resolved conflict in tui/src/utilities.rs by updating imports from 'common' to 'homedisplay' to match the crate rename.
- Created separate ci.yml for lightweight checks on pushes/PRs
- Updated build-x86_64.yml to only run release builds (no more CI artifacts)
- Raspberry Pi workflow already correctly configured for releases only
- CI workflow includes: formatting, clippy, compile checks, and tests
- Release workflows focus on building and uploading artifacts

Benefits:
- Faster CI feedback for developers
- No unnecessary artifact generation on every push
- Resource-efficient separation of concerns
- ARM builds only trigger on releases (expensive operations)
- Updated actions/checkout from v3 to v4
- Updated actions/cache from v3 to v4
- Replaced deprecated actions-rs/toolchain@v1 with dtolnay/rust-toolchain@stable
- Updated actions/create-release@v1 to softprops/action-gh-release@v2
- Modernized Rust toolchain setup with integrated target specification

Fixes deprecation warnings and ensures compatibility with latest GitHub Actions infrastructure.
- Run clippy only on homedisplay crate (minimal external deps)
- Remove src-tauri checks from CI (requires system dependencies)
- Check frontend with WASM target (proper build target)
- Run tests only on homedisplay crate to avoid dependency issues
- Add WASM target to Rust toolchain setup

Fixes clippy failures due to missing Tauri system dependencies in CI environment.
@Minigrim0
Minigrim0 merged commit de41197 into main Jul 13, 2025
2 checks passed
@Minigrim0
Minigrim0 deleted the tui-async-improvements branch July 13, 2025 09:12
@Minigrim0
Minigrim0 restored the tui-async-improvements branch July 19, 2025 14:18
@Minigrim0
Minigrim0 deleted the tui-async-improvements branch July 19, 2025 14:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant