fix: persist "Planned later" and "Schedule" toggles in localStorage on runs page

The toggle states are now saved to localStorage and restored when
navigating back to the runs page, providing a consistent user experience.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Ruben Fiszel
2026-01-25 23:42:22 +00:00
co-authored by Claude Opus 4.5
parent 865ab70c89
commit 35081ca9d2
@@ -61,6 +61,16 @@
filters.path = initialPath
}
// Initialize toggle filters from localStorage if not set via URL params
// Check if URL has the params explicitly set; if not, use localStorage values
const urlParams = new URLSearchParams(window.location.search)
if (!urlParams.has('show_schedules')) {
filters.show_schedules = getShowSchedules()
}
if (!urlParams.has('show_future_jobs')) {
filters.show_future_jobs = getShowFutureJobs()
}
let selectedIds: string[] = $state([])
let loadingSelectedIds = $state(false)
let selectedWorkspace: string | undefined = $state(undefined)
@@ -98,6 +108,24 @@
}
}
function getShowSchedules() {
try {
return localStorage.getItem('show_schedules_in_runs') != 'false'
} catch (e) {
console.error('Error getting show schedules', e)
return true
}
}
function getShowFutureJobs() {
try {
return localStorage.getItem('show_future_jobs_in_runs') != 'false'
} catch (e) {
console.error('Error getting show future jobs', e)
return true
}
}
let manualDatePicker: ManuelDatePicker | undefined = $state(undefined)
let graph: 'RunChart' | 'ConcurrencyChart' = $state(
typeOfChart(page.url.searchParams.get('graph'))
@@ -274,6 +302,15 @@
}
})
// Persist toggle filters to localStorage
$effect(() => {
localStorage.setItem('show_schedules_in_runs', filters.show_schedules ? 'true' : 'false')
})
$effect(() => {
localStorage.setItem('show_future_jobs_in_runs', filters.show_future_jobs ? 'true' : 'false')
})
async function cancelJobs(uuidsToCancel: string[], forceCancel: boolean = false) {
const uuids = await JobService.cancelSelection({
workspace: $workspaceStore ?? '',