From 72f966e4fcbd331ebb96f6874f8b759d5129059f Mon Sep 17 00:00:00 2001 From: Michael Neale Date: Thu, 8 May 2025 08:52:57 +1000 Subject: [PATCH] recipe welcome message (#2456) --- ui/desktop/src/components/SplashPills.tsx | 55 +++++++++++++++++++---- 1 file changed, 47 insertions(+), 8 deletions(-) diff --git a/ui/desktop/src/components/SplashPills.tsx b/ui/desktop/src/components/SplashPills.tsx index 821c59ef..38230670 100644 --- a/ui/desktop/src/components/SplashPills.tsx +++ b/ui/desktop/src/components/SplashPills.tsx @@ -5,7 +5,13 @@ function truncateText(text: string, maxLength: number = 100): string { return text.slice(0, maxLength) + '...'; } -function SplashPill({ content, append, className = '', longForm = '' }) { +interface SplashPillProps { + content: string; + append: (text: string) => void; + className?: string; +} + +function SplashPill({ content, append, className = '' }: SplashPillProps) { const displayText = truncateText(content); return ( @@ -13,7 +19,7 @@ function SplashPill({ content, append, className = '', longForm = '' }) { className={`px-4 py-2 text-sm text-center text-textStandard cursor-pointer border border-borderSubtle hover:bg-bgSubtle rounded-full transition-all duration-150 ${className}`} onClick={async () => { // Always use the full text (longForm or original content) when clicked - await append(longForm || content); + await append(content); }} title={content.length > 100 ? content : undefined} // Show full text on hover if truncated > @@ -22,9 +28,29 @@ function SplashPill({ content, append, className = '', longForm = '' }) { ); } -export default function SplashPills({ append, activities = null }) { +interface ContextBlockProps { + content: string; +} + +function ContextBlock({ content }: ContextBlockProps) { + // Remove the "message:" prefix and trim whitespace + const displayText = content.replace(/^message:/i, '').trim(); + + return ( +
+
{displayText}
+
+ ); +} + +interface SplashPillsProps { + append: (text: string) => void; + activities: string[] | null; +} + +export default function SplashPills({ append, activities = null }: SplashPillsProps) { // If custom activities are provided, use those instead of the default ones - const pills = activities || [ + const defaultPills = [ 'What can you do?', 'Demo writing and reading files', 'Make a snake game in a new folder', @@ -32,11 +58,24 @@ export default function SplashPills({ append, activities = null }) { 'Take a screenshot and summarize', ]; + const pills = activities || defaultPills; + + // Check if the first pill starts with "message:" + const hasContextPill = pills.length > 0 && pills[0].toLowerCase().startsWith('message:'); + + // Extract the context pill and the remaining pills + const contextPill = hasContextPill ? pills[0] : null; + const remainingPills = hasContextPill ? pills.slice(1) : pills; + return ( -
- {pills.map((content, index) => ( - - ))} +
+ {contextPill && } + +
+ {remainingPills.map((content, index) => ( + + ))} +
); }