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

3clyp50 committed Jan 6, 2026 at 01:56 UTC 1f0bbc27216af56c2a64eed83df885df3c4ef9f1
1 file changed +29
webui/components/modals/scheduler/scheduler-store.js
+29
@@ -937,7 +937,36 @@ const schedulerStoreModel = {
937 return this.formatProjectName(this.extractTaskProject(task));
938 },
939
940 + syncTasksFromSidebar(sidebarTasks) {
941 + // Sync scheduler store with sidebar's poll data for instant access
942 + if (!Array.isArray(sidebarTasks) || sidebarTasks.length === 0) return;
943 +
944 + // Smart merge: preserve object references to prevent UI flickering
945 + const taskMap = new Map(this.tasks.map((t) => [t.uuid, t]));
946 + this.tasks = sidebarTasks.map((sidebarTask) => {
947 + const taskId = sidebarTask.uuid || sidebarTask.id;
948 + const existing = taskMap.get(taskId);
949 + if (existing) {
950 + // Update existing object in-place if different
951 + if (JSON.stringify(existing) !== JSON.stringify(sidebarTask)) {
952 + Object.assign(existing, sidebarTask);
953 + }
954 + return existing;
955 + }
956 + return sidebarTask;
957 + });
958 + this.hasNoTasks = this.tasks.length === 0;
959 + },
960 +
961 showTaskDetail(taskId) {
962 + // Sync with sidebar data if our array is empty (e.g., on page load before modal opened)
963 + if (this.tasks.length === 0) {
964 + const tasksStore = globalThis.Alpine?.store?.('tasks');
965 + if (tasksStore?.tasks?.length > 0) {
966 + this.syncTasksFromSidebar(tasksStore.tasks);
967 + }
968 + }
969 +
970 const task = this.tasks.find((t) => t.uuid === taskId);
971 if (!task) {
972 this.notifyError("Task not found");