From 2eb34a709b0f3e5322756e91e014abdaf754a526 Mon Sep 17 00:00:00 2001 From: hermes-explorigin Date: Tue, 8 Sep 2026 02:08:21 +0000 Subject: [PATCH] Fix tab/view navigation: reactivity loop + Daily forecast TDZ - notifications.svelte.js: analyze() iterated the reactive $state field `alerts` right after writing it, inside an $effect. That read-after-write made Svelte treat the effect as depending on `alerts`, so writing it re-ran the effect forever -> effect_update_depth_exceeded, which killed the click handler after setting the hash but before swapping the view. Iterate the local newAlerts array instead. - DailyForecast.svelte: use `precip` {@const} before its declaration caused a 'Cannot access precip before initialization' TDZ error when the 7-day tab rendered. Moved the declaration above its first use. Both verified in a real headless Chromium: tabs now switch correctly (hash + active state + content), no console/page errors. 81/81 tests pass. --- dist/index.html | 8 ++++---- src/components/DailyForecast.svelte | 2 +- src/lib/stores/notifications.svelte.js | 4 +++- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/dist/index.html b/dist/index.html index ef95e00..d3127b4 100644 --- a/dist/index.html +++ b/dist/index.html @@ -6220,7 +6220,7 @@ var NotificationStore = class { } newAlerts = newAlerts.filter((a) => !this.dismissedIds.has(a.id)); this.alerts = newAlerts; - for (const a of this.alerts) { + for (const a of newAlerts) { if (this._notifiedIds.has(a.id)) continue; this._notifiedIds.add(a.id); notify({ @@ -6831,10 +6831,10 @@ function DailyForecast($$anchor, $$props) { var fragment_1 = comment(); var node_1 = first_child(fragment_1); var consequent_2 = ($$anchor) => { - const info = /* @__PURE__ */ user_derived(() => getWeatherInfo(get(daily).weather_code[i], precip)); + const precip = /* @__PURE__ */ user_derived(() => get(daily).precipitation_probability_max?.[i] || 0); + const info = /* @__PURE__ */ user_derived(() => getWeatherInfo(get(daily).weather_code[i], get(precip))); const tempMax = /* @__PURE__ */ user_derived(() => Math.round(get(daily).temperature_2m_max[i])); const tempMin = /* @__PURE__ */ user_derived(() => Math.round(get(daily).temperature_2m_min[i])); - const precip = /* @__PURE__ */ user_derived(() => get(daily).precipitation_probability_max?.[i] || 0); const wind = /* @__PURE__ */ user_derived(() => get(daily).wind_speed_10m_max?.[i]); var div_2 = root_2$6(); set_class(div_2, 1, "day-card card-glass svelte-ss3yj8", null, {}, { today: i === 0 }); @@ -8792,7 +8792,7 @@ delegate([ ]); //#endregion //#region src/main.js -console.info({ commit_hash: "2c678fd00db6e0244334a9b6de10a6d379c9126c" }); +console.info({ commit_hash: "897f49ae2209cb2213ea97a4a082bb4bdfa2889a" }); registerServiceWorker(); mount(App, { target: document.getElementById("app") }); //#endregion diff --git a/src/components/DailyForecast.svelte b/src/components/DailyForecast.svelte index 3fe8ae2..0dc1467 100644 --- a/src/components/DailyForecast.svelte +++ b/src/components/DailyForecast.svelte @@ -29,10 +29,10 @@
{#each daily.time as day, i} {#if i < 7} + {@const precip = daily.precipitation_probability_max?.[i] || 0} {@const info = getWeatherInfo(daily.weather_code[i], precip)} {@const tempMax = Math.round(daily.temperature_2m_max[i])} {@const tempMin = Math.round(daily.temperature_2m_min[i])} - {@const precip = daily.precipitation_probability_max?.[i] || 0} {@const wind = daily.wind_speed_10m_max?.[i]}
diff --git a/src/lib/stores/notifications.svelte.js b/src/lib/stores/notifications.svelte.js index 5a7fcda..580f934 100644 --- a/src/lib/stores/notifications.svelte.js +++ b/src/lib/stores/notifications.svelte.js @@ -150,7 +150,9 @@ export class NotificationStore { // Lightweight native notifications: surface alerts that just appeared and // haven't been notified this forecast day. Best-effort — never blocks. - for (const a of this.alerts) { + // NOTE: iterate the local `newAlerts` (not reactive `this.alerts`) — a + // read-after-write on $state inside this $effect would loop forever. + for (const a of newAlerts) { if (this._notifiedIds.has(a.id)) continue this._notifiedIds.add(a.id) notify({