Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix: skip already-elapsed perpetual parks when updateTaskInterval recomputes cadence (#3590)

[._.]/ Adam Eivyf3c0dfcaa218
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index babe7eb1ab..4846dc47ab 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -197,3 +197,4 @@
- **[issue-3566] The Writers Room synced review no longer hides its Script and Media panes on a phone.** The three panes were laid out as a grid that only ever split into columns at desktop widths; below that they stacked into one column inside a fixed-height, `overflow-hidden` container with nothing to scroll, so on a ~375px screen the Prose pane filled the view and Script and Media sat past the bottom edge, unreachable — the cross-link highlighting the panel exists for was invisible on half of it. Narrow widths now show one pane at a time, picked from a 44px-tall selector that replaces the desktop "which panes sit side by side" toggles in the same spot on the toolbar; each pane keeps its own scroller, so selecting a prose segment still scrolls the linked scene into view when you switch to it. Picking a pane on the phone selector also re-enables it, so a pane switched off on a desktop session isn't stranded, and if the pane you were viewing is switched off the view falls back to one that's still on rather than going blank. Desktop layout is unchanged.
- **[issue-3586] The Writers Room synced review now shows which card you actually clicked.** All three panes drew their cards through a helper that had four states — selected, linked, dimmed, plain — but every caller passed "not selected" as a constant, so the strongest of the four was unreachable code. Because the mapping deliberately includes the selected item in its own pane's highlight set, the card you clicked came out styled exactly like the cards it links to: with a prose segment selected, the segment itself and the scene it maps to were the same faint accent border, and nothing on screen said which end of the cross-link you were standing on. The real selection is now threaded into each pane, so the anchor card takes the full accent ring and its linked counterparts keep the lighter treatment, in the prose, script and media panes alike.
- **[issue-3569] The Writers Room library's header buttons are now big enough to hit on a phone.** "New folder", "New work" and "Hide library" each wrapped a 14px icon in nothing but `p-1`, giving them roughly 22x22px of tappable area sitting side by side in a 260px sidebar — close enough together that a thumb aiming for "New work" landed on "New folder" instead, which is the one control the whole pane exists to reach. All three now clear the 44px floor the rest of the app uses, as do the create-folder and create-work forms they open: the name/title inputs, the kind dropdown, and the Add/Create/Cancel buttons were all ~24px tall, so getting past the header only landed you on a second row of targets just as easy to miss. Unlike the bible and snapshot rows in #3565, the header row has no padding of its own for the extra height to bleed back into, so it grows to 44px rather than clawing it back with a negative margin that would collide with the pane's top edge. "Hide library" stays desktop-only and is centred with `inline-flex` rather than `flex`, since the two are the same Tailwind layer and a bare `flex` would race the `md:` variant that hides it.
+- **[issue-3590] Lengthening a perpetual task's recheck cadence no longer delays a recheck that was already due.** When the recheck cadence changes, the schedule re-derives the park timestamp of every currently-parked execution record from the new cadence, so the edit takes effect on the next slot instead of waiting out the old timestamp. The guard was "does this record carry a park at all" — but an elapsed park is never cleared when it expires (the task simply reports itself as due for a recheck, and the dispatch gate clears the park when it actually runs), so a record that was ready to run right now was matched by that guard too and stamped with a fresh future timestamp. Shortening the cadence was harmless, since the new timestamp was sooner; lengthening it pushed the pending recheck back out by the new interval, and the drain the user was waiting on silently went quiet again. Only parks still in the future are re-derived now — a record whose park has already elapsed is left exactly as it is, so it rechecks on the very next tick.
diff --git a/server/services/taskSchedule.js b/server/services/taskSchedule.js
index 1bd10663f8..34f1798171 100644
--- a/server/services/taskSchedule.js
+++ b/server/services/taskSchedule.js
@@ -796,14 +796,20 @@ export async function updateTaskInterval(taskType, settings) {
// from the new cadence — otherwise an already-parked task keeps waiting out
// its old timestamp and the cadence control appears to do nothing until then.
// Only recompute existing parks (never create one), and compute from now so a
- // shortened cadence takes effect on the next slot.
+ // shortened cadence takes effect on the next slot. A park whose timestamp has
+ // ALREADY elapsed is left alone (#3590): an elapsed park is not cleared when it
+ // expires — shouldRunTask reports `perpetual-recheck` and the dispatch gate
+ // clears it — so it is a record that is DUE RIGHT NOW. Restamping it from a
+ // lengthened cadence would silently push already-due work back into the future.
const merged = schedule.tasks[taskType];
if (merged.type === INTERVAL_TYPES.PERPETUAL && ('recheckCron' in settings || 'recheckIntervalMs' in settings)) {
const exec = schedule.executions[`task:${taskType}`];
if (exec) {
+ const nowMs = Date.now();
const records = [exec, ...Object.values(exec.perApp || {})];
for (const rec of records) {
- if (rec?.parkedUntil) {
+ const parkedUntilMs = rec?.parkedUntil ? new Date(rec.parkedUntil).getTime() : 0;
+ if (parkedUntilMs > nowMs) {
rec.parkedUntil = await computePerpetualRecheckAt(merged);
}
}
diff --git a/server/services/taskSchedule.test.js b/server/services/taskSchedule.test.js
index 70361cc7ab..bd923e3a13 100644
--- a/server/services/taskSchedule.test.js
+++ b/server/services/taskSchedule.test.js
@@ -1862,6 +1862,37 @@ describe('taskSchedule', () => {
const saved = JSON.parse(writeFile.mock.calls.at(-1)[1])
expect(saved.executions['task:claim-issue'].perApp['app-1'].parkedUntil).toBeUndefined()
})
+
+ // #3590: an elapsed park is never cleared when it expires — shouldRunTask
+ // reports `perpetual-recheck` and the dispatch gate clears it — so a record
+ // whose parkedUntil is in the past is DUE RIGHT NOW. Restamping it from a
+ // LENGTHENED cadence would silently delay work the user is already waiting on.
+ it('leaves an already-elapsed park alone while re-deriving a future one', async () => {
+ isTaskTypeEnabledForApp.mockResolvedValue(true)
+ const soon = new Date(Date.now() + 60 * 1000).toISOString()
+ const elapsed = new Date(Date.now() - 60 * 1000).toISOString()
+ mockSchedule({
+ tasks: { 'claim-issue': { type: 'perpetual', enabled: true, recheckIntervalMs: 60 * 1000 } },
+ executions: { 'task:claim-issue': { lastRun: null, count: 0, perApp: {
+ 'app-future': { lastRun: null, count: 0, parkedUntil: soon },
+ 'app-elapsed': { lastRun: null, count: 0, parkedUntil: elapsed }
+ } } }
+ })
+ // Cadence LENGTHENED from 1 minute to 30 days.
+ await updateTaskInterval('claim-issue', { recheckIntervalMs: 30 * 24 * 60 * 60 * 1000 })
+ const saved = JSON.parse(writeFile.mock.calls.at(-1)[1])
+ const perApp = saved.executions['task:claim-issue'].perApp
+ // The future park is rewritten from the new (longer) cadence.
+ expect(new Date(perApp['app-future'].parkedUntil).getTime())
+ .toBeGreaterThan(new Date(soon).getTime())
+ // The elapsed park is untouched, so the recheck it was owed still fires now.
+ expect(perApp['app-elapsed'].parkedUntil).toBe(elapsed)
+
+ readJSONFile.mockResolvedValue(saved)
+ const result = await shouldRunTask('claim-issue', 'app-elapsed')
+ expect(result.shouldRun).toBe(true)
+ expect(result.reason).toBe('perpetual-recheck')
+ })
})
describe('getScheduleStatus per-app park aggregate', () => {