Skip to content

Commit 88daa53

Browse files
MrMushrooooomadamdotdevin
authored andcommitted
fix(app): stabilize project close navigation (anomalyco#15817)
Co-authored-by: Adam <2363879+adamdotdevin@users.noreply.github.com>
1 parent 70bd9a0 commit 88daa53

1 file changed

Lines changed: 26 additions & 5 deletions

File tree

packages/app/src/pages/layout.tsx

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1214,11 +1214,28 @@ export default function Layout(props: ParentProps) {
12141214
}
12151215

12161216
function closeProject(directory: string) {
1217-
const index = layout.projects.list().findIndex((x) => x.worktree === directory)
1218-
const next = layout.projects.list()[index + 1]
1217+
const list = layout.projects.list()
1218+
const index = list.findIndex((x) => x.worktree === directory)
1219+
const active = currentProject()?.worktree === directory
1220+
if (index === -1) return
1221+
const next = list[index + 1]
1222+
1223+
if (!active) {
1224+
layout.projects.close(directory)
1225+
return
1226+
}
1227+
1228+
if (!next) {
1229+
layout.projects.close(directory)
1230+
navigate("/")
1231+
return
1232+
}
1233+
1234+
navigateWithSidebarReset(`/${base64Encode(next.worktree)}/session`)
12191235
layout.projects.close(directory)
1220-
if (next) navigateToProject(next.worktree)
1221-
else navigate("/")
1236+
queueMicrotask(() => {
1237+
void navigateToProject(next.worktree)
1238+
})
12221239
}
12231240

12241241
function toggleProjectWorkspaces(project: LocalProject) {
@@ -2073,7 +2090,11 @@ export default function Layout(props: ParentProps) {
20732090
onOpenSettings={openSettings}
20742091
helpLabel={() => language.t("sidebar.help")}
20752092
onOpenHelp={() => platform.openLink("https://opencode.ai/desktop-feedback")}
2076-
renderPanel={() => <SidebarPanel project={currentProject()} />}
2093+
renderPanel={() => (
2094+
<Show when={currentProject()} keyed>
2095+
{(project) => <SidebarPanel project={project} />}
2096+
</Show>
2097+
)}
20772098
/>
20782099
</div>
20792100
<Show when={!layout.sidebar.opened() ? hoverProjectData()?.worktree : undefined} keyed>

0 commit comments

Comments
 (0)