Skip to content

Commit d35f9d0

Browse files
committed
feat(copilot): baseline user-input ui/ux improvement
1 parent d6bfe44 commit d35f9d0

File tree

5 files changed

+40
-64
lines changed

5 files changed

+40
-64
lines changed

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel-new/components/copilot/components/context-usage-pill/context-usage-pill.tsx

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import { memo } from 'react'
44
import { Plus } from 'lucide-react'
5+
import { Badge } from '@/components/emcn'
56
import { cn } from '@/lib/utils'
67

78
/**
@@ -52,7 +53,7 @@ export const ContextUsagePill = memo(
5253
const isHighUsage = percentage >= HIGH_USAGE_THRESHOLD
5354

5455
/**
55-
* Determines the color class based on usage percentage
56+
* Determines the color classes based on usage percentage
5657
* @returns Tailwind classes for background and text color
5758
*/
5859
const getColorClass = () => {
@@ -65,7 +66,7 @@ export const ContextUsagePill = memo(
6566
if (percentage >= COLOR_THRESHOLDS.MODERATE) {
6667
return 'bg-yellow-500/10 text-yellow-600 dark:text-yellow-400'
6768
}
68-
return 'bg-gray-500/10 text-gray-600 dark:text-gray-400'
69+
return ''
6970
}
7071

7172
/**
@@ -75,13 +76,8 @@ export const ContextUsagePill = memo(
7576
const formattedPercentage = percentage < 1 ? percentage.toFixed(1) : percentage.toFixed(0)
7677

7778
return (
78-
<div
79-
className={cn(
80-
'inline-flex items-center gap-1 rounded-full px-2 py-0.5 font-medium text-[11px] tabular-nums transition-colors',
81-
getColorClass(),
82-
isHighUsage && 'border border-red-500/50',
83-
className
84-
)}
79+
<Badge
80+
className={cn('tabular-nums transition-colors', getColorClass(), className)}
8581
title={`Context used in this chat: ${percentage.toFixed(2)}%`}
8682
>
8783
<span>{formattedPercentage}%</span>
@@ -91,14 +87,14 @@ export const ContextUsagePill = memo(
9187
e.stopPropagation()
9288
onCreateNewChat()
9389
}}
94-
className='inline-flex items-center justify-center transition-opacity hover:opacity-70'
90+
className='inline-flex items-center justify-center border-none bg-transparent p-0 transition-opacity hover:opacity-70'
9591
title='Recommended: Start a new chat for better quality'
9692
type='button'
9793
>
9894
<Plus className='h-3 w-3' />
9995
</button>
10096
)}
101-
</div>
97+
</Badge>
10298
)
10399
}
104100
)

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel-new/components/copilot/components/user-input/components/copilot-slider.tsx

Lines changed: 0 additions & 25 deletions
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
export { AttachedFilesDisplay } from './attached-files-display'
22
export { ContextPills } from './context-pills'
3-
export { CopilotSlider } from './copilot-slider'
43
export { MentionMenuPortal } from './mention-menu-portal'
54
export { ModeSelector } from './mode-selector'
65
export { ModelSelector } from './model-selector'

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel-new/components/copilot/components/user-input/user-input.tsx

Lines changed: 30 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@ import {
88
useImperativeHandle,
99
useState,
1010
} from 'react'
11-
import { ArrowUp, AtSign, Loader2, Paperclip, X } from 'lucide-react'
11+
import { ArrowUp, AtSign, Image, Loader2, X } from 'lucide-react'
1212
import { useParams } from 'next/navigation'
1313
import { createPortal } from 'react-dom'
14-
import { Button, Textarea } from '@/components/ui'
14+
import { Badge, Button } from '@/components/emcn'
15+
import { Button as ShadCNButton, Textarea } from '@/components/ui'
1516
import { useSession } from '@/lib/auth-client'
1617
import { createLogger } from '@/lib/logs/console/logger'
1718
import { cn } from '@/lib/utils'
@@ -118,8 +119,7 @@ const UserInput = forwardRef<UserInputRef, UserInputProps>(
118119

119120
// Effective placeholder
120121
const effectivePlaceholder =
121-
placeholder ||
122-
(mode === 'ask' ? 'Ask, plan, understand workflows' : 'Build, edit, debug workflows')
122+
placeholder || (mode === 'ask' ? 'Ask about your workflow' : 'Plan, search, build anything')
123123

124124
// Custom hooks - order matters for ref sharing
125125
const mentionMenu = useMentionMenu({
@@ -905,16 +905,17 @@ const UserInput = forwardRef<UserInputRef, UserInputProps>(
905905
>
906906
{/* Top Row: @ Button + Context Usage Pill */}
907907
<div className='mb-[6px] flex items-center justify-between'>
908-
<Button
909-
variant='ghost'
910-
size='icon'
908+
<Badge
911909
onClick={handleOpenMentionMenuWithAt}
912-
disabled={disabled || isLoading}
913-
className='!h-3 !w-3 text-muted-foreground hover:text-foreground'
914910
title='Insert @'
911+
className={cn(
912+
'radius-[6px] cursor-pointer border border-[#575757] bg-transparent dark:border-[#575757] dark:bg-transparent',
913+
(disabled || isLoading) && 'cursor-not-allowed',
914+
'rounded-[6px] p-[4.5px]'
915+
)}
915916
>
916-
<AtSign className='!h-[14px] !w-[14px]' strokeWidth={1.25} />
917-
</Button>
917+
<AtSign className='h-3 w-3' strokeWidth={1.25} />
918+
</Badge>
918919

919920
{/* Context Usage Pill */}
920921
{!hideContextUsage && contextUsage && contextUsage.percentage > 0 && (
@@ -1037,20 +1038,20 @@ const UserInput = forwardRef<UserInputRef, UserInputProps>(
10371038
</div>
10381039

10391040
{/* Right side: Attach Button + Send Button */}
1040-
<div className='flex flex-shrink-0 items-center gap-1.5'>
1041-
<Button
1042-
variant='ghost'
1043-
size='icon'
1041+
<div className='flex flex-shrink-0 items-center gap-[10px]'>
1042+
<Badge
10441043
onClick={fileAttachments.handleFileSelect}
1045-
disabled={disabled || isLoading}
1046-
className='h-6 w-6 text-muted-foreground hover:text-foreground'
10471044
title='Attach file'
1045+
className={cn(
1046+
'cursor-pointer rounded-[6px] bg-transparent p-[0px] dark:bg-transparent',
1047+
(disabled || isLoading) && 'cursor-not-allowed opacity-50'
1048+
)}
10481049
>
1049-
<Paperclip className='h-3 w-3' />
1050-
</Button>
1050+
<Image className='!h-3.5 !w-3.5 scale-x-110' />
1051+
</Badge>
10511052

10521053
{showAbortButton ? (
1053-
<Button
1054+
<ShadCNButton
10541055
onClick={handleAbort}
10551056
disabled={isAborting}
10561057
size='icon'
@@ -1062,18 +1063,22 @@ const UserInput = forwardRef<UserInputRef, UserInputProps>(
10621063
) : (
10631064
<X className='h-3 w-3' />
10641065
)}
1065-
</Button>
1066+
</ShadCNButton>
10661067
) : (
10671068
<Button
1069+
variant='primary'
10681070
onClick={handleSubmit}
10691071
disabled={!canSubmit}
1070-
size='icon'
1071-
className='h-6 w-6 rounded-full bg-[var(--brand-primary-hover-hex)] text-white shadow-[0_0_0_0_var(--brand-primary-hover-hex)] transition-all duration-200 hover:bg-[var(--brand-primary-hover-hex)] hover:shadow-[0_0_0_4px_rgba(127,47,255,0.15)]'
1072+
className={cn(
1073+
'h-[22px] w-[22px] rounded-full p-0',
1074+
canSubmit &&
1075+
'ring-2 ring-[#8E4CFB] ring-offset-2 ring-offset-[#282828] dark:ring-offset-[#353535]'
1076+
)}
10721077
>
10731078
{isLoading ? (
1074-
<Loader2 className='h-3 w-3 animate-spin' />
1079+
<Loader2 className='h-3.5 w-3.5 animate-spin' />
10751080
) : (
1076-
<ArrowUp className='h-3 w-3' />
1081+
<ArrowUp className='h-3.5 w-3.5' />
10771082
)}
10781083
</Button>
10791084
)}

apps/sim/components/emcn/components/badge.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@ import { cva, type VariantProps } from 'class-variance-authority'
33
import { cn } from '@/lib/utils'
44

55
const badgeVariants = cva(
6-
'inline-flex items-center px-[9px] py-[2.5px] text-[13px] font-medium gap-[4px] rounded-[40px] focus:outline-none',
6+
'inline-flex items-center px-[9px] py-[2.5px] text-[13px] font-medium gap-[4px] rounded-[40px] focus:outline-none transition-colors',
77
{
88
variants: {
99
variant: {
10-
default: 'bg-[#272727] text-[#B1B1B1] dark:bg-[#272727] dark:text-[#B1B1B1]',
10+
default:
11+
'bg-[#272727] text-[#B1B1B1] dark:bg-[#272727] dark:text-[#B1B1B1] hover:text-[#E6E6E6] dark:hover:text-[#E6E6E6]',
1112
},
1213
},
1314
defaultVariants: {

0 commit comments

Comments
 (0)