Skip to content

Conversation

@cloudmark
Copy link
Contributor

Here's a comprehensive PR description for the region synchronization fix:


PR Description

Reason for Change

Problem:
When clicking on region annotations (either directly on the plot or in the Regions sidebar/outliner), the view scrolls to show the region but does NOT synchronize with other synced media components. This breaks multi-modal data exploration workflows where users expect all synchronized components (Audio, TimeSeries, etc.) to seek to the same time position.

For example:

  • Click on a TimeSeries region labeled "Walking" → Only TimeSeries view scrolls
  • Audio player stays at current position
  • Other TimeSeries (velocity, acceleration, etc.) don't update
  • User cannot navigate synchronized data by clicking annotations

Root Cause:
The selectRegion() method in TimeSeriesRegion.js only calls scrollToRegion() which adjusts the view but does not:

  1. Update the cursor position (setCursor())
  2. Emit a sync event (syncSend()) to notify other components

This is inconsistent with how clicking directly on empty plot areas works, which DOES emit sync events.

Solution:
Modified TimeSeriesRegion.selectRegion() to emit sync events after scrolling to the region. The method now:

  1. Scrolls the TimeSeries view to show the region (existing behavior)
  2. Updates the cursor/playhead position using setCursor()
  3. Calculates relative time from the region's start time
  4. Emits a sync event via syncSend() to notify all components in the same sync group
  5. Handles both date-formatted and numeric time columns properly

Videos


Rollout Strategy

No special rollout needed - This fix is gated by existing feature flag:

  • Requires FF_TIMESERIES_SYNC feature flag to be enabled
  • No new environment variables needed
  • No API changes
  • Backward compatible - only improves existing behavior
  • Change applies automatically when feature flag is active

Testing

Manual Testing Performed:

  1. Basic Region Click Test

    • Created TimeSeries task with Audio and multiple TimeSeries (acceleration, velocity)
    • Created region annotations on TimeSeries
    • Clicked on regions directly on the plot
    • Verified all synced components seek to region's start time (see fix demo video)
    • Tested with both numeric and date-formatted time columns
  2. Regions Sidebar Test

    • Clicked on regions in the Regions sidebar/outliner
    • Verified all synced components synchronize
    • Confirmed behavior is identical to clicking on plot
  3. Edge Cases

    • Regions at the very start/end of timeseries
    • Multiple regions selected in sequence
    • Instant regions (zero duration)
    • Date-formatted time columns with millisecond precision
  4. Interaction Consistency

    • Clicking empty plot → syncs all components (existing behavior - works)
    • Clicking region on plot → syncs all components (NEW - works)
    • Clicking region in sidebar → syncs all components (NEW - works)
  5. Multi-Component Synchronization

    • Audio + multiple TimeSeries (acceleration, velocity, gyroscope)
    • Verified sync works in all directions:
      • TimeSeries region → Audio seeks
      • Audio region → TimeSeries seek (if applicable)
      • All TimeSeries update together

Code Quality:

  • No linting errors introduced
  • Follows existing code patterns and conventions
  • Uses existing setCursor() and syncSend() methods
  • Properly checks feature flag before emitting sync

Risks

Risk Level: LOW

Performance:

  • No performance impact - only adds two method calls when regions are clicked
  • Sync events are already used throughout the system
  • No additional data processing or computations

Backward Compatibility:

  • No breaking changes
  • Only affects behavior when FF_TIMESERIES_SYNC is enabled
  • Users without the feature flag see no change
  • All existing TimeSeries functionality preserved

Security:

  • No security implications
  • No new dependencies added
  • No changes to data handling or storage
  • Uses existing sync infrastructure

User Experience:

  • Fixes broken behavior - strictly an improvement
  • Makes region clicks consistent with plot clicks
  • Improves multi-modal data exploration workflows

Reviewer Notes

Key Points to Review:

  1. Implementation Location (web/libs/editor/src/regions/TimeSeriesRegion.js)

    • Changes are in selectRegion() method (lines ~72-93)
    • Feature flag check ensures safe rollout
    • Time conversion handles both date and numeric formats
  2. Code Logic:

    // After existing scrollToRegion() call:
    if (isFF(FF_TIMESERIES_SYNC) && self.parent.sync) {
      const regionStartTime = self.start;
      self.parent.setCursor(regionStartTime);
      
      const [minKey] = self.parent.keysRange;
      if (minKey !== undefined) {
        let relativeTime;
        if (self.parent.isDate) {
          relativeTime = (regionStartTime - minKey) / 1000;
        } else {
          relativeTime = regionStartTime - minKey;
        }
        self.parent.syncSend({ time: relativeTime, playing: false }, "seek");
      }
    }
  3. Consistency with Existing Code:

    • Uses same pattern as handleMainAreaClick() and plotClickHandler()
    • Reuses existing setCursor() and syncSend() methods
    • Follows same time conversion logic as other seek operations
  4. Testing the Fix:

    • Watch both demonstration videos to see before/after behavior
    • Load any TimeSeries task with sync enabled
    • Click on regions (plot or sidebar) and verify all components sync

