Skip to content

Commit cc65762

Browse files
author
Dylan Huang
committed
Refactor ChatInterface and MetadataSection components for improved layout and functionality
- Adjusted default chat height in ChatInterface from 512px to 400px for better UI consistency. - Enhanced MetadataSection to include expandable functionality, allowing users to toggle visibility of metadata details. - Updated Row component to set defaultExpanded prop for MetadataSection, ensuring sections are expanded by default.
1 parent 71dd500 commit cc65762

File tree

3 files changed

+36
-6
lines changed

3 files changed

+36
-6
lines changed

vite-app/src/components/ChatInterface.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ interface ChatInterfaceProps {
88

99
export const ChatInterface = ({ messages }: ChatInterfaceProps) => {
1010
const [chatWidth, setChatWidth] = useState(600); // Default width in pixels
11-
const [chatHeight, setChatHeight] = useState(512); // Default height in pixels (32rem = 512px)
11+
const [chatHeight, setChatHeight] = useState(400); // Default height in pixels
1212
const [isResizingWidth, setIsResizingWidth] = useState(false);
1313
const [isResizingHeight, setIsResizingHeight] = useState(false);
1414
const [initialWidth, setInitialWidth] = useState(0);
Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,48 @@
1+
import { useState } from "react";
2+
13
export const MetadataSection = ({
24
title,
35
data,
6+
defaultExpanded = false,
47
}: {
58
title: string;
69
data: any;
10+
defaultExpanded?: boolean;
711
}) => {
12+
const [isExpanded, setIsExpanded] = useState(defaultExpanded);
13+
814
if (!data || Object.keys(data).length === 0) return null;
915

1016
return (
1117
<div className="mb-2">
12-
<h4 className="font-semibold text-xs text-gray-700 mb-1">{title}</h4>
13-
<div className="border border-gray-200 p-2 text-xs bg-white">
14-
<pre className="whitespace-pre-wrap overflow-x-auto">
15-
{JSON.stringify(data, null, 1)}
16-
</pre>
18+
<div
19+
className="flex items-center justify-between cursor-pointer hover:bg-gray-50 p-1 rounded"
20+
onClick={() => setIsExpanded(!isExpanded)}
21+
>
22+
<h4 className="font-semibold text-xs text-gray-700">{title}</h4>
23+
<svg
24+
className={`h-3 w-3 text-gray-500 transition-transform duration-200 ${
25+
isExpanded ? "rotate-180" : ""
26+
}`}
27+
fill="none"
28+
stroke="currentColor"
29+
viewBox="0 0 24 24"
30+
>
31+
<path
32+
strokeLinecap="round"
33+
strokeLinejoin="round"
34+
strokeWidth={2}
35+
d="M19 9l-7 7-7-7"
36+
/>
37+
</svg>
1738
</div>
39+
{isExpanded && (
40+
<div className="border border-gray-200 p-2 text-xs bg-white mt-1">
41+
<pre className="whitespace-pre-wrap overflow-x-auto">
42+
{JSON.stringify(data, null, 1)}
43+
</pre>
44+
</div>
45+
)}
1846
</div>
1947
);
2048
};

vite-app/src/components/Row.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,12 +115,14 @@ export const Row = observer(
115115
<MetadataSection
116116
title="Eval Metadata"
117117
data={row.eval_metadata}
118+
defaultExpanded={true}
118119
/>
119120

120121
{/* Evaluation Result */}
121122
<MetadataSection
122123
title="Evaluation Result"
123124
data={row.evaluation_result}
125+
defaultExpanded={true}
124126
/>
125127

126128
{/* Ground Truth */}

0 commit comments

Comments
 (0)