Skip to content

Frontend API cleanup: Remove unused endpoints and dead code (via React Doctor)#491

Draft
Irozuku wants to merge 35 commits intodevelopfrom
fix/react-doctor-fixes
Draft

Frontend API cleanup: Remove unused endpoints and dead code (via React Doctor)#491
Irozuku wants to merge 35 commits intodevelopfrom
fix/react-doctor-fixes

Conversation

@Irozuku
Copy link
Collaborator

@Irozuku Irozuku commented Mar 19, 2026

Summary

This pull request cleans up the frontend codebase by removing unused and obsolete API functions, files, and related helpers. The goal is to reduce technical debt, simplify the API layer, and improve maintainability. The cleanup was assisted using React Doctor (https://github.com/millionco/react-doctor), which helped identify dead code and unused endpoints. No new features or bug fixes are introduced—this is purely a refactor and cleanup effort.

Before

image

After

image

Type of Change

Check all that apply like this [x]:

  • Backend change
  • Frontend change
  • CI / Workflow change
  • Build / Packaging change
  • Bug fix
  • Documentation

Changes (by file)

  • DashAI/front/src/api/oldEndpoints.ts: Deleted entire file (legacy unused endpoints).
  • DashAI/front/src/api/datasets.ts: Removed multiple unused dataset-related API functions.
  • DashAI/front/src/api/converter.ts: Removed unused converter-related API functions.
  • DashAI/front/src/api/exploration.ts: Deleted unused exploration endpoints (get/create/update).
  • DashAI/front/src/api/generativeTask.ts: Removed unused functions and related imports.
  • DashAI/front/src/api/dataloader.ts: Deleted entire file (unused API).
  • DashAI/front/src/api/task.ts: Deleted entire file (unused API).
  • DashAI/front/src/api/notebook.ts: Removed unused API functions.
  • DashAI/front/src/api/predict.ts: Removed unused API functions.
  • DashAI/front/src/api/values.ts: Deleted entire file (unused helper functions).
  • DashAI/front/src/components/configurableObject/FormRenderer.jsx: Removed unused FormRenderer function.
  • DashAI/front/src/components/ArrayInput.jsx: Improved state initialization using a function.
  • DashAI/front/src/components/ResponsiveAppBar.jsx: Removed unnecessary autoFocus prop.

Testing (optional)

  • Verify that no removed API functions are still referenced anywhere in the frontend.
  • Run the app and ensure all existing features (datasets, notebooks, predictions, etc.) work as expected.
  • Check for any missing imports or runtime errors after cleanup.

Notes (optional)

  • This PR focuses on long-term maintainability by eliminating dead code.
  • React Doctor was used to systematically detect unused code paths and endpoints.
  • Reduces bundle size and improves readability of the API layer.
  • Safe refactor assuming all removed functions were truly unused.

Irozuku and others added 30 commits March 19, 2026 15:27
Removed 72 of 74 flagged unused files. Two files were retained:
- i18next.config.js: CLI tool config for i18next-cli, not a React import
- src/setupTests.js: auto-loaded by react-scripts (CRA convention)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Remove exports confirmed unused via grep across the entire src/ tree:
- utils/i18n/index.js: remove default export (file kept for side-effect import)
- components/jobs/JobQueueWidget.jsx: remove exported StatusIcon and statusText
- api/converter.ts: remove getDatasetConverterList and getConvertersByNotebook
- api/datasets.ts: remove copyDataset, getDatasetSampleByFilePath, getModelSessionsExist, exportDatasetCsvById
- api/exploration.ts: remove getExplorationById, createExploration, updateExploration
- api/generativeTask.ts: remove getGenerativeTask and getGenerativeSessionParametersHistory
- api/notebook.ts: remove getNotebook
- api/predict.ts: remove downloadPredict and getPredictionSummary
- utils/jobPoller.js: unexport startJobPoller, stopJobPoller, cleanupJobPoller (kept as internal functions); remove unused getJobStatus import
- utils/parseRange.js: remove parseIndexToRange
- utils/typesLists.js: remove dataTypesList
- components/models/ModelsContext.jsx: remove OptionsEnum
- components/custom/contexts/DatasetsAndNotebooksContext.jsx: remove OptionsEnum
- components/notebooks/tool/toolCategories.js: unexport PREFERRED_ORDER (kept as module-level const used by sortCategories)
- hooks/useJobPolling.js: remove useJobTracker
- pages/results/constants/extractRows.jsx: remove replaceModelNameForRuns (referenced undefined getModels)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…rrors)

Fixes Rules of Hooks violations in 15 components where useState, useEffect,
useCallback, useRef, and other hooks were called after early return statements
or inside conditional branches. All hooks are now unconditionally called at
the top of each component, with early returns moved to after all hook calls.

For FormSchemaRenderFields, extracted SubField as a module-level component
to eliminate useMemo called inside a loop within a useCallback.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…10 files)

- InferenceMethodDialog: remove useEffect that reset selectedMethods from defaultSelected prop
- NumberInputOptimize: remove switchState + useEffect; use mergedOptimize directly
- IntegerInputOptimize: remove switchState + useEffect; use mergedOptimize directly
- ConfigureExplainerStep: replace setNextEnabled useEffect with combined handleSetError callback
- TrainNode: replace initialized useState + reset useEffect with initializedForModelRef
- InputWithDebounce: annotate value-sync useEffect as intentional debounce synchronization
- DebouncedColorPicker: annotate value-sync useEffect as intentional debounce synchronization
- ResultsByExplorer: file was deleted in Task 1 (skipped)
- ResultsGraphs: selectedMetrics reset is user-interactive state, not simple derivation (left as-is)
- GenerativeChat: messages reset on taskName is an intentional side effect (left as-is)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Move ExplainersTable, PluginsActions, CsvExportButton, CustomToolbar, and
MetricsSection from inside their parent components to module scope so they
are not re-created on every render. Convert all captured parent
state/variables to explicit props.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add stable key prop to TimestampWrapper element rendered inside the
getActions array in the actions column definition.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace inline `= []` prop defaults with module-level constants to avoid
creating new array references on every render, preventing unnecessary
re-renders in child components that use reference equality checks.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace setState(state +/- n) with setState(prev => prev +/- n) in
modal step navigation and modification counters.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Use item.id, item.name, or composite keys instead of array index for
React list keys to ensure stable reconciliation.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Wrap non-trivial useState initializers in arrow functions so they only
run once on mount rather than on every render.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Create LazyRecharts.jsx with React.lazy wrappers for top-level chart
containers (LineChart, BarChart, PieChart). Wrap chart JSX in Suspense
with a CircularProgress fallback in the 6 files that use recharts.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace sequential awaits with Promise.all in getHyperparameterPlot and
fetchComponents where all calls are independent of each other.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- TimestampWrapper: add role="button", tabIndex=0, and onKeyDown handler
  for keyboard accessibility on the clickable div
- JobQueueWidget: replace transition:"all" with specific CSS properties
  to avoid animating properties that shouldn't change
- SelectDatasetStep: fix stale closure in useEffect by using functional
  setState and adding setNewExp as a dependency

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…Chart

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…+ datasets)

- DatasetModal: move requestError recovery (setActiveStep + setNextEnabled)
  into handleSubmitNewDataset and handlePreviewDataset directly, removing
  the useEffect that reacted to requestError state

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… models)

- SelectDatasetStep: collapse 3 chained useEffects (row selection → set id →
  validate → update newExpl/nextEnabled) into a single async
  handleDatasetRowSelection handler; refactor validateDataset and getTotalRows
  to accept datasetId parameter instead of reading from stale state

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…explorations)

- ConverterTargetColumnModal: replace useEffect([open]) with handleOpen()
  that sets initial state and fetches columns before opening the dialog
- ConfigureAndUploadDatasetStep: consolidate two useEffects that reacted to
  previewError into a handlePreviewError callback passed to Upload child

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ficial

Refactored DatasetAutocomplete to use useReducer for the fetch-info
loading/error/data lifecycle (4+ setState calls in one effect replaced
with dispatched actions). All other flagged files were evaluated and
left unchanged — their multiple setStates either represent independent
concerns or are used individually by event handlers throughout the
component, making useReducer a net complexity increase with no benefit.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Reviewed all 23 autoFocus instances. Kept autoFocus on MUI Dialog buttons
and inputs (DeleteItemModal, NewExperimentModal, RetrainConfirmDialog,
PredictionCard, ExplanainersCard, DeleteConfirmationModal, DatasetModal,
ExplorationModal, NewLocalExplainerModal, NewGlobalExplainerModal,
PreviewDatasetTable inline edit field) where it improves keyboard UX.

Removed autoFocus from two non-modal contexts:
- SelectTypeCell: inline table Select cell (non-modal, causes unexpected focus)
- ResponsiveAppBar: app bar Menu (non-modal navigation menu)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ocument intent)

For 10 existing files with useState seeded from a prop, added explanatory
comments clarifying that the prop is an initial value only (not kept in sync),
or noting where sync is handled separately via a useEffect.

Files documented:
- InferenceMethodDialog: selectedMethods from defaultSelected
- OptimizationTableSelectOptimizer: selectedOptimizer from optimizerName
- ModelsTableSelectMetric: selectedMetric from metricName
- PredictionCreationDialog: predictionMode from defaultMode
- InputWithDebounce: inputValue from value (sync via useEffect already noted)
- GroupedCollapsibleList: openGroups from initialOpenGroups
- EditableColumnHeader: editValue from columnName (reset on each edit session)
- CollapsibleList: open from defaultOpen
- ExplorerDetailsModal: localData from data (diverges on user edits)
- Upload: file from initialFile

4 files were deleted in Phase 1 and skipped.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…(5 files)

Converted inline renderXxx() functions called as {renderXxx()} to named
components at module scope, called as JSX:

- NewPipeline.jsx: renderNodeDialogContent → NodeDialogContent component
  accepting selectedNode, nodeData, getConnectedNodeData, onClose, onSave
- NewExperimentModal.jsx + renderStep.js: renderStep() utility function
  replaced with StepContent named component (accepts stepName + shared props)
- ResultsExploration.jsx: renderVisualizer() → ExplorationVisualizer component
  accepting type and dataObj props, placed after getDataFromOrientation
- FormSchemaRenderFields.jsx: renderFields() useCallback → FieldList component
  at module scope accepting modelSchema, values, errors, handleChange, setError,
  errorsMessage
- ParamsSettings.jsx: renderFields() → ParamsFieldList component at module scope
  accepting modelSchema, localValues, onFieldChange

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…eneficial

- JobQueueWidget: replace confirmClearAll+clearingAll booleans with a
  clearAllReducer (idle→confirming→clearing→idle state machine)
- RunCard: consolidate 6 edit-state fields (isEditing, name, parameters,
  optimizer, optimizerParams, goalMetric) into editReducer with atomic
  CANCEL/SYNC_RUN resets

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Move the renderTypesAsChips render helper out of the component body and
into module scope to reduce component size and make the function
independently testable.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace index-based keys with stable item-derived keys in NodeSidebar
(paragraph content), ExplainersPlot (explainer.id + index), and
ColorscaleSelector (colorstop position + color value).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ants

Replace inline `= {}` default prop values with module-level constants
(EMPTY_GROUPS, EMPTY_OPEN_GROUPS, EMPTY_CARDINALITY, EMPTY_FORM_VALUES)
in GroupedCollapsibleList, ColumnSelector, and Upload to prevent
unnecessary re-renders from new object identity on each render.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Wrap the setSelectedColumn call in handleOpen with a functional updater
to avoid potential stale closure issues with the classColumnInitialValue
prop reference.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Irozuku and others added 5 commits March 19, 2026 19:40
…ants (4 files)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@Irozuku Irozuku added front Frontend work chore Quality enhancement of the code, infrastructure, CI/CD, etc... refactor Prune and embelish code labels Mar 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chore Quality enhancement of the code, infrastructure, CI/CD, etc... front Frontend work refactor Prune and embelish code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant