Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions app/(chat)/agents/components/agent-prompt-card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,26 @@ import { toast } from 'sonner';
interface AgentPromptCardProps {
agentPrompt: string;
showTitle?: boolean;
/** Number of lines to show when collapsed (defaults to 8) */
collapsedLines?: number;
/** Character length that triggers truncation (defaults to 500) */
longCharThreshold?: number;
/** Line count that triggers truncation (defaults to 8) */
longLineThreshold?: number;
}

export function AgentPromptCard({ agentPrompt, showTitle = true }: AgentPromptCardProps) {
export function AgentPromptCard({
agentPrompt,
showTitle = true,
collapsedLines = 8,
longCharThreshold = 500,
longLineThreshold = 8,
}: AgentPromptCardProps) {
const [isExpanded, setIsExpanded] = useState(false);
const isLong = agentPrompt.length > 500 || agentPrompt.split('\n').length > 8;
const totalLines = agentPrompt.split('\n');
const isLong = agentPrompt.length > longCharThreshold || totalLines.length > longLineThreshold;
const displayText = !isExpanded && isLong
? agentPrompt.split('\n').slice(0, 8).join('\n') + (agentPrompt.split('\n').length > 8 ? '\n...' : '...')
? totalLines.slice(0, collapsedLines).join('\n') + (totalLines.length > collapsedLines ? '\n...' : '...')
: agentPrompt;

const copyToClipboard = async () => {
Expand Down
9 changes: 8 additions & 1 deletion app/(chat)/agents/components/agent-quick-view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,14 @@ export function AgentQuickView({ agent, open, onOpenChange }: AgentQuickViewProp
<h3 className="text-sm font-medium text-muted-foreground">
Agent Prompt
</h3>
<AgentPromptCard agentPrompt={agent.agentPrompt} showTitle={false} />
<AgentPromptCard
agentPrompt={agent.agentPrompt}
showTitle={false}
/* Make preview more compact to avoid pushing CTA */
collapsedLines={4}
longCharThreshold={200}
longLineThreshold={4}
/>
</div>
)}

Expand Down
Loading