Skip to content

Commit 4ab34ae

Browse files
committed
Options select
1 parent 36e9ba5 commit 4ab34ae

File tree

1 file changed

+51
-57
lines changed
  • apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/copilot/components/tool-call

1 file changed

+51
-57
lines changed

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/copilot/components/tool-call/tool-call.tsx

Lines changed: 51 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,15 @@ export function OptionsSelector({
184184
setChosenKey(selected.key)
185185
onSelect(selected.key, selected.title)
186186
}
187+
} else if (/^[1-9]$/.test(e.key)) {
188+
// Number keys select that option directly
189+
const optionIndex = sortedOptions.findIndex((opt) => opt.key === e.key)
190+
if (optionIndex !== -1) {
191+
e.preventDefault()
192+
const selected = sortedOptions[optionIndex]
193+
setChosenKey(selected.key)
194+
onSelect(selected.key, selected.title)
195+
}
187196
}
188197
}
189198

@@ -194,65 +203,50 @@ export function OptionsSelector({
194203
if (sortedOptions.length === 0) return null
195204

196205
return (
197-
<div
198-
ref={containerRef}
199-
className='mt-3 overflow-hidden rounded-md border border-[var(--border-1)] bg-[var(--surface-1)]'
200-
>
201-
<div className='divide-y divide-[var(--border-1)]'>
202-
{sortedOptions.map((option, index) => {
203-
const isHovered = index === hoveredIndex && !isLocked
204-
const isChosen = option.key === chosenKey
205-
const isRejected = isLocked && !isChosen
206-
207-
return (
208-
<div
209-
key={option.key}
210-
onClick={() => {
211-
if (!disabled && !isLocked) {
212-
setChosenKey(option.key)
213-
onSelect(option.key, option.title)
214-
}
215-
}}
216-
onMouseEnter={() => {
217-
if (!isLocked) setHoveredIndex(index)
218-
}}
219-
className={`flex items-start gap-2.5 px-2.5 py-2 transition-colors ${
220-
isLocked
221-
? isChosen
222-
? 'bg-[var(--surface-3)]'
223-
: 'bg-transparent'
224-
: isHovered
225-
? 'cursor-pointer bg-[var(--surface-3)]'
226-
: 'cursor-pointer hover:bg-[var(--surface-2)]'
227-
} ${disabled ? 'cursor-not-allowed opacity-50' : ''} ${isLocked ? 'cursor-default' : ''}`}
206+
<div ref={containerRef} className='mt-3 flex flex-col gap-1 pb-1'>
207+
{sortedOptions.map((option, index) => {
208+
const isHovered = index === hoveredIndex && !isLocked
209+
const isChosen = option.key === chosenKey
210+
const isRejected = isLocked && !isChosen
211+
212+
return (
213+
<div
214+
key={option.key}
215+
onClick={() => {
216+
if (!disabled && !isLocked) {
217+
setChosenKey(option.key)
218+
onSelect(option.key, option.title)
219+
}
220+
}}
221+
onMouseEnter={() => {
222+
if (!isLocked) setHoveredIndex(index)
223+
}}
224+
className={clsx(
225+
'group flex cursor-pointer items-start gap-2.5 rounded-[8px] p-1',
226+
'hover:bg-[var(--surface-6)] dark:hover:bg-[var(--surface-5)]',
227+
disabled && 'cursor-not-allowed opacity-50',
228+
isLocked && 'cursor-default',
229+
isHovered && 'is-hovered bg-[var(--surface-6)] dark:bg-[var(--surface-5)]'
230+
)}
231+
>
232+
<Button
233+
variant='3d'
234+
className='group-hover:-translate-y-0.5 group-[.is-hovered]:-translate-y-0.5 w-[22px] py-[2px] text-[11px] group-hover:text-[var(--text-primary)] group-[.is-hovered]:text-[var(--text-primary)] group-hover:shadow-[0_4px_0_0_rgba(48,48,48,1)] group-[.is-hovered]:shadow-[0_4px_0_0_rgba(48,48,48,1)]'
228235
>
229-
{/* Option number */}
230-
<div
231-
className={`flex h-5 w-5 flex-shrink-0 items-center justify-center font-medium font-mono text-[11px] ${
232-
isRejected ? 'text-[var(--text-tertiary)]' : 'text-[var(--text-secondary)]'
233-
}`}
234-
>
235-
{option.key}.
236-
</div>
236+
{option.key}
237+
</Button>
237238

238-
{/* Option content */}
239-
<div
240-
className={`min-w-0 flex-1 font-season text-[12px] leading-5 [&_code]:px-1 [&_code]:py-0.5 [&_code]:text-[11px] [&_p]:m-0 [&_p]:leading-5 ${
241-
isChosen
242-
? 'font-medium text-[var(--text-primary)]'
243-
: isRejected
244-
? 'text-[var(--text-tertiary)] line-through'
245-
: isHovered
246-
? 'font-medium text-[var(--text-primary)]'
247-
: 'text-[var(--text-secondary)]'
248-
}`}
249-
>
250-
<CopilotMarkdownRenderer content={option.title} />
251-
</div>
252-
</div>
253-
)
254-
})}
255-
</div>
239+
<span
240+
className={clsx(
241+
'min-w-0 flex-1 pt-0.5 font-season text-[12px] leading-5 text-[var(--text-tertiary)] group-hover:text-[var(--text-primary)] group-[.is-hovered]:text-[var(--text-primary)] [&_code]:px-1 [&_code]:py-0.5 [&_code]:text-[11px] [&_p]:m-0 [&_p]:leading-5',
242+
isRejected && 'text-[var(--text-tertiary)] line-through opacity-50'
243+
)}
244+
>
245+
<CopilotMarkdownRenderer content={option.title} />
246+
</span>
247+
</div>
248+
)
249+
})}
256250
</div>
257251
)
258252
}

0 commit comments

Comments
 (0)