Skip to content

Support anomaly investigation overlays in both time-series renderers - #240

Merged
novykh merged 10 commits into
mainfrom
feat/anomaly-advisor-chart-overlays
Oct 28, 2026
Merged

novykh merged 10 commits into
mainfrom
feat/anomaly-advisor-chart-overlays

Conversation

@ktsaou

@ktsaou ktsaou commented Oct 5, 2026 •

Copy link
Copy Markdown
Member

Summary

Support the redesigned Anomalies investigation chart with both native time-series renderers, without pinning Dygraph or changing the dashboard's renderer policy.

  • Provide post-underlay callbacks and CSS-pixel X/Y coordinates for finding regions, baseline lines and precise hit-testing in Dygraph and uPlot. uPlot converts device pixels once and restores canvas state even when an extension throws.
  • Add enabledAnnotations, defaulting to true (same enabledX form as enabledHover/enabledNavigation). Strict false suppresses saved/draft annotations and annotation-oriented click/tap behavior while preserving raw UI events for investigation selection. Other overlays and ordinary chart defaults remain unchanged.
  • Honor finite highlightOpacity (default 1) in both renderers, clamped to [0, 1], without changing the highlighted range or leaking canvas state. Changing enabledAnnotations or highlightOpacity redraws the native canvas.
  • Forward stationary uPlot clicks and taps. Do not commit a pan unless the existing five-pixel drag threshold is crossed; clicking a short-window chart must not replace its query window with uPlot's expanded axis bounds.
  • Remount the current native UI in its existing React container when the renderer changes. Cleanup targets the captured old UI. Rebind annotation hover, overlay labels, metric popovers and plot-area listeners to the replacement renderer, preserving the React subtree and chart attributes.

Base and scope

This companion is based on main at da91889cc, which includes the merged renderer PR #234. The PR diff contains only the companion extensions and this port, not the underlying renderer implementation. The old main-based head remains recoverable locally.

No package version, dependency or release workflow is changed. No detection algorithm, Chat or dashboard-provider policy changes are included. Correlation (weights) queries do change; see "Behaviour changes for existing SDK users".

Validation

  • Real-SDK negative controls reproduced missing native callbacks/coordinates, imprecise snapped-sample selection, an unmounted replacement UI and the stale React subscriptions before their fixes. The bidirectional renderer lifecycle regression fails all four affected owners without the corrections and passes afterward.
  • Final scoped source run: 57 suites / 639 tests pass. Three failures in two unchanged suites also reproduce on pristine SDK 7 source: the getDateDiff() declaration-order error and two grid CSS serialization assertions under the shared frontend test toolchain. No full charts-suite pass is claimed.
  • Independent adversarial re-review passes the incremental source: six separately constructed lifecycle/gesture probes; the final DPR2 source matrix of six suites / 60 tests; and ordinary table/modern-pie transitions using real SDK controllers and React components.
  • Final frontend native-overlay/Timeline integration: two suites / nine tests pass at both native DPR1 and DPR2. Physical browser checks confirm finding hover, stationary selection without a query-window commit, real panning and high-DPI selection. The live Anomalies page renders with uPlot and keeps its chart height.
  • Changed JavaScript passes ESLint and Prettier; whitespace checks pass. Resource-intensive runs use nice priority 15 and one Jest worker per suite/shard.
  • Local Codacy is unconfigured; Cloud has no PR analysis available. No Codacy quality/coverage pass is claimed.
  • The existing Storybook workflow fails before jobs on the companion and renderer branches. It is unchanged here; the test workflow runs on main, not PR branches.

