Skip to content

fix(studio): Use RHF for render performance#746

Open
steramae-nvidia wants to merge 5 commits into
mainfrom
steramae/dd-performance-pass
Open

fix(studio): Use RHF for render performance#746
steramae-nvidia wants to merge 5 commits into
mainfrom
steramae/dd-performance-pass

Conversation

@steramae-nvidia

@steramae-nvidia steramae-nvidia commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

This PR is a performance improvement for the DD build route by using React Hook Form for state management. By adopting this, we can cut down on unnecessary rerenders. It also helps with state access and form components.

Summary by CodeRabbit

  • New Features
    • Added a live visual canvas for viewing and interacting with data-generation workflows.
    • Configuration panels now update immediately as columns, models, filesets, sampling options, and generation settings are edited.
    • Added support for displaying empty workflow canvases and managing selections by item.
  • Bug Fixes
    • Preview errors are now clearly shown without sending an invalid preview request.
    • Dependent dataset fields are cleared when the selected fileset changes.
  • Tests
    • Added coverage for successful previews, preview logs, and configuration errors.

Signed-off-by: Sean Teramae <steramae@nvidia.com>
@steramae-nvidia
steramae-nvidia requested review from a team as code owners July 16, 2026 23:14
@github-actions github-actions Bot added the fix label Jul 16, 2026
Signed-off-by: Sean Teramae <steramae@nvidia.com>
@github-actions

github-actions Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor
Suite Lines Covered Line Rate Branch Rate
Unit Tests 25531/32732 78.0% 62.7%
Integration Tests 14730/31381 46.9% 19.3%

Signed-off-by: Sean Teramae <steramae@nvidia.com>
Signed-off-by: Sean Teramae <steramae@nvidia.com>
Signed-off-by: Sean Teramae <steramae@nvidia.com>
@coderabbitai

coderabbitai Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The data designer builder now uses shared react-hook-form state for columns, models, toolbar fields, configuration panels, graph rendering, validation, submission, and preview. Preview config errors are surfaced in logs, and controlled switches support value conversion hooks.

Changes

Data designer form state

