AI-native knowledge base & Evernote/Obsidian alternative with instant sync & native MCP. Free on Cloudflare or self-hosted via Docker.
HTML ai-agentcloudflarecloudflare-d1cloudflare-r2cloudflare-workersdockerelectronevernoteevernote-alternativeknowledge-basemcpnote-takingobsidian-alternativeoffline-firstpersonal-knowledge-basepwaself-hostedsqlitetiptapweb-clipper
Clarify dense architecture diagram relations
tianma-if22c5c7905607
diff --git a/apps/web/src/components/DiagramEditorPane.tsx b/apps/web/src/components/DiagramEditorPane.tsxindex b987a05f..a99893b8 100644--- a/apps/web/src/components/DiagramEditorPane.tsx+++ b/apps/web/src/components/DiagramEditorPane.tsx@@ -1697,6 +1697,9 @@ export const DiagramEditorPane = ({const editSessionRef = useRef<MemoEditSession | null>(null);const saveRef = useRef<() => void>(() => undefined);const document = parseDiagramDocument(memo.contentMarkdown);+ const denseArchitecture = document?.kind === "architecture"+ && document.edges.length >= 16+ && document.edges.length / Math.max(1, document.nodes.filter((node) => node.shape !== "boundary").length) >= 1.1;const documentTheme = document?.kind === "architecture"? resolveDiagramTheme(document.theme ?? "brand"): document?.kind === "flowchart"@@ -1719,6 +1722,7 @@ export const DiagramEditorPane = ({const [selectedEdgeId, setSelectedEdgeId] = useState<string | null>(null);const [selectedEdgeLabel, setSelectedEdgeLabel] = useState("");const [hasSelection, setHasSelection] = useState(false);+ const [showAllArchitectureLabels, setShowAllArchitectureLabels] = useState(false);const [dirty, setDirty] = useState(false);const [tagsDirty, setTagsDirty] = useState(false);const [dirtyVersion, setDirtyVersion] = useState(0);@@ -3414,6 +3418,7 @@ export const DiagramEditorPane = ({<div className="flex min-h-0 flex-1 flex-col"><DiagramToolbarappearance={resolvedTheme}+ architectureLabels={denseArchitecture ? { showAll: showAllArchitectureLabels, onToggle: () => setShowAllArchitectureLabels((current) => !current) } : undefined}canRedo={historyState.redo}canUndo={historyState.undo}hasSelection={hasSelection}@@ -3520,6 +3525,7 @@ export const DiagramEditorPane = ({data-architecture-placement={pendingArchitectureItem ? "active" : undefined}data-diagram-appearance={resolvedTheme}data-diagram-kind={document.kind}+ data-label-mode={denseArchitecture && !showAllArchitectureLabels ? "focus" : "all"}data-diagram-theme={theme}data-shift-select={shiftSelectActive ? "active" : undefined}data-space-pan={spacePanActive ? "active" : undefined}@@ -3540,6 +3546,12 @@ export const DiagramEditorPane = ({</kbd><span>{t("diagram.navHintBoxSelect")}</span></span>+ {denseArchitecture && !showAllArchitectureLabels ? (+ <>+ <span className="text-slate-300 dark:text-slate-600">·</span>+ <span>{t("diagram.navHintFocusRelations")}</span>+ </>+ ) : null}{document.kind === "mind-map" && (<><span className="text-slate-300 dark:text-slate-600">·</span>diff --git a/apps/web/src/components/DiagramToolbar.tsx b/apps/web/src/components/DiagramToolbar.tsxindex d6739309..0688913f 100644--- a/apps/web/src/components/DiagramToolbar.tsx+++ b/apps/web/src/components/DiagramToolbar.tsx@@ -4,6 +4,8 @@ import {BookOpen,ChevronDown,Download,+ Eye,+ EyeOff,FileCode2,FileImage,Redo2,@@ -140,6 +142,7 @@ type DiagramToolbarProps = {canUndo: boolean;hasSelection: boolean;leading?: ReactNode;+ architectureLabels?: { showAll: boolean; onToggle: () => void };onAutoLayout: () => void;onDeleteSelection: () => void;onExport: (format: "png" | "svg") => void;@@ -256,6 +259,7 @@ export const DiagramToolbar = ({canUndo,hasSelection,leading,+ architectureLabels,onAutoLayout,onDeleteSelection,onExport,@@ -295,6 +299,17 @@ export const DiagramToolbar = ({<TooltipContent>{t("diagram.autoLayoutTooltip")}</TooltipContent></Tooltip>)}+ {architectureLabels ? (+ <Tooltip>+ <TooltipTrigger asChild>+ <Button size="sm" variant={architectureLabels.showAll ? "soft" : "ghost"} className="gap-1.5 px-2.5" aria-pressed={architectureLabels.showAll} onClick={architectureLabels.onToggle}>+ {architectureLabels.showAll ? <Eye className="h-4 w-4" /> : <EyeOff className="h-4 w-4" />}+ {t("diagram.allEdgeLabels")}+ </Button>+ </TooltipTrigger>+ <TooltipContent>{t(architectureLabels.showAll ? "diagram.hideDenseEdgeLabels" : "diagram.showAllEdgeLabels")}</TooltipContent>+ </Tooltip>+ ) : null}<MemoEditorToolbarDivider /><Tooltip><TooltipTrigger asChild><Button size="icon" variant="ghost" aria-label={t("diagram.zoomOut")} onClick={onZoomOut}><ZoomOut className="h-4 w-4" /></Button></TooltipTrigger><TooltipContent>{t("diagram.zoomOut")}</TooltipContent></Tooltip><DiagramZoomPercentField zoomPercent={zoomPercent} onZoomTo={onZoomTo} />diff --git a/apps/web/src/lib/diagram-layout.test.mjs b/apps/web/src/lib/diagram-layout.test.mjsindex c5b2c2f0..65622570 100644--- a/apps/web/src/lib/diagram-layout.test.mjs+++ b/apps/web/src/lib/diagram-layout.test.mjs@@ -196,6 +196,25 @@ describe("diagram auto layout", () => {expect(heights.long).toBeGreaterThan(heights.medium);});+ test("opens vertical lanes for groups with many cross-boundary relations", () => {+ const nodes = [+ { id: "business", type: "boundary", label: "业务层" },+ { id: "data", type: "boundary", label: "数据层" },+ ...Array.from({ length: 4 }, (_, index) => ({ id: `service-${index}`, type: "service", label: `服务 ${index}`, parentId: "business" })),+ ...Array.from({ length: 4 }, (_, index) => ({ id: `store-${index}`, type: "database", label: `存储 ${index}`, parentId: "data" })),+ ];+ const edges = Array.from({ length: 4 }, (_, service) => Array.from({ length: 4 }, (_, store) => ({+ source: `service-${service}`, target: `store-${store}`,+ }))).flat();+ const rowGap = (document) => {+ const services = document.nodes.filter((node) => node.parentId === "business").sort((a, b) => a.y - b.y);+ return Math.min(...services.slice(1).map((node, index) => node.y - services[index].y - services[index].height));+ };+ const sparse = compileDiagramIr({ kind: "architecture", nodes, edges: edges.slice(0, 1) });+ const dense = compileDiagramIr({ kind: "architecture", nodes, edges });+ expect(rowGap(dense)).toBeGreaterThan(rowGap(sparse) + 40);+ });+test("turns a long ungrouped architecture pipeline downward on creation and auto layout", () => {const nodes = Array.from({ length: 17 }, (_, index) => ({id: `service-${index}`,diff --git a/apps/web/src/styles/globals.css b/apps/web/src/styles/globals.cssindex d5f008aa..80bb420a 100644--- a/apps/web/src/styles/globals.css+++ b/apps/web/src/styles/globals.css@@ -727,6 +727,16 @@ html[data-edgeever-extension-theme] .edgeever-memo-divider {filter: drop-shadow(0 0 3px rgb(22 160 110 / 0.22));}+.edgeever-diagram-canvas[data-diagram-kind="architecture"][data-label-mode="focus"] .x6-edge-labels {+ opacity: 0;+ pointer-events: none;+}++.edgeever-diagram-canvas[data-diagram-kind="architecture"][data-label-mode="focus"][data-relations-focused="true"] .x6-edge.edgeever-relation-focused .x6-edge-labels {+ opacity: 1;+ pointer-events: auto;+}+/* X6 owns the scroll extent so oversized diagrams remain reachable in both* directions while the editor chrome stays fixed around the viewport. */.edgeever-diagram-scroller {diff --git a/packages/shared/src/diagram-layout.ts b/packages/shared/src/diagram-layout.tsindex 8bd816ed..a71bf355 100644--- a/packages/shared/src/diagram-layout.ts+++ b/packages/shared/src/diagram-layout.ts@@ -121,7 +121,7 @@ const ARCHITECTURE_GROUP_VERTICAL_GAP = 88;const ARCHITECTURE_GROUP_PAD_X = 36;const ARCHITECTURE_GROUP_PAD_Y = 56;const ARCHITECTURE_LAYOUT_SPACING = { rank: 96, node: 40 };-const ARCHITECTURE_META_SPACING = { rank: 88, node: 56 };+const ARCHITECTURE_META_SPACING = { rank: 128, node: 56 };const ARCHITECTURE_ORIGIN = 32;export const compactArchitectureNodeSize = (@@ -876,11 +876,18 @@ const computeArchitectureLayout = (document: DiagramDocument, options: DiagramLaconst groupMetaNodes = groups.map((group) => {const memberIds = new Set(group.members.map((node) => node.id));const intraEdges = document.edges.filter((edge) => memberIds.has(edge.source) && memberIds.has(edge.target));+ const crossEdgeCount = document.edges.filter((edge) => (+ memberIds.has(edge.source) !== memberIds.has(edge.target)+ )).length;+ // Cross-boundary relations need separate vertical lanes beside their nodes.+ // Keep sparse groups compact while giving dense groups room for labels.+ const nodeGap = Math.min(112, ARCHITECTURE_LAYOUT_SPACING.node+ + Math.round(crossEdgeCount / group.members.length * 22));const inner = layoutArchitectureGraph(group.members,intraEdges,direction,- ARCHITECTURE_LAYOUT_SPACING,+ { ...ARCHITECTURE_LAYOUT_SPACING, node: nodeGap },{ x: 0, y: 0 },ARCHITECTURE_LAYOUT_ROW_WIDTH - ARCHITECTURE_GROUP_PAD_X * 2,);diff --git a/packages/shared/src/i18n/en-US.ts b/packages/shared/src/i18n/en-US.tsindex 1957ba9d..dd15c449 100644--- a/packages/shared/src/i18n/en-US.ts+++ b/packages/shared/src/i18n/en-US.ts@@ -527,6 +527,7 @@ export const enUS = {editNode: "Edit node text",deleteSelection: "Delete selection",navHintPan: "Drag to pan",+ navHintFocusRelations: "Hover a node or edge to inspect its relations",navHintBoxSelect: "Box select",navHintAddChild: "Child node",navHintAddSibling: "Sibling node",@@ -542,6 +543,9 @@ export const enUS = {fit: "Fit diagram",autoLayout: "Auto layout",autoLayoutTooltip: "Re-arrange all nodes and connections",+ allEdgeLabels: "All labels",+ showAllEdgeLabels: "Show all connection labels",+ hideDenseEdgeLabels: "Show labels only for the focused relation",toolbar: "Diagram toolbar",theme: "Color scheme",themeGroupVivid: "Bright",diff --git a/packages/shared/src/i18n/ja.ts b/packages/shared/src/i18n/ja.tsindex 63daf234..f2a0daf4 100644--- a/packages/shared/src/i18n/ja.ts+++ b/packages/shared/src/i18n/ja.ts@@ -527,6 +527,7 @@ export const ja = {editNode: "ノードの文字を編集",deleteSelection: "選択を削除",navHintPan: "ドラッグで移動",+ navHintFocusRelations: "ノードや線にカーソルを合わせて関係を確認",navHintBoxSelect: "範囲選択",navHintAddChild: "子ノード",navHintAddSibling: "同階層ノード",@@ -542,6 +543,9 @@ export const ja = {fit: "図に合わせる",autoLayout: "自動レイアウト",autoLayoutTooltip: "すべてのノードと接続を再配置",+ allEdgeLabels: "すべてのラベル",+ showAllEdgeLabels: "接続ラベルをすべて表示",+ hideDenseEdgeLabels: "注目中の関係のラベルのみ表示",toolbar: "図のツールバー",theme: "配色",themeGroupVivid: "鮮やか",diff --git a/packages/shared/src/i18n/zh-CN.ts b/packages/shared/src/i18n/zh-CN.tsindex 610ef748..acf2cfe9 100644--- a/packages/shared/src/i18n/zh-CN.ts+++ b/packages/shared/src/i18n/zh-CN.ts@@ -527,6 +527,7 @@ export const zhCN = {editNode: "编辑节点文字",deleteSelection: "删除所选内容",navHintPan: "拖动画布",+ navHintFocusRelations: "悬停节点或连线查看关系",navHintBoxSelect: "框选",navHintAddChild: "子节点",navHintAddSibling: "同级节点",@@ -542,6 +543,9 @@ export const zhCN = {fit: "适应画布",autoLayout: "自动布局",autoLayoutTooltip: "重新规整所有节点与连线",+ allEdgeLabels: "全部标签",+ showAllEdgeLabels: "显示所有连线标签",+ hideDenseEdgeLabels: "只显示当前关系的标签",toolbar: "图形工具栏",theme: "配色",themeGroupVivid: "鲜亮",