|
25 | 25 | import ChevronDownIcon from '~icons/lucide/chevron-down'; |
26 | 26 | import RefreshCwIcon from '~icons/lucide/refresh-cw'; |
27 | 27 | import PencilIcon from '~icons/lucide/pencil'; |
28 | | - import StarIcon from '~icons/lucide/star'; |
29 | 28 | import * as DropdownMenu from '$lib/components/ui/dropdown-menu'; |
30 | 29 | import { AnnotationSchema, type Annotation } from '$lib/types'; |
31 | 30 | import ExternalLinkIcon from '~icons/lucide/external-link'; |
|
187 | 186 |
|
188 | 187 | let isEditing = $state(false); |
189 | 188 | let editedContent = $state(''); |
190 | | - let isStarred = $state<boolean>(false); |
191 | | -
|
192 | | - $effect(() => { |
193 | | - isStarred = message.starred ?? false; |
194 | | - }); |
195 | 189 |
|
196 | 190 | function startEditing() { |
197 | 191 | editedContent = message.content; |
|
280 | 274 | } |
281 | 275 | } |
282 | 276 | } |
283 | | -
|
284 | | - async function toggleStarred() { |
285 | | - if (!session.current?.session.token) return; |
286 | | - if (message.role !== 'assistant') return; |
287 | | -
|
288 | | - const previous = isStarred; |
289 | | - isStarred = !isStarred; |
290 | | -
|
291 | | - try { |
292 | | - const res = await fetch(api.messages.setStarred.url, { |
293 | | - method: 'POST', |
294 | | - headers: { 'Content-Type': 'application/json' }, |
295 | | - body: JSON.stringify({ |
296 | | - action: 'setStarred', |
297 | | - messageId: message.id, |
298 | | - starred: isStarred, |
299 | | - }), |
300 | | - }); |
301 | | -
|
302 | | - if (!res.ok) { |
303 | | - console.error('Failed to update starred state'); |
304 | | - isStarred = previous; |
305 | | - return; |
306 | | - } |
307 | | -
|
308 | | - invalidateQueryPattern(api.messages.getAllFromConversation.url); |
309 | | - } catch (e) { |
310 | | - console.error('Error updating starred state:', e); |
311 | | - isStarred = previous; |
312 | | - } |
313 | | - } |
314 | 277 | </script> |
315 | 278 |
|
316 | 279 | {#if message.role !== 'system' && !(message.role === 'assistant' && message.content.length === 0 && message.reasoning?.length === 0 && !message.error)} |
|
518 | 481 | {/snippet} |
519 | 482 | {message.role === 'user' ? 'Branch and regenerate message' : 'Branch off this message'} |
520 | 483 | </Tooltip> |
521 | | - {#if message.role === 'assistant' && message.content.length > 0 && !message.error} |
522 | | - <Tooltip> |
523 | | - {#snippet trigger(tooltip)} |
524 | | - <Button |
525 | | - size="icon" |
526 | | - variant="ghost" |
527 | | - class="order-1 size-7" |
528 | | - onclick={toggleStarred} |
529 | | - {...tooltip.trigger} |
530 | | - > |
531 | | - <StarIcon |
532 | | - class={cn('size-4', { |
533 | | - 'fill-yellow-400 text-yellow-400': isStarred, |
534 | | - 'text-muted-foreground/60': !isStarred, |
535 | | - })} |
536 | | - /> |
537 | | - </Button> |
538 | | - {/snippet} |
539 | | - {isStarred ? 'Unstar message' : 'Star message'} |
540 | | - </Tooltip> |
541 | | - {/if} |
| 484 | + |
542 | 485 | {#if message.content.length > 0} |
543 | 486 | <Tooltip> |
544 | 487 | {#snippet trigger(tooltip)} |
|
576 | 519 | {#if message.role === 'assistant'} |
577 | 520 | <!-- Desktop: Show all metadata inline --> |
578 | 521 | <div class="hidden items-center gap-2 md:flex"> |
579 | | - {#if message.modelId !== undefined} |
| 522 | + {#if message.modelId} |
580 | 523 | {@const modelName = message.modelId.split('/').pop() || message.modelId} |
581 | 524 | <span class="text-muted-foreground text-xs">{modelName}</span> |
582 | 525 | {/if} |
|
625 | 568 | </div> |
626 | 569 | <!-- Mobile: Compact metadata in a single info chip --> |
627 | 570 | <div class="flex items-center gap-1.5 md:hidden"> |
628 | | - {#if message.modelId !== undefined} |
| 571 | + {#if message.modelId} |
629 | 572 | {@const modelName = message.modelId.split('/').pop() || message.modelId} |
630 | 573 | <span class="text-muted-foreground max-w-[100px] truncate text-xs">{modelName}</span> |
631 | 574 | {/if} |
|
0 commit comments