Skip to content

Conversation

@johallar
Copy link
Contributor

@johallar johallar commented Oct 24, 2025

Description

This makes sure we're using createRoot instead of render which resolves a react console warning

Warning: ReactDOM.render is no longer supported in React 18. Use createRoot instead. Until you switch to the new API, your app will behave as if it's running React 17.

  • Ensure that each html page has only one root component. New "Page" components were created where necessary that handle layout/lazy loading

Motivation and Context

This gets the app closer to a FE router, instead of separate html pages, saving us a bunch of round trips for deps/styles included inline.

Should also boost FE performance by allowing react to do render optimizations (eg. not completely re-render the title tabs on each nav)

Impact

This sets the FE up for performance gains in the future, nothing should change for the end user ATM

Test Plan

Contributor checklist

  • Please make sure your submission complies with our contributing guide, in particular code style and commit standards.
  • PR description addresses the issue accurately and concisely. If the change is non-trivial, a GitHub Issue is referenced.
  • Documented new properties (with its default value), SQL syntax, functions, or other functionality.
  • If release notes are required, they follow the release notes guidelines.
  • Adequate tests were added if applicable.
  • CI passed.
  • If adding new dependencies, verified they have an OpenSSF Scorecard score of 5.0 or higher (or obtained explicit TSC approval for lower scores).

Release Notes

Please follow release notes guidelines and fill in the release notes below.

== NO RELEASE NOTE ==

@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Oct 24, 2025

Reviewer's Guide

This PR refactors all UI entry points to use React 18’s createRoot API instead of ReactDOM.render, consolidates multiple mount points into single-root page components, introduces new high-level components (ClusterOverview, Worker, Stage, Plan, Query) handling layout and lazy loading (including PageTitle), updates HTML templates to match the single-root structure, and disables PropTypes lint warnings.

Class diagram for new high-level page components

classDiagram
    class ClusterOverview {
        +PageTitle
        +ClusterHUD (lazy)
        +QueryList (lazy)
    }
    class Worker {
        +PageTitle
        +WorkerStatus (lazy)
        +WorkerThreadList (lazy)
    }
    class Stage {
        +PageTitle
        +StageDetail (lazy)
    }
    class Plan {
        +PageTitle
        +LivePlan (lazy)
        +getFirstParameter()
    }
    class Query {
        +PageTitle
        +QueryDetail (lazy)
    }
    ClusterOverview --> PageTitle
    ClusterOverview --> ClusterHUD
    ClusterOverview --> QueryList
    Worker --> PageTitle
    Worker --> WorkerStatus
    Worker --> WorkerThreadList
    Stage --> PageTitle
    Stage --> StageDetail
    Plan --> PageTitle
    Plan --> LivePlan
    Plan --> getFirstParameter
    Query --> PageTitle
    Query --> QueryDetail
Loading

Flow diagram for React root mounting refactor

flowchart TD
    A["HTML page with multiple mount points"] -->|Old: ReactDOM.render to #title, #cluster-hud, #query-list, etc.| B["Multiple React components mounted separately"]
    B --> C["Fragmented page layout"]
    D["HTML page with single #app-root"] -->|New: ReactDOM.createRoot to #app-root| E["Single high-level page component (e.g., ClusterOverview)"]
    E --> F["Unified layout and lazy loading"]
Loading

File-Level Changes

Change Details Files
Migrate entry points to React 18 root API
  • Update imports to use react-dom/client
  • Replace ReactDOM.render/createRoot usage with ReactDOM.createRoot(...).render(...)
  • Consolidate multiple mounts into a single root per page
src/index.jsx
src/sql_client.jsx
src/plan.jsx
src/res_groups.jsx
src/query.jsx
src/stage.jsx
src/timeline.jsx
src/embedded_plan.jsx
src/worker.jsx
src/static/index.html
src/static/query.html
src/static/worker.html
src/static/res_groups.html
src/static/plan.html
src/static/stage.html
src/static/timeline.html
src/static/sql_client.html
Introduce unified Page components
  • Create ClusterOverview, Worker, Stage, Plan, Query components
  • Encapsulate PageTitle and lazy-loaded children in each component
  • Update entry files to render these new page components
src/components/ClusterOverview.jsx
src/components/Worker.jsx
src/components/Stage.jsx
src/components/Plan.jsx
src/components/Query.jsx
Embed PageTitle into existing views
  • Insert PageTitle at the top of ResourceGroupView
  • Insert PageTitle in SQLClient component
  • Insert PageTitle in Splits component
src/components/ResourceGroupView.jsx
src/components/SQLClient.tsx
src/components/Splits.tsx
Adjust ESLint config
  • Disable react/prop-types rule
src/eslint.config.mjs

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@johallar johallar marked this pull request as ready for review November 18, 2025 22:09
@johallar johallar requested review from a team and yhwang as code owners November 18, 2025 22:09
Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey there - I've reviewed your changes - here's some feedback:

  • It looks like the worker entrypoint (src/worker.jsx) wasn’t updated to use ReactDOM.createRoot and mount the new Worker component into the renamed worker-root container.
  • The PR mixes two patterns for createRoot imports (sometimes importing createRoot directly, sometimes using ReactDOM.createRoot) – consider standardizing on one for consistency.
  • PageTitle usage is duplicated in almost every new page component – you might extract a Layout or wrapper HOC to DRY up passing the same titles/urls/current props.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- It looks like the worker entrypoint (src/worker.jsx) wasn’t updated to use ReactDOM.createRoot and mount the new Worker component into the renamed `worker-root` container.
- The PR mixes two patterns for createRoot imports (sometimes importing createRoot directly, sometimes using ReactDOM.createRoot) – consider standardizing on one for consistency.
- PageTitle usage is duplicated in almost every new page component – you might extract a Layout or wrapper HOC to DRY up passing the same titles/urls/current props.

## Individual Comments

### Comment 1
<location> `presto-ui/src/components/Worker.jsx:10-17` </location>
<code_context>
+export const Worker = () => {
+    return (
+        <>
+            <div id="title">
+                <PageTitle titles={["Worker Status"]} />
+            </div>
+
+            <div id="worker-status">
+                <WorkerStatus />
+            </div>
+            <div id="worker-threads">
+                <WorkerThreadList />
+            </div>
</code_context>

<issue_to_address>
**issue:** Multiple root-level elements with IDs may cause issues with React hydration.

Consider wrapping these elements in a single root container to prevent hydration issues and avoid duplicating IDs in the static HTML.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment on lines +10 to +17
<div id="title">
<PageTitle titles={["Worker Status"]} />
</div>

<div id="worker-status">
<WorkerStatus />
</div>
<div id="worker-threads">
Copy link
Contributor

Choose a reason for hiding this comment

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

issue: Multiple root-level elements with IDs may cause issues with React hydration.

Consider wrapping these elements in a single root container to prevent hydration issues and avoid duplicating IDs in the static HTML.

@yhwang
Copy link
Member

yhwang commented Nov 21, 2025

Hi @johallar again, thank you for the great effort of refactoring. I reviewed, checked out, ran the server with your changes, and verified all of the pages. I believe all changes are good. However, I need your help to also update the presto-ui/src/router/index.jsx. That's the router's index page, and it's also using the index.html. Since you updated the index.html, the router's index.jsx would need the update as well.

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