Skip to content

feat: add manual update-check keybinding ("C" key)#36

Merged
yashksaini-coder merged 2 commits into
mainfrom
feat/manual-update-check
May 26, 2026
Merged

feat: add manual update-check keybinding ("C" key)#36
yashksaini-coder merged 2 commits into
mainfrom
feat/manual-update-check

Conversation

@yashksaini-coder
Copy link
Copy Markdown
Collaborator

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 as keys.check_update) at any time in normal mode to immediately kick off a fresh update check.

Implementation

config.rs — new check_update = "C" field in Keys.

ui/app.rs:

  • update_tx: Sender<Option<(String, String)>> is now stored on App. The auto-start spawn receives a clone, so the sender is still available after the thread takes ownership.
  • New trigger_manual_update_check() method: spawns a thread that calls check_for_updates(None) (bypassing the skipped-version filter — the user explicitly asked) and sends the result through the same update_rx channel. The existing update-prompt UI handles it without any extra code.
  • C key bound in the normal-mode event loop.

main.rs — new line in --help output.

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>
@vercel
Copy link
Copy Markdown

vercel Bot commented May 26, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
trx Ready Ready Preview, Comment May 26, 2026 6:45am

Copy link
Copy Markdown
Contributor

Copilot AI left a 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 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_tx on App and add trigger_manual_update_check() to spawn an on-demand update check and send results to the existing update_rx.
  • Expose the new keybinding in --help output 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.

Comment thread src/config.rs
Comment on lines 22 to 35
#[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,
}
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/ui/app.rs
Comment on lines +149 to +160
/// 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);
});
}
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/ui/app.rs
Comment on lines +152 to +159
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);
});
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
@yashksaini-coder yashksaini-coder merged commit 7d3d0a3 into main May 26, 2026
2 checks passed
@yashksaini-coder yashksaini-coder deleted the feat/manual-update-check branch May 28, 2026 04:22
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.

Feature: Add a update kyemap option

2 participants