Layer / File(s) Summary
Form state foundation
web/packages/studio/src/routes/DataDesignerJobBuildRoute/useJobBuilder.ts
Job builder values, selections, additions, removals, and auto-fill behavior now use react-hook-form state.
Route composition and builder surfaces
web/packages/studio/src/routes/DataDesignerJobBuildRoute/*
The route provides form context and connects toolbar, palette, configuration pane, canvas, validation, preview configuration, and submission to current form values.
Controlled configuration panels
web/packages/common/src/components/form/ControlledSwitch/index.tsx, web/packages/studio/src/components/ColumnConfigPanel/*, web/packages/studio/src/components/ModelConfigPanel/index.tsx
Column, seed-dataset, and model controls use controller paths, watched values, validation, dependent-field updates, and switch conversion callbacks.
Preview error handling and coverage
web/packages/studio/src/components/NewDataDesignerJobForm/usePreview.*
Preview configuration failures are logged without issuing a request, with tests covering failure and successful streaming paths.

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant DataDesignerJobBuildRoute
  participant FormProvider
  participant BuilderConfigPane
  participant BuilderCanvas
  User->>BuilderConfigPane: edit column or model
  BuilderConfigPane->>FormProvider: update controlled field
  FormProvider->>DataDesignerJobBuildRoute: provide current form values
  DataDesignerJobBuildRoute->>BuilderCanvas: pass form-backed columns
  BuilderCanvas->>BuilderCanvas: buildGraph(columns)
Loading

Possibly related PRs

Suggested reviewers: htolentino-nvidia, marcusds

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title matches the main change: adopting React Hook Form in studio to improve render performance.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch steramae/dd-performance-pass

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
web/packages/studio/src/routes/DataDesignerJobBuildRoute/index.tsx (1)

135-154: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Do not swallow configuration-build failures.

buildDataDesignerConfig runs inside this try, but the catch assumes every error populated createJob.error. A build failure therefore opens an empty details panel. Build separately and surface that error, or narrow this catch to mutation failures.

Based on learnings, submit handlers must not silently swallow non-mutation build errors.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@web/packages/studio/src/routes/DataDesignerJobBuildRoute/index.tsx` around
lines 135 - 154, The submit flow should not route buildDataDesignerConfig
failures through the mutation-error catch. Move configuration construction
outside the try/catch, or otherwise narrow the catch to createJob.mutateAsync
failures, and surface any configuration-build error directly while preserving
the existing mutation failure handling and navigation behavior.

Source: Learnings

🧹 Nitpick comments (3)
web/packages/studio/src/components/NewDataDesignerJobForm/usePreview.test.tsx (2)

36-40: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Assert the original config-build error.

This regex also matches the fallback preview message, so the test would pass even if the thrown SyntaxError.message were discarded. Assert Unexpected token n in JSON at position 2 directly.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@web/packages/studio/src/components/NewDataDesignerJobForm/usePreview.test.tsx`
around lines 36 - 40, Strengthen the assertion in the previewLogs test for the
config-build error so it checks for the exact original SyntaxError message,
“Unexpected token n in JSON at position 2,” rather than the broad
JSON/error/preview regex. Keep the existing non-empty previewLogs assertion and
verify that the thrown error message is preserved and shown to the user.

46-49: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Replace the unchecked callback assertion with narrowing.

Use a type predicate in find instead of as ((l: string) => void) | undefined.

As per coding guidelines, TypeScript should prefer type guards and narrowing over type assertions.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@web/packages/studio/src/components/NewDataDesignerJobForm/usePreview.test.tsx`
around lines 46 - 49, Update the streamPreviewMock implementation to replace the
callback type assertion in the args.find call with an inline type predicate that
narrows the matching value to the expected line-handler function, preserving the
existing optional invocation of onLine.

Source: Coding guidelines

web/packages/studio/src/routes/DataDesignerJobBuildRoute/useJobBuilder.ts (1)

51-55: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Declare the hook's return type and remove the assertion.

Add a JobBuilderReturn interface, annotate useJobBuilder, and return form directly. The current assertion adds no safety.

As per coding guidelines, “Use explicit return types for public APIs and complex functions in TypeScript” and “Use type assertions sparingly.”

Also applies to: 181-183

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@web/packages/studio/src/routes/DataDesignerJobBuildRoute/useJobBuilder.ts`
around lines 51 - 55, Define a JobBuilderReturn interface for the hook’s
returned shape, annotate useJobBuilder with that explicit return type, and
remove the unnecessary type assertion from the returned form value. Update the
corresponding return statement while preserving the existing hook behavior and
API.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@web/packages/studio/src/components/ModelConfigPanel/index.tsx`:
- Around line 56-59: Update the alias set construction in the ModelConfigPanel
validation flow around validateModelAlias so every peer alias is trimmed before
uniqueness checking. Preserve excluding modelIndex and filtering empty values,
and ensure validateModelAlias receives normalized alias values.

---

Outside diff comments:
In `@web/packages/studio/src/routes/DataDesignerJobBuildRoute/index.tsx`:
- Around line 135-154: The submit flow should not route buildDataDesignerConfig
failures through the mutation-error catch. Move configuration construction
outside the try/catch, or otherwise narrow the catch to createJob.mutateAsync
failures, and surface any configuration-build error directly while preserving
the existing mutation failure handling and navigation behavior.

---

Nitpick comments:
In
`@web/packages/studio/src/components/NewDataDesignerJobForm/usePreview.test.tsx`:
- Around line 36-40: Strengthen the assertion in the previewLogs test for the
config-build error so it checks for the exact original SyntaxError message,
“Unexpected token n in JSON at position 2,” rather than the broad
JSON/error/preview regex. Keep the existing non-empty previewLogs assertion and
verify that the thrown error message is preserved and shown to the user.
- Around line 46-49: Update the streamPreviewMock implementation to replace the
callback type assertion in the args.find call with an inline type predicate that
narrows the matching value to the expected line-handler function, preserving the
existing optional invocation of onLine.

In `@web/packages/studio/src/routes/DataDesignerJobBuildRoute/useJobBuilder.ts`:
- Around line 51-55: Define a JobBuilderReturn interface for the hook’s returned
shape, annotate useJobBuilder with that explicit return type, and remove the
unnecessary type assertion from the returned form value. Update the
corresponding return statement while preserving the existing hook behavior and
API.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: ddb76e80-f5eb-4648-8add-6551328d96ce

📥 Commits

Reviewing files that changed from the base of the PR and between 2412ab7 and f95471e.

📒 Files selected for processing (12)
  • web/packages/common/src/components/form/ControlledSwitch/index.tsx
  • web/packages/studio/src/components/ColumnConfigPanel/SeedDatasetConfig.tsx
  • web/packages/studio/src/components/ColumnConfigPanel/index.tsx
  • web/packages/studio/src/components/ModelConfigPanel/index.tsx
  • web/packages/studio/src/components/NewDataDesignerJobForm/usePreview.test.tsx
  • web/packages/studio/src/components/NewDataDesignerJobForm/usePreview.ts
  • web/packages/studio/src/routes/DataDesignerJobBuildRoute/BuilderCanvas.tsx
  • web/packages/studio/src/routes/DataDesignerJobBuildRoute/BuilderConfigPane.tsx
  • web/packages/studio/src/routes/DataDesignerJobBuildRoute/BuilderPalette.tsx
  • web/packages/studio/src/routes/DataDesignerJobBuildRoute/BuilderToolbar.tsx
  • web/packages/studio/src/routes/DataDesignerJobBuildRoute/index.tsx
  • web/packages/studio/src/routes/DataDesignerJobBuildRoute/useJobBuilder.ts

Comment thread web/packages/studio/src/components/ModelConfigPanel/index.tsx
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.

1 participant