glad-web 1.0.11 → 1.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -52,6 +52,7 @@ function normalizeJob(input, existing = null, options = {}) {
52
52
  const now = Date.now();
53
53
  const schedule = input.schedule || {};
54
54
  const target = input.target || {};
55
+ const hasStoredNextRunAt = existing && typeof existing.nextRunAt === 'number';
55
56
  const job = {
56
57
  id: existing?.id || input.id || uuidv4(),
57
58
  name: String(input.name || existing?.name || 'Scheduled Task').trim() || 'Scheduled Task',
@@ -73,7 +74,13 @@ function normalizeJob(input, existing = null, options = {}) {
73
74
  lastSessionId: existing?.lastSessionId || input.lastSessionId || null,
74
75
  running: Boolean(existing?.running || false)
75
76
  };
76
- job.nextRunAt = job.enabled ? computeNextRunAt(job.schedule) : null;
77
+
78
+ if (options.recomputeNextRunAt || !hasStoredNextRunAt) {
79
+ job.nextRunAt = job.enabled ? computeNextRunAt(job.schedule, now) : null;
80
+ } else {
81
+ job.nextRunAt = existing.nextRunAt;
82
+ }
83
+
77
84
  return job;
78
85
  }
79
86
 
@@ -102,7 +109,17 @@ class JobStore {
102
109
  const jobs = this.list();
103
110
  const index = jobs.findIndex(job => job.id === id);
104
111
  if (index === -1) return null;
105
- jobs[index] = normalizeJob(input, jobs[index], { touch: true });
112
+ const existing = jobs[index];
113
+ const nextSchedule = {
114
+ time: String(input.schedule?.time || existing.schedule?.time || '09:00'),
115
+ weekdays: normalizeWeekdays(input.schedule?.weekdays ?? existing.schedule?.weekdays ?? [1, 2, 3, 4, 5])
116
+ };
117
+ const scheduleChanged = JSON.stringify(nextSchedule) !== JSON.stringify(existing.schedule);
118
+ const enabledChanged = Boolean(input.enabled ?? existing.enabled ?? true) !== Boolean(existing.enabled);
119
+ jobs[index] = normalizeJob(input, existing, {
120
+ touch: true,
121
+ recomputeNextRunAt: scheduleChanged || enabledChanged
122
+ });
106
123
  this.saveAll(jobs);
107
124
  return jobs[index];
108
125
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "glad-web",
3
- "version": "1.0.11",
3
+ "version": "1.0.12",
4
4
  "description": "Glad transforms terminal-based AI coding tools into a polished, mobile-friendly local Web interface.",
5
5
  "main": "index.js",
6
6
  "bin": {