mirror of
https://github.com/jesseduffield/lazygit.git
synced 2026-11-21 04:46:29 +03:00
amend! Remind the user of an update when lazygit is idle
Remind the user of an update when lazygit is idle The note in the bottom-right corner is easy to miss. Users need a notification to actually update, but one that pops up at startup gets in the way of the work that they started lazygit for. Show the update menu when the user hasn't pressed a key or used the mouse for a minute, and no other popup is open. After the user responds to the menu, don't show it again for a day. Users who never leave lazygit idle wouldn't see the menu at all, so also show it at startup if the update has been available for a week and the user never responded to the menu for it. The menu now has "Remind me tomorrow" and "Skip this version"; closing the menu does the same as the former. Skipping a version keeps lazygit quiet until a newer one comes out, but the note stays. If several lazygit instances are idle at the same time, e.g. in different terminal tabs, all of them show the menu. Otherwise a lazygit that the user forgot in some tab would get the reminder every day, and the others never. When the user responds to the menu in one of them, the others close theirs. If update.method is never, don't show the menu; only the note appears then. The menu tells the user about this setting. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
1f2bc0a4b5
commit
2396d6e738
4 files changed
+13
-2
No files matched your search
@@ -307,6 +307,8 @@ func (self *UpdateHelper) updateMenuOptions(newVersion *types.VersionNumber) typ
|
||||
},
|
||||
},
|
||||
)
|
||||
paragraphs = append(paragraphs, self.c.Tr.TurnOffUpdateReminders)
|
||||
|
||||
// Whatever the user chooses counts as a response, and so does closing the
|
||||
// menu
|
||||
for _, item := range items {
|
||||
|
||||
@@ -291,6 +291,7 @@ type TranslationSet struct {
|
||||
RestartToUseNewVersion string
|
||||
RemindMeTomorrow string
|
||||
SkipThisVersion string
|
||||
TurnOffUpdateReminders string
|
||||
IntroPopupMessage string
|
||||
NonReloadableConfigWarningTitle string
|
||||
NonReloadableConfigWarning string
|
||||
@@ -1529,6 +1530,7 @@ func EnglishTranslationSet() *TranslationSet {
|
||||
RestartToUseNewVersion: "Restart to use {{.newVersion}}",
|
||||
RemindMeTomorrow: "Remind me tomorrow",
|
||||
SkipThisVersion: "Skip this version",
|
||||
TurnOffUpdateReminders: "To turn off these reminders, set update.method to never in your config file.",
|
||||
IntroPopupMessage: englishIntroPopupMessage,
|
||||
NonReloadableConfigWarningTitle: "Config changed",
|
||||
NonReloadableConfigWarning: englishNonReloadableConfigWarning,
|
||||
|
||||
@@ -256,6 +256,13 @@ func (u *Updater) IsStartingUp() bool {
|
||||
return u.now().Sub(u.startTime) < startupPeriod
|
||||
}
|
||||
|
||||
// RemindersEnabled returns whether lazygit reminds the user of available
|
||||
// updates. With update.method set to never, it only shows the note in the
|
||||
// bottom-right corner.
|
||||
func (u *Updater) RemindersEnabled() bool {
|
||||
return u.ChecksEnabled() && u.UserConfig().Update.Method != "never"
|
||||
}
|
||||
|
||||
// DueReminder returns the version to remind the user of, or nil if no reminder
|
||||
// is due
|
||||
func (u *Updater) DueReminder(reminder Reminder) *types.VersionNumber {
|
||||
@@ -263,7 +270,7 @@ func (u *Updater) DueReminder(reminder Reminder) *types.VersionNumber {
|
||||
}
|
||||
|
||||
func (u *Updater) dueReminder(state *config.AppState, reminder Reminder) *types.VersionNumber {
|
||||
if !u.ChecksEnabled() {
|
||||
if !u.RemindersEnabled() {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -351,7 +351,7 @@ func TestIsHandledAfter(t *testing.T) {
|
||||
assert.True(t, updater.IsHandledAfter(shownAt))
|
||||
}
|
||||
|
||||
func TestRemindersAreOffWhenChecksAre(t *testing.T) {
|
||||
func TestRemindersAreOffWithUpdateMethodNever(t *testing.T) {
|
||||
updater := newTestUpdater(t, nil, "0.66.2", Installation{Kind: InstallKindRelease, ExecutablePath: "/bin/lazygit"})
|
||||
updater.appState.(*fakeAppStateStore).state.Updates = config.UpdatesState{LatestVersion: "v0.67.0"}
|
||||
updater.UserConfig().Update.Method = "never"
|
||||
|
||||
Reference in new issue
Block a user