fix(notifications): reconcile stale monitored-node IDs; per-source select/deselect (#3486)#3487
Merged
Merged
Conversation
…lect/deselect (#3486) The Battery Alerts "monitored nodes" picker is source-scoped: it only lists the current source's nodes (/api/nodes?sourceId=…, also channel-permission filtered). The saved selection is per-source too, but IDs saved under a different source or for nodes that no longer exist under the active source stayed in selectedMonitoredNodes invisibly. "Deselect all" mapped only the visible/filtered rows, so it could never clear them — the count stuck at e.g. "11 selected" with nothing checked, and getLowBatteryMonitoredNodes matched nothing. - Reconcile: on load, prune the per-source selection to IDs that actually resolve under the active source (guarded on a populated node list so a failed/empty fetch can't wipe a valid selection; handles either nodes/prefs load order). - Select all / Deselect all now operate per-source: with no search term, Select all selects the whole current source and Deselect all clears the entire selection (stale IDs included). With a search active, the previous subset add/remove behaviour is preserved. Extracts the set logic into pure helpers (src/components/monitoredNodes.ts) with unit tests covering reconcile and both button modes. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Claude encountered an error —— View job I'll analyze this and get back to you. |
1 similar comment
|
Claude encountered an error —— View job I'll analyze this and get back to you. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #3486.
Problem
In Notifications → Battery Alerts, the "Select which nodes to monitor" picker showed a stuck selection count (e.g. "11 node(s) selected") with nothing visibly checked, and "Deselect all" couldn't clear it. Low-battery alerts also silently matched nothing.
Root cause
The picker is source-scoped: it only lists the current source's nodes (
/api/nodes?sourceId=…, also channel-permission filtered). The saved selection is per-source too, but node IDs saved under a different source — or for nodes that no longer exist under the active source — stayed inselectedMonitoredNodeswhile being invisible in the list. "Deselect all" mapped over only the visible/filtered rows (filteredNodes), so those stale IDs were unreachable and the count never went to 0.getLowBatteryMonitoredNodesthen found no matching nodes to alert on.(There is no key-format mismatch — selection and list both compare bare
nodeIdstrings. The IDs are simply filtered out of the source-scoped response.)Fix
Set logic is extracted into pure helpers (
src/components/monitoredNodes.ts) with unit tests.Notes
Validation
tsc --noEmit: clean🤖 Generated with Claude Code