Behaviour changes for existing SDK users

  • Correlation baselines (volume and ks2). Every weights request now uses an adaptive preceding baseline: 4× the window for windows under 1 hour, 2× under 6 hours, 1× otherwise (getCorrelationBaseline). For these two methods an explicit baselineAfter/baselineBefore is intentionally ignored (pinned by correlationBaseline.test.js). anomaly-rate and value keep explicit baselines. Callers that sent no baseline used to compare a window with itself; they now compare it with the preceding window. The Correlate drawer moves from a fixed 4× baseline to the adaptive one. Fully relative live windows are anchored to the captured clock when one exists.
  • Touch taps differ by renderer on purpose. uPlot always forwards a stationary tap as a click UI event and sets clickX only while annotations are enabled. Dygraph keeps its existing tap behavior (clickX, no click) while annotations are enabled, and emits click without clickX only when they are disabled. Forwarding click on every Dygraph tap would route taps into its click-to-pin/annotation path for existing users. Both renderers are pinned by tests.
  • Renderer swap and external listeners. A renderer swap creates a new UI object. Listeners registered with ui.on(...) on the old UI end when it unmounts (unmount clears its listeners), so consumers must re-subscribe on mountChartUI. The old UI is unmounted twice during a swap (by the SDK swap and by ChartContainer cleanup); the second call is harmless and fires unmountChartUI again.
  • uPlot click scope. uPlot forwards stationary mouse clicks only in pan navigation mode; drags and modifier gestures emit no click. Dygraph clicks come from Dygraph's own click callback; their behavior in select/highlight modes is not covered by this PR.
  • uPlot panning for all uPlot users. A pan is committed only after the five-pixel drag threshold is crossed, and a stationary press emits no panEnd. This stops a click from replacing a short window with uPlot's expanded axis bounds, and applies to every chart rendered with uPlot.

Review follow-ups in this PR

  • annotationsEnabled renamed to enabledAnnotations (frontend consumers updated in the companion PR).
  • Native canvases redraw when enabledAnnotations or highlightOpacity change; highlightOpacity has a no-op default of 1.
  • Shared helpers for the annotation gate and highlight opacity; weights payloads are built once per request.
  • usesAdaptiveBaseline exported; the Correlate drawer no longer computes a baseline that the fetch layer replaces.
  • useChartUI hook replaces the chartLibrary attribute as the "UI replaced" signal in the five renderer-bound effects.
  • Investigation tests use real renderers and the canvas event log instead of fake UIs or patched canvas methods.

Integration / release

Companion to frontend Anomalies PR #5889.

  1. Integrate this companion into the SDK 7 release source.
  2. Publish a compatible SDK 7 package containing these extensions. This PR does not choose a release version or publish a package.
  3. Explicitly update the frontend dependency/lockfile and verify a clean installation without development overlays.
  4. Complete frontend manual acceptance testing.

The currently published 7.0.0-alpha.1 does not contain these extensions. Local frontend validation preserves SDK 7 and compiles only the required companion modules into the existing development installation; it does not replace SDK 7 with SDK 6 or certify a clean released-package installation.

The PR remains draft and is not release-ready until these gates are satisfied.

@ktsaou
ktsaou force-pushed the feat/anomaly-advisor-chart-overlays branch 2 times, most recently from e14fbc3 to c583dfb Compare October 6, 2026 03:47
@ktsaou ktsaou changed the title Support temporary investigation overlays and annotation opt-out Support anomaly investigation overlays in both time-series renderers Oct 6, 2026
@ktsaou
ktsaou changed the base branch from main to feat/uplot-renderer October 6, 2026 03:47
@ktsaou
ktsaou marked this pull request as ready for review October 7, 2026 08:18
Base automatically changed from feat/uplot-renderer to main October 14, 2026 15:18
@novykh
novykh force-pushed the feat/anomaly-advisor-chart-overlays branch from ccae6cb to 8adff02 Compare October 15, 2026 05:37
@ktsaou
ktsaou force-pushed the feat/anomaly-advisor-chart-overlays branch from 8adff02 to ba76425 Compare October 18, 2026 14:37
@novykh
novykh force-pushed the feat/anomaly-advisor-chart-overlays branch from 564b7c7 to 0c90df4 Compare October 20, 2026 09:32
@novykh
novykh merged commit aafcc07 into main Oct 28, 2026
1 check passed
@novykh
novykh deleted the feat/anomaly-advisor-chart-overlays branch October 28, 2026 08:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants