Replace Mermaid org chart with PNG image in export preview
The frontend generateReadmeFromSelection() was building an inline Mermaid diagram for the org chart. The server already generates a PNG at images/org-chart.png, so the preview should reference it the same way. Removed dead mermaidId/mermaidEscape/generateOrgChartMermaid helpers. Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
parent
f7c766ff32
commit
c39758a169
1 changed files with 3 additions and 34 deletions
|
|
@ -343,36 +343,6 @@ const ROLE_LABELS: Record<string, string> = {
|
||||||
vp: "VP", manager: "Manager", engineer: "Engineer", agent: "Agent",
|
vp: "VP", manager: "Manager", engineer: "Engineer", agent: "Agent",
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Sanitize slug for use as a Mermaid node ID. */
|
|
||||||
function mermaidId(slug: string): string {
|
|
||||||
return slug.replace(/[^a-zA-Z0-9_]/g, "_");
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Escape text for Mermaid node labels. */
|
|
||||||
function mermaidEscape(s: string): string {
|
|
||||||
return s.replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">");
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Generate a Mermaid org chart from the selected agents. */
|
|
||||||
function generateOrgChartMermaid(agents: CompanyPortabilityManifest["agents"]): string | null {
|
|
||||||
if (agents.length === 0) return null;
|
|
||||||
const lines: string[] = [];
|
|
||||||
lines.push("```mermaid");
|
|
||||||
lines.push("graph TD");
|
|
||||||
for (const agent of agents) {
|
|
||||||
const roleLabel = ROLE_LABELS[agent.role] ?? agent.role;
|
|
||||||
lines.push(` ${mermaidId(agent.slug)}["${mermaidEscape(agent.name)}<br/><small>${mermaidEscape(roleLabel)}</small>"]`);
|
|
||||||
}
|
|
||||||
const slugSet = new Set(agents.map((a) => a.slug));
|
|
||||||
for (const agent of agents) {
|
|
||||||
if (agent.reportsToSlug && slugSet.has(agent.reportsToSlug)) {
|
|
||||||
lines.push(` ${mermaidId(agent.reportsToSlug)} --> ${mermaidId(agent.slug)}`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
lines.push("```");
|
|
||||||
return lines.join("\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Regenerate README.md content based on the currently checked files.
|
* Regenerate README.md content based on the currently checked files.
|
||||||
* Only counts/lists entities whose files are in the checked set.
|
* Only counts/lists entities whose files are in the checked set.
|
||||||
|
|
@ -400,10 +370,9 @@ function generateReadmeFromSelection(
|
||||||
lines.push(`> ${companyDescription}`);
|
lines.push(`> ${companyDescription}`);
|
||||||
lines.push("");
|
lines.push("");
|
||||||
}
|
}
|
||||||
// Org chart as Mermaid diagram
|
// Org chart image (generated during export as images/org-chart.png)
|
||||||
const mermaid = generateOrgChartMermaid(agents);
|
if (agents.length > 0) {
|
||||||
if (mermaid) {
|
lines.push("");
|
||||||
lines.push(mermaid);
|
|
||||||
lines.push("");
|
lines.push("");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue