fix: auto-expand conflicting files and warn on agent overwrites during import
When importing into an existing company, files with "update" action (conflicts) now have their parent directories auto-expanded so users immediately see what will be overwritten. Additionally, server-side warnings are generated for any agent or project that will be overwritten by the import. Co-Authored-By: Paperclip <noreply@paperclip.ing> Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
3572ef230d
commit
298cb4ab8a
2 changed files with 31 additions and 5 deletions
|
|
@ -2042,6 +2042,20 @@ export function companyPortabilityService(db: Db) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Warn about agents that will be overwritten/updated
|
||||||
|
for (const ap of agentPlans) {
|
||||||
|
if (ap.action === "update") {
|
||||||
|
warnings.push(`Existing agent "${ap.plannedName}" (${ap.slug}) will be overwritten by import.`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Warn about projects that will be overwritten/updated
|
||||||
|
for (const pp of projectPlans) {
|
||||||
|
if (pp.action === "update") {
|
||||||
|
warnings.push(`Existing project "${pp.plannedName}" (${pp.slug}) will be overwritten by import.`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (include.issues) {
|
if (include.issues) {
|
||||||
for (const manifestIssue of manifest.issues) {
|
for (const manifestIssue of manifest.issues) {
|
||||||
issuePlans.push({
|
issuePlans.push({
|
||||||
|
|
|
||||||
|
|
@ -566,13 +566,25 @@ export function CompanyImport() {
|
||||||
// Check all files by default
|
// Check all files by default
|
||||||
const allFiles = new Set(Object.keys(result.files));
|
const allFiles = new Set(Object.keys(result.files));
|
||||||
setCheckedFiles(allFiles);
|
setCheckedFiles(allFiles);
|
||||||
// Expand top-level dirs
|
// Expand top-level dirs + all ancestor dirs of files with conflicts (update action)
|
||||||
const tree = buildFileTree(result.files, buildActionMap(result));
|
const am = buildActionMap(result);
|
||||||
const topDirs = new Set<string>();
|
const tree = buildFileTree(result.files, am);
|
||||||
|
const dirsToExpand = new Set<string>();
|
||||||
for (const node of tree) {
|
for (const node of tree) {
|
||||||
if (node.kind === "dir") topDirs.add(node.path);
|
if (node.kind === "dir") dirsToExpand.add(node.path);
|
||||||
}
|
}
|
||||||
setExpandedDirs(topDirs);
|
// Auto-expand directories containing conflicting files so they're visible
|
||||||
|
for (const [filePath, action] of am) {
|
||||||
|
if (action === "update") {
|
||||||
|
const segments = filePath.split("/").filter(Boolean);
|
||||||
|
let current = "";
|
||||||
|
for (let i = 0; i < segments.length - 1; i++) {
|
||||||
|
current = current ? `${current}/${segments[i]}` : segments[i];
|
||||||
|
dirsToExpand.add(current);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
setExpandedDirs(dirsToExpand);
|
||||||
// Select first file
|
// Select first file
|
||||||
const firstFile = Object.keys(result.files)[0];
|
const firstFile = Object.keys(result.files)[0];
|
||||||
if (firstFile) setSelectedFile(firstFile);
|
if (firstFile) setSelectedFile(firstFile);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue