This commit is contained in:
Timothy Jaeryang Baek committed 2026-06-06 09:44:59 +01:00
1 parent 697888f247
commit 768a19649b
5 files changed
+138 -41

No files matched your search

@@ -131,7 +131,7 @@
<div class="h-px bg-gray-100/50 dark:bg-white/3 mx-1 my-0.5"></div>
{:else}
<button
class="flex items-center gap-2 w-full h-7 px-2 rounded-xl text-xs transition-colors duration-75
class="flex items-center gap-2 w-full h-6 px-2 rounded-xl text-xs transition-colors duration-75
{item.active ? 'text-gray-900 dark:text-white bg-gray-50 dark:bg-white/5' : 'text-gray-500 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-white/5 hover:text-gray-900 dark:hover:text-white'}"
onclick={() => { item.onclick(); onclose(); }}
>
@@ -219,7 +219,7 @@
</div>
<!-- Settings - pinned bottom -->
<div class="relative px-1.5 pb-1.5 shrink-0">
<div class="relative px-1.5 pb-0.5 shrink-0">
<button
bind:this={menuButtonEl}
@@ -2,6 +2,7 @@
import { onMount } from 'svelte';
import { toolApprovalMode, type ToolApprovalMode } from '$lib/stores';
import { tooltip } from '$lib/tooltip';
import Icon from '../Icon.svelte';
interface Props {
onfiles: (files: FileList) => void;
@@ -9,6 +10,7 @@
let { onfiles }: Props = $props();
let open = $state(false);
let tab = $state<'' | 'tools'>('');
let btnEl: HTMLButtonElement | undefined = $state();
let menuEl: HTMLDivElement | undefined = $state();
let inputEl: HTMLInputElement | undefined = $state();
@@ -21,9 +23,16 @@
{ value: 'full', label: 'Full access', desc: 'All tool calls run without confirmation' },
];
const currentModeLabel = $derived(
modes.find((m) => m.value === $toolApprovalMode)?.label ?? 'Tool level'
);
function toggle() {
open = !open;
if (open) requestAnimationFrame(updatePosition);
if (open) {
tab = '';
requestAnimationFrame(updatePosition);
}
}
function updatePosition() {
@@ -57,10 +66,14 @@
function close() {
open = false;
ready = false;
tab = '';
}
$effect(() => {
if (!open) ready = false;
if (!open) {
ready = false;
tab = '';
}
});
</script>
@@ -94,38 +107,100 @@
<!-- svelte-ignore a11y_no_static_element_interactions -->
<div
bind:this={menuEl}
class="fixed z-[101] min-w-36 rounded-xl bg-white dark:bg-[#1a1a1a] border border-gray-150 dark:border-white/6 shadow-xl p-0.5"
class="fixed z-[101] w-48 rounded-xl bg-white dark:bg-[#1a1a1a] border border-gray-150 dark:border-white/6 shadow-xl p-0.5 overflow-hidden"
style="left: {pos.x}px; bottom: {pos.bottom}px; opacity: {ready ? 1 : 0}; pointer-events: {ready ? 'auto' : 'none'};"
onclick={(e) => e.stopPropagation()}
>
<button
class="flex items-center gap-2 w-full h-7 px-2 rounded-xl text-xs text-gray-500 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-white/5 hover:text-gray-900 dark:hover:text-white transition-colors duration-75"
onclick={triggerUpload}
>
<svg class="size-3.5 shrink-0" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round">
<path d="M21.44 11.05l-9.19 9.19a6 6 0 01-8.49-8.49l9.19-9.19a4 4 0 015.66 5.66l-9.2 9.19a2 2 0 01-2.83-2.83l8.49-8.48" />
</svg>
<span class="flex-1 text-left truncate">Attach files</span>
</button>
<div class="h-px bg-gray-100 dark:bg-white/4 mx-1 my-0.5"></div>
{#each modes as mode}
<button
class="flex items-center gap-2 w-full h-7 px-2 rounded-xl text-xs transition-colors duration-75
{$toolApprovalMode === mode.value
? 'text-gray-900 dark:text-white bg-gray-50 dark:bg-white/5'
: 'text-gray-500 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-white/5 hover:text-gray-900 dark:hover:text-white'}"
onclick={() => selectMode(mode.value)}
use:tooltip={{ content: mode.desc, placement: 'right' }}
>
<span class="flex-1 text-left truncate">{mode.label}</span>
{#if $toolApprovalMode === mode.value}
<svg class="w-3 h-3 shrink-0 text-gray-400 dark:text-gray-500" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
<polyline points="20 6 9 17 4 12" />
{#if tab === ''}
<!-- Main menu -->
<div class="plus-menu-slide-in-left">
<button
class="flex items-center gap-2 w-full h-7 px-2 rounded-xl text-xs text-gray-500 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-white/5 hover:text-gray-900 dark:hover:text-white transition-colors duration-75"
onclick={triggerUpload}
>
<svg class="size-3.5 shrink-0" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round">
<path d="M21.44 11.05l-9.19 9.19a6 6 0 01-8.49-8.49l9.19-9.19a4 4 0 015.66 5.66l-9.2 9.19a2 2 0 01-2.83-2.83l8.49-8.48" />
</svg>
{/if}
</button>
{/each}
<span class="flex-1 text-left truncate">Attach files</span>
</button>
<div class="h-px bg-gray-100/50 dark:bg-white/3 mx-1 my-0.5"></div>
<button
class="flex items-center gap-2 w-full h-7 px-2 rounded-xl text-xs text-gray-500 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-white/5 hover:text-gray-900 dark:hover:text-white transition-colors duration-75"
onclick={() => tab = 'tools'}
>
<Icon name="shield" size={14} />
<span class="flex-1 text-left truncate">Tool level</span>
<span class="text-[10px] text-gray-400 dark:text-gray-500 truncate max-w-16">{currentModeLabel}</span>
<Icon name="chevron-right" size={12} class="shrink-0 text-gray-400 dark:text-gray-500" />
</button>
</div>
{:else if tab === 'tools'}
<!-- Tool level submenu -->
<div class="plus-menu-slide-in-right">
<button
class="flex items-center gap-2 w-full h-7 px-2 rounded-xl text-xs text-gray-500 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-white/5 hover:text-gray-900 dark:hover:text-white transition-colors duration-75"
onclick={() => tab = ''}
>
<Icon name="chevron-left" size={12} />
<span class="flex-1 text-left font-medium">Tool level</span>
</button>
<div class="h-px bg-gray-100/50 dark:bg-white/3 mx-1 my-0.5"></div>
{#each modes as mode}
<button
class="flex items-center gap-2 w-full h-7 px-2 rounded-xl text-xs transition-colors duration-75
{$toolApprovalMode === mode.value
? 'text-gray-900 dark:text-white bg-gray-50 dark:bg-white/5'
: 'text-gray-500 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-white/5 hover:text-gray-900 dark:hover:text-white'}"
onclick={() => selectMode(mode.value)}
use:tooltip={{ content: mode.desc, placement: 'right' }}
>
<span class="flex-1 text-left truncate">{mode.label}</span>
{#if $toolApprovalMode === mode.value}
<svg class="w-3 h-3 shrink-0 text-gray-400 dark:text-gray-500" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
<polyline points="20 6 9 17 4 12" />
</svg>
{/if}
</button>
{/each}
</div>
{/if}
</div>
{/if}
<style>
@reference "../../../app.css";
.plus-menu-slide-in-left {
animation: slideFromLeft 0.15s ease-out;
}
.plus-menu-slide-in-right {
animation: slideFromRight 0.15s ease-out;
}
@keyframes slideFromLeft {
from {
opacity: 0;
transform: translateX(-12px);
}
to {
opacity: 1;
transform: translateX(0);
}
}
@keyframes slideFromRight {
from {
opacity: 0;
transform: translateX(12px);
}
to {
opacity: 1;
transform: translateX(0);
}
}
</style>
@@ -2,6 +2,7 @@
import { tick } from 'svelte';
import Icon from '../Icon.svelte';
import { fileIconName } from '$lib/utils/fileIcon';
import { openFileTab } from '$lib/stores';
interface Props {
content: string;
@@ -124,7 +125,7 @@
<!-- Bubble: right-aligned -->
<div class="flex justify-end">
<div class="max-w-[90%] px-4 py-2 rounded-3xl bg-gray-50 dark:bg-white/[0.06]">
<div class="text-[13px] leading-relaxed text-gray-900 dark:text-gray-200 whitespace-pre-wrap break-words">{#each parsedContent as segment}{#if segment.type === 'text'}{segment.value}{:else}<span class="inline-flex items-center gap-0.5 bg-blue-500/10 text-blue-400 rounded px-1.5 py-px mx-0.5 text-xs font-mono align-baseline"><Icon name={fileIconName(segment.label, 'file')} size={11} />{segment.label}</span>{/if}{/each}</div>
<div class="text-[13px] leading-relaxed text-gray-900 dark:text-gray-200 whitespace-pre-wrap break-words">{#each parsedContent as segment}{#if segment.type === 'text'}{segment.value}{:else}<button class="inline-flex items-center gap-0.5 bg-blue-500/10 text-blue-400 rounded px-1.5 py-px mx-0.5 text-xs font-mono align-baseline border-none cursor-pointer hover:bg-blue-500/20 transition-colors" title={segment.path} onclick={(e) => { e.preventDefault(); openFileTab(segment.path); }}><Icon name={fileIconName(segment.label, 'file')} size={11} />{segment.label}</button>{/if}{/each}</div>
</div>
</div>
{#if siblingTotal > 1 || onedit}
@@ -1,5 +1,6 @@
<script lang="ts">
import type { Token } from 'marked';
import { openFileTab } from '$lib/stores';
interface Props {
items: Token[];
@@ -53,13 +54,31 @@
>{('text' in item) ? item.text : item.raw}</code>
{:else if item.type === 'link'}
<a href={('href' in item) ? item.href : '#'} target="_blank" rel="noopener noreferrer">
{#if 'tokens' in item && item.tokens}
<svelte:self items={item.tokens} />
{:else}
{('text' in item) ? item.text : item.raw}
{/if}
</a>
{@const href = ('href' in item) ? item.href : ''}
{#if href?.startsWith('file:///')}
{@const filePath = decodeURIComponent(href.replace('file://', ''))}
{@const fileName = filePath.split('/').pop() || filePath}
<!-- svelte-ignore a11y_no_static_element_interactions -->
<button
class="inline-flex items-center gap-1 px-1.5 py-px rounded-md text-[13px] leading-snug font-medium cursor-pointer border-none bg-blue-500/10 text-blue-500 dark:text-blue-400 hover:bg-blue-500/12 transition-colors align-baseline"
title={filePath}
onclick={(e) => { e.preventDefault(); openFileTab(filePath); }}
>
<svg class="w-3.5 h-3.5 shrink-0" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round">
<path d="M9 1.5H4a1.5 1.5 0 0 0-1.5 1.5v10A1.5 1.5 0 0 0 4 14.5h8a1.5 1.5 0 0 0 1.5-1.5V6L9 1.5Z" />
<path d="M9 1.5V6h4.5" />
</svg>
{fileName}
</button>
{:else}
<a href={href || '#'} target="_blank" rel="noopener noreferrer">
{#if 'tokens' in item && item.tokens}
<svelte:self items={item.tokens} />
{:else}
{('text' in item) ? item.text : item.raw}
{/if}
</a>
{/if}
{:else if item.type === 'image'}
<img
@@ -82,3 +101,5 @@
{/if}
{/if}
{/each}