General Notes

Implementation Details:

The fix adds synchronization logic to TimeSeriesRegion.selectRegion():

  • Called when region is clicked on plot OR in sidebar
  • Scrolls view to region (existing behavior - preserved)
  • Updates cursor position to region start time (NEW)
  • Emits sync event to all synced components (NEW)

Time Conversion:

  • For date-formatted columns: converts milliseconds to seconds
  • For numeric columns: uses values directly
  • Matches existing time conversion patterns throughout TimeSeries

Feature Flag:

  • Protected by FF_TIMESERIES_SYNC feature flag
  • Safe to deploy with flag disabled
  • Can be enabled per-project or globally

Benefits:

  • Clicking any region (plot or sidebar) now syncs all components
  • Consistent behavior across all interaction methods
  • Critical for multi-modal workflows (IoT, wearables, autonomous vehicles)
  • Improved user experience for time-series annotation tasks

Files Changed:

  1. web/libs/editor/src/regions/TimeSeriesRegion.js - Added sync logic to selectRegion()

No Migration Required - This is a transparent bug fix that improves behavior without requiring any user action or configuration changes.


Related Context

Related to Issue: #8603

When clicking on region annotations (either directly on the plot or in the
Regions sidebar/outliner), the view would scroll to show the region but would
NOT synchronize with other synced media components. This broke multi-modal
data exploration workflows where users expect all synchronized components
(Audio, TimeSeries, etc.) to seek to the same time position.

For example, clicking on a TimeSeries region labeled "Walking" would only
scroll the TimeSeries view but would not seek the Audio player or other
synced TimeSeries to that time.

Changes:
- Modified TimeSeriesRegion.selectRegion() to emit sync events after
  scrolling to the region
- Added setCursor() call to update the cursor/playhead position
- Added syncSend() call with the region's start time to notify all synced
  components in the same sync group
- Handles both date-formatted and numeric time columns properly
- Applies to both direct region clicks and Regions sidebar/outliner clicks

Benefits:
- Clicking any region (plot or sidebar) now syncs all components
- Consistent behavior between clicking empty plot vs clicking regions
- Improved multi-modal data exploration and navigation
- Users can now easily navigate synchronized data by clicking annotations

Impact:
- Affects all TimeSeries annotation tasks with synchronized media
- Critical for multi-sensor data workflows (IoT, wearables, autonomous vehicles)
- Requires FF_TIMESERIES_SYNC feature flag to be enabled

Bug demonstration: https://www.loom.com/share/2584716884114820a7e4b5b76a3316b3
Fix demonstration: https://www.loom.com/share/9a6421fca42d424bb068779d9a4d7021

Files changed:
- web/libs/editor/src/regions/TimeSeriesRegion.js
@cloudmark cloudmark requested a review from a team as a code owner October 8, 2025 10:02
@netlify
Copy link

netlify bot commented Oct 8, 2025

👷 Deploy request for heartex-docs pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 38f829b

@netlify
Copy link

netlify bot commented Oct 8, 2025

👷 Deploy request for label-studio-docs-new-theme pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 38f829b

@netlify
Copy link

netlify bot commented Oct 8, 2025

Deploy Preview for label-studio-storybook ready!

Name Link
🔨 Latest commit 38f829b
🔍 Latest deploy log https://app.netlify.com/projects/label-studio-storybook/deploys/68e636c9c9f3cf0008921652
😎 Deploy Preview https://deploy-preview-8604--label-studio-storybook.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@github-actions github-actions bot added the fix label Oct 8, 2025
@netlify
Copy link

netlify bot commented Oct 8, 2025

Deploy Preview for label-studio-playground ready!

Name Link
🔨 Latest commit 38f829b
🔍 Latest deploy log https://app.netlify.com/projects/label-studio-playground/deploys/68e636c91b5d580008929794
😎 Deploy Preview https://deploy-preview-8604--label-studio-playground.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

"on-headers": "1.1.0",
"form-data": "4.0.4",
"stylus": "0.0.1-security"
"stylus": "0.64.0"
Copy link
Contributor

Choose a reason for hiding this comment

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

this seems unrelated - was that intended?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, this was done so I could build it, "stylus": "0.0.1-security" was not being resolved, not sure if its just me or not.

If its me, we can simply revert.

Copy link
Contributor

Choose a reason for hiding this comment

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

the whole override can probably be removed

Copy link
Contributor

Choose a reason for hiding this comment

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

Great catch, @cloudmark! I think it's best to take it from this PR to avoid mixing concerns.
Let's review this separately @yyassi-heartex, as @nass600 said this can probably be removed since it's coming from the npm incident.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hi @cloudmark we discussed internally, please leave the stylus version unchanged - we'll be creating a PR internally to remove it anyways

@yyassi-heartex
Copy link
Contributor

yyassi-heartex commented Oct 17, 2025

/jira create

Workflow run
Jira issue TRIAG-1683 is created

@cloudmark
Copy link
Contributor Author

cloudmark commented Oct 21, 2025 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants