Skip to content

refactor(app): migrate $app/stores to $app/state #1207 - #1237

Merged
escapedcat merged 1 commit into
mainfrom
chore/app-state
Aug 10, 2026
Merged

refactor(app): migrate $app/stores to $app/state #1207#1237
escapedcat merged 1 commit into
mainfrom
chore/app-state

Conversation

@escapedcat

@escapedcat escapedcat commented Aug 10, 2026

Copy link
Copy Markdown
Collaborator

Summary

Migrates all five $app/stores consumers to $app/state (#1207). The store flavor is deprecated since Kit 2.12; the state flavor is rune-backed — which is exactly why this wasn't a blind find-and-replace: a bare page.* read inside a legacy-mode $: statement is not tracked and runs exactly once. Each file got a per-site audit:

File Read context Treatment
communities/map/+page.svelte const snapshot reads at init mechanical swap (same snapshot semantics)
leaderboard/+page.svelte inside an event handler, runes-mode file mechanical swap
+error.svelte onMount + template mechanical swap
AreaPage.svelte reactive $: driving section-tab switching toStore(() => page.params.section) — Svelte's official bridge gives the legacy $: a real store dependency; without it, tab navigation would silently stop updating activeSection. Full runes conversion is #1208 scope.
+layout.svelte $: if (browser) applying ?language= on every nav afterNavigate() — fires on mount + every client-side navigation, the identical cadence the $page store dep provided; a bare read would have applied the language param only on initial load

Verified

  • svelte-check 0/0, Biome clean, 584/584 tests, prod build green
  • Deploy-preview QA (below): area section-tab switching stays reactive; ?language= still applies

Closes #1207. Part of #1201.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Improved page-state handling across section navigation, error pages, community maps, and leaderboards.
    • Preserved active sections, query parameters, language settings, and leaderboard period changes during navigation.
    • Improved language synchronization when navigating between pages.
    • Maintained offline reload status and error-message display behavior.

$app/stores is deprecated since Kit 2.12; $app/state's page is
rune-backed. Three of the five files were mechanical swaps (snapshot
reads at init, runes-mode reads, onMount/template reads). Two needed
real care because a bare page.* read inside a legacy $: statement is
not tracked and would run exactly once:

- AreaPage.svelte: activeSection derives from page.params.section
  reactively (section tab switching). Bridged with
  toStore(() => page.params.section) so the legacy $: keeps a real
  store dependency. Full runes conversion is #1208 scope.
- +layout.svelte: the ?language= applier ran on every navigation via
  its $page store dep. Replaced with afterNavigate (fires on mount +
  every client-side nav — identical cadence, clearer intent).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@netlify

netlify Bot commented Aug 10, 2026

Copy link
Copy Markdown

Deploy Preview for btcmap ready!

Name Link
🔨 Latest commit 2ba5f0d
🔍 Latest deploy log https://app.netlify.com/projects/btcmap/deploys/6a79baa802586a0008d6d4ca
😎 Deploy Preview https://deploy-preview-1237--btcmap.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 52 (🔴 down 8 from production)
Accessibility: 97 (no change from production)
Best Practices: 92 (🔴 down 8 from production)
SEO: 96 (no change from production)
PWA: 90 (no change from production)
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

@qodo-code-review

Copy link
Copy Markdown
Contributor

ⓘ Qodo reviews are paused because the subscription is no longer active. Ask your workspace admin to reactivate the subscription to resume reviews. Manage billing

@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The PR migrates five Svelte components from $app/stores to $app/state. It preserves active-section reactivity, route query-parameter handling, error display, and language synchronization across client-side navigation.

Changes

SvelteKit app-state migration

Layer / File(s) Summary
Route page-state consumers
src/routes/+error.svelte, src/routes/communities/map/+page.svelte, src/routes/leaderboard/+page.svelte
Error handling, query-parameter reads, and leaderboard URL construction now use the $app/state page object.
Area active-section reactivity
src/components/area/AreaPage.svelte
page.params.section is adapted with toStore so legacy reactive statements continue to update the active section.
Language navigation synchronization
src/routes/+layout.svelte
Language query parameters are processed on mount and after client-side navigation with afterNavigate, updating the locale and local storage.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested labels: Review effort 2/5

Suggested reviewers: dadofsambonzuki

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the primary change: migrating five consumers from $app/stores to $app/state.
Description check ✅ Passed The description explains the migration, behavior-preserving treatments, validation results, and issue links; only the Screenshots section is absent.
Linked Issues check ✅ Passed The PR migrates all five files to $app/state and preserves reactive navigation and URL-parameter behavior required by [#1207].
Out of Scope Changes check ✅ Passed All changes are limited to the five specified consumers and related compatibility handling, with no unrelated changes described.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/app-state

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR migrates the remaining $app/stores consumers to the deprecated replacement $app/state, taking care to preserve reactivity in legacy-mode components where a plain page.* read would otherwise not re-trigger $: statements.

Changes:

  • Replaced $app/stores page usage with $app/state page across affected routes/components.
  • Updated the root layout’s ?language= syncing from a $: + $page dependency to afterNavigate() to keep the same “on mount + every navigation” cadence.
  • Bridged page.params.section into legacy $: reactivity in AreaPage.svelte using toStore(() => ...) so section-tab navigation continues to update.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/routes/leaderboard/+page.svelte Swaps $page store reads to page state reads inside a runes-mode event handler.
src/routes/communities/map/+page.svelte Replaces $page snapshot query-param reads with page state snapshot reads.
src/routes/+layout.svelte Uses afterNavigate() to re-apply ?language= on mount and client navigations using $app/state.
src/routes/+error.svelte Replaces $page.status / $page.error reads with page.status / page.error in mount logic and template.
src/components/area/AreaPage.svelte Uses toStore(() => page.params.section) to keep legacy $: section switching reactive with $app/state.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/routes/communities/map/`+page.svelte:
- Line 42: Replace the non-rune page usage with the established legacy page
subscription/helper in src/routes/communities/map/+page.svelte at lines 42 and
59-61, and in src/routes/+error.svelte at lines 8-11 and 38. Keep the adapter
unchanged and ensure page.url.searchParams, page.status, and page.error continue
updating during client-side navigation.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 55611e3a-41fb-4b9a-bbde-b75dc16bb7f8

📥 Commits

Reviewing files that changed from the base of the PR and between ff0ac11 and 2ba5f0d.

📒 Files selected for processing (5)
  • src/components/area/AreaPage.svelte
  • src/routes/+error.svelte
  • src/routes/+layout.svelte
  • src/routes/communities/map/+page.svelte
  • src/routes/leaderboard/+page.svelte

Comment thread src/routes/communities/map/+page.svelte
@escapedcat
escapedcat merged commit bce8e85 into main Aug 10, 2026
13 checks passed
@escapedcat
escapedcat deleted the chore/app-state branch August 10, 2026 12:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor(kit): migrate $app/stores → $app/state

2 participants