|
271 | 271 | {#if isRouter} |
272 | 272 | <DropdownMenu.Root bind:open={isOpen} onOpenChange={handleOpenChange}> |
273 | 273 | <DropdownMenu.Trigger |
| 274 | + class={cn( |
| 275 | + `inline-grid cursor-pointer grid-cols-[1fr_auto_1fr] items-center gap-1.5 rounded-sm bg-muted-foreground/10 px-1.5 py-1 text-xs transition hover:text-foreground focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-60`, |
| 276 | + !isCurrentModelInCache |
| 277 | + ? 'bg-red-400/10 !text-red-400 hover:bg-red-400/20 hover:text-red-400' |
| 278 | + : forceForegroundText |
| 279 | + ? 'text-foreground' |
| 280 | + : isHighlightedCurrentModelActive |
| 281 | + ? 'text-foreground' |
| 282 | + : 'text-muted-foreground', |
| 283 | + isOpen ? 'text-foreground' : '' |
| 284 | + )} |
| 285 | + style="max-width: min(calc(100cqw - 9rem), 20rem)" |
274 | 286 | disabled={disabled || updating} |
275 | | - onclick={(e) => { |
276 | | - e.preventDefault(); |
277 | | - e.stopPropagation(); |
278 | | - }} |
279 | 287 | > |
280 | | - <button |
281 | | - type="button" |
282 | | - class={cn( |
283 | | - `inline-grid cursor-pointer grid-cols-[1fr_auto_1fr] items-center gap-1.5 rounded-sm bg-muted-foreground/10 px-1.5 py-1 text-xs transition hover:text-foreground focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-60`, |
284 | | - !isCurrentModelInCache |
285 | | - ? 'bg-red-400/10 !text-red-400 hover:bg-red-400/20 hover:text-red-400' |
286 | | - : forceForegroundText |
287 | | - ? 'text-foreground' |
288 | | - : isHighlightedCurrentModelActive |
289 | | - ? 'text-foreground' |
290 | | - : 'text-muted-foreground', |
291 | | - isOpen ? 'text-foreground' : '' |
292 | | - )} |
293 | | - style="max-width: min(calc(100cqw - 9rem), 20rem)" |
294 | | - disabled={disabled || updating} |
295 | | - > |
296 | | - <Package class="h-3.5 w-3.5" /> |
297 | | - |
298 | | - {#if selectedOption} |
299 | | - <Tooltip.Root> |
300 | | - <Tooltip.Trigger class="min-w-0 overflow-hidden"> |
301 | | - <ModelId modelId={selectedOption.model} class="min-w-0" showOrgName /> |
302 | | - </Tooltip.Trigger> |
303 | | - |
304 | | - <Tooltip.Content> |
305 | | - <p class="font-mono">{selectedOption.model}</p> |
306 | | - </Tooltip.Content> |
307 | | - </Tooltip.Root> |
308 | | - {:else} |
309 | | - <span class="min-w-0 font-medium">Select model</span> |
310 | | - {/if} |
311 | | - |
312 | | - {#if updating || isLoadingModel} |
313 | | - <Loader2 class="h-3 w-3.5 animate-spin" /> |
314 | | - {:else} |
315 | | - <ChevronDown class="h-3 w-3.5" /> |
316 | | - {/if} |
317 | | - </button> |
| 288 | + <Package class="h-3.5 w-3.5" /> |
| 289 | + |
| 290 | + {#if selectedOption} |
| 291 | + <Tooltip.Root> |
| 292 | + <Tooltip.Trigger> |
| 293 | + <!-- prevent another nested button element --> |
| 294 | + {#snippet child({ props })} |
| 295 | + <ModelId |
| 296 | + modelId={selectedOption.model} |
| 297 | + class="min-w-0 overflow-hidden" |
| 298 | + showOrgName |
| 299 | + {...props} |
| 300 | + /> |
| 301 | + {/snippet} |
| 302 | + </Tooltip.Trigger> |
| 303 | + |
| 304 | + <Tooltip.Content> |
| 305 | + <p class="font-mono">{selectedOption.model}</p> |
| 306 | + </Tooltip.Content> |
| 307 | + </Tooltip.Root> |
| 308 | + {:else} |
| 309 | + <span class="min-w-0 font-medium">Select model</span> |
| 310 | + {/if} |
| 311 | + |
| 312 | + {#if updating || isLoadingModel} |
| 313 | + <Loader2 class="h-3 w-3.5 animate-spin" /> |
| 314 | + {:else} |
| 315 | + <ChevronDown class="h-3 w-3.5" /> |
| 316 | + {/if} |
318 | 317 | </DropdownMenu.Trigger> |
319 | 318 |
|
320 | 319 | <DropdownMenu.Content |
|
407 | 406 |
|
408 | 407 | {#if selectedOption} |
409 | 408 | <Tooltip.Root> |
410 | | - <Tooltip.Trigger class="min-w-0 overflow-hidden"> |
411 | | - <ModelId modelId={selectedOption.model} class="min-w-0" showOrgName /> |
| 409 | + <Tooltip.Trigger> |
| 410 | + <!-- prevent another nested button element --> |
| 411 | + {#snippet child({ props })} |
| 412 | + <ModelId |
| 413 | + modelId={selectedOption.model} |
| 414 | + class="min-w-0 overflow-hidden" |
| 415 | + showOrgName |
| 416 | + {...props} |
| 417 | + /> |
| 418 | + {/snippet} |
412 | 419 | </Tooltip.Trigger> |
413 | 420 |
|
414 | 421 | <Tooltip.Content> |
|
0 commit comments