Skip to content

DEV: timeshift overlay - #180

Open
YektaY wants to merge 8 commits into
mainfrom
timeshift-overlay
Open

YektaY wants to merge 8 commits into
mainfrom
timeshift-overlay

Conversation

@YektaY

@YektaY YektaY commented Nov 12, 2026

Copy link
Copy Markdown
Collaborator

Originally opened by tiffany-slac as slaclab/react-trace-archive#180. Its review history and CI runs stay in the archive.

Description

  • Add timeOffset field to PVTrace for offsets like "-1d", "-7d"
  • Offset traces fetch [from+offset, to+offset] and shift timestamps onto the plot's axis
  • Legend and tooltip show the offset, e.g. "PV:TEST (−1 d)"
  • "Duplicate with offset" action via clock icon on trace rows with preset and custom offsets
  • Offset traces are archive-only (live data disabled)
  • Offset traces use dashed line style to distinguish from the original
  • Time Offset input in RightPanel General tab with validation

Motivation

Closes #124

Screenshots

Screenshot 2026-11-09 at 1 59 30 PM

Pre-merge checklist

  • Code works interactively in the browser
  • New/changed components are covered in the test suite where possible
  • Test suite passes locally (npm test)
  • Linting passes (npm run lint)
  • Test suite passes on GitHub Actions

tiffany-slac and others added 4 commits November 4, 2026 17:48
- Per-plot undo/redo stack for view states (time window + Y-axis ranges)
- Back/Forward buttons in the tab bar with Undo/Redo icons
- Reset zoom button that restores full range, re-enables autoscroll, and resets all Y-axes to auto-scale (fixes #109)
- Keyboard shortcuts: Alt+←/→ for back/forward, Alt+0 for reset zoom
- 300ms coalesce timer so rapid zoom adjustments merge into one history entry
- Reset zoom button per grid cell
- Programmatic zoom restore via ECharts dispatchAction with zoomTarget prop
- Session-only history, not persisted to workspaces
- Clean up zoomTargetByPlot entries when a plot is removed
- Read post-update plots inside setPlots updater in updateAxisInPlot so the history snapshot reflects the actual axis state
- Narrow useEffect dependency from full zoomTarget object to zoomTarget?.generation to avoid unnecessary effect runs
- Add timeOffset field to PVTrace for offsets like "-1d", "-7d"
- Offset traces fetch [from+offset, to+offset] and shift timestamps onto the plot's axis
- Legend and tooltip show the offset, e.g. "PV:TEST (−1 d)"
- "Duplicate with offset" action via clock icon on trace rows with preset and custom offsets
- Offset traces are archive-only (live data disabled)
- Offset traces use dashed line style to distinguish from the original
- Time Offset input in RightPanel General tab with validation
@YektaY
YektaY requested a review from a team as a code owner November 12, 2026 06:34

@jbellister-slac jbellister-slac left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested locally, looks cool! Looked at only the time-offset commit (4cb0e1c). The first three commits are already reviewed at #172.

I think it might be useful to have some added documentation covering this feature.

A few inline comments below.

Comment thread src/components/TraceApp.tsx Outdated

const updateTrace = (traceId: string, updates: Partial<PVTrace>) => {
if (updates.timeOffset && parseOffsetMs(updates.timeOffset) != null) {
updates = { ...updates, useLive: false, useArchive: true };

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two gaps in how the archive-only rule is applied:

  • It is enforced only when the offset is edited through updateTrace. A workspace file or share link with timeOffset set and useLive: true loads as-is, and traceSamples shifts live points along with archive ones, so live data would be drawn displaced by the offset. Enforcing it on load, or ignoring live points for offset traces in traceSamples, would close that.
  • Clearing the offset leaves useLive off. A trace that was live before an offset was typed in stays archive-only afterwards with nothing indicating why.

Comment thread src/components/LeftPanel.tsx Outdated
className="offset-popover"
onClick={(e) => e.stopPropagation()}
onKeyDown={(e) => {
if (e.key === 'Escape') onClose();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few things on the popover:

  • Escape only fires when focus is inside this div, but after clicking the clock button focus stays on the button, so Escape does nothing until something inside is focused.
  • There is no outside-click close, so popovers can be left open on several rows at once.
  • role="menu" is set but the items have no menuitem role or arrow-key handling.
  • Styling and hover are done with inline styles and mouse handlers; the rest of the panel uses classes in App.css.
  • Dragging to select text in the custom input starts a row drag, since the popover sits inside the sortable row.

Comment thread src/components/TraceApp.tsx Outdated
...source,
id,
color: colorForIndex(getPalette(paletteId), plot.traces.length),
displayName: '',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor: this drops a custom display name from the source trace. traceLabel appends the offset to whichever name is in use, so keeping source.displayName would give e.g. "Beam current (−1 d)" instead of falling back to the PV name.

tiffany-slac and others added 3 commits November 19, 2026 14:47
- Sanitize offset traces on workspace/share-link load to force archive-only mode
- Restore useLive when clearing a trace's time offset
- Preserve custom display name when duplicating a trace with offset
- Fix OffsetPopover: close on Escape and outside click, prevent drag conflict, add ARIA roles, and move inline styles to CSS classes
- Document the "Compare with a Time Offset" feature: creating offset traces, how they display, editing/removing offsets
- Add missing zoomTarget and liveChart dependencies to useEffect
- Run prettier on PlotArea.tsx

This branch has not been deployed

No deployments
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.

[FEATURE] - Time-shifted overlay: compare a PV with an earlier time range

3 participants