Refactor: split ImportWizard into pure ImportPipeline and UI wrapper

ImportPipeline holds all data and logic (raw JSON, records, proposals,
model_name, build_model). ImportWizard wraps it with UI-only state
(step, cursor, message). Rename WizardState → WizardStep throughout.
Headless import in dispatch.rs now constructs ImportPipeline directly.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Ed L
2026-03-21 23:28:27 -07:00
parent 413601517d
commit 197b66e4e1
5 changed files with 303 additions and 169 deletions

View File

@ -196,20 +196,17 @@ fn import_json_headless(
let proposals = analyze_records(&records);
// Auto-accept all and build
let wizard = crate::import::wizard::ImportWizard {
state: crate::import::wizard::WizardState::NameModel,
// Auto-accept all and build via ImportPipeline
let pipeline = crate::import::wizard::ImportPipeline {
raw: value,
array_paths: vec![],
selected_path: array_path.unwrap_or("").to_string(),
records,
proposals: proposals.into_iter().map(|mut p| { p.accepted = p.kind != FieldKind::Label; p }).collect(),
model_name: model_name.unwrap_or("Imported Model").to_string(),
cursor: 0,
message: None,
};
match wizard.build_model() {
match pipeline.build_model() {
Ok(new_model) => {
*model = new_model;
CommandResult::ok_msg("JSON imported successfully")