From 30848828296cb0eba29dfc6319b3aa9a6bb7e098 Mon Sep 17 00:00:00 2001 From: Gregory Schier Date: Thu, 10 Sep 2026 09:31:50 -0700 Subject: [PATCH] fix(import): say where a document was already imported, and to what MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit "Already imported" left the reader to guess what had been compared — names, paths, contents — when the answer is the source keys, the same overlap that decides whether a re-import merges. The title now names the workspace holding it and the detail says what importing here would do. The destination row also stopped wedging the kind and the name into one value: the row's label carries the kind, so the value is just the name. Co-Authored-By: Claude Opus 5 --- .../components/ImportDataDialog.tsx | 20 +++++++++++-------- crates/yaak/src/import.rs | 13 +++++++----- 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/apps/yaak-client/components/ImportDataDialog.tsx b/apps/yaak-client/components/ImportDataDialog.tsx index 3ad8db5a..c0e072aa 100644 --- a/apps/yaak-client/components/ImportDataDialog.tsx +++ b/apps/yaak-client/components/ImportDataDialog.tsx @@ -11,7 +11,7 @@ import { platform } from "@yaakapp-internal/platform"; import classNames from "classnames"; import { formatDistanceToNowStrict } from "date-fns"; import { useEffect, useMemo, useRef, useState } from "react"; -import { pluralize, pluralizeCount } from "../lib/pluralize"; +import { pluralize } from "../lib/pluralize"; import { CommercialUseBanner } from "./CommercialUseBanner"; import { Button } from "./core/Button"; import { Checkbox } from "./core/Checkbox"; @@ -308,17 +308,21 @@ function LoadedImportDataDialog({ return item.selected; }).length; - const destinationLabel = (() => { + // The row's label carries what kind of destination it is, so the value can just be its name + const [destinationLabel, destinationValue] = ((): [string, string] => { if (plan.destination.type === "new_workspace") { const names = plan.resources.workspaces.map((w) => w.name).filter((n) => n !== ""); - if (names.length > 1) return pluralizeCount("new workspace", names.length); - return names[0] == null ? "New workspace" : `New workspace · ${names[0]}`; + if (names.length === 0) return ["New workspace", "Untitled"]; + return [pluralize("New workspace", names.length), names.join(", ")]; } const { workspaceId, folderId } = plan.destination; const name = workspaces.find((w) => w.id === workspaceId)?.name ?? "Unknown workspace"; - return folderId != null && folderId === selectedFolder?.id - ? `${name} / ${selectedFolder.name}` - : name; + return [ + "Destination", + folderId != null && folderId === selectedFolder?.id + ? `${name} / ${selectedFolder.name}` + : name, + ]; })(); // The destination workspace roots the tree. It is not a plan item — commit always applies @@ -345,7 +349,7 @@ function LoadedImportDataDialog({
- +
{plan.warnings.map((warning) => ( diff --git a/crates/yaak/src/import.rs b/crates/yaak/src/import.rs index a619d1e0..b49278d7 100644 --- a/crates/yaak/src/import.rs +++ b/crates/yaak/src/import.rs @@ -331,8 +331,8 @@ fn warn_if_imported_elsewhere(db: &ClientDb, plan: &mut ImportPlan) -> Result<() } let names = names.iter().map(String::as_str).collect::>(); plan.warnings.push(ImportPlanWarning::warning( - "Already imported", - format!("{} · importing here makes a second copy", display_list(&names)), + format!("This document is already imported into {}", display_list(&names)), + "Importing it here makes a second copy instead of updating that one", )); Ok(()) } @@ -1758,14 +1758,17 @@ mod tests { let warning = elsewhere .warnings .iter() - .find(|w| w.title == "Already imported") + .find(|w| w.title == "This document is already imported into Imported") .expect("copying a document that already landed somewhere is called out"); - assert_eq!(warning.detail, "Imported · importing here makes a second copy"); + assert_eq!( + warning.detail, + "Importing it here makes a second copy instead of updating that one" + ); // Merging back into the workspace it created is the whole point, so it says nothing. let merging = replan(&query_manager, &workspace_id, imported_resources()); assert!( - merging.warnings.iter().all(|w| w.title != "Already imported"), + merging.warnings.iter().all(|w| !w.title.starts_with("This document is already")), "{:?}", merging.warnings );