Frontend API cleanup: Remove unused endpoints and dead code (via React Doctor)#491
Draft
Frontend API cleanup: Remove unused endpoints and dead code (via React Doctor)#491
Conversation
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>
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
After
Type of Change
Check all that apply like this [x]:
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 unusedFormRendererfunction.DashAI/front/src/components/ArrayInput.jsx: Improved state initialization using a function.DashAI/front/src/components/ResponsiveAppBar.jsx: Removed unnecessaryautoFocusprop.Testing (optional)
Notes (optional)