@gentbajko/slopify 4.5.4 → 4.5.6
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.
- package/dist/extension/slopify-studio-chrome.zip +0 -0
- package/dist/extension/slopify-studio-firefox.zip +0 -0
- package/dist/main.js +3 -0
- package/dist/patch-notes/4.5.5.md +13 -0
- package/dist/patch-notes/4.5.6.md +12 -0
- package/dist/patch-notes/index.json +12 -0
- package/dist/slices/agents/attention.js +29 -0
- package/dist/slices/rebuild/continue-held.js +69 -0
- package/dist/slices/schedules/continue-stopped.js +45 -0
- package/dist/slices/schedules/held-back.js +62 -0
- package/dist/slices/schedules/prepare.js +30 -2
- package/dist/slices/schedules/repo.js +1 -1
- package/dist/slices/schedules/scheduler.js +20 -3
- package/package.json +1 -1
|
Binary file
|
|
Binary file
|
package/dist/main.js
CHANGED
|
@@ -70,6 +70,7 @@ import { createNotificationSender } from "./slices/notifications/send.js";
|
|
|
70
70
|
import { createServerNotifier } from "./slices/notifications/server.js";
|
|
71
71
|
import { seedSamples } from "./slices/onboarding/sample.js";
|
|
72
72
|
import { templateById } from "./slices/project-templates/repo.js";
|
|
73
|
+
import { continueHeldRun } from "./slices/rebuild/continue-held.js";
|
|
73
74
|
import { createNarrationRetries } from "./slices/rebuild/narration-retry.js";
|
|
74
75
|
import { recoverProject } from "./slices/rebuild/recovery.js";
|
|
75
76
|
import { claimWork, finishWork, maySubmit } from "./slices/rebuild/repo.js";
|
|
@@ -518,6 +519,8 @@ export async function boot(config, options = {}) {
|
|
|
518
519
|
const scheduleRunnerDeps = {
|
|
519
520
|
...draftDeps,
|
|
520
521
|
designs: () => designMake,
|
|
522
|
+
// A made-ahead run a restart stopped goes on when its day takes it.
|
|
523
|
+
continueRun: (projectId) => continueHeldRun(rebuild, projectId),
|
|
521
524
|
// The newest version that may run: legacy, marked ready, or carried by Slopify. Only a
|
|
522
525
|
// project template's: a design schedule asks the designs (runnableDesignVersion).
|
|
523
526
|
template: (id) => runnableTemplate(runtimeDb, id),
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Slopify 4.5.5
|
|
2
|
+
|
|
3
|
+
Released 27 November 2026.
|
|
4
|
+
|
|
5
|
+
A video made ahead is now made on its day even after the computer restarted, and a schedule that skips its runs says which video holds it back.
|
|
6
|
+
|
|
7
|
+
## A video made ahead is rendered on its day after a restart
|
|
8
|
+
|
|
9
|
+
- **Its day now continues a video made ahead that a restart stopped.** When the app restarted while a schedule held a video made ahead for its day, the video read Stopped, and on its day the schedule took it but nothing rendered it until someone pressed Continue the run. The schedule's day is the go-ahead, so it now does what Continue the run would: the steps the restart held go on and the video is made. Nothing already made is made or paid for again, a project you paused stays paused, and a checkpoint of yours still waits for your approval.
|
|
10
|
+
- **The day never starts paid work you didn't start.** If settings saved on the video since need new paid steps that were never started, the day leaves it Stopped and the schedule's run history says so, with the button to press.
|
|
11
|
+
- **A skipped run says which video holds it back.** A schedule skips its runs while the video of an earlier run is unfinished. When that video is paused, stopped by a restart, waiting for your review or has a failed step, the skipped run now names the video and says what to press, instead of only "the previous run was still going". In what needs attention, that video's entry also says which schedule waits on it.
|
|
12
|
+
- A video made ahead still reads Stopped between a restart and its day when the restart held its steps; its day now moves it on by itself.
|
|
13
|
+
- Technical: `continuePrepared` (`schedules/prepare.ts`) is async and, for a project with a `prepared_videos` row, calls the new `ScheduleDeps.continueRun`, wired in `main.ts` to `continueHeldRun` (`rebuild/continue-held.ts`). That calls `recoverProject` with `{ kind: "resume" }` only when the head has restart-held admitted work (`dispatch_state='held'`, `pendingAdmitted`, no waiting external review), the project isn't paused, and every provider recipe the resume plan would make is already reserved on the head with the same fingerprint; otherwise it returns a refusal sentence the scheduler stores as the run's `error`. `overlapSentence` (`schedules/held-back.ts`) replaces the fixed overlap skip text, and `needsAttention` appends the schedules an unsettled run's project holds back.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# Slopify 4.5.6
|
|
2
|
+
|
|
3
|
+
Released 1 December 2026.
|
|
4
|
+
|
|
5
|
+
A restart no longer leaves a schedule's videos Stopped.
|
|
6
|
+
|
|
7
|
+
## A schedule's videos go on by themselves after a restart
|
|
8
|
+
|
|
9
|
+
- **Videos made ahead no longer read Stopped after a restart.** A restart stops every run that was going, and a video made ahead then read Stopped until someone pressed Continue the run or its day came. Now, a minute after Slopify starts, each of a schedule's videos that a restart stopped goes on as Continue the run would take it on. A video made ahead goes back to Waiting for its day.
|
|
10
|
+
- **A video its day already took no longer holds the schedule back.** When the computer restarted while a schedule's video was still being finished (its shorts or its PDF, say), it stayed Stopped and the schedule skipped every run after it until someone pressed Continue the run. That video now finishes by itself after the restart, and the next runs go ahead.
|
|
11
|
+
- The same limits as the day apply: nothing already made is made or paid for again, a project you paused stays paused, a checkpoint of yours still waits for your approval, and paid steps nobody started are left for you (the log says which video and why).
|
|
12
|
+
- Technical: new `continueStopped` (`schedules/continue-stopped.ts`) runs once, on the schedule runner's first tick after start. It takes every live project with a `prepared_videos` row or in an unsettled `schedule_runs` row of a live schedule, and for each that `projectHolds` reads as stopped it calls `ScheduleDeps.continueRun` (`continueHeldRun`).
|
|
@@ -1,4 +1,16 @@
|
|
|
1
1
|
[
|
|
2
|
+
{
|
|
3
|
+
"id": "4.5.6",
|
|
4
|
+
"title": "Slopify 4.5.6",
|
|
5
|
+
"version": "4.5.6",
|
|
6
|
+
"date": "2026-12-01"
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
"id": "4.5.5",
|
|
10
|
+
"title": "Slopify 4.5.5",
|
|
11
|
+
"version": "4.5.5",
|
|
12
|
+
"date": "2026-11-27"
|
|
13
|
+
},
|
|
2
14
|
{
|
|
3
15
|
"id": "4.5.4",
|
|
4
16
|
"title": "Slopify 4.5.4",
|
|
@@ -4,6 +4,7 @@ import { liveProject } from "../admission/repo.js";
|
|
|
4
4
|
import { externalReviewOf } from "../reviews/external-rows.js";
|
|
5
5
|
import { waitingExternalReviewRows } from "../reviews/external-waiting.js";
|
|
6
6
|
import { projectHolds } from "../reviews/holds.js";
|
|
7
|
+
import { heldBack } from "../schedules/held-back.js";
|
|
7
8
|
import { templateSampleProjects } from "../template-studio/repo.js";
|
|
8
9
|
import { setAsideProjects } from "../uploads/repo.js";
|
|
9
10
|
import { postsWaiting } from "./attention-posts.js";
|
|
@@ -58,6 +59,7 @@ export function needsAttention(deps, now) {
|
|
|
58
59
|
];
|
|
59
60
|
const aside = setAsideProjects(db);
|
|
60
61
|
const samples = templateSampleProjects(db);
|
|
62
|
+
const blocking = schedulesHeldBack(deps);
|
|
61
63
|
return sources
|
|
62
64
|
.flatMap(([source, entries]) => {
|
|
63
65
|
try {
|
|
@@ -71,8 +73,35 @@ export function needsAttention(deps, now) {
|
|
|
71
73
|
}
|
|
72
74
|
})
|
|
73
75
|
.filter((entry) => entry.projectId === null || (!aside.has(entry.projectId) && !samples.has(entry.projectId)))
|
|
76
|
+
.map((entry) => {
|
|
77
|
+
const names = entry.projectId === null ? undefined : blocking.get(entry.projectId);
|
|
78
|
+
return names === undefined
|
|
79
|
+
? entry
|
|
80
|
+
: {
|
|
81
|
+
...entry,
|
|
82
|
+
reason: `${entry.reason} Until this video finishes, ${names.map((name) => `the schedule “${name}”`).join(" and ")} skips its runs.`,
|
|
83
|
+
};
|
|
84
|
+
})
|
|
74
85
|
.toSorted((a, b) => a.since.localeCompare(b.since));
|
|
75
86
|
}
|
|
87
|
+
// The schedules each unfinished video of an earlier run holds back (`schedules/held-back.ts`):
|
|
88
|
+
// said on that video's entries, since a schedule skips its runs until the video finishes.
|
|
89
|
+
function schedulesHeldBack(deps) {
|
|
90
|
+
const names = new Map();
|
|
91
|
+
try {
|
|
92
|
+
for (const one of heldBack(deps.db)) {
|
|
93
|
+
const listed = names.get(one.projectId) ?? [];
|
|
94
|
+
if (!listed.includes(one.scheduleName))
|
|
95
|
+
names.set(one.projectId, [...listed, one.scheduleName]);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
catch (error) {
|
|
99
|
+
deps.log.write("error", "attention.source", {
|
|
100
|
+
detail: `needs_attention left out which schedules wait on a video because reading them failed: ${causedBy(error)}`,
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
return names;
|
|
104
|
+
}
|
|
76
105
|
function titles(db) {
|
|
77
106
|
return new Map(db
|
|
78
107
|
.prepare("SELECT id, title FROM projects")
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import { pendingAdmitted } from "../admission/admitted-work.js";
|
|
3
|
+
import { projectPaused, stagesOf } from "../admission/repo.js";
|
|
4
|
+
import { currentRevisionId } from "../revisions/repo.js";
|
|
5
|
+
import { getRevisionView } from "../revisions/view.js";
|
|
6
|
+
import { planPreview } from "./preview-plan.js";
|
|
7
|
+
import { retainedPreviewPlan } from "./preview-retained.js";
|
|
8
|
+
import { recoverProject } from "./recovery.js";
|
|
9
|
+
import { resumeSelection } from "./recovery-selection.js";
|
|
10
|
+
const fix = "Open it in Projects and press Continue the run.";
|
|
11
|
+
// The scheduled day is the go-ahead for a video made ahead, so a run a restart stopped goes on
|
|
12
|
+
// as Continue the run would take it on: the steps a restart held on its current version are let
|
|
13
|
+
// go again. Only steps already admitted go on. A step that costs money and was never admitted
|
|
14
|
+
// (an edit saved on it and never started) waits for the person, so the day spends nothing they
|
|
15
|
+
// didn't start. A Pause is left alone, and a person's checkpoint still holds what it holds.
|
|
16
|
+
export async function continueHeldRun(deps, projectId) {
|
|
17
|
+
const head = currentRevisionId(deps.db, projectId);
|
|
18
|
+
if (head === undefined || projectPaused(deps.db, projectId))
|
|
19
|
+
return { kind: "untouched" };
|
|
20
|
+
const held = deps.db
|
|
21
|
+
.prepare(`SELECT 1 FROM revision_work w WHERE w.project_id=? AND w.dispatch_state='held' AND ${pendingAdmitted("w")}
|
|
22
|
+
AND NOT EXISTS (SELECT 1 FROM external_reviews e WHERE e.work_id=w.id AND e.state='waiting')
|
|
23
|
+
LIMIT 1`)
|
|
24
|
+
.get(projectId);
|
|
25
|
+
if (held === undefined)
|
|
26
|
+
return { kind: "untouched" };
|
|
27
|
+
const view = getRevisionView(deps, projectId, head);
|
|
28
|
+
if (view === undefined)
|
|
29
|
+
return { kind: "untouched" };
|
|
30
|
+
const catalogue = deps.catalogue.read();
|
|
31
|
+
const selection = resumeSelection(retainedPreviewPlan(deps, view, catalogue), stagesOf(deps.db, projectId));
|
|
32
|
+
const planned = planPreview(deps, view, catalogue, selection, deps.ids.next());
|
|
33
|
+
if (!planned.ok)
|
|
34
|
+
return {
|
|
35
|
+
kind: "refused",
|
|
36
|
+
sentence: `This run took the video made ahead but couldn't continue it, because what is left to make couldn't be worked out. ${fix}`,
|
|
37
|
+
};
|
|
38
|
+
const { execution } = planned.value;
|
|
39
|
+
const reused = new Set(execution.dispositions.filter((row) => row.disposition === "reuse").map((row) => row.key));
|
|
40
|
+
// Admitted already: reserved on this version under the same starting point and not finished,
|
|
41
|
+
// which is the step admission lets go again rather than makes anew (`admission-repo.ts`).
|
|
42
|
+
const admitted = (key, fingerprint) => deps.db
|
|
43
|
+
.prepare(`SELECT 1 FROM revision_work_reservations r JOIN revision_work w ON w.id=r.work_id
|
|
44
|
+
WHERE r.revision_id=? AND r.work_key=? AND r.fingerprint=? AND w.state!='done'
|
|
45
|
+
AND w.recipe_context IS NOT NULL`)
|
|
46
|
+
.get(head, key, fingerprint) !== undefined;
|
|
47
|
+
const unstarted = execution.recipes.filter((recipe) => recipe.kind === "provider" &&
|
|
48
|
+
!reused.has(recipe.key) &&
|
|
49
|
+
!admitted(recipe.key, recipe.fingerprint));
|
|
50
|
+
if (unstarted.length > 0)
|
|
51
|
+
return {
|
|
52
|
+
kind: "refused",
|
|
53
|
+
sentence: `This run took the video made ahead but didn't continue it, because settings saved on it since need new paid steps that were never started (${String(unstarted.length)}). ${fix}`,
|
|
54
|
+
};
|
|
55
|
+
const result = await recoverProject(deps, projectId, {
|
|
56
|
+
baseRevisionId: head,
|
|
57
|
+
idempotencyKey: randomUUID(),
|
|
58
|
+
action: { kind: "resume" },
|
|
59
|
+
});
|
|
60
|
+
if (result.ok)
|
|
61
|
+
return { kind: "continued" };
|
|
62
|
+
const detail = result.reason === "readiness" && result.fields !== undefined && result.fields.length > 0
|
|
63
|
+
? result.fields.map((field) => field.message).join(" ")
|
|
64
|
+
: `Slopify refused to continue it (${result.reason}).`;
|
|
65
|
+
return {
|
|
66
|
+
kind: "refused",
|
|
67
|
+
sentence: `This run took the video made ahead but couldn't continue it. ${detail} ${fix}`,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { errorText } from "../../kernel/errors.js";
|
|
3
|
+
import { projectHolds } from "../reviews/holds.js";
|
|
4
|
+
import { projectIsActive } from "./repo.js";
|
|
5
|
+
// The videos a schedule owns: made ahead for a day still to come, or taken by a run whose
|
|
6
|
+
// videos aren't all finished. Oldest first. A deleted schedule owns nothing.
|
|
7
|
+
function scheduledProjects(db) {
|
|
8
|
+
const ids = db
|
|
9
|
+
.prepare(`SELECT p.project_id AS id FROM prepared_videos p
|
|
10
|
+
JOIN schedules s ON s.id=p.schedule_id AND s.deleted_at IS NULL
|
|
11
|
+
UNION
|
|
12
|
+
SELECT admitted.value AS id FROM schedule_runs r, json_each(r.project_ids_json) AS admitted
|
|
13
|
+
JOIN schedules s ON s.id=r.schedule_id AND s.deleted_at IS NULL
|
|
14
|
+
WHERE r.projects_settled_at IS NULL AND r.status!='running'`)
|
|
15
|
+
.all()
|
|
16
|
+
.map((row) => z.string().parse(row.id));
|
|
17
|
+
return [...new Set(ids)].filter((id) => projectIsActive(db, id));
|
|
18
|
+
}
|
|
19
|
+
// A restart stops every run that was going (`recoverWork`), and a schedule's videos then read
|
|
20
|
+
// Stopped until someone presses Continue the run: a made-ahead video until its day, and one its
|
|
21
|
+
// day already took never finishes, so the schedule skips its next runs. A schedule runs without
|
|
22
|
+
// anyone watching, so once Slopify is back each of its videos a restart stopped goes on as
|
|
23
|
+
// Continue the run would take it on (`continueHeldRun`): never past a Pause or a person's
|
|
24
|
+
// checkpoint, and never a paid step nobody started. Returns the projects it continued.
|
|
25
|
+
export async function continueStopped(deps) {
|
|
26
|
+
const { continueRun } = deps;
|
|
27
|
+
if (continueRun === undefined)
|
|
28
|
+
return [];
|
|
29
|
+
const continued = [];
|
|
30
|
+
for (const projectId of scheduledProjects(deps.db)) {
|
|
31
|
+
if (!projectHolds(deps.db, { projectId }).stopped.has(projectId))
|
|
32
|
+
continue;
|
|
33
|
+
try {
|
|
34
|
+
const outcome = await continueRun(projectId);
|
|
35
|
+
if (outcome.kind === "continued")
|
|
36
|
+
continued.push(projectId);
|
|
37
|
+
else if (outcome.kind === "refused")
|
|
38
|
+
deps.log.write("warn", "schedule.continue", { projectId, detail: outcome.sentence });
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
deps.log.write("error", "schedule.continue", { projectId, detail: errorText(error) });
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return continued;
|
|
45
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { projectPaused, stagesOf } from "../admission/repo.js";
|
|
3
|
+
import { projectHolds } from "../reviews/holds.js";
|
|
4
|
+
import { heldForItsDay } from "./prepare.js";
|
|
5
|
+
import { projectIsActive } from "./repo.js";
|
|
6
|
+
const row = z.object({
|
|
7
|
+
schedule_id: z.string(),
|
|
8
|
+
name: z.string(),
|
|
9
|
+
project_id: z.string(),
|
|
10
|
+
title: z.string(),
|
|
11
|
+
});
|
|
12
|
+
// Oldest run first. A schedule deleted holds nothing back.
|
|
13
|
+
export function heldBack(db, scheduleId) {
|
|
14
|
+
const rows = db
|
|
15
|
+
.prepare(`SELECT r.schedule_id, s.name, admitted.value AS project_id, p.title
|
|
16
|
+
FROM schedule_runs r, json_each(r.project_ids_json) AS admitted
|
|
17
|
+
JOIN schedules s ON s.id=r.schedule_id AND s.deleted_at IS NULL
|
|
18
|
+
JOIN projects p ON p.id=admitted.value
|
|
19
|
+
WHERE r.projects_settled_at IS NULL AND r.status!='running'
|
|
20
|
+
AND (?1 IS NULL OR r.schedule_id=?1)
|
|
21
|
+
ORDER BY r.scheduled_for, r.started_at, r.id`)
|
|
22
|
+
.all(scheduleId ?? null)
|
|
23
|
+
.map((value) => row.parse(value));
|
|
24
|
+
return rows
|
|
25
|
+
.filter((one) => projectIsActive(db, one.project_id))
|
|
26
|
+
.map((one) => ({
|
|
27
|
+
scheduleId: one.schedule_id,
|
|
28
|
+
scheduleName: one.name,
|
|
29
|
+
projectId: one.project_id,
|
|
30
|
+
title: one.title,
|
|
31
|
+
}));
|
|
32
|
+
}
|
|
33
|
+
const generic = "Skipped because the previous run of this schedule was still going.";
|
|
34
|
+
// Why a run was skipped for overlap, naming the earlier run's video when nothing but the
|
|
35
|
+
// person moves it on: what stops it, and the button that fixes it.
|
|
36
|
+
export function overlapSentence(db, scheduleId) {
|
|
37
|
+
const first = heldBack(db, scheduleId)[0];
|
|
38
|
+
if (first === undefined)
|
|
39
|
+
return generic;
|
|
40
|
+
const video = `the video of an earlier run, “${first.title}”,`;
|
|
41
|
+
const after = "; this schedule's runs go ahead again once it finishes.";
|
|
42
|
+
if (projectPaused(db, first.projectId))
|
|
43
|
+
return `Skipped because ${video} is paused. Open it in Projects and press Continue the run${after}`;
|
|
44
|
+
const failed = stagesOf(db, first.projectId).find((stage) => stage.state === "failed");
|
|
45
|
+
if (failed !== undefined)
|
|
46
|
+
return `Skipped because ${video} has a failed ${failed.kind} step. Open it in Projects and press Try again on that step${after}`;
|
|
47
|
+
const holds = projectHolds(db, { projectId: first.projectId });
|
|
48
|
+
if (holds.stopped.has(first.projectId))
|
|
49
|
+
return `Skipped because ${video} stopped before it finished, as a restart leaves a run. Open it in Projects and press Continue the run${after}`;
|
|
50
|
+
// Any checkpoint of the person's left to approve, reached or not: the video can't be made
|
|
51
|
+
// until it is (one whose inputs are still being made holds nothing yet, `holds.ts`).
|
|
52
|
+
const review = db
|
|
53
|
+
.prepare(`SELECT c.stage FROM review_checkpoints c
|
|
54
|
+
JOIN project_heads h ON h.project_id=c.project_id AND h.revision_id=c.revision_id
|
|
55
|
+
WHERE c.project_id=? AND c.state IN ('held','pending-review') AND c.approved_at IS NULL
|
|
56
|
+
AND NOT (c.stage='video' AND ${heldForItsDay("c")})
|
|
57
|
+
ORDER BY c.created_at LIMIT 1`)
|
|
58
|
+
.get(first.projectId);
|
|
59
|
+
if (typeof review?.stage === "string")
|
|
60
|
+
return `Skipped because ${video} waits for your review before its ${review.stage} step. Open it in Projects and approve it${after}`;
|
|
61
|
+
return generic;
|
|
62
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { errorText } from "../../kernel/errors.js";
|
|
1
2
|
import { derive } from "../../kernel/runner/graph.js";
|
|
2
3
|
import { projectPaused, stagesOf } from "../admission/repo.js";
|
|
3
4
|
import { render } from "../admission/substitute.js";
|
|
@@ -141,8 +142,13 @@ export function preparedProject(db, scheduleId, title, byTitle = true) {
|
|
|
141
142
|
}
|
|
142
143
|
// The scheduled day for a prepared video: its own Before Video hold is taken away, so the
|
|
143
144
|
// video renders as soon as what it needs is done. A Before Video checkpoint the template had
|
|
144
|
-
// stays for the person to approve.
|
|
145
|
-
|
|
145
|
+
// stays for the person to approve. The day is the go-ahead for a video made ahead: one a restart
|
|
146
|
+
// stopped goes on as Continue the run would take it on (`continueHeldRun`), never past a Pause
|
|
147
|
+
// or a person's checkpoint. What it couldn't continue is said in a sentence for the run.
|
|
148
|
+
export async function continuePrepared(deps, prepared) {
|
|
149
|
+
const madeAhead = deps.db
|
|
150
|
+
.prepare("SELECT 1 FROM prepared_videos WHERE project_id=? LIMIT 1")
|
|
151
|
+
.get(prepared.projectId) !== undefined;
|
|
146
152
|
if (prepared.release) {
|
|
147
153
|
const head = currentRevisionId(deps.db, prepared.projectId);
|
|
148
154
|
if (head !== undefined) {
|
|
@@ -154,7 +160,29 @@ export function continuePrepared(deps, prepared) {
|
|
|
154
160
|
}
|
|
155
161
|
// Continued once: the topic is used, and the project is now the run's.
|
|
156
162
|
deps.db.prepare("DELETE FROM prepared_videos WHERE project_id=?").run(prepared.projectId);
|
|
163
|
+
let sentence;
|
|
164
|
+
if (madeAhead && deps.continueRun !== undefined) {
|
|
165
|
+
try {
|
|
166
|
+
const outcome = await deps.continueRun(prepared.projectId);
|
|
167
|
+
if (outcome.kind === "refused")
|
|
168
|
+
sentence = outcome.sentence;
|
|
169
|
+
}
|
|
170
|
+
catch (error) {
|
|
171
|
+
deps.log.write("error", "schedule.continue", {
|
|
172
|
+
projectId: prepared.projectId,
|
|
173
|
+
detail: errorText(error),
|
|
174
|
+
});
|
|
175
|
+
sentence =
|
|
176
|
+
"This run took the video made ahead but couldn't continue it, because Slopify hit an internal error. Open it in Projects and press Continue the run.";
|
|
177
|
+
}
|
|
178
|
+
if (sentence !== undefined)
|
|
179
|
+
deps.log.write("warn", "schedule.continue", {
|
|
180
|
+
projectId: prepared.projectId,
|
|
181
|
+
detail: sentence,
|
|
182
|
+
});
|
|
183
|
+
}
|
|
157
184
|
deps.runner.tick(prepared.projectId);
|
|
185
|
+
return sentence;
|
|
158
186
|
}
|
|
159
187
|
// Which of a schedule's topics are prepared, and their projects, for the topic list.
|
|
160
188
|
export function preparedTopics(deps, scheduleId) {
|
|
@@ -251,7 +251,7 @@ export function settleTerminalScheduleRuns(db, settledAt) {
|
|
|
251
251
|
return settled;
|
|
252
252
|
});
|
|
253
253
|
}
|
|
254
|
-
function projectIsActive(db, projectId) {
|
|
254
|
+
export function projectIsActive(db, projectId) {
|
|
255
255
|
// A project in the trash takes no part in a schedule's overlap: it cannot run there.
|
|
256
256
|
if (!projectExists(db, projectId))
|
|
257
257
|
return false;
|
|
@@ -3,13 +3,17 @@ import { reviewDraft } from "../play-drafts/review.js";
|
|
|
3
3
|
import { createDraft } from "../play-drafts/service.js";
|
|
4
4
|
import { startPlayDraft } from "../play-drafts/start.js";
|
|
5
5
|
import { nextOccurrence } from "./calendar.js";
|
|
6
|
+
import { continueStopped } from "./continue-stopped.js";
|
|
6
7
|
import { claimDesignRun } from "./design-run.js";
|
|
8
|
+
import { overlapSentence } from "./held-back.js";
|
|
7
9
|
import { missedGraceMs } from "./next-run.js";
|
|
8
10
|
import { continuePrepared, preparedProject, scheduledDocument, scheduledTitle } from "./prepare.js";
|
|
9
11
|
import { activeRun, dueSchedules, insertRun, recordRunDispatch, recordRunStartIdentity, recoverRunningRuns, scheduleById, scheduleRows, updateRun, } from "./repo.js";
|
|
10
12
|
import { generateTopics, generationDue, releaseTopicLeases } from "./topics.js";
|
|
11
13
|
export function createScheduleRunner(deps) {
|
|
12
14
|
let ticking = false;
|
|
15
|
+
// The first tick after Slopify starts continues the schedule's videos a restart stopped.
|
|
16
|
+
let restarted = true;
|
|
13
17
|
// ceiling: one entry per schedule generating now.
|
|
14
18
|
const generations = new Set();
|
|
15
19
|
const stopping = new AbortController();
|
|
@@ -57,6 +61,14 @@ export function createScheduleRunner(deps) {
|
|
|
57
61
|
try {
|
|
58
62
|
recoverRunningRuns(deps.db, now.toISOString(), "The previous schedule tick could not record this run's result.");
|
|
59
63
|
startGenerations(now);
|
|
64
|
+
if (restarted) {
|
|
65
|
+
restarted = false;
|
|
66
|
+
const continued = await continueStopped(deps);
|
|
67
|
+
if (continued.length > 0)
|
|
68
|
+
deps.log.write("info", "schedule.continue", {
|
|
69
|
+
detail: `Continued ${String(continued.length)} scheduled video(s) a restart stopped.`,
|
|
70
|
+
});
|
|
71
|
+
}
|
|
60
72
|
const due = dueSchedules(deps.db, now.toISOString());
|
|
61
73
|
const claimed = due.flatMap((schedule) => claim(deps, schedule, now));
|
|
62
74
|
const settled = await Promise.allSettled(claimed.map((entry) => execute(deps, entry)));
|
|
@@ -117,7 +129,7 @@ function claim(deps, schedule, now) {
|
|
|
117
129
|
endedAt: skip ? now.toISOString() : null,
|
|
118
130
|
error: skip
|
|
119
131
|
? overlapping
|
|
120
|
-
?
|
|
132
|
+
? overlapSentence(deps.db, schedule.id)
|
|
121
133
|
: occurrence
|
|
122
134
|
? "Skipped because Slopify was not running at the scheduled time."
|
|
123
135
|
: (noTopic ?? notReady)
|
|
@@ -151,10 +163,15 @@ async function execute(deps, claimed) {
|
|
|
151
163
|
// than make the same video twice.
|
|
152
164
|
const prepared = preparedProject(deps.db, claimed.schedule.id, scheduledTitle(fresh), topic !== undefined);
|
|
153
165
|
if (prepared !== undefined) {
|
|
154
|
-
continuePrepared(deps, prepared);
|
|
155
166
|
run = { ...run, projectIds: [prepared.projectId] };
|
|
156
167
|
recordRunDispatch(deps.db, run, deps.clock.now().toISOString(), topic);
|
|
157
|
-
|
|
168
|
+
const stuck = await continuePrepared(deps, prepared);
|
|
169
|
+
updateRun(deps.db, {
|
|
170
|
+
...run,
|
|
171
|
+
status: "succeeded",
|
|
172
|
+
endedAt: deps.clock.now().toISOString(),
|
|
173
|
+
...(stuck === undefined ? {} : { error: stuck }),
|
|
174
|
+
});
|
|
158
175
|
return;
|
|
159
176
|
}
|
|
160
177
|
const draft = createDraft(deps, { id: deps.uuid(), document: fresh });
|