-
Notifications
You must be signed in to change notification settings - Fork 3
feat(tui): add auto-update notification system #124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Greptile OverviewGreptile SummaryThis PR implements a passive auto-update notification system for the Cortex TUI that checks for new versions in the background and displays a banner above the input field. Key Changes
Implementation Notes
This is a lightweight notification-only implementation that complements the existing modal-based upgrade system. Confidence Score: 4/5
|
| Filename | Overview |
|---|---|
| src/cortex-tui/src/app/state.rs | Added UpdateNotificationStatus enum and three new fields (update_status, update_progress, update_version) to track auto-update state |
| src/cortex-tui/src/runner/app_runner/runner.rs | Spawns background task to check for updates using UpdateManager::check_update(), returns version and sha256 hash |
| src/cortex-tui/src/runner/event_loop/core.rs | Added update_check_task field and new tokio::select! branch to handle update check completion, updates state and shows toast notification |
| src/cortex-tui/src/views/minimal_session/view.rs | Added render_update_banner() method and integrated banner into layout above input field, shows status with icons and colors |
Sequence Diagram
sequenceDiagram
participant User
participant AppRunner
participant EventLoop
participant UpdateTask
participant UpdateManager
participant API as Cortex Software API
participant AppState
participant UI as MinimalSessionView
User->>AppRunner: Start TUI application
AppRunner->>UpdateTask: tokio::spawn(update check)
activate UpdateTask
UpdateTask->>UpdateManager: UpdateManager::new()
UpdateManager-->>UpdateTask: manager instance
UpdateTask->>UpdateManager: check_update().await
UpdateManager->>API: get_latest(channel)
API-->>UpdateManager: ReleaseInfo
UpdateManager->>UpdateManager: compare_versions()
alt Update available
UpdateManager-->>UpdateTask: Some((version, sha256))
else No update
UpdateManager-->>UpdateTask: None
end
deactivate UpdateTask
AppRunner->>EventLoop: new().with_update_check_task(task)
AppRunner->>EventLoop: run()
activate EventLoop
EventLoop->>UI: Initial render
UI-->>User: Display TUI
loop Main Event Loop
EventLoop->>EventLoop: tokio::select!
alt Update task completes
UpdateTask-->>EventLoop: Ok(Some((version, sha256)))
EventLoop->>AppState: update_status = Available
EventLoop->>AppState: update_version = version
EventLoop->>AppState: toasts.info("new version available")
EventLoop->>UI: render()
UI->>UI: render_update_banner()
UI-->>User: Show "🔄 A new version is available (X.Y.Z)"
else User input event
EventLoop->>EventLoop: handle_engine_event()
else Stream event
EventLoop->>EventLoop: handle_stream_event()
else Tool event
EventLoop->>EventLoop: handle_tool_event()
end
end
deactivate EventLoop
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
4 files reviewed, 1 comment
src/cortex-tui/src/app/state.rs
Outdated
| /// Status of the auto-update notification system | ||
| #[derive(Debug, Clone, PartialEq, Eq)] | ||
| pub enum UpdateNotificationStatus { | ||
| /// Update check in progress | ||
| Checking, | ||
| /// A new version is available | ||
| Available, | ||
| /// Currently downloading the update | ||
| Downloading, | ||
| /// Download complete, restart required | ||
| RestartRequired, | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Defined states Checking, Downloading, and RestartRequired that aren't currently used by the implementation - only Available is ever set in core.rs:391
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/cortex-tui/src/app/state.rs
Line: 25:36
Comment:
Defined states `Checking`, `Downloading`, and `RestartRequired` that aren't currently used by the implementation - only `Available` is ever set in `core.rs:391`
How can I resolve this? If you propose a fix, please make it concise.0ab95fd to
a7652b4
Compare
Add background update checking on TUI startup with visual notification: - Add UpdateStatus enum tracking: Checking, Available, Downloading, Downloaded, UpToDate, and Error states - Integrate update check in app runner on startup (background async) - Display update banner in MinimalSessionView input area showing: - 'Checking for updates...' during check - 'A new version (vX.X.X) is available' when update found - 'Downloading update...' during download - 'Restart to apply update' after download completes - Add security hardening to cortex-update: - Enforce HTTPS for update URLs (reject insecure except localhost) - Add path traversal protection in archive extraction - Use cryptographically secure random bytes for temp directories - Fix TOCTOU race condition in tar/zip extraction - Add SAFETY comments for unsafe Windows API calls - Address clippy warnings and code quality improvements
d65aa2b to
5b75003
Compare
Removed unused variants (Checking, CheckFailed, UpToDate) from UpdateStatus enum as per Greptile code review recommendation. Only variants that are actually used in the codebase are retained: NotChecked, Available, Downloading, and ReadyToRestart.
Summary
This PR implements a complete auto-update notification system for the Cortex TUI CLI that:
Features
A new version (X.Y.Z) is available- When an update is detectedDownloading... X%- During update download (with progress percentage)You must restart to run the latest version- After successful download/installationChanges
cortex-update crate (Security Fixes)
#![allow(warnings, clippy::all)]warning suppressiongetrandomcortex-tui crate (Feature Implementation)
cortex-updateas a dependencyUpdateStatusenum to track update states (NotChecked, Checking, Available, Downloading, ReadyToRestart, CheckFailed, UpToDate)update_statusandupdate_infofields toAppStaterender_update_banner()function in MinimalSessionView renderingAppRunner::run_direct_provider()Testing
cargo check -p cortex-update -p cortex-tuiScreenshots
The update banner appears above the input box in one of these styles:
↑ A new version (0.2.0) is available(accent color, bold)⟳ Downloading update... 45%(warning color)✓ You must restart to run the latest version(success color, bold)