fix(app): stabilize project close navigation (#15817)
Co-authored-by: Adam <2363879+adamdotdevin@users.noreply.github.com>
This commit is contained in:
@@ -1213,11 +1213,28 @@ export default function Layout(props: ParentProps) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function closeProject(directory: string) {
|
function closeProject(directory: string) {
|
||||||
const index = layout.projects.list().findIndex((x) => x.worktree === directory)
|
const list = layout.projects.list()
|
||||||
const next = layout.projects.list()[index + 1]
|
const index = list.findIndex((x) => x.worktree === directory)
|
||||||
|
const active = currentProject()?.worktree === directory
|
||||||
|
if (index === -1) return
|
||||||
|
const next = list[index + 1]
|
||||||
|
|
||||||
|
if (!active) {
|
||||||
|
layout.projects.close(directory)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!next) {
|
||||||
|
layout.projects.close(directory)
|
||||||
|
navigate("/")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
navigateWithSidebarReset(`/${base64Encode(next.worktree)}/session`)
|
||||||
layout.projects.close(directory)
|
layout.projects.close(directory)
|
||||||
if (next) navigateToProject(next.worktree)
|
queueMicrotask(() => {
|
||||||
else navigate("/")
|
void navigateToProject(next.worktree)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function toggleProjectWorkspaces(project: LocalProject) {
|
function toggleProjectWorkspaces(project: LocalProject) {
|
||||||
@@ -2064,7 +2081,11 @@ export default function Layout(props: ParentProps) {
|
|||||||
onOpenSettings={openSettings}
|
onOpenSettings={openSettings}
|
||||||
helpLabel={() => language.t("sidebar.help")}
|
helpLabel={() => language.t("sidebar.help")}
|
||||||
onOpenHelp={() => platform.openLink("https://opencode.ai/desktop-feedback")}
|
onOpenHelp={() => platform.openLink("https://opencode.ai/desktop-feedback")}
|
||||||
renderPanel={() => <SidebarPanel project={currentProject()} />}
|
renderPanel={() => (
|
||||||
|
<Show when={currentProject()} keyed>
|
||||||
|
{(project) => <SidebarPanel project={project} />}
|
||||||
|
</Show>
|
||||||
|
)}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<Show when={!layout.sidebar.opened() ? hoverProjectData()?.worktree : undefined} keyed>
|
<Show when={!layout.sidebar.opened() ? hoverProjectData()?.worktree : undefined} keyed>
|
||||||
|
|||||||
Reference in New Issue
Block a user