From 1f0bbc27216af56c2a64eed83df885df3c4ef9f1 Mon Sep 17 00:00:00 2001 From: 3clyp50 Date: Tue, 6 Jan 2026 01:56:13 +0100 Subject: [PATCH] task sync from sidebar in scheduler store - Added method to merge sidebar tasks into the scheduler store, preserving object references - Updated showTaskDetail to sync with sidebar when the task list is empty (the empty array was causing the Task not found error. Tasks are now available on page load --- .../modals/scheduler/scheduler-store.js | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/webui/components/modals/scheduler/scheduler-store.js b/webui/components/modals/scheduler/scheduler-store.js index 819fb99e6..bda9dc4e6 100644 --- a/webui/components/modals/scheduler/scheduler-store.js +++ b/webui/components/modals/scheduler/scheduler-store.js @@ -937,7 +937,36 @@ const schedulerStoreModel = { return this.formatProjectName(this.extractTaskProject(task)); }, + syncTasksFromSidebar(sidebarTasks) { + // Sync scheduler store with sidebar's poll data for instant access + if (!Array.isArray(sidebarTasks) || sidebarTasks.length === 0) return; + + // Smart merge: preserve object references to prevent UI flickering + const taskMap = new Map(this.tasks.map((t) => [t.uuid, t])); + this.tasks = sidebarTasks.map((sidebarTask) => { + const taskId = sidebarTask.uuid || sidebarTask.id; + const existing = taskMap.get(taskId); + if (existing) { + // Update existing object in-place if different + if (JSON.stringify(existing) !== JSON.stringify(sidebarTask)) { + Object.assign(existing, sidebarTask); + } + return existing; + } + return sidebarTask; + }); + this.hasNoTasks = this.tasks.length === 0; + }, + showTaskDetail(taskId) { + // Sync with sidebar data if our array is empty (e.g., on page load before modal opened) + if (this.tasks.length === 0) { + const tasksStore = globalThis.Alpine?.store?.('tasks'); + if (tasksStore?.tasks?.length > 0) { + this.syncTasksFromSidebar(tasksStore.tasks); + } + } + const task = this.tasks.find((t) => t.uuid === taskId); if (!task) { this.notifyError("Task not found");