Skip to content

Commit 1249f11

Browse files
committed
fix: resolve all svelte lint warnings (state_referenced_locally, a11y, unused ignore)
1 parent 96e79f4 commit 1249f11

File tree

7 files changed

+32
-17
lines changed

7 files changed

+32
-17
lines changed

src/lib/components/EditConversationModal.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
1212
let { open = false, title = "", onclose, onsave }: Props = $props();
1313
14-
let newTitle = $state(title);
14+
let newTitle = $state("");
1515
let inputEl: HTMLInputElement | undefined = $state();
1616
17-
$effect(() => {
17+
$effect.pre(() => {
1818
// keep local input in sync if parent changes title while open
1919
if (open) {
2020
newTitle = title;

src/lib/components/NavConversationItem.svelte

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@
6666
}}
6767
>
6868
{#if inlineEditing}
69-
<!-- svelte-ignore a11y_autofocus -->
7069
<input
7170
bind:this={inputEl}
7271
type="text"

src/lib/components/chat/ChatWindow.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@
268268
269269
// Force scroll to bottom when user sends a new message
270270
// Pattern: user message + empty assistant message are added together
271-
let prevMessageCount = $state(messages.length);
271+
let prevMessageCount = $state(0);
272272
let forceReattach = $state(0);
273273
$effect(() => {
274274
if (messages.length > prevMessageCount) {

src/lib/components/chat/MarkdownRenderer.svelte

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,22 @@
1515
1616
let { content, sources = [], loading = false }: Props = $props();
1717
18-
let blocks: BlockToken[] = $state(processBlocksSync(content, sources));
18+
// Sync-computed blocks used as fallback and for SSR (where effects don't run)
19+
let syncBlocks = $derived(processBlocksSync(content, sources));
20+
let workerBlocks: BlockToken[] | null = $state(null);
21+
let blocks = $derived(workerBlocks ?? syncBlocks);
22+
1923
let worker: Worker | null = null;
2024
let latestRequestId = 0;
2125
2226
function handleBlocks(result: BlockToken[], requestId: number) {
2327
if (requestId !== latestRequestId) return;
24-
blocks = result;
28+
workerBlocks = result;
2529
updateDebouncer.endRender();
2630
}
2731
2832
$effect(() => {
29-
if (!browser) {
30-
blocks = processBlocksSync(content, sources);
31-
return;
32-
}
33+
if (!browser) return;
3334
3435
const requestId = ++latestRequestId;
3536
@@ -42,7 +43,6 @@
4243
(async () => {
4344
updateDebouncer.startRender();
4445
const processed = await processBlocks(content, sources);
45-
// Only apply if this is still the latest request
4646
handleBlocks(processed, requestId);
4747
})();
4848
});

src/lib/components/chat/ModelSwitch.svelte

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,13 @@
1111
1212
let { models, currentModel }: Props = $props();
1313
14-
let selectedModelId = $state(
15-
models.map((m) => m.id).includes(currentModel.id) ? currentModel.id : models[0].id
16-
);
14+
let selectedModelId = $state("");
15+
16+
$effect.pre(() => {
17+
selectedModelId = models.map((m) => m.id).includes(currentModel.id)
18+
? currentModel.id
19+
: models[0].id;
20+
});
1721
1822
async function handleModelChange() {
1923
if (!page.params.id) return;

src/lib/components/mcp/AddServerForm.svelte

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,15 @@
2929
submitLabel = "Add Server",
3030
}: Props = $props();
3131
32-
let name = $state(initialName);
33-
let url = $state(initialUrl);
34-
let headers = $state<KeyValuePair[]>(initialHeaders.length > 0 ? [...initialHeaders] : []);
32+
let name = $state("");
33+
let url = $state("");
34+
let headers = $state<KeyValuePair[]>([]);
35+
36+
$effect.pre(() => {
37+
name = initialName;
38+
url = initialUrl;
39+
headers = initialHeaders.length > 0 ? [...initialHeaders] : [];
40+
});
3541
let showHeaderValues = $state<Record<number, boolean>>({});
3642
let error = $state<string | null>(null);
3743

src/lib/components/players/AudioPlayer.svelte

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,12 @@
6565
<span class="text-xs">{format(time)}</span>
6666
<div
6767
class="relative h-2 flex-1 rounded-full bg-gray-200 dark:bg-gray-700"
68+
role="slider"
69+
aria-label="Seek"
70+
aria-valuenow={time}
71+
aria-valuemin={0}
72+
aria-valuemax={duration}
73+
tabindex="0"
6874
onpointerdown={() => {
6975
paused = true;
7076
}}

0 commit comments

Comments
 (0)