From 82ee025cd3208cbf5fe2b685a6311e4286186fcc Mon Sep 17 00:00:00 2001 From: Gregory Schier Date: Tue, 8 Sep 2026 08:27:17 -0700 Subject: [PATCH] refactor(import): call a turned-down resource ignored "Not imported" was two words in a column of one-word states, and it read as a description of this run rather than the standing decision it is. Co-Authored-By: Claude Opus 5 --- .../components/ImportDataDialog.tsx | 26 ++++++------- .../yaak-cli/src/commands/import_export.rs | 6 +-- .../yaak-cli/tests/import_export_commands.rs | 2 +- .../yaak-rpc-schema/bindings/gen_util.ts | 4 +- crates/yaak-models/bindings/gen_util.ts | 4 +- crates/yaak-models/src/util.rs | 4 +- crates/yaak/src/import.rs | 38 +++++++++---------- 7 files changed, 42 insertions(+), 42 deletions(-) diff --git a/apps/yaak-client/components/ImportDataDialog.tsx b/apps/yaak-client/components/ImportDataDialog.tsx index 0d9264b9..456ea07b 100644 --- a/apps/yaak-client/components/ImportDataDialog.tsx +++ b/apps/yaak-client/components/ImportDataDialog.tsx @@ -272,7 +272,7 @@ function LoadedImportDataDialog({ if (checked) { const byId = new Map(items.map((i) => [i.modelId, i])); for (const ancestor of ancestorsOf(node.data, byId)) { - if (ancestor.action === "not_imported") targets.add(ancestor.modelId); + if (ancestor.action === "ignored") targets.add(ancestor.modelId); } } setItems((prev) => prev.map((i) => (targets.has(i.modelId) ? { ...i, selected: checked } : i))); @@ -293,9 +293,9 @@ function LoadedImportDataDialog({ for (const parent of ancestorsOf(item, byId)) { if (parent.model !== "folder") break; const missing = - (parent.action === "create" || parent.action === "not_imported") && !parent.selected; - // A not-imported row stays checkable: checking it brings its folders back with it - if (missing && item.action !== "delete" && item.action !== "not_imported") { + (parent.action === "create" || parent.action === "ignored") && !parent.selected; + // An ignored row stays checkable: checking it brings its folders back with it + if (missing && item.action !== "delete" && item.action !== "ignored") { disabled.add(item.modelId); } if (parent.action === "delete" && parent.selected && item.action === "delete") { @@ -364,7 +364,7 @@ function LoadedImportDataDialog({ checked={nodeCheckedStatus} onCheck={toggleNode} isCheckboxDisabled={(n) => disabledIds.has(n.key)} - isCollapsedByDefault={(n) => n.data.action === "not_imported"} + isCollapsedByDefault={(n) => n.data.action === "ignored"} isRelevant={(n) => n.data.model === "workspace" || n.data.action !== "unchanged"} renderRow={(n) => } /> @@ -597,7 +597,7 @@ function ImportTreeRow({ item.action === "update" && "text-info", item.action === "delete" && "text-danger", item.action === "keep_local" && item.selected && "text-warning", - item.action === "not_imported" && "text-text-subtlest", + item.action === "ignored" && "text-text-subtlest", )} > {actionLabel(item)} @@ -619,8 +619,8 @@ function actionLabel(item: ImportPlanItem): string | null { return "removed"; case "keep_local": return "edited"; - case "not_imported": - return "not imported"; + case "ignored": + return "ignored"; default: return null; } @@ -637,15 +637,15 @@ function actionHelp(item: ImportPlanItem): string | null { case "update": return help("Changed since the last import"); case "delete": - return item.reason === "moved_into_not_imported_folder" - ? "Moved into a folder that isn't imported. Import that folder instead to follow the move" + return item.reason === "moved_into_ignored_folder" + ? "Moved into an ignored folder. Import that folder instead to follow the move" : "Deleted since the last import"; case "keep_local": return help("Local edits made since the last import. Importing will revert them if checked"); case "conflict": return help("Changed both here and in the file since the last import"); - case "not_imported": - return "In the file, but not imported. Check it to import it"; + case "ignored": + return "In the file, but ignored. Check it to import it"; default: return null; } @@ -717,7 +717,7 @@ function togglesWith(root: ImportPlanItem, item: ImportPlanItem): boolean { if (item.action === "keep_local") { return root.modelId === item.modelId && item.model !== "folder"; } - return item.action === "create" || item.action === "update" || item.action === "not_imported"; + return item.action === "create" || item.action === "update" || item.action === "ignored"; } function nodeCheckedStatus( diff --git a/crates-cli/yaak-cli/src/commands/import_export.rs b/crates-cli/yaak-cli/src/commands/import_export.rs index bc2728ef..e2b9e935 100644 --- a/crates-cli/yaak-cli/src/commands/import_export.rs +++ b/crates-cli/yaak-cli/src/commands/import_export.rs @@ -113,9 +113,9 @@ fn format_skipped(items: &[ImportPlanItem]) -> Option { if keep_local > 0 { parts.push(format!("{keep_local} with local edits")); } - let not_imported = count(ImportPlanAction::NotImported); - if not_imported > 0 { - parts.push(format!("{not_imported} previously not imported")); + let ignored = count(ImportPlanAction::Ignored); + if ignored > 0 { + parts.push(format!("{ignored} ignored")); } let unchanged = count(ImportPlanAction::Unchanged); if unchanged > 0 { diff --git a/crates-cli/yaak-cli/tests/import_export_commands.rs b/crates-cli/yaak-cli/tests/import_export_commands.rs index f77c5c17..f05e5561 100644 --- a/crates-cli/yaak-cli/tests/import_export_commands.rs +++ b/crates-cli/yaak-cli/tests/import_export_commands.rs @@ -307,7 +307,7 @@ fn re_import_leaves_deleted_resources_alone() { ]) .assert() .success() - .stdout(contains("Skipped 1 previously not imported")); + .stdout(contains("Skipped 1 ignored")); let query_manager = query_manager(data_dir); let requests = diff --git a/crates/common/yaak-rpc-schema/bindings/gen_util.ts b/crates/common/yaak-rpc-schema/bindings/gen_util.ts index 7fd672a5..f706cb08 100644 --- a/crates/common/yaak-rpc-schema/bindings/gen_util.ts +++ b/crates/common/yaak-rpc-schema/bindings/gen_util.ts @@ -63,7 +63,7 @@ export type ImportPlanAction = | "unchanged" | "keep_local" | "conflict" - | "not_imported"; + | "ignored"; export type ImportPlanItem = { action: ImportPlanAction; @@ -86,7 +86,7 @@ export type ImportPlanItem = { /** * Extra context for an action that would otherwise be indistinguishable from its plain form. */ -export type ImportPlanReason = "moved_into_not_imported_folder"; +export type ImportPlanReason = "moved_into_ignored_folder"; export type ImportPlanWarning = { title: string; detail: string }; diff --git a/crates/yaak-models/bindings/gen_util.ts b/crates/yaak-models/bindings/gen_util.ts index 7fd672a5..f706cb08 100644 --- a/crates/yaak-models/bindings/gen_util.ts +++ b/crates/yaak-models/bindings/gen_util.ts @@ -63,7 +63,7 @@ export type ImportPlanAction = | "unchanged" | "keep_local" | "conflict" - | "not_imported"; + | "ignored"; export type ImportPlanItem = { action: ImportPlanAction; @@ -86,7 +86,7 @@ export type ImportPlanItem = { /** * Extra context for an action that would otherwise be indistinguishable from its plain form. */ -export type ImportPlanReason = "moved_into_not_imported_folder"; +export type ImportPlanReason = "moved_into_ignored_folder"; export type ImportPlanWarning = { title: string; detail: string }; diff --git a/crates/yaak-models/src/util.rs b/crates/yaak-models/src/util.rs index 7e1c5d67..deb89485 100644 --- a/crates/yaak-models/src/util.rs +++ b/crates/yaak-models/src/util.rs @@ -170,7 +170,7 @@ pub enum ImportPlanAction { KeepLocal, Conflict, /// Present in the source but previously turned down; selecting it imports it again - NotImported, + Ignored, } /// Extra context for an action that would otherwise be indistinguishable from its plain form. @@ -178,7 +178,7 @@ pub enum ImportPlanAction { #[serde(rename_all = "snake_case")] #[ts(export, export_to = "gen_util.ts")] pub enum ImportPlanReason { - MovedIntoNotImportedFolder, + MovedIntoIgnoredFolder, } #[derive(Debug, Clone, Copy, PartialEq, Eq, Deserialize, Serialize, TS)] diff --git a/crates/yaak/src/import.rs b/crates/yaak/src/import.rs index b021c0b7..29df03d5 100644 --- a/crates/yaak/src/import.rs +++ b/crates/yaak/src/import.rs @@ -311,7 +311,7 @@ fn commit_plan_in_tx(db: &ClientDb, plan: ImportPlan) -> Result item.selected, + | ImportPlanAction::Ignored => item.selected, ImportPlanAction::Conflict => { item.resolution == Some(ImportConflictResolution::TakeSource) } @@ -323,7 +323,7 @@ fn commit_plan_in_tx(db: &ClientDb, plan: ImportPlan) -> Result = plan @@ -526,7 +526,7 @@ fn record_import_source( | ImportPlanAction::Conflict, ) => Some((Some(model_id.to_string()), Some(content_hash(incoming()?)))), // Turned down, so remember it as not wanted rather than offering it again - Some(ImportPlanAction::Create | ImportPlanAction::NotImported) => Some((None, None)), + Some(ImportPlanAction::Create | ImportPlanAction::Ignored) => Some((None, None)), Some(ImportPlanAction::Delete) if item.is_some_and(|i| i.selected) => { Some((None, None)) } @@ -798,7 +798,7 @@ fn merge_with_linked_source( } }; - let not_imported_folders = plan + let ignored_folders = plan .resources .folders .iter() @@ -811,14 +811,14 @@ fn merge_with_linked_source( .iter() .map(|v| (v.id.as_str(), v.folder_id.as_deref())) .collect::>(); - let inside_a_not_imported_folder = |parent_id: Option<&str>| { + let inside_an_ignored_folder = |parent_id: Option<&str>| { let mut seen = BTreeSet::new(); let mut next = parent_id; while let Some(id) = next { if !seen.insert(id) { break; } - if not_imported_folders.contains(id) { + if ignored_folders.contains(id) { return true; } next = folder_parents.get(id).copied().flatten(); @@ -847,14 +847,14 @@ fn merge_with_linked_source( // Nothing can be created inside a folder that isn't imported, so it starts unchecked // and comes along only if the folder does. - let reachable = !inside_a_not_imported_folder(parent_id.as_deref()); + let reachable = !inside_an_ignored_folder(parent_id.as_deref()); let row = match status(&planned_id, resource) { KeyStatus::New => { items.push(item(ImportPlanAction::Create, reachable, None, None)); return Ok(()); } KeyStatus::NotWanted => { - items.push(item(ImportPlanAction::NotImported, false, None, None)); + items.push(item(ImportPlanAction::Ignored, false, None, None)); return Ok(()); } KeyStatus::Wanted(row) => row, @@ -866,7 +866,7 @@ fn merge_with_linked_source( ImportPlanAction::Delete, false, None, - Some(ImportPlanReason::MovedIntoNotImportedFolder), + Some(ImportPlanReason::MovedIntoIgnoredFolder), )); return Ok(()); } @@ -1158,7 +1158,7 @@ fn validate_plan(plan: &ImportPlan) -> Result<()> { i.model_id == id && !matches!( i.action, - ImportPlanAction::Create | ImportPlanAction::NotImported + ImportPlanAction::Create | ImportPlanAction::Ignored ) }) }; @@ -2334,7 +2334,7 @@ mod tests { let plan = replan(&query_manager, &workspace_id, imported_resources()); let root = item_by_name(&plan, "Root Request"); - assert_eq!(root.action, ImportPlanAction::NotImported, "deleting it means not wanting it"); + assert_eq!(root.action, ImportPlanAction::Ignored, "deleting it means not wanting it"); assert!(!root.selected); assert_ne!(root.model_id, root_id); @@ -2346,7 +2346,7 @@ mod tests { ); let plan = replan(&query_manager, &workspace_id, imported_resources()); - assert_eq!(item_by_name(&plan, "Root Request").action, ImportPlanAction::NotImported); + assert_eq!(item_by_name(&plan, "Root Request").action, ImportPlanAction::Ignored); } #[test] @@ -2371,12 +2371,12 @@ mod tests { let plan = replan(&query_manager, &workspace_id, resources); let extra = item_by_name(&plan, "Extra Request"); - assert_eq!(extra.action, ImportPlanAction::NotImported, "deselecting it is remembered"); + assert_eq!(extra.action, ImportPlanAction::Ignored, "deselecting it is remembered"); assert!(!extra.selected); } #[test] - fn restoring_a_not_imported_item_relinks_its_source_key() { + fn restoring_an_ignored_item_relinks_its_source_key() { let (query_manager, _blob_manager, _rx) = yaak_models::init_in_memory().expect("initialize database"); let committed = first_import(&query_manager); @@ -2390,7 +2390,7 @@ mod tests { commit_import_plan(&query_manager, plan).expect("commit with deselected create"); let mut plan = replan(&query_manager, &workspace_id, resources.clone()); - assert_eq!(item_by_name(&plan, "Extra Request").action, ImportPlanAction::NotImported); + assert_eq!(item_by_name(&plan, "Extra Request").action, ImportPlanAction::Ignored); select(&mut plan, "Extra Request", true); commit_import_plan(&query_manager, plan).expect("commit with restored item"); @@ -2410,7 +2410,7 @@ mod tests { } #[test] - fn moving_into_a_not_imported_folder_offers_a_delete() { + fn moving_into_an_ignored_folder_offers_a_delete() { let (query_manager, _blob_manager, _rx) = yaak_models::init_in_memory().expect("initialize database"); let committed = first_import(&query_manager); @@ -2437,11 +2437,11 @@ mod tests { // The source moves an imported request into the folder that was turned down. let plan = replan(&query_manager, &workspace_id, with_extra_folder(true)); - assert_eq!(item_by_name(&plan, "Extra Folder").action, ImportPlanAction::NotImported); + assert_eq!(item_by_name(&plan, "Extra Folder").action, ImportPlanAction::Ignored); let root = item_by_name(&plan, "Root Request"); assert_eq!(root.action, ImportPlanAction::Delete); assert!(!root.selected, "a deletion is never applied by default"); - assert_eq!(root.reason, Some(ImportPlanReason::MovedIntoNotImportedFolder)); + assert_eq!(root.reason, Some(ImportPlanReason::MovedIntoIgnoredFolder)); // Anything new inside that folder can't be created either, so it waits for the folder. let mut resources = with_extra_folder(true); @@ -2466,7 +2466,7 @@ mod tests { let plan = replan(&query_manager, &workspace_id, with_extra_folder(true)); assert_eq!( item_by_name(&plan, "Root Request").action, - ImportPlanAction::NotImported, + ImportPlanAction::Ignored, "accepting the deletion means the resource is no longer wanted" ); }