fix: keep sidebar projects stable across WSL refreshes

This commit is contained in:
LukeParkerDev
2026-04-16 17:58:00 +10:00
parent fcc9cab760
commit 06b27db78e
2 changed files with 16 additions and 6 deletions

View File

@@ -2343,6 +2343,7 @@ export default function Layout(props: ParentProps) {
}
const projects = () => layout.projects.list()
const projectIds = createMemo(() => projects().map((project) => project.worktree))
const projectOverlay = () => <ProjectDragOverlay projects={projects} activeProject={() => store.activeProject} />
const sidebarContent = (mobile?: boolean) => (
<SidebarContent
@@ -2350,9 +2351,17 @@ export default function Layout(props: ParentProps) {
opened={() => layout.sidebar.opened()}
aimMove={aim.move}
projects={projects}
renderProject={(project) => (
<SortableProject ctx={projectSidebarCtx} project={project} sortNow={sortNow} mobile={mobile} />
)}
projectIds={projectIds}
renderProject={(worktree) => {
const project = createMemo(() => projects().find((item) => item.worktree === worktree))
return (
<Show when={project()}>
{(project) => (
<SortableProject ctx={projectSidebarCtx} project={project()} sortNow={sortNow} mobile={mobile} />
)}
</Show>
)
}}
handleDragStart={handleDragStart}
handleDragEnd={handleDragEnd}
handleDragOver={handleDragOver}

View File

@@ -18,7 +18,8 @@ export const SidebarContent = (props: {
opened: Accessor<boolean>
aimMove: (event: MouseEvent) => void
projects: Accessor<LocalProject[]>
renderProject: (project: LocalProject) => JSX.Element
projectIds: Accessor<string[]>
renderProject: (worktree: string) => JSX.Element
handleDragStart: (event: unknown) => void
handleDragEnd: () => void
handleDragOver: (event: DragEvent) => void
@@ -64,8 +65,8 @@ export const SidebarContent = (props: {
<DragDropSensors />
<ConstrainDragXAxis />
<div class="h-full w-full flex flex-col items-center gap-3 px-3 py-3 overflow-y-auto no-scrollbar">
<SortableProvider ids={props.projects().map((p) => projectSortableId(p.worktree))}>
<For each={props.projects()}>{(project) => props.renderProject(project)}</For>
<SortableProvider ids={props.projectIds().map(projectSortableId)}>
<For each={props.projectIds()}>{(worktree) => props.renderProject(worktree)}</For>
</SortableProvider>
<Tooltip
placement={placement()}