wu981526092 commited on
Commit
738bb6b
·
1 Parent(s): ad76cdf
frontend/src/components/features/comparison/ComparisonResults.tsx CHANGED
@@ -11,16 +11,10 @@ import {
11
  import { BarChart3, Users, Network, GitBranch, TrendingUp } from "lucide-react";
12
  import { GraphComparisonResults } from "@/types";
13
 
14
- const truncateGraphName = (
15
- filename: string,
16
- maxLength: number = 30
17
- ): string => {
18
- if (filename.length <= maxLength) return filename;
19
-
20
- // Smart truncation - keep beginning and end if possible
21
- const start = filename.substring(0, Math.floor(maxLength * 0.6));
22
- const end = filename.substring(filename.length - Math.floor(maxLength * 0.3));
23
- return `${start}...${end}`;
24
  };
25
 
26
  interface ComparisonResultsProps {
@@ -115,8 +109,11 @@ export const ComparisonResults: React.FC<ComparisonResultsProps> = ({
115
  Graph 1
116
  </h3>
117
  <div className="p-3 bg-muted/50 rounded-lg">
118
- <h4 className="font-medium" title={graph1_info.filename}>
119
- {truncateGraphName(graph1_info.filename)}
 
 
 
120
  </h4>
121
  <div className="text-sm text-muted-foreground mt-1">
122
  {graph1_entity_count} entities • {graph1_relation_count}{" "}
@@ -131,8 +128,11 @@ export const ComparisonResults: React.FC<ComparisonResultsProps> = ({
131
  Graph 2
132
  </h3>
133
  <div className="p-3 bg-muted/50 rounded-lg">
134
- <h4 className="font-medium" title={graph2_info.filename}>
135
- {truncateGraphName(graph2_info.filename)}
 
 
 
136
  </h4>
137
  <div className="text-sm text-muted-foreground mt-1">
138
  {graph2_entity_count} entities • {graph2_relation_count}{" "}
 
11
  import { BarChart3, Users, Network, GitBranch, TrendingUp } from "lucide-react";
12
  import { GraphComparisonResults } from "@/types";
13
 
14
+ // Prefer system_name when available
15
+ const getGraphDisplayName = (g?: { filename: string; system_name?: string }) => {
16
+ if (!g) return "";
17
+ return g.system_name && g.system_name.trim().length > 0 ? g.system_name : g.filename;
 
 
 
 
 
 
18
  };
19
 
20
  interface ComparisonResultsProps {
 
109
  Graph 1
110
  </h3>
111
  <div className="p-3 bg-muted/50 rounded-lg">
112
+ <h4
113
+ className="font-medium whitespace-normal break-words"
114
+ title={getGraphDisplayName(graph1_info)}
115
+ >
116
+ {getGraphDisplayName(graph1_info)}
117
  </h4>
118
  <div className="text-sm text-muted-foreground mt-1">
119
  {graph1_entity_count} entities • {graph1_relation_count}{" "}
 
128
  Graph 2
129
  </h3>
130
  <div className="p-3 bg-muted/50 rounded-lg">
131
+ <h4
132
+ className="font-medium whitespace-normal break-words"
133
+ title={getGraphDisplayName(graph2_info)}
134
+ >
135
+ {getGraphDisplayName(graph2_info)}
136
  </h4>
137
  <div className="text-sm text-muted-foreground mt-1">
138
  {graph2_entity_count} entities • {graph2_relation_count}{" "}
frontend/src/components/features/comparison/GraphSelector.tsx CHANGED
@@ -166,10 +166,10 @@ export const GraphSelector: React.FC<GraphSelectorProps> = ({
166
  {selectedGraph1 ? (
167
  <div>
168
  <div
169
- className="font-medium text-sm"
170
  title={getGraphDisplayName(selectedGraph1)}
171
  >
172
- {truncateGraphName(getGraphDisplayName(selectedGraph1))}
173
  </div>
174
  <div className="text-xs text-muted-foreground">
175
  {selectedGraph1.graph_type} •{" "}
@@ -200,10 +200,10 @@ export const GraphSelector: React.FC<GraphSelectorProps> = ({
200
  {selectedGraph2 ? (
201
  <div>
202
  <div
203
- className="font-medium text-sm"
204
  title={getGraphDisplayName(selectedGraph2)}
205
  >
206
- {truncateGraphName(getGraphDisplayName(selectedGraph2))}
207
  </div>
208
  <div className="text-xs text-muted-foreground">
209
  {selectedGraph2.graph_type} •{" "}
@@ -267,10 +267,10 @@ export const GraphSelector: React.FC<GraphSelectorProps> = ({
267
  <IconComponent className="h-5 w-5 text-primary flex-shrink-0" />
268
  <div className="flex-1 min-w-0">
269
  <div
270
- className="font-semibold text-base text-foreground mb-1 truncate"
271
  title={getGraphDisplayName(graph)}
272
  >
273
- {truncateGraphName(getGraphDisplayName(graph))}
274
  </div>
275
  <div className="flex items-center gap-3 flex-wrap">
276
  <Badge
@@ -507,10 +507,10 @@ export const GraphSelector: React.FC<GraphSelectorProps> = ({
507
  </div>
508
  <div className="pl-7">
509
  <div
510
- className="font-medium text-sm text-foreground truncate"
511
  title={getGraphDisplayName(selectedGraph1!)}
512
  >
513
- {truncateGraphName(getGraphDisplayName(selectedGraph1!), 25)}
514
  </div>
515
  <div className="flex items-center gap-2 mt-1">
516
  <Badge variant="outline" className="text-xs">
@@ -531,10 +531,10 @@ export const GraphSelector: React.FC<GraphSelectorProps> = ({
531
  </div>
532
  <div className="pl-7">
533
  <div
534
- className="font-medium text-sm text-foreground truncate"
535
  title={getGraphDisplayName(selectedGraph2!)}
536
  >
537
- {truncateGraphName(getGraphDisplayName(selectedGraph2!), 25)}
538
  </div>
539
  <div className="flex items-center gap-2 mt-1">
540
  <Badge variant="outline" className="text-xs">
 
166
  {selectedGraph1 ? (
167
  <div>
168
  <div
169
+ className="font-medium text-sm whitespace-normal break-words"
170
  title={getGraphDisplayName(selectedGraph1)}
171
  >
172
+ {getGraphDisplayName(selectedGraph1)}
173
  </div>
174
  <div className="text-xs text-muted-foreground">
175
  {selectedGraph1.graph_type} •{" "}
 
200
  {selectedGraph2 ? (
201
  <div>
202
  <div
203
+ className="font-medium text-sm whitespace-normal break-words"
204
  title={getGraphDisplayName(selectedGraph2)}
205
  >
206
+ {getGraphDisplayName(selectedGraph2)}
207
  </div>
208
  <div className="text-xs text-muted-foreground">
209
  {selectedGraph2.graph_type} •{" "}
 
267
  <IconComponent className="h-5 w-5 text-primary flex-shrink-0" />
268
  <div className="flex-1 min-w-0">
269
  <div
270
+ className="font-semibold text-base text-foreground mb-1 whitespace-normal break-words"
271
  title={getGraphDisplayName(graph)}
272
  >
273
+ {getGraphDisplayName(graph)}
274
  </div>
275
  <div className="flex items-center gap-3 flex-wrap">
276
  <Badge
 
507
  </div>
508
  <div className="pl-7">
509
  <div
510
+ className="font-medium text-sm text-foreground whitespace-normal break-words"
511
  title={getGraphDisplayName(selectedGraph1!)}
512
  >
513
+ {getGraphDisplayName(selectedGraph1!)}
514
  </div>
515
  <div className="flex items-center gap-2 mt-1">
516
  <Badge variant="outline" className="text-xs">
 
531
  </div>
532
  <div className="pl-7">
533
  <div
534
+ className="font-medium text-sm text-foreground whitespace-normal break-words"
535
  title={getGraphDisplayName(selectedGraph2!)}
536
  >
537
+ {getGraphDisplayName(selectedGraph2!)}
538
  </div>
539
  <div className="flex items-center gap-2 mt-1">
540
  <Badge variant="outline" className="text-xs">
frontend/src/components/features/comparison/VisualComparison.tsx CHANGED
@@ -24,17 +24,24 @@ import { createKnowledgeGraphConfig } from "@/lib/graph-config-factory";
24
  import { GraphSelectionCallbacks } from "@/types/graph-visualization";
25
 
26
  const truncateGraphName = (
27
- filename: string,
28
  maxLength: number = 30
29
  ): string => {
30
- if (filename.length <= maxLength) return filename;
31
-
32
- // Smart truncation - keep beginning and end if possible
33
- const start = filename.substring(0, Math.floor(maxLength * 0.6));
34
- const end = filename.substring(filename.length - Math.floor(maxLength * 0.3));
35
  return `${start}...${end}`;
36
  };
37
 
 
 
 
 
 
 
 
 
38
  interface VisualComparisonProps {
39
  graph1: AvailableGraph;
40
  graph2: AvailableGraph;
@@ -307,8 +314,8 @@ export const VisualComparison: React.FC<VisualComparisonProps> = ({
307
  metadata: {
308
  ...graph1Data.metadata,
309
  merged: true,
310
- graph1Name: graph1.filename,
311
- graph2Name: graph2.filename,
312
  },
313
  mergeStats: {
314
  totalNodes: allEntities.length,
@@ -322,7 +329,7 @@ export const VisualComparison: React.FC<VisualComparisonProps> = ({
322
  },
323
  };
324
  },
325
- [graph1.filename, graph2.filename]
326
  );
327
 
328
  // Function to apply overlay coloring based on element source
@@ -665,10 +672,10 @@ export const VisualComparison: React.FC<VisualComparisonProps> = ({
665
  <CardHeader className="pb-2">
666
  <CardTitle className="text-base flex items-start justify-between gap-2">
667
  <span
668
- title={graph1.filename}
669
- className="truncate min-w-0 flex-1"
670
  >
671
- {truncateGraphName(graph1.filename)}
672
  </span>
673
  <div className="flex gap-1 flex-shrink-0">
674
  <Badge variant="outline" className="text-xs">
@@ -698,10 +705,10 @@ export const VisualComparison: React.FC<VisualComparisonProps> = ({
698
  <CardHeader className="pb-2">
699
  <CardTitle className="text-base flex items-start justify-between gap-2">
700
  <span
701
- title={graph2.filename}
702
- className="truncate min-w-0 flex-1"
703
  >
704
- {truncateGraphName(graph2.filename)}
705
  </span>
706
  <div className="flex gap-1 flex-shrink-0">
707
  <Badge variant="outline" className="text-xs">
@@ -732,8 +739,8 @@ export const VisualComparison: React.FC<VisualComparisonProps> = ({
732
  <CardHeader className="pb-2">
733
  <CardTitle className="text-base flex items-start justify-between gap-2">
734
  <span
735
- title={`${graph1.filename} + ${graph2.filename}`}
736
- className="truncate min-w-0 flex-1"
737
  >
738
  Overlay Comparison
739
  </span>
 
24
  import { GraphSelectionCallbacks } from "@/types/graph-visualization";
25
 
26
  const truncateGraphName = (
27
+ name: string,
28
  maxLength: number = 30
29
  ): string => {
30
+ if (!name) return "";
31
+ if (name.length <= maxLength) return name;
32
+ const start = name.substring(0, Math.floor(maxLength * 0.6));
33
+ const end = name.substring(name.length - Math.floor(maxLength * 0.3));
 
34
  return `${start}...${end}`;
35
  };
36
 
37
+ // Prefer human-friendly system name where available
38
+ const getGraphDisplayName = (graph?: AvailableGraph | null) => {
39
+ if (!graph) return "";
40
+ return graph.system_name && graph.system_name.trim().length > 0
41
+ ? graph.system_name
42
+ : graph.filename;
43
+ };
44
+
45
  interface VisualComparisonProps {
46
  graph1: AvailableGraph;
47
  graph2: AvailableGraph;
 
314
  metadata: {
315
  ...graph1Data.metadata,
316
  merged: true,
317
+ graph1Name: getGraphDisplayName(graph1),
318
+ graph2Name: getGraphDisplayName(graph2),
319
  },
320
  mergeStats: {
321
  totalNodes: allEntities.length,
 
329
  },
330
  };
331
  },
332
+ [graph1.filename, graph2.filename, graph1.system_name, graph2.system_name]
333
  );
334
 
335
  // Function to apply overlay coloring based on element source
 
672
  <CardHeader className="pb-2">
673
  <CardTitle className="text-base flex items-start justify-between gap-2">
674
  <span
675
+ title={getGraphDisplayName(graph1)}
676
+ className="min-w-0 flex-1 whitespace-normal break-words"
677
  >
678
+ {getGraphDisplayName(graph1)}
679
  </span>
680
  <div className="flex gap-1 flex-shrink-0">
681
  <Badge variant="outline" className="text-xs">
 
705
  <CardHeader className="pb-2">
706
  <CardTitle className="text-base flex items-start justify-between gap-2">
707
  <span
708
+ title={getGraphDisplayName(graph2)}
709
+ className="min-w-0 flex-1 whitespace-normal break-words"
710
  >
711
+ {getGraphDisplayName(graph2)}
712
  </span>
713
  <div className="flex gap-1 flex-shrink-0">
714
  <Badge variant="outline" className="text-xs">
 
739
  <CardHeader className="pb-2">
740
  <CardTitle className="text-base flex items-start justify-between gap-2">
741
  <span
742
+ title={`${getGraphDisplayName(graph1)} + ${getGraphDisplayName(graph2)}`}
743
+ className="min-w-0 flex-1 whitespace-normal break-words"
744
  >
745
  Overlay Comparison
746
  </span>