summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJack <[email protected]>2026-03-03 20:25:55 +0800
committerGitHub <[email protected]>2026-03-03 06:25:55 -0600
commit356b5d46013fe374ed1a581f11d1939d222964ac (patch)
tree352e2042c886dd41b5a2bf4a605906e6083b89a5
parent7305fc044d3be663147c1461a353956659704a90 (diff)
downloadopencode-356b5d46013fe374ed1a581f11d1939d222964ac.tar.gz
opencode-356b5d46013fe374ed1a581f11d1939d222964ac.zip
fix(app): stabilize project close navigation (#15817)
Co-authored-by: Adam <[email protected]>
-rw-r--r--packages/app/src/pages/layout.tsx31
1 files changed, 26 insertions, 5 deletions
diff --git a/packages/app/src/pages/layout.tsx b/packages/app/src/pages/layout.tsx
index f93d1f069..daf2aaa5c 100644
--- a/packages/app/src/pages/layout.tsx
+++ b/packages/app/src/pages/layout.tsx
@@ -1213,11 +1213,28 @@ export default function Layout(props: ParentProps) {
}
function closeProject(directory: string) {
- const index = layout.projects.list().findIndex((x) => x.worktree === directory)
- const next = layout.projects.list()[index + 1]
+ const list = layout.projects.list()
+ 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)
- if (next) navigateToProject(next.worktree)
- else navigate("/")
+ queueMicrotask(() => {
+ void navigateToProject(next.worktree)
+ })
}
function toggleProjectWorkspaces(project: LocalProject) {
@@ -2064,7 +2081,11 @@ export default function Layout(props: ParentProps) {
onOpenSettings={openSettings}
helpLabel={() => language.t("sidebar.help")}
onOpenHelp={() => platform.openLink("https://opencode.ai/desktop-feedback")}
- renderPanel={() => <SidebarPanel project={currentProject()} />}
+ renderPanel={() => (
+ <Show when={currentProject()} keyed>
+ {(project) => <SidebarPanel project={project} />}
+ </Show>
+ )}
/>
</div>
<Show when={!layout.sidebar.opened() ? hoverProjectData()?.worktree : undefined} keyed>