Skip to content

feat(databases): Import Data modal — samples, CSV/JSON files, and URL loads#1412

Open
dawsontoth wants to merge 3 commits into
stagefrom
feat/easy-data-import-1292
Open

feat(databases): Import Data modal — samples, CSV/JSON files, and URL loads#1412
dawsontoth wants to merge 3 commits into
stagefrom
feat/easy-data-import-1292

Conversation

@dawsontoth

@dawsontoth dawsontoth commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Closes #1292.

What

Replaces the bare-bones Import CSV modal with an Import Data flow modeled on the issue's mockups, with three methods:

Method Backend operation
Sample Datasets — three bundled starter datasets (Dogs, Books, Animals), plus Random Data generation for the selected table csv_data_load / insert
Import from File — CSV or JSON upload (was CSV-only) csv_data_load / insert
Load from URL — CSV fetched by the instance csv_url_load

UX details

  • Front and center: a second entry point in the Databases sidebar (next to "Create a Table"), so import is available even on an empty database — the key onboarding moment the issue is about. The table-toolbar button ("Import CSV" → "Import Data") opens the same modal prefilled with the current table and defaults to the file method; the sidebar defaults to samples.
  • Random Data: when the target table already exists and has columns beyond the primary key/system timestamps, the dataset picker offers a "Random Data" option (with a 1–1000 row-count input). Values are driven by each column's declared type, with column-name heuristics (email, name, age, price, boolean-ish, dates, …) for schemaless tables; the primary key is omitted so Harper assigns it.
  • Tables are created automatically (primary key id) when the target doesn't exist, with an inline heads-up alert. Picking a sample dataset auto-fills its suggested table name.
  • Job tracking: CSV loads return a job_id that the old modal ignored ("Please wait a few moments then refresh the table"). The new flow polls get_job until the job completes, then refreshes the table tree and navigates to the imported table — data is just there when the modal closes. Job errors (e.g. malformed CSV) surface as real error toasts.
  • Sample datasets are bundled into the app via ?raw imports (~6 KB total), so they work on self-hosted/air-gapped instances that can't fetch external URLs.

Scope notes

The mockup's Connect to Database (mongodump, .zip, live sync) has no supporting operations in Harper today, so it's intentionally left out rather than shipped as a dead-end UI; the method picker makes it easy to add once the backend exists. import_from_s3 is also a candidate for a follow-up method.

Testing

  • New unit tests: get_job polling (waitForJob), JSON upload parsing, random-record generation (types, heuristics, skipped columns), and sample-dataset CSV validity (format, unique ids, consistent columns). Full suite green; tsc, oxlint, dprint clean.
  • Verified end-to-end against a stage test cluster: the Dogs sample import created data.dog and loaded 15 records (create_tablecsv_data_loadget_job polling → auto-navigate), and Random Data then inserted 7 generated rows into that table with sensible per-column values. Also exercised both entry points, method switching, dataset auto-fill, and the new-table alert.

🤖 Generated with Claude Code

… loads

Replaces the bare-bones Import CSV modal with an Import Data flow (#1292):

- Sample Datasets: three bundled starter datasets (dogs, books, animals)
  loaded via csv_data_load, so they work on air-gapped instances too
- Import from File: CSV via csv_data_load, JSON via insert
- Load from URL: csv_url_load fetched by the instance
- Missing tables are created automatically (primary key id) before loading
- CSV loads now poll get_job until the job finishes instead of telling the
  user to wait and refresh
- Second entry point in the Databases sidebar so import is available before
  any table exists

Connect-to-database / live sync from the issue mockup needs backend support
and is intentionally out of scope.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@dawsontoth dawsontoth requested a review from a team as a code owner July 2, 2026 20:56

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request replaces the CSV-only import modal with a comprehensive ImportDataModal that supports importing data from local CSV/JSON files, remote URLs, and pre-loaded sample datasets. It also introduces utility functions for parsing JSON records, a job polling mechanism to track asynchronous imports, and corresponding unit tests. Feedback on these changes includes improving the resilience of the job polling loop against transient network errors, handling potential FileReader failures when uploading files, and adding an error handler to the import mutation to provide user feedback on failures.

Comment thread src/integrations/api/instance/database/getJob.ts
Comment thread src/features/instance/databases/modals/ImportDataModal.tsx
Comment thread src/features/instance/databases/modals/ImportDataModal.tsx
dawsontoth and others added 2 commits July 2, 2026 17:05
When the import target already exists and has columns beyond the primary key
and system timestamps, the Sample Datasets picker gains a 'Random Data' option
(under a 'This table' group) with a row-count input (1-1000, default 25).
Values come from the column's declared type when the table has one, falling
back to column-name heuristics (email, name, age, price, boolean-ish, dates,
...) for schemaless tables. The primary key is omitted so Harper assigns it.

Verified end-to-end against a stage test cluster: Dogs sample import created
data.dog and loaded 15 rows (csv_data_load + get_job polling), then Random
Data inserted 7 heuristic rows into it.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Review feedback: waitForJob now tolerates transient get_job failures (up to 5
consecutive) instead of failing an import whose job is still running, and the
file dropzone reports FileReader errors via a toast.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.

Make data ingestion super easy in the UI

1 participant