@@ -5,7 +5,6 @@ import { IconButton } from "@opencode-ai/ui/icon-button"
55import { Icon } from "@opencode-ai/ui/icon"
66import { Button } from "@opencode-ai/ui/button"
77import { Tooltip , TooltipKeybind } from "@opencode-ai/ui/tooltip"
8- import { useTheme } from "@opencode-ai/ui/theme/context"
98import { IconButtonV2 } from "@opencode-ai/ui/v2/icon-button-v2"
109import { Icon as IconV2 } from "@opencode-ai/ui/v2/icon"
1110import { KeybindV2 } from "@opencode-ai/ui/v2/keybind-v2"
@@ -28,28 +27,8 @@ import { tabKey, useTabs } from "@/context/tabs"
2827import type { PromptSession } from "@/context/prompt"
2928import "./titlebar.css"
3029import { newTabTooltipKeybind } from "./command-tooltip-keybind"
30+ import { macTitlebarLeftPadding } from "./titlebar-padding"
3131
32- type TauriDesktopWindow = {
33- startDragging ?: ( ) => Promise < void >
34- toggleMaximize ?: ( ) => Promise < void >
35- }
36-
37- type TauriThemeWindow = {
38- setTheme ?: ( theme ?: "light" | "dark" | null ) => Promise < void >
39- }
40-
41- type TauriApi = {
42- window ?: {
43- getCurrentWindow ?: ( ) => TauriDesktopWindow
44- }
45- webviewWindow ?: {
46- getCurrentWebviewWindow ?: ( ) => TauriThemeWindow
47- }
48- }
49-
50- const tauriApi = ( ) => ( window as unknown as { __TAURI__ ?: TauriApi } ) . __TAURI__
51- const currentDesktopWindow = ( ) => tauriApi ( ) ?. window ?. getCurrentWindow ?.( )
52- const currentThemeWindow = ( ) => tauriApi ( ) ?. webviewWindow ?. getCurrentWebviewWindow ?.( )
5332const legacyTitlebarHeight = 40
5433const v2TitlebarHeight = 36
5534const minTitlebarZoom = 0.25
@@ -73,7 +52,6 @@ export function Titlebar(props: { update?: TitlebarUpdate; debugTools?: { visibl
7352 const command = useCommand ( )
7453 const language = useLanguage ( )
7554 const settings = useSettings ( )
76- const theme = useTheme ( )
7755 const server = useServer ( )
7856 const navigate = useNavigate ( )
7957 const location = useLocation ( )
@@ -84,7 +62,6 @@ export function Titlebar(props: { update?: TitlebarUpdate; debugTools?: { visibl
8462
8563 const mac = createMemo ( ( ) => platform . platform === "desktop" && platform . os === "macos" )
8664 const windows = createMemo ( ( ) => platform . platform === "desktop" && platform . os === "windows" )
87- const electronWindows = createMemo ( ( ) => windows ( ) && ! tauriApi ( ) )
8865 const linux = createMemo ( ( ) => platform . platform === "desktop" && platform . os === "linux" )
8966 const web = createMemo ( ( ) => platform . platform === "web" )
9067 const zoom = ( ) => platform . webviewZoom ?.( ) ?? 1
@@ -175,56 +152,6 @@ export function Titlebar(props: { update?: TitlebarUpdate; debugTools?: { visibl
175152 } ,
176153 ] )
177154
178- const getWin = ( ) => {
179- if ( platform . platform !== "desktop" ) return
180- return currentDesktopWindow ( )
181- }
182-
183- createEffect ( ( ) => {
184- if ( platform . platform !== "desktop" ) return
185-
186- const scheme = theme . colorScheme ( )
187- const value = scheme === "system" ? null : scheme
188-
189- const win = currentThemeWindow ( )
190- if ( ! win ?. setTheme ) return
191-
192- void win . setTheme ( value ) . catch ( ( ) => undefined )
193- } )
194-
195- const interactive = ( target : EventTarget | null ) => {
196- if ( ! ( target instanceof Element ) ) return false
197-
198- const selector =
199- "button, a, input, textarea, select, option, [role='button'], [role='menuitem'], [contenteditable='true'], [contenteditable='']"
200-
201- return ! ! target . closest ( selector )
202- }
203-
204- const drag = ( e : MouseEvent ) => {
205- if ( platform . platform !== "desktop" ) return
206- if ( e . buttons !== 1 ) return
207- if ( interactive ( e . target ) ) return
208-
209- const win = getWin ( )
210- if ( ! win ?. startDragging ) return
211-
212- e . preventDefault ( )
213- void win . startDragging ( ) . catch ( ( ) => undefined )
214- }
215-
216- const maximize = ( e : MouseEvent ) => {
217- if ( platform . platform !== "desktop" ) return
218- if ( interactive ( e . target ) ) return
219- if ( e . target instanceof Element && e . target . closest ( "[data-tauri-decorum-tb]" ) ) return
220-
221- const win = getWin ( )
222- if ( ! win ?. toggleMaximize ) return
223-
224- e . preventDefault ( )
225- void win . toggleMaximize ( ) . catch ( ( ) => undefined )
226- }
227-
228155 return (
229156 < header
230157 data-slot = { useV2Titlebar ( ) ? "titlebar-v2" : undefined }
@@ -236,17 +163,13 @@ export function Titlebar(props: { update?: TitlebarUpdate; debugTools?: { visibl
236163 } }
237164 style = { {
238165 "min-height" : minHeight ( ) ,
239- // Keep native macOS traffic lights clear even when the desktop window is narrow.
240- "padding-left" : mac ( ) ? `${ 84 / zoom ( ) } px` : 0 ,
241- width : electronWindows ( ) ? `env(titlebar-area-width, calc(100vw - ${ windowsControlsWidth ( ) } ))` : undefined ,
242- "max-width" : electronWindows ( )
243- ? `env(titlebar-area-width, calc(100vw - ${ windowsControlsWidth ( ) } ))`
244- : undefined ,
245- "align-self" : electronWindows ( ) ? "flex-start" : undefined ,
166+ // Keep visible native macOS traffic lights clear even when the desktop window is narrow.
167+ "padding-left" : mac ( ) ? macTitlebarLeftPadding ( zoom ( ) , platform . windowFullscreen ?.( ) ?? false ) : 0 ,
168+ width : windows ( ) ? `env(titlebar-area-width, calc(100vw - ${ windowsControlsWidth ( ) } ))` : undefined ,
169+ "max-width" : windows ( ) ? `env(titlebar-area-width, calc(100vw - ${ windowsControlsWidth ( ) } ))` : undefined ,
170+ "align-self" : windows ( ) ? "flex-start" : undefined ,
246171 } }
247172 data-tauri-drag-region
248- onMouseDown = { drag }
249- onDblClick = { maximize }
250173 >
251174 < Switch >
252175 < Match when = { useV2Titlebar ( ) } >
@@ -527,9 +450,6 @@ export function Titlebar(props: { update?: TitlebarUpdate; debugTools?: { visibl
527450 </ Show >
528451 < div class = "flex-1" />
529452 < TitlebarV2Right state = { v2RightState ( ) } />
530- < Show when = { windows ( ) && ! electronWindows ( ) } >
531- < div data-tauri-decorum-tb class = "flex flex-row" />
532- </ Show >
533453 </ div >
534454 )
535455 } }
@@ -549,7 +469,6 @@ export function Titlebar(props: { update?: TitlebarUpdate; debugTools?: { visibl
549469 < WindowsAppMenu command = { command } platform = { platform } />
550470 </ Show >
551471 < Show when = { mac ( ) } >
552- { /*<div class="h-full shrink-0" style={{ width: `${72 / zoom()}px` }} />*/ }
553472 < div class = "xl:hidden w-10 shrink-0 flex items-center justify-center" >
554473 < IconButton
555474 icon = "menu"
@@ -678,12 +597,10 @@ export function Titlebar(props: { update?: TitlebarUpdate; debugTools?: { visibl
678597 "pr-2" : ! windows ( ) ,
679598 } }
680599 data-tauri-drag-region
681- onMouseDown = { drag }
682600 >
683601 < div id = "opencode-titlebar-right" class = "flex items-center gap-1 shrink-0 justify-end" />
684602 < Show when = { windows ( ) } >
685- { ! tauriApi ( ) && < div class = "shrink-0" style = { { width : windowsControlsWidth ( ) } } /> }
686- < div data-tauri-decorum-tb class = "flex flex-row" />
603+ < div class = "shrink-0" style = { { width : windowsControlsWidth ( ) } } />
687604 </ Show >
688605 </ div >
689606 </ div >
0 commit comments