Improve JsonView component styling and change to use JsonView in PromptsTab
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import { useState, memo } from "react";
|
import { useState, memo } from "react";
|
||||||
import { JsonValue } from "./DynamicJsonForm";
|
import { JsonValue } from "./DynamicJsonForm";
|
||||||
|
import clsx from "clsx";
|
||||||
|
|
||||||
interface JsonViewProps {
|
interface JsonViewProps {
|
||||||
data: JsonValue;
|
data: JsonValue;
|
||||||
@@ -70,7 +71,7 @@ const JsonNode = memo(
|
|||||||
boolean: "text-amber-600",
|
boolean: "text-amber-600",
|
||||||
null: "text-purple-600",
|
null: "text-purple-600",
|
||||||
undefined: "text-gray-600",
|
undefined: "text-gray-600",
|
||||||
string: "text-green-600",
|
string: "text-green-600 break-all",
|
||||||
default: "text-gray-700",
|
default: "text-gray-700",
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -173,7 +174,7 @@ const JsonNode = memo(
|
|||||||
{name}:
|
{name}:
|
||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
<span className={typeStyleMap.string}>"{value}"</span>
|
<p className={typeStyleMap.string}>"{value}"</p>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -186,7 +187,10 @@ const JsonNode = memo(
|
|||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
<span
|
<span
|
||||||
className={`${typeStyleMap.string} cursor-pointer group-hover:text-green-500`}
|
className={clsx(
|
||||||
|
typeStyleMap.string,
|
||||||
|
"cursor-pointer group-hover:text-green-500",
|
||||||
|
)}
|
||||||
onClick={() => setIsExpanded(!isExpanded)}
|
onClick={() => setIsExpanded(!isExpanded)}
|
||||||
title={isExpanded ? "Click to collapse" : "Click to expand"}
|
title={isExpanded ? "Click to collapse" : "Click to expand"}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { Button } from "@/components/ui/button";
|
|||||||
import { Combobox } from "@/components/ui/combobox";
|
import { Combobox } from "@/components/ui/combobox";
|
||||||
import { Label } from "@/components/ui/label";
|
import { Label } from "@/components/ui/label";
|
||||||
import { TabsContent } from "@/components/ui/tabs";
|
import { TabsContent } from "@/components/ui/tabs";
|
||||||
import { Textarea } from "@/components/ui/textarea";
|
|
||||||
import {
|
import {
|
||||||
ListPromptsResult,
|
ListPromptsResult,
|
||||||
PromptReference,
|
PromptReference,
|
||||||
@@ -13,6 +13,7 @@ import { AlertCircle } from "lucide-react";
|
|||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import ListPane from "./ListPane";
|
import ListPane from "./ListPane";
|
||||||
import { useCompletionState } from "@/lib/hooks/useCompletionState";
|
import { useCompletionState } from "@/lib/hooks/useCompletionState";
|
||||||
|
import JsonView from "./JsonView";
|
||||||
|
|
||||||
export type Prompt = {
|
export type Prompt = {
|
||||||
name: string;
|
name: string;
|
||||||
@@ -151,11 +152,9 @@ const PromptsTab = ({
|
|||||||
Get Prompt
|
Get Prompt
|
||||||
</Button>
|
</Button>
|
||||||
{promptContent && (
|
{promptContent && (
|
||||||
<Textarea
|
<div className="p-4 border rounded">
|
||||||
value={promptContent}
|
<JsonView data={promptContent} />
|
||||||
readOnly
|
</div>
|
||||||
className="h-64 font-mono"
|
|
||||||
/>
|
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
|
|||||||
@@ -54,17 +54,14 @@ const ToolsTab = ({
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<h4 className="font-semibold mb-2">Invalid Tool Result:</h4>
|
<h4 className="font-semibold mb-2">Invalid Tool Result:</h4>
|
||||||
<pre className="bg-gray-50 dark:bg-gray-800 dark:text-gray-100 p-4 rounded text-sm overflow-auto max-h-64">
|
<div className="p-4 border rounded">
|
||||||
<JsonView data={escapeUnicode(toolResult)} />
|
<JsonView data={escapeUnicode(toolResult)} />
|
||||||
</pre>
|
</div>
|
||||||
<h4 className="font-semibold mb-2">Errors:</h4>
|
<h4 className="font-semibold mb-2">Errors:</h4>
|
||||||
{parsedResult.error.errors.map((error, idx) => (
|
{parsedResult.error.errors.map((error, idx) => (
|
||||||
<pre
|
<div key={idx} className="p-4 border rounded">
|
||||||
key={idx}
|
|
||||||
className="bg-gray-50 dark:bg-gray-800 dark:text-gray-100 p-4 rounded text-sm overflow-auto max-h-64"
|
|
||||||
>
|
|
||||||
<JsonView data={escapeUnicode(error)} />
|
<JsonView data={escapeUnicode(error)} />
|
||||||
</pre>
|
</div>
|
||||||
))}
|
))}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
@@ -80,9 +77,9 @@ const ToolsTab = ({
|
|||||||
{structuredResult.content.map((item, index) => (
|
{structuredResult.content.map((item, index) => (
|
||||||
<div key={index} className="mb-2">
|
<div key={index} className="mb-2">
|
||||||
{item.type === "text" && (
|
{item.type === "text" && (
|
||||||
<pre className="bg-gray-50 dark:bg-gray-800 dark:text-gray-100 p-4 rounded text-sm overflow-auto max-h-64">
|
<div className="p-4 border rounded">
|
||||||
<JsonView data={item.text} />
|
<JsonView data={item.text} />
|
||||||
</pre>
|
</div>
|
||||||
)}
|
)}
|
||||||
{item.type === "image" && (
|
{item.type === "image" && (
|
||||||
<img
|
<img
|
||||||
@@ -101,9 +98,9 @@ const ToolsTab = ({
|
|||||||
<p>Your browser does not support audio playback</p>
|
<p>Your browser does not support audio playback</p>
|
||||||
</audio>
|
</audio>
|
||||||
) : (
|
) : (
|
||||||
<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">
|
<div className="p-4 border rounded">
|
||||||
<JsonView data={escapeUnicode(item.resource)} />
|
<JsonView data={escapeUnicode(item.resource)} />
|
||||||
</pre>
|
</div>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
@@ -113,9 +110,9 @@ const ToolsTab = ({
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<h4 className="font-semibold mb-2">Tool Result (Legacy):</h4>
|
<h4 className="font-semibold mb-2">Tool Result (Legacy):</h4>
|
||||||
<pre className="bg-gray-50 dark:bg-gray-800 dark:text-gray-100 p-4 rounded text-sm overflow-auto max-h-64">
|
<div className="p-4 border rounded">
|
||||||
<JsonView data={escapeUnicode(toolResult.toolResult)} />
|
<JsonView data={escapeUnicode(toolResult.toolResult)} />
|
||||||
</pre>
|
</div>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user