Skip to content

Refactor: Migrate ViewingLayer to Functional Component#3504

Open
M-DEV-1 wants to merge 10 commits intojaegertracing:mainfrom
M-DEV-1:M-DEV-1/migrate-viewinglayer
Open

Refactor: Migrate ViewingLayer to Functional Component#3504
M-DEV-1 wants to merge 10 commits intojaegertracing:mainfrom
M-DEV-1:M-DEV-1/migrate-viewinglayer

Conversation

@M-DEV-1
Copy link
Copy Markdown

@M-DEV-1 M-DEV-1 commented Feb 5, 2026

Which problem is this PR solving?

Description of the changes

How was this change tested?

Unit Tests

image

Visuals

  • Before
image
  • After
image

Videos

  • Updated (After)
Screencast.from.2026-02-06.02-32-03.webm

Checklist

Signed-off-by: M-DEV-1 <mahadevankizhakkedathu@gmail.com>
@M-DEV-1 M-DEV-1 requested a review from a team as a code owner February 5, 2026 13:07
Copilot AI review requested due to automatic review settings February 5, 2026 13:07
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request migrates the ViewingLayer component from a React class-based component to a functional component using hooks, as part of the larger modernization effort to refactor Jaeger UI's codebase (#2610).

Changes:

  • Converted class component to functional component using forwardRef
  • Replaced this.state with useState for the preventCursorLine state
  • Replaced componentWillUnmount with useEffect for cleanup logic
  • Added useImperativeHandle to expose component methods for backwards compatibility with existing tests
  • Wrapped component in React.memo to preserve PureComponent performance optimization
  • Used useRef pattern with propsRef to ensure handlers have access to latest props

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: mahadevan <135952571+M-DEV-1@users.noreply.github.com>
Copilot AI review requested due to automatic review settings February 5, 2026 13:18
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 5 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Signed-off-by: M-DEV-1 <mahadevankizhakkedathu@gmail.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copilot AI review requested due to automatic review settings February 9, 2026 06:45
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +178 to 183
it('prevents the cursor from being drawn on scrubber mouseleave', async () => {
fireEvent.mouseLeave(container.querySelectorAll('[data-testid="scrubber"]')[0]);
expect(ref.current.state.preventCursorLine).toBe(false);
await waitFor(() =>
expect(container.querySelector('.ViewingLayer--cursorGuide')).toBeInTheDocument()
);
});
Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

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

The test name "prevents the cursor from being drawn on scrubber mouseleave" no longer matches the asserted behavior (it waits for the cursor guide to be present after mouseleave). Renaming the test to reflect the actual expectation (e.g. cursor guide is restored on mouseleave) will reduce confusion when debugging failures.

Copilot uses AI. Check for mistakes.
@codecov
Copy link
Copy Markdown

codecov Bot commented Feb 20, 2026

Codecov Report

❌ Patch coverage is 97.43590% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.31%. Comparing base (efb138f) to head (8c7d54e).
⚠️ Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
...acePage/TracePageHeader/SpanGraph/ViewingLayer.tsx 97.43% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3504      +/-   ##
==========================================
- Coverage   88.32%   88.31%   -0.01%     
==========================================
  Files         299      299              
  Lines        9487     9496       +9     
  Branches     2420     2420              
==========================================
+ Hits         8379     8386       +7     
- Misses       1105     1107       +2     
  Partials        3        3              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copilot AI review requested due to automatic review settings March 5, 2026 05:45
@M-DEV-1
Copy link
Copy Markdown
Author

M-DEV-1 commented Mar 5, 2026

Hi @yurishkuro,

just bumping this PR in case it got buried. would really appreciate a review when you have time.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +178 to 183
it('prevents the cursor from being drawn on scrubber mouseleave', async () => {
fireEvent.mouseLeave(container.querySelectorAll('[data-testid="scrubber"]')[0]);
expect(ref.current.state.preventCursorLine).toBe(false);
await waitFor(() =>
expect(container.querySelector('.ViewingLayer--cursorGuide')).toBeInTheDocument()
);
});
Copy link

Copilot AI Mar 5, 2026

Choose a reason for hiding this comment

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

This test name no longer matches the assertion: on mouseLeave the cursor guide is expected to re-appear (i.e., cursor drawing is no longer prevented). Renaming the test to reflect the intended behavior will make failures easier to interpret.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

taking a look.

@M-DEV-1
Copy link
Copy Markdown
Author

M-DEV-1 commented Mar 5, 2026

Also, since I've been periodically updating the branch with main, the history now includes several "merge main into " commits. would you prefer that I rebase the branch to remove those merge commits, or leave it as-is?

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.

[UI Refactor] Migrate ViewingLayer to Functional Component

2 participants