ui: Add service run history and service DAG state (part 2 of 12)
Stack 30/41. Base branch: main. The code here has no caller yet; the callers arrive in parts 3 to 12 of the subject (#3824 to #3834).
Summary
Part 2 of 12 of the service run history work. It adds the UI helpers that later parts use to show the state and the run history of a service DAG, a DAG that runs for years and restarts by itself. It also makes useElementWidth report the content box, the box that ResizeObserver reports.
Changes
useElementWidthreports the content box on the first measure and on each resize. Before, it reported the border box.ContinuousPanelsubtracts its padding only from the no-layout default, so the samples chart fills the panel.shortRunIdshortens scheduler IDs to their UTC date and time:sched-9f8e7d6c5b4a-20261121T090000:sched-9fbefore,1121-090000afterrestart-1a2b3c4d5e6f-20261108T150405:restart-before,1108-150405after
dagSchedule:restartsByItself,hasActiveServiceRun(with the 5-minute not-started window of spec 080),getRestartAfterStopSec.useSharedViewsmerges the workflow and run views of the Workflows page. A save keeps the fields of the other mode.useIsAdminIfSignedInanduseCanManageSkillsauth hooks.useServiceDAGsSSEtakes a remote node;useDAGsListSSEtakesactivityWindow.monaco-lookshares the editor font, wrap and Unicode-highlight options.- AI navigation labels in English, Japanese and Chinese.
Core change
useElementWidth reads the content box both times: from clientWidth less the padding on the first measure, then from the ResizeObserver entry. The panel uses that measure as is, and subtracts its padding only from the default. A scheduler ID becomes its date and time, because the hash is the same for every run of a DAG in most schemes.
// ui/src/hooks/useElementWidth.ts:30-36
const read = (next: number) => setWidth(next > 0 ? next : null);
read(contentWidth(element));
if (typeof ResizeObserver !== 'function') return;
const observer = new ResizeObserver((entries) => {
const entry = entries[entries.length - 1];
read(entry ? entry.contentRect.width : contentWidth(element));
});
// ui/src/features/workflow-workspace/continuous/ContinuousPanel.tsx:111-113
// The measure is the content box; the default is the whole panel.
const chartWidth =
useElementWidth(rootRef) ?? DEFAULT_WIDTH_PX - PANEL_PAD_PX;
// ui/src/lib/shortRunId.ts:8-9, 21-24
const SCHEDULER_ID =
/^(?:sched|restart|catchup|oneoff)-([0-9a-f]{6,})(?:-\d{4}(\d{4})T(\d{6}))?$/;
const [, hash = '', date, time] = scheduled;
return date && time
? `${date}-${time}`
: hash.slice(0, SHORT_RUN_ID_LENGTH);
Testing
ContinuousPanel.test.tsx, "fills the measured width of the panel": failed before the panel fix (208 points instead of 214).shortRunId.test.ts: the restart, schedule and daily-schedule cases failed before the ID change.pnpm exec vitest runon the ContinuousPanel, shortRunId, SSEManager, useElementWidth and RunTimeline tests: 160 passed.pnpm typecheck, pluseslintandprettier --checkon the changed files.
Performance
No performance risk: the change adds no polling, SSE topic, timer or persisted data. useElementWidth keeps one ResizeObserver per element and adds one computed-style read per mount.
Review guide
- Mechanical:
i18n/messages.ts, and theclientWidthstubs inRunTimeline.test.tsx. - Needs judgment: the
useElementWidthcontract. Its other callers now get their inner width:TimelineChart's frame loses its 1px borders.- The canvas toolbar row loses its
px-2before the compact threshold. RunTimeline's frame has no padding and does not change.
Out of scope
- The callers of the new hooks and helpers (#3824 to #3834).
hasActiveServiceRunreadsqueuedAtorstartedAt, while the server readsCreatedAt(internal/runtime/manager.go:642).DAGRunSummaryhas nocreatedAt, so matching them needs an API field. That goes with the first caller.- Part 7's
SamplesPanel.test.tsxexpects the oldaaaa-113000form. It needs1108-113000when that part is rebased.
Summary by cubic
Adds the UI groundwork for the service run history and service DAG state (part 2 of 12), so the Workflows list, page header, and run timeline can reflect whether a service is active.
- New
useSharedViewshook merges the workflow and run views of the Workflows page; saving a view keeps the fields of the other mode untouched. useElementWidthnow reports the content box width, matching what ResizeObserver sends, instead of the border box.- New
dagSchedulehelpers decide when a service DAG has an active run (including the 5-minute not-started window of spec 080) and when a stopped run restarts;shortRunIddrops the shared scheme from scheduler restart, catchup, and oneoff run IDs. - New
useCanManageSkillsanduseIsAdminIfSignedInauth hooks; managing skills and notifications requires a server-wide developer role. SSEManagermaps the/events/service-dagsendpoint, anduseServiceDAGsSSEaccepts a remote node.- New
monaco-lookmodule shares editor font, word-wrap, and unicode-highlight options; i18n adds AI navigation labels in English, Japanese, and Chinese.
Summary by CodeRabbit
- New Features
- Added a unified view for workflow and run views, with sorting and support for creating, updating, and deleting views.
- Added service-DAG status and restart information, including support for updates from remote nodes.
- Added permission checks for administrator access and skill management.
- Added clearer short IDs for scheduled, catchup, and one-off runs.
- Improvements
- Improved editor sizing to account for padding.
- Added translated navigation labels and AI section descriptions in English, Simplified Chinese, and Japanese.