-
Notifications
You must be signed in to change notification settings - Fork 22
Add version update checker for worker
CLI
#501
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
base: main
Are you sure you want to change the base?
Conversation
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.
Pull Request Overview
Adds a daily version update checker to the worker
CLI that fetches the latest release from GitHub, compares it against the current version, caches the result in the user’s home directory, and prints a notification with install instructions if an update is available.
- Introduce
VersionChecker
service for fetching, comparing, and caching version info - Register and invoke
VersionChecker
in the CLI entrypoint - Store and load a JSON cache at
~/.prime_worker_version_check
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
File | Description |
---|---|
crates/worker/src/services/version_checker.rs | New service implementing version fetching, comparison, caching, and notification |
crates/worker/src/services/mod.rs | Expose version_checker module |
crates/worker/src/cli/command.rs | Instantiate and run daily version check in execute_command |
Comments suppressed due to low confidence (1)
crates/worker/src/services/version_checker.rs:71
- There are no tests covering the caching logic or
should_check_today()
behavior. Adding tests for scenarios like a cache older than 24 hours versus recent cache would improve reliability.
fn should_check_today(&self) -> bool {
.map(|s| s.parse().unwrap_or(0)) | ||
.collect(); | ||
|
||
let latest_parts: Vec<u32> = latest | ||
.split('.') | ||
.take(3) | ||
.map(|s| s.parse().unwrap_or(0)) | ||
.collect(); |
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.
Parsing version components with unwrap_or(0)
swallows errors and never triggers the fallback in is_newer_version
. Consider returning a parse error instead of defaulting to zero so that non‐numeric or pre-release tags use the intended fallback logic.
.map(|s| s.parse().unwrap_or(0)) | |
.collect(); | |
let latest_parts: Vec<u32> = latest | |
.split('.') | |
.take(3) | |
.map(|s| s.parse().unwrap_or(0)) | |
.collect(); | |
.map(|s| s.parse()) | |
.collect::<Result<Vec<u32>, _>>()?; | |
let latest_parts: Vec<u32> = latest | |
.split('.') | |
.take(3) | |
.map(|s| s.parse()) | |
.collect::<Result<Vec<u32>, _>>()?; |
Copilot uses AI. Check for mistakes.
fn load_cache(&self) -> Result<VersionCheckCache> { | ||
let content = fs::read_to_string(&self.cache_file_path)?; |
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.
This synchronous std::fs::read_to_string
call runs on the async Tokio runtime and may block the executor. Consider using tokio::fs::read_to_string
or spawning a blocking task.
fn load_cache(&self) -> Result<VersionCheckCache> { | |
let content = fs::read_to_string(&self.cache_file_path)?; | |
async fn load_cache(&self) -> Result<VersionCheckCache> { | |
let content = tokio::fs::read_to_string(&self.cache_file_path).await?; |
Copilot uses AI. Check for mistakes.
Context
This PR addresses #413
Implementation
Example
Below is the message shown to users when a new update is available: