Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

refactor(chat): migrate components to Svelte 5 runes and callback props, and render katex math through the vendored marked

nirholas1638ffc94876
diff --git a/chat/src/AgentPicker.svelte b/chat/src/AgentPicker.svelte
index b33131f94..e49503706 100644
--- a/chat/src/AgentPicker.svelte
+++ b/chat/src/AgentPicker.svelte
@@ -1,34 +1,33 @@
<script>
- import { createEventDispatcher } from 'svelte';
import { localAgentId, activeAgent, agentLibraryUrl } from './stores.js';
import { focusOnMount } from './actions.js';
import { t } from './i18n.js';
- const dispatch = createEventDispatcher();
+ let { onpick } = $props();
- let query = '';
- let myAgents = [];
- let marketAgents = [];
- let libraryAgents = [];
- let loadingMine = false;
- let loadingMarket = false;
- let loadingLibrary = false;
+ let query = $state('');
+ let myAgents = $state([]);
+ let marketAgents = $state([]);
+ let libraryAgents = $state([]);
+ let loadingMine = $state(false);
+ let loadingMarket = $state(false);
+ let loadingLibrary = $state(false);
let debounceTimer;
// Marketplace filter/pagination state
- let marketSort = 'popular';
+ let marketSort = $state('popular');
let marketCategory = '';
let marketCursor = null;
- let marketHasMore = false;
- let marketError = false;
+ let marketHasMore = $state(false);
+ let marketError = $state(false);
// Detail preview state
- let previewAgent = null;
- let previewLoading = false;
+ let previewAgent = $state(null);
+ let previewLoading = $state(false);
// Library pagination + error state
- let libraryLimit = 60;
- let libraryError = false;
+ let libraryLimit = $state(60);
+ let libraryError = $state(false);
// Normalizes a pai-chat / lobehub library agent (index entry) into the local agent shape.
function normalizeLibraryAgent(item) {
@@ -127,14 +126,14 @@
loadingMine = false;
}
- $: filteredMine = query
+ let filteredMine = $derived(query
? myAgents.filter((a) =>
(a.name || '').toLowerCase().includes(query.toLowerCase()) ||
(a.description || '').toLowerCase().includes(query.toLowerCase()),
)
- : myAgents;
+ : myAgents);
- $: filteredLibrary = (query
+ let filteredLibrary = $derived((query
? libraryAgents.filter((a) => {
const q = query.toLowerCase();
return (
@@ -145,7 +144,7 @@
);
})
: libraryAgents
- ).slice(0, libraryLimit);
+ ).slice(0, libraryLimit));
function onInput() {
clearTimeout(debounceTimer);
@@ -185,7 +184,7 @@
const detail = await loadLibraryAgentDetail(agent);
localAgentId.set(detail.id);
activeAgent.set(detail);
- dispatch('pick', detail);
+ onpick?.(detail);
return;
}
try {
@@ -195,7 +194,7 @@
const detail = json.agent ?? json.data?.agent ?? agent;
localAgentId.set(detail.id);
activeAgent.set(detail);
- dispatch('pick', detail);
+ onpick?.(detail);
return;
}
} catch {}
@@ -206,19 +205,19 @@
const detail = json.data?.agent ?? agent;
localAgentId.set(detail.id);
activeAgent.set(detail);
- dispatch('pick', detail);
+ onpick?.(detail);
return;
}
} catch {}
localAgentId.set(agent.id);
activeAgent.set(agent);
- dispatch('pick', agent);
+ onpick?.(agent);
}
function clear() {
localAgentId.set('');
activeAgent.set(null);
- dispatch('pick', null);
+ onpick?.(null);
}
function initials(name) {
@@ -241,7 +240,7 @@
<input
type="text"
bind:value={query}
- on:input={onInput}
+ oninput={onInput}
placeholder={$t('searchAgents')}
class="w-full rounded-lg border border-gray-200 px-3 py-2 text-[13px] outline-none focus:border-indigo-400"
use:focusOnMount
@@ -251,7 +250,7 @@
{#if $localAgentId}
<button
class="text-left text-[12px] text-slate-400 underline hover:text-slate-600"
- on:click={clear}
+ onclick={clear}
>{$t('removeAgent')}</button>
{:else}
<span></span>
@@ -280,7 +279,7 @@
<button
class="flex flex-col items-center gap-1.5 rounded-xl p-2 text-center transition hover:bg-gray-50
{$localAgentId === agent.id ? 'bg-indigo-50 ring-2 ring-indigo-300' : 'ring-1 ring-gray-100'}"
- on:click={() => pick(agent)}
+ onclick={() => pick(agent)}
title={agent.description || agent.name}
>
{#if agent.thumbnail_url}
@@ -311,7 +310,7 @@
<select
class="rounded border border-gray-200 px-1.5 py-0.5 text-[11px] text-slate-600 outline-none"
bind:value={marketSort}
- on:change={() => searchMarket(query, true)}
+ onchange={() => searchMarket(query, true)}
>
<option value="popular">Popular</option>
<option value="recent">Recent</option>
@@ -324,14 +323,14 @@
<p class="text-center text-[12px] text-slate-400 py-3">{$t('loading')}</p>
{:else if marketError}
<p class="text-[12px] text-slate-400 py-2">
- Failed to load. <button class="underline" on:click={() => searchMarket(query, true)}>retry</button>
+ Failed to load. <button class="underline" onclick={() => searchMarket(query, true)}>retry</button>
</p>
{:else if marketAgents.length === 0}
<p class="text-[12px] text-slate-400 py-2">{$t('noAgentsFound')}</p>
{:else if previewAgent}
<!-- Detail preview panel -->
<div class="rounded-xl border border-gray-100 bg-gray-50 p-3">
- <button class="mb-2 text-[11px] text-slate-400 hover:text-slate-600" on:click={() => previewAgent = null}>
+ <button class="mb-2 text-[11px] text-slate-400 hover:text-slate-600" onclick={() => previewAgent = null}>
← Back
</button>
<div class="flex items-start gap-3">
@@ -360,7 +359,7 @@
{/if}
<button
class="mt-3 w-full rounded-lg bg-indigo-600 px-3 py-2 text-[13px] font-medium text-white hover:bg-indigo-700"
- on:click={() => pick(previewAgent)}
+ onclick={() => pick(previewAgent)}
>
Use this agent
</button>
@@ -371,7 +370,7 @@
<button
class="flex flex-col items-center gap-1.5 rounded-xl p-2 text-center transition hover:bg-gray-50
{$localAgentId === agent.id ? 'bg-indigo-50 ring-2 ring-indigo-300' : 'ring-1 ring-gray-100'}"
- on:click={() => openPreview(agent)}
+ onclick={() => openPreview(agent)}
title={agent.description || agent.name}
>
{#if agent.thumbnail_url}
@@ -387,7 +386,7 @@
<button
class="mt-2 w-full rounded-lg border border-slate-200 py-1.5 text-[12px] text-slate-500 hover:bg-gray-50"
disabled={loadingMarket}
- on:click={loadMoreMarket}
+ onclick={loadMoreMarket}
>
{loadingMarket ? 'Loading…' : 'Load more'}
</button>
@@ -410,7 +409,7 @@
<button
class="flex flex-col items-center gap-1.5 rounded-xl p-2 text-center transition hover:bg-gray-50
{$localAgentId === agent.id ? 'bg-indigo-50 ring-2 ring-indigo-300' : 'ring-1 ring-gray-100'}"
- on:click={() => pick(agent)}
+ onclick={() => pick(agent)}
title={agent.description || agent.name}
>
{#if agent.thumbnail_url}
@@ -435,7 +434,7 @@
{#if !query && libraryAgents.length > filteredLibrary.length}
<button
class="mt-1.5 w-full rounded-lg border border-slate-200 py-1.5 text-[12px] text-slate-500 hover:bg-gray-50"
- on:click={loadMoreLibrary}
+ onclick={loadMoreLibrary}
>
Show more ({libraryAgents.length - filteredLibrary.length} hidden)
</button>
diff --git a/chat/src/AgentSettingsModal.svelte b/chat/src/AgentSettingsModal.svelte
index 2a1441696..bd6752913 100644
--- a/chat/src/AgentSettingsModal.svelte
+++ b/chat/src/AgentSettingsModal.svelte
@@ -1,25 +1,32 @@
-<script>
+<script lang="ts">
+
import { activeAgent, params, toolSchema } from './stores.js';
import Modal from './Modal.svelte';
- export let open = false;
- export let onSave = null;
-
- let draft = {};
- $: if (open && $activeAgent) {
- draft = {
- system_prompt: $activeAgent.system_prompt || '',
- greeting: $activeAgent.greeting || '',
- preferred_model: $activeAgent.preferred_model || null,
- temperature: $activeAgent.temperature ?? $params.temperature,
- maxTokens: $activeAgent.maxTokens ?? $params.maxTokens,
- tools: [...($activeAgent.tools || [])],
- };
+ interface Props {
+ open?: boolean;
+ onSave?: any;
}
- $: allTools = ($toolSchema || []).flatMap((g) =>
+ let { open = $bindable(false), onSave = null }: Props = $props();
+
+ let draft = $state({});
+ $effect.pre(() => {
+ if (open && $activeAgent) {
+ draft = {
+ system_prompt: $activeAgent.system_prompt || '',
+ greeting: $activeAgent.greeting || '',
+ preferred_model: $activeAgent.preferred_model || null,
+ temperature: $activeAgent.temperature ?? $params.temperature,
+ maxTokens: $activeAgent.maxTokens ?? $params.maxTokens,
+ tools: [...($activeAgent.tools || [])],
+ };
+ }
+ });
+
+ let allTools = $derived(($toolSchema || []).flatMap((g) =>
(g.schema || []).map((t) => ({ name: t.function.name, groupName: g.name }))
- );
+ ));
function toggleTool(name) {
if (draft.tools.includes(name)) {
@@ -61,7 +68,7 @@
rows="5"
class="rounded-lg border border-slate-200 px-3 py-2 text-[13px] text-slate-800 resize-y outline-none focus:border-indigo-400"
placeholder="You are a helpful assistant..."
- />
+ ></textarea>
</label>
<label class="flex flex-col gap-1.5 text-[12px] font-medium text-slate-600">
@@ -71,7 +78,7 @@
rows="2"
class="rounded-lg border border-slate-200 px-3 py-2 text-[13px] text-slate-800 resize-y outline-none focus:border-indigo-400"
placeholder="Hello! How can I help you today?"
- />
+ ></textarea>
</label>
<label class="flex flex-col gap-1.5 text-[12px] font-medium text-slate-600">
@@ -110,7 +117,7 @@
<input
type="checkbox"
checked={draft.tools.includes(tool.name)}
- on:change={() => toggleTool(tool.name)}
+ onchange={() => toggleTool(tool.name)}
class="accent-indigo-500"
/>
{tool.name}
@@ -122,13 +129,13 @@
<div class="flex justify-end gap-2 pt-2">
<button
- on:click={() => (open = false)}
+ onclick={() => (open = false)}
class="rounded-lg border border-slate-200 px-4 py-1.5 text-[13px] text-slate-600 hover:bg-slate-50"
>
Cancel
</button>
<button
- on:click={save}
+ onclick={save}
class="rounded-lg bg-indigo-500 px-4 py-1.5 text-[13px] font-medium text-white hover:bg-indigo-600"
>
Save
diff --git a/chat/src/AgentWallet.svelte b/chat/src/AgentWallet.svelte
index 77afe7fb4..45a605570 100644
--- a/chat/src/AgentWallet.svelte
+++ b/chat/src/AgentWallet.svelte
@@ -1,20 +1,26 @@
-<script>
+<script lang="ts">
+
// The wallet identity of the agent you're chatting with. Tip it for a good
// answer, copy its address, or open its full wallet on three.ws. Thin Svelte
// wrapper over the shared portable wallet (one module, mounted everywhere the
// avatar appears) so the chat never forks the wallet logic. Reads only public
// data from the CORS:* wallet-embed endpoint; it is the visitor view by
// construction (no owner controls in chat).
- import { onMount, onDestroy } from 'svelte';
+ import { onMount, onDestroy, untrack } from 'svelte';
import { mountPortableWallet } from '$shared/portable-wallet.js';
- export let agentId = '';
- /** 'chip' toggles a popover; 'card' renders the wallet open inline. */
- export let variant = 'chip';
+
+ interface Props {
+ agentId?: string;
+ /** 'chip' toggles a popover; 'card' renders the wallet open inline. */
+ variant?: string;
+ }
+
+ let { agentId = '', variant = 'chip' }: Props = $props();
- let host;
+ let host = $state();
let mount = null;
- let mountedId = null;
+ let mountedId = $state(null);
function remount(id) {
if (mount) {
@@ -38,7 +44,10 @@
onDestroy(() => { try { mount?.destroy(); } catch { /* gone */ } });
// Re-mount when the active agent changes.
- $: if (host && agentId !== mountedId) remount(agentId);
+ $effect.pre(() => {
+ const id = agentId;
+ if (host && id !== mountedId) untrack(() => remount(id));
+ });
</script>
<span class="agent-wallet" bind:this={host}></span>
diff --git a/chat/src/App.svelte b/chat/src/App.svelte
index bc48a63a2..c67142321 100644
--- a/chat/src/App.svelte
+++ b/chat/src/App.svelte
@@ -1,11 +1,13 @@
<script>
+
import { v4 as uuidv4 } from 'uuid';
- import { onMount, tick } from 'svelte';
+ import { onMount, tick, untrack } from 'svelte';
import { fade, fly } from 'svelte/transition';
import { complete, generateImage } from './convo.js';
import KnobsSidebar from './KnobsSidebar.svelte';
import Button from './Button.svelte';
- import { marked } from 'marked';
+ // Same module instance the Markdown renderer lexes with, so the katex extension applies.
+ import { marked } from './svelte-marked/markdown/marked.esm.js';
import markedKatex from './marked-katex-extension';
import { persisted } from './localstorage.js';
@@ -86,17 +88,9 @@
})
);
- // The chat app's own marketing pages were removed; every surface they
- // covered is published for real at the site root. Old links still resolve:
- // the hash is mapped to the live page and the location is replaced, so the
- // dead route never occupies a history entry.
- $: {
- const retired = siteRouteFor($route);
- if (retired) window.location.replace(retired);
- }
const convoId = persisted('convoId');
- let convos = {};
+ let convos = $state({});
// Initialize history and convo with a blank slate while we wait for IndexedDB to start
const defaultConvo = {
@@ -108,9 +102,9 @@
tools: [],
agentId: null,
};
- let convo = defaultConvo;
+ let convo = $state(defaultConvo);
- let db;
+ let db = $state();
const request = indexedDB.open('threews-chat', 3);
request.onupgradeneeded = (event) => {
const db = event.target.result;
@@ -171,7 +165,7 @@
const transaction = db.transaction(['messages'], 'readwrite');
const store = transaction.objectStore('messages');
- store.put(msg);
+ store.put($state.snapshot(msg));
if (opts.syncToServer && $syncServer.token && $syncServer.password) {
sendSingleItem($syncServer.address, $syncServer.token, {
@@ -348,7 +342,7 @@
versions,
};
- store.put(convoConvertedOrNot);
+ store.put($state.snapshot(convoConvertedOrNot));
if (
opts.syncToServer &&
@@ -412,55 +406,20 @@
};
}
- let historyBuckets = [];
- $: {
- historyBuckets = [];
- for (const entry of Object.values(convos).sort((a, b) => b.time - a.time)) {
- if (entry.shared || isNaN(new Date(entry.time).getTime())) {
- continue;
- }
- const bucketKey = getRelativeDate(entry.time);
+ let searchQuery = $state('');
- const existingBucket = historyBuckets.find((bucket) => bucket.relativeDate === bucketKey);
- if (!existingBucket) {
- historyBuckets.push({ relativeDate: bucketKey, convos: [entry] });
- } else {
- existingBucket.convos.push(entry);
- }
- }
- historyBuckets.sort((a, b) => b.convos[0].time - a.convos[0].time);
- }
+ let generating = $state(false);
+ let editingTitleId = $state(null);
- let searchQuery = '';
- $: filteredConvos = searchQuery.trim()
- ? Object.values(convos).filter(
- (c) =>
- !c.shared &&
- (c.messages.some(
- (m) =>
- typeof m.content === 'string' &&
- m.content.toLowerCase().includes(searchQuery.toLowerCase())
- ) ||
- (c.title || '').toLowerCase().includes(searchQuery.toLowerCase()) ||
- (c.messages.find((m) => m.role === 'user')?.content || '')
- .toLowerCase()
- .includes(searchQuery.toLowerCase()))
- )
- : null;
+ let historyOpen = $state(false);
+ let knobsOpen = $state(false);
- let generating = false;
- $: $generatingStore = generating;
- let editingTitleId = null;
+ let activeToolcall = $state(null);
- let historyOpen = false;
- let knobsOpen = false;
-
- let activeToolcall = null;
-
- let scrollableEl = null;
- let previousScrollTop = 0;
- let autoscrollCanceled;
+ let scrollableEl = $state(null);
+ let previousScrollTop = $state(0);
+ let autoscrollCanceled = $state();
let scrollAnimFrame = null;
function scrollToBottom() {
if (!scrollableEl) return;
@@ -484,22 +443,21 @@
scrollAnimFrame = requestAnimationFrame(step);
}
}
- let textareaEls = [];
- let inputTextareaEl;
+ let textareaEls = $state([]);
+ let inputTextareaEl = $state();
- let handleFileDrop;
+ let handleFileDrop = $state();
- let innerWidth = window.innerWidth;
+ let innerWidth = $state(window.innerWidth);
- $: splitView = innerWidth > 1215 && activeToolcall && !$config.explicitToolView;
let settingsModalOpen = false;
- let toolcallModalOpen = false;
+ let toolcallModalOpen = $state(false);
let thinkingStartTime = null;
let thinkingInterval = null;
- let tree;
+ let tree = $state();
function handleAbort() {
if (!generating) {
@@ -1184,11 +1142,6 @@
saveConversation(convo);
}
- $: if ($activeAgent !== undefined) {
- const agentId = $activeAgent?.id ?? null;
- switchToAgentConversation(agentId);
- if ($activeAgent) applyAgentToConvo($activeAgent);
- }
// Split history at this point:
function saveVersion(message, i) {
@@ -1200,8 +1153,8 @@
}
const nullIdx = convo.versions[message.vid].findIndex((v) => v === null);
convo.versions[message.vid][nullIdx] = [
- structuredClone(message),
- ...structuredClone(convo.messages.slice(i + 1)).map((m) => {
+ $state.snapshot(message),
+ ...$state.snapshot(convo.messages.slice(i + 1)).map((m) => {
return {
...m,
editing: false,
@@ -1320,7 +1273,7 @@
return ok;
}
- let exportOpen = false;
+ let exportOpen = $state(false);
function downloadFile(content, filename, type) {
const blob = new Blob([content], { type });
@@ -1428,7 +1381,7 @@
}
}
- let models = [...BUILTIN_MODELS];
+ let models = $state([...BUILTIN_MODELS]);
let loading = false;
@@ -1441,11 +1394,11 @@
}
}
- let installToastMsg = '';
+ let installToastMsg = $state('');
// Token-gate enforcement state
- let gateState = null; // null | 'pending' | 'checking' | 'denied'
- let gateError = '';
+ let gateState = $state(null); // null | 'pending' | 'checking' | 'denied'
+ let gateError = $state('');
let activeGate = null; // { id, s, sl }
async function verifyGate(walletType) {
@@ -1506,7 +1459,7 @@
}
}
- let choiceHandler;
+ let choiceHandler = $state();
async function makeChoice() {
return new Promise((resolve) => {
choiceHandler = (choice) => {
@@ -1515,17 +1468,17 @@
});
}
- let isChoosing = false;
- let question = '';
- let choices = [];
- let chose = null; // index
+ let isChoosing = $state(false);
+ let question = $state('');
+ let choices = $state([]);
+ let chose = $state(null); // index
// Wallet transaction approval gate. Tool bodies call
// window.requestWalletApproval(details) which resolves on Approve and rejects
// on Reject, pausing the transaction until the user confirms.
- let txApprovalDetails = null;
- let txApprovalResolve = null;
- let txApprovalReject = null;
+ let txApprovalDetails = $state(null);
+ let txApprovalResolve = $state(null);
+ let txApprovalReject = $state(null);
export async function choose(newQuestion, newChoices) {
chose = null;
question = newQuestion;
@@ -1551,18 +1504,7 @@
return choseValue;
}
- $: window.convo = convo;
- $: window.saveConversation = saveConversation;
- $: {
- // Only a white-labeled brand renames the tab. On the stock build the title
- // stays the one index.html declares, so the tab, the share card and the
- // site's page index all say the same thing about /chat.
- if ($brandConfig.name && $brandConfig.name !== STOCK_BRAND_NAME) {
- document.title = $brandConfig.name;
- }
- document.documentElement.style.setProperty('--accent', $brandConfig.accent_color);
- }
function syncRouteFromHash() {
const hash = window.location.hash.slice(1) || 'chat';
@@ -1873,50 +1815,26 @@
// For displaying compact tools, we need to collapse sequences of Assistant and Tool messages into a single message
// inside which we'll display all the tool calls.
// Returns a list of ranges of messages containing the start and end indices of messages that should be collapsed.
- let collapsedRanges = [];
- $: if (!$config.explicitToolView) {
- collapsedRanges = [];
- let range = { starti: null, endi: null };
- for (let i = convo.messages.length - 1; i >= 0; i--) {
- if (
- convo.messages[i].role === 'tool' ||
- (convo.messages[i].role === 'assistant' &&
- convo.messages[i].toolcalls &&
- i !== convo.messages.length - 1)
- ) {
- if (range.endi === null) {
- range.endi = i + 1;
- }
- } else {
- if (range.endi !== null) {
- range.starti = i + 1;
- collapsedRanges.push(range);
- collapsedRanges = collapsedRanges;
- range = { starti: null, endi: null };
- }
- }
- }
- }
- let savedTime = 0;
- let video;
+ let savedTime = $state(0);
+ let video = $state();
// Floating 3D agent
- let agentEl;
- let agentReady = false;
- let agentPendingSpeak = null;
- let agentVisible = true;
- let agentScriptLoaded = false;
+ let agentEl = $state();
+ let agentReady = $state(false);
+ let agentPendingSpeak = $state(null);
+ let agentVisible = $state(true);
+ let agentScriptLoaded = $state(false);
let prevThoughtBubbleActive = false;
- let thinkingTransitioning = false;
+ let thinkingTransitioning = $state(false);
let agentPickerOpen = false;
- let showAgentSettings = false;
+ let showAgentSettings = $state(false);
// Walk while tokens are actively arriving. `generating` flips false the
// instant the network stream ends, but we want the avatar to keep walking
// until rendering settles: a 600ms tail bridges micro-pauses between tokens
// and the gap between last token and DOM paint.
- let tokensFlowing = false;
+ let tokensFlowing = $state(false);
let _tokensFlowingTimer = null;
function pulseTokens() {
tokensFlowing = true;
@@ -1926,25 +1844,7 @@
// Live thought bubble above the avatar: streams the active reasoning,
// then collapses to a "Thought for Xs" summary while the response streams.
- let thoughtBubbleEl;
- $: thinkingMessage = (() => {
- const msgs = convo?.messages;
- if (!msgs?.length || !generating) return null;
- const last = msgs[msgs.length - 1];
- if (!last || last.role !== 'assistant' || !last.reasoning) return null;
- return last;
- })();
- $: thoughtBubbleActive = !!thinkingMessage?.thinking;
- $: thoughtBubbleText = thinkingMessage?.thoughts || '';
- $: thoughtBubbleSeconds = thinkingMessage?.thinkingTime
- ? thinkingMessage.thinkingTime < 1 ? '<1' : Math.ceil(thinkingMessage.thinkingTime)
- : 0;
- $: if (thoughtBubbleEl && thoughtBubbleActive && thoughtBubbleText) {
- // Auto-scroll to bottom as tokens stream in
- queueMicrotask(() => {
- if (thoughtBubbleEl) thoughtBubbleEl.scrollTop = thoughtBubbleEl.scrollHeight;
- });
- }
+ let thoughtBubbleEl = $state();
// Drag state for the floating agent widget
/** @type {{ x: number | null, y: number | null }} */
@@ -1954,7 +1854,7 @@
let dragStart = { x: 0, y: 0 };
let dragMoved = false;
/** @type {'dying' | 'falling' | null} */
- let avatarExitAnim = null;
+ let avatarExitAnim = $state(null);
/** @param {MouseEvent} e */
function onAvatarDragStart(e) {
@@ -2018,42 +1918,9 @@
setTimeout(() => { avatarExitAnim = null; }, 1200);
}
- $: effectiveAgentId = $localAgentId || $brandConfig.agent_id || '';
- $: if (effectiveAgentId && !agentScriptLoaded) {
- agentScriptLoaded = true;
- const s = document.createElement('script');
- s.type = 'module';
- s.src = '/agent-3d/latest/agent-3d.js';
- document.head.appendChild(s);
- }
- // Expose to client tools
- $: if (agentEl) window.__threewsAgent = agentEl;
-
- $: if (agentEl && !agentReady) {
- agentEl.addEventListener('agent:ready', () => {
- agentReady = true;
- // Re-frame once the canvas has its final on-screen size, because the
- // internal framing happens at load time, before our ResizeObserver
- // has reacted to the host's actual width/height. Without this, the
- // avatar's feet can clip on first render at large element sizes.
- try {
- requestAnimationFrame(() => {
- try { agentEl._viewer?.resize?.(); } catch {}
- try { agentEl._viewer?.frameContent?.(); } catch {}
- });
- } catch {}
- if (!avatarExitAnim) {
- // STEP 1: force walk so we can verify the clip plays at all.
- playClipWithFallback(agentEl, 'walk', ['walking', 'Walk', 'Walking', 'run', 'Run', 'idle']);
- }
- if (agentPendingSpeak) {
- agentEl.speak(agentPendingSpeak);
- agentPendingSpeak = null;
- }
- }, { once: true });
- }
+
function playClipWithFallback(el, primary, fallbacks = []) {
if (!el) return;
@@ -2070,7 +1937,7 @@
// kicks idle right after scene init, the embedded GLB may have its own
// 'idle' on a separate mixer, and any of half a dozen handlers can call
// _stopWalkAnimation. Poll and brute-force walk until it sticks.
- let walkWatchdogTimer = null;
+ let walkWatchdogTimer = $state(null);
let _walkDiagLogged = false;
function ensureWalkPlaying() {
if (!agentEl) { return; }
@@ -2135,40 +2002,9 @@
})();
}
- // STEP 1: force the walking animation always so we can confirm it plays.
- // (Idle / think switching deliberately disabled while we verify the walk clip.)
- $: if (agentEl && agentReady && !avatarExitAnim && !thinkingTransitioning) {
- ensureWalkPlaying();
- clearInterval(walkWatchdogTimer);
- walkWatchdogTimer = setInterval(ensureWalkPlaying, 500);
- }
- // When thinking ends, play a one-shot falling animation before resuming the loop.
- $: {
- const wasActive = prevThoughtBubbleActive;
- prevThoughtBubbleActive = thoughtBubbleActive;
- if (wasActive && !thoughtBubbleActive && agentEl && agentReady && !avatarExitAnim) {
- thinkingTransitioning = true;
- try { agentEl.play('falling', { loop: false }); } catch {}
- setTimeout(() => {
- thinkingTransitioning = false;
- if (agentEl && agentReady && !avatarExitAnim) {
- agentEl.play((generating || tokensFlowing) ? 'walk' : 'idle', { loop: true }).catch(() => {});
- }
- }, 1200);
- }
- }
- $: if (effectiveAgentId) {
- agentReady = false;
- agentPendingSpeak = null;
- }
- // Inject 3D agent tools into schema when an agent is active
- $: if (effectiveAgentId) {
- const hasGroup = $toolSchema.some(g => g.name === '3D Agent');
- if (!hasGroup) $toolSchema = [...$toolSchema, agentToolSchema];
- }
function detectEmotion(text) {
const t = text.toLowerCase();
@@ -2195,7 +2031,6 @@
return top[1] >= 2 ? top[0] : null;
}
- $: if ($mode !== 'website') websiteCategory.set(null);
// Providers differ on how a stream ends: some send a single chunk carrying
// finish_reason, others repeat it on a trailing usage chunk. Speaking is
@@ -2281,18 +2116,212 @@
}
}
- let showSkillsMarketplace = false;
+ let showSkillsMarketplace = $state(false);
function removeSkill(name) {
toolSchema.update(groups => groups.filter(g => g.name !== name));
}
+ // The chat app's own marketing pages were removed; every surface they
+ // covered is published for real at the site root. Old links still resolve:
+ // the hash is mapped to the live page and the location is replaced, so the
+ // dead route never occupies a history entry.
+ $effect.pre(() => {
+ const retired = siteRouteFor($route);
+ if (retired) window.location.replace(retired);
+ });
+ const historyBuckets = $derived.by(() => {
+ const buckets = [];
+ for (const entry of Object.values(convos).sort((a, b) => b.time - a.time)) {
+ if (entry.shared || isNaN(new Date(entry.time).getTime())) {
+ continue;
+ }
+
+ const bucketKey = getRelativeDate(entry.time);
+
+ const existingBucket = buckets.find((bucket) => bucket.relativeDate === bucketKey);
+ if (!existingBucket) {
+ buckets.push({ relativeDate: bucketKey, convos: [entry] });
+ } else {
+ existingBucket.convos.push(entry);
+ }
+ }
+ return buckets.sort((a, b) => b.convos[0].time - a.convos[0].time);
+ });
+ let filteredConvos = $derived(searchQuery.trim()
+ ? Object.values(convos).filter(
+ (c) =>
+ !c.shared &&
+ (c.messages.some(
+ (m) =>
+ typeof m.content === 'string' &&
+ m.content.toLowerCase().includes(searchQuery.toLowerCase())
+ ) ||
+ (c.title || '').toLowerCase().includes(searchQuery.toLowerCase()) ||
+ (c.messages.find((m) => m.role === 'user')?.content || '')
+ .toLowerCase()
+ .includes(searchQuery.toLowerCase()))
+ )
+ : null);
+ $effect.pre(() => {
+ $generatingStore = generating;
+ });
+ let splitView = $derived(innerWidth > 1215 && activeToolcall && !$config.explicitToolView);
+ // Only the active agent triggers a switch; the conversation state the switch
+ // reads and writes must not re-run it.
+ $effect.pre(() => {
+ const agent = $activeAgent;
+ if (agent !== undefined) {
+ untrack(() => {
+ switchToAgentConversation(agent?.id ?? null);
+ if (agent) applyAgentToConvo(agent);
+ });
+ }
+ });
+ $effect.pre(() => {
+ window.convo = convo;
+ });
+ $effect.pre(() => {
+ window.saveConversation = saveConversation;
+ });
+ $effect.pre(() => {
+ // Only a white-labeled brand renames the tab. On the stock build the title
+ // stays the one index.html declares, so the tab, the share card and the
+ // site's page index all say the same thing about /chat.
+ if ($brandConfig.name && $brandConfig.name !== STOCK_BRAND_NAME) {
+ document.title = $brandConfig.name;
+ }
+ document.documentElement.style.setProperty('--accent', $brandConfig.accent_color);
+ });
+ const collapsedRanges = $derived.by(() => {
+ const ranges = [];
+ if ($config.explicitToolView) return ranges;
+ let range = { starti: null, endi: null };
+ for (let i = convo.messages.length - 1; i >= 0; i--) {
+ if (
+ convo.messages[i].role === 'tool' ||
+ (convo.messages[i].role === 'assistant' &&
+ convo.messages[i].toolcalls &&
+ i !== convo.messages.length - 1)
+ ) {
+ if (range.endi === null) {
+ range.endi = i + 1;
+ }
+ } else {
+ if (range.endi !== null) {
+ range.starti = i + 1;
+ ranges.push(range);
+ range = { starti: null, endi: null };
+ }
+ }
+ }
+ return ranges;
+ });
+ let thinkingMessage = $derived((() => {
+ const msgs = convo?.messages;
+ if (!msgs?.length || !generating) return null;
+ const last = msgs[msgs.length - 1];
+ if (!last || last.role !== 'assistant' || !last.reasoning) return null;
+ return last;
+ })());
+ let thoughtBubbleActive = $derived(!!thinkingMessage?.thinking);
+ let thoughtBubbleText = $derived(thinkingMessage?.thoughts || '');
+ let thoughtBubbleSeconds = $derived(thinkingMessage?.thinkingTime
+ ? thinkingMessage.thinkingTime < 1 ? '<1' : Math.ceil(thinkingMessage.thinkingTime)
+ : 0);
+ $effect.pre(() => {
+ if (thoughtBubbleEl && thoughtBubbleActive && thoughtBubbleText) {
+ // Auto-scroll to bottom as tokens stream in
+ queueMicrotask(() => {
+ if (thoughtBubbleEl) thoughtBubbleEl.scrollTop = thoughtBubbleEl.scrollHeight;
+ });
+ }
+ });
+ let effectiveAgentId = $derived($localAgentId || $brandConfig.agent_id || '');
+ $effect.pre(() => {
+ if (effectiveAgentId && !agentScriptLoaded) {
+ agentScriptLoaded = true;
+ const s = document.createElement('script');
+ s.type = 'module';
+ s.src = '/agent-3d/latest/agent-3d.js';
+ document.head.appendChild(s);
+ }
+ });
+ // Expose to client tools
+ $effect.pre(() => {
+ if (agentEl) window.__threewsAgent = agentEl;
+ });
+ $effect.pre(() => {
+ if (agentEl && !agentReady) {
+ agentEl.addEventListener('agent:ready', () => {
+ agentReady = true;
+ // Re-frame once the canvas has its final on-screen size, because the
+ // internal framing happens at load time, before our ResizeObserver
+ // has reacted to the host's actual width/height. Without this, the
+ // avatar's feet can clip on first render at large element sizes.
+ try {
+ requestAnimationFrame(() => {
+ try { agentEl._viewer?.resize?.(); } catch {}
+ try { agentEl._viewer?.frameContent?.(); } catch {}
+ });
+ } catch {}
+ if (!avatarExitAnim) {
+ // STEP 1: force walk so we can verify the clip plays at all.
+ playClipWithFallback(agentEl, 'walk', ['walking', 'Walk', 'Walking', 'run', 'Run', 'idle']);
+ }
+ if (agentPendingSpeak) {
+ agentEl.speak(agentPendingSpeak);
+ agentPendingSpeak = null;
+ }
+ }, { once: true });
+ }
+ });
+ $effect.pre(() => {
+ if (effectiveAgentId) {
+ agentReady = false;
+ agentPendingSpeak = null;
+ }
+ });
+ // When thinking ends, play a one-shot falling animation before resuming the loop.
+ $effect.pre(() => {
+ const wasActive = prevThoughtBubbleActive;
+ prevThoughtBubbleActive = thoughtBubbleActive;
+ if (wasActive && !thoughtBubbleActive && agentEl && agentReady && !avatarExitAnim) {
+ thinkingTransitioning = true;
+ try { agentEl.play('falling', { loop: false }); } catch {}
+ setTimeout(() => {
+ thinkingTransitioning = false;
+ if (agentEl && agentReady && !avatarExitAnim) {
+ agentEl.play((generating || tokensFlowing) ? 'walk' : 'idle', { loop: true }).catch(() => {});
+ }
+ }, 1200);
+ }
+ });
+ // STEP 1: force the walking animation always so we can confirm it plays.
+ // (Idle / think switching deliberately disabled while we verify the walk clip.)
+ $effect.pre(() => {
+ if (agentEl && agentReady && !avatarExitAnim && !thinkingTransitioning) {
+ untrack(ensureWalkPlaying);
+ clearInterval(walkWatchdogTimer);
+ walkWatchdogTimer = setInterval(ensureWalkPlaying, 500);
+ }
+ });
+ // Inject 3D agent tools into schema when an agent is active
+ $effect.pre(() => {
+ if (effectiveAgentId) {
+ const hasGroup = $toolSchema.some(g => g.name === '3D Agent');
+ if (!hasGroup) $toolSchema = [...$toolSchema, agentToolSchema];
+ }
+ });
+ $effect.pre(() => {
+ if ($mode !== 'website') websiteCategory.set(null);
+ });
</script>
<svelte:window
bind:innerWidth
- on:touchstart={closeSidebars}
- on:click={closeSidebars}
- on:keydown={(event) => {
+ ontouchstart={closeSidebars}
+ onclick={closeSidebars}
+ onkeydown={(event) => {
if (
event.key === 'Escape' &&
generating &&
@@ -2321,15 +2350,15 @@
autoplay
loop
bind:this={video}
- on:timeupdate={() => {
+ ontimeupdate={() => {
savedTime = video.currentTime;
}}
- on:loadeddata={() => {
+ onloadeddata={() => {
if (savedTime > 0) {
video.currentTime = savedTime;
}
}}
- />
+ ></video>
{/if}
{#if siteRouteFor($route)}
@@ -2351,7 +2380,7 @@
</div>
<div class="flex h-12 items-center gap-1 px-2 py-1 md:hidden">
<button
- on:click={newConversation}
+ onclick={newConversation}
class="flex rounded-full p-2 transition-colors hover:bg-gray-100"
>
<Icon icon={feStar} strokeWidth={3} class="ml-auto h-4 w-4 text-slate-700" />
@@ -2359,7 +2388,7 @@
<button
data-trigger="history"
class="flex rounded-full p-2 transition-colors hover:bg-gray-100"
- on:click={() => (historyOpen = !historyOpen)}
+ onclick={() => (historyOpen = !historyOpen)}
>
<Icon icon={feMenu} strokeWidth={3} class="m-auto h-4 w-4 text-slate-700" />
</button>
@@ -2367,11 +2396,11 @@
<ModelSelector
{convo}
{models}
- on:change={({ detail }) => {
+ onchange={(detail) => {
convo.models = [detail];
saveConversation(convo);
}}
- on:changeMulti={({ detail }) => {
+ onchangeMulti={(detail) => {
if (convo.models.find((m) => m.id === detail.id)) {
convo.models = convo.models.filter((m) => m.id !== detail.id);
} else {
@@ -2385,14 +2414,14 @@
<button
class="ml-auto flex rounded-full p-2 transition-colors hover:bg-gray-100"
use:flash
- on:click={shareConversation}
+ onclick={shareConversation}
>
<Icon icon={feShare} strokeWidth={3} class="m-auto h-4 w-4 text-slate-700" />
</button>
<div class="relative">
<button
class="flex rounded-full p-2 transition-colors hover:bg-gray-100 disabled:opacity-40"
- on:click={() => (exportOpen = !exportOpen)}
+ onclick={() => (exportOpen = !exportOpen)}
disabled={convo.messages.length === 0}
title="Export conversation"
>
@@ -2403,16 +2432,16 @@
class="fixed inset-0 z-20 cursor-default"
aria-hidden="true"
tabindex="-1"
- on:click={() => (exportOpen = false)}
- />
+ onclick={() => (exportOpen = false)}
+ ></button>
<div class="absolute right-0 top-full mt-1 z-30 w-48 rounded-xl border border-rule bg-white p-1 shadow-pop">
<button
class="flex h-9 w-full items-center rounded-lg px-3 text-sm font-medium text-ink hover:bg-paper"
- on:click={exportConvoAsMarkdown}
+ onclick={exportConvoAsMarkdown}
>Export as Markdown</button>
<button
class="flex h-9 w-full items-center rounded-lg px-3 text-sm font-medium text-ink hover:bg-paper"
- on:click={exportConvoAsJSON}
+ onclick={exportConvoAsJSON}
>Export as JSON</button>
</div>
{/if}
@@ -2423,7 +2452,7 @@
aria-label="Model settings"
aria-expanded={knobsOpen}
title="Model settings"
- on:click={() => (knobsOpen = !knobsOpen)}
+ onclick={() => (knobsOpen = !knobsOpen)}
>
<Icon icon={feSidebar} strokeWidth={3} class="m-auto h-4 w-4 text-slate-700" />
</button>
@@ -2438,7 +2467,7 @@
>
<div class="mb-1 pr-3">
<button
- on:click={newConversation}
+ onclick={newConversation}
class="three.ws-btn-primary flex w-full items-center justify-start gap-2 rounded-full px-4 py-2.5"
>
<span class="text-base font-medium leading-none">+</span>
@@ -2466,7 +2495,7 @@
)}
<li class="group relative">
<button
- on:click={() => {
+ onclick={() => {
handleAbort();
historyOpen = false;
activeToolcall = null;
@@ -2502,7 +2531,7 @@
{/if}
</button>
<button
- on:click={() => {
+ onclick={() => {
if ($convoId === historyConvo.id) {
const newId = Object.values(convos).find(
(e) => e.id !== historyConvo.id && !e.shared
@@ -2539,14 +2568,14 @@
<input
class="w-full bg-transparent text-sm text-ink outline-none"
bind:value={historyConvo.title}
- on:blur={() => { saveConversation(historyConvo); convos = { ...convos }; editingTitleId = null; }}
- on:keydown={(e) => e.key === 'Enter' && e.target.blur()}
+ onblur={() => { saveConversation(historyConvo); convos = { ...convos }; editingTitleId = null; }}
+ onkeydown={(e) => e.key === 'Enter' && e.target.blur()}
use:focusOnMount
/>
</div>
{:else}
<button
- on:click={() => {
+ onclick={() => {
handleAbort();
historyOpen = false;
@@ -2567,7 +2596,7 @@
>
<span
class="line-clamp-1"
- on:dblclick|stopPropagation={() => { editingTitleId = historyConvo.id; }}
+ ondblclick={(event) => { event.stopPropagation(); editingTitleId = historyConvo.id; }}
>
{historyConvo.title || (historyConvo.messages.length === 0
? 'New conversation'
@@ -2580,7 +2609,7 @@
</button>
{/if}
<button
- on:click={() => {
+ onclick={() => {
if ($convoId === historyConvo.id) {
const newId = Object.values(convos).find(
(e) => e.id !== historyConvo.id && !e.shared
@@ -2612,7 +2641,7 @@
<button
data-trigger="settings"
class="mx-3 flex flex-1 items-center gap-x-4 rounded-lg border border-rule px-4 py-3 text-left text-sm font-medium hover:bg-paper-deep"
- on:click={() => {
+ onclick={() => {
historyOpen = false;
}}
>
@@ -2627,11 +2656,11 @@
<ModelSelector
{convo}
{models}
- on:change={({ detail }) => {
+ onchange={(detail) => {
convo.models = [detail];
saveConversation(convo);
}}
- on:changeMulti={({ detail }) => {
+ onchangeMulti={(detail) => {
if (convo.models.find((m) => m.id === detail.id)) {
convo.models = convo.models.filter((m) => m.id !== detail.id);
} else {
@@ -2647,14 +2676,14 @@
use:flash
aria-label="Share conversation"
title="Share conversation"
- on:click={shareConversation}
+ onclick={shareConversation}
>
<Icon icon={feShare} strokeWidth={3} class="m-auto h-4 w-4 text-slate-700" />
</button>
<div class="relative">
<button
class="flex rounded-full p-3 transition-colors hover:bg-gray-100 disabled:opacity-40"
- on:click={() => (exportOpen = !exportOpen)}
+ onclick={() => (exportOpen = !exportOpen)}
disabled={convo.messages.length === 0}
title="Export conversation"
>
@@ -2665,23 +2694,23 @@
class="fixed inset-0 z-20 cursor-default"
aria-hidden="true"
tabindex="-1"
- on:click={() => (exportOpen = false)}
- />
+ onclick={() => (exportOpen = false)}
+ ></button>
<div class="absolute right-0 top-full mt-1 z-30 w-48 rounded-xl border border-rule bg-white p-1 shadow-pop">
<button
class="flex h-9 w-full items-center rounded-lg px-3 text-sm font-medium text-ink hover:bg-paper"
- on:click={exportConvoAsMarkdown}
+ onclick={exportConvoAsMarkdown}
>Export as Markdown</button>
<button
class="flex h-9 w-full items-center rounded-lg px-3 text-sm font-medium text-ink hover:bg-paper"
- on:click={exportConvoAsJSON}
+ onclick={exportConvoAsJSON}
>Export as JSON</button>
</div>
{/if}
</div>
<button
class="relative flex items-center gap-1 rounded-full p-3 transition-colors hover:bg-gray-100"
- on:click={() => (showSkillsMarketplace = true)}
+ onclick={() => (showSkillsMarketplace = true)}
title="Skills Marketplace"
>
<Icon icon={feGrid} strokeWidth={3} class="m-auto h-4 w-4 text-slate-700" />
@@ -2696,7 +2725,7 @@
aria-label="Model settings"
aria-expanded={knobsOpen}
title="Model settings"
- on:click={() => (knobsOpen = !knobsOpen)}
+ onclick={() => (knobsOpen = !knobsOpen)}
>
<Icon icon={feSidebar} strokeWidth={3} class="m-auto h-4 w-4 text-slate-700" />
</button>
@@ -2705,53 +2734,57 @@
{#if convo.messages.length === 0}
<div class="flex h-full w-full overflow-y-auto">
<EmptyState>
- <svelte:fragment slot="composer">
- <Composer
- bind:generating
- bind:convo
- {saveMessage}
- {saveConversation}
- {submitCompletion}
- {scrollToBottom}
- {handleAbort}
- {tree}
- bind:inputTextareaEl
- bind:handleFileDrop
- placeholder={$mode === 'website' ? 'Describe the website you want to build' : $t('typeMessage')}
- mode={$mode}
- modes={[{ id: 'website', label: 'Website' }]}
- onModeClear={() => mode.set(null)}
- />
- </svelte:fragment>
- <svelte:fragment slot="chips">
- {#if $mode === 'website'}
- <WebsiteFlow />
- {:else if $mode === 'desktop'}
- <DesktopFlow />
- {:else}
- <SuggestionChips />
- {/if}
- </svelte:fragment>
+ {#snippet composer()}
+
+ <Composer
+ bind:generating
+ bind:convo
+ {saveMessage}
+ {saveConversation}
+ {submitCompletion}
+ {scrollToBottom}
+ {handleAbort}
+ {tree}
+ bind:inputTextareaEl
+ bind:handleFileDrop
+ placeholder={$mode === 'website' ? 'Describe the website you want to build' : $t('typeMessage')}
+ mode={$mode}
+ modes={[{ id: 'website', label: 'Website' }]}
+ onModeClear={() => mode.set(null)}
+ />
+
+ {/snippet}
+ {#snippet chips()}
+
+ {#if $mode === 'website'}
+ <WebsiteFlow />
+ {:else if $mode === 'desktop'}
+ <DesktopFlow />
+ {:else}
+ <SuggestionChips />
+ {/if}
+
+ {/snippet}
</EmptyState>
</div>
{:else}
<div class="flex h-full w-full">
- <!-- svelte-ignore a11y-no-static-element-interactions -->
+ <!-- svelte-ignore a11y_no_static_element_interactions -->
<div
class="{splitView
? 'w-[50%]'
: 'w-full'} relative max-h-[calc(100vh-49px)] transition-[width] duration-500 ease-in-out"
- on:dragover={(event) => {
+ ondragover={(event) => {
event.preventDefault();
}}
- on:drop={handleFileDrop}
+ ondrop={handleFileDrop}
>
<div
bind:this={scrollableEl}
class="{splitView
? 'scrollbar-none'
: 'scrollbar-ultraslim'} scrollable flex h-full w-full flex-col overflow-y-auto pb-[128px]"
- on:scroll={() => {
+ onscroll={() => {
const { scrollTop, scrollHeight, clientHeight } = scrollableEl;
if (scrollTop < previousScrollTop) {
autoscrollCanceled = true;
@@ -2785,7 +2818,7 @@
bind:chose
bind:activeToolcall
bind:textareaEls
- on:rerender={() => {
+ onrerender={() => {
convo.messages = convo.messages;
}}
/>
@@ -2795,7 +2828,7 @@
</ul>
</div>
- <div class="pointer-events-none absolute bottom-[72px] inset-x-0 h-8 z-[98] bg-gradient-to-t from-paper to-transparent" />
+ <div class="pointer-events-none absolute bottom-[72px] inset-x-0 h-8 z-[98] bg-gradient-to-t from-paper to-transparent"></div>
{#if $toolSchema.length > 0 || effectiveAgentId}
<div class="flex flex-wrap gap-1.5 px-4 pt-2 pb-0">
{#each $toolSchema as group}
@@ -2803,7 +2836,7 @@
{group.name}
<button
class="ml-0.5 rounded-full p-0.5 text-indigo-400 hover:bg-indigo-100 hover:text-indigo-600"
- on:click={() => removeSkill(group.name)}
+ onclick={() => removeSkill(group.name)}
aria-label="Remove {group.name}"
>
<Icon icon={feX} class="h-2.5 w-2.5" />
@@ -2812,14 +2845,14 @@
{/each}
<button
class="text-[11px] text-slate-400 hover:text-slate-600"
- on:click={() => (showSkillsMarketplace = true)}
+ onclick={() => (showSkillsMarketplace = true)}
>
+ Add skill
</button>
{#if effectiveAgentId}
<button
class="inline-flex items-center gap-1 rounded-full border border-emerald-200 bg-emerald-50 px-2.5 py-0.5 text-[11px] font-medium text-emerald-700 hover:bg-emerald-100"
- on:click={agentVisible ? killAvatar : reviveAvatar}
+ onclick={agentVisible ? killAvatar : reviveAvatar}
title={agentVisible ? 'Hide avatar' : 'Show avatar'}
>
{agentVisible ? 'Hide avatar' : 'Show avatar'}
@@ -2859,7 +2892,7 @@
{question}
{choices}
class="!rounded-xl"
- on:close={() => {
+ onclose={() => {
activeToolcall = null;
}}
/>
@@ -2877,11 +2910,11 @@
<SettingsModal
open={settingsModalOpen}
trigger="settings"
- on:fetchModels={async () => {
+ onfetchModels={async () => {
const fetched = await fetchModels({ onFinally: () => {} });
models = [...BUILTIN_MODELS, ...fetched];
}}
- on:disableTool={({ detail: name }) => {
+ ondisableTool={(name) => {
convo.tools = convo.tools.filter((n) => n !== name);
saveConversation(convo);
}}
@@ -2897,7 +2930,7 @@
trigger="toolcall"
class="!p-0"
buttonClass="hidden"
- on:close={() => {
+ onclose={() => {
activeToolcall = null;
}}
>
@@ -2912,7 +2945,7 @@
{question}
{choices}
class="!rounded-xl"
- on:close={() => {
+ onclose={() => {
toolcallModalOpen = false;
activeToolcall = null;
}}
@@ -2947,14 +2980,14 @@
<div class="flex flex-col gap-3">
<button
class="flex items-center justify-center gap-2 rounded-xl bg-purple-600 px-4 py-3 text-sm font-semibold text-white transition hover:bg-purple-700 active:scale-95"
- on:click={() => verifyGate('solana')}
+ onclick={() => verifyGate('solana')}
>
<svg class="h-5 w-5" viewBox="0 0 128 128" fill="none"><circle cx="64" cy="64" r="64" fill="#9945FF"/><path d="M86 44H42l14 14h44L86 44zm0 26H42l14 14h44L86 70zM42 84h44l-14 14H28L42 84z" fill="white"/></svg>
Verify with Solana Wallet
</button>
<button
class="flex items-center justify-center gap-2 rounded-xl bg-blue-600 px-4 py-3 text-sm font-semibold text-white transition hover:bg-blue-700 active:scale-95"
- on:click={() => verifyGate('evm')}
+ onclick={() => verifyGate('evm')}
>
<svg class="h-5 w-5" viewBox="0 0 128 128" fill="none"><circle cx="64" cy="64" r="64" fill="#627EEA"/><path d="M64 20v33l28 12.5L64 20z" fill="white" fill-opacity=".6"/><path d="M64 20L36 65.5l28-12.5V20z" fill="white"/><path d="M64 88v20l28-38.5L64 88z" fill="white" fill-opacity=".6"/><path d="M64 108V88L36 69.5 64 108z" fill="white"/><path d="M64 82.5l28-16.9-28-12.6v29.5z" fill="white" fill-opacity=".2"/><path d="M36 65.5l28 16.9V53l-28 12.5z" fill="white" fill-opacity=".6"/></svg>
Verify with EVM Wallet
@@ -2972,7 +3005,7 @@
<div class="flex flex-col gap-2">
<button
class="rounded-xl bg-slate-100 px-4 py-2 text-sm font-medium text-slate-700 transition hover:bg-slate-200"
- on:click={() => { gateState = 'pending'; gateError = ''; }}
+ onclick={() => { gateState = 'pending'; gateError = ''; }}
>Try a different wallet</button>
</div>
{/if}
diff --git a/chat/src/ArtifactButton.svelte b/chat/src/ArtifactButton.svelte
index 57bf176d4..b847c43a9 100644
--- a/chat/src/ArtifactButton.svelte
+++ b/chat/src/ArtifactButton.svelte
@@ -1,10 +1,15 @@
-<script>
+<script lang="ts">
import Icon from './Icon.svelte';
import { feTerminal, feBox } from './feather.js';
import { onMount } from 'svelte';
- export let xml;
- export let active = false;
+ interface Props {
+ xml: any;
+ active?: boolean;
+ onclick?: (event: any) => void;
+ }
+
+ let { xml, active = false, onclick }: Props = $props();
</script>
<button
@@ -12,7 +17,7 @@
class="{active
? 'bg-slate-800'
: 'bg-gray-200 hover:bg-gray-300'} group/artifact relative flex items-center gap-2 self-start rounded-full px-3.5 py-2 transition-[background-color,box-shadow] duration-500"
- on:click
+ onclick={onclick}
>
<Icon icon={feBox} class="{active ? 'text-white' : 'text-slate-800'} h-4 w-4" />
diff --git a/chat/src/AvatarIcon.svelte b/chat/src/AvatarIcon.svelte
index 28b8497f9..2aaddeb4f 100644
--- a/chat/src/AvatarIcon.svelte
+++ b/chat/src/AvatarIcon.svelte
@@ -1,4 +1,4 @@
-<script context="module">
+<script module>
import {
Scene,
PerspectiveCamera,
@@ -63,14 +63,11 @@
import { onMount, onDestroy } from 'svelte';
import { generating } from './stores.js';
- export let avatarUrl = '';
- /** When true (default), avatar plays walking while $generating, idle otherwise.
- * When false, renders a single still frame (cheap for dense lists). */
- export let live = true;
+ let { avatarUrl = '', live = true } = $props();
- let canvas;
- let state = avatarUrl ? 'loading' : 'error';
- let mixer = null;
+ let canvas = $state();
+ let loadState = $state(avatarUrl ? 'loading' : 'error');
+ let mixer = $state.raw(null);
let walkAction = null;
let idleAction = null;
let renderer = null;
@@ -146,9 +143,9 @@
}
renderer.render(scene, camera);
- state = 'done';
+ loadState = 'done';
} catch {
- state = 'error';
+ loadState = 'error';
}
});
@@ -175,7 +172,9 @@
renderer?.render(scene, camera);
}
- $: if (live && mixer) tickPlayState();
+ $effect(() => {
+ if (live && mixer) tickPlayState();
+ });
onDestroy(() => {
observer?.disconnect();
@@ -190,13 +189,13 @@
});
</script>
-<span class="h-full w-full block {state === 'done' ? 'avatar-fall-in' : 'invisible'}">
+<span class="h-full w-full block {loadState === 'done' ? 'avatar-fall-in' : 'invisible'}">
<canvas
bind:this={canvas}
width="128"
height="128"
class="h-full w-full object-cover {$generating && live ? 'avatar-bob' : ''}"
- />
+ ></canvas>
</span>
<style>
diff --git a/chat/src/AvatarPreview.svelte b/chat/src/AvatarPreview.svelte
index 322188782..74ae4be5d 100644
--- a/chat/src/AvatarPreview.svelte
+++ b/chat/src/AvatarPreview.svelte
@@ -14,19 +14,21 @@
} from 'three';
import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';
- export let thumbnail_url = null;
- export let model_url = null;
- export let alt = '';
- export let size = 128;
- export let class_name = 'h-16 w-full rounded object-cover';
- export let bg_color = '#e8e8e8';
+ let {
+ thumbnail_url = null,
+ model_url = null,
+ alt = '',
+ size = 128,
+ class_name = 'h-16 w-full rounded object-cover',
+ bg_color = '#e8e8e8',
+ } = $props();
- let canvas;
- let state = thumbnail_url ? 'done' : model_url ? 'idle' : 'none';
+ let canvas = $state();
+ let loadState = $state(thumbnail_url ? 'done' : model_url ? 'idle' : 'none');
let observer;
onMount(() => {
- if (state !== 'idle') return;
+ if (loadState !== 'idle') return;
observer = new IntersectionObserver(
(entries) => {
if (entries[0].isIntersecting) {
@@ -44,7 +46,7 @@
});
async function renderPreview() {
- state = 'loading';
+ loadState = 'loading';
try {
const resp = await fetch(model_url, { mode: 'cors' });
if (!resp.ok) throw new Error(resp.status);
@@ -94,16 +96,16 @@
for (const m of mats) m.dispose();
});
- state = 'done';
+ loadState = 'done';
} catch {
- state = 'error';
+ loadState = 'error';
}
}
</script>
{#if thumbnail_url}
<img src={thumbnail_url} {alt} class={class_name} loading="lazy" />
-{:else if state === 'none'}
+{:else if loadState === 'none'}
<div class="{class_name} flex items-center justify-center bg-slate-100 text-[10px] text-slate-400">
No preview
</div>
@@ -112,9 +114,9 @@
bind:this={canvas}
width={size}
height={size}
- class="{class_name} {state === 'loading' ? 'animate-pulse bg-slate-100' : ''} {state === 'error' ? 'hidden' : ''}"
- />
- {#if state === 'error'}
+ class="{class_name} {loadState === 'loading' ? 'animate-pulse bg-slate-100' : ''} {loadState === 'error' ? 'hidden' : ''}"
+ ></canvas>
+ {#if loadState === 'error'}
<div class="{class_name} flex items-center justify-center bg-slate-100 text-[10px] text-slate-400">
No preview
</div>
diff --git a/chat/src/Button.svelte b/chat/src/Button.svelte
index e8888afe1..9527649a0 100644
--- a/chat/src/Button.svelte
+++ b/chat/src/Button.svelte
@@ -1,24 +1,39 @@
<script lang="ts">
import { flash } from './actions.js';
- export let variant = 'outline';
- let className = '';
- export { className as class };
- export let trigger = null;
- export let disabled = false;
+
- export let el = undefined;
- export let use = [() => {}, {}];
+ interface Props {
+ variant?: string;
+ class?: string;
+ trigger?: any;
+ disabled?: boolean;
+ el?: any;
+ use?: any;
+ children?: import('svelte').Snippet;
+ onclick?: (event: any) => void;
+ }
- $: useFn = use[0];
- $: useParams = use[1];
+ let {
+ variant = 'outline',
+ class: className = '',
+ trigger = null,
+ disabled = false,
+ el = $bindable(undefined),
+ use = [() => {}, {}],
+ children,
+ onclick
+ }: Props = $props();
- const variantClass = {
+ let useFn = $derived(use[0]);
+ let useParams = $derived(use[1]);
+
+ const variantClass = $derived({
outline:
'border bg-white border-slate-300 hover:border-slate-400 transition-colors text-slate-700 text-sm px-3 py-1.5 rounded-lg',
dark: 'bg-slate-800 hover:bg-slate-700 text-white text-sm px-4 py-2 rounded-lg transition-colors',
transparent: 'rounded-full p-3 transition-colors hover:bg-gray-100',
- }[variant];
+ }[variant]);
</script>
<button
@@ -28,7 +43,7 @@
class="{className} {variantClass} flex items-center"
use:flash
use:useFn={useParams}
- on:click
+ onclick={onclick}
>
- <slot />
+ {@render children?.()}
</button>
diff --git a/chat/src/Checkbox.svelte b/chat/src/Checkbox.svelte
index 5dbc0c935..8d7a1915c 100644
--- a/chat/src/Checkbox.svelte
+++ b/chat/src/Checkbox.svelte
@@ -1,21 +1,27 @@
-<script>
+<script lang="ts">
import { feCheck } from './feather';
import Icon from './Icon.svelte';
- export let checked;
- let className = '';
- export { className as class };
+ interface Props {
+ checked: any;
+ class?: string;
+ onchange?: (event: any) => void;
+ onclick?: (event: any) => void;
+ }
+
+ let { checked = $bindable(), class: className = '', onchange, onclick }: Props = $props();
+
</script>
<!-- Hidden native checkbox -->
-<input type="checkbox" bind:checked on:change class="group hidden" />
+<input type="checkbox" bind:checked onchange={onchange} class="group hidden" />
<!-- Custom checkbox -->
-<!-- svelte-ignore a11y-click-events-have-key-events -->
-<!-- svelte-ignore a11y-no-noninteractive-tabindex -->
-<!-- svelte-ignore a11y-no-static-element-interactions -->
+<!-- svelte-ignore a11y_click_events_have_key_events -->
+<!-- svelte-ignore a11y_no_noninteractive_tabindex -->
+<!-- svelte-ignore a11y_no_static_element_interactions -->
<span
- on:click
+ onclick={onclick}
class="{className} {checked
? 'border-slate-800 bg-slate-800'
: 'bg-white'} relative flex h-4 w-4 shrink-0 items-center justify-center rounded border border-slate-300 transition-colors focus:outline-none focus:ring-0"
diff --git a/chat/src/Choice.svelte b/chat/src/Choice.svelte
index 6b948593d..0f36ca78c 100644
--- a/chat/src/Choice.svelte
+++ b/chat/src/Choice.svelte
@@ -1,13 +1,22 @@
-<script>
+<script lang="ts">
import { fade } from 'svelte/transition';
import Button from './Button.svelte';
import { feCheck, feX } from './feather';
import Icon from './Icon.svelte';
- export let choiceHandler;
- export let question = '';
- export let choices = [];
- export let chose = null;
+ interface Props {
+ choiceHandler: any;
+ question?: string;
+ choices?: any;
+ chose?: any;
+ }
+
+ let {
+ choiceHandler,
+ question = '',
+ choices = [],
+ chose = $bindable(null)
+ }: Props = $props();
</script>
<div class="mx-auto flex w-full max-w-[500px] flex-col">
@@ -27,7 +36,7 @@
class="{chose === i
? 'ring-2 ring-slate-800 ring-offset-1'
: ''} w-full !justify-center px-6 disabled:opacity-75 disabled:hover:bg-slate-800"
- on:click={() => {
+ onclick={() => {
choiceHandler(choice);
chose = i;
}}
@@ -49,7 +58,7 @@
<Button
class="{chose !== null ? 'invisible' : ''} mt-6 self-center"
- on:click={() => {
+ onclick={() => {
choiceHandler(
'User closed the prompt and refused to answer, do not prompt again unless explicitly asked.'
);
diff --git a/chat/src/ClientTool.svelte b/chat/src/ClientTool.svelte
index b2d1d8468..d9cd356ae 100644
--- a/chat/src/ClientTool.svelte
+++ b/chat/src/ClientTool.svelte
@@ -1,12 +1,10 @@
-<script>
- import { createEventDispatcher } from 'svelte';
+<script lang="ts">
import Button from './Button.svelte';
import Icon from './Icon.svelte';
import { feEdit2, feTrash } from './feather.js';
- const dispatch = createEventDispatcher();
- export let definition;
+ let { definition, onedit, ondelete } = $props();
</script>
<div class="flex items-center rounded-lg border border-slate-300 pl-4 pr-2 py-2">
@@ -14,16 +12,16 @@
<Button
class="ml-auto w-7 h-7 !p-0 justify-center shrink-0"
- on:click={() => {
- dispatch('edit');
+ onclick={() => {
+ onedit?.();
}}
>
<Icon icon={feEdit2} class="text-slate-700 w-3 h-3" />
</Button>
<Button
class="ml-2 w-7 h-7 !p-0 justify-center shrink-0"
- on:click={() => {
- dispatch('delete');
+ onclick={() => {
+ ondelete?.();
}}
>
<Icon icon={feTrash} class="text-slate-700 w-3 h-3" />
diff --git a/chat/src/ClientToolSetting.svelte b/chat/src/ClientToolSetting.svelte
index 69d1df93c..2c58f4c78 100644
--- a/chat/src/ClientToolSetting.svelte
+++ b/chat/src/ClientToolSetting.svelte
@@ -1,14 +1,13 @@
<script>
- import { createEventDispatcher } from 'svelte';
import Button from './Button.svelte';
import Icon from './Icon.svelte';
import { feCheck, fePlus, feTrash } from './feather.js';
- const dispatch = createEventDispatcher();
+ let { onsave } = $props();
- let viewingUI = true;
+ let viewingUI = $state(true);
- let toolDefinition = {
+ let toolDefinition = $state({
name: '',
description: '',
arguments: [
@@ -19,9 +18,9 @@
},
],
body: '',
- };
+ });
export function load(definition) {
- toolDefinition = structuredClone(definition);
+ toolDefinition = structuredClone($state.snapshot(definition));
}
function convertFunctionFormat(inputObj) {
@@ -79,7 +78,7 @@
<div class="mb-4 flex items-center gap-8 sm:mb-5">
<h1 class="text-xl font-semibold">Client-side tool</h1>
<button
- on:click={(event) => {
+ onclick={(event) => {
event.stopPropagation();
viewingUI = !viewingUI;
}}
@@ -110,7 +109,7 @@
bind:value={toolDefinition.description}
rows={3}
class="rounded-lg border border-slate-300 px-3 py-2 text-sm text-slate-800 transition-colors placeholder:text-gray-500 focus:border-slate-400 focus:outline-none"
- /></label
+ ></textarea></label
>
<p class="ml-[3px] mt-2 text-[10px] uppercase tracking-wide">Arguments:</p>
@@ -148,7 +147,7 @@
<Button
variant="outline"
class="h-[38px] w-[38px] shrink-0 self-end rounded-lg"
- on:click={() => {
+ onclick={() => {
toolDefinition.arguments.splice(i, 1);
toolDefinition.arguments = toolDefinition.arguments;
}}
@@ -161,7 +160,7 @@
{/each}
<Button
class="mt-1 self-start px-5"
- on:click={() => {
+ onclick={() => {
toolDefinition.arguments = [
...toolDefinition.arguments,
{ name: '', type: 'string', description: '' },
@@ -178,7 +177,7 @@
bind:value={toolDefinition.body}
rows={6}
class="w-full rounded-lg border border-slate-300 px-3 py-2 font-mono text-sm text-slate-800 transition-colors placeholder:text-gray-500 focus:border-slate-400 focus:outline-none"
- on:keydown={(event) => {
+ onkeydown={(event) => {
if (event.key == 'Tab') {
event.preventDefault();
var start = event.target.selectionStart;
@@ -192,13 +191,13 @@
event.target.selectionStart = event.target.selectionEnd = start + 1;
}
}}
- /></label
+ ></textarea></label
>
</div>
{:else}
<textarea
value={JSON.stringify(toolDefinition, null, 2)}
- on:change={(event) => {
+ onchange={(event) => {
try {
toolDefinition = JSON.parse(event.target.value);
} catch (error) {
@@ -207,13 +206,13 @@
}}
class="w-full rounded-lg border border-slate-300 px-3 py-2 font-mono text-sm text-slate-800 transition-colors placeholder:text-gray-500 focus:border-slate-400 focus:outline-none"
rows={14}
- />
+ ></textarea>
{/if}
<Button
class="ml-auto mt-5 !px-6"
- on:click={() => {
- dispatch('save', convertFunctionFormat(toolDefinition));
+ onclick={() => {
+ onsave?.(convertFunctionFormat(toolDefinition));
}}
>
<Icon icon={feCheck} strokeWidth={3} class="mr-2 h-3 w-3 text-slate-700" />
diff --git a/chat/src/CompanyLogo.svelte b/chat/src/CompanyLogo.svelte
index f3cc244b1..df17f228b 100644
--- a/chat/src/CompanyLogo.svelte
+++ b/chat/src/CompanyLogo.svelte
@@ -1,12 +1,22 @@
-<script>
+<script lang="ts">
import { talkingHeadAvatarUrl } from './stores.js';
import AvatarIcon from './AvatarIcon.svelte';
- export let model;
- export let size = 'h-7 w-7';
- export let rounded = null;
- /** Live-animated walking avatar. Set false for dense lists (dropdown rows), which uses a still frame. */
- export let live = true;
+
+ interface Props {
+ model: any;
+ size?: string;
+ rounded?: any;
+ /** Live-animated walking avatar. Set false for dense lists (dropdown rows), which uses a still frame. */
+ live?: boolean;
+ }
+
+ let {
+ model,
+ size = 'h-7 w-7',
+ rounded = null,
+ live = true
+ }: Props = $props();
// Remember to update hasCompanyLogo from convo.js when adding new logos.
const base = import.meta.env.BASE_URL;
diff --git a/chat/src/FilePill.svelte b/chat/src/FilePill.svelte
index fb8435c14..2e0b94f4c 100644
--- a/chat/src/FilePill.svelte
+++ b/chat/src/FilePill.svelte
@@ -1,19 +1,23 @@
-<script>
- import { createEventDispatcher } from 'svelte';
+<script lang="ts">
import { feX, feFileText } from '$src/feather';
import Icon from '$src/Icon.svelte';
- const dispatch = createEventDispatcher();
- export let file;
- export let canDelete = false;
+ interface Props {
+ file: any;
+ canDelete?: boolean;
+ ondelete?: (...args: any[]) => void;
+ onshowContents?: (...args: any[]) => void;
+ }
+
+ let { file, canDelete = false, ondelete, onshowContents }: Props = $props();
</script>
<div class="flex mb-2 items-center self-start gap-1.5 rounded-full border border-slate-200 bg-white pl-2.5 pr-3 py-1.5">
{#if canDelete}
<button
- on:click={() => {
- dispatch('delete');
+ onclick={() => {
+ ondelete?.();
}}
class="flex h-4 w-4 rounded-full"
>
@@ -22,8 +26,8 @@
{:else}
<!-- If can not delete, then the action is to show file contents. -->
<button
- on:click={() => {
- dispatch('showContents');
+ onclick={() => {
+ onshowContents?.();
}}
class="flex h-4 w-4 rounded-full"
>
diff --git a/chat/src/FileTreeNode.svelte b/chat/src/FileTreeNode.svelte
index 384fa94f0..692503ed6 100644
--- a/chat/src/FileTreeNode.svelte
+++ b/chat/src/FileTreeNode.svelte
@@ -1,16 +1,28 @@
-<script>
+<script lang="ts">
+ import FileTreeNode from './FileTreeNode.svelte';
import { slide } from 'svelte/transition';
import Checkbox from './Checkbox.svelte';
import Icon from './Icon.svelte';
import { feChevronDown } from './feather.js';
- import { createEventDispatcher } from 'svelte';
- const dispatch = createEventDispatcher();
- export let item;
- export let level = 0;
- export let collapsed = {};
- export let selectedFiles = [];
+ interface Props {
+ item: any;
+ level?: number;
+ collapsed?: any;
+ selectedFiles?: any;
+ onfileSelected?: (...args: any[]) => void;
+ onfileDeselected?: (...args: any[]) => void;
+ }
+
+ let {
+ item,
+ level = 0,
+ collapsed = $bindable({}),
+ selectedFiles = $bindable([]),
+ onfileSelected,
+ onfileDeselected
+ }: Props = $props();
// Helper function to get all files in a directory
function getAllFiles(dir) {
@@ -51,7 +63,7 @@
for (const path of filePaths) {
if (!selectedFiles.includes(path)) {
selectedFiles = [...selectedFiles, path];
- dispatch('fileSelected', { path });
+ onfileSelected?.({ path });
}
}
} else {
@@ -65,7 +77,7 @@
// Dispatch events for deselected files
for (const path of pathsToDeselect) {
- dispatch('fileDeselected', { path });
+ onfileDeselected?.({ path });
}
}
}
@@ -74,10 +86,10 @@
function toggleFile(path, nowEnabled) {
if (nowEnabled) {
selectedFiles = [...selectedFiles, path];
- dispatch('fileSelected', { path });
+ onfileSelected?.({ path });
} else {
selectedFiles = selectedFiles.filter((p) => p !== path);
- dispatch('fileDeselected', { path });
+ onfileDeselected?.({ path });
}
}
</script>
@@ -90,7 +102,7 @@
>
<Checkbox
checked={isDirFullySelected(selectedFiles, item)}
- on:change={() => {
+ onchange={() => {
toggleDir(item, !isDirFullySelected(selectedFiles, item));
}}
/>
@@ -98,7 +110,7 @@
</label>
<button
- on:click={() => (collapsed[item.path] = !collapsed[item.path])}
+ onclick={() => (collapsed[item.path] = !collapsed[item.path])}
class="absolute right-1 top-1/2 flex h-8 w-8 -translate-y-1/2 rounded-full transition-colors hover:bg-gray-100"
>
<Icon
@@ -113,7 +125,7 @@
{#if !collapsed[item.path]}
<div transition:slide={{ duration: 300 }}>
{#each item.children as child}
- <svelte:self item={child} level={level + 1} {collapsed} bind:selectedFiles on:fileSelected on:fileDeselected />
+ <FileTreeNode item={child} level={level + 1} {collapsed} bind:selectedFiles {onfileSelected} {onfileDeselected} />
{/each}
</div>
{/if}
@@ -125,7 +137,7 @@
>
<Checkbox
checked={isFileSelected(selectedFiles, item.path)}
- on:change={() => {
+ onchange={() => {
toggleFile(item.path, !isFileSelected(selectedFiles, item.path));
}}
/>
diff --git a/chat/src/FilesDropdown.svelte b/chat/src/FilesDropdown.svelte
index 528d08b5d..611979bad 100644
--- a/chat/src/FilesDropdown.svelte
+++ b/chat/src/FilesDropdown.svelte
@@ -1,28 +1,35 @@
-<script>
+<script lang="ts">
+
import { scale } from 'svelte/transition';
import { cubicIn } from 'svelte/easing';
import FileTreeNode from './FileTreeNode.svelte';
- import { createEventDispatcher } from 'svelte';
- const dispatch = createEventDispatcher();
- export let open = false;
- export let tree;
- export let selectedFiles = [];
+ interface Props {
+ open?: boolean;
+ tree: any;
+ selectedFiles?: any;
+ onfileSelected?: (...args: any[]) => void;
+ onfileDeselected?: (...args: any[]) => void;
+ }
+
+ let { open = $bindable(false), tree, selectedFiles = $bindable([]), onfileSelected, onfileDeselected }: Props = $props();
// For keeping track of collapsed state of directories
- let collapsed = {};
+ let collapsed = $state({});
// For search functionality
- let searchTerm = '';
+ let searchTerm = $state('');
let debouncedSearchTerm = '';
let debounceTimeout;
- let inputEl;
+ let inputEl = $state();
- $: if (open && inputEl) {
- inputEl.focus();
- }
+ $effect.pre(() => {
+ if (open && inputEl) {
+ inputEl.focus();
+ }
+ });
// Clear all selections
function clearSelections() {
@@ -112,22 +119,24 @@
}
// When search term changes, filter the tree
- $: filteredTree = tree && filterTree(tree, searchTerm);
+ let filteredTree = $derived(tree && filterTree(tree, searchTerm));
// When searching, expand directories that contain matches
- $: if (searchTerm && filteredTree) {
- // Reset collapsed state when search term changes
- collapsed = {};
- }
+ $effect.pre(() => {
+ if (searchTerm && filteredTree) {
+ // Reset collapsed state when search term changes
+ collapsed = {};
+ }
+ });
</script>
<svelte:window
- on:click={(event) => {
+ onclick={(event) => {
if (!event.target.closest('#files-dropdown')) {
open = false;
}
}}
- on:touchstart={(event) => {
+ ontouchstart={(event) => {
if (!event.target.closest('#files-dropdown')) {
open = false;
}
@@ -146,7 +155,7 @@
<div class="w-full px-3 pb-2 pt-2.5">
<div class="mb-1 flex items-center justify-between">
<h3 class="text-sm font-medium text-slate-800">Files</h3>
- <button class="text-xs text-gray-600 hover:text-gray-800" on:click={clearSelections}>
+ <button class="text-xs text-gray-600 hover:text-gray-800" onclick={clearSelections}>
Unselect all
</button>
</div>
@@ -154,12 +163,12 @@
bind:this={inputEl}
type="text"
value={searchTerm}
- on:input={updateSearch}
- on:keydown={(event) => {
+ oninput={updateSearch}
+ onkeydown={(event) => {
if (event.key === 'Enter') {
const firstFilteredFile = filteredTree?.children?.[0];
if (firstFilteredFile) {
- dispatch('fileSelected', firstFilteredFile)
+ onfileSelected?.(firstFilteredFile)
}
}
}}
@@ -174,8 +183,8 @@
level={0}
{collapsed}
bind:selectedFiles
- on:fileSelected
- on:fileDeselected
+ {onfileSelected}
+ {onfileDeselected}
/>
{:else if searchTerm}
<li class="px-4 py-2 text-xs text-gray-500">No matching files found</li>
diff --git a/chat/src/Icon.svelte b/chat/src/Icon.svelte
index d224ada97..032754804 100644
--- a/chat/src/Icon.svelte
+++ b/chat/src/Icon.svelte
@@ -1,12 +1,21 @@
-<script>
- export let icon;
- let className = '';
- export { className as class };
- export let strokeWidth = 2;
- export let use = [() => {}, {}];
+<script lang="ts">
+
+ interface Props {
+ icon: any;
+ class?: string;
+ strokeWidth?: number;
+ use?: any;
+ }
- $: useFn = use[0];
- $: useParams = use[1];
+ let {
+ icon,
+ class: className = '',
+ strokeWidth = 2,
+ use = [() => {}, {}]
+ }: Props = $props();
+
+ let useFn = $derived(use[0]);
+ let useParams = $derived(use[1]);
</script>
<svg
diff --git a/chat/src/KnobsSidebar.svelte b/chat/src/KnobsSidebar.svelte
index 2b08c4898..91797c334 100644
--- a/chat/src/KnobsSidebar.svelte
+++ b/chat/src/KnobsSidebar.svelte
@@ -1,10 +1,14 @@
-<script>
+<script lang="ts">
import { params, activeAgent } from './stores.js';
import { t } from './i18n.js';
import KnowledgeBasePanel from './KnowledgeBasePanel.svelte';
- export let knobsOpen = false;
- export let db = null;
+ interface Props {
+ knobsOpen?: boolean;
+ db?: any;
+ }
+
+ let { knobsOpen = false, db = null }: Props = $props();
</script>
<aside
diff --git a/chat/src/KnowledgeBasePanel.svelte b/chat/src/KnowledgeBasePanel.svelte
index 601bb72aa..a6232c27c 100644
--- a/chat/src/KnowledgeBasePanel.svelte
+++ b/chat/src/KnowledgeBasePanel.svelte
@@ -1,13 +1,15 @@
-<script>
+<script lang="ts">
+ import { untrack } from 'svelte';
+
import { activeAgent, openaiAPIKey, notify } from './stores.js';
import { ingestFile, getChunksForAgent, deleteChunksForFile } from './knowledge.js';
- export let db;
+ let { db } = $props();
- let files = [];
- let uploading = false;
- let uploadProgress = { stage: '', done: 0, total: 0 };
- let fileInput;
+ let files = $state([]);
+ let uploading = $state(false);
+ let uploadProgress = $state({ stage: '', done: 0, total: 0 });
+ let fileInput = $state();
async function loadFiles() {
if (!db || !$activeAgent) return;
@@ -48,7 +50,9 @@
await loadFiles();
}
- $: if (db && $activeAgent) loadFiles();
+ $effect.pre(() => {
+ if (db && $activeAgent) untrack(loadFiles);
+ });
</script>
<div class="flex flex-col gap-3">
@@ -66,7 +70,7 @@
</div>
<button
class="text-[12px] text-red-400 hover:text-red-600"
- on:click={() => removeFile(f.filename)}
+ onclick={() => removeFile(f.filename)}
>Remove</button>
</li>
{/each}
@@ -87,7 +91,7 @@
type="file"
accept=".txt,.md"
class="hidden"
- on:change={handleUpload}
+ onchange={handleUpload}
/>
</label>
{/if}
diff --git a/chat/src/Message.svelte b/chat/src/Message.svelte
index ebf1e4dc1..c6be3399a 100644
--- a/chat/src/Message.svelte
+++ b/chat/src/Message.svelte
@@ -1,4 +1,4 @@
-<script context="module">
+<script module>
// Remembered position (in scroll-content space, so it's scroll-independent) of
// the avatar slot the agent last stood in. When a new assistant message mounts
// its own <agent-3d>, we use this to walk the avatar down from where it was to
@@ -8,8 +8,9 @@
const WALK_IN_MS = 820;
</script>
-<script>
- import { createEventDispatcher, tick } from 'svelte';
+<script lang="ts">
+
+ import { tick, untrack } from 'svelte';
import { fly } from 'svelte/transition';
import { cubicOut } from 'svelte/easing';
import { v4 as uuidv4 } from 'uuid';
@@ -40,11 +41,10 @@
import ToolcallButton from './ToolcallButton.svelte';
import ModelViewer3D from './ModelViewer3D.svelte';
- const dispatch = createEventDispatcher();
- let agentEl;
- let agentSlotEl;
- let agentWalkedIn = false;
+ let agentEl = $state();
+ let agentSlotEl = $state();
+ let agentWalkedIn = $state(false);
let lastReactedToUserId = null;
// Position of the avatar slot within the scroll container's content, immune to
@@ -94,15 +94,6 @@
setTimeout(() => done(), WALK_IN_MS + 120); // safety net if transitionend is missed
}
- $: if (agentEl && agentSlotEl && !agentWalkedIn) {
- agentWalkedIn = true;
- const slot = agentSlotEl;
- const run = () => walkAgentIntoPlace(slot, agentEl);
- if (agentEl._mounted) run();
- else agentEl.addEventListener('agent:ready', run, { once: true });
- // Never leave the slot stuck invisible if the avatar fails to load.
- setTimeout(() => { if (slot && slot.style.opacity === '0') slot.style.opacity = '1'; }, 6000);
- }
function faceCamera(el) {
const apply = () => {
@@ -132,16 +123,6 @@
lastReactedToUserId = userMessage.id;
}
- $: if (agentEl) faceCamera(agentEl);
- $: if (agentEl && convo?.messages?.length) {
- const last = convo.messages[i];
- const isLatest = last?.role === 'assistant'
- && i === convo.messages.findLastIndex((m) => m.role === 'assistant');
- if (isLatest) {
- const prior = [...convo.messages.slice(0, i)].reverse().find((m) => m.role === 'user');
- if (prior) reactToUserSentiment(agentEl, prior);
- }
- }
function msgTransition(node, { style }) {
if (style === 'snap') return { duration: 0 };
@@ -150,27 +131,30 @@
}
- export let message;
- export let i;
- export let convo;
- export let generating;
- export let collapsedRanges;
-
- export let saveMessage;
- export let deleteMessage;
- export let saveVersion;
- export let saveConversation;
- export let shiftVersion;
- export let insertSystemPrompt;
- export let submitCompletion;
- export let isChoosing;
- export let choiceHandler;
- export let question;
- export let choices;
-
- export let chose;
- export let activeToolcall;
- export let textareaEls;
+
+
+ let {
+ message = $bindable(),
+ i,
+ convo = $bindable(),
+ generating,
+ collapsedRanges,
+ saveMessage,
+ deleteMessage,
+ saveVersion,
+ saveConversation,
+ shiftVersion,
+ insertSystemPrompt,
+ submitCompletion,
+ isChoosing,
+ choiceHandler,
+ question,
+ choices,
+ chose = $bindable(),
+ activeToolcall = $bindable(),
+ textareaEls = $bindable(),
+ onrerender
+ } = $props();
// Tool responses carrying a 3D model envelope, rendered inline in the thread
// (in addition to the clickable pill that opens the full tool view).
@@ -287,26 +271,52 @@
return toolcalls.reverse().flat();
}
- let contentHeight;
- let copied = false;
+ let contentHeight = $state();
+ let copied = $state(false);
async function copyContent() {
await navigator.clipboard.writeText(message.content || '');
copied = true;
setTimeout(() => (copied = false), 1500);
}
+ $effect.pre(() => {
+ if (agentEl && agentSlotEl && !agentWalkedIn) {
+ agentWalkedIn = true;
+ const slot = agentSlotEl;
+ const run = () => walkAgentIntoPlace(slot, agentEl);
+ if (agentEl._mounted) run();
+ else agentEl.addEventListener('agent:ready', run, { once: true });
+ // Never leave the slot stuck invisible if the avatar fails to load.
+ setTimeout(() => { if (slot && slot.style.opacity === '0') slot.style.opacity = '1'; }, 6000);
+ }
+ });
+ $effect.pre(() => {
+ const el = agentEl;
+ if (el) untrack(() => faceCamera(el));
+ });
+ $effect.pre(() => {
+ if (agentEl && convo?.messages?.length) {
+ const last = convo.messages[i];
+ const isLatest = last?.role === 'assistant'
+ && i === convo.messages.findLastIndex((m) => m.role === 'assistant');
+ if (isLatest) {
+ const prior = [...convo.messages.slice(0, i)].reverse().find((m) => m.role === 'user');
+ if (prior) untrack(() => reactToUserSentiment(agentEl, prior));
+ }
+ }
+ });
</script>
{#if (['user', 'assistant'].includes(message.role) || (message.role === 'system' && (!message.customInstructions || (message.customInstructions && message.showCustomInstructions)))) && ($config.explicitToolView || !collapsedRanges.some((r) => i >= r.starti && i < r.endi))}
{@const effectiveAgentId = $localAgentId || $brandConfig?.agent_id || ''}
{@const hasLogo = message.role === 'assistant'}
{@const isLatestAssistant = message.role === 'assistant' && i === convo.messages.findLastIndex((m) => m.role === 'assistant')}
- <!-- svelte-ignore a11y-click-events-have-key-events a11y-no-noninteractive-element-interactions -->
+ <!-- svelte-ignore a11y_click_events_have_key_events, a11y_no_noninteractive_element_interactions -->
<li
data-role={message.role}
in:msgTransition={{ style: $config.messageAnimation ?? 'smooth' }}
class="group relative flex {message.role === 'user' ? 'justify-end' : 'justify-start'} pt-4 pb-10"
style="z-index: {convo.messages.length - i};"
- on:touchstart={(event) => {
+ ontouchstart={(event) => {
// Make click trigger hover on mobile:
event.target.dispatchEvent(new MouseEvent('mouseenter'));
}}
@@ -315,7 +325,7 @@
<Button
variant="outline"
class="absolute left-1/2 top-0 z-[98] -translate-x-1/2 border-dashed text-xs opacity-0 transition-[border-color,opacity] group-hover:opacity-100"
- on:click={insertSystemPrompt}
+ onclick={insertSystemPrompt}
>
<Icon icon={feTerminal} class="mr-2 h-3 w-3 text-slate-600" />
Add system prompt
@@ -324,7 +334,7 @@
<Button
variant="outline"
class="absolute left-1/2 top-0 z-[98] -translate-x-1/2 text-xs opacity-0 transition-opacity group-hover:opacity-100"
- on:click={() => {
+ onclick={() => {
convo.messages[i - 1].showCustomInstructions = true;
saveMessage(convo.messages[i - 1]);
}}
@@ -359,7 +369,7 @@
{/if}
<button
disabled={message.role === 'system' || (message.role === 'assistant' && hasLogo && isLatestAssistant)}
- on:click={() => {
+ onclick={() => {
if (message.role === 'assistant' && hasLogo && isLatestAssistant) return;
if (message.role === 'user') {
message.role = 'assistant';
@@ -376,7 +386,6 @@
its window and pull it up so the empty headroom is cropped, keeping the
figure large without the avatar floating in dead space. -->
<span bind:this={agentSlotEl} class="w-full h-full overflow-hidden inline-block shrink-0 rounded-[inherit] will-change-transform" style="opacity:0;">
- <!-- svelte-ignore custom-element-no-implicit-ns -->
<agent-3d
bind:this={agentEl}
{...($talkingHeadAvatarUrl
@@ -420,14 +429,14 @@
</div>
{/if}
- <!-- svelte-ignore a11y-no-static-element-interactions -->
+ <!-- svelte-ignore a11y_no_static_element_interactions -->
{#if message.editing}
<textarea
bind:this={textareaEls[i]}
class="w-full resize-none border-none bg-transparent p-0 leading-[28px] text-slate-800 outline-none focus:ring-0"
rows={1}
bind:value={message.pendingContent}
- on:keydown={(event) => {
+ onkeydown={(event) => {
if (
event.key === 'Enter' &&
!event.shiftKey &&
@@ -441,12 +450,12 @@
event.target.blur();
}
}}
- on:input={(event) => {
+ oninput={(event) => {
// Resize textarea as content grows:
event.target.style.height = 'auto';
event.target.style.height = event.target.scrollHeight + 'px';
}}
- />
+ ></textarea>
{:else}
<div class="flex w-full flex-col gap-6">
{#if !$config.explicitToolView}
@@ -476,7 +485,7 @@
{toolcall}
{toolresponse}
active={toolcall.id === activeToolcall?.id}
- on:click={() => {
+ onclick={() => {
activeToolcall = toolcall;
}}
/>
@@ -485,7 +494,7 @@
{#each model3dResponses(message).filter((p) => toolcallsOnLine.includes(p.toolcall)) as pair (pair.toolcall.id)}
<ModelViewer3D
content={pair.resp.content.content}
- on:resolved={(e) => persistResolvedModel(pair.resp, e.detail.glb_url)}
+ onresolved={(detail) => persistResolvedModel(pair.resp, detail.glb_url)}
/>
{/each}
{/if}
@@ -510,7 +519,7 @@
class="{message.thinking
? 'animate-pulse'
: ''} flex items-center gap-x-1.5 self-start rounded-full bg-paper-deep px-3.5 py-2 text-left text-xs text-ink-faint transition-colors hover:bg-paper-deep"
- on:click={() => {
+ onclick={() => {
message.thoughtsExpanded = !message.thoughtsExpanded;
saveMessage(message);
}}
@@ -542,7 +551,7 @@
{#if contentHeight > 400}
<button
class="sticky z-10 bottom-2 left-1/2 flex translate-x-[calc(-50%+40px)] items-center gap-x-1.5 self-start rounded-full bg-paper-deep px-3.5 py-2 text-left text-xs text-ink-faint transition-colors hover:bg-paper-deep"
- on:click={() => {
+ onclick={() => {
message.thoughtsExpanded = !message.thoughtsExpanded;
saveMessage(message);
}}
@@ -557,7 +566,7 @@
{/if}
{#if generating && message.role === 'assistant' && i === convo.messages.length - 1 && message.content === '' && !message.toolcalls}
- <div class="mt-2 h-3 w-3 shrink-0 animate-bounce rounded-full bg-slate-600" />
+ <div class="mt-2 h-3 w-3 shrink-0 animate-bounce rounded-full bg-slate-600"></div>
{/if}
<MessageContent {message} />
@@ -574,7 +583,7 @@
{toolcall}
{toolresponse}
active={toolcall.id === activeToolcall?.id}
- on:click={() => {
+ onclick={() => {
activeToolcall = toolcall;
}}
/>
@@ -583,7 +592,7 @@
{#each model3dResponses(message) as pair (pair.toolcall.id)}
<ModelViewer3D
content={pair.resp.content.content}
- on:resolved={(e) => persistResolvedModel(pair.resp, e.detail.glb_url)}
+ onresolved={(detail) => persistResolvedModel(pair.resp, detail.glb_url)}
/>
{/each}
{/if}
@@ -601,7 +610,7 @@
{question}
{choices}
class="mb-1"
- on:click={() => {
+ onclick={() => {
convo.messages[i].toolcalls[ti].expanded =
!convo.messages[i].toolcalls[ti].expanded;
saveMessage(convo.messages[i]);
@@ -617,7 +626,7 @@
{#if convo.messages.filter((msg) => msg.role !== 'system' && !msg.submitted).length >= 2 && i === convo.messages.length - 1 && message.role !== 'assistant'}
<button
class="flex items-center gap-x-1 rounded-full bg-green-100 px-3 py-2"
- on:click={() => {
+ onclick={() => {
submitCompletion();
}}
>
@@ -628,7 +637,7 @@
{#if message.role !== 'assistant' && message.pendingContent && message.pendingContent !== message.content}
<button
class="flex items-center gap-x-1 rounded-full bg-green-50 px-3 py-2 hover:bg-green-100"
- on:click={(event) => {
+ onclick={(event) => {
if (message.role === 'system') {
// If system message, accept the edit instead of submitting at point:
convo.messages[i].content = message.pendingContent;
@@ -654,7 +663,7 @@
{#if message.role === 'assistant' && message.pendingContent && message.pendingContent !== message.content && message.content !== '...' && i === convo.messages.length - 1}
<button
class="flex items-center gap-x-1.5 rounded-full bg-green-50 px-3 py-2 hover:bg-green-100"
- on:click={async () => {
+ onclick={async () => {
convo.messages[i].unclosed = true;
saveMessage(convo.messages[i]);
submitCompletion(false);
@@ -666,7 +675,7 @@
{/if}
<button
class="flex items-center gap-x-1 rounded-full bg-gray-50 px-3 py-2 hover:bg-gray-100"
- on:click={() => {
+ onclick={() => {
convo.messages[i].editing = false;
convo.messages[i].pendingContent = '';
saveMessage(convo.messages[i]);
@@ -688,7 +697,7 @@
<button
class="group flex h-6 w-6 shrink-0 rounded-full md:h-3 md:w-3"
disabled={versionIndex === 0}
- on:click={() => {
+ onclick={() => {
shiftVersion(-1, message, i);
}}
>
@@ -703,7 +712,7 @@
<button
class="group flex h-6 w-6 shrink-0 rounded-full md:h-3 md:w-3"
disabled={versionIndex === versions.length - 1}
- on:click={() => {
+ onclick={() => {
shiftVersion(1, message, i);
}}
>
@@ -723,7 +732,7 @@
<button
class="group flex h-6 w-6 shrink-0 rounded-full"
disabled={versionIndex === 0}
- on:click={() => shiftVersion(-1, prevMsg, i - 1)}
+ onclick={() => shiftVersion(-1, prevMsg, i - 1)}
>
<Icon icon={feChevronLeft} class="m-auto h-3 w-3 group-disabled:opacity-30" />
</button>
@@ -731,7 +740,7 @@
<button
class="group flex h-6 w-6 shrink-0 rounded-full"
disabled={versionIndex === versions.length - 1}
- on:click={() => shiftVersion(1, prevMsg, i - 1)}
+ onclick={() => shiftVersion(1, prevMsg, i - 1)}
>
<Icon icon={feChevronRight} class="m-auto h-3 w-3 group-disabled:opacity-30" />
</button>
@@ -753,7 +762,7 @@
{#if message.role !== 'system'}
<button
class="group/actions flex h-7 w-7 shrink-0 rounded-lg hover:bg-gray-100"
- on:click={copyContent}
+ onclick={copyContent}
aria-label="Copy message"
title="Copy"
>
@@ -768,7 +777,7 @@
class="group/actions flex h-7 w-7 shrink-0 rounded-lg hover:bg-gray-100"
aria-label="Edit message"
title="Edit"
- on:click={async () => {
+ onclick={async () => {
convo.messages[i].editing = true;
convo.messages[i].pendingContent = convo.messages[i].content;
await tick();
@@ -789,7 +798,7 @@
class="group/actions flex h-7 w-7 shrink-0 rounded-lg hover:bg-gray-100"
aria-label="Regenerate reply"
title="Regenerate"
- on:click={() => {
+ onclick={() => {
activeToolcall = null;
if (message.role === 'user') {
@@ -829,12 +838,12 @@
class="group/actions flex h-7 w-7 shrink-0 rounded-lg hover:bg-gray-100"
aria-label="Delete message"
title="Delete"
- on:click={() => {
+ onclick={() => {
// Remove this message from the conversation:
convo.messages = convo.messages.slice(0, i).concat(convo.messages.slice(i + 1));
deleteMessage(message);
saveConversation(convo);
- dispatch('rerender');
+ onrerender?.();
}}
>
<Icon
@@ -849,7 +858,7 @@
<button
aria-label="Insert a message here"
title="Insert a message here"
- on:click={async () => {
+ onclick={async () => {
// Insert a blank message inbetween the next message and the next next message:
let role;
if (message.role === 'assistant' || message.role === 'system') {
diff --git a/chat/src/MessageContent.svelte b/chat/src/MessageContent.svelte
index 28cedd593..328515cd4 100644
--- a/chat/src/MessageContent.svelte
+++ b/chat/src/MessageContent.svelte
@@ -1,9 +1,8 @@
-<script>
+<script lang="ts">
import Markdown from './svelte-marked/markdown/Markdown.svelte';
- export let message;
- export let contentHeight = undefined;
+ let { message, contentHeight = $bindable(undefined) } = $props();
</script>
{#if message.error}
diff --git a/chat/src/Modal.svelte b/chat/src/Modal.svelte
index f85a70800..315c9363d 100644
--- a/chat/src/Modal.svelte
+++ b/chat/src/Modal.svelte
@@ -1,26 +1,37 @@
-<script>
- import { createEventDispatcher } from 'svelte';
+<script lang="ts">
import { fade, scale } from 'svelte/transition';
import { cubicIn } from 'svelte/easing';
import Icon from './Icon.svelte';
import { feX } from './feather.js';
- const dispatch = createEventDispatcher();
- export let open = false;
- export let trigger = '';
- let className = '';
- export { className as class };
- export let buttonClass = '';
+
+ interface Props {
+ open?: boolean;
+ trigger?: string;
+ class?: string;
+ buttonClass?: string;
+ children?: import('svelte').Snippet;
+ onclose?: (...args: any[]) => void;
+ }
+
+ let {
+ open = $bindable(false),
+ trigger = '',
+ class: className = '',
+ buttonClass = '',
+ children,
+ onclose
+ }: Props = $props();
</script>
<svelte:window
- on:click={(event) => {
+ onclick={(event) => {
if (!trigger) return;
if (event.target.closest(`[data-trigger=${trigger}]`)) {
open = !open;
if (!open) {
- dispatch('close');
+ onclose?.();
}
}
}}
@@ -31,26 +42,26 @@
transition:fade={{ duration: 200, easing: cubicIn }}
aria-hidden="true"
class="fixed inset-0 z-[101] h-screen w-screen bg-black opacity-[0.1]"
- on:click={() => {
+ onclick={() => {
open = false;
- dispatch('close');
+ onclose?.();
}}
- />
+ ></div>
<div
role="dialog"
transition:scale={{ opacity: 0, start: 0.98, duration: 150, easing: cubicIn }}
class="{className} fixed left-1/2 top-1/2 z-[101] max-h-[95vh] w-[95%] -translate-x-1/2 -translate-y-1/2 overflow-y-auto rounded-xl border bg-white px-5 py-6 shadow-2xl scrollbar-ultraslim md:w-[700px]"
>
<button
- on:click={() => {
+ onclick={() => {
open = false;
- dispatch('close');
+ onclose?.();
}}
class="{buttonClass} absolute right-4 top-3 flex rounded-full p-3 transition-colors hover:bg-gray-100"
>
<Icon icon={feX} class="ml-auto h-4 w-4 text-slate-700" />
</button>
- <slot />
+ {@render children?.()}
</div>
{/if}
diff --git a/chat/src/ModelSelector.svelte b/chat/src/ModelSelector.svelte
index 0c2003e6f..e52f983a9 100644
--- a/chat/src/ModelSelector.svelte
+++ b/chat/src/ModelSelector.svelte
@@ -1,5 +1,5 @@
-<script>
- import { createEventDispatcher, tick } from 'svelte';
+<script lang="ts">
+ import { tick } from 'svelte';
import { scale, slide } from 'svelte/transition';
import { cubicIn } from 'svelte/easing';
import { formatModelName, formatMultipleModelNames } from './providers.js';
@@ -9,19 +9,24 @@
import Icon from './Icon.svelte';
import Checkbox from './Checkbox.svelte';
- const dispatch = createEventDispatcher();
- export let convo;
- export let models = [];
- let className = '';
- export { className as class };
+ interface Props {
+ convo: any;
+ models?: any;
+ class?: string;
+ onchange?: (...args: any[]) => void;
+ onchangeMulti?: (...args: any[]) => void;
+ }
+
+ let { convo, models = [], class: className = '', onchange, onchangeMulti }: Props = $props();
+
let id = 'tool-selector';
- let open = false;
- let query = '';
+ let open = $state(false);
+ let query = $state('');
- $: filteredModels =
- query.length > 0
+ let filteredModels =
+ $derived(query.length > 0
? models.filter((model) => {
if (model.provider.toLowerCase() === query.toLowerCase()) {
return true;
@@ -33,21 +38,21 @@
}
model.name.toLowerCase().includes(query.toLowerCase());
})
- : models;
+ : models);
- let inputEl;
- let innerWidth;
+ let inputEl = $state();
+ let innerWidth = $state();
</script>
<svelte:window
bind:innerWidth
- on:click={(event) => {
+ onclick={(event) => {
if (!event.target.closest(`#${id}`)) {
open = false;
query = '';
}
}}
- on:touchstart={(event) => {
+ ontouchstart={(event) => {
if (!event.target.closest(`#${id}`)) {
open = false;
query = '';
@@ -59,7 +64,7 @@
<div class="relative">
<button
class="flex h-9 w-full min-w-[190px] max-w-[200px] items-center gap-2.5 rounded-[10px] border border-slate-200 px-2 text-left transition-colors hover:border-slate-400 sm:h-10 sm:min-w-[280px] sm:pl-4 sm:pr-9"
- on:click={async () => {
+ onclick={async () => {
open = !open;
if (open && innerWidth > 640) {
await tick();
@@ -99,9 +104,9 @@
placeholder="Search models..."
class="w-full appearance-none rounded-t-lg border-0 border-b border-slate-300 px-4 py-2.5 text-sm text-slate-800 placeholder:text-slate-700 focus:outline-none focus:ring-0"
bind:value={query}
- on:keydown={(event) => {
+ onkeydown={(event) => {
if (event.key === 'Enter') {
- dispatch('change', filteredModels[0]);
+ onchange?.(filteredModels[0]);
open = false;
query = '';
}
@@ -112,8 +117,8 @@
<li>
<button
class="flex w-full items-center gap-2 whitespace-nowrap px-3 py-2 text-left text-xs transition-colors hover:bg-gray-100"
- on:click={() => {
- dispatch('change', model);
+ onclick={() => {
+ onchange?.(model);
open = false;
query = '';
}}
@@ -129,10 +134,9 @@
<Checkbox
checked={!!convo.models?.find((m) => m.id === model.id)}
- on:change={() => {}}
- on:click={(event) => {
+ onclick={(event) => {
event.stopPropagation();
- dispatch('changeMulti', model);
+ onchangeMulti?.(model);
}}
class="ml-auto"
/>
diff --git a/chat/src/ModelViewer3D.svelte b/chat/src/ModelViewer3D.svelte
index 794a529c6..ce7c42550 100644
--- a/chat/src/ModelViewer3D.svelte
+++ b/chat/src/ModelViewer3D.svelte
@@ -1,5 +1,5 @@
<script>
- import { createEventDispatcher, onDestroy, onMount } from 'svelte';
+ import { onDestroy, onMount } from 'svelte';
import {
ACESFilmicToneMapping,
AnimationMixer,
@@ -20,24 +20,21 @@
import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
import { RoomEnvironment } from 'three/addons/environments/RoomEnvironment.js';
- const dispatch = createEventDispatcher();
-
// Envelope produced by the forge tools (application/model-3d) or a bare
// { glb } for GLB links found in message text.
- export let content = {};
- export let height = 340;
+ let { content = {}, height = 340, onresolved = undefined } = $props();
- let container;
- let canvas;
+ let container = $state();
+ let canvas = $state();
// none → generating → loading → ready, or error / lost at any point.
- let state = 'none';
- let errorMessage = '';
- let loadPct = 0;
- let genPct = 0;
- let genLabel = 'Generating model';
- let hasSkeleton = false;
- let skeletonVisible = false;
- let glbUrl = content?.glb || null;
+ let loadState = $state('none');
+ let errorMessage = $state('');
+ let loadPct = $state(0);
+ let genPct = $state(0);
+ let genLabel = $state('Generating model');
+ let hasSkeleton = $state(false);
+ let skeletonVisible = $state(false);
+ let glbUrl = $state(content?.glb || null);
let renderer = null;
let scene = null;
@@ -58,12 +55,12 @@
const prompt = content?.prompt || '';
const etaSeconds = typeof content?.eta === 'number' && content.eta > 0 ? content.eta : 60;
const forgeUrl = 'https://three.ws/forge' + (prompt ? '?prompt=' + encodeURIComponent(prompt) : '');
- $: viewerUrl = glbUrl ? 'https://three.ws/viewer?src=' + encodeURIComponent(glbUrl) : null;
- $: arUrl = glbUrl ? 'https://three.ws/ar?src=' + encodeURIComponent(glbUrl) : null;
+ const viewerUrl = $derived(glbUrl ? 'https://three.ws/viewer?src=' + encodeURIComponent(glbUrl) : null);
+ const arUrl = $derived(glbUrl ? 'https://three.ws/ar?src=' + encodeURIComponent(glbUrl) : null);
onMount(() => {
if (content?.error) {
- state = 'error';
+ loadState = 'error';
errorMessage = String(content.error);
return;
}
@@ -97,13 +94,13 @@
} else if (content?.job) {
pollJob(content.job);
} else {
- state = 'error';
+ loadState = 'error';
errorMessage = 'No model URL or generation job was provided.';
}
}
function pollJob(job) {
- state = 'generating';
+ loadState = 'generating';
const startedAt = Date.now();
genTicker = setInterval(() => {
const elapsed = (Date.now() - startedAt) / 1000;
@@ -121,13 +118,13 @@
if (j.status === 'done' && j.glb_url) {
clearInterval(genTicker);
glbUrl = j.glb_url;
- dispatch('resolved', { glb_url: j.glb_url });
+ onresolved?.({ glb_url: j.glb_url });
loadModel(j.glb_url);
return;
}
if (j.status === 'failed') {
clearInterval(genTicker);
- state = 'error';
+ loadState = 'error';
errorMessage = j.error ? String(j.error) : 'Generation failed.';
return;
}
@@ -138,7 +135,7 @@
}
if (tries >= maxTries) {
clearInterval(genTicker);
- state = 'error';
+ loadState = 'error';
errorMessage = 'Generation timed out. Open the Forge to check on it.';
return;
}
@@ -161,7 +158,7 @@
}
async function loadModel(url) {
- state = 'loading';
+ loadState = 'loading';
loadPct = 0;
let gltf;
try {
@@ -176,14 +173,14 @@
gltf = await loadGlb('/api/glb?src=' + encodeURIComponent(url));
} catch {
if (destroyed) return;
- state = 'error';
+ loadState = 'error';
errorMessage = 'Could not load the 3D model file.';
return;
}
}
if (destroyed) return;
- // State first: animate() only runs while state === 'ready'.
- state = 'ready';
+ // State first: animate() only runs while loadState === 'ready'.
+ loadState = 'ready';
setupScene(gltf);
}
@@ -223,7 +220,7 @@
(ev) => {
ev.preventDefault();
cancelAnimationFrame(rafId);
- state = 'lost';
+ loadState = 'lost';
},
{ once: true },
);
@@ -262,7 +259,7 @@
}
function animate() {
- if (destroyed || state !== 'ready') return;
+ if (destroyed || loadState !== 'ready') return;
rafId = requestAnimationFrame(animate);
// Skip rendering while scrolled far offscreen; the context stays warm.
if (!visible) return;
@@ -319,18 +316,18 @@
}
</script>
-<!-- svelte-ignore a11y-no-noninteractive-tabindex a11y-no-noninteractive-element-interactions -->
+<!-- svelte-ignore a11y_no_noninteractive_tabindex, a11y_no_noninteractive_element_interactions -->
<div
bind:this={container}
class="relative w-full overflow-hidden rounded-lg border border-slate-200 bg-white focus-visible:outline focus-visible:outline-2 focus-visible:outline-slate-400"
style="min-height: {height}px"
- data-mv3d={state}
+ data-mv3d={loadState}
tabindex="0"
role="group"
aria-label={prompt ? '3D model: ' + prompt : '3D model viewer'}
- on:keydown={onKeydown}
+ onkeydown={onKeydown}
>
- {#if state === 'error'}
+ {#if loadState === 'error'}
<div class="flex flex-col items-center justify-center gap-3 px-6 text-center" style="height: {height}px">
<span class="text-sm font-medium text-slate-700">3D generation didn't finish</span>
<span class="max-w-md text-xs text-slate-500">{errorMessage}</span>
@@ -343,7 +340,7 @@
Retry in the Forge ↗
</a>
</div>
- {:else if state === 'generating' || state === 'none'}
+ {:else if loadState === 'generating' || loadState === 'none'}
<div class="flex flex-col items-center justify-center gap-4 px-6" style="height: {height}px">
{#if content?.preview}
<img
@@ -352,36 +349,34 @@
class="h-32 w-32 animate-pulse rounded-lg object-cover"
/>
{:else}
- <div class="h-32 w-32 animate-pulse rounded-lg bg-slate-100" />
+ <div class="h-32 w-32 animate-pulse rounded-lg bg-slate-100"></div>
{/if}
<div class="flex w-full max-w-xs flex-col gap-1.5">
<div class="h-1.5 w-full overflow-hidden rounded-full bg-slate-100">
<div
class="h-full rounded-full bg-slate-500 transition-[width] duration-500"
- style="width: {genPct}%"
- />
+ style="width: {genPct}%"></div>
</div>
<span class="text-center text-xs text-slate-500">{genLabel} · usually ~{etaSeconds}s</span>
</div>
</div>
- {:else if state === 'loading'}
+ {:else if loadState === 'loading'}
<div class="flex flex-col items-center justify-center gap-4 px-6" style="height: {height}px">
- <div class="h-32 w-32 animate-pulse rounded-lg bg-slate-100" />
+ <div class="h-32 w-32 animate-pulse rounded-lg bg-slate-100"></div>
<div class="flex w-full max-w-xs flex-col gap-1.5">
<div class="h-1.5 w-full overflow-hidden rounded-full bg-slate-100">
<div
class="h-full rounded-full bg-slate-500 transition-[width] duration-300"
- style="width: {loadPct}%"
- />
+ style="width: {loadPct}%"></div>
</div>
<span class="text-center text-xs text-slate-500">Loading model…</span>
</div>
</div>
- {:else if state === 'lost'}
+ {:else if loadState === 'lost'}
<div class="flex flex-col items-center justify-center gap-3 px-6" style="height: {height}px">
<span class="text-xs text-slate-500">The 3D view was paused to free graphics memory.</span>
<button
- on:click={reload}
+ onclick={reload}
class="rounded-full border border-slate-200 px-3.5 py-1.5 text-xs text-slate-600 transition-colors hover:bg-slate-50 focus-visible:outline focus-visible:outline-2 focus-visible:outline-slate-400"
>
Reload 3D view
@@ -391,11 +386,11 @@
<canvas
bind:this={canvas}
- class="{state === 'ready' ? 'block' : 'hidden'} w-full touch-none"
+ class="{loadState === 'ready' ? 'block' : 'hidden'} w-full touch-none"
style="height: {height}px"
- />
+ ></canvas>
- {#if state === 'ready'}
+ {#if loadState === 'ready'}
{#if prompt || content?.status_note}
<div class="pointer-events-none absolute left-3 top-2.5 max-w-[70%] rounded-lg bg-white/80 px-2.5 py-1.5 backdrop-blur-sm">
{#if prompt}
@@ -441,7 +436,7 @@
</a>
{/if}
<button
- on:click={recenter}
+ onclick={recenter}
class="ml-auto rounded-full border border-slate-200 bg-white/85 px-2.5 py-1 text-[11px] text-slate-600 backdrop-blur-sm transition-colors hover:bg-white focus-visible:outline focus-visible:outline-2 focus-visible:outline-slate-400"
aria-label="Recenter the camera"
>
@@ -449,7 +444,7 @@
</button>
{#if hasSkeleton}
<button
- on:click={toggleSkeleton}
+ onclick={toggleSkeleton}
class="rounded-full border border-slate-200 bg-white/85 px-2.5 py-1 text-[11px] backdrop-blur-sm transition-colors hover:bg-white focus-visible:outline focus-visible:outline-2 focus-visible:outline-slate-400 {skeletonVisible
? 'bg-slate-700 text-white hover:bg-slate-600'
: 'text-slate-600'}"
diff --git a/chat/src/NotificationBell.svelte b/chat/src/NotificationBell.svelte
index 98127ac6c..60d21a2ca 100644
--- a/chat/src/NotificationBell.svelte
+++ b/chat/src/NotificationBell.svelte
@@ -4,11 +4,11 @@
import Icon from './Icon.svelte';
import { feBell } from './feather.js';
- let notifications = [];
- let unreadCount = 0;
- let open = false;
+ let notifications = $state([]);
+ let unreadCount = $state(0);
+ let open = $state(false);
let loading = false;
- let el;
+ let el = $state();
async function fetchNotifications() {
if (!$currentUser) return;
@@ -79,14 +79,14 @@
});
</script>
-<svelte:window on:click={handleWindowClick} on:focus={() => { if ($currentUser) fetchNotifications(); }} />
+<svelte:window onclick={handleWindowClick} onfocus={() => { if ($currentUser) fetchNotifications(); }} />
{#if $currentUser}
<div class="relative" bind:this={el}>
<button
class="relative rounded p-2 text-ink hover:bg-paper-deep"
aria-label="Notifications"
- on:click={toggle}
+ onclick={toggle}
>
<Icon icon={feBell} class="h-5 w-5" />
{#if unreadCount > 0}
@@ -103,7 +103,7 @@
{#if unreadCount > 0}
<button
class="text-xs text-ink-soft hover:text-ink"
- on:click={markAllRead}
+ onclick={markAllRead}
>Mark all read</button>
{/if}
</div>
diff --git a/chat/src/PayWalletPicker.svelte b/chat/src/PayWalletPicker.svelte
index 6d26f3477..a9a263973 100644
--- a/chat/src/PayWalletPicker.svelte
+++ b/chat/src/PayWalletPicker.svelte
@@ -1,21 +1,22 @@
<script>
- import { onMount, onDestroy } from 'svelte';
+
+ import { onMount, onDestroy, untrack } from 'svelte';
import { currentUser, payAgentId, payWallet } from './stores.js';
- let open = false;
- let agents = []; // [{ id, name, solana_address, usdc, sol, ... }]
- let agentsLoading = false;
- let agentsError = '';
- let demoWallet = { address: null, usdc: null, sol: null, configured: null };
- let demoLoading = false;
- let demoError = '';
- let demoUnconfigured = false;
- let popoverEl;
- let buttonEl;
+ let open = $state(false);
+ let agents = $state([]); // [{ id, name, solana_address, usdc, sol, ... }]
+ let agentsLoading = $state(false);
+ let agentsError = $state('');
+ let demoWallet = $state({ address: null, usdc: null, sol: null, configured: null });
+ let demoLoading = $state(false);
+ let demoError = $state('');
+ let demoUnconfigured = $state(false);
+ let popoverEl = $state();
+ let buttonEl = $state();
- $: signedIn = !!$currentUser;
- $: agentsWithWallet = agents.filter((a) => !!a.solana_address);
- $: selectedAgent = agentsWithWallet.find((a) => a.id === $payAgentId) || null;
+ let signedIn = $derived(!!$currentUser);
+ let agentsWithWallet = $derived(agents.filter((a) => !!a.solana_address));
+ let selectedAgent = $derived(agentsWithWallet.find((a) => a.id === $payAgentId) || null);
function fmtUsdc(v) {
if (v == null || Number.isNaN(Number(v))) return '- USDC';
@@ -105,7 +106,7 @@
// list makes Svelte track them; the guard form `if (x || y || z)` would
// be always-truthy here because `agents` is always an array and
// `demoWallet` always an object.
- $: { agents; demoWallet; selectedAgent; publishWallet(); }
+ $effect.pre(() => { agents; demoWallet; selectedAgent; untrack(publishWallet); });
function selectShared() {
$payAgentId = null;
@@ -155,7 +156,7 @@
userUnsub?.();
});
- $: currentLabel = (() => {
+ let currentLabel = $derived((() => {
const w = $payWallet;
if (w?.address) {
const usdc = fmtUsdc(w.usdc);
@@ -165,18 +166,18 @@
if (demoLoading || agentsLoading) return 'Pay · loading…';
if (demoError) return 'Pay · wallet error';
return 'Pay · not configured';
- })();
- $: dotClass = $payWallet?.address
+ })());
+ let dotClass = $derived($payWallet?.address
? 'bg-emerald-500'
: demoError
? 'bg-red-500'
- : 'bg-slate-300';
+ : 'bg-slate-300');
</script>
<div class="relative">
<button
bind:this={buttonEl}
- on:click={() => (open = !open)}
+ onclick={() => (open = !open)}
class="flex h-9 items-center gap-2 rounded-full border border-rule bg-white px-3 text-[12px] font-medium text-ink shadow-sm transition-colors hover:bg-paper-deep"
title="Wallet that pays for x402 paid-tool calls"
>
@@ -196,7 +197,7 @@
class="flex w-full items-start gap-3 rounded-lg border px-3 py-2 text-left transition-colors {$payAgentId == null
? 'border-emerald-500 bg-emerald-50'
: 'border-rule hover:bg-paper-deep'}"
- on:click={selectShared}
+ onclick={selectShared}
>
<div class="mt-0.5 flex h-7 w-7 shrink-0 items-center justify-center rounded-md bg-gradient-to-br from-indigo-500 to-cyan-400 text-[10px] font-bold text-white">3</div>
<div class="min-w-0 flex-1">
@@ -240,7 +241,7 @@
: a.solana_address
? 'border-rule hover:bg-paper-deep'
: 'border-rule opacity-60'}"
- on:click={() => selectAgent(a)}
+ onclick={() => selectAgent(a)}
disabled={!a.solana_address}
title={a.solana_address ? `Pay from ${a.name}` : 'This agent has no Solana wallet yet'}
>
diff --git a/chat/src/ReasoningEffortRangeDropdown.svelte b/chat/src/ReasoningEffortRangeDropdown.svelte
index bda8a53d7..4312fc0bb 100644
--- a/chat/src/ReasoningEffortRangeDropdown.svelte
+++ b/chat/src/ReasoningEffortRangeDropdown.svelte
@@ -1,22 +1,26 @@
-<script>
+<script lang="ts">
import { scale } from 'svelte/transition';
import { cubicIn } from 'svelte/easing';
import { params } from './stores.js';
- export let open = false;
- export let convo;
+ interface Props {
+ open?: boolean;
+ convo: any;
+ }
- let innerWidth;
+ let { open = $bindable(false), convo }: Props = $props();
+
+ let innerWidth = $state();
</script>
<svelte:window
bind:innerWidth
- on:click={(event) => {
+ onclick={(event) => {
if (!event.target.closest('#reasoning-effort-dropdown')) {
open = false;
}
}}
- on:touchstart={(event) => {
+ ontouchstart={(event) => {
if (!event.target.closest('#reasoning-effort-dropdown')) {
open = false;
}
@@ -35,7 +39,7 @@
<div class="mb-2 flex items-baseline justify-between">
<button
class="flex self-start rounded-full bg-gray-200 px-2 py-0.5 text-left transition-colors hover:bg-gray-300"
- on:click={() => {
+ onclick={() => {
$params.reasoningEffort['range'] = min;
}}
>
@@ -43,7 +47,7 @@
</button>
<button
class="flex rounded-full bg-gray-200 px-2 py-0.5 text-left transition-colors hover:bg-gray-300"
- on:click={() => {
+ onclick={() => {
$params.reasoningEffort['range'] = max;
}}
>
diff --git a/chat/src/SettingsModal.svelte b/chat/src/SettingsModal.svelte
index 104abcfcc..76c66587c 100644
--- a/chat/src/SettingsModal.svelte
+++ b/chat/src/SettingsModal.svelte
@@ -1,5 +1,5 @@
-<script>
- import { createEventDispatcher, onDestroy, tick } from 'svelte';
+<script lang="ts">
+ import { onDestroy, tick } from 'svelte';
import { v4 as uuidv4 } from 'uuid';
import {
anthropicAPIKey,
@@ -43,20 +43,25 @@
import { sendSingleItem, resetSyncCircuit } from './sync.js';
import AvatarPreview from './AvatarPreview.svelte';
- const dispatch = createEventDispatcher();
- export let open = false;
- export let trigger = '';
+ interface Props {
+ open?: boolean;
+ trigger?: string;
+ onfetchModels?: (...args: any[]) => void;
+ ondisableTool?: (...args: any[]) => void;
+ }
+
+ let { open = $bindable(false), trigger = '', onfetchModels, ondisableTool }: Props = $props();
- let activeTab = 'api-keys';
+ let activeTab = $state('api-keys');
// Brand admin panel
- let adminKey = '';
- let adminUnlocked = false;
- let brandSaving = false;
- let brandSaveError = '';
- let brandSaveOk = false;
- let brandDraft = { name: '', logo_url: '', accent_color: '#6366f1', tagline: '', system_prompt: '' };
+ let adminKey = $state('');
+ let adminUnlocked = $state(false);
+ let brandSaving = $state(false);
+ let brandSaveError = $state('');
+ let brandSaveOk = $state(false);
+ let brandDraft = $state({ name: '', logo_url: '', accent_color: '#6366f1', tagline: '', system_prompt: '' });
function openBrandTab() {
activeTab = 'brand';
@@ -102,11 +107,11 @@
}
// Avatar selector: pulls user's avatars (session auth) + featured public avatars
- let myAvatars = [];
- let featuredAvatars = [];
- let avatarsLoading = false;
- let avatarsError = '';
- let avatarsLoaded = false;
+ let myAvatars = $state([]);
+ let featuredAvatars = $state([]);
+ let avatarsLoading = $state(false);
+ let avatarsError = $state('');
+ let avatarsLoaded = $state(false);
async function openAvatarTab() {
activeTab = 'avatar';
@@ -149,7 +154,7 @@
// Browser speech synthesis. Chrome populates getVoices() asynchronously, so
// the list starts empty and fills in on the voiceschanged event.
const speech = typeof window !== 'undefined' ? window.speechSynthesis : null;
- let voices = [];
+ let voices = $state([]);
function loadVoices() {
voices = speech ? speech.getVoices() : [];
@@ -170,20 +175,20 @@
speech.speak(utt);
}
- let addClientToolOpen = false;
- let loadClientTool = null;
+ let addClientToolOpen = $state(false);
+ let loadClientTool = $state(null);
- let elRefreshToolSchema;
+ let elRefreshToolSchema = $state();
// Draft values for API keys: nothing commits until Save is clicked
- let draftKeys = {
+ let draftKeys = $state({
openrouter: $openrouterAPIKey,
anthropic: $anthropicAPIKey,
openai: $openaiAPIKey,
groq: $groqAPIKey,
mistral: $mistralAPIKey,
- };
- let savedKey = '';
+ });
+ let savedKey = $state('');
const keyStores = {
openrouter: openrouterAPIKey,
@@ -201,7 +206,7 @@
}
async function onAPIKeyUpdate() {
- dispatch('fetchModels');
+ onfetchModels?.();
if ($syncServer.token && $syncServer.password) {
await sendSingleItem($syncServer.address, $syncServer.token, {
conversation: null,
@@ -224,7 +229,7 @@
class="{activeTab === 'api-keys'
? 'bg-gray-100/70'
: 'hover:bg-gray-100/70'} flex w-full items-center gap-x-2.5 rounded-lg px-4 py-2.5 text-left text-[13px] font-medium text-slate-700 transition-colors"
- on:click={() => (activeTab = 'api-keys')}
+ onclick={() => (activeTab = 'api-keys')}
>
<Icon icon={feKey} class="h-3 w-3 text-slate-700" />
API keys
@@ -235,7 +240,7 @@
class="{activeTab === 'custom-instructions'
? 'bg-gray-100/70'
: 'hover:bg-gray-100/70'} flex w-full items-center gap-x-2.5 rounded-lg px-4 py-2.5 text-left text-[13px] font-medium text-slate-700 transition-colors"
- on:click={() => (activeTab = 'custom-instructions')}
+ onclick={() => (activeTab = 'custom-instructions')}
>
<Icon icon={feEdit3} class="h-3 w-3 text-slate-700" />
Custom instructions
@@ -246,7 +251,7 @@
class="{activeTab === 'remote-server'
? 'bg-gray-100/70'
: ' hover:bg-gray-100/70'} flex w-full items-center gap-x-2.5 rounded-lg px-4 py-2.5 text-left text-[13px] font-medium text-slate-700 transition-colors"
- on:click={() => (activeTab = 'remote-server')}
+ onclick={() => (activeTab = 'remote-server')}
>
<Icon icon={feHardDrive} class="h-3 w-3 text-slate-700" />
Sync and servers
@@ -257,7 +262,7 @@
class="{activeTab === 'tools'
? 'bg-gray-100/70'
: ' hover:bg-gray-100/70'} flex w-full items-center gap-x-2.5 rounded-lg px-4 py-2.5 text-left text-[13px] font-medium text-slate-700 transition-colors"
- on:click={() => (activeTab = 'tools')}
+ onclick={() => (activeTab = 'tools')}
>
<Icon icon={feTool} class="h-3 w-3 text-slate-700" />
Tool calling
@@ -268,7 +273,7 @@
class="{activeTab === 'brand'
? 'bg-gray-100/70'
: ' hover:bg-gray-100/70'} flex w-full items-center gap-x-2.5 rounded-lg px-4 py-2.5 text-left text-[13px] font-medium text-slate-700 transition-colors"
- on:click={openBrandTab}
+ onclick={openBrandTab}
>
<Icon icon={feLayout} class="h-3 w-3 text-slate-700" />
Brand
@@ -280,7 +285,7 @@
class="{activeTab === 'avatar'
? 'bg-gray-100/70'
: ' hover:bg-gray-100/70'} flex w-full items-center gap-x-2.5 rounded-lg px-4 py-2.5 text-left text-[13px] font-medium text-slate-700 transition-colors"
- on:click={openAvatarTab}
+ onclick={openAvatarTab}
>
<Icon icon={feStar} class="h-3 w-3 text-slate-700" />
Avatar
@@ -312,7 +317,7 @@
{savedKey === key
? 'border-green-300 bg-green-50 text-green-700'
: 'border-slate-200 bg-slate-50 text-slate-500 hover:bg-slate-100'}"
- on:click={() => saveKey(key)}
+ onclick={() => saveKey(key)}
>
{savedKey === key ? '✓ Saved' : 'Save'}
</button>
@@ -345,7 +350,7 @@
bind:value={$params.customInstructions}
rows={10}
class="rounded-lg border border-slate-300 px-3 py-2 text-sm transition-colors scrollbar-slim focus:border-slate-400 focus:outline-none"
- /></label
+ ></textarea></label
>
{:else if activeTab === 'remote-server'}
<label class="mb-4 flex items-start gap-2 text-[13px] text-slate-700">
@@ -406,7 +411,7 @@
<input
type="text"
bind:value={$syncServer.address}
- on:change={resetSyncCircuit}
+ onchange={resetSyncCircuit}
placeholder="https://your-sync-server.example.com"
class="rounded-lg border border-slate-300 px-3 py-2 text-sm text-slate-800 transition-colors placeholder:text-gray-500 focus:border-slate-400 focus:outline-none"
/></label
@@ -475,13 +480,13 @@
readonly
class="mt-2 rounded-lg border border-slate-300 px-3 py-2 text-sm text-slate-800 transition-colors scrollbar-ultraslim placeholder:text-gray-500 focus:border-slate-400 focus:outline-none"
value={JSON.stringify($toolSchema, null, 2)}
- />
+ ></textarea>
<div class="mt-3 flex flex-col gap-3 text-sm sm:flex-row">
<Button
bind:el={elRefreshToolSchema}
variant="outline"
class="self-start"
- on:click={async () => {
+ onclick={async () => {
if (!$remoteServer.address) {
elRefreshToolSchema.dispatchEvent(new CustomEvent('flashError'));
return;
@@ -513,7 +518,7 @@
<Button
variant="outline"
class="self-start"
- on:click={() => {
+ onclick={() => {
const clientToolsSchemaIndex = $toolSchema.findIndex(
(g) => g.name === 'Client-side'
);
@@ -543,13 +548,13 @@
?.schema.filter((t) => t.clientDefinition) || [] as tool}
<ClientTool
definition={tool.clientDefinition}
- on:edit={async () => {
+ onedit={async () => {
addClientToolOpen = true;
await tick();
loadClientTool(tool.clientDefinition);
}}
- on:delete={() => {
- dispatch('disableTool', tool.clientDefinition.name);
+ ondelete={() => {
+ ondisableTool?.(tool.clientDefinition.name);
const clientToolsSchemaIndex = $toolSchema.findIndex(
(g) => g.name === 'Client-side'
);
@@ -567,7 +572,7 @@
{/each}
<Button
class="self-start"
- on:click={async () => {
+ onclick={async () => {
addClientToolOpen = true;
await tick();
@@ -607,7 +612,7 @@
{#each [['snap', 'Snap'], ['elegant', 'Elegant'], ['smooth', 'Smooth']] as [val, label]}
<button
class="flex-1 rounded-lg border px-3 py-1.5 text-[13px] transition-colors {($config.messageAnimation ?? 'smooth') === val ? 'border-slate-900 bg-slate-900 text-white' : 'border-slate-200 text-slate-700 hover:border-slate-400'}"
- on:click={() => ($config.messageAnimation = val)}
+ onclick={() => ($config.messageAnimation = val)}
>
{label}
</button>
@@ -629,7 +634,7 @@
/>
<button
class="rounded-lg bg-indigo-500 px-3 py-2 text-[13px] font-medium text-white hover:bg-indigo-600 disabled:opacity-50"
- on:click={() => { if (adminKey.trim()) adminUnlocked = true; }}
+ onclick={() => { if (adminKey.trim()) adminUnlocked = true; }}
>Unlock</button>
</div>
</label>
@@ -707,7 +712,7 @@
<button
class="mt-1 rounded-lg bg-indigo-500 px-4 py-2 text-[13px] font-medium text-white hover:bg-indigo-600 disabled:opacity-50"
disabled={brandSaving}
- on:click={saveBrand}
+ onclick={saveBrand}
>{brandSaving ? 'Saving…' : 'Save branding'}</button>
{/if}
</div>
@@ -745,7 +750,7 @@
</label>
<button
type="button"
- on:click={previewVoice}
+ onclick={previewVoice}
class="rounded-md border border-slate-200 px-3 py-1.5 text-[12px] font-medium text-slate-700 transition-colors hover:border-indigo-300 hover:bg-indigo-50 focus:outline-none focus:ring-2 focus:ring-indigo-300"
>Preview</button>
</div>
@@ -771,7 +776,7 @@
{#each myAvatars as a (a.id)}
<button
type="button"
- on:click={() => selectAvatar(a)}
+ onclick={() => selectAvatar(a)}
class="flex flex-col items-center gap-1 rounded-md border p-1.5 text-left transition-colors {$talkingHeadAvatarUrl === a.model_url
? 'border-indigo-400 bg-indigo-50'
: 'border-slate-200 hover:border-indigo-300'}"
@@ -791,7 +796,7 @@
{#each featuredAvatars as a (a.id)}
<button
type="button"
- on:click={() => selectAvatar(a)}
+ onclick={() => selectAvatar(a)}
class="flex flex-col items-center gap-1 rounded-md border p-1.5 text-left transition-colors {$talkingHeadAvatarUrl === a.model_url
? 'border-indigo-400 bg-indigo-50'
: 'border-slate-200 hover:border-indigo-300'}"
@@ -821,7 +826,7 @@
{#if $talkingHeadAvatarUrl}
<button
type="button"
- on:click={clearAvatar}
+ onclick={clearAvatar}
class="text-[11px] text-slate-500 underline hover:text-slate-700"
>Reset to default</button>
{/if}
@@ -847,7 +852,7 @@
<Modal bind:open={addClientToolOpen} class="!px-8 transition-[all] md:!w-[800px]">
<ClientToolSetting
bind:load={loadClientTool}
- on:save={({ detail }) => {
+ onsave={(detail) => {
let clientToolsSchemaIndex = $toolSchema.findIndex((g) => g.name === 'Client-side');
if (clientToolsSchemaIndex === -1) {
$toolSchema.push({
diff --git a/chat/src/SkillsMarketplaceModal.svelte b/chat/src/SkillsMarketplaceModal.svelte
index 607457118..cd1aa7c3d 100644
--- a/chat/src/SkillsMarketplaceModal.svelte
+++ b/chat/src/SkillsMarketplaceModal.svelte
@@ -1,33 +1,35 @@
<script>
+ import { untrack } from 'svelte';
+
import Modal from './Modal.svelte';
import Markdown from './svelte-marked/markdown/Markdown.svelte';
import { toolSchema, knowledgeSkills, currentUser, notify, pluginLibraryUrl } from './stores.js';
- export let open = false;
+ /**
+ * @typedef {Object} Props
+ * @property {boolean} [open]
+ */
+
+ /** @type {Props} */
+ let { open = $bindable(false) } = $props();
- let view = 'browse';
- $: if (view !== 'publish') publishError = null;
+ let view = $state('browse');
// Browse state
- let skills = [];
- let localSkills = [];
- let showLocalSkills = false;
- let loading = false;
- let loaded = false;
- let fetchFailed = false;
- let searchQuery = '';
- let debouncedSearch = '';
- let selectedCategory = null;
+ let skills = $state([]);
+ let localSkills = $state([]);
+ let showLocalSkills = $state(false);
+ let loading = $state(false);
+ let loaded = $state(false);
+ let fetchFailed = $state(false);
+ let searchQuery = $state('');
+ let debouncedSearch = $state('');
+ let selectedCategory = $state(null);
let page = null;
- let hasMore = false;
+ let hasMore = $state(false);
let sort = 'popular';
- let installPending = {};
+ let installPending = $state({});
- $: if (open && !loaded) {
- loadCategories();
- loadSkills(true);
- loadLocalSkills();
- }
async function loadLocalSkills() {
try {
@@ -117,14 +119,14 @@
}
// Detail expansion state
- let expandedSkillId = null;
- let detailLoading = false;
- let detail = null;
- let userRating = null;
- let hoverStar = 0;
+ let expandedSkillId = $state(null);
+ let detailLoading = $state(false);
+ let detail = $state(null);
+ let userRating = $state(null);
+ let hoverStar = $state(0);
// Publish state
- let publishForm = {
+ let publishForm = $state({
name: '',
slug: '',
description: '',
@@ -149,13 +151,13 @@
),
isPublic: true,
pricePerCallUsd: 0
- };
- let publishError = null;
- let publishLoading = false;
- let schemaValid = null;
- let schemaErrorMsg = '';
+ });
+ let publishError = $state(null);
+ let publishLoading = $state(false);
+ let schemaValid = $state(null);
+ let schemaErrorMsg = $state('');
- let categories = [];
+ let categories = $state([]);
async function loadCategories() {
try {
@@ -527,11 +529,11 @@
}
// Library tab state
- let libraryPlugins = [];
- let loadingLibrary = false;
- let libraryQuery = '';
- let libraryInstalling = {};
- let failedAvatars = new Set();
+ let libraryPlugins = $state([]);
+ let loadingLibrary = $state(false);
+ let libraryQuery = $state('');
+ let libraryInstalling = $state({});
+ let failedAvatars = $state(new Set());
async function loadPluginLibrary() {
loadingLibrary = true;
@@ -564,16 +566,6 @@
libraryLoaded = true;
}
- $: filteredLibraryPlugins = libraryQuery
- ? libraryPlugins.filter((p) => {
- const q = libraryQuery.toLowerCase();
- return (
- p.name.toLowerCase().includes(q) ||
- p.description.toLowerCase().includes(q) ||
- p.tags.some((t) => t.toLowerCase().includes(q))
- );
- })
- : libraryPlugins;
function isLibraryPluginInstalled(identifier) {
return $toolSchema.some(
@@ -620,24 +612,13 @@
}
}
- let libraryLoaded = false;
- let libraryError = false;
- let libraryFailed = {};
- $: if (view === 'library' && !loadingLibrary && !libraryLoaded) loadPluginLibrary();
+ let libraryLoaded = $state(false);
+ let libraryError = $state(false);
+ let libraryFailed = $state({});
- // init and keyboard
- $: if (open && !loaded && !loading) {
- Promise.all([loadSkills(true), loadCategories()]);
- }
-
- $: if (!open) { fetchFailed = false; loaded = false; }
- $: tagPills = publishForm.tags
- .split(',')
- .map((t) => t.trim())
- .filter(Boolean);
function handleKeydown(e) {
if (!open) return;
@@ -647,9 +628,48 @@
detail = null;
}
}
+ $effect.pre(() => {
+ if (view !== 'publish') publishError = null;
+ });
+ $effect.pre(() => {
+ if (!open) { fetchFailed = false; loaded = false; }
+ });
+ $effect.pre(() => {
+ if (open && !loaded) {
+ untrack(() => {
+ loadCategories();
+ loadSkills(true);
+ loadLocalSkills();
+ });
+ }
+ });
+ let filteredLibraryPlugins = $derived(libraryQuery
+ ? libraryPlugins.filter((p) => {
+ const q = libraryQuery.toLowerCase();
+ return (
+ p.name.toLowerCase().includes(q) ||
+ p.description.toLowerCase().includes(q) ||
+ p.tags.some((t) => t.toLowerCase().includes(q))
+ );
+ })
+ : libraryPlugins);
+ $effect.pre(() => {
+ if (view === 'library' && !loadingLibrary && !libraryLoaded) untrack(loadPluginLibrary);
+ });
+ // init and keyboard
+
+ $effect.pre(() => {
+ if (open && !loaded && !loading) {
+ untrack(() => Promise.all([loadSkills(true), loadCategories()]));
+ }
+ });
+ let tagPills = $derived(publishForm.tags
+ .split(',')
+ .map((t) => t.trim())
+ .filter(Boolean));
</script>
-<svelte:window on:keydown={handleKeydown} />
+<svelte:window onkeydown={handleKeydown} />
<Modal bind:open class="md:w-[820px] max-w-[820px]">
<!-- Tab bar -->
@@ -658,7 +678,7 @@
class="mr-4 border-b-2 pb-2 text-[13px] font-medium transition-colors {view === 'browse'
? 'border-indigo-500 text-indigo-600'
: 'border-transparent text-slate-500 hover:text-slate-700'}"
- on:click={() => (view = 'browse')}
+ onclick={() => (view = 'browse')}
>
Browse
</button>
@@ -666,7 +686,7 @@
class="mr-4 border-b-2 pb-2 text-[13px] font-medium transition-colors {view === 'library'
? 'border-indigo-500 text-indigo-600'
: 'border-transparent text-slate-500 hover:text-slate-700'}"
- on:click={() => (view = 'library')}
+ onclick={() => (view = 'library')}
>
Library
</button>
@@ -674,7 +694,7 @@
class="border-b-2 pb-2 text-[13px] font-medium transition-colors {view === 'publish'
? 'border-indigo-500 text-indigo-600'
: 'border-transparent text-slate-500 hover:text-slate-700'}"
- on:click={() => (view = 'publish')}
+ onclick={() => (view = 'publish')}
>
Publish
</button>
@@ -688,7 +708,7 @@
class="rounded-md px-3 py-1.5 text-left text-[12px] font-medium transition-colors {selectedCategory === null
? 'bg-indigo-50 text-indigo-700'
: 'text-slate-600 hover:bg-slate-100'}"
- on:click={() => selectCategory(null)}
+ onclick={() => selectCategory(null)}
>
All skills
</button>
@@ -697,7 +717,7 @@
class="rounded-md px-3 py-1.5 text-left text-[12px] transition-colors {categorySlug(selectedCategory) === cat.slug
? 'bg-indigo-50 font-medium text-indigo-700'
: 'text-slate-600 hover:bg-slate-100'}"
- on:click={() => selectCategory(cat)}
+ onclick={() => selectCategory(cat)}
>
{cat.label}
</button>
@@ -713,24 +733,24 @@
class="px-3 py-1 rounded-full text-sm"
class:bg-white={!showLocalSkills}
class:text-slate-500={showLocalSkills}
- on:click={() => (showLocalSkills = false)}>Marketplace</button
+ onclick={() => (showLocalSkills = false)}>Marketplace</button
>
<button
class="px-3 py-1 rounded-full text-sm"
class:bg-white={showLocalSkills}
class:text-slate-500={!showLocalSkills}
- on:click={() => (showLocalSkills = true)}>Local</button
+ onclick={() => (showLocalSkills = true)}>Local</button
>
</div>
<input
type="text"
placeholder="Search skills..."
bind:value={searchQuery}
- on:input={handleSearchInput}
+ oninput={handleSearchInput}
class="min-w-0 flex-1 rounded-lg border border-slate-200 bg-white px-3 py-1.5 text-[13px] text-slate-700 outline-none focus:border-indigo-400 focus:ring-1 focus:ring-indigo-200"
/>
<select
- on:change={handleSortChange}
+ onchange={handleSortChange}
class="rounded-lg border border-slate-200 bg-white px-2 py-1.5 text-[12px] text-slate-600 outline-none focus:border-indigo-400"
>
<option value="popular">Popular</option>
@@ -745,14 +765,14 @@
class="rounded-full border px-2.5 py-0.5 text-[11px] {selectedCategory === null
? 'border-indigo-400 bg-indigo-50 text-indigo-700'
: 'border-slate-200 text-slate-500'}"
- on:click={() => selectCategory(null)}>All</button
+ onclick={() => selectCategory(null)}>All</button
>
{#each categories as cat (cat.slug)}
<button
class="rounded-full border px-2.5 py-0.5 text-[11px] {categorySlug(selectedCategory) === cat.slug
? 'border-indigo-400 bg-indigo-50 text-indigo-700'
: 'border-slate-200 text-slate-500'}"
- on:click={() => selectCategory(cat)}>{cat.label}</button
+ onclick={() => selectCategory(cat)}>{cat.label}</button
>
{/each}
</div>
@@ -828,14 +848,14 @@
{:else if installed}
<button
class="shrink-0 rounded-lg border border-slate-200 px-3 py-1.5 text-[11px] text-slate-500 transition-colors hover:border-red-200 hover:bg-red-50 hover:text-red-600"
- on:click={() => toggleLocalInstall(skill)}
+ onclick={() => toggleLocalInstall(skill)}
>
Remove
</button>
{:else}
<button
class="shrink-0 rounded-lg border border-slate-200 bg-slate-50 px-3 py-1.5 text-[11px] font-medium text-slate-700 transition-colors hover:bg-slate-100"
- on:click={() => toggleLocalInstall(skill)}
+ onclick={() => toggleLocalInstall(skill)}
>
Install
</button>
@@ -853,13 +873,13 @@
<div class="grid grid-cols-1 gap-3 sm:grid-cols-2">
{#each skills as skill (skill.id)}
<!-- Card -->
- <!-- svelte-ignore a11y-click-events-have-key-events -->
- <!-- svelte-ignore a11y-no-static-element-interactions -->
+ <!-- svelte-ignore a11y_click_events_have_key_events -->
+ <!-- svelte-ignore a11y_no_static_element_interactions -->
<div
class="cursor-pointer rounded-lg border px-3 py-3 transition-colors {expandedSkillId === skill.id
? 'border-indigo-300 bg-indigo-50/30 ring-1 ring-indigo-200'
: 'border-slate-200 hover:border-slate-300'}"
- on:click={() => toggleExpand(skill)}
+ onclick={() => toggleExpand(skill)}
aria-expanded={expandedSkillId === skill.id}
>
<div class="flex items-start justify-between gap-x-3">
@@ -901,14 +921,14 @@
{:else if isInstalled(skill)}
<button
class="shrink-0 rounded-lg border border-slate-200 px-3 py-1.5 text-[11px] text-slate-500 transition-colors hover:border-red-200 hover:bg-red-50 hover:text-red-600"
- on:click={(e) => toggleInstall(skill, e)}
+ onclick={(e) => toggleInstall(skill, e)}
>
Remove
</button>
{:else}
<button
class="shrink-0 rounded-lg border border-slate-200 bg-slate-50 px-3 py-1.5 text-[11px] font-medium text-slate-700 transition-colors hover:bg-slate-100"
- on:click={(e) => toggleInstall(skill, e)}
+ onclick={(e) => toggleInstall(skill, e)}
>
Install
</button>
@@ -975,13 +995,13 @@
(!userRating && star <= Math.round(detail.avg_rating ?? 0))
? '#f59e0b'
: '#d1d5db'}"
- on:click={() => {
+ onclick={() => {
if ($currentUser && !userRating) submitRating(detail.id, star);
}}
- on:mouseenter={() => {
+ onmouseenter={() => {
if ($currentUser && !userRating) hoverStar = star;
}}
- on:mouseleave={() => (hoverStar = 0)}
+ onmouseleave={() => (hoverStar = 0)}
tabindex={$currentUser && !userRating ? 0 : -1}
aria-label="Rate {star} star{star > 1 ? 's' : ''}"
>*</button>
@@ -1055,21 +1075,21 @@
{:else if isInstalled(skill)}
<button
class="rounded-lg border border-slate-200 px-3 py-1.5 text-[12px] text-slate-500 transition-colors hover:border-red-200 hover:bg-red-50 hover:text-red-600"
- on:click={(e) => toggleInstall(skill, e)}
+ onclick={(e) => toggleInstall(skill, e)}
>
Remove skill
</button>
{:else}
<button
class="rounded-lg border border-indigo-200 bg-indigo-50 px-3 py-1.5 text-[12px] font-medium text-indigo-700 transition-colors hover:bg-indigo-100"
- on:click={(e) => toggleInstall(skill, e)}
+ onclick={(e) => toggleInstall(skill, e)}
>
Install skill
</button>
{/if}
<button
class="rounded-lg border border-slate-200 px-3 py-1.5 text-[12px] text-slate-600 transition-colors hover:bg-slate-50"
- on:click={(e) => copySlug(skill.slug, e)}
+ onclick={(e) => copySlug(skill.slug, e)}
>
Copy slug
</button>
@@ -1084,7 +1104,7 @@
<button
class="mt-4 w-full rounded-lg border border-slate-200 py-2 text-[12px] text-slate-500 transition-colors hover:bg-slate-50 disabled:opacity-50"
disabled={loading}
- on:click={() => loadSkills(false)}
+ onclick={() => loadSkills(false)}
>
{loading ? 'Loading...' : 'Load more'}
</button>
@@ -1111,7 +1131,7 @@
<span>Failed to load plugin registry</span>
<button
class="ml-3 underline hover:text-red-900"
- on:click={() => { libraryLoaded = false; loadPluginLibrary(); }}
+ onclick={() => { libraryLoaded = false; loadPluginLibrary(); }}
>
Retry
</button>
@@ -1128,7 +1148,7 @@
alt=""
class="h-8 w-8 shrink-0 rounded-md object-cover"
loading="lazy"
- on:error={() => { failedAvatars = new Set([...failedAvatars, plugin.identifier]); }}
+ onerror={() => { failedAvatars = new Set([...failedAvatars, plugin.identifier]); }}
/>
{:else}
<span class="shrink-0 text-2xl leading-none">{plugin.avatar?.startsWith('http') ? '🔧' : plugin.avatar}</span>
@@ -1163,7 +1183,7 @@
: 'bg-indigo-50 text-indigo-600 hover:bg-indigo-100'}
disabled:opacity-50"
disabled={!!libraryInstalling[plugin.identifier]}
- on:click={() =>
+ onclick={() =>
isLibraryPluginInstalled(plugin.identifier)
? toolSchema.update((g) => g.filter((x) => x.id !== `lib:${plugin.identifier}`))
: installLibraryPlugin(plugin)}
@@ -1196,7 +1216,7 @@
id="pf-name"
type="text"
bind:value={publishForm.name}
- on:input={(e) => { handleNameInput(e); publishError = null; }}
+ oninput={(e) => { handleNameInput(e); publishError = null; }}
placeholder="My Skill"
class="rounded-lg border border-slate-200 px-3 py-1.5 text-[13px] text-slate-700 outline-none focus:border-indigo-400 focus:ring-1 focus:ring-indigo-200"
/>
@@ -1208,7 +1228,7 @@
id="pf-slug"
type="text"
bind:value={publishForm.slug}
- on:input={() => (publishError = null)}
+ oninput={() => (publishError = null)}
placeholder="my-skill"
class="rounded-lg border border-slate-200 px-3 py-1.5 text-[13px] text-slate-700 outline-none focus:border-indigo-400 focus:ring-1 focus:ring-indigo-200"
/>
@@ -1222,11 +1242,11 @@
<textarea
id="pf-desc"
bind:value={publishForm.description}
- on:input={() => (publishError = null)}
+ oninput={() => (publishError = null)}
placeholder="Describe what this skill does..."
rows="3"
class="resize-none rounded-lg border border-slate-200 px-3 py-1.5 text-[13px] text-slate-700 outline-none focus:border-indigo-400 focus:ring-1 focus:ring-indigo-200"
- />
+ ></textarea>
</div>
<div class="flex gap-x-3">
@@ -1253,7 +1273,7 @@
id="pf-tags"
type="text"
bind:value={publishForm.tags}
- on:input={() => (publishError = null)}
+ oninput={() => (publishError = null)}
placeholder="search, web, api"
class="rounded-lg border border-slate-200 px-3 py-1.5 text-[13px] text-slate-700 outline-none focus:border-indigo-400 focus:ring-1 focus:ring-indigo-200"
/>
@@ -1275,16 +1295,16 @@
<textarea
id="pf-schema"
bind:value={publishForm.schemaText}
- on:input={() => (publishError = null)}
+ oninput={() => (publishError = null)}
rows="10"
spellcheck="false"
class="resize-y rounded-lg border border-slate-200 px-3 py-1.5 font-mono text-[12px] text-slate-700 outline-none focus:border-indigo-400 focus:ring-1 focus:ring-indigo-200"
- />
+ ></textarea>
<div class="flex items-center gap-x-2">
<button
type="button"
class="rounded-lg border border-slate-200 px-3 py-1 text-[11px] text-slate-600 transition-colors hover:bg-slate-50"
- on:click={validateSchema}
+ onclick={validateSchema}
>
Validate JSON
</button>
@@ -1332,7 +1352,7 @@
type="button"
disabled={publishLoading || !publishForm.name || !publishForm.slug}
class="self-start rounded-lg bg-indigo-600 px-4 py-2 text-[13px] font-medium text-white transition-colors hover:bg-indigo-700 disabled:opacity-50"
- on:click={publishSkill}
+ onclick={publishSkill}
>
{publishLoading ? 'Publishing...' : 'Publish skill'}
</button>
diff --git a/chat/src/ToolDropdown.svelte b/chat/src/ToolDropdown.svelte
index fef5f8fce..90afb60a2 100644
--- a/chat/src/ToolDropdown.svelte
+++ b/chat/src/ToolDropdown.svelte
@@ -1,4 +1,4 @@
-<script>
+<script lang="ts">
import { scale, slide } from 'svelte/transition';
import { cubicIn } from 'svelte/easing';
import { toolSchema } from './stores.js';
@@ -8,15 +8,19 @@
import { focusOnMount } from './actions.js';
import ToolPackModal from './ToolPackModal.svelte';
- export let open = false;
- export let convo;
- export let saveConversation;
+ interface Props {
+ open?: boolean;
+ convo: any;
+ saveConversation: any;
+ }
+
+ let { open = $bindable(false), convo = $bindable(), saveConversation }: Props = $props();
- let collapsed = {};
- let innerWidth;
- let query = '';
+ let collapsed = $state({});
+ let innerWidth = $state();
+ let query = $state('');
- $: filteredSchema = query.trim()
+ let filteredSchema = $derived(query.trim()
? $toolSchema
.map((group) => {
const q = query.toLowerCase();
@@ -27,7 +31,7 @@
return tools.length ? { ...group, schema: tools } : null;
})
.filter(Boolean)
- : $toolSchema;
+ : $toolSchema);
function setTools(newTools) {
convo.tools = convo.tools.concat(newTools);
@@ -44,17 +48,17 @@
saveConversation(convo);
}
- let packModalOpen = false;
+ let packModalOpen = $state(false);
</script>
<svelte:window
bind:innerWidth
- on:click={(event) => {
+ onclick={(event) => {
if (!event.target.closest('#tool-dropdown')) {
open = false;
}
}}
- on:touchstart={(event) => {
+ ontouchstart={(event) => {
if (!event.target.closest('#tool-dropdown')) {
open = false;
}
@@ -72,7 +76,7 @@
<h3 class="text-sm font-medium text-slate-800">Tools</h3>
<button
class="text-xs text-gray-600 hover:text-gray-800"
- on:click={() => {
+ onclick={() => {
clearTools();
}}
>
@@ -93,13 +97,13 @@
{/if}
{#each filteredSchema as group}
<div class="relative w-full">
- <!-- svelte-ignore a11y-label-has-associated-control -->
+ <!-- svelte-ignore a11y_label_has_associated_control -->
<label
class="flex w-full items-center gap-x-3 whitespace-nowrap py-2 pl-4 pr-3 text-left text-xs transition-colors hover:bg-gray-100"
>
<Checkbox
checked={group.schema.every((t) => convo.tools.includes(t.function.name))}
- on:change={(event) => {
+ onchange={(event) => {
const names = group.schema.map((t) => t.function.name);
if (event.target.checked) {
setTools(names);
@@ -112,7 +116,7 @@
</label>
<button
- on:click={() => (collapsed[group.name] = !collapsed[group.name])}
+ onclick={() => (collapsed[group.name] = !collapsed[group.name])}
class="absolute right-1 top-1/2 flex h-8 w-8 -translate-y-1/2 rounded-full transition-colors hover:bg-gray-100"
>
<Icon
@@ -128,13 +132,13 @@
<div transition:slide={{ duration: 300 }}>
{#each group.schema as schema, i}
<li class="flex w-full">
- <!-- svelte-ignore a11y-label-has-associated-control -->
+ <!-- svelte-ignore a11y_label_has_associated_control -->
<label
class="flex w-full items-center gap-x-3 whitespace-nowrap py-2 pl-6 pr-3 text-left text-xs transition-colors hover:bg-gray-100"
>
<Checkbox
checked={convo.tools.includes(schema.function.name)}
- on:change={(event) => {
+ onchange={(event) => {
if (event.target.checked) {
setTools([schema.function.name]);
} else {
@@ -155,7 +159,7 @@
<div class="border-t border-slate-100 px-3 py-2">
<button
class="w-full rounded-lg border border-slate-200 py-1.5 text-[11px] text-slate-500 transition-colors hover:bg-gray-50 hover:text-slate-700"
- on:click={() => (packModalOpen = true)}
+ onclick={() => (packModalOpen = true)}
>
Browse tool packs
</button>
diff --git a/chat/src/ToolPackModal.svelte b/chat/src/ToolPackModal.svelte
index 8b1029037..f6ec8a33a 100644
--- a/chat/src/ToolPackModal.svelte
+++ b/chat/src/ToolPackModal.svelte
@@ -1,9 +1,13 @@
-<script>
+<script lang="ts">
import Modal from './Modal.svelte';
import { toolSchema } from './stores.js';
import { curatedToolPacks } from './tools.js';
- export let open = false;
+ interface Props {
+ open?: boolean;
+ }
+
+ let { open = $bindable(false) }: Props = $props();
function isInstalled(pack) {
return $toolSchema.some((g) => g.name === pack.name);
@@ -35,14 +39,14 @@
{#if isInstalled(pack)}
<button
class="shrink-0 rounded-lg border border-slate-200 px-3 py-1.5 text-[12px] text-slate-500 transition-colors hover:border-red-200 hover:bg-red-50 hover:text-red-600"
- on:click={() => remove(pack)}
+ onclick={() => remove(pack)}
>
Remove
</button>
{:else}
<button
class="shrink-0 rounded-lg border border-slate-200 bg-slate-50 px-3 py-1.5 text-[12px] font-medium text-slate-700 transition-colors hover:bg-slate-100"
- on:click={() => install(pack)}
+ onclick={() => install(pack)}
>
Install
</button>
diff --git a/chat/src/ToolPill.svelte b/chat/src/ToolPill.svelte
index 84482e0b0..5cfcdfb1f 100644
--- a/chat/src/ToolPill.svelte
+++ b/chat/src/ToolPill.svelte
@@ -1,15 +1,21 @@
-<script>
+<script lang="ts">
import Icon from './Icon.svelte';
- export let selected = false;
- export let icon;
+ interface Props {
+ selected?: boolean;
+ icon: any;
+ children?: import('svelte').Snippet;
+ onclick?: (event: any) => void;
+ }
+
+ let { selected = false, icon, children, onclick }: Props = $props();
</script>
<button
class="{selected
? 'text-white bg-slate-800'
: 'bg-white hover:bg-gray-200'} shrink-0 flex items-center gap-1.5 rounded-full border border-slate-200 px-2.5 py-1 text-sm transition-colors"
- on:click
+ onclick={onclick}
>
<Icon
{icon}
@@ -18,5 +24,5 @@
? 'text-white'
: 'text-slate-800'} m-auto h-3.5 w-3.5 transition-colors group-disabled:text-slate-400"
/>
- <slot />
+ {@render children?.()}
</button>
diff --git a/chat/src/Toolcall.svelte b/chat/src/Toolcall.svelte
index 7f15499e8..c1506a87e 100644
--- a/chat/src/Toolcall.svelte
+++ b/chat/src/Toolcall.svelte
@@ -1,5 +1,5 @@
-<script>
- import { createEventDispatcher } from 'svelte';
+<script lang="ts">
+
import { fade, slide } from 'svelte/transition';
import JsonView from './svelte-json-view/JsonView.svelte';
import Icon from './Icon.svelte';
@@ -7,68 +7,90 @@
import Choice from './Choice.svelte';
import { feCheck, feChevronDown, feLoader, feX } from './feather.js';
- const dispatch = createEventDispatcher();
- export let toolcall;
- export let toolresponse;
- export let collapsable = true;
- export let closeButton = false;
- export let isChoosing = false;
- export let choiceHandler;
- export let question = '';
- export let choices = [];
- export let chose = null;
- let className = '';
- export { className as class };
+ interface Props {
+ toolcall: any;
+ toolresponse: any;
+ collapsable?: boolean;
+ closeButton?: boolean;
+ isChoosing?: boolean;
+ choiceHandler: any;
+ question?: string;
+ choices?: any;
+ chose?: any;
+ class?: string;
+ onclose?: (...args: any[]) => void;
+ onclick?: (event: any) => void;
+ }
- $: finished = toolcall.finished || toolresponse;
+ let {
+ toolcall,
+ toolresponse,
+ collapsable = true,
+ closeButton = false,
+ isChoosing = false,
+ choiceHandler,
+ question = '',
+ choices = [],
+ chose = $bindable(null),
+ class: className = '',
+ onclose,
+ onclick
+ }: Props = $props();
+
- let displayType = null;
- let displayTypeDisabled = false;
- let displayedContent = null;
- $: if (toolresponse && toolresponse.content && toolresponse.content.contentType) {
- displayType = null;
- displayedContent = null;
- // When a special contentType is returned, if a `content` field is not present,
- // we automatically fill it with the value of whatever argument (single) was passed into the tool call.
- // This is done in order to save tokens, because it prevents us having to re-send the content again to the model.
- if (!toolresponse.content.content && Object.keys(toolcall.arguments).length === 1) {
- displayedContent = toolcall.arguments[Object.keys(toolcall.arguments)[0]];
- } else {
- displayedContent = toolresponse.content.content;
- }
- if (displayedContent) {
- const contentType = toolresponse.content.contentType;
- // Get display type for this type of content:
- if (contentType.startsWith('image/')) {
- displayType = 'image';
- } else if (contentType === 'text/html') {
- displayType = 'webpage';
- } else if (contentType === 'text/markdown') {
- displayType = 'markdown';
- } else if (contentType === 'application/tx-result') {
- displayType = 'tx_result';
- } else if (contentType === 'application/model-3d') {
- displayType = 'model3d';
+ let finished = $derived(toolcall.finished || toolresponse);
+
+ let displayType = $state(null);
+ let displayTypeDisabled = $state(false);
+ let displayedContent = $state(null);
+ $effect.pre(() => {
+ if (toolresponse && toolresponse.content && toolresponse.content.contentType) {
+ displayType = null;
+ displayedContent = null;
+ // When a special contentType is returned, if a `content` field is not present,
+ // we automatically fill it with the value of whatever argument (single) was passed into the tool call.
+ // This is done in order to save tokens, because it prevents us having to re-send the content again to the model.
+ if (!toolresponse.content.content && Object.keys(toolcall.arguments).length === 1) {
+ displayedContent = toolcall.arguments[Object.keys(toolcall.arguments)[0]];
+ } else {
+ displayedContent = toolresponse.content.content;
+ }
+ if (displayedContent) {
+ const contentType = toolresponse.content.contentType;
+ // Get display type for this type of content:
+ if (contentType.startsWith('image/')) {
+ displayType = 'image';
+ } else if (contentType === 'text/html') {
+ displayType = 'webpage';
+ } else if (contentType === 'text/markdown') {
+ displayType = 'markdown';
+ } else if (contentType === 'application/tx-result') {
+ displayType = 'tx_result';
+ } else if (contentType === 'application/model-3d') {
+ displayType = 'model3d';
+ }
+ // ...
}
- // ...
}
- }
- $: if (isChoosing) {
- displayType = 'choice';
- }
+ });
+ $effect.pre(() => {
+ if (isChoosing) {
+ displayType = 'choice';
+ }
+ });
</script>
<div class="{className} flex h-full w-full flex-col bg-white">
- <!-- svelte-ignore a11y-no-static-element-interactions -->
+ <!-- svelte-ignore a11y_no_static_element_interactions -->
<svelte:element
this={collapsable ? 'button' : 'div'}
class="{!collapsable || toolcall.expanded ? '' : 'rounded-b-lg'} {collapsable
? 'transition-colors hover:bg-gray-50'
: ''} flex items-center gap-4 rounded-t-lg border border-slate-200 px-5 py-3 text-sm text-slate-700 sm:gap-3"
- on:click
+ onclick={onclick}
>
{#if finished}
<span in:fade={{ duration: 300 }}>
@@ -93,7 +115,7 @@
<div class="-my-1.5 -mr-2 ml-auto flex items-center gap-2">
{#if displayType !== null}
<button
- on:click={(event) => {
+ onclick={(event) => {
event.stopPropagation();
displayTypeDisabled = !displayTypeDisabled;
}}
@@ -115,8 +137,8 @@
/>
{:else if closeButton}
<button
- on:click={() => {
- dispatch('close');
+ onclick={() => {
+ onclose?.();
}}
class="flex rounded-full p-3 transition-colors hover:bg-gray-100"
>
@@ -145,11 +167,11 @@
{:else if toolcall.arguments}
{toolcall.arguments}
{:else}
- <div class="h-3 w-3 shrink-0 animate-bounce rounded-full bg-slate-600" />
+ <div class="h-3 w-3 shrink-0 animate-bounce rounded-full bg-slate-600"></div>
{/if}
</div>
{#if toolresponse}
- <div class="h-px w-full border-t border-dashed border-slate-300" />
+ <div class="h-px w-full border-t border-dashed border-slate-300"></div>
<div class="flex flex-col rounded-b-lg border border-t-0 border-slate-200">
<span class="px-4 pt-3 text-sm font-medium tracking-[0.01em] text-slate-700"
>Result:</span
@@ -179,7 +201,7 @@
class="h-full min-h-[50vh] w-full"
frameborder="0"
allowfullscreen
- />
+ ></iframe>
</div>
{:else if displayType === 'choice'}
<div class="flex flex-col rounded-b-lg border border-t-0 border-slate-200 px-6 py-5">
diff --git a/chat/src/ToolcallButton.svelte b/chat/src/ToolcallButton.svelte
index 23144f34e..58c49b00b 100644
--- a/chat/src/ToolcallButton.svelte
+++ b/chat/src/ToolcallButton.svelte
@@ -1,13 +1,18 @@
-<script>
+<script lang="ts">
import Icon from './Icon.svelte';
import { feTerminal } from './feather.js';
import { onMount } from 'svelte';
- export let toolcall;
- export let toolresponse;
- export let active = false;
+ interface Props {
+ toolcall: any;
+ toolresponse: any;
+ active?: boolean;
+ onclick?: (event: any) => void;
+ }
- let flash = false;
+ let { toolcall, toolresponse, active = false, onclick }: Props = $props();
+
+ let flash = $state(false);
onMount(() => {
flash = true;
@@ -24,7 +29,7 @@
: 'bg-gray-200 hover:bg-gray-300'} {flash
? 'ring-2 ring-gray-400 ring-offset-1'
: ''} group/toolcall relative flex items-center gap-2 self-start rounded-full px-3.5 py-2 transition-[background-color,box-shadow] duration-500"
- on:click
+ onclick={onclick}
>
<Icon icon={feTerminal} class="{active ? 'text-white' : 'text-slate-800'} h-4 w-4" />
{#if toolcall}
diff --git a/chat/src/Tooltip.svelte b/chat/src/Tooltip.svelte
index 3e377fff3..ce0238fcc 100644
--- a/chat/src/Tooltip.svelte
+++ b/chat/src/Tooltip.svelte
@@ -1,12 +1,16 @@
-<script>
+<script lang="ts">
import Icon from './Icon.svelte';
import { feHelpCircle } from './feather.js';
import { tooltip } from './tooltip.js';
- export let icon = feHelpCircle;
- export let content = '';
- let className = '';
- export { className as class };
+ interface Props {
+ icon?: any;
+ content?: string;
+ class?: string;
+ }
+
+ let { icon = feHelpCircle, content = '', class: className = '' }: Props = $props();
+
</script>
<Icon {icon} class="{className} h-3 w-3 text-slate-800" use={[tooltip, { content }]} />
\ No newline at end of file
diff --git a/chat/src/TxApprovalModal.svelte b/chat/src/TxApprovalModal.svelte
index 13ffcaa40..5642324ec 100644
--- a/chat/src/TxApprovalModal.svelte
+++ b/chat/src/TxApprovalModal.svelte
@@ -1,25 +1,34 @@
-<script>
+<script lang="ts">
import { fade, scale } from 'svelte/transition';
import { cubicIn } from 'svelte/easing';
import Button from './Button.svelte';
- export let details; // { network, from, to, amount, token, memo?, estimatedFee? }
- export let guard = null; // GuardChain verdict from /api/agent/guard, when preflighted
- export let onApprove; // () => void
- export let onReject; // () => void
+ interface Props {
+ details: any; // { network, from, to, amount, token, memo?, estimatedFee? }
+ guard?: any; // GuardChain verdict from /api/agent/guard, when preflighted
+ onApprove: any; // () => void
+ onReject: any; // () => void
+ }
+
+ let {
+ details,
+ guard = null,
+ onApprove,
+ onReject
+ }: Props = $props();
- let pending = false;
+ let pending = $state(false);
// A `block` verdict never reaches this modal (the tool body is refused
// before the wallet prompt). The intervention layer always reads
// approval_required here because this modal IS the intervention, so the
// chip keys off every OTHER layer: "cleared" means nothing beyond the
// approval you are already giving was flagged.
- $: guardFlags = (guard?.layers || []).filter(
+ let guardFlags = $derived((guard?.layers || []).filter(
(l) => l.layer !== 'intervention' && ['warn', 'approval_required', 'block', 'error'].includes(l.status),
- );
- $: guardTone = guard && guardFlags.length === 0 ? 'ok' : 'review';
- $: guardCriticalSpots = (guard?.blindSpots || []).filter((s) => s.severity === 'critical');
+ ));
+ let guardTone = $derived(guard && guardFlags.length === 0 ? 'ok' : 'review');
+ let guardCriticalSpots = $derived((guard?.blindSpots || []).filter((s) => s.severity === 'critical'));
function truncate(addr) {
if (!addr || addr.length <= 12) return addr;
@@ -36,21 +45,21 @@
onReject();
}
- $: rows = [
+ let rows = $derived([
{ label: 'Network', value: details.network },
{ label: 'From', value: truncate(details.from) },
{ label: 'To', value: truncate(details.to) },
{ label: 'Amount', value: `${details.amount} ${details.token}` },
...(details.memo ? [{ label: 'Memo', value: details.memo }] : []),
...(details.estimatedFee ? [{ label: 'Estimated Fee', value: details.estimatedFee }] : []),
- ];
+ ]);
</script>
<div
transition:fade={{ duration: 200, easing: cubicIn }}
aria-hidden="true"
class="fixed inset-0 z-[200] bg-black/60"
-/>
+></div>
<div
role="dialog"
@@ -103,7 +112,7 @@
variant="outline"
class="flex-1 !justify-center !border-slate-600 !bg-transparent !text-slate-300 hover:!border-slate-400 disabled:opacity-50"
disabled={pending}
- on:click={reject}
+ onclick={reject}
>
Reject
</Button>
@@ -111,7 +120,7 @@
variant="dark"
class="flex-1 !justify-center !bg-indigo-600 hover:!bg-indigo-500 disabled:opacity-50"
disabled={pending}
- on:click={approve}
+ onclick={approve}
>
Approve
</Button>
diff --git a/chat/src/WalletConnect.svelte b/chat/src/WalletConnect.svelte
index 8569899b5..6d6fbe69d 100644
--- a/chat/src/WalletConnect.svelte
+++ b/chat/src/WalletConnect.svelte
@@ -2,8 +2,8 @@
import { currentUser, loadCurrentUser, walletProvider } from './stores.js';
import { signInWithEVM, signInWithSolana, signOut } from './walletAuth.js';
- let loading = null; // 'evm' | 'sol' | null
- let error = '';
+ let loading = $state(null); // 'evm' | 'sol' | null
+ let error = $state('');
async function connectEVM() {
error = '';
@@ -54,7 +54,7 @@
<span class="opacity-30">·</span>
<button
class="text-sm text-ink-soft underline hover:text-ink"
- on:click={handleSignOut}
+ onclick={handleSignOut}
>Sign out</button>
</span>
{:else}
@@ -63,7 +63,7 @@
<!-- EVM button -->
<button
disabled={loading !== null}
- on:click={connectEVM}
+ onclick={connectEVM}
class="h-9 rounded-full bg-black px-4 text-sm font-medium text-white transition-colors hover:bg-[#333] disabled:opacity-50"
>
{loading === 'evm' ? 'Connecting…' : 'Connect EVM'}
@@ -71,7 +71,7 @@
<!-- Solana button -->
<button
disabled={loading !== null}
- on:click={connectSolana}
+ onclick={connectSolana}
class="h-9 rounded-full border border-rule bg-white px-4 text-sm font-medium text-ink transition-colors hover:bg-paper disabled:opacity-50"
>
{loading === 'sol' ? 'Connecting…' : 'Connect Solana'}
diff --git a/chat/src/main.js b/chat/src/main.js
index 55fb5e739..aa6f96e36 100644
--- a/chat/src/main.js
+++ b/chat/src/main.js
@@ -1,7 +1,8 @@
import './app.pcss';
import App from './App.svelte';
+import { mount } from "svelte";
-const app = new App({
+const app = mount(App, {
target: document.getElementById('app'),
});
diff --git a/chat/src/svelte-json-view/JsonView.svelte b/chat/src/svelte-json-view/JsonView.svelte
index 9b7b98ca9..e415ef619 100644
--- a/chat/src/svelte-json-view/JsonView.svelte
+++ b/chat/src/svelte-json-view/JsonView.svelte
@@ -1,15 +1,25 @@
<script>
- /** @type {*} - object or array to display */
- export let json;
- /** @type {number} - initial expansion depth */
- export let depth = Infinity;
- export let _cur = 0;
- export let _last = true;
+ import JsonView from './JsonView.svelte';
+
+
+
+ /**
+ * @typedef {Object} Props
+ * @property {*} json
+ * @property {number} [depth]
+ * @property {number} [_cur]
+ * @property {boolean} [_last]
+ */
- let items = [];
- let isArray = false;
- let brackets = ['', ''];
- let collapsed = false;
+ /** @type {Props} */
+ let {
+ json,
+ depth = Infinity,
+ _cur = 0,
+ _last = true
+ } = $props();
+
+ let collapsed = $state(false);
/**
* @param {*} i
@@ -54,13 +64,13 @@
if (e instanceof KeyboardEvent && ['Enter', ' '].includes(e.key)) clicked();
}
- $: {
- items = getType(json) === 'object' ? Object.keys(json) : [];
- isArray = Array.isArray(json);
- brackets = isArray ? ['[', ']'] : ['{', '}'];
- }
+ const items = $derived(getType(json) === 'object' ? Object.keys(json) : []);
+ const isArray = $derived(Array.isArray(json));
+ const brackets = $derived(isArray ? ['[', ']'] : ['{', '}']);
- $: collapsed = depth < _cur;
+ $effect.pre(() => {
+ collapsed = depth < _cur;
+ });
</script>
{#if !items.length}
@@ -73,8 +83,8 @@
class:isArray
role="button"
tabindex="0"
- on:click={clicked}
- on:keydown={pressed}>{brackets[0]}...{brackets[1]}</span
+ onclick={clicked}
+ onkeydown={pressed}>{brackets[0]}...{brackets[1]}</span
>{#if !_last && collapsed}<span class="_jsonSep">,</span>{/if}
{:else}
<span
@@ -82,8 +92,8 @@
class:isArray
role="button"
tabindex="0"
- on:click={clicked}
- on:keydown={pressed}>{brackets[0]}</span
+ onclick={clicked}
+ onkeydown={pressed}>{brackets[0]}</span
>
<ul class="_jsonList">
{#each items as i, idx}
@@ -92,7 +102,7 @@
<span class="_jsonKey">{stringify(i)}</span><span class="_jsonSep">:</span>
{/if}
{#if getType(json[i]) === 'object'}
- <svelte:self json={json[i]} {depth} _cur={_cur + 1} _last={idx === items.length - 1} />
+ <JsonView json={json[i]} {depth} _cur={_cur + 1} _last={idx === items.length - 1} />
{:else}
<span class="_jsonVal {getType(json[i])}">{format(json[i])}</span
>{#if idx < items.length - 1}<span class="_jsonSep">,</span>{/if}
@@ -105,41 +115,41 @@
class:isArray
role="button"
tabindex="0"
- on:click={clicked}
- on:keydown={pressed}>{brackets[1]}</span
+ onclick={clicked}
+ onkeydown={pressed}>{brackets[1]}</span
>{#if !_last}<span class="_jsonSep">,</span>{/if}
{/if}
<style>
- :where(._jsonList) {
+ :where(:global(._jsonList)) {
list-style: none;
margin: 0;
padding: 0;
padding-left: var(--jsonPaddingLeft, 1rem);
}
- :where(._jsonBkt) {
+ :where(:global(._jsonBkt)) {
color: var(--jsonBracketColor, currentcolor);
}
- :where(._jsonBkt):not(.empty):hover {
+ :where(:global(._jsonBkt)):not(.empty):hover {
cursor: pointer;
background: var(--jsonBracketHoverBackground, rgba(255,255,255,0.08));
}
- :where(._jsonSep) {
+ :where(:global(._jsonSep)) {
color: var(--jsonSeparatorColor, currentcolor);
}
- :where(._jsonKey) {
+ :where(:global(._jsonKey)) {
color: var(--jsonKeyColor, currentcolor);
}
- :where(._jsonVal) {
+ :where(:global(._jsonVal)) {
color: var(--jsonValColor, #9ca3af);
}
- :where(._jsonVal).string {
+ :where(:global(._jsonVal)).string {
color: var(--jsonValStringColor, #34d399);
}
- :where(._jsonVal).number {
+ :where(:global(._jsonVal)).number {
color: var(--jsonValNumberColor, #fbbf24);
}
- :where(._jsonVal).boolean {
+ :where(:global(._jsonVal)).boolean {
color: var(--jsonValBooleanColor, #60a5fa);
}
</style>
diff --git a/chat/src/svelte-marked/markdown/Markdown.svelte b/chat/src/svelte-marked/markdown/Markdown.svelte
index fd42b2339..9e5bb7770 100644
--- a/chat/src/svelte-marked/markdown/Markdown.svelte
+++ b/chat/src/svelte-marked/markdown/Markdown.svelte
@@ -1,4 +1,6 @@
<script lang="ts">
+ import { run } from 'svelte/legacy';
+
import type { TokensList } from 'marked';
import MarkdownTokens from './MarkdownTokens.svelte';
@@ -13,34 +15,46 @@
suppressWarnings();
- /**
+
+
+
+
+
+
+ interface Props {
+ /**
* The markdown source
*/
- export let source: string;
-
- /**
+ source: string;
+ /**
* Options passed to markdown renderers
*/
- export let options: Partial<MarkdownOptions> = {};
-
- /**
+ options?: Partial<MarkdownOptions>;
+ /**
* Optional renderers that can overwrite the default ones.
*/
- export let renderers: Partial<Renderers> = {};
+ renderers?: Partial<Renderers>;
+ message: any;
+ }
- export let message;
+ let {
+ source,
+ options = {},
+ renderers = {},
+ message
+ }: Props = $props();
- let tokens: TokensList;
- let actualRenderers: Renderers;
- let actualOptions: MarkdownOptions;
+ let tokens: TokensList = $state();
+ let actualRenderers: Renderers = $state();
+ let actualOptions: MarkdownOptions = $state();
- $: {
+ run(() => {
// Only a single reactive block is needed here, so that changing the source
// Will also re-create the options and renderers, so that a new Slugger is created
tokens = parse(source);
actualRenderers = { ...defaultRenderers(), ...renderers };
actualOptions = { ...defaultOptions(), ...options };
- }
+ });
</script>
<MarkdownTokens {tokens} renderers={actualRenderers} options={actualOptions} {message} />
diff --git a/chat/src/svelte-marked/markdown/MarkdownToken.svelte b/chat/src/svelte-marked/markdown/MarkdownToken.svelte
index bba28fd8b..1fc1a07d1 100644
--- a/chat/src/svelte-marked/markdown/MarkdownToken.svelte
+++ b/chat/src/svelte-marked/markdown/MarkdownToken.svelte
@@ -3,19 +3,29 @@
import MarkdownTokens from './MarkdownTokens.svelte'
import type { MarkdownOptions, Renderers } from './markedConfiguration'
- export let token: Token
- export let renderers: Renderers
- export let options: MarkdownOptions
- export let message;
+ interface Props {
+ token: Token;
+ renderers: Renderers;
+ options: MarkdownOptions;
+ message: any;
+ }
+
+ let {
+ token,
+ renderers,
+ options,
+ message
+ }: Props = $props();
</script>
{#if renderers[token.type]}
- <svelte:component this={renderers[token.type]} {token} {options} {renderers} {message}>
+ {@const SvelteComponent = renderers[token.type]}
+ <SvelteComponent {token} {options} {renderers} {message}>
{#if 'tokens' in token && token['tokens']}
<MarkdownTokens tokens={token['tokens']} {renderers} {options} {message} />
{:else}
{token.raw}
{/if}
- </svelte:component>
+ </SvelteComponent>
{/if}
diff --git a/chat/src/svelte-marked/markdown/MarkdownTokens.svelte b/chat/src/svelte-marked/markdown/MarkdownTokens.svelte
index 84619c44b..83cda23b7 100644
--- a/chat/src/svelte-marked/markdown/MarkdownTokens.svelte
+++ b/chat/src/svelte-marked/markdown/MarkdownTokens.svelte
@@ -3,11 +3,20 @@
import MarkdownToken from './MarkdownToken.svelte'
import type { MarkdownOptions, Renderers } from './markedConfiguration'
- export let tokens: Token[] | null
- export let renderers: Renderers
- export let options: MarkdownOptions
- export let message;
+ interface Props {
+ tokens: Token[] | null;
+ renderers: Renderers;
+ options: MarkdownOptions;
+ message: any;
+ }
+
+ let {
+ tokens,
+ renderers,
+ options,
+ message
+ }: Props = $props();
</script>
{#if tokens}
diff --git a/chat/src/svelte-marked/markdown/components/MarkdownBlockKatex.svelte b/chat/src/svelte-marked/markdown/components/MarkdownBlockKatex.svelte
index b277eabe8..acd38ae3c 100644
--- a/chat/src/svelte-marked/markdown/components/MarkdownBlockKatex.svelte
+++ b/chat/src/svelte-marked/markdown/components/MarkdownBlockKatex.svelte
@@ -1,9 +1,9 @@
<script lang="ts">
import katex from 'katex';
- export let token = undefined;
+ let { token = undefined } = $props();
- $: html = katex.renderToString(token.text, { throwOnError: false, displayMode: token.displayMode }) + '\n';
+ let html = $derived(katex.renderToString(token.text, { throwOnError: false, displayMode: token.displayMode }) + '\n');
</script>
{@html html}
diff --git a/chat/src/svelte-marked/markdown/components/MarkdownBloquote.svelte b/chat/src/svelte-marked/markdown/components/MarkdownBloquote.svelte
index 57f325e5f..934835540 100644
--- a/chat/src/svelte-marked/markdown/components/MarkdownBloquote.svelte
+++ b/chat/src/svelte-marked/markdown/components/MarkdownBloquote.svelte
@@ -1,6 +1,11 @@
<script lang="ts">
import type { Tokens } from 'marked'
import type { MarkdownOptions, Renderers } from '../markedConfiguration'
+ interface Props {
+ children?: import('svelte').Snippet;
+ }
+
+ let { children }: Props = $props();
export const token: Tokens.Blockquote = undefined
export const options: MarkdownOptions = undefined
@@ -8,5 +13,5 @@
</script>
<blockquote>
- <slot />
+ {@render children?.()}
</blockquote>
diff --git a/chat/src/svelte-marked/markdown/components/MarkdownDel.svelte b/chat/src/svelte-marked/markdown/components/MarkdownDel.svelte
index 348d68dbd..0af482336 100644
--- a/chat/src/svelte-marked/markdown/components/MarkdownDel.svelte
+++ b/chat/src/svelte-marked/markdown/components/MarkdownDel.svelte
@@ -1,6 +1,11 @@
<script lang="ts">
import type { Tokens } from 'marked'
import type { MarkdownOptions, Renderers } from '../markedConfiguration'
+ interface Props {
+ children?: import('svelte').Snippet;
+ }
+
+ let { children }: Props = $props();
export const token: Tokens.Del = undefined
export const options: MarkdownOptions = undefined
@@ -8,5 +13,5 @@
</script>
<del>
- <slot />
+ {@render children?.()}
</del>
diff --git a/chat/src/svelte-marked/markdown/components/MarkdownDfn.svelte b/chat/src/svelte-marked/markdown/components/MarkdownDfn.svelte
index ef52529b0..f14d26d16 100644
--- a/chat/src/svelte-marked/markdown/components/MarkdownDfn.svelte
+++ b/chat/src/svelte-marked/markdown/components/MarkdownDfn.svelte
@@ -1,6 +1,11 @@
<script lang="ts">
import type { Tokens } from 'marked'
import type { MarkdownOptions, Renderers } from '../markedConfiguration'
+ interface Props {
+ children?: import('svelte').Snippet;
+ }
+
+ let { children }: Props = $props();
export const token: Tokens.Blockquote = undefined
export const options: MarkdownOptions = undefined
@@ -8,5 +13,5 @@
</script>
<dfn>
- <slot />
+ {@render children?.()}
</dfn>
diff --git a/chat/src/svelte-marked/markdown/components/MarkdownEm.svelte b/chat/src/svelte-marked/markdown/components/MarkdownEm.svelte
index 70ea5f48c..c8360ca3d 100644
--- a/chat/src/svelte-marked/markdown/components/MarkdownEm.svelte
+++ b/chat/src/svelte-marked/markdown/components/MarkdownEm.svelte
@@ -1,6 +1,11 @@
<script lang="ts">
import type { Tokens } from 'marked'
import type { MarkdownOptions, Renderers } from '../markedConfiguration'
+ interface Props {
+ children?: import('svelte').Snippet;
+ }
+
+ let { children }: Props = $props();
export const token: Tokens.Em = undefined
export const options: MarkdownOptions = undefined
@@ -8,5 +13,5 @@
</script>
<em>
- <slot />
+ {@render children?.()}
</em>
diff --git a/chat/src/svelte-marked/markdown/components/MarkdownHeading.svelte b/chat/src/svelte-marked/markdown/components/MarkdownHeading.svelte
index 1298d4a31..1fa49fe72 100644
--- a/chat/src/svelte-marked/markdown/components/MarkdownHeading.svelte
+++ b/chat/src/svelte-marked/markdown/components/MarkdownHeading.svelte
@@ -4,14 +4,19 @@
import type { Tokens } from 'marked'
import type { MarkdownOptions, Renderers } from '../markedConfiguration'
- export let token: Tokens.Heading
- export let options: MarkdownOptions
+ interface Props {
+ token: Tokens.Heading;
+ options: MarkdownOptions;
+ children?: import('svelte').Snippet;
+ }
+
+ let { token, options, children }: Props = $props();
export const renderers: Renderers = undefined
- let id: string | undefined
- $: id = generatePathSegment(token.text, options.slugger)
+ let id: string | undefined = $derived(generatePathSegment(token.text, options.slugger))
+
</script>
<svelte:element this={`h${token.depth}`} {id}>
- <slot />
+ {@render children?.()}
</svelte:element>
diff --git a/chat/src/svelte-marked/markdown/components/MarkdownHtml.svelte b/chat/src/svelte-marked/markdown/components/MarkdownHtml.svelte
index e77a3b0ae..e7c6417f7 100644
--- a/chat/src/svelte-marked/markdown/components/MarkdownHtml.svelte
+++ b/chat/src/svelte-marked/markdown/components/MarkdownHtml.svelte
@@ -4,12 +4,16 @@
import { parseXML } from '$src/widgets.js';
import ArtifactButton from '$src/ArtifactButton.svelte';
- export let token: Tokens.HTML;
export const options: MarkdownOptions = undefined;
export const renderers: Renderers = undefined;
- export let message;
+ interface Props {
+ token: Tokens.HTML;
+ message: any;
+ }
- $: xml = parseXML(token.text);
+ let { token, message }: Props = $props();
+
+ let xml = $derived(parseXML(token.text));
</script>
{#if xml.element === 'artifact' && message?.role === 'assistant'}
diff --git a/chat/src/svelte-marked/markdown/components/MarkdownImage.svelte b/chat/src/svelte-marked/markdown/components/MarkdownImage.svelte
index 0951718bc..230de1d64 100644
--- a/chat/src/svelte-marked/markdown/components/MarkdownImage.svelte
+++ b/chat/src/svelte-marked/markdown/components/MarkdownImage.svelte
@@ -2,7 +2,11 @@
import type { Tokens } from 'marked'
import type { MarkdownOptions, Renderers } from '../markedConfiguration'
- export let token: Tokens.Image
+ interface Props {
+ token: Tokens.Image;
+ }
+
+ let { token }: Props = $props();
export const options: MarkdownOptions = undefined
export const renderers: Renderers = undefined
</script>
diff --git a/chat/src/svelte-marked/markdown/components/MarkdownInlineKatex.svelte b/chat/src/svelte-marked/markdown/components/MarkdownInlineKatex.svelte
index f1033d438..eef4c843d 100644
--- a/chat/src/svelte-marked/markdown/components/MarkdownInlineKatex.svelte
+++ b/chat/src/svelte-marked/markdown/components/MarkdownInlineKatex.svelte
@@ -1,9 +1,9 @@
<script lang="ts">
import katex from 'katex';
- export let token = undefined;
+ let { token = undefined } = $props();
- $: html = katex.renderToString(token.text, { throwOnError: false, displayMode: token.displayMode });
+ let html = $derived(katex.renderToString(token.text, { throwOnError: false, displayMode: token.displayMode }));
</script>
{@html html}
diff --git a/chat/src/svelte-marked/markdown/components/MarkdownLink.svelte b/chat/src/svelte-marked/markdown/components/MarkdownLink.svelte
index fb636cfdd..67a2e5cc2 100644
--- a/chat/src/svelte-marked/markdown/components/MarkdownLink.svelte
+++ b/chat/src/svelte-marked/markdown/components/MarkdownLink.svelte
@@ -3,8 +3,13 @@
import type { Tokens } from 'marked'
import type { MarkdownOptions, Renderers } from '../markedConfiguration'
- export let token: Tokens.Link
- export let options: MarkdownOptions
+ interface Props {
+ token: Tokens.Link;
+ options: MarkdownOptions;
+ children?: import('svelte').Snippet;
+ }
+
+ let { token, options, children }: Props = $props();
export const renderers: Renderers = undefined
</script>
@@ -14,5 +19,5 @@
: token.href}
title={token.title}
>
- <slot />
+ {@render children?.()}
</a>
diff --git a/chat/src/svelte-marked/markdown/components/MarkdownParagraph.svelte b/chat/src/svelte-marked/markdown/components/MarkdownParagraph.svelte
index 3eaf5809c..37a3fc4ed 100644
--- a/chat/src/svelte-marked/markdown/components/MarkdownParagraph.svelte
+++ b/chat/src/svelte-marked/markdown/components/MarkdownParagraph.svelte
@@ -1,6 +1,11 @@
<script lang="ts">
import type { Tokens } from 'marked'
import type { MarkdownOptions, Renderers } from '../markedConfiguration'
+ interface Props {
+ children?: import('svelte').Snippet;
+ }
+
+ let { children }: Props = $props();
export const token: Tokens.Paragraph = undefined
export const options: MarkdownOptions = undefined
@@ -8,5 +13,5 @@
</script>
<p>
- <slot />
+ {@render children?.()}
</p>
diff --git a/chat/src/svelte-marked/markdown/components/MarkdownSpace.svelte b/chat/src/svelte-marked/markdown/components/MarkdownSpace.svelte
index 9a011a6ac..940b55c22 100644
--- a/chat/src/svelte-marked/markdown/components/MarkdownSpace.svelte
+++ b/chat/src/svelte-marked/markdown/components/MarkdownSpace.svelte
@@ -1,10 +1,15 @@
<script lang="ts">
import type { Tokens } from 'marked'
import type { MarkdownOptions, Renderers } from '../markedConfiguration'
+ interface Props {
+ children?: import('svelte').Snippet;
+ }
+
+ let { children }: Props = $props();
export const token: Tokens.Space = undefined
export const options: MarkdownOptions = undefined
export const renderers: Renderers = undefined
</script>
-<slot />
+{@render children?.()}
diff --git a/chat/src/svelte-marked/markdown/components/MarkdownStrong.svelte b/chat/src/svelte-marked/markdown/components/MarkdownStrong.svelte
index 5403313d1..1bbdb4397 100644
--- a/chat/src/svelte-marked/markdown/components/MarkdownStrong.svelte
+++ b/chat/src/svelte-marked/markdown/components/MarkdownStrong.svelte
@@ -1,6 +1,11 @@
<script lang="ts">
import type { Tokens } from 'marked'
import type { MarkdownOptions, Renderers } from '../markedConfiguration'
+ interface Props {
+ children?: import('svelte').Snippet;
+ }
+
+ let { children }: Props = $props();
export const token: Tokens.Strong = undefined
export const options: MarkdownOptions = undefined
@@ -8,5 +13,5 @@
</script>
<strong>
- <slot />
+ {@render children?.()}
</strong>
diff --git a/chat/src/svelte-marked/markdown/components/MarkdownText.svelte b/chat/src/svelte-marked/markdown/components/MarkdownText.svelte
index 67e72a836..b550d8ec0 100644
--- a/chat/src/svelte-marked/markdown/components/MarkdownText.svelte
+++ b/chat/src/svelte-marked/markdown/components/MarkdownText.svelte
@@ -1,10 +1,15 @@
<script lang="ts">
import type { Tokens } from 'marked'
import type { MarkdownOptions, Renderers } from '../markedConfiguration'
+ interface Props {
+ children?: import('svelte').Snippet;
+ }
+
+ let { children }: Props = $props();
export const token: Tokens.Text = undefined
export const options: MarkdownOptions = undefined
export const renderers: Renderers = undefined
</script>
-<slot />
+{@render children?.()}
diff --git a/chat/src/svelte-marked/markdown/components/code/MarkdownCode.svelte b/chat/src/svelte-marked/markdown/components/code/MarkdownCode.svelte
index 54ac6f1e6..ea702ff8a 100644
--- a/chat/src/svelte-marked/markdown/components/code/MarkdownCode.svelte
+++ b/chat/src/svelte-marked/markdown/components/code/MarkdownCode.svelte
@@ -1,18 +1,24 @@
<script lang="ts">
+ import { run } from 'svelte/legacy';
+
import { flash } from '../../../../actions.js';
import { feChevronDown, feChevronUp, feCopy } from '../../../../feather.js';
import Icon from '../../../../Icon.svelte';
import type { MarkdownOptions, Renderers } from '../../markedConfiguration';
import type { Tokens } from 'marked';
- export let token: Tokens.Code;
+ interface Props {
+ token: Tokens.Code;
+ }
+
+ let { token }: Props = $props();
export const options: MarkdownOptions = undefined;
export const renderers: Renderers = undefined;
// Passed to every renderer by the marked harness; this one renders the same
// header for assistant and user code blocks, so it goes unread.
export const message = undefined;
- let attrs: Record<string, any> = {};
+ let attrs: Record<string, any> = $state({});
function parseAttributes(langString) {
const regex = /(\w+)=["'](.+?)["']/g;
@@ -24,19 +30,21 @@
return attrs;
}
- $: if (token.lang) {
- attrs = parseAttributes(token.lang);
- }
+ run(() => {
+ if (token.lang) {
+ attrs = parseAttributes(token.lang);
+ }
+ });
- let clientHeight;
- let showingAll = false;
+ let clientHeight = $state();
+ let showingAll = $state(false);
</script>
<div class="relative" bind:clientHeight>
{#if clientHeight > 400}
<button
class="absolute bottom-8 left-1/2 flex -translate-x-1/2 items-center gap-x-1.5 self-start rounded-full bg-gray-200 px-3.5 py-2 text-left text-xs transition-colors hover:bg-gray-300"
- on:click={() => (showingAll = !showingAll)}
+ onclick={() => (showingAll = !showingAll)}
>
<Icon icon={showingAll ? feChevronUp : feChevronDown} class="h-4 w-4 transition-transform" />
{showingAll ? 'Show less' : 'Show all'}
@@ -54,7 +62,7 @@
<button
class="flex items-center gap-x-1.5 self-start rounded-full bg-gray-200 px-3.5 py-2 text-left text-xs transition-colors hover:bg-gray-300"
use:flash
- on:click={(event) => {
+ onclick={(event) => {
event.currentTarget.dispatchEvent(new CustomEvent('flashSuccess'));
navigator.clipboard.writeText(token.text);
}}
diff --git a/chat/src/svelte-marked/markdown/components/code/MarkdownCodeSpan.svelte b/chat/src/svelte-marked/markdown/components/code/MarkdownCodeSpan.svelte
index 22296388c..1ed5658c4 100644
--- a/chat/src/svelte-marked/markdown/components/code/MarkdownCodeSpan.svelte
+++ b/chat/src/svelte-marked/markdown/components/code/MarkdownCodeSpan.svelte
@@ -2,7 +2,11 @@
import type { MarkdownOptions, Renderers } from '../../markedConfiguration'
import type { Tokens } from 'marked'
- export let token: Tokens.Codespan
+ interface Props {
+ token: Tokens.Codespan;
+ }
+
+ let { token }: Props = $props();
export const options: MarkdownOptions = undefined
export const renderers: Renderers = undefined
</script>
diff --git a/chat/src/svelte-marked/markdown/components/list/MarkdownList.svelte b/chat/src/svelte-marked/markdown/components/list/MarkdownList.svelte
index 3a9ab6652..d24207c5a 100644
--- a/chat/src/svelte-marked/markdown/components/list/MarkdownList.svelte
+++ b/chat/src/svelte-marked/markdown/components/list/MarkdownList.svelte
@@ -3,12 +3,16 @@
import type { Tokens } from 'marked'
import MarkdownToken from '../../MarkdownToken.svelte'
- export let token: Tokens.List
- export let options: MarkdownOptions
- export let renderers: Renderers
+ interface Props {
+ token: Tokens.List;
+ options: MarkdownOptions;
+ renderers: Renderers;
+ }
- let component: 'ol' | 'ul'
- $: component = token.ordered ? 'ol' : 'ul'
+ let { token, options, renderers }: Props = $props();
+
+ let component: 'ol' | 'ul' = $derived(token.ordered ? 'ol' : 'ul')
+
</script>
<svelte:element this={component} start={token.start || 1}>
diff --git a/chat/src/svelte-marked/markdown/components/list/MarkdownListItem.svelte b/chat/src/svelte-marked/markdown/components/list/MarkdownListItem.svelte
index ad70b7fe4..f663c10c7 100644
--- a/chat/src/svelte-marked/markdown/components/list/MarkdownListItem.svelte
+++ b/chat/src/svelte-marked/markdown/components/list/MarkdownListItem.svelte
@@ -2,10 +2,15 @@
import type { MarkdownOptions, Renderers } from '../../markedConfiguration'
import type { Tokens } from 'marked'
+ interface Props {
+ children?: import('svelte').Snippet;
+ }
+
+ let { children }: Props = $props();
export const token: Tokens.ListItem = undefined
export const options: MarkdownOptions = undefined
export const renderers: Renderers = undefined
</script>
-<li><slot /></li>
+<li>{@render children?.()}</li>
diff --git a/chat/src/svelte-marked/markdown/components/table/MarkdownTable.svelte b/chat/src/svelte-marked/markdown/components/table/MarkdownTable.svelte
index 99ad71b33..f565e9048 100644
--- a/chat/src/svelte-marked/markdown/components/table/MarkdownTable.svelte
+++ b/chat/src/svelte-marked/markdown/components/table/MarkdownTable.svelte
@@ -3,9 +3,13 @@
import type { MarkdownOptions, Renderers } from '../../markedConfiguration'
import type { Tokens } from 'marked'
- export let token: Tokens.Table
- export let options: MarkdownOptions
- export let renderers: Renderers
+ interface Props {
+ token: Tokens.Table;
+ options: MarkdownOptions;
+ renderers: Renderers;
+ }
+
+ let { token, options, renderers }: Props = $props();
</script>
<table>
diff --git a/chat/src/three-ui/Composer.svelte b/chat/src/three-ui/Composer.svelte
index 4687b5cac..b9764674d 100644
--- a/chat/src/three-ui/Composer.svelte
+++ b/chat/src/three-ui/Composer.svelte
@@ -1,5 +1,5 @@
-<script>
- import { afterUpdate, onDestroy, tick } from 'svelte';
+<script lang="ts">
+ import { onDestroy, tick } from 'svelte';
import { v4 as uuidv4 } from 'uuid';
import Icon from '../Icon.svelte';
import {
@@ -22,33 +22,17 @@
import FilesDropdown from '../FilesDropdown.svelte';
import FilePill from '../FilePill.svelte';
- // Input.svelte-compatible props
- export let generating;
- export let convo;
- export let saveMessage;
- export let saveConversation;
- export let submitCompletion;
- export let scrollToBottom;
- export let handleAbort;
- export let tree;
-
- // three.ws-specific props
- export let placeholder = 'Assign a task or ask anything';
- export let mode = null;
- export let modes = [];
- export let onModeClear = () => {};
-
const imageUrlRegex = /https?:\/\/[^\s]+?\.(png|jpe?g)(?=\s|$)/gi;
- let content = '';
- let pendingImages = [];
- let imageUrlsBlacklist = [];
- let pendingFiles = [];
- let selectedFiles = [];
+ let content = $state('');
+ let pendingImages = $state([]);
+ let imageUrlsBlacklist = $state([]);
+ let pendingFiles = $state([]);
+ let selectedFiles = $state([]);
- let toolsOpen = false;
- let filesOpen = false;
- let reasoningEffortDropdownOpen = false;
+ let toolsOpen = $state(false);
+ let filesOpen = $state(false);
+ let reasoningEffortDropdownOpen = $state(false);
const unsubFill = composerFill.subscribe((fill) => {
if (!fill) return;
@@ -66,12 +50,41 @@
});
onDestroy(unsubFill);
- $: isMultimodal = convo.models[0].modality === 'text+image->text';
- $: canSend = content.trim().length > 0 || pendingImages.length > 0 || pendingFiles.length > 0;
- $: isGenerating = generating && convo.messages.filter((msg) => msg.generated).length > 0;
- let fileInputEl;
- export let inputTextareaEl;
+ let fileInputEl = $state();
+ interface Props {
+ // Input.svelte-compatible props
+ generating: any;
+ convo: any;
+ saveMessage: any;
+ saveConversation: any;
+ submitCompletion: any;
+ scrollToBottom: any;
+ handleAbort: any;
+ tree: any;
+ // three.ws-specific props
+ placeholder?: string;
+ mode?: any;
+ modes?: any;
+ onModeClear?: any;
+ inputTextareaEl: any;
+ }
+
+ let {
+ generating,
+ convo = $bindable(),
+ saveMessage,
+ saveConversation,
+ submitCompletion,
+ scrollToBottom,
+ handleAbort,
+ tree,
+ placeholder = 'Assign a task or ask anything',
+ mode = null,
+ modes = [],
+ onModeClear = () => {},
+ inputTextareaEl = $bindable()
+ }: Props = $props();
export function autoresizeTextarea() {
if (!inputTextareaEl) return;
@@ -247,7 +260,7 @@
event.target.value = '';
}
- let recording = false;
+ let recording = $state(false);
let recognition = null;
function toggleVoiceInput() {
@@ -275,7 +288,7 @@
recording = true;
}
- let containerEl, leftFadeEl, rightFadeEl;
+ let containerEl = $state(), leftFadeEl = $state(), rightFadeEl = $state();
function updateFades() {
if (!containerEl || !leftFadeEl || !rightFadeEl) return;
@@ -290,12 +303,29 @@
}
}
- afterUpdate(updateFades);
+ // The pill row changes width whenever pills mount, unmount or resize, so watch the
+ // row itself rather than guessing which state changes affect it.
+ $effect(() => {
+ if (!containerEl) return;
+ updateFades();
+ const resize = new ResizeObserver(updateFades);
+ resize.observe(containerEl);
+ const mutation = new MutationObserver(updateFades);
+ mutation.observe(containerEl, { childList: true, subtree: true, characterData: true });
+ return () => {
+ resize.disconnect();
+ mutation.disconnect();
+ };
+ });
+
+ let isMultimodal = $derived(convo.models[0].modality === 'text+image->text');
+ let canSend = $derived(content.trim().length > 0 || pendingImages.length > 0 || pendingFiles.length > 0);
+ let isGenerating = $derived(generating && convo.messages.filter((msg) => msg.generated).length > 0);
</script>
<svelte:window
- on:resize={updateFades}
- on:keydown={(event) => {
+ onresize={updateFades}
+ onkeydown={(event) => {
if (navigator.platform.match(/Mac|iPhone|iPod|iPad/)) {
if (event.metaKey && event.key === 'p') {
filesOpen = true;
@@ -323,8 +353,8 @@
rows={1}
class="w-full resize-none bg-transparent border-0 p-0 outline-none ring-0 focus:outline-none focus:ring-0 text-base text-ink placeholder-ink-faint font-sans overflow-y-auto scrollbar-ultraslim"
style="max-height:320px;"
- on:paste={handlePaste}
- on:keydown={(event) => {
+ onpaste={handlePaste}
+ onkeydown={(event) => {
if (event.key === 'Enter' && !event.shiftKey && innerWidth > 880) {
event.preventDefault();
sendMessage();
@@ -332,7 +362,7 @@
event.currentTarget.blur();
}
}}
- on:input={async () => {
+ oninput={async () => {
autoresizeTextarea();
const imageLinkedUrls = content.match(imageUrlRegex) || [];
for (const url of imageLinkedUrls) {
@@ -346,7 +376,7 @@
}
}
}}
- />
+ ></textarea>
<!-- Attachment chips -->
{#if pendingFiles.length > 0 || pendingImages.length > 0}
@@ -355,7 +385,7 @@
<FilePill
{file}
canDelete
- on:delete={() => {
+ ondelete={() => {
const [deleted] = pendingFiles.splice(i, 1);
pendingFiles = pendingFiles;
selectedFiles = selectedFiles.filter((f) => f !== deleted.path);
@@ -371,7 +401,7 @@
class="h-16 w-16 rounded-lg border border-rule object-cover"
/>
<button
- on:click={() => {
+ onclick={() => {
pendingImages[i].fidelity =
pendingImages[i].fidelity === 'high' ? 'low' : 'high';
pendingImages = pendingImages;
@@ -384,7 +414,7 @@
</span>
</button>
<button
- on:click={() => {
+ onclick={() => {
pendingImages.splice(i, 1);
pendingImages = pendingImages;
imageUrlsBlacklist.push(image.url);
@@ -406,7 +436,7 @@
<!-- "+" attach button -->
<button
class="flex h-9 w-9 shrink-0 items-center justify-center rounded-full border border-rule bg-white text-ink hover:bg-paper-deep transition-colors text-xl leading-none"
- on:click={() => fileInputEl.click()}
+ onclick={() => fileInputEl.click()}
title="Attach files"
>
<input
@@ -414,7 +444,7 @@
class="hidden"
bind:this={fileInputEl}
multiple
- on:change={handleFileUpload}
+ onchange={handleFileUpload}
/>
+
</button>
@@ -430,7 +460,7 @@
<span>{modes.find((m) => m.id === mode)?.label ?? mode}</span>
<button
class="ml-0.5 flex h-3.5 w-3.5 items-center justify-center rounded-full hover:bg-rule transition-colors"
- on:click={onModeClear}
+ onclick={onModeClear}
>
<Icon icon={feX} class="h-2.5 w-2.5" />
</button>
@@ -442,21 +472,21 @@
<div
bind:this={leftFadeEl}
class="pointer-events-none absolute left-0 top-0 z-10 h-full w-4 bg-gradient-to-r from-white to-transparent opacity-0 transition-opacity"
- />
+ ></div>
<div
bind:this={rightFadeEl}
class="pointer-events-none absolute right-0 top-0 z-10 h-full w-4 bg-gradient-to-l from-white to-transparent opacity-0 transition-opacity"
- />
+ ></div>
<div
bind:this={containerEl}
- on:scroll={updateFades}
+ onscroll={updateFades}
class="flex max-w-[200px] gap-1.5 overflow-x-auto scrollbar-none sm:max-w-none"
>
<div id="tool-dropdown" class="contents">
<ToolPill
icon={feTool}
selected={toolsOpen}
- on:click={() => (toolsOpen = !toolsOpen)}
+ onclick={() => (toolsOpen = !toolsOpen)}
>
Tools
{#if convo.tools?.length > 0}
@@ -477,7 +507,7 @@
<ToolPill
icon={feFolder}
selected={filesOpen}
- on:click={() => (filesOpen = !filesOpen)}
+ onclick={() => (filesOpen = !filesOpen)}
>
Files
{#if pendingFiles.length > 0}
@@ -494,7 +524,7 @@
bind:open={filesOpen}
{tree}
bind:selectedFiles
- on:fileSelected={async ({ detail }) => {
+ onfileSelected={async (detail) => {
const path = detail.path;
const response = await fetch(
`${$remoteServer.address}/read_file?path=${path}`
@@ -503,7 +533,7 @@
pendingFiles = [...pendingFiles, { path, contents }];
tick().then(() => autoresizeTextarea());
}}
- on:fileDeselected={({ detail }) => {
+ onfileDeselected={(detail) => {
pendingFiles = pendingFiles.filter((f) => f.path !== detail.path);
tick().then(() => autoresizeTextarea());
}}
@@ -515,7 +545,7 @@
<ToolPill
icon={feSearch}
selected={convo.websearch}
- on:click={() => {
+ onclick={() => {
convo.websearch = !convo.websearch;
saveConversation(convo);
}}
@@ -528,7 +558,7 @@
<ToolPill
icon={feZap}
selected={false}
- on:click={() => {
+ onclick={() => {
if (convo.reasoningEffort === 'low') {
convo.reasoningEffort = 'medium';
} else if (convo.reasoningEffort === 'medium') {
@@ -550,7 +580,7 @@
<ToolPill
icon={feZap}
selected={reasoningEffortDropdownOpen}
- on:click={() =>
+ onclick={() =>
(reasoningEffortDropdownOpen = !reasoningEffortDropdownOpen)}
>
Thinking
@@ -573,7 +603,7 @@
<button
type="button"
title={recording ? 'Stop recording' : 'Speak a message'}
- on:click={toggleVoiceInput}
+ onclick={toggleVoiceInput}
class="flex h-9 w-9 items-center justify-center rounded-full transition-colors
{recording ? 'bg-red-500 text-white animate-pulse' : 'text-ink-faint hover:text-ink'}"
>
@@ -582,7 +612,7 @@
{#if isGenerating}
<button
class="flex h-9 w-9 items-center justify-center rounded-full bg-ink transition-colors hover:bg-[#333]"
- on:click={handleAbort}
+ onclick={handleAbort}
title="Stop generating"
>
<Icon icon={feSquare} strokeWidth={4} class="h-3.5 w-3.5 text-white" />
@@ -593,7 +623,7 @@
class="flex h-9 w-9 items-center justify-center rounded-full transition-colors {canSend
? 'bg-black text-white hover:bg-[#333] cursor-pointer'
: 'bg-paper-deep text-ink-faint cursor-default'}"
- on:click={sendMessage}
+ onclick={sendMessage}
title="Send message"
>
<Icon icon={feArrowUp} class="h-4 w-4" />
diff --git a/chat/src/three-ui/EmptyState.svelte b/chat/src/three-ui/EmptyState.svelte
index a21b1acd6..4de1c5b9d 100644
--- a/chat/src/three-ui/EmptyState.svelte
+++ b/chat/src/three-ui/EmptyState.svelte
@@ -1,17 +1,23 @@
-<script>
+<script lang="ts">
import { mode } from '../stores.js';
import SlidesFlow from './flows/SlidesFlow.svelte';
import DesignFlow from './flows/DesignFlow.svelte';
import UtilityFlows from './flows/UtilityFlows.svelte';
+ interface Props {
+ composer?: import('svelte').Snippet;
+ chips?: import('svelte').Snippet;
+ }
+
+ let { composer, chips }: Props = $props();
</script>
<section class="w-full flex flex-col items-center px-6 pt-[18vh] md:pt-[22vh] pb-32">
<h1 class="three-ui-hero text-center mb-9">What can I do for you?</h1>
<div class="w-full max-w-[760px]">
- <slot name="composer" />
+ {@render composer?.()}
</div>
<div class="w-full max-w-[760px] mt-4">
- <slot name="chips" />
+ {@render chips?.()}
</div>
{#if $mode === 'slides'}
<SlidesFlow />
diff --git a/chat/src/three-ui/MoreDropdown.svelte b/chat/src/three-ui/MoreDropdown.svelte
index 76b7def0e..c72358838 100644
--- a/chat/src/three-ui/MoreDropdown.svelte
+++ b/chat/src/three-ui/MoreDropdown.svelte
@@ -1,5 +1,4 @@
<script>
- import { createEventDispatcher } from 'svelte';
import Icon from '../Icon.svelte';
import { mode } from '../stores.js';
import {
@@ -7,7 +6,7 @@
feBox, fePackage, feHexagon, feRepeat, feGlobe,
} from '../feather.js';
- const dispatch = createEventDispatcher();
+ let { onclose } = $props();
const items = [
{ id: 'pumpfun', label: 'Pump.fun live feed', icon: feZap },
@@ -26,30 +25,30 @@
function pick(item) {
mode.set(item.id);
- dispatch('close');
+ onclose?.();
}
function onKey(e) {
- if (e.key === 'Escape') dispatch('close');
+ if (e.key === 'Escape') onclose?.();
}
</script>
-<svelte:window on:keydown={onKey} />
+<svelte:window onkeydown={onKey} />
<!-- Dismiss backdrop -->
<button
class="fixed inset-0 z-20 cursor-default"
aria-hidden="true"
tabindex="-1"
- on:click={() => dispatch('close')}
-/>
+ onclick={() => onclose?.()}
+></button>
<!-- Dropdown card -->
<div class="absolute bottom-full mb-2 right-0 z-30 bg-white border border-rule rounded-2xl shadow-pop p-2 w-[260px]">
{#each items as item}
<button
class="flex items-center gap-3 w-full px-3 h-10 rounded-lg text-sm font-medium text-ink hover:bg-paper"
- on:click={() => pick(item)}
+ onclick={() => pick(item)}
>
<Icon icon={item.icon} class="h-4 w-4 shrink-0" />
<span>{item.label}</span>
diff --git a/chat/src/three-ui/SuggestionChips.svelte b/chat/src/three-ui/SuggestionChips.svelte
index 9b0b96b26..1032450af 100644
--- a/chat/src/three-ui/SuggestionChips.svelte
+++ b/chat/src/three-ui/SuggestionChips.svelte
@@ -4,7 +4,7 @@
import { feTrendingUp, feBarChart2, feActivity, feAlertCircle, feMoreHorizontal, feBox, feLayers, feZap } from '../feather.js';
import MoreDropdown from './MoreDropdown.svelte';
- let moreOpen = false;
+ let moreOpen = $state(false);
const chips = [
{ id: 'text3d', label: 'Text → 3D', icon: feZap },
@@ -25,19 +25,19 @@
{#each chips as c}
<button
class="three-ui-chip {$mode === c.id ? 'three-ui-chip-selected' : ''}"
- on:click={() => pick(c.id)}
+ onclick={() => pick(c.id)}
>
<Icon icon={c.icon} class="h-4 w-4" />
{c.label}
</button>
{/each}
<div class="relative">
- <button class="three-ui-chip" on:click={() => (moreOpen = !moreOpen)}>
+ <button class="three-ui-chip" onclick={() => (moreOpen = !moreOpen)}>
<Icon icon={feMoreHorizontal} class="h-4 w-4" />
More
</button>
{#if moreOpen}
- <MoreDropdown on:close={() => (moreOpen = false)} />
+ <MoreDropdown onclose={() => (moreOpen = false)} />
{/if}
</div>
</div>
diff --git a/chat/src/three-ui/TopNav.svelte b/chat/src/three-ui/TopNav.svelte
index 01838478e..5c13cea0c 100644
--- a/chat/src/three-ui/TopNav.svelte
+++ b/chat/src/three-ui/TopNav.svelte
@@ -12,7 +12,7 @@
// never disagree on labels or hrefs.
import { CHAT_SITE_LINKS as siteLinks } from '../../../public/nav-data.js';
- let mobileOpen = false;
+ let mobileOpen = $state(false);
function goChatHome() {
route.set('chat');
@@ -36,7 +36,7 @@
</a>
<span class="select-none text-base font-light text-ink-soft/60" aria-hidden="true">/</span>
<button
- on:click={goChatHome}
+ onclick={goChatHome}
class="rounded-full px-2 py-1 text-sm font-medium text-ink transition-colors hover:bg-paper-deep"
aria-current={$route === 'chat' ? 'page' : undefined}
>
@@ -80,7 +80,7 @@
class="rounded-full p-2 text-ink transition-colors hover:bg-paper-deep xl:hidden"
aria-label={mobileOpen ? 'Close menu' : 'Open menu'}
aria-expanded={mobileOpen}
- on:click={() => (mobileOpen = !mobileOpen)}
+ onclick={() => (mobileOpen = !mobileOpen)}
>
<Icon icon={mobileOpen ? feX : feMenu} class="h-5 w-5" />
</button>
@@ -92,7 +92,7 @@
<div class="border-t border-rule bg-paper xl:hidden">
<div class="flex flex-col gap-1 px-4 py-3">
<button
- on:click={goChatHome}
+ onclick={goChatHome}
class="flex h-11 items-center rounded-xl px-3 text-sm font-medium text-ink transition-colors hover:bg-paper-deep"
aria-current={$route === 'chat' ? 'page' : undefined}
>
diff --git a/chat/src/three-ui/flows/DesignFlow.svelte b/chat/src/three-ui/flows/DesignFlow.svelte
index c9335f8bf..8500c9c32 100644
--- a/chat/src/three-ui/flows/DesignFlow.svelte
+++ b/chat/src/three-ui/flows/DesignFlow.svelte
@@ -49,7 +49,7 @@
{#each cards as card}
<button
class="bg-white border border-rule rounded-2xl p-5 flex gap-4 hover:bg-paper transition-colors text-left w-full"
- on:click={() => selectCard(card.description)}
+ onclick={() => selectCard(card.description)}
>
<div class="flex-1 min-w-0">
<div class="flex items-center justify-between text-ink font-semibold text-sm">
diff --git a/chat/src/three-ui/flows/DesktopFlow.svelte b/chat/src/three-ui/flows/DesktopFlow.svelte
index 62b1be821..d09f163e6 100644
--- a/chat/src/three-ui/flows/DesktopFlow.svelte
+++ b/chat/src/three-ui/flows/DesktopFlow.svelte
@@ -69,7 +69,7 @@
{#each samplePrompts as prompt}
<button
class="bg-white border border-rule rounded-xl p-4 h-[112px] flex flex-col justify-between text-left hover:bg-paper transition-colors"
- on:click={() => selectPrompt(prompt)}
+ onclick={() => selectPrompt(prompt)}
>
<span class="text-sm text-ink leading-snug">{prompt}</span>
<Icon icon={feArrowUpLeft} size={14} class="text-ink-faint self-end" />
@@ -83,7 +83,7 @@
{#each platforms as p}
<button
class="three-ui-chip {$appPlatforms.has(p.id) ? 'three-ui-chip-selected' : ''}"
- on:click={() => togglePlatform(p.id)}
+ onclick={() => togglePlatform(p.id)}
>
<Icon icon={p.icon} size={16} />
{p.label}
@@ -95,7 +95,7 @@
<h3 class="text-sm font-semibold mt-10 mb-3">Explore ideas</h3>
<div class="flex flex-wrap gap-2">
{#each ideas as idea}
- <button class="three-ui-chip" on:click={() => selectIdea(idea)}>
+ <button class="three-ui-chip" onclick={() => selectIdea(idea)}>
{idea}
<Icon icon={feArrowUpLeft} size={14} class="text-ink-faint" />
</button>
diff --git a/chat/src/three-ui/flows/SamplePromptGrid.svelte b/chat/src/three-ui/flows/SamplePromptGrid.svelte
index 8fa630c11..b78dda51f 100644
--- a/chat/src/three-ui/flows/SamplePromptGrid.svelte
+++ b/chat/src/three-ui/flows/SamplePromptGrid.svelte
@@ -1,10 +1,9 @@
-<script>
+<script lang="ts">
import Icon from '../../Icon.svelte';
import { feArrowUpLeft } from '../../feather.js';
import { composerFill } from '../../stores.js';
- export let title;
- export let prompts;
+ let { title, prompts } = $props();
</script>
<div>
@@ -13,7 +12,7 @@
{#each prompts as prompt}
<button
class="relative bg-white border border-rule rounded-xl p-4 h-[96px] text-left text-sm hover:bg-paper transition-colors overflow-hidden"
- on:click={() => composerFill.set({ text: prompt, submit: true })}
+ onclick={() => composerFill.set({ text: prompt, submit: true })}
>
<span class="line-clamp-3 block pr-5">{prompt}</span>
<Icon
diff --git a/chat/src/three-ui/flows/SlidesFlow.svelte b/chat/src/three-ui/flows/SlidesFlow.svelte
index 274b40c5a..8de7beec6 100644
--- a/chat/src/three-ui/flows/SlidesFlow.svelte
+++ b/chat/src/three-ui/flows/SlidesFlow.svelte
@@ -24,8 +24,8 @@
];
const slideCountOptions = ['4 - 8', '8 - 12', '12 - 16', '16 - 20'];
- let selectedSlideCount = '8 - 12';
- let slideCountOpen = false;
+ let selectedSlideCount = $state('8 - 12');
+ let slideCountOpen = $state(false);
/** The chosen length is part of every request, so the control actually steers output. */
function withSlideCount(text) {
@@ -51,7 +51,7 @@
{#each samplePrompts as prompt}
<button
class="bg-white border border-rule rounded-xl p-4 text-left h-[112px] flex flex-col justify-between hover:bg-paper transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-ink"
- on:click={() => selectPrompt(prompt)}
+ onclick={() => selectPrompt(prompt)}
>
<span class="text-sm text-ink line-clamp-2">{prompt}</span>
<Icon icon={feArrowUpLeft} class="w-[14px] h-[14px] text-ink-faint self-end shrink-0" />
@@ -66,7 +66,7 @@
class="bg-white border border-rule rounded-full h-9 px-3 text-sm flex items-center gap-2 hover:bg-paper transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-ink"
aria-expanded={slideCountOpen}
aria-label="Slide count: {selectedSlideCount}"
- on:click={() => (slideCountOpen = !slideCountOpen)}
+ onclick={() => (slideCountOpen = !slideCountOpen)}
>
<Icon icon={feLayout} class="w-4 h-4 text-ink-soft" />
{selectedSlideCount}
@@ -78,7 +78,7 @@
<button
class="block w-full px-4 py-2 text-sm text-left text-ink hover:bg-paper first:rounded-t-xl last:rounded-b-xl"
aria-current={option === selectedSlideCount ? 'true' : undefined}
- on:click={() => { selectedSlideCount = option; slideCountOpen = false; }}
+ onclick={() => { selectedSlideCount = option; slideCountOpen = false; }}
>
{option}
</button>
@@ -92,7 +92,7 @@
{#each templates as template}
<button
class="aspect-[4/3] bg-paper-deep rounded-xl flex flex-col items-center justify-center gap-1.5 px-2 text-center hover:bg-white hover:border hover:border-rule transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-ink"
- on:click={() => selectTemplate(template)}
+ onclick={() => selectTemplate(template)}
>
<span class="text-sm text-ink font-serif">{template.name}</span>
<Icon icon={feArrowUpLeft} class="w-[14px] h-[14px] text-ink-faint" />
diff --git a/chat/src/three-ui/flows/WebsiteFlow.svelte b/chat/src/three-ui/flows/WebsiteFlow.svelte
index 56b55298f..bebe7f759 100644
--- a/chat/src/three-ui/flows/WebsiteFlow.svelte
+++ b/chat/src/three-ui/flows/WebsiteFlow.svelte
@@ -1,4 +1,5 @@
<script>
+
import { websiteCategory, composerFill } from '../../stores.js';
import Icon from '../../Icon.svelte';
import {
@@ -38,8 +39,8 @@
linkbio: 'Create a link-in-bio page for ',
};
- let referenceOpen = false;
- let referenceUrl = '';
+ let referenceOpen = $state(false);
+ let referenceUrl = $state('');
/** Append a site the model should take its cues from to whatever is composed. */
function addReference() {
@@ -74,14 +75,14 @@
<button
class="inline-flex items-center gap-1.5 text-sm text-ink hover:underline focus:outline-none focus-visible:ring-2 focus-visible:ring-ink rounded"
aria-expanded={referenceOpen}
- on:click={() => (referenceOpen = !referenceOpen)}
+ onclick={() => (referenceOpen = !referenceOpen)}
>
<Icon icon={feLink} size={14} /> Add website reference
</button>
</div>
{#if referenceOpen}
- <form class="mt-3 flex gap-2" on:submit|preventDefault={addReference}>
+ <form class="mt-3 flex gap-2" onsubmit={(event) => { event.preventDefault(); addReference(); }}>
<input
type="url"
bind:value={referenceUrl}
@@ -103,7 +104,7 @@
{#each categories as c}
<button
class="three-ui-chip whitespace-nowrap {$websiteCategory === c.id ? 'three-ui-chip-selected' : ''}"
- on:click={() => pick(c.id)}
+ onclick={() => pick(c.id)}
>
<Icon icon={c.icon} size={16} />
{c.label}
@@ -116,7 +117,7 @@
<h3 class="text-sm font-semibold mb-3">Explore ideas</h3>
<div class="flex flex-wrap gap-2">
{#each ideasByCategory[$websiteCategory] as idea}
- <button class="three-ui-chip" on:click={() => selectIdea(idea)}>
+ <button class="three-ui-chip" onclick={() => selectIdea(idea)}>
<span>{idea}</span>
<Icon icon={feArrowUpLeft} size={14} class="text-ink-faint" />
</button>
diff --git a/chat/src/three-ui/pages/AuthPage.svelte b/chat/src/three-ui/pages/AuthPage.svelte
index 67d8f7a95..a588b11b3 100644
--- a/chat/src/three-ui/pages/AuthPage.svelte
+++ b/chat/src/three-ui/pages/AuthPage.svelte
@@ -1,16 +1,21 @@
-<script>
+<script lang="ts">
+
import { route, loadCurrentUser } from '../../stores.js';
import { signInWithEVM, signInWithSolana } from '../../walletAuth.js';
import { signInWithPassword, registerWithPassword } from '../../passwordAuth.js';
- export let kind = 'signin'; // 'signin' | 'signup'
+ interface Props {
+ kind?: string; // 'signin' | 'signup'
+ }
+
+ let { kind = 'signin' }: Props = $props();
- let email = '';
- let password = '';
- let name = '';
- let tosAccepted = false;
- let loading = null; // 'evm' | 'sol' | 'password' | null
- let error = '';
+ let email = $state('');
+ let password = $state('');
+ let name = $state('');
+ let tosAccepted = $state(false);
+ let loading = $state(null); // 'evm' | 'sol' | 'password' | null
+ let error = $state('');
async function connectEVM() {
error = '';
@@ -74,14 +79,14 @@
<div class="mt-6 space-y-3">
<button
disabled={loading !== null}
- on:click={connectEVM}
+ onclick={connectEVM}
class="bg-black text-white rounded-xl h-11 w-full flex items-center justify-center gap-2 hover:bg-[#333] text-sm font-medium disabled:opacity-50 transition-colors"
>
{loading === 'evm' ? 'Connecting…' : 'Connect EVM Wallet'}
</button>
<button
disabled={loading !== null}
- on:click={connectSolana}
+ onclick={connectSolana}
class="bg-white border border-rule text-ink rounded-xl h-11 w-full flex items-center justify-center gap-2 hover:bg-paper text-sm font-medium disabled:opacity-50 transition-colors"
>
{loading === 'sol' ? 'Connecting…' : 'Connect Solana Wallet'}
@@ -89,10 +94,10 @@
</div>
<div class="flex items-center gap-3 text-xs text-ink-faint my-4">
- <span class="flex-1 h-px bg-rule" />or<span class="flex-1 h-px bg-rule" />
+ <span class="flex-1 h-px bg-rule"></span>or<span class="flex-1 h-px bg-rule"></span>
</div>
- <form class="space-y-3" on:submit|preventDefault={submit}>
+ <form class="space-y-3" onsubmit={(event) => { event.preventDefault(); submit(); }}>
{#if kind === 'signup'}
<label class="block">
<span class="text-xs font-medium text-ink-soft mb-1.5 block">Name</span>
@@ -143,10 +148,10 @@
<p class="text-center text-sm text-ink-soft mt-6">
{#if kind === 'signin'}
Don't have an account?
- <button class="text-ink underline" on:click={() => route.set('signup')}>Sign up</button>
+ <button class="text-ink underline" onclick={() => route.set('signup')}>Sign up</button>
{:else}
Already have an account?
- <button class="text-ink underline" on:click={() => route.set('signin')}>Sign in</button>
+ <button class="text-ink underline" onclick={() => route.set('signin')}>Sign in</button>
{/if}
</p>
</section>