feat(import): warn that a document already has a workspace

Renaming the second workspace was the mechanism, not the news: what
matters is that this document already produced a workspace, so importing
it here copies it instead of updating it. The plan says that outright,
names the workspace, and does it on key overlap rather than on the name —
so it holds after either side has been renamed, and stays quiet when the
import is merging into that very workspace.

Plan notes carry a level so the ones worth a second thought read as
cautions, and the destination row gets its "new" chip back.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Gregory Schier
2026-09-08 08:56:44 -07:00
co-authored by Claude Opus 5
parent cdc034b25a
commit 213458b60c
5 changed files with 173 additions and 46 deletions
+6 -1
View File
@@ -88,7 +88,12 @@ export type ImportPlanItem = {
*/
export type ImportPlanReason = "moved_into_ignored_folder";
export type ImportPlanWarning = { title: string; detail: string };
export type ImportPlanWarning = { title: string; detail: string; level: ImportPlanWarningLevel };
/**
* Whether a plan's note is something to know or something to think twice about.
*/
export type ImportPlanWarningLevel = "info" | "warning";
/**
* The model types an import plan can contain.
+30
View File
@@ -109,6 +109,36 @@ pub enum ImportDestination {
pub struct ImportPlanWarning {
pub title: String,
pub detail: String,
#[serde(default)]
pub level: ImportPlanWarningLevel,
}
/// Whether a plan's note is something to know or something to think twice about.
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Deserialize, Serialize, TS)]
#[serde(rename_all = "snake_case")]
#[ts(export, export_to = "gen_util.ts")]
pub enum ImportPlanWarningLevel {
#[default]
Info,
Warning,
}
impl ImportPlanWarning {
pub fn info(title: impl Into<String>, detail: impl Into<String>) -> Self {
Self {
title: title.into(),
detail: detail.into(),
level: ImportPlanWarningLevel::Info,
}
}
pub fn warning(title: impl Into<String>, detail: impl Into<String>) -> Self {
Self {
title: title.into(),
detail: detail.into(),
level: ImportPlanWarningLevel::Warning,
}
}
}
/// Where an import's contents came from, used to link the committed workspace back to it.