Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/lib/components/EditConversationModal.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@

let { open = false, title = "", onclose, onsave }: Props = $props();

let newTitle = $state(title);
let newTitle = $state("");
let inputEl: HTMLInputElement | undefined = $state();

$effect(() => {
$effect.pre(() => {
// keep local input in sync if parent changes title while open
if (open) {
newTitle = title;
Expand Down
1 change: 0 additions & 1 deletion src/lib/components/NavConversationItem.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@
}}
>
{#if inlineEditing}
<!-- svelte-ignore a11y_autofocus -->
<input
bind:this={inputEl}
type="text"
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/chat/ChatWindow.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@

// Force scroll to bottom when user sends a new message
// Pattern: user message + empty assistant message are added together
let prevMessageCount = $state(messages.length);
let prevMessageCount = $state(0);
let forceReattach = $state(0);
$effect(() => {
if (messages.length > prevMessageCount) {
Expand Down
14 changes: 7 additions & 7 deletions src/lib/components/chat/MarkdownRenderer.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,22 @@

let { content, sources = [], loading = false }: Props = $props();

let blocks: BlockToken[] = $state(processBlocksSync(content, sources));
// Sync-computed blocks used as fallback and for SSR (where effects don't run)
let syncBlocks = $derived(processBlocksSync(content, sources));
let workerBlocks: BlockToken[] | null = $state(null);
let blocks = $derived(workerBlocks ?? syncBlocks);

let worker: Worker | null = null;
let latestRequestId = 0;

function handleBlocks(result: BlockToken[], requestId: number) {
if (requestId !== latestRequestId) return;
blocks = result;
workerBlocks = result;
updateDebouncer.endRender();
}

$effect(() => {
if (!browser) {
blocks = processBlocksSync(content, sources);
return;
}
if (!browser) return;

const requestId = ++latestRequestId;

Expand All @@ -42,7 +43,6 @@
(async () => {
updateDebouncer.startRender();
const processed = await processBlocks(content, sources);
// Only apply if this is still the latest request
handleBlocks(processed, requestId);
})();
});
Expand Down
10 changes: 7 additions & 3 deletions src/lib/components/chat/ModelSwitch.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,13 @@

let { models, currentModel }: Props = $props();

let selectedModelId = $state(
models.map((m) => m.id).includes(currentModel.id) ? currentModel.id : models[0].id
);
let selectedModelId = $state("");

$effect.pre(() => {
selectedModelId = models.map((m) => m.id).includes(currentModel.id)
? currentModel.id
: models[0].id;
});

async function handleModelChange() {
if (!page.params.id) return;
Expand Down
12 changes: 9 additions & 3 deletions src/lib/components/mcp/AddServerForm.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,15 @@
submitLabel = "Add Server",
}: Props = $props();

let name = $state(initialName);
let url = $state(initialUrl);
let headers = $state<KeyValuePair[]>(initialHeaders.length > 0 ? [...initialHeaders] : []);
let name = $state("");
let url = $state("");
let headers = $state<KeyValuePair[]>([]);

$effect.pre(() => {
name = initialName;
url = initialUrl;
headers = initialHeaders.length > 0 ? [...initialHeaders] : [];
});
let showHeaderValues = $state<Record<number, boolean>>({});
let error = $state<string | null>(null);

Expand Down
6 changes: 6 additions & 0 deletions src/lib/components/players/AudioPlayer.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@
<span class="text-xs">{format(time)}</span>
<div
class="relative h-2 flex-1 rounded-full bg-gray-200 dark:bg-gray-700"
role="slider"
aria-label="Seek"
aria-valuenow={time}
aria-valuemin={0}
aria-valuemax={duration}
tabindex="0"
onpointerdown={() => {
paused = true;
}}
Expand Down
35 changes: 18 additions & 17 deletions src/lib/migrations/routines/09-delete-empty-conversations.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type { Conversation } from "$lib/types/Conversation";
import { ObjectId } from "mongodb";
import { deleteConversations } from "./09-delete-empty-conversations";
import { afterAll, afterEach, beforeAll, describe, expect, test } from "vitest";
import { collections } from "$lib/server/database";
import { collections, ready } from "$lib/server/database";

type Message = Conversation["messages"][number];

Expand Down Expand Up @@ -190,25 +190,26 @@ describe.sequential("Deleting discarded conversations", async () => {

expect(result).toBe(10010);
});
});

beforeAll(async () => {
await collections.users.insertOne(userData);
await collections.sessions.insertOne(sessionForUser);
}, 20000);
beforeAll(async () => {
await ready;
await collections.users.insertOne(userData);
await collections.sessions.insertOne(sessionForUser);
}, 20000);

afterAll(async () => {
await collections.users.deleteOne({
_id: userData._id,
});
await collections.sessions.deleteOne({
_id: sessionForUser._id,
afterAll(async () => {
await collections.users.deleteOne({
_id: userData._id,
});
await collections.sessions.deleteOne({
_id: sessionForUser._id,
});
await collections.conversations.deleteMany({});
});
await collections.conversations.deleteMany({});
});

afterEach(async () => {
await collections.conversations.deleteMany({
_id: { $in: [conversationBase._id] },
afterEach(async () => {
await collections.conversations.deleteMany({
_id: { $in: [conversationBase._id] },
});
});
});
Loading