Skip to content

Conversation

@ConradKash
Copy link

@ConradKash ConradKash commented Jan 30, 2026

Which problem is this PR solving?

Fixes #3370

Description of the changes

Converts the TraceStatisticsHeader class component to a functional component using React hooks:

  • Converted class component to functional component using React hooks (useState, useEffect, useCallback, useMemo)
  • Added React.memo for performance optimization
  • Added comprehensive test suite using React Testing Library
  • Fixed a typo in variable naming (newWohleTable → newWholeTable)

How was this change tested?

  • I added TraceStatisticsHeader.test.js to test the logic of the page

Checklist

Copilot AI review requested due to automatic review settings January 30, 2026 18:13
@ConradKash ConradKash requested a review from a team as a code owner January 30, 2026 18:13
Copy link

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 converts the TraceStatisticsHeader component from a React class component to a functional component using hooks, as part of the larger UI modernization effort (#2610).

Changes:

  • Converted class component to functional component with hooks (useState, useEffect, useCallback, useMemo)
  • Replaced lifecycle method (constructor) with useEffect hook for initialization
  • Added comprehensive test suite using React Testing Library
  • Refactored all class methods to useCallback hooks
  • Fixed typo in variable name (newWohleTable → newWholeTable)

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 7 comments.

File Description
TraceStatisticsHeader.tsx Converted from class to functional component with hooks; replaced state with useState, constructor initialization with useEffect, and methods with useCallback
TraceStatisticsHeader.test.js New test file with comprehensive test coverage using React Testing Library instead of Enzyme

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

@jkowall
Copy link
Contributor

jkowall commented Jan 30, 2026

@ConradKash please process the feedback accordingly, and sign the DCO. Read more in CONTRIBUTING.md.

@github-actions github-actions bot added the waiting-for-author PR is waiting for author to respond to maintainer's comments label Jan 30, 2026
@ConradKash ConradKash force-pushed the feature-update-trace-statistics-header branch from a8ab3fb to bf2b7e9 Compare January 30, 2026 19:18
@github-actions github-actions bot removed the waiting-for-author PR is waiting for author to respond to maintainer's comments label Jan 30, 2026
Copilot AI review requested due to automatic review settings January 30, 2026 19:54
Copy link

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 3 comments.


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

Copilot AI review requested due to automatic review settings January 31, 2026 20:22
Copy link

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 3 comments.


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

Copilot AI review requested due to automatic review settings January 31, 2026 20:42
Copy link

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 no new comments.


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

this.clearValue = this.clearValue.bind(this);
}
// This ensures that the service name is only computed once on initial render
const initialServiceName = getServiceName();
Copy link
Contributor

Choose a reason for hiding this comment

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

Performance Issue: Unnecessary computation on every render

getServiceName() is called on every render of the component, but the value is only used in the useEffect which runs once due to the empty dependency array []. After the initial render, this computation is wasted.

The comment claims "This ensures that the service name is only computed once on initial render" but this is incorrect - it's computed on every render.

Fix:

const initialServiceName = useMemo(() => getServiceName(), []);

Or better yet, compute it inside the useEffect where it's actually used, eliminating the need for this variable entirely.

Suggested change
const initialServiceName = getServiceName();
const initialServiceName = useMemo(() => getServiceName(), []);

Spotted by Graphite Agent

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

Copy link
Member

Choose a reason for hiding this comment

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

why is this resolved? The bot is right, and the comment is lying.

…aceStatisticsHeader.tsx

Co-authored-by: graphite-app[bot] <96075541+graphite-app[bot]@users.noreply.github.com>
Signed-off-by: Kakuru Conrad Akankwasa <[email protected]>
Copilot AI review requested due to automatic review settings January 31, 2026 20:50
…aceStatisticsHeader.test.js

Co-authored-by: Copilot <[email protected]>
Signed-off-by: Kakuru Conrad Akankwasa <[email protected]>
Copy link

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 3 comments.


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

…ServiceName computation with useMemo

Signed-off-by: ConradKash <[email protected]>
@ConradKash
Copy link
Author

@ConradKash please process the feedback accordingly, and sign the DCO. Read more in CONTRIBUTING.md.

Hey @jkowall, I have finished setting PR to the standard kindly review.

@yurishkuro yurishkuro changed the title Feature update trace statistics header Convert TraceStatisticsHeader to a functional component Feb 3, 2026
Copy link
Member

@yurishkuro yurishkuro left a comment

Choose a reason for hiding this comment

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

please address comments. Minimize the diff by avoiding unnecessary code moves.


}, []);

const setValueNameSelector1 = useCallback(
Copy link
Member

Choose a reason for hiding this comment

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

setValueNameSelector1 was defined earlier in the code, why is it moved down? This increases the size of the diff, making it harder to review

* @param {string} valueNameSelector1 - The primary value selector name.
* @param {string | null} valueNameSelector2 - The optional secondary value selector name.
* @property {boolean} useOtelTerms - Flag to determine whether to use OpenTelemetry terminology in the UI.
*/
Copy link
Member

Choose a reason for hiding this comment

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

documentation is useful but need to be inline, not as a separate block that will get out of sync with the actual definition

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 TraceStatisticsHeader to Functional Component

3 participants