mirror of
https://github.com/anomalyco/opencode.git
synced 2026-05-22 20:05:23 +00:00
fix: keep sidebar projects stable across WSL refreshes
This commit is contained in:
@@ -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}
|
||||
|
||||
@@ -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()}
|
||||
|
||||
Reference in New Issue
Block a user