Skip to content

feat(code): toast when manual update check finds no update#2024

Open
k11kirky wants to merge 3 commits intomainfrom
posthog-code/up-to-date-toast
Open

feat(code): toast when manual update check finds no update#2024
k11kirky wants to merge 3 commits intomainfrom
posthog-code/up-to-date-toast

Conversation

@k11kirky
Copy link
Copy Markdown
Contributor

@k11kirky k11kirky commented May 5, 2026

Summary

Addresses Marcus's papercut: clicking Check for Updates… in the app menu was silent when no update was available. Now a "You're on the latest version" success toast surfaces, while automatic background checks remain quiet.

How it works

  • Tracks a menuCheckPending flag in updateStore that's only set when the onCheckFromMenu subscription fires (the menu-triggered path).
  • When the next status update reports upToDate, the flag is consumed and a success toast is shown.
  • If the check fails, an error toast is shown instead.
  • If an update was found, the existing UpdateBanner already surfaces it, so the toast is suppressed.
  • Periodic/automatic checks never set the flag, so they stay silent.
  • The Settings page bypasses the store and runs its own mutation, so its inline status text isn't double-shown as a toast.

Test plan

  • Run pnpm typecheck, pnpm lint, pnpm test — all pass locally.
  • Manual: in a packaged build, click Check for Updates… when on the latest version → expect "You're on the latest version" toast.
  • Manual: when an update is available → expect the existing UpdateBanner (no extra toast).
  • Manual: with no network → expect "Failed to check for updates" toast.
  • Manual: leave the app open and confirm hourly periodic checks remain silent.

Created with PostHog Code

Generated-By: PostHog Code
Task-Id: d79f9950-8e3f-4cc1-9e09-166a4f99aad5
@k11kirky k11kirky marked this pull request as ready for review May 5, 2026 09:26
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 5, 2026

Comments Outside Diff (1)

  1. apps/code/src/renderer/stores/updateStore.ts, line 98-101 (link)

    P1 If the status subscription fires an onError, menuCheckPending is never reset. Any subsequent onData call (e.g. from a background periodic check that recovers) would then fire a spurious "You're on the latest version" toast even though the user didn't click Check for Updates.

    Prompt To Fix With AI
    This is a comment left during a code review.
    Path: apps/code/src/renderer/stores/updateStore.ts
    Line: 98-101
    
    Comment:
    If the status subscription fires an `onError`, `menuCheckPending` is never reset. Any subsequent `onData` call (e.g. from a background periodic check that recovers) would then fire a spurious "You're on the latest version" toast even though the user didn't click **Check for Updates**.
    
    
    
    How can I resolve this? If you propose a fix, please make it concise.
Prompt To Fix All With AI
Fix the following 2 code review issues. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 2
apps/code/src/renderer/stores/updateStore.ts:98-101
If the status subscription fires an `onError`, `menuCheckPending` is never reset. Any subsequent `onData` call (e.g. from a background periodic check that recovers) would then fire a spurious "You're on the latest version" toast even though the user didn't click **Check for Updates**.

```suggestion
    onError: (error) => {
      log.error("Update status subscription error", { error });
      menuCheckPending = false;
    },
  });
```

### Issue 2 of 2
apps/code/src/renderer/stores/updateStore.ts:121-126
Only `"disabled"` and `"already_checking"` (implicit fall-through) are handled. Any other `errorCode` value — including future ones — silently leaves `menuCheckPending = true` forever. The intent is clearly to keep the flag only for `"already_checking"`; making that explicit and resetting otherwise is safer.

```suggestion
          if (!result.success) {
            if (result.errorCode === "disabled") {
              menuCheckPending = false;
              toast.error(result.errorMessage ?? "Updates not available");
            } else if (result.errorCode !== "already_checking") {
              // Unknown/future error code — reset the flag so it never gets stuck.
              menuCheckPending = false;
            }
            // For "already_checking", keep the flag so the in-flight check
            // surfaces the toast when it resolves.
          }
```

Reviews (1): Last reviewed commit: "feat(code): toast when manual update che..." | Re-trigger Greptile

Comment thread apps/code/src/renderer/stores/updateStore.ts Outdated
k11kirky and others added 2 commits May 5, 2026 10:31
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Prevents a stale flag from triggering a spurious "You're on the latest
version" toast when a subsequent periodic check resolves after the
subscription recovers from an error. Flagged by Greptile.

Generated-By: PostHog Code
Task-Id: d79f9950-8e3f-4cc1-9e09-166a4f99aad5
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.

1 participant