Reduce size of instructions and examples font in agents

This commit is contained in:
akhisud3195 2025-05-07 20:35:50 +05:30
parent dc555a21c0
commit 703df486f9
2 changed files with 389 additions and 349 deletions

View file

@ -235,16 +235,16 @@ export function EditableField({
> >
{value ? ( {value ? (
<> <>
{markdown && <div className="max-h-[420px] overflow-y-auto"> {markdown && <div>
<MarkdownContent content={value} atValues={mentionsAtValues} /> <MarkdownContent content={value} atValues={mentionsAtValues} />
</div>} </div>}
{!markdown && <div className={`${multiline ? 'whitespace-pre-wrap max-h-[420px] overflow-y-auto' : 'flex items-center'}`}> {!markdown && <div className={multiline ? 'whitespace-pre-wrap' : 'flex items-center'}>
<MarkdownContent content={value} atValues={mentionsAtValues} /> <MarkdownContent content={value} atValues={mentionsAtValues} />
</div>} </div>}
</> </>
) : ( ) : (
<> <>
{markdown && <div className="max-h-[420px] overflow-y-auto text-gray-400"> {markdown && <div className="text-gray-400">
<MarkdownContent content={placeholder} atValues={mentionsAtValues} /> <MarkdownContent content={placeholder} atValues={mentionsAtValues} />
</div>} </div>}
{!markdown && <span className="text-gray-400">{placeholder}</span>} {!markdown && <span className="text-gray-400">{placeholder}</span>}

View file

@ -29,6 +29,9 @@ const sectionHeaderStyles = "text-xs font-medium uppercase tracking-wider text-g
// Common textarea styles // Common textarea styles
const textareaStyles = "rounded-lg p-3 border border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800 hover:bg-gray-50 dark:hover:bg-gray-750 focus:shadow-inner focus:ring-2 focus:ring-indigo-500/20 dark:focus:ring-indigo-400/20 placeholder:text-gray-400 dark:placeholder:text-gray-500"; const textareaStyles = "rounded-lg p-3 border border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800 hover:bg-gray-50 dark:hover:bg-gray-750 focus:shadow-inner focus:ring-2 focus:ring-indigo-500/20 dark:focus:ring-indigo-400/20 placeholder:text-gray-400 dark:placeholder:text-gray-500";
// Add this type definition after the imports
type TabType = 'configurations' | 'instructions' | 'examples';
export function AgentConfig({ export function AgentConfig({
projectId, projectId,
workflow, workflow,
@ -59,6 +62,7 @@ export function AgentConfig({
const { showPreview } = usePreviewModal(); const { showPreview } = usePreviewModal();
const [localName, setLocalName] = useState(agent.name); const [localName, setLocalName] = useState(agent.name);
const [nameError, setNameError] = useState<string | null>(null); const [nameError, setNameError] = useState<string | null>(null);
const [activeTab, setActiveTab] = useState<TabType>('configurations');
useEffect(() => { useEffect(() => {
setLocalName(agent.name); setLocalName(agent.name);
@ -126,7 +130,29 @@ export function AgentConfig({
</div> </div>
} }
> >
<div className="flex flex-col gap-6 p-4"> <div className="flex flex-col gap-6 p-4 h-[calc(100vh-100px)] min-h-0 flex-1">
{/* Tabs */}
<div className="flex border-b border-gray-200 dark:border-gray-700">
{(['configurations', 'instructions', 'examples'] as TabType[]).map((tab) => (
<button
key={tab}
onClick={() => setActiveTab(tab)}
className={clsx(
"px-4 py-2 text-sm font-medium transition-colors relative",
activeTab === tab
? "text-indigo-600 dark:text-indigo-400 after:absolute after:bottom-0 after:left-0 after:right-0 after:h-0.5 after:bg-indigo-500 dark:after:bg-indigo-400"
: "text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-300"
)}
>
{tab.charAt(0).toUpperCase() + tab.slice(1)}
</button>
))}
</div>
{/* Tab Content */}
<div className="mt-4 flex-1 flex flex-col min-h-0 h-0">
{activeTab === 'configurations' && (
<div className="space-y-6">
{!agent.locked && ( {!agent.locked && (
<div className="space-y-4"> <div className="space-y-4">
<div className="space-y-2"> <div className="space-y-2">
@ -218,63 +244,6 @@ export function AgentConfig({
/> />
</div> </div>
<div className="space-y-4">
<div className="flex items-center justify-between">
<label className={sectionHeaderStyles}>
Instructions
</label>
<CustomButton
variant="primary"
size="sm"
onClick={() => setShowGenerateModal(true)}
startContent={<Sparkles className="w-4 h-4" />}
>
Generate
</CustomButton>
</div>
<EditableField
key="instructions"
value={agent.instructions}
onChange={(value) => {
handleUpdate({
...agent,
instructions: value
});
}}
markdown
multiline
mentions
mentionsAtValues={atMentions}
showSaveButton={true}
showDiscardButton={true}
className="border border-gray-200 dark:border-gray-700 rounded-lg focus-within:ring-2 focus-within:ring-indigo-500/20 dark:focus-within:ring-indigo-400/20"
/>
</div>
<div className="space-y-4">
<label className={sectionHeaderStyles}>
Examples
</label>
<EditableField
key="examples"
value={agent.examples || ""}
onChange={(value) => {
handleUpdate({
...agent,
examples: value
});
}}
placeholder="Enter examples for this agent"
markdown
multiline
mentions
mentionsAtValues={atMentions}
showSaveButton={true}
showDiscardButton={true}
className="border border-gray-200 dark:border-gray-700 rounded-lg focus-within:ring-2 focus-within:ring-indigo-500/20 dark:focus-within:ring-indigo-400/20"
/>
</div>
{useRag && ( {useRag && (
<div className="space-y-4"> <div className="space-y-4">
<label className={sectionHeaderStyles}> <label className={sectionHeaderStyles}>
@ -488,7 +457,78 @@ export function AgentConfig({
/> />
</div> </div>
)} )}
</div>
)}
{activeTab === 'instructions' && (
<div className="flex flex-col flex-1 min-h-0 h-0">
<div className="flex items-center justify-between mb-4">
<label className={sectionHeaderStyles}>
Instructions
</label>
<CustomButton
variant="primary"
size="sm"
onClick={() => setShowGenerateModal(true)}
startContent={<Sparkles className="w-4 h-4" />}
>
Generate
</CustomButton>
</div>
<div className="flex-1 min-h-0 h-0">
<div className="text-sm h-full">
<EditableField
key="instructions"
value={agent.instructions}
onChange={(value) => {
handleUpdate({
...agent,
instructions: value
});
}}
markdown
multiline
mentions
mentionsAtValues={atMentions}
showSaveButton={true}
showDiscardButton={true}
className="h-full min-h-0 border border-gray-200 dark:border-gray-700 rounded-lg focus-within:ring-2 focus-within:ring-indigo-500/20 dark:focus-within:ring-indigo-400/20 overflow-auto"
/>
</div>
</div>
</div>
)}
{activeTab === 'examples' && (
<div className="flex flex-col flex-1 min-h-0 h-0">
<label className={clsx(sectionHeaderStyles, "mb-4")}>
Examples
</label>
<div className="flex-1 min-h-0 h-0">
<div className="text-sm h-full">
<EditableField
key="examples"
value={agent.examples || ""}
onChange={(value) => {
handleUpdate({
...agent,
examples: value
});
}}
placeholder="Enter examples for this agent"
markdown
multiline
mentions
mentionsAtValues={atMentions}
showSaveButton={true}
showDiscardButton={true}
className="h-full min-h-0 border border-gray-200 dark:border-gray-700 rounded-lg focus-within:ring-2 focus-within:ring-indigo-500/20 dark:focus-within:ring-indigo-400/20 overflow-auto"
/>
</div>
</div>
</div>
)}
</div>
<PreviewModalProvider> <PreviewModalProvider>
<GenerateInstructionsModal <GenerateInstructionsModal