Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ui/packages/@quent/components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"@tanstack/react-table": "^8.0.0",
"@tanstack/react-virtual": "^3.0.0",
"@xyflow/react": "^12.10.1",
"echarts": "^5.6.0",
"echarts": "^6.1.0",
"echarts-for-react": "^3.0.6",
"jotai": "^2.0.0",
"react": "^19.0.0",
Expand Down
21 changes: 7 additions & 14 deletions ui/packages/@quent/components/src/dag/DagPlayhead.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// SPDX-License-Identifier: Apache-2.0

import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
import { useCallback, useEffect, useRef, useState } from 'react';
import { Pause, Play } from 'lucide-react';
import { cn, formatDurationForWindow } from '@quent/utils';
import {
Expand All @@ -10,19 +10,14 @@ import {
usePlayheadTimeS,
useSetPlayheadTimeS,
} from '@quent/hooks';
import { broadcastSyncedPointer, hideSyncedPointer, nanosToMs } from '../lib/timeline.utils';
import { broadcastSyncedPointer, hideSyncedPointer } from '../lib/timeline.utils';

/** Interval between play ticks; each tick advances the playhead by one bin. */
const PLAY_INTERVAL_MS = 100;
const KEYBOARD_STEP_BINS = 1;
const KEYBOARD_FAST_STEP_BINS = 10;

interface DagPlayheadProps {
/**
* Query epoch (ns since Unix epoch). Used to broadcast a synced axis
* pointer to the timeline charts while scrubbing/playing.
*/
startTimeUnixNs: bigint;
className?: string;
}

Expand All @@ -38,7 +33,7 @@ function formatTimeLabel(timeS: number, windowS: number): string {
* changes into per-bin frames. Renders nothing when the feature is
* unavailable or disabled.
*/
export function DagPlayhead({ startTimeUnixNs, className }: DagPlayheadProps) {
export function DagPlayhead({ className }: DagPlayheadProps) {
const enabled = useDataFlowEnabled();
const meta = useDataFlowMeta();
const playheadTimeS = usePlayheadTimeS();
Expand All @@ -51,8 +46,6 @@ export function DagPlayhead({ startTimeUnixNs, className }: DagPlayheadProps) {
const playheadRef = useRef<number | null>(playheadTimeS);
playheadRef.current = playheadTimeS;

const startTimeMs = useMemo(() => nanosToMs(startTimeUnixNs), [startTimeUnixNs]);

const bin = meta?.bin ?? null;

const clampTime = useCallback(
Expand All @@ -72,9 +65,9 @@ export function DagPlayhead({ startTimeUnixNs, className }: DagPlayheadProps) {
const t = Math.min(1, Math.max(0, (clientX - rect.left) / rect.width));
const timeS = bin.startS + t * (bin.endS - bin.startS);
setPlayheadTimeS(timeS);
broadcastSyncedPointer(startTimeMs + timeS * 1000);
broadcastSyncedPointer(timeS * 1000);
},
[bin, setPlayheadTimeS, startTimeMs]
[bin, setPlayheadTimeS]
);

const handlePointerDown = useCallback(
Expand Down Expand Up @@ -172,11 +165,11 @@ export function DagPlayhead({ startTimeUnixNs, className }: DagPlayheadProps) {
const current = playheadRef.current ?? startS;
const next = Math.min(current + binDurationS, endS);
setPlayheadTimeS(next);
broadcastSyncedPointer(startTimeMs + next * 1000);
broadcastSyncedPointer(next * 1000);
if (next >= endS) setIsPlaying(false);
}, PLAY_INTERVAL_MS);
return () => window.clearInterval(id);
}, [isPlaying, bin, setPlayheadTimeS, startTimeMs]);
}, [isPlaying, bin, setPlayheadTimeS]);

// Clear the synced crosshair when playback stops.
useEffect(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ const taskFsm: FiniteStateMachine = {

describe('buildTimelineMarks attributes', () => {
it('copies recorded and derived attributes onto marks', () => {
const marks = buildTimelineMarks([taskFsm], 0n, 'light', new Set([THREAD_ID]));
const marks = buildTimelineMarks([taskFsm], 'light', new Set([THREAD_ID]));
expect(marks).toBeDefined();
// Only the computing transition has a usage on the filtered resource.
expect(marks).toHaveLength(1);
Expand All @@ -406,7 +406,7 @@ describe('buildTimelineMarks attributes', () => {
});

it('omits attribute keys for attribute-less transitions', () => {
const marks = buildTimelineMarks([taskFsm], 0n, 'light', null);
const marks = buildTimelineMarks([taskFsm], 'light', null);
expect(marks).toHaveLength(2);
const queueing = marks!.find(m => m.stateName === 'queueing')!;
expect(queueing.derivedAttributes).toBeUndefined();
Expand All @@ -422,7 +422,7 @@ describe('buildTimelineMarks attributes', () => {
return rest;
}),
} as unknown as FiniteStateMachine;
const marks = buildTimelineMarks([legacyFsm], 0n, 'light', new Set([THREAD_ID]));
const marks = buildTimelineMarks([legacyFsm], 'light', new Set([THREAD_ID]));
expect(marks).toHaveLength(1);
expect(marks![0]!.attributes).toBeUndefined();
expect(marks![0]!.derivedAttributes).toBeUndefined();
Expand Down
24 changes: 11 additions & 13 deletions ui/packages/@quent/components/src/lib/timeline.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,12 @@ import { MAX_TIMELINE_BINS } from '@quent/utils';
void getColorForKey;
const LONG_ENTITIES_BIN_MULTIPLIER = 30;

/** Minimum bin duration in nanoseconds — prevents ECharts from stacking bins when zoomed too far. */
export const MIN_BIN_DURATION_NS = 250;
/** Minimum bin duration in nanoseconds — the backend cannot produce sub-1ns bins. */
export const MIN_BIN_DURATION_NS = 10;

/**
* Minimum visible zoom window in seconds.
* Below this, each bin would cover less than MIN_BIN_DURATION_NS nanoseconds.
* 10 ns/bin × 400 bins = 4 μs
* Minimum visible zoom window in seconds: the smallest window the backend can
* bin at 1 ns/bin. 1 ns/bin × MAX_TIMELINE_BINS bins.
*/
export const MIN_ZOOM_WINDOW_S = (MIN_BIN_DURATION_NS * MAX_TIMELINE_BINS) / 1_000_000_000;

Expand All @@ -71,7 +70,6 @@ export function getLongEntitiesThreshold(windowSeconds: number): number {
export function buildBinnedTimelineSeries(
data: ResourceTimeline,
config: BinnedSpanSec,
startTime: bigint,
theme: PaletteTheme,
capacities?: CapacityDecl[],
quantitySpecs?: { [key in string]?: QuantitySpec },
Expand All @@ -83,7 +81,9 @@ export function buildBinnedTimelineSeries(
const { bin_duration, num_bins, span } = config;

const numBinsNumber = Number(num_bins);
const firstBinMs = nanosToMs(startTime) + span.start * 1_000;
// x-domain is relative to query start (ms); span.start is already relative
// seconds, so no absolute epoch base is added — keeps values float64-exact.
const firstBinMs = span.start * 1_000;
const binDurationMs = bin_duration * 1_000;

const timestamps = new Array<number>(numBinsNumber);
Expand Down Expand Up @@ -170,7 +170,6 @@ export function getLongFsms(data: ResourceTimeline): FiniteStateMachine[] {
*/
export function buildTimelineMarks(
longFsms: FiniteStateMachine[],
startTime: bigint,
theme: PaletteTheme,
resourceIdsForFilter?: Set<string> | null,
fsmTypes?: { [key in string]?: FsmTypeDecl },
Expand All @@ -180,7 +179,6 @@ export function buildTimelineMarks(
): TimelineMark[] | undefined {
if (longFsms.length === 0) return undefined;

const startTimeMs = nanosToMs(startTime);
const colorFsm = createFsmTypeColorFn(fsmTypes ?? {}, theme);

const marks = longFsms.flatMap(fsm => {
Expand All @@ -196,8 +194,8 @@ export function buildTimelineMarks(
return null;
}
const next = fsm.transitions[i + 1];
const xStart = startTimeMs + transition.timestamp * 1000;
const xEnd = startTimeMs + next.timestamp * 1000;
const xStart = transition.timestamp * 1000;
const xEnd = next.timestamp * 1000;
const color = colorFsm(transition.name);
return {
label,
Expand Down Expand Up @@ -473,8 +471,8 @@ function broadcastHidePointer(source: EChartsInstance | null) {
}

/**
* Broadcast a synced axis-pointer crosshair at `timestampMs` (epoch ms) to
* every registered timeline chart, without a source chart. Used by the DAG
* Broadcast a synced axis-pointer crosshair at `timestampMs` (ms relative to
* query start) to every registered timeline chart, without a source chart. Used by the DAG
* playhead so scrubbing/playing draws a crosshair on the right-panel
* timelines with zero React re-renders.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,7 @@ import EChartsReactCore from 'echarts-for-react/lib/core';
import type { EChartsOption } from '../lib/echarts';
import type { EChartsInstance } from 'echarts-for-react';
import type { CustomSeriesOption } from 'echarts/charts';
import {
nanosToMs,
registerAxisPointerSync,
unregisterAxisPointerSync,
} from '../lib/timeline.utils';
import { registerAxisPointerSync, unregisterAxisPointerSync } from '../lib/timeline.utils';
import { useChartConnect } from '../lib/useChartConnect';
import { useMinZoomSpanPct } from '../lib/useMinZoomSpanPct';
import { useTimelineWheelNavigation } from '../lib/useTimelineWheelNavigation';
Expand Down Expand Up @@ -47,7 +43,6 @@ function getOperatorBarColors(typeName: string | undefined): { fill: string; str

export interface OperatorGanttChartProps {
operators: OperatorActiveSpanEntry[];
startTime: bigint;
durationSeconds: number;
height?: number;
/** Whether dark mode is active. Passed explicitly to decouple from ThemeContext. */
Expand All @@ -56,7 +51,6 @@ export interface OperatorGanttChartProps {

export function OperatorGanttChart({
operators,
startTime,
durationSeconds,
height = DEFAULT_HEIGHT,
isDark,
Expand All @@ -70,11 +64,7 @@ export function OperatorGanttChart({
const [nodePalette] = useNodeColorPalette();
const barLabelTextColor = textColor;
const selectedNodeIds = useSelectedNodeIds();
const startTimeMs = useMemo(() => nanosToMs(startTime), [startTime]);
const xAxisMax = useMemo(
() => startTimeMs + durationSeconds * 1_000,
[startTimeMs, durationSeconds]
);
const xAxisMax = useMemo(() => durationSeconds * 1_000, [durationSeconds]);
const minZoomSpanPct = useMinZoomSpanPct(durationSeconds);
const attachWheelNavigation = useTimelineWheelNavigation(minZoomSpanPct);
const wrapperRef = useRef<HTMLDivElement | null>(null);
Expand Down Expand Up @@ -230,8 +220,8 @@ export function OperatorGanttChart({
},
grid: gridOptions,
xAxis: {
type: 'time',
min: startTimeMs,
type: 'value',
min: 0,
max: xAxisMax,
show: true,
axisLabel: { show: false },
Expand Down Expand Up @@ -292,15 +282,7 @@ export function OperatorGanttChart({
},
],
}),
[
gridOptions,
startTimeMs,
xAxisMax,
yAxisCategories,
customSeriesData,
renderItem,
minZoomSpanPct,
]
[gridOptions, xAxisMax, yAxisCategories, customSeriesData, renderItem, minZoomSpanPct]
);

const handleClick = useMemo(
Expand Down
Loading
Loading