Skip to content

improvement(tables): clean up duplicate types, unnecessary memos, and barrel imports#4205

Merged
waleedlatif1 merged 2 commits intostagingfrom
waleedlatif1/fix-csv-import-types
Apr 16, 2026
Merged

improvement(tables): clean up duplicate types, unnecessary memos, and barrel imports#4205
waleedlatif1 merged 2 commits intostagingfrom
waleedlatif1/fix-csv-import-types

Conversation

@waleedlatif1
Copy link
Copy Markdown
Collaborator

Summary

  • Remove duplicate CsvHeaderMapping type from hooks/queries/tables.ts, import from canonical @/lib/table source
  • Replace sub-module imports (@/lib/table/csv-import, @/lib/table/constants, @/lib/table/types) with barrel @/lib/table
  • Remove unnecessary useMemo for trivial arithmetic (appendCapacityDeficit, replaceCapacityDeficit) in import-csv-dialog
  • Move static array maps (comparisonOptions, logicalOptions, sortDirectionOptions) from useMemo to module-level constants in use-query-builder.ts
  • Call importMutation.mutateAsync directly instead of extracting to intermediate variable (stable in TanStack Query v5)

Type of Change

  • Code quality improvement (no behavior change)

Testing

Verified TypeScript compilation passes with zero errors. All changes are semantically identical — no behavior change.

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel
Copy link
Copy Markdown

vercel bot commented Apr 16, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Apr 16, 2026 11:40pm

Request Review

@cursor
Copy link
Copy Markdown

cursor bot commented Apr 16, 2026

PR Summary

Low Risk
Refactor-only changes (imports and memoization) with no intended behavior changes, but small risk of stale barrel exports or hook dependency issues affecting build/runtime.

Overview
Cleans up table-related imports by routing CSV import utilities, constants, and table types through the @/lib/table barrel (including copilot’s user-table tool and the CSV import dialog).

Removes duplicated CsvHeaderMapping from hooks/queries/tables.ts, and simplifies a few React patterns: replaces trivial useMemo computations with direct expressions in ImportCsvDialog, calls importMutation.mutateAsync directly, and hoists query-builder option arrays from useMemo to module-level constants.

Reviewed by Cursor Bugbot for commit b023d45. Configure here.

Comment thread apps/sim/app/workspace/[workspaceId]/home/home.tsx Outdated
Comment thread apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/panel.tsx Outdated
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Apr 16, 2026

Greptile Summary

This PR is a code quality cleanup across four tables-related files: it removes a duplicate CsvHeaderMapping type definition, consolidates sub-module @/lib/table/* imports into the barrel, drops two unnecessary useMemo wrappers around trivial arithmetic, promotes three static option arrays to module-level constants, and calls importMutation.mutateAsync directly rather than through an intermediate variable. All changes are semantically equivalent with no behaviour difference.

Confidence Score: 5/5

Safe to merge — all changes are semantically identical refactors with no behaviour change.

The only finding is a P2 style inconsistency: one @/lib/table/types sub-module import was missed in user-table.ts despite being listed in the PR description as a target. All other changes are correct and beneficial.

apps/sim/lib/copilot/tools/server/table/user-table.ts — one remaining sub-path import at line 44.

Important Files Changed

Filename Overview
apps/sim/app/workspace/[workspaceId]/tables/components/import-csv-dialog/import-csv-dialog.tsx Removes useMemo wrappers for trivial arithmetic (appendCapacityDeficit, replaceCapacityDeficit) and calls importMutation.mutateAsync directly — both correct for TanStack Query v5.
apps/sim/hooks/queries/tables.ts Removes locally-duplicated CsvHeaderMapping type in favour of importing from the @/lib/table barrel; no functional change.
apps/sim/lib/copilot/tools/server/table/user-table.ts Consolidates most @/lib/table sub-module imports into the barrel; one sub-path import (@/lib/table/types) remains at line 44, inconsistent with the PR's stated goal.
apps/sim/lib/table/query-builder/use-query-builder.ts Promotes three static option arrays (comparisonOptions, logicalOptions, sortDirectionOptions) from per-render useMemo to module-level constants; correct since the source arrays are static.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[import-csv-dialog.tsx] -->|CsvImportMode, useImportCsvIntoTable| B[hooks/queries/tables.ts]
    A -->|TableDefinition, parseCsvBuffer| C[lib/table barrel]
    B -->|CsvHeaderMapping, Filter, RowData| C
    D[user-table.ts] -->|buildAutoMapping, CsvHeaderMapping, etc| C
    D -->|RowData, TableDefinition - subpath still used| E[lib/table/types]
    F[use-query-builder.ts] -->|reads constants| G[query-builder/constants]
    F -->|module-level arrays| H[comparisonOptions / logicalOptions / sortDirectionOptions]
    C --> E
Loading

Reviews (2): Last reviewed commit: "improvement(tables): clean up duplicate ..." | Re-trigger Greptile

@waleedlatif1 waleedlatif1 force-pushed the waleedlatif1/fix-csv-import-types branch from a23bbbe to b023d45 Compare April 16, 2026 23:05
@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@cursor review

Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit b023d45. Configure here.

@waleedlatif1 waleedlatif1 merged commit c06361b into staging Apr 16, 2026
13 checks passed
@waleedlatif1 waleedlatif1 deleted the waleedlatif1/fix-csv-import-types branch April 16, 2026 23:47
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.

1 participant