Skip to content

fix: stop re-prompting update after user skips or upgrades#25

Merged
pie-314 merged 2 commits into
mainfrom
fix/update-loop-bug
May 22, 2026
Merged

fix: stop re-prompting update after user skips or upgrades#25
pie-314 merged 2 commits into
mainfrom
fix/update-loop-bug

Conversation

@yashksaini-coder
Copy link
Copy Markdown
Collaborator

Fixes #24.

Root causes fixed

Three bugs caused TRX to keep showing the update dialog on every launch:

1. Dead should_update field removed

App::should_update: Option<String> was initialized to None and never written to anywhere. The guard && self.should_update.is_none() was always true (dead code). Field and guard removed.

2. Skip is now persisted across restarts

Pressing Esc or q on the update prompt previously only dismissed the dialog in-memory. On the next launch the same GitHub release was fetched and the user was prompted again, forever.

Fix: when the user dismisses the prompt, the skipped version string is written to ~/.config/trx/config.toml as settings.skipped_update_version. The value survives restarts. When a genuinely newer tag appears on GitHub the stored version no longer matches, so the prompt resurfaces automatically — users are never silently stuck on an old version.

3. check_for_updates skips early for persisted skip

The signature changed from check_for_updates()check_for_updates(skipped_version: Option<&str>). The background thread is handed the persisted value at startup and returns None immediately if the latest release matches — so the channel event is never sent and the UI never receives a stale prompt.

Files changed

File Change
src/config.rs Added skipped_update_version: Option<String> to Settings (defaults to None)
src/updater.rs New skipped_version param; early-return when it matches latest
src/ui/app.rs Removed dead field, persists skip on Esc/q, passes skipped version to thread

Testing

cargo build          # compiles clean, zero warnings

Manual test flow:

  1. Build a dev binary where current version < latest tag
  2. Launch → update prompt appears
  3. Press Esc → inspect ~/.config/trx/config.toml: skipped_update_version field is set
  4. Relaunch → no prompt (skipped version matches latest)
  5. Simulate a newer tag → prompt reappears

Fixes #24.

Three bugs caused TRX to keep prompting the same update indefinitely:

1. Dead code: App::should_update field was initialized to None and never
   written to; the guard it gated was always true. Removed the field and
   cleaned up the guard.

2. No skip persistence: pressing Esc on the update prompt dismissed the
   dialog in-memory only. On the next launch the same version was fetched
   and the prompt appeared again. Now the skipped version is written to
   ~/.config/trx/config.toml (settings.skipped_update_version) so it
   survives restarts. When a genuinely newer release appears the stored
   version no longer matches and the prompt resurfaces automatically.

3. check_for_updates now accepts skipped_version: Option<&str> and
   returns None immediately when the latest release matches the user's
   persisted skip, so the background thread never sends the stale event.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 21, 2026 04:32
@vercel
Copy link
Copy Markdown

vercel Bot commented May 21, 2026

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

Project Deployment Actions Updated (UTC)
trx Building Building Preview May 21, 2026 4:32am

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

This PR addresses repeated update prompts by persisting “skipped” update state in the user config and using that persisted value to suppress prompts for the same GitHub release across restarts.

Changes:

  • Add settings.skipped_update_version to the persisted config and default it to None.
  • Update the updater to accept an optional skipped version and early-return when it matches the latest tag.
  • Remove the dead App::should_update field and persist the skipped version when the user dismisses the update prompt (Esc/q).

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/config.rs Adds persisted skipped_update_version setting (default None).
src/updater.rs Adds skipped_version parameter and suppresses prompt when it matches latest.
src/ui/app.rs Removes unused should_update, passes persisted skip into update check thread, persists skip on dismiss.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/config.rs Outdated
Comment on lines +16 to +17
/// Version the user explicitly skipped. Cleared automatically when a
/// genuinely newer release appears, so the prompt resurfaces then.
The doc comment said the field was "cleared automatically" when a newer
release appears, but the code only ignored the stale value — the config
file still held the old skipped version string.

Now, when the background thread returns a new update event (meaning the
latest tag is genuinely newer than the skipped version), the app clears
skipped_update_version and persists the config before showing the prompt.
This keeps the stored config tidy and makes the behavior match the docs.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Owner

@pie-314 pie-314 left a comment

Choose a reason for hiding this comment

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

LGTM

@pie-314 pie-314 merged commit df5bc8e into main May 22, 2026
@yashksaini-coder yashksaini-coder deleted the fix/update-loop-bug branch May 26, 2026 05: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.

bug: TRX repeatedly prompts for update even after successfully updating

3 participants