fix(svelte): replace $effect with onMount for side effects

$effect runs during SSR and re-runs on every reactive dependency change,
causing polling loops and URL reads to fire at the wrong time. onMount
runs once on the client after first render, which is the correct lifecycle
for polling, URL param reads, and async data loads.

- IndexingProgress: polling loop now starts on mount, not on reactive trigger
- search/+page.svelte: URL param init moved to onMount; use window.location
  directly instead of the page store to avoid reactive re-runs
- settings/+page.svelte: config load and local provider probe moved to onMount

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Giancarmine Salucci
2026-03-25 14:30:04 +01:00
parent 215cadf070
commit a63de39473
3 changed files with 224 additions and 203 deletions

View File

@@ -1,12 +1,12 @@
<script lang="ts">
import { onMount } from 'svelte';
import type { IndexingJob } from '$lib/types';
let { jobId }: { jobId: string } = $props();
let job = $state<IndexingJob | null>(null);
$effect(() => {
// Reset and restart polling whenever jobId changes.
onMount(() => {
job = null;
let stopped = false;
@@ -23,13 +23,13 @@
}
}
poll();
void poll();
const interval = setInterval(() => {
if (job?.status === 'done' || job?.status === 'failed') {
clearInterval(interval);
return;
}
poll();
void poll();
}, 2000);
return () => {