@@ -1213,11 +1213,28 @@ export default function Layout(props: ParentProps) {
12131213 }
12141214
12151215 function closeProject ( directory : string ) {
1216- const index = layout . projects . list ( ) . findIndex ( ( x ) => x . worktree === directory )
1217- const next = layout . projects . list ( ) [ index + 1 ]
1216+ const list = layout . projects . list ( )
1217+ const index = list . findIndex ( ( x ) => x . worktree === directory )
1218+ const active = currentProject ( ) ?. worktree === directory
1219+ if ( index === - 1 ) return
1220+ const next = list [ index + 1 ]
1221+
1222+ if ( ! active ) {
1223+ layout . projects . close ( directory )
1224+ return
1225+ }
1226+
1227+ if ( ! next ) {
1228+ layout . projects . close ( directory )
1229+ navigate ( "/" )
1230+ return
1231+ }
1232+
1233+ navigateWithSidebarReset ( `/${ base64Encode ( next . worktree ) } /session` )
12181234 layout . projects . close ( directory )
1219- if ( next ) navigateToProject ( next . worktree )
1220- else navigate ( "/" )
1235+ queueMicrotask ( ( ) => {
1236+ void navigateToProject ( next . worktree )
1237+ } )
12211238 }
12221239
12231240 function toggleProjectWorkspaces ( project : LocalProject ) {
@@ -2064,7 +2081,11 @@ export default function Layout(props: ParentProps) {
20642081 onOpenSettings = { openSettings }
20652082 helpLabel = { ( ) => language . t ( "sidebar.help" ) }
20662083 onOpenHelp = { ( ) => platform . openLink ( "https://opencode.ai/desktop-feedback" ) }
2067- renderPanel = { ( ) => < SidebarPanel project = { currentProject ( ) } /> }
2084+ renderPanel = { ( ) => (
2085+ < Show when = { currentProject ( ) } keyed >
2086+ { ( project ) => < SidebarPanel project = { project } /> }
2087+ </ Show >
2088+ ) }
20682089 />
20692090 </ div >
20702091 < Show when = { ! layout . sidebar . opened ( ) ? hoverProjectData ( ) ?. worktree : undefined } keyed >
0 commit comments