Skip to content

feat: CSV batch import via context menu and file drop #201

@careck

Description

@careck

Summary

Import CSV files to batch-create child notes under a parent. Each CSV row becomes a child note with fields populated from column values. Uses a hybrid mapping approach: auto-mapping from schema field definitions by default, with optional register_csv_import Rhai hook for custom mapping logic.

This is the inverse of the text export views feature (#170) and extends the register_drop hook system (#200).

Design Spec

Full spec in the CSV Import section of docs/superpowers/specs/2026-05-13-register-drop-design.md

Entry Points

  • Context menu: Right-click a note → "Import CSV..." → file picker → preview → import
  • File drop / paste: Drop a .csv file on a tree node → routes to CSV import flow (not generic file drop)

Key Features

  • Hybrid mapping (Approach C): If the child schema has a register_csv_import handler, use it. Otherwise, auto-map CSV column headers to schema field names with type coercion.
  • Preview dialog: Shows row count, sample rows, mapped/ignored columns, warnings (coercion failures), and errors (missing required fields). Import is blocked when errors exist.
  • Type coercion: text as-is, number/rating parsed to f64, boolean from true/false/1/0, date from ISO 8601 + common formats, select validated against options list.
  • Schema selection: auto-selected if parent allows only one child schema, otherwise picker dialog.

Script API

register_csv_import("Book", "Book List", |parent, row| {
    let child = create_child(parent.id, "Book");
    set_title(child.id, row["title"]);
    set_field(child.id, "author", row["author"] ?? "Unknown");
    commit();
});

Scope

  • Core engine: register_csv_import hook registration and dispatch, auto-mapping engine with type coercion
  • Desktop crate: csv crate for parsing, two new Tauri commands (preview_csv_import, execute_csv_import)
  • Frontend: CsvImportPreviewDialog.tsx, context menu entry, CSV file drop routing, i18n keys

Dependencies

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions