Skip to content

Commit e6f5da8

Browse files
committed
Improve JsonView component styling and change to use JsonView in PromptsTab
1 parent 196fd67 commit e6f5da8

File tree

3 files changed

+22
-22
lines changed

3 files changed

+22
-22
lines changed

client/src/components/JsonView.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { useState, memo } from "react";
22
import { JsonValue } from "./DynamicJsonForm";
3+
import clsx from "clsx";
34

45
interface JsonViewProps {
56
data: JsonValue;
@@ -70,7 +71,7 @@ const JsonNode = memo(
7071
boolean: "text-amber-600",
7172
null: "text-purple-600",
7273
undefined: "text-gray-600",
73-
string: "text-green-600",
74+
string: "text-green-600 break-all",
7475
default: "text-gray-700",
7576
};
7677

@@ -173,7 +174,7 @@ const JsonNode = memo(
173174
{name}:
174175
</span>
175176
)}
176-
<span className={typeStyleMap.string}>"{value}"</span>
177+
<p className={typeStyleMap.string}>"{value}"</p>
177178
</div>
178179
);
179180
}
@@ -186,7 +187,10 @@ const JsonNode = memo(
186187
</span>
187188
)}
188189
<span
189-
className={`${typeStyleMap.string} cursor-pointer group-hover:text-green-500`}
190+
className={clsx(
191+
typeStyleMap.string,
192+
"cursor-pointer group-hover:text-green-500",
193+
)}
190194
onClick={() => setIsExpanded(!isExpanded)}
191195
title={isExpanded ? "Click to collapse" : "Click to expand"}
192196
>

client/src/components/PromptsTab.tsx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Button } from "@/components/ui/button";
33
import { Combobox } from "@/components/ui/combobox";
44
import { Label } from "@/components/ui/label";
55
import { TabsContent } from "@/components/ui/tabs";
6-
import { Textarea } from "@/components/ui/textarea";
6+
77
import {
88
ListPromptsResult,
99
PromptReference,
@@ -13,6 +13,7 @@ import { AlertCircle } from "lucide-react";
1313
import { useEffect, useState } from "react";
1414
import ListPane from "./ListPane";
1515
import { useCompletionState } from "@/lib/hooks/useCompletionState";
16+
import JsonView from "./JsonView";
1617

1718
export type Prompt = {
1819
name: string;
@@ -151,11 +152,9 @@ const PromptsTab = ({
151152
Get Prompt
152153
</Button>
153154
{promptContent && (
154-
<Textarea
155-
value={promptContent}
156-
readOnly
157-
className="h-64 font-mono"
158-
/>
155+
<div className="p-4 border rounded">
156+
<JsonView data={promptContent} />
157+
</div>
159158
)}
160159
</div>
161160
) : (

client/src/components/ToolsTab.tsx

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -54,17 +54,14 @@ const ToolsTab = ({
5454
return (
5555
<>
5656
<h4 className="font-semibold mb-2">Invalid Tool Result:</h4>
57-
<pre className="bg-gray-50 dark:bg-gray-800 dark:text-gray-100 p-4 rounded text-sm overflow-auto max-h-64">
57+
<div className="p-4 border rounded">
5858
<JsonView data={escapeUnicode(toolResult)} />
59-
</pre>
59+
</div>
6060
<h4 className="font-semibold mb-2">Errors:</h4>
6161
{parsedResult.error.errors.map((error, idx) => (
62-
<pre
63-
key={idx}
64-
className="bg-gray-50 dark:bg-gray-800 dark:text-gray-100 p-4 rounded text-sm overflow-auto max-h-64"
65-
>
62+
<div key={idx} className="p-4 border rounded">
6663
<JsonView data={escapeUnicode(error)} />
67-
</pre>
64+
</div>
6865
))}
6966
</>
7067
);
@@ -80,9 +77,9 @@ const ToolsTab = ({
8077
{structuredResult.content.map((item, index) => (
8178
<div key={index} className="mb-2">
8279
{item.type === "text" && (
83-
<pre className="bg-gray-50 dark:bg-gray-800 dark:text-gray-100 p-4 rounded text-sm overflow-auto max-h-64">
80+
<div className="p-4 border rounded">
8481
<JsonView data={item.text} />
85-
</pre>
82+
</div>
8683
)}
8784
{item.type === "image" && (
8885
<img
@@ -101,9 +98,9 @@ const ToolsTab = ({
10198
<p>Your browser does not support audio playback</p>
10299
</audio>
103100
) : (
104-
<pre className="bg-gray-50 dark:bg-gray-800 dark:text-gray-100 whitespace-pre-wrap break-words p-4 rounded text-sm overflow-auto max-h-64">
101+
<div className="p-4 border rounded">
105102
<JsonView data={escapeUnicode(item.resource)} />
106-
</pre>
103+
</div>
107104
))}
108105
</div>
109106
))}
@@ -113,9 +110,9 @@ const ToolsTab = ({
113110
return (
114111
<>
115112
<h4 className="font-semibold mb-2">Tool Result (Legacy):</h4>
116-
<pre className="bg-gray-50 dark:bg-gray-800 dark:text-gray-100 p-4 rounded text-sm overflow-auto max-h-64">
113+
<div className="p-4 border rounded">
117114
<JsonView data={escapeUnicode(toolResult.toolResult)} />
118-
</pre>
115+
</div>
119116
</>
120117
);
121118
}

0 commit comments

Comments
 (0)