diff --git a/src/lib/components/lines-and-dots/colors.ts b/src/lib/components/lines-and-dots/colors.ts index 2bedf6a767..96a1e682db 100644 --- a/src/lib/components/lines-and-dots/colors.ts +++ b/src/lib/components/lines-and-dots/colors.ts @@ -4,6 +4,8 @@ import type { WorkflowStatus } from '$lib/types/workflows'; const DEFAULT_STROKE_COLOR = 'currentColor'; +const EVENT_GROUP_COLOR = 'var(--color-content-brand)'; + const WORKFLOW_ACTION_COLOR_VARIABLES = { workflow: 'var(--color-action-workflow)', activity: 'var(--color-action-activity)', @@ -50,16 +52,22 @@ export const getStatusStrokeColor = ( status: WorkflowStatus | EventClassification | 'Delayed', ): string => (status && STATUS_STROKE_COLORS[status]) ?? DEFAULT_STROKE_COLOR; -const CATEGORY_STROKE_COLORS: Record< - EventTypeCategory | 'pending' | 'retry' | 'marker' | 'command', - string -> = { +type StrokeCategory = + | EventTypeCategory + | 'pending' + | 'retry' + | 'marker' + | 'command' + | 'event-group'; + +const CATEGORY_STROKE_COLORS: Record = { timer: WORKFLOW_ACTION_COLOR_VARIABLES.timer, signal: WORKFLOW_ACTION_COLOR_VARIABLES.signal, activity: WORKFLOW_ACTION_COLOR_VARIABLES.activity, workflow: WORKFLOW_ACTION_COLOR_VARIABLES.workflow, marker: colorScales.neutral[1], command: colorScales.neutral[1], + 'event-group': EVENT_GROUP_COLOR, 'child-workflow': WORKFLOW_ACTION_COLOR_VARIABLES.workflow, update: colorScales.persimmon[8], pending: colorScales['slate-blue'][8], @@ -69,9 +77,8 @@ const CATEGORY_STROKE_COLORS: Record< other: DEFAULT_STROKE_COLOR, }; -export const getCategoryStrokeColor = ( - category: EventTypeCategory | 'pending' | 'retry' | 'marker' | 'command', -): string => CATEGORY_STROKE_COLORS[category] ?? DEFAULT_STROKE_COLOR; +export const getCategoryStrokeColor = (category: StrokeCategory): string => + CATEGORY_STROKE_COLORS[category] ?? DEFAULT_STROKE_COLOR; export type DotColors = { readonly fill: string; readonly stroke: string }; @@ -172,7 +179,7 @@ export function strokeColor({ delayed = false, }: { status?: WorkflowStatus | 'none'; - category?: EventTypeCategory | 'pending' | 'retry'; + category?: EventTypeCategory | 'pending' | 'retry' | 'event-group'; classification?: EventClassification; delayed?: boolean; }): string { diff --git a/src/lib/components/lines-and-dots/event-group-filter/event-group-filter.svelte b/src/lib/components/lines-and-dots/event-group-filter/event-group-controls.svelte similarity index 79% rename from src/lib/components/lines-and-dots/event-group-filter/event-group-filter.svelte rename to src/lib/components/lines-and-dots/event-group-filter/event-group-controls.svelte index ffcae33417..3217fc3b8f 100644 --- a/src/lib/components/lines-and-dots/event-group-filter/event-group-filter.svelte +++ b/src/lib/components/lines-and-dots/event-group-filter/event-group-controls.svelte @@ -2,11 +2,14 @@ import { prefersReducedMotion } from 'svelte/motion'; import { fade, slide } from 'svelte/transition'; + import type { Snippet } from 'svelte'; + import type { EventGroupOption } from '$lib/services/grouped-event-buffer'; import EventGroupFilterMenu from './event-group-filter-menu.svelte'; - let { options }: { options: EventGroupOption[] } = $props(); + let { options, toggle }: { options: EventGroupOption[]; toggle?: Snippet } = + $props(); const transitionDuration = $derived(prefersReducedMotion.current ? 0 : 150); @@ -17,6 +20,7 @@ transition:slide={{ axis: 'x', duration: transitionDuration }} >
+ {@render toggle?.()}
diff --git a/src/lib/components/lines-and-dots/event-group-filter/event-group-filter-menu.svelte b/src/lib/components/lines-and-dots/event-group-filter/event-group-filter-menu.svelte index 7bc5eff450..942ac97122 100644 --- a/src/lib/components/lines-and-dots/event-group-filter/event-group-filter-menu.svelte +++ b/src/lib/components/lines-and-dots/event-group-filter/event-group-filter-menu.svelte @@ -135,8 +135,9 @@ {#if $open}
  • @@ -161,13 +162,18 @@ {#if matchingOptions.length} {#each visibleOptions as option (option.group.key)} {@const label = labelFor(option)} - toggle(option.group.key)} class="min-w-0"> + toggle(option.group.key)} + class="min-w-0" + data-track-text="event-group" + > {#snippet leading()} toggle(option.group.key)} checked={selectedKeys.has(option.group.key)} {label} labelHidden + data-track-text="event-group" /> {/snippet}
    diff --git a/src/lib/components/lines-and-dots/event-type-filter.svelte b/src/lib/components/lines-and-dots/event-type-filter.svelte index 492f23c7b9..3d7b0d0a8d 100644 --- a/src/lib/components/lines-and-dots/event-type-filter.svelte +++ b/src/lib/components/lines-and-dots/event-type-filter.svelte @@ -17,7 +17,6 @@ compactEventTypeOptions, } from '$lib/models/event-history/get-event-categorization'; import { clearActiveGroups } from '$lib/stores/active-events'; - import { eventViewType } from '$lib/stores/event-view'; import { eventStatusFilter, eventTypeFilter } from '$lib/stores/filters'; import { temporalVersion } from '$lib/stores/versions'; import { updateEventFilterParams } from '$lib/utilities/event-filter-params'; @@ -28,9 +27,10 @@ interface Props { compact?: boolean; + statusFilterAvailable?: boolean; } - let { compact = false }: Props = $props(); + let { compact = false, statusFilterAvailable = true }: Props = $props(); const open = writable(false); @@ -85,13 +85,10 @@ }; const onPendingClick = () => { + const statusFilter = !$eventStatusFilter; $eventTypeFilter = defaultOptions; - $eventStatusFilter = !$eventStatusFilter; - updateEventFilterParams( - page.url, - { categories: null, statusFilter: !$eventStatusFilter }, - goto, - ); + $eventStatusFilter = statusFilter; + updateEventFilterParams(page.url, { categories: null, statusFilter }, goto); }; const onNoneClick = () => { @@ -105,13 +102,14 @@ }; const filterActive = $derived( - $eventTypeFilter.length < defaultOptions.length, + ($eventStatusFilter && statusFilterAvailable) || + $eventTypeFilter.length < defaultOptions.length, ); {translate('common.filter')} {#snippet leading()} @@ -145,7 +144,7 @@ {/snippet} {translate('common.all')} - {#if $eventViewType !== 'json'} + {#if statusFilterAvailable} diff --git a/src/lib/components/lines-and-dots/timeline-graph/constants.ts b/src/lib/components/lines-and-dots/timeline-graph/constants.ts index e1f83a8d10..59f7e66bb0 100644 --- a/src/lib/components/lines-and-dots/timeline-graph/constants.ts +++ b/src/lib/components/lines-and-dots/timeline-graph/constants.ts @@ -3,3 +3,15 @@ export const ROW_HEIGHT = BASE_RADIUS * 4; export const GUTTER = BASE_RADIUS * 8; export const RADIUS = BASE_RADIUS * 1.5; export const DOT_STROKE = 2; +export const EVENT_GROUP_LINE_HEIGHT = 4; +export const EVENT_GROUP_CAP_HEIGHT = 14; +export const EVENT_GROUP_CAP_WIDTH = 2; +export const EVENT_GROUP_HEADER_MIN_HEIGHT = 32; +export const EVENT_GROUP_HEADER_SPACING = 16; +export const EVENT_GROUP_FOOTER_SPACING = 16; +export const EVENT_GROUP_ROW_OVERFLOW = Math.max( + 0, + (RADIUS * 3 - ROW_HEIGHT) / 2, +); +export const EVENT_GROUP_INSET = 8; +export const EVENT_GROUP_BORDER_WIDTH = 2; diff --git a/src/lib/components/lines-and-dots/timeline-graph/timeline-graph-row.svelte b/src/lib/components/lines-and-dots/timeline-graph/timeline-graph-row.svelte index f21a8378b5..10e71d76d5 100644 --- a/src/lib/components/lines-and-dots/timeline-graph/timeline-graph-row.svelte +++ b/src/lib/components/lines-and-dots/timeline-graph/timeline-graph-row.svelte @@ -11,6 +11,7 @@ update: 'border-blue-11 bg-indigo-11/80', other: 'border-neutral-5 bg-indigo-12/80', default: 'border-slate-blue-10 bg-slate-blue-11/80', + 'event-group': 'border-brand bg-alpha-indigo-30', }, }, }); @@ -21,6 +22,7 @@ import Preview from '$lib/holocene/markdown-editor/preview.svelte'; import { translate } from '$lib/i18n/translate'; import type { EventGroup } from '$lib/models/event-groups/event-groups'; + import { isTimelineEventGroup } from '$lib/models/event-history/timeline-event-groups'; import { setActiveGroup } from '$lib/stores/active-events'; import { resolveSystemNexusEvent } from '$lib/system-nexus-endpoints'; import { @@ -38,7 +40,14 @@ import { dotBox, lineBox } from './primitives'; import { type DotColors, dotColors, strokeColor } from '../colors'; import { CategoryIcon, type TimelineIconName } from '../constants'; - import { GUTTER, RADIUS, ROW_HEIGHT } from './constants'; + import { + EVENT_GROUP_CAP_HEIGHT, + EVENT_GROUP_CAP_WIDTH, + EVENT_GROUP_LINE_HEIGHT, + GUTTER, + RADIUS, + ROW_HEIGHT, + } from './constants'; import { timelineTextPosition } from './timeline-positioning'; type Props = { @@ -46,6 +55,8 @@ canvasWidth: number; project: (time: ValidTime | undefined | null) => number; readOnly: boolean; + expanded?: boolean; + onSelect?: (group: EventGroup) => void; // Reactive event count so the row recomputes on streamed appends (eventList // is mutated in place) and on pooled re-point. eventCount?: number; @@ -56,10 +67,13 @@ canvasWidth, project, readOnly = false, + expanded = false, + onSelect, eventCount = 0, }: Props = $props(); const timelineWidth = $derived(canvasWidth - 2 * GUTTER); + const eventGroup = $derived(isTimelineEventGroup(group) ? group : undefined); const pendingActivity = $derived(group?.pendingActivity); // Reactive (not untrack) so a re-pointed pooled row relabels for its new group. @@ -111,9 +125,15 @@ ) => { // Loop to `count` (not events.map) to depend on eventCount without allocating. const points: number[] = []; - const pointCount = Math.min(count, events.length); - for (let idx = 0; idx < pointCount; idx++) { - points.push(Math.round(project(events[idx].eventTime))); + if (eventGroup) { + const start = Math.round(project(eventGroup.initialEvent.eventTime)); + const end = Math.round(project(eventGroup.lastEvent.eventTime)); + points.push(start, Math.max(end, start + RADIUS * 2)); + } else { + const pointCount = Math.min(count, events.length); + for (let idx = 0; idx < pointCount; idx++) { + points.push(Math.round(project(events[idx].eventTime))); + } } if (pauseTime) { points.push(Math.round(project(pauseTime))); @@ -133,7 +153,11 @@ const onClick = () => { if (readOnly) return; - setActiveGroup(group); + if (onSelect) { + onSelect(group); + } else { + setActiveGroup(group); + } }; // Only activity groups carry an ActivityTaskStarted event; guard so other @@ -154,10 +178,12 @@ ); const lineColor = $derived( - strokeColor({ - category: effectiveCategory, - classification: group.lastEvent.classification, - }), + eventGroup + ? strokeColor({ category: 'event-group' }) + : strokeColor({ + category: effectiveCategory, + classification: group.lastEvent.classification, + }), ); const showRetryGradient = $derived( retried && group.lastEvent.classification === 'Completed', @@ -181,11 +207,16 @@ // Highlight corner radius, concentric with the dots' rounded corners. const highlightRadius = RADIUS * 0.8; const spanLeft = $derived(points[0] - HALO); + const eventGroupEnd = $derived( + group.isPending ? canvasWidth - GUTTER : points[points.length - 1], + ); const spanWidth = $derived( - (group.isPending && canvasWidth - points[0] - HALO) || - (points.length >= 2 - ? points[points.length - 1] - points[0] + RADIUS * 3 - : RADIUS * 3), + eventGroup + ? eventGroupEnd - points[0] + HALO * 2 + : (group.isPending && canvasWidth - points[0] - HALO) || + (points.length >= 2 + ? points[points.length - 1] - points[0] + RADIUS * 3 + : RADIUS * 3), ); const spanCy = HALO; // button-local vertical center const labelMaxWidth = $derived( @@ -225,18 +256,21 @@ animate?: boolean; gradient?: boolean; dim?: number; + thin?: boolean; }, )} {@const bounds = lineBox([leftX, spanCy], [rightX, spanCy])} + {@const lineHeight = opts.thin ? EVENT_GROUP_LINE_HEIGHT : bounds.height}
    @@ -267,11 +301,24 @@
    {/snippet} +{#snippet cap(pointX: number, color: string)} +
    +{/snippet} +