@@ -21,6 +21,8 @@ import { useLayout } from "@/context/layout"
2121import { usePlatform } from "@/context/platform"
2222import { useServer } from "@/context/server"
2323import { useSync } from "@/context/sync"
24+ import { useTerminal } from "@/context/terminal"
25+ import { focusTerminalById } from "@/pages/session/helpers"
2426import { decode64 } from "@/utils/base64"
2527import { Persist , persisted } from "@/utils/persist"
2628import { StatusPopover } from "../status-popover"
@@ -229,6 +231,7 @@ export function SessionHeader() {
229231 const sync = useSync ( )
230232 const platform = usePlatform ( )
231233 const language = useLanguage ( )
234+ const terminal = useTerminal ( )
232235
233236 const projectDirectory = createMemo ( ( ) => decode64 ( params . dir ) ?? "" )
234237 const project = createMemo ( ( ) => {
@@ -296,6 +299,16 @@ export function SessionHeader() {
296299 ] as const
297300 } )
298301
302+ const toggleTerminal = ( ) => {
303+ const next = ! view ( ) . terminal . opened ( )
304+ view ( ) . terminal . toggle ( )
305+ if ( ! next ) return
306+
307+ const id = terminal . active ( )
308+ if ( ! id ) return
309+ focusTerminalById ( id )
310+ }
311+
299312 const [ prefs , setPrefs ] = persisted ( Persist . global ( "open.app" ) , createStore ( { app : "finder" as OpenApp } ) )
300313 const [ menu , setMenu ] = createStore ( { open : false } )
301314 const [ openRequest , setOpenRequest ] = createStore ( {
@@ -617,39 +630,39 @@ export function SessionHeader() {
617630 </ div >
618631 </ Show >
619632 < div class = "flex items-center gap-1" >
620- < div class = "hidden md:flex items-center gap-1 shrink-0" >
621- < TooltipKeybind
622- title = { language . t ( "command.terminal.toggle" ) }
623- keybind = { command . keybind ( "terminal.toggle" ) }
633+ < TooltipKeybind
634+ title = { language . t ( "command.terminal.toggle" ) }
635+ keybind = { command . keybind ( "terminal.toggle" ) }
636+ >
637+ < Button
638+ variant = "ghost"
639+ class = "group/terminal-toggle titlebar-icon w-8 h-6 p-0 box-border shrink-0"
640+ onClick = { toggleTerminal }
641+ aria-label = { language . t ( "command.terminal.toggle" ) }
642+ aria-expanded = { view ( ) . terminal . opened ( ) }
643+ aria-controls = "terminal-panel"
624644 >
625- < Button
626- variant = "ghost"
627- class = "group/terminal-toggle titlebar-icon w-8 h-6 p-0 box-border"
628- onClick = { ( ) => view ( ) . terminal . toggle ( ) }
629- aria-label = { language . t ( "command.terminal.toggle" ) }
630- aria-expanded = { view ( ) . terminal . opened ( ) }
631- aria-controls = "terminal-panel"
632- >
633- < div class = "relative flex items-center justify-center size-4 [&>*]:absolute [&>*]:inset-0" >
634- < Icon
635- size = "small"
636- name = { view ( ) . terminal . opened ( ) ? "layout-bottom-partial" : "layout-bottom" }
637- class = "group-hover/terminal-toggle:hidden"
638- />
639- < Icon
640- size = "small"
641- name = "layout-bottom-partial"
642- class = "hidden group-hover/terminal-toggle:inline-block"
643- />
644- < Icon
645- size = "small"
646- name = { view ( ) . terminal . opened ( ) ? "layout-bottom" : "layout-bottom-partial" }
647- class = "hidden group-active/terminal-toggle:inline-block"
648- />
649- </ div >
650- </ Button >
651- </ TooltipKeybind >
645+ < div class = "relative flex items-center justify-center size-4 [&>*]:absolute [&>*]:inset-0" >
646+ < Icon
647+ size = "small"
648+ name = { view ( ) . terminal . opened ( ) ? "layout-bottom-partial" : "layout-bottom" }
649+ class = "group-hover/terminal-toggle:hidden"
650+ />
651+ < Icon
652+ size = "small"
653+ name = "layout-bottom-partial"
654+ class = "hidden group-hover/terminal-toggle:inline-block"
655+ />
656+ < Icon
657+ size = "small"
658+ name = { view ( ) . terminal . opened ( ) ? "layout-bottom" : "layout-bottom-partial" }
659+ class = "hidden group-active/terminal-toggle:inline-block"
660+ />
661+ </ div >
662+ </ Button >
663+ </ TooltipKeybind >
652664
665+ < div class = "hidden md:flex items-center gap-1 shrink-0" >
653666 < TooltipKeybind
654667 title = { language . t ( "command.review.toggle" ) }
655668 keybind = { command . keybind ( "review.toggle" ) }
0 commit comments