mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-10-22 11:45:52 +00:00
Persist include-resolved across Patrol findings polling
loadDashboardData and other unscoped loadPatrolFindings callers were overwriting the Resolved/All tab data set with the active-only payload on every poll, causing those tabs to blink empty between refreshes. A module-level sticky preference now flips to true the first time any caller asks for includeResolved and keeps subsequent unscoped loads expanded, so the Resolved and All tabs hold their data across polling.
This commit is contained in:
@@ -200,6 +200,15 @@ const [findingsError, setFindingsError] = createSignal<string | null>(null);
|
||||
const [patrolFindings, setPatrolFindings] = createSignal<UnifiedFinding[]>([]);
|
||||
const [patrolFindingsLoading, setPatrolFindingsLoading] = createSignal(false);
|
||||
const [patrolFindingsError, setPatrolFindingsError] = createSignal<string | null>(null);
|
||||
// Sticky preference: once a surface asks for include-resolved data,
|
||||
// subsequent unscoped loadPatrolFindings calls (from polling, dashboard
|
||||
// refresh, etc.) keep returning the expanded set. Otherwise the
|
||||
// Resolved/All tabs would intermittently empty whenever a polling
|
||||
// loadDashboardData overwrote the include-resolved load with the
|
||||
// active-only default. Reset to false when nothing on screen needs the
|
||||
// expanded set (no current call site does this; FindingsPanel's effect
|
||||
// would set it back to true the moment Resolved/All becomes active).
|
||||
let patrolFindingsIncludeResolvedPreference = false;
|
||||
|
||||
function normalizeUnifiedFindingRecord(item: UnifiedFindingRecord, now: number): UnifiedFinding {
|
||||
const alertIdentifier = item.alertIdentifier;
|
||||
@@ -443,10 +452,22 @@ export const aiIntelligenceStore = {
|
||||
},
|
||||
|
||||
async loadPatrolFindings(options?: { includeResolved?: boolean }) {
|
||||
// Sticky preference: once a caller has explicitly asked for the
|
||||
// expanded set, treat all subsequent loads (including unscoped
|
||||
// polling refreshes) as expanded so the Resolved/All tab data does
|
||||
// not blink to empty between polls. The Patrol findings endpoint
|
||||
// is cheap; the per-finding cap keeps the payload bounded.
|
||||
if (options?.includeResolved) {
|
||||
patrolFindingsIncludeResolvedPreference = true;
|
||||
}
|
||||
const includeResolved =
|
||||
options?.includeResolved === true || patrolFindingsIncludeResolvedPreference;
|
||||
setPatrolFindingsLoading(true);
|
||||
setPatrolFindingsError(null);
|
||||
try {
|
||||
const findings = await getPatrolFindings(options);
|
||||
const findings = await getPatrolFindings(
|
||||
includeResolved ? { includeResolved: true } : undefined,
|
||||
);
|
||||
const now = Date.now();
|
||||
setPatrolFindings(findings.map((item) => normalizePatrolFindingRecord(item, now)));
|
||||
} catch (e) {
|
||||
|
||||
Reference in New Issue
Block a user