fix: skip draft/pre-release versions in update banner check (#2254)#2268
fix: skip draft/pre-release versions in update banner check (#2254)#2268idling11 wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Code Review
This pull request adds a check to skip draft and pre-release versions when checking for new updates in the TUI. However, the reviewer pointed out that the GitHub API /releases/latest endpoint already excludes drafts and pre-releases, making this check redundant. The reviewer suggested either updating the CI/CD workflow to publish the release only after assets are uploaded, or checking if the assets array is empty in the client-side code.
| if json["draft"].as_bool().unwrap_or(true) | ||
| || json["prerelease"].as_bool().unwrap_or(false) | ||
| { | ||
| return None; | ||
| } |
There was a problem hiding this comment.
The GitHub API endpoint /releases/latest is documented to explicitly exclude both draft and pre-release versions (it only returns the most recent non-draft, non-prerelease release). Because of this, a successful response from this endpoint will never have draft: true or prerelease: true, making this check redundant.
If the premature banner is currently being triggered when a tag is pushed, it is likely because the CI/CD workflow immediately publishes the release as a full, non-draft release before the assets are fully uploaded. In that scenario, draft and prerelease will both be false, meaning this check will not prevent the premature banner.
To resolve this issue effectively, you can either:
- Recommended: Update the CI/CD workflow to create the release as a
draftfirst, upload the assets, and only publish it (setdrafttofalse) once all assets are uploaded. Since/releases/latestalready ignores drafts, this requires no client-side changes. - Client-side fallback: Check if the
assetsarray in the JSON response is empty. If no assets are uploaded yet, we can skip showing the banner.
if json["assets"].as_array().map_or(true, |a| a.is_empty()) {
return None;
}| if json["draft"].as_bool().unwrap_or(true) | ||
| || json["prerelease"].as_bool().unwrap_or(false) | ||
| { |
There was a problem hiding this comment.
The fallback defaults for the two fields are inconsistent.
draft uses unwrap_or(true) — treating a missing/non-bool value as "yes, it's a draft" (skip the banner) — while prerelease uses unwrap_or(false) — treating missing as "no, it's not a pre-release" (don't skip). If the draft key is ever absent from the response, all update notifications will be silently suppressed forever. Both fields should use the same default.
| if json["draft"].as_bool().unwrap_or(true) | |
| || json["prerelease"].as_bool().unwrap_or(false) | |
| { | |
| if json["draft"].as_bool().unwrap_or(false) | |
| || json["prerelease"].as_bool().unwrap_or(false) | |
| { |
|
Thanks @idling11. I folded the draft/prerelease guard from this PR into #2275, which also requires the release assets plus checksum manifest to be uploaded and makes the update hint a transient status toast instead of a persistent footer override. I added explicit credit for #2268 in #2275 so the contribution is carried into the v0.8.48 release notes/credit pass if that path lands. Leaving this open until #2275 finishes CI, then we can close/supersede this one without losing the attribution. |
Summary
Version-check background task now ignores draft and pre-release
GitHub releases so a pushed tag does not trigger a premature
"vX.Y.Z available" banner before release assets are uploaded.
Closes: #2254
Problem
/releases/latestGitHub API returns the most recent releaseincluding drafts and pre-releases. When a maintainer pushes a tag
(but hasn't uploaded binary assets yet), the status bar shows
a persistent "new version available" message that:
statusline items
Fix
After fetching the release JSON, check
draftandprereleasefields. If either is
true, returnNoneso no hint is shown.Files Changed
crates/tui/src/tui/ui.rsGreptile Summary
Adds a guard in the background version-check task that skips GitHub releases where
draftorprereleaseistrue, preventing a premature "new version available" banner before release assets are ready.None(no banner) when either flag is set.draftusesunwrap_or(true)(treat missing as draft → always skip) whileprereleaseusesunwrap_or(false)(treat missing as stable → don't skip). This inconsistency means an absent or non-booleandraftfield would permanently silence all update notifications.Confidence Score: 4/5
The change is safe to merge — it tightens the update-notification filter and cannot break any other functionality.
The logic is sound and the GitHub API reliably returns these fields, so the asymmetric defaults are unlikely to cause problems in practice. However, unwrap_or(true) on draft silently suppresses all update banners any time the field is missing, while unwrap_or(false) on prerelease takes the opposite stance.
Only crates/tui/src/tui/ui.rs is affected; the inconsistent fallback defaults in the new guard are the only item worth a second look.
Important Files Changed
draftfield's fallback default is inconsistent withprerelease's, risking silent suppression of all update notifications if the field is absent.Reviews (1): Last reviewed commit: "fix: skip draft/prerelease versions in u..." | Re-trigger Greptile