Skip to content

fix(mods): resolve startup mod updates notice when updates complete (#752) - #798

Merged
Zaldaryon merged 2 commits into
devfrom
fix/issue-752-startup-mod-update-notice
Nov 10, 2026
Merged

Zaldaryon merged 2 commits into
devfrom
fix/issue-752-startup-mod-update-notice

Conversation

@Zaldaryon

Copy link
Copy Markdown
Collaborator

Summary

When mod updates are detected on startup, GlobalModUpdateChecker displays an actionable notification banner ("The selected Installation has X Mods with updates available") with a "View updates" action. Because actionable notifications have no auto-dismiss timeout, the notice remained on screen indefinitely even after the player navigated to Manage Mods and completed "Update all" or updated the individual mods.

This change:

  1. Adds options.onCreated and options.id to NotificationOptions and introduces resolveNotification(id: string, resolvedWith?: string) to NotificationsContext to dismiss banners and mark records resolved in the Activity Center.
  2. Introduces an in-memory registry (modUpdateNotices.ts) tracking the active startup mod update notice per installation.
  3. Automatically resolves and dismisses the startup notice when:
    • "Update all" completes successfully in useBulkUpdateMods and leaves no remaining updatable mods.
    • Folder refresh in useManageInstalledMods finishes scanning and confirms zero updatable mods remain (covering single mod updates, manual installations, and deletions).

Type

  • Bug fix
  • Feature
  • Performance
  • Refactor or cleanup
  • Tests only
  • Docs or build

Checklist

  • Targets dev, not main.
  • npm run typecheck passes.
  • npm run lint:ci passes.
  • npm run format:check passes.
  • npm run test:coverage passes, coverage at or above the floor in vitest.config.ts.
  • npm run build:unpack passes.

Testing

  1. npm run typecheck: passed with zero errors across node, web, and tests.
  2. npm run lint:ci: passed with zero errors across oxlint and eslint.
  3. npm run format:check: passed with 100% formatted.
  4. npm run test:coverage: passed with 305 test files (1927 tests passed, 2 skipped) with coverage floors exceeded:
    • Statements: 95.06% (floor: 94.0%)
    • Branches: 91.27% (floor: 89.0%)
    • Functions: 95.87% (floor: 94.0%)
    • Lines: 97.03% (floor: 96.0%)
  5. npm run build:unpack: passed with unpacked Linux binary generated in dist/linux-unpacked.
  6. Unit and DOM tests:
    • Added unit tests in tests/renderer/modUpdateNotices.test.ts for recording, retrieving, and resolving startup notice entries.
    • Added unit tests in tests/renderer-dom/activityCenter.test.tsx for options.onCreated, options.id, and resolveNotification.
    • Added regression test in tests/renderer-dom/globalModUpdateChecker.test.tsx verifying startup notice tracking and dismissal upon resolution.

Related issues

Fixes #752

@Zaldaryon
Zaldaryon requested a review from Pixnop October 27, 2026 18:20

@Pixnop Pixnop left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I reviewed a560156d against dev adab6b96: ran your new tests against dev's code, then mounted Manage Mods with a recorded startup notice and tried a whole-folder Update all, an Update all with the search on, a scan with the ModDB unreachable, and an Installation switch during the 2 s delay.

The rescan in useManageInstalledMods.refresh is the right place for the fix. It judges the whole folder, and every update made on Manage Mods ends there: Update all flips _updatingMods (useBulkUpdateMods.ts:68 and :128), which reruns the scan (useManageInstalledMods.ts:46-47), and row updates call refresh. With a whole-folder Update all, the notice is resolved and leaves the screen, which is the case in #752. On dev's code the three test files fail, 2 of 67 tests plus two files at import, but only because the new API is missing. With both resolveStartupModUpdateNotice calls turned into no-ops, all 75 tests still pass, so nothing pins the fix itself.

Approving. Notes 1 to 4 are worth taking in this PR, since 1 and 3 are deletions. The rest can wait.

Not blocking

  1. Update all with the search on closes the notice while other Mods still have updates. The page runs Update all on visibleMods (ManageMods.tsx:232), and remainingUpdatable (useBulkUpdateMods.ts:112) only looks at that list. With Alpha and Beta updatable, I searched "alpha" and clicked Update all: the notice was resolved, and the rescan that followed still listed Beta under updates. The block is not needed: without it, I checked that the rescan closes the notice after a whole-folder Update all and keeps it after the filtered one. Removing the block, its import and the resolveNotification destructure fixes it.

  2. A scan whose ModDB lookups fail closes the notice. _updatableTo is only set when the lookup worked, so offline, or once a timeout makes the remaining lookups fail, updatableCount can be 0 and useManageInstalledMods.ts:61-64 resolves the notice though nothing was updated. I reproduced it with queryURL rejecting. The startup check already treats failed lookups as unknown (#618). Passing onFinish to getCompleteInstalledMods in refresh and resolving only when failedLookups === 0 would match.

  3. The new timer cleanup loses the notice for the session. ADD_NOTIFIED_MOD_UPDATE is dispatched (GlobalModUpdateChecker.tsx:31) before the timer starts (:33). If the player switches Installation during the 2 s, the cleanup at :59 cancels the notice, and coming back does not post it again. A test that switches away and back passes on dev and fails here. The cleanup is outside #752, so I would drop it. If you want it, move the dispatch inside the timeout callback.

  4. The tests do not reach the paths that carry the fix. The new test at globalModUpdateChecker.test.tsx:173 resolves through a synthetic ResolveNoticeButton. tests/renderer-dom/helpers/mountManageMods.tsx already gives a ManageMods harness. Four cases would hold it: whole-folder Update all closes the notice, a filtered Update all that leaves Beta keeps it, failed lookups keep it, and a single row update closes it.

  5. A second notice for the same Installation orphans the first. When startup lookups partly failed, switching away and back posts the notice again (the #618 test shows two). A notice with an action is never folded into an earlier one, so modUpdateNotices.ts:12 overwrites the first id and only the second gets resolved: the first banner stays on screen, or in the Activity Center if it was closed with x. With the #618 setup, resolving after the revisit left one of the two banners up. Keeping a set of ids per Installation, or resolving the old id before recording a new one, covers it.

  6. Updates from the ModDB catalog page do not close the notice right away. ModReleaseList can update an installed Mod from InstallMod.tsx:98, which never runs the Manage Mods rescan, so the notice waits for the next visit to Manage Mods. Fine if the module comment says so.

  7. Some new API surface is unused. Production code never sets NotificationOptions.id (read at NotificationsContext.tsx:430), and getStartupModUpdateNotice, clearStartupModUpdateNotice and the boolean returned by resolveStartupModUpdateNotice only serve tests. Since onCreated runs synchronously, addNotification returning the id, as the issue suggested, would do the same with less. The reset helper would match resetWhatsNewCacheForTests as ...ForTests.

@Zaldaryon
Zaldaryon merged commit f294de1 into dev Nov 10, 2026
11 checks passed
@Zaldaryon
Zaldaryon deleted the fix/issue-752-startup-mod-update-notice branch November 10, 2026 23:10
Pixnop added a commit that referenced this pull request Nov 10, 2026
refresh now passes both the scan cache and the onFinish that resolves the startup update notice from #798. onFinish skips a scan already superseded by an applied one, so an older folder read cannot resolve the notice.
@Pixnop

Pixnop commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

I reviewed 270e9623 against a560156d: read the new commit and the whole PR again against #752, put each old bug back to see which test goes red, and merged the branch with #806 to check the onFinish resolve against its cached ModDB answers.

Round one

Update all with the search on no longer closes the notice. The block in useBulkUpdateMods.ts is gone, so only the whole-folder rescan decides (useManageInstalledMods.ts:57-59), and every update on the page ends in it: Update all through the effect at :44-47, rows through refresh. The filtered case does not hold this yet, see note 1.

A scan with failed lookups keeps the notice. onFinish resolves only when updates === 0 && failedLookups === 0, the same rule as the startup check. With the ModDB offline, Reload reports 0 updates and 2 failures, and the notice stays.

The timer cleanup is gone. GlobalModUpdateChecker.tsx is dev's code again apart from onCreated.

The tests now go through Manage Mods. The all and row cases (manageMods.test.tsx:2483) fail on dev with only modUpdateNotices.ts copied in, and fail at this head when the onFinish resolve is a no-op. The beforePage slot in mountManageMods is a tidy way to mount the checker next to the page.

A second notice no longer orphans the first. The set per Installation (modUpdateNotices.ts:5) is deleted before its ids are resolved, so a second resolve does nothing. tests/renderer/modUpdateNotices.test.ts goes red when recordStartupModUpdateNotice keeps one id again.

The catalog limit is in the module comment (modUpdateNotices.ts:1-4), and the unused API is removed.

Still approved.

Not blocking

  1. The filtered and offline cases can pass with notes 1 and 2 put back. manageMods.test.tsx:2535 checks the notice with getByText right after the rescan. A resolved toast stays in the DOM during its exit animation (NotificationsOverlay.tsx:163-174), so the check still finds it. With the old Update all block restored, filtered passed 4 runs out of 4. With the condition reduced to updates === 0, offline fails alone or in a run of the whole file, but passed 5 out of 5 when the four cases ran on their own, so it only catches that bug by timing. With this line in its place, both fail every time and the four cases still pass at this head:

    await expect(waitFor(() => expect(screen.queryByText(notice)).toBeNull(), { timeout: 1_500 })).rejects.toThrow()
  2. The only change left in useBulkUpdateMods.ts is the braces at :109-111. They conflicted with Show a singular form in the partial Mod update toast #803, which rewrites the next line of that if/else. I kept them when I merged dev into Show a singular form in the partial Mod update toast #803, so nothing is left to do there.

  3. Make enabling, disabling or deleting a Mod in Manage Mods stop waiting on the ModDB #806 conflicted in refresh. Both PRs add a property after version: installation.version, in the getCompleteInstalledMods({...}) call: onFinish here, cache there. Keeping both is the whole fix, and the tests of both PRs pass on the merged tree. Resolving from onFinish still behaves after Make enabling, disabling or deleting a Mod in Manage Mods stop waiting on the ModDB #806. A row update closes the notice from the cached releases without a new lookup. A lookup that failed in the page-open scan is reused as a failure, so the notice stays until Reload or the next full scan. I have since added that case to Make enabling, disabling or deleting a Mod in Manage Mods stop waiting on the ModDB #806: one lookup fails, the only updatable Mod is updated from its row, and the notice stays.

Zaldaryon added a commit that referenced this pull request Nov 16, 2026
* Address review follow-ups for merged pull requests

* Test recovery folder recheck after copy

* Align French config recovery messages
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.

2 participants