feat: add manual update-check keybinding ("C" key)#36
Conversation
Fixes #14 On startup, TRX already spawns a background thread to check for a new binary release. This commit lets the user re-trigger that check at any time without restarting the app. ## Changes ### config.rs Added `check_update: String` to `Keys` (default `"C"`). Configurable via `keys.check_update` in `config.toml`. ### ui/app.rs - Stored `update_tx: Sender<Option<(String, String)>>` on `App`. The auto-start thread now receives a **clone** of the sender, so the original remains available for manual re-use. - Added `trigger_manual_update_check()`: spawns a fresh thread that calls `check_for_updates(None)` (bypasses the skipped-version filter because the user explicitly asked) and sends the result back through the same `update_rx` channel — the existing update-prompt UI handles it identically. - Bound the `check_update` key in the normal-mode event loop. ### main.rs Added the new keybinding to `--help` output. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Pull request overview
Adds a manual “check for TRX binary updates” action that users can trigger during a running TUI session (normal mode) via a configurable keybinding, reusing the existing update prompt flow.
Changes:
- Introduce
keys.check_update(default"C") in configuration defaults. - Keep
update_txonAppand addtrigger_manual_update_check()to spawn an on-demand update check and send results to the existingupdate_rx. - Expose the new keybinding in
--helpoutput and bind it in the normal-mode event loop.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/ui/app.rs | Stores update_tx, adds manual update-check trigger method, and binds the new key in the main input loop. |
| src/config.rs | Extends Keys with check_update and sets its default value. |
| src/main.rs | Prints the new keybinding in --help output. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| #[derive(Debug, Serialize, Deserialize, Clone)] | ||
| pub struct Keys { | ||
| pub quit: String, | ||
| pub install: String, | ||
| pub remove: String, | ||
| pub search_edit: String, | ||
| pub toggle_select: String, | ||
| pub tab_next: String, | ||
| pub tab_prev: String, | ||
| pub system_upgrade: String, | ||
| pub refresh_db: String, | ||
| pub help: String, | ||
| pub check_update: String, | ||
| } |
There was a problem hiding this comment.
Fixed. Added #[serde(default = "default_check_update_key")] to the check_update field and a default_check_update_key() -> String helper. Existing configs without this key now deserialize with the default "C" instead of failing and wiping the whole config.
| /// Spawn a fresh update-check thread and funnel the result back through | ||
| /// the existing `update_rx` channel so the main event loop handles it | ||
| /// identically to the automatic startup check. | ||
| pub fn trigger_manual_update_check(&self) { | ||
| let tx = self.update_tx.clone(); | ||
| // Bypass the skipped-version filter for manual checks — the user | ||
| // explicitly asked, so always show the prompt even for a skipped tag. | ||
| thread::spawn(move || { | ||
| let res = crate::updater::check_for_updates(None); | ||
| let _ = tx.send(res); | ||
| }); | ||
| } |
There was a problem hiding this comment.
Fixed. The skip-clearing logic now only removes skipped_update_version when the detected version differs from the stored skip (i.e., the skip is truly stale). If the user manually checks and the same version is detected, their explicit skip is preserved.
| pub fn trigger_manual_update_check(&self) { | ||
| let tx = self.update_tx.clone(); | ||
| // Bypass the skipped-version filter for manual checks — the user | ||
| // explicitly asked, so always show the prompt even for a skipped tag. | ||
| thread::spawn(move || { | ||
| let res = crate::updater::check_for_updates(None); | ||
| let _ = tx.send(res); | ||
| }); |
There was a problem hiding this comment.
Fixed. Added an Arc<AtomicBool> field update_check_in_flight to the App struct. trigger_manual_update_check now uses compare_exchange to atomically claim the slot; if a check is already in flight the call returns early. The thread releases the guard when done.
- config.rs: add #[serde(default)] for check_update field (backward-compat) - app.rs: add AtomicBool guard to prevent overlapping update-check threads - app.rs: skip-clearing only removes skipped_update_version when detected version differs from stored skip (preserves user's explicit choice) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Fixes #14
Problem
TRX already checks for a new release at startup (when
auto_update_check = true), but there was no way for the user to re-trigger that check during a session without restarting the app.Solution
Press
C(configurable askeys.check_update) at any time in normal mode to immediately kick off a fresh update check.Implementation
config.rs— newcheck_update = "C"field inKeys.ui/app.rs:update_tx: Sender<Option<(String, String)>>is now stored onApp. The auto-start spawn receives a clone, so the sender is still available after the thread takes ownership.trigger_manual_update_check()method: spawns a thread that callscheck_for_updates(None)(bypassing the skipped-version filter — the user explicitly asked) and sends the result through the sameupdate_rxchannel. The existing update-prompt UI handles it without any extra code.Ckey bound in the normal-mode event loop.main.rs— new line in--helpoutput.