From 7b396ff72daf5ea0e4e266ea51d3f64a5ad8ca9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C5=ABdolfs=20O=C5=A1i=C5=86=C5=A1?= Date: Mon, 23 Mar 2026 17:22:07 -0600 Subject: [PATCH] Persist sidebar across navigations to preserve scroll position MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Move AppSidebar out of per-route view components into App.svelte so it is never unmounted on navigation. This fixes the sidebar scroll position resetting to the top whenever the user opens a repository or navigates between Issues, Patches and the repo home view. Also removes the redundant invoke("config") call from each repo route loader — the value is now taken from sidebarData.config, which loadSidebarData() already fetches. --- src/App.svelte | 52 ++++++++++++++++++++++--------- src/lib/router/definitions.ts | 12 +++++++ src/modals/Guide.svelte | 2 +- src/views/Inbox.svelte | 2 +- src/views/repo/Issue.svelte | 5 +-- src/views/repo/Issues.svelte | 6 ++-- src/views/repo/Layout.svelte | 57 +++++++++++----------------------- src/views/repo/Patch.svelte | 5 +-- src/views/repo/Patches.svelte | 6 ++-- src/views/repo/RepoHome.svelte | 6 ++-- src/views/repo/router.ts | 28 +++++++---------- 11 files changed, 88 insertions(+), 93 deletions(-) diff --git a/src/App.svelte b/src/App.svelte index 21231e80d..12b509725 100644 --- a/src/App.svelte +++ b/src/App.svelte @@ -1,6 +1,7 @@ - - -
- - {#if selfScroll} -
- {@render children()} -
- {:else} - { - if (!loadingContent) { - loadingContent = true; - void loadMoreContent().finally(() => (loadingContent = false)); - } +{#if selfScroll} +
+ {@render children()} +
+{:else} + { + if (!loadingContent) { + loadingContent = true; + void loadMoreContent().finally(() => (loadingContent = false)); } - : undefined}> - {@render children()} - - {/if} -
+ } + : undefined}> + {@render children()} + +{/if} diff --git a/src/views/repo/Patch.svelte b/src/views/repo/Patch.svelte index c88ef0654..aa7fea604 100644 --- a/src/views/repo/Patch.svelte +++ b/src/views/repo/Patch.svelte @@ -13,7 +13,6 @@ import { nodeRunning } from "@app/lib/events"; import { invoke } from "@app/lib/invoke"; import * as router from "@app/lib/router"; - import type { SidebarData } from "@app/lib/router/definitions"; import { didFromPublicKey, explorerUrl, @@ -46,7 +45,6 @@ activity: Operation[]; status: PatchStatus | undefined; review: Review | DraftReview | undefined; - sidebarData: SidebarData; } /* eslint-disable prefer-const */ @@ -58,7 +56,6 @@ status: initialStatus, activity, review, - sidebarData, }: Props = $props(); /* eslint-enable prefer-const */ @@ -249,7 +246,7 @@ } - + {#if review} ; status: PatchStatus | undefined; - sidebarData: SidebarData; } - const { repo, patches, status, sidebarData }: Props = $props(); + const { repo, patches, status }: Props = $props(); let items = $state(patches.content); let cursor = patches.cursor; @@ -225,7 +223,7 @@ } - +
Patches diff --git a/src/views/repo/RepoHome.svelte b/src/views/repo/RepoHome.svelte index 07d2623fe..1db26c862 100644 --- a/src/views/repo/RepoHome.svelte +++ b/src/views/repo/RepoHome.svelte @@ -9,7 +9,6 @@ import { useOverlayScrollbars } from "overlayscrollbars-svelte"; import { invoke, InvokeError } from "@app/lib/invoke"; - import type { SidebarData } from "@app/lib/router/definitions"; import { highlight } from "@app/lib/syntax"; import FileBlock from "@app/components/FileBlock.svelte"; @@ -27,11 +26,10 @@ tree: Tree; repo: RepoInfo; readme: Readme | null; - sidebarData: SidebarData; } /* eslint-disable prefer-const */ - let { tree, readme, repo, sidebarData }: Props = $props(); + let { tree, readme, repo }: Props = $props(); /* eslint-enable prefer-const */ let currentPath = $state(""); @@ -120,7 +118,7 @@ } - +
; status: PatchStatus | undefined; sidebarData: SidebarData; @@ -137,10 +134,9 @@ export type LoadedRepoRoute = export async function loadPatch( route: RepoPatchRoute, ): Promise { - const [sidebarData, config, repo, patches, patch, revisions, activity] = + const [sidebarData, repo, patches, patch, revisions, activity] = await Promise.all([ loadSidebarData(), - invoke("config"), invoke("repo_by_id", { rid: route.rid, }), @@ -163,6 +159,8 @@ export async function loadPatch( }), ]); + const config = sidebarData.config; + const draftReview = route.reviewId !== undefined && draftReviewStorage.get(route.reviewId, { @@ -195,9 +193,8 @@ export async function loadPatch( export async function loadPatches( route: RepoPatchesRoute, ): Promise { - const [sidebarData, config, repo, patches] = await Promise.all([ + const [sidebarData, repo, patches] = await Promise.all([ loadSidebarData(), - invoke("config"), invoke("repo_by_id", { rid: route.rid, }), @@ -210,16 +207,15 @@ export async function loadPatches( return { resource: "repo.patches", - params: { sidebarData, repo, config, patches, status: route.status }, + params: { sidebarData, repo, patches, status: route.status }, }; } export async function loadRepoHome( route: RepoHomeRoute, ): Promise { - const [sidebarData, config, repo, readme, tree] = await Promise.all([ + const [sidebarData, repo, readme, tree] = await Promise.all([ loadSidebarData(), - invoke("config"), invoke("repo_by_id", { rid: route.rid, }), @@ -235,17 +231,16 @@ export async function loadRepoHome( return { resource: "repo.home", - params: { sidebarData, repo, sha: route.sha, config, readme, tree }, + params: { sidebarData, repo, sha: route.sha, readme, tree }, }; } export async function loadIssue( route: RepoIssueRoute, ): Promise { - const [sidebarData, config, repo, issue, activity, issues, threads] = + const [sidebarData, repo, issue, activity, issues, threads] = await Promise.all([ loadSidebarData(), - invoke("config"), invoke("repo_by_id", { rid: route.rid, }), @@ -272,7 +267,7 @@ export async function loadIssue( params: { sidebarData, repo, - config, + config: sidebarData.config, issue, activity, issues, @@ -285,9 +280,8 @@ export async function loadIssue( export async function loadIssues( route: RepoIssuesRoute, ): Promise { - const [sidebarData, config, repo, issues] = await Promise.all([ + const [sidebarData, repo, issues] = await Promise.all([ loadSidebarData(), - invoke("config"), invoke("repo_by_id", { rid: route.rid, }), @@ -299,7 +293,7 @@ export async function loadIssues( return { resource: "repo.issues", - params: { sidebarData, repo, config, issues, status: route.status }, + params: { sidebarData, repo, issues, status: route.status }, }; }