diff --git a/src/components/TemplateAttributeDialog.tsx b/src/components/TemplateAttributeDialog.tsx index d2fe539..eeca899 100644 --- a/src/components/TemplateAttributeDialog.tsx +++ b/src/components/TemplateAttributeDialog.tsx @@ -1,5 +1,12 @@ import { useState } from "react"; import { ChatStore } from "@/types/chatstore"; +import { + Tooltip, + TooltipContent, + TooltipProvider, + TooltipTrigger, +} from "@/components/ui/tooltip"; + import { Dialog, DialogContent, @@ -31,7 +38,9 @@ export function TemplateAttributeDialog({ langCode, }: TemplateAttributeDialogProps) { // Create a map of all ChatStore attributes and their selection state - const [selectedAttributes, setSelectedAttributes] = useState>(() => { + const [selectedAttributes, setSelectedAttributes] = useState< + Record + >(() => { const initial: Record = {}; // Initialize all attributes as selected by default Object.keys(chatStore).forEach((key) => { @@ -71,13 +80,31 @@ export function TemplateAttributeDialog({ setSelectedAttributes(newSelected); }; + const formatValue = (value: any): string => { + if (value === null || value === undefined) return "null"; + if (typeof value === "object") { + if (Array.isArray(value)) { + return `[${value.length} items]`; + } + return "{...}"; + } + if (typeof value === "string") { + if (value.length > 50) { + return value.substring(0, 47) + "..."; + } + return value; + } + return String(value); + }; + return ( Select Template Attributes - Choose which attributes to include in your template. Unselected attributes will be omitted. + Choose which attributes to include in your template. Unselected + attributes will be omitted. @@ -93,9 +120,7 @@ export function TemplateAttributeDialog({ }} placeholder={tr("Enter template name", langCode)} /> - {nameError && ( -

{nameError}

- )} + {nameError &&

{nameError}

}
@@ -108,7 +133,7 @@ export function TemplateAttributeDialog({
-
+
{Object.keys(chatStore).map((key) => (
- + + + +
+ + + {formatValue(chatStore[key as keyof ChatStore])} + +
+
+ +

+ {JSON.stringify( + chatStore[key as keyof ChatStore], + null, + 2 + )} +

+
+
+
))}
@@ -139,4 +184,4 @@ export function TemplateAttributeDialog({
); -} \ No newline at end of file +}