feat(web): manage independent schedules and restore recorded stage navigation
This commit is contained in:
@@ -8,6 +8,7 @@ import { describeError } from "../format.js";
|
||||
import {
|
||||
PIPELINE_SORTS,
|
||||
PIPELINE_DETAIL_TABS,
|
||||
PIPELINE_SCHEDULE_FILTERS,
|
||||
RUN_PRESENCES,
|
||||
RUN_STATUS_FILTERS,
|
||||
EMPTY_PIPELINE_FILTERS,
|
||||
@@ -30,6 +31,7 @@ import { statusIcon } from "../statusIcon.js";
|
||||
import { writeGraphExpanded } from "../graphPrefs.js";
|
||||
import { pendingRun, createRunIntent, saveRunIntent, clearRunIntent } from "../runIntent.js";
|
||||
import { ProtocolError } from "../client.js";
|
||||
import { pipelineScheduleLabel, pipelineScheduleState } from "../scheduleOrigin.js";
|
||||
|
||||
export function createPipelinesView(rt) {
|
||||
const { state, repo, modal } = rt;
|
||||
@@ -164,6 +166,23 @@ function renderFilterPanel() {
|
||||
),
|
||||
);
|
||||
}
|
||||
panel.append(h("div", { class: "filter-section", text: "Scheduling" }));
|
||||
panel.append(h("div", { class: "muted", text: "Configured schedules, including paused." }));
|
||||
for (const option of PIPELINE_SCHEDULE_FILTERS) {
|
||||
panel.append(h("label", { class: "filter-item" }, h("input", {
|
||||
type: "radio",
|
||||
name: "pipelineScheduleFilter",
|
||||
"data-pipeline-schedule": option.key,
|
||||
checked: (filters.scheduled ?? "any") === option.key,
|
||||
onchange: () => {
|
||||
state.pipelineFilters = { ...state.pipelineFilters, scheduled: option.key };
|
||||
renderContent();
|
||||
},
|
||||
}), h("span", { text: option.label })));
|
||||
}
|
||||
if (state.pipelines.some((pipeline) => pipelineScheduleState(pipeline) === null)) {
|
||||
panel.append(h("p", { class: "muted", text: "Some records have no scheduling metadata; they stay unclassified." }));
|
||||
}
|
||||
panel.append(
|
||||
h("div", { class: "filter-actions" }, h("button", { class: "ghost", text: "Clear filters", onclick: clearPipelineFilters })),
|
||||
);
|
||||
@@ -263,6 +282,8 @@ function renderPipelineRow(pipeline, latestRuns, runsKnown, now) {
|
||||
}),
|
||||
);
|
||||
const updated = pipelineUpdatedLine(pipeline);
|
||||
const scheduled = pipelineScheduleLabel(pipeline);
|
||||
if (scheduled) children.push(h("span", { class: "row-meta pipeline-schedule-meta", text: scheduled, title: "Configured schedules, including paused" }));
|
||||
if (updated) children.push(h("span", { class: "row-meta", text: updated }));
|
||||
if (runsKnown) {
|
||||
const run = latestRuns.get(pipeline.id);
|
||||
@@ -560,6 +581,16 @@ function renderPipelineDetail() {
|
||||
applyRoute(route);
|
||||
},
|
||||
}),
|
||||
rt.views?.schedules ? h("button", {
|
||||
class: "pipeline-schedules",
|
||||
type: "button",
|
||||
text: "Schedules",
|
||||
onclick: () => {
|
||||
state.pipelineTab = "summary";
|
||||
renderContent();
|
||||
requestAnimationFrame(() => document.querySelector(".schedule-section")?.scrollIntoView({ block: "start" }));
|
||||
},
|
||||
}) : null,
|
||||
),
|
||||
);
|
||||
// The Run dialog is an overlay; append it before the tab branches so Graph
|
||||
@@ -599,6 +630,9 @@ function renderPipelineDetail() {
|
||||
return pane;
|
||||
}
|
||||
if (state.pipelineTab === "source") {
|
||||
if (Object.hasOwn(d, "schedule_count") && d.graph?.settings?.schedules?.length) {
|
||||
pane.append(h("p", { class: "muted", text: "Legacy scheduling settings in this immutable source are inactive. Use Schedules to manage future runs." }));
|
||||
}
|
||||
pane.append(h("pre", { class: "source-code" }, h("code", { text: d.source || "" })));
|
||||
return pane;
|
||||
}
|
||||
@@ -615,6 +649,7 @@ function renderPipelineDetail() {
|
||||
);
|
||||
}
|
||||
pane.append(rows);
|
||||
if (rt.views?.schedules) pane.append(rt.views.schedules.renderPipelineSchedules(d));
|
||||
pane.append(
|
||||
h(
|
||||
"button",
|
||||
|
||||
@@ -7,6 +7,7 @@ import { backChevronIcon, h, kvMono, canCopyLink, canShare, copyArtifactLink, sh
|
||||
import { isExecuting, changeKindTone, describeError } from "../format.js";
|
||||
import { resolveArtifactUrl } from "../serverUrl.js";
|
||||
import { runStateOf, runStatusLabel } from "../runs.js";
|
||||
import { scheduledRunLabel } from "../scheduleOrigin.js";
|
||||
import { PIPELINE_GRAPH_EMPTY, RUN_GRAPH_MISSING, mount as mountGraph } from "../graph.js";
|
||||
import { writeGraphExpanded } from "../graphPrefs.js";
|
||||
import { definitionDocument } from "./stageDefinition.js";
|
||||
@@ -216,7 +217,7 @@ function renderRunDetail(now = Date.now()) {
|
||||
* The Graph tab (R5): the run's own guidance note plus the shared workflow graph
|
||||
* mounted in run mode, or the app's exact missing-graph sentence when the server
|
||||
* sent no stages. The active stage pulses with its elapsed time while the run
|
||||
* executes; clicking a stage opens its authored definition without navigating.
|
||||
* executes; clicking a stage opens the same recorded-visit pane as Timeline.
|
||||
* The mount handle is tracked in `state.runGraph` so a re-render
|
||||
* (or a tab/run change) always unmounts the previous wheel/pointer/resize
|
||||
* listeners and the elapsed timer.
|
||||
@@ -233,9 +234,7 @@ function renderRunGraphTab(d) {
|
||||
state.runGraph = mountGraph(host, d.graph, {
|
||||
runState: runGraphState(d),
|
||||
expanded: state.runGraphExpanded,
|
||||
onStageTap: (key) => rt.views.dialogs.openStageDefinition(
|
||||
runDefinition(d), key, `Run ${d.id} · pipeline ${d.pipeline_id} · v${d.version}`,
|
||||
),
|
||||
onStageTap: (key) => openStagePane(key, latestVisitIndex(d, key)),
|
||||
onExpandedChange: (value) => {
|
||||
state.runGraphExpanded = value;
|
||||
writeGraphExpanded(value);
|
||||
@@ -418,6 +417,8 @@ function renderRunSummaryTab(d, now) {
|
||||
const wrap = h("div", { class: "run-tab-body" });
|
||||
wrap.append(renderRunTitleRow(d));
|
||||
wrap.append(h("div", { class: "run-identity muted", text: runIdentityLine(d) }));
|
||||
const origin = scheduledRunLabel(d);
|
||||
if (origin) wrap.append(h("p", { class: "run-schedule-origin muted", text: origin }));
|
||||
|
||||
const rows = h("div", { class: "kv" });
|
||||
for (const row of summaryRows(d, now)) {
|
||||
@@ -970,9 +971,28 @@ function renderDecisionCard(decision) {
|
||||
return card;
|
||||
}
|
||||
|
||||
/** Cancel/Retry actions, shown exactly per the app's eligibility rules. */
|
||||
/** Run controls plus an independent schedule seeded from the original RunInfo. */
|
||||
function renderRunActions(d) {
|
||||
const buttons = [];
|
||||
if (rt.views?.schedules && Number(d.pipeline_id) > 0 && Number(d.version) > 0) {
|
||||
buttons.push(h("button", {
|
||||
class: "run-action schedule-run",
|
||||
type: "button",
|
||||
text: "Schedule this run",
|
||||
title: "Save this run's prompt and options with an independent timer; does not rerun it now",
|
||||
onclick: async (event) => {
|
||||
const trigger = event.currentTarget;
|
||||
trigger.disabled = true;
|
||||
try {
|
||||
const pipeline = await runDefinition(d);
|
||||
if (state.runDetail?.id === d.id) rt.views.schedules.openScheduleEditor({ pipeline, run: d, trigger });
|
||||
} catch (error) {
|
||||
state.actionError = describeError(error);
|
||||
renderContent();
|
||||
} finally { trigger.disabled = false; }
|
||||
},
|
||||
}));
|
||||
}
|
||||
if (canCancel(d)) {
|
||||
buttons.push(
|
||||
h("button", {
|
||||
|
||||
@@ -5,9 +5,11 @@
|
||||
import { h } from "../dom.js";
|
||||
import { statusIcon } from "../statusIcon.js";
|
||||
import { renderMiniGraph, createMiniGraphCache } from "../miniGraph.js";
|
||||
import { scheduledRunLabel, runScheduleState } from "../scheduleOrigin.js";
|
||||
import {
|
||||
RUN_STATES,
|
||||
RUN_TIME_RANGES,
|
||||
RUN_SCHEDULE_FILTERS,
|
||||
RUN_SORTS,
|
||||
runStateOf,
|
||||
runStatusLabel,
|
||||
@@ -148,6 +150,8 @@ function renderRunRow(run, now) {
|
||||
row.append(h("span", { class: "run-row-title", text: identity.label }));
|
||||
}
|
||||
|
||||
const scheduled = scheduledRunLabel(run);
|
||||
if (scheduled) row.append(h("span", { class: "run-row-schedule row-meta", text: scheduled }));
|
||||
row.append(h("span", { class: "run-row-progress", text: progressText(run) }));
|
||||
row.append(
|
||||
h("span", {
|
||||
@@ -236,6 +240,10 @@ function renderAppliedRunFilters() {
|
||||
if (range && state.runFilters.timeRange !== defaultRunFilters().timeRange) {
|
||||
applied.append(chip(range.label, () => setTimeRangeFilter(defaultRunFilters().timeRange)));
|
||||
}
|
||||
const scheduled = RUN_SCHEDULE_FILTERS.find((entry) => entry.value === state.runFilters.scheduled);
|
||||
if (scheduled && scheduled.value !== "any") {
|
||||
applied.append(chip(scheduled.label, () => setScheduleFilter("any"), "schedule-filter-chip"));
|
||||
}
|
||||
return applied;
|
||||
}
|
||||
|
||||
@@ -275,6 +283,15 @@ function renderFilterMenu() {
|
||||
}),
|
||||
);
|
||||
}
|
||||
menu.append(h("div", { class: "menu-divider" }));
|
||||
menu.append(h("div", { class: "menu-section", text: "Trigger" }));
|
||||
for (const option of RUN_SCHEDULE_FILTERS) {
|
||||
menu.append(filterCheck(option.label, (filters.scheduled ?? "any") === option.value,
|
||||
() => setScheduleFilter(option.value), { "data-run-schedule": option.value }));
|
||||
}
|
||||
if (state.runs.some((run) => runScheduleState(run) === null)) {
|
||||
menu.append(h("p", { class: "muted", text: "Some records have no scheduling provenance; they stay unclassified." }));
|
||||
}
|
||||
menu.append(
|
||||
h(
|
||||
"div",
|
||||
@@ -347,6 +364,11 @@ function setTimeRangeFilter(timeRange) {
|
||||
closeMenu();
|
||||
}
|
||||
|
||||
function setScheduleFilter(scheduled) {
|
||||
state.runFilters = { ...state.runFilters, scheduled };
|
||||
closeMenu();
|
||||
}
|
||||
|
||||
function clearRunFilters() {
|
||||
state.runFilters = defaultRunFilters();
|
||||
if (state.selectedRunId == null) rt.pushRoute({ kind: "runs" });
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { h } from '../dom.js';
|
||||
import { SCHEDULE_DAYS, scheduleDraft, serializeSchedule, scheduleRuleLabel, scheduleDueLabel } from '../schedules.js';
|
||||
import { newChatOperationId } from '../repository.js';
|
||||
|
||||
export function createSchedulesView(rt) {
|
||||
const cache = new Map();
|
||||
@@ -44,7 +45,9 @@ export function createSchedulesView(rt) {
|
||||
const entry = cache.get(id);
|
||||
const section = h('section', { class: 'schedule-section', 'aria-label': 'Schedules' },
|
||||
h('div', { class: 'schedule-heading' }, h('h3', { text: `Schedules${entry && !entry.loading && !entry.error ? ` (${entry.items.length})` : ''}` }),
|
||||
button('Add schedule', event => openScheduleEditor({ pipeline, trigger: event.currentTarget }), { class: 'schedule-add' })),
|
||||
h('div', { class: 'schedule-actions' },
|
||||
button('Refresh', () => { void loadPipelineSchedules(id, { force: true }); refresh(); }, { class: 'schedule-refresh' }),
|
||||
button('Add schedule', event => openScheduleEditor({ pipeline, trigger: event.currentTarget }), { class: 'schedule-add' }))),
|
||||
h('p', { class: 'schedule-muted', text: 'Independent prompts and timers for this pipeline. Schedules do not change its definition.' }));
|
||||
if (entry.loading) section.append(h('p', { role: 'status', text: 'Loading schedules…' }));
|
||||
if (entry.error) section.append(h('div', { class: 'schedule-error', role: 'alert' }, entry.error,
|
||||
@@ -56,7 +59,7 @@ export function createSchedulesView(rt) {
|
||||
h('div', { class: 'schedule-heading' }, h('strong', { text: schedule.name }), h('span', { class: 'schedule-badge', text: schedule.enabled ? 'Enabled' : 'Paused' })),
|
||||
h('div', { class: 'schedule-muted', text: `Pinned v${schedule.version} · ${scheduleRuleLabel(schedule.rule)}` }),
|
||||
h('p', { class: 'schedule-prompt', text: schedule.input?.prompt ?? '' }),
|
||||
h('div', { class: 'schedule-muted', text: `Next: ${schedule.enabled ? scheduleDueLabel(schedule.next_due) : 'Paused'}` }), errorNode);
|
||||
h('div', { class: 'schedule-muted', text: `Next: ${schedule.enabled ? scheduleDueLabel(schedule.next_due, schedule.rule?.timezone) : 'Paused'}` }), errorNode);
|
||||
const actions = h('div', { class: 'schedule-actions' });
|
||||
const edit = button('Edit', event => openScheduleEditor({ pipeline, schedule, trigger: event.currentTarget }));
|
||||
const toggle = button(schedule.enabled ? 'Pause' : 'Enable', async () => {
|
||||
@@ -96,10 +99,11 @@ export function createSchedulesView(rt) {
|
||||
h('p', { text: 'Future runs only. Run history and active runs will not be deleted.' }), errorNode,
|
||||
h('div', { class: 'schedule-actions' }, button('Keep schedule', close), confirm)));
|
||||
rt.modal.open('schedule-delete', panel, { trigger, onClose: close, renderManaged: false, history: false,
|
||||
fallbackSelectors: ['.schedule-add'] });
|
||||
fallbackSelectors: ['.schedule-add', '.schedule-run', '#detailTitle', '#pane-main'] });
|
||||
}
|
||||
function openScheduleEditor({ pipeline, schedule = null, run = null, trigger = null }) {
|
||||
const draft = scheduleDraft({ pipeline, schedule, run, workspace: rt.state.workspace });
|
||||
const requestKey = schedule?.id ? undefined : `schedule:${newChatOperationId()}`;
|
||||
let pending = false;
|
||||
const close = () => { if (!pending) rt.modal.close('schedule-editor'); };
|
||||
const fields = {};
|
||||
@@ -130,10 +134,12 @@ export function createSchedulesView(rt) {
|
||||
field('name', 'Name', { required: true }), field('prompt', 'Prompt', { textarea: true, required: true, rows: 5 }),
|
||||
h('div', { class: 'schedule-grid' }, field('version', 'Pinned version', { inputmode: 'numeric' }), field('workspace', 'Server workspace', { required: true })),
|
||||
h('label', { class: 'schedule-field' }, 'Timer', mode), interval, clock, days,
|
||||
field('timezone', 'Timezone (blank uses server timezone)'), h('label', { class: 'schedule-check' }, enabled, 'Enabled'),
|
||||
field('timezone', 'Timezone (blank uses server timezone)'), h('label', { class: 'schedule-check' }, enabled, 'Enabled'),
|
||||
h('p', { class: 'schedule-muted', text: 'Enabled schedules start future runs automatically, including model usage and the workflow’s permitted tools.' }),
|
||||
h('details', { class: 'schedule-advanced' }, h('summary', { text: 'Advanced run options' }),
|
||||
field('model', 'Model (provider/model)'), field('stageModels', 'Stage models (JSON object)', { textarea: true, rows: 3 }),
|
||||
field('otherInput', 'Other input (JSON object; prompt above wins)', { textarea: true, rows: 4 }),
|
||||
field('otherInput', 'Other input (JSON object; prompt above wins)', { textarea: true, rows: 4 }),
|
||||
field('writePaths', 'Write paths (JSON array; optional additional restriction)', { textarea: true, rows: 3 }),
|
||||
field('title', 'Run title (optional)'), h('label', { class: 'schedule-field' }, 'Notifications', notify), field('outputFormat', 'Output format (optional)')),
|
||||
errorNode, h('div', { class: 'schedule-actions schedule-footer' }, button('Cancel', close), save));
|
||||
form.addEventListener('submit', async event => {
|
||||
@@ -148,7 +154,7 @@ export function createSchedulesView(rt) {
|
||||
} catch (error) { errorNode.textContent = message(error); errorNode.hidden = false; return; }
|
||||
const controls = [...form.querySelectorAll('input, textarea, select, button')];
|
||||
pending = true; controls.forEach(control => { control.disabled = true; }); save.textContent = 'Saving…';
|
||||
try { await rt.repo.saveSchedule(record); }
|
||||
try { await rt.repo.saveSchedule(record, { requestKey }); }
|
||||
catch (error) {
|
||||
errorNode.textContent = `${message(error)} Your draft is preserved. If this schedule changed elsewhere, reopen it before retrying.`;
|
||||
errorNode.hidden = false; pending = false; controls.forEach(control => { control.disabled = false; }); save.textContent = 'Save schedule'; return;
|
||||
@@ -158,7 +164,7 @@ export function createSchedulesView(rt) {
|
||||
});
|
||||
const overlay = h('div', { class: 'schedule-overlay', role: 'dialog', 'aria-modal': 'true', 'aria-label': schedule ? 'Edit schedule' : 'Add schedule' }, form);
|
||||
rt.modal.open('schedule-editor', overlay, { trigger, onClose: close, renderManaged: false, history: false,
|
||||
fallbackSelectors: ['.schedule-add'] });
|
||||
fallbackSelectors: ['.schedule-add', '.schedule-run', '#detailTitle', '#pane-main'] });
|
||||
return overlay;
|
||||
}
|
||||
return { renderPipelineSchedules, openScheduleEditor, loadPipelineSchedules, clearScheduleCache };
|
||||
|
||||
Reference in New Issue
Block a user