@@ -7,19 +7,20 @@ import {
77 Match ,
88 onMount ,
99 Show ,
10- startTransition ,
1110 Switch ,
1211 untrack ,
1312} from "solid-js"
1413import { createStore } from "solid-js/store"
15- import { useLocation , useMatch , useNavigate , useParams } from "@solidjs/router"
14+ import { useLocation , useNavigate , useParams } from "@solidjs/router"
1615import { IconButton } from "@opencode-ai/ui/icon-button"
1716import { Icon } from "@opencode-ai/ui/icon"
1817import { Button } from "@opencode-ai/ui/button"
1918import { Tooltip , TooltipKeybind } from "@opencode-ai/ui/tooltip"
2019import { useTheme } from "@opencode-ai/ui/theme/context"
2120import { IconButtonV2 } from "@opencode-ai/ui/v2/icon-button-v2"
2221import { Icon as IconV2 } from "@opencode-ai/ui/v2/icon"
22+ import { KeybindV2 } from "@opencode-ai/ui/v2/keybind-v2"
23+ import { TooltipV2 } from "@opencode-ai/ui/v2/tooltip-v2"
2324
2425import { getProjectAvatarVariant , LayoutRoute , useLayout , type LocalProject } from "@/context/layout"
2526import { usePlatform } from "@/context/platform"
@@ -253,7 +254,6 @@ export function Titlebar(props: { update?: TitlebarUpdate }) {
253254 { ( _ ) => {
254255 const serverSync = useServerSync ( )
255256 const navigate = useNavigate ( )
256- const homeMatch = useMatch ( ( ) => "/" )
257257 const layout = useLayout ( )
258258
259259 const newSessionHref = ( ) => {
@@ -268,17 +268,6 @@ export function Titlebar(props: { update?: TitlebarUpdate }) {
268268 const tabs = useTabs ( )
269269 const tabsStore = tabs . store
270270 const tabsStoreActions = tabs
271- const navigateTab = ( tab : Tab ) => {
272- const href = tabHref ( tab )
273- if ( tab . server === server . key ) {
274- navigate ( href )
275- return
276- }
277- void startTransition ( ( ) => {
278- server . setActive ( tab . server )
279- navigate ( href )
280- } )
281- }
282271
283272 const matchRoute = ( route : LayoutRoute ) => {
284273 if ( route . type === "home" ) return
@@ -309,7 +298,10 @@ export function Titlebar(props: { update?: TitlebarUpdate }) {
309298 const route = layout . route ( )
310299 if ( ! tabs . ready ( ) ) return
311300 const tab = currentTab ( )
312- if ( tab ) return
301+ if ( tab ) {
302+ tabs . remember ( tab )
303+ return
304+ }
313305
314306 if ( route . type === "session" ) {
315307 const sync = serverSync ( ) . createDirSyncContext ( route . dir )
@@ -332,6 +324,18 @@ export function Titlebar(props: { update?: TitlebarUpdate }) {
332324 } )
333325
334326 const openNewTab = ( ) => navigate ( newSessionHref ( ) )
327+ const toggleHome = ( ) => tabs . toggleHome ( { home : layout . route ( ) . type === "home" , current : currentTab ( ) } )
328+
329+ command . register ( "titlebar-home" , ( ) => [
330+ {
331+ id : "home.toggle" ,
332+ title : language . t ( "home.title" ) ,
333+ category : language . t ( "command.category.view" ) ,
334+ keybind : "mod+b" ,
335+ hidden : true ,
336+ onSelect : toggleHome ,
337+ } ,
338+ ] )
335339
336340 command . register ( "tabs" , ( ) => {
337341 const current = currentTab ( )
@@ -369,7 +373,7 @@ export function Titlebar(props: { update?: TitlebarUpdate }) {
369373 if ( index === - 1 ) index = tabsStore . length - 1
370374
371375 const next = tabsStore [ index ]
372- if ( next ) navigateTab ( next )
376+ if ( next ) tabs . select ( next )
373377 } ,
374378 } ,
375379 {
@@ -386,7 +390,7 @@ export function Titlebar(props: { update?: TitlebarUpdate }) {
386390 if ( index === tabsStore . length ) index = 0
387391
388392 const next = tabsStore [ index ]
389- if ( next ) navigateTab ( next )
393+ if ( next ) tabs . select ( next )
390394 } ,
391395 } ,
392396 ...Array . from ( { length : 9 } , ( _ , i ) => {
@@ -401,7 +405,7 @@ export function Titlebar(props: { update?: TitlebarUpdate }) {
401405 hidden : true ,
402406 onSelect : ( ) => {
403407 const tab = tabsStore [ index ]
404- if ( tab ) navigateTab ( tab )
408+ if ( tab ) tabs . select ( tab )
405409 } ,
406410 }
407411 } ) ,
@@ -427,15 +431,28 @@ export function Titlebar(props: { update?: TitlebarUpdate }) {
427431 < Show when = { windows ( ) || linux ( ) } >
428432 < WindowsAppMenu command = { command } platform = { platform } variant = "v2" />
429433 </ Show >
430- < IconButtonV2
431- variant = "ghost-muted"
432- size = "large"
433- as = "a"
434- href = "/"
435- class = "!w-9 shrink-0"
436- icon = { < IconV2 name = "grid-plus" /> }
437- state = { ! ! homeMatch ( ) ? "pressed" : undefined }
438- />
434+ < TooltipV2
435+ placement = "bottom"
436+ value = {
437+ < >
438+ { language . t ( "home.title" ) }
439+ < KeybindV2 keys = { command . keybindParts ( "home.toggle" ) } variant = "neutral" />
440+ </ >
441+ }
442+ class = "shrink-0"
443+ >
444+ < IconButtonV2
445+ type = "button"
446+ variant = "ghost-muted"
447+ size = "large"
448+ class = "!w-9 shrink-0"
449+ icon = { < IconV2 name = "grid-plus" /> }
450+ state = { layout . route ( ) . type === "home" ? "pressed" : undefined }
451+ onClick = { toggleHome }
452+ aria-label = { language . t ( "home.title" ) }
453+ aria-pressed = { layout . route ( ) . type === "home" }
454+ />
455+ </ TooltipV2 >
439456
440457 < div data-slot = "titlebar-tabs" class = "relative min-w-0" >
441458 < div
@@ -469,7 +486,7 @@ export function Titlebar(props: { update?: TitlebarUpdate }) {
469486 title = { language . t ( "command.session.new" ) }
470487 active = { currentTab ( ) === tab }
471488 onNavigate = { ( ) => {
472- navigateTab ( tab )
489+ tabs . select ( tab )
473490 ref . scrollIntoView ( { behavior : "instant" } )
474491 } }
475492 onClose = { ( ) => tabsStoreActions . removeTab ( i ( ) ) }
@@ -488,7 +505,7 @@ export function Titlebar(props: { update?: TitlebarUpdate }) {
488505 directory = { decode64 ( tab . dirBase64 ) ! }
489506 sessionId = { tab . sessionId }
490507 onNavigate = { ( ) => {
491- navigateTab ( tab )
508+ tabs . select ( tab )
492509
493510 ref . scrollIntoView ( { behavior : "instant" } )
494511 } }
@@ -518,7 +535,7 @@ export function Titlebar(props: { update?: TitlebarUpdate }) {
518535 title = { language . t ( "command.session.new" ) }
519536 onClose = { ( ) => {
520537 const tab = tabsStore . at ( - 1 )
521- if ( tab ) navigateTab ( tab )
538+ if ( tab ) tabs . select ( tab )
522539 else navigate ( "/" )
523540 } }
524541 />
0 commit comments