@@ -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"
@@ -30,31 +29,11 @@ import "./titlebar.css"
3029import { newTabTooltipKeybind } from "./command-tooltip-keybind"
3130import { normalizeSessionInfo } from "@/utils/session"
3231
33- type TauriDesktopWindow = {
34- startDragging ?: ( ) => Promise < void >
35- toggleMaximize ?: ( ) => Promise < void >
36- }
37-
38- type TauriThemeWindow = {
39- setTheme ?: ( theme ?: "light" | "dark" | null ) => Promise < void >
40- }
41-
42- type TauriApi = {
43- window ?: {
44- getCurrentWindow ?: ( ) => TauriDesktopWindow
45- }
46- webviewWindow ?: {
47- getCurrentWebviewWindow ?: ( ) => TauriThemeWindow
48- }
49- }
50-
51- const tauriApi = ( ) => ( window as unknown as { __TAURI__ ?: TauriApi } ) . __TAURI__
52- const currentDesktopWindow = ( ) => tauriApi ( ) ?. window ?. getCurrentWindow ?.( )
53- const currentThemeWindow = ( ) => tauriApi ( ) ?. webviewWindow ?. getCurrentWebviewWindow ?.( )
5432const legacyTitlebarHeight = 40
5533const v2TitlebarHeight = 36
5634const minTitlebarZoom = 0.25
5735const windowsControlsBaseWidth = 138 // 3 native Windows caption buttons at 46px each.
36+ const macTrafficLightsBaseWidth = 84
5837
5938export type TitlebarUpdate = {
6039 version : ( ) => string | undefined
@@ -74,7 +53,6 @@ export function Titlebar(props: { update?: TitlebarUpdate; debugTools?: { visibl
7453 const command = useCommand ( )
7554 const language = useLanguage ( )
7655 const settings = useSettings ( )
77- const theme = useTheme ( )
7856 const server = useServer ( )
7957 const navigate = useNavigate ( )
8058 const location = useLocation ( )
@@ -85,9 +63,9 @@ export function Titlebar(props: { update?: TitlebarUpdate; debugTools?: { visibl
8563
8664 const mac = createMemo ( ( ) => platform . platform === "desktop" && platform . os === "macos" )
8765 const windows = createMemo ( ( ) => platform . platform === "desktop" && platform . os === "windows" )
88- const electronWindows = createMemo ( ( ) => windows ( ) && ! tauriApi ( ) )
8966 const linux = createMemo ( ( ) => platform . platform === "desktop" && platform . os === "linux" )
9067 const web = createMemo ( ( ) => platform . platform === "web" )
68+ const macTrafficLights = createMemo ( ( ) => mac ( ) && ! platform . windowFullscreen ?.( ) )
9169 const zoom = ( ) => platform . webviewZoom ?.( ) ?? 1
9270 const titlebarZoom = ( ) => ( windows ( ) ? Math . max ( zoom ( ) , minTitlebarZoom ) : zoom ( ) )
9371 const counterZoom = ( ) => ( windows ( ) && titlebarZoom ( ) < 1 ? 1 / titlebarZoom ( ) : 1 )
@@ -176,56 +154,6 @@ export function Titlebar(props: { update?: TitlebarUpdate; debugTools?: { visibl
176154 } ,
177155 ] )
178156
179- const getWin = ( ) => {
180- if ( platform . platform !== "desktop" ) return
181- return currentDesktopWindow ( )
182- }
183-
184- createEffect ( ( ) => {
185- if ( platform . platform !== "desktop" ) return
186-
187- const scheme = theme . colorScheme ( )
188- const value = scheme === "system" ? null : scheme
189-
190- const win = currentThemeWindow ( )
191- if ( ! win ?. setTheme ) return
192-
193- void win . setTheme ( value ) . catch ( ( ) => undefined )
194- } )
195-
196- const interactive = ( target : EventTarget | null ) => {
197- if ( ! ( target instanceof Element ) ) return false
198-
199- const selector =
200- "button, a, input, textarea, select, option, [role='button'], [role='menuitem'], [contenteditable='true'], [contenteditable='']"
201-
202- return ! ! target . closest ( selector )
203- }
204-
205- const drag = ( e : MouseEvent ) => {
206- if ( platform . platform !== "desktop" ) return
207- if ( e . buttons !== 1 ) return
208- if ( interactive ( e . target ) ) return
209-
210- const win = getWin ( )
211- if ( ! win ?. startDragging ) return
212-
213- e . preventDefault ( )
214- void win . startDragging ( ) . catch ( ( ) => undefined )
215- }
216-
217- const maximize = ( e : MouseEvent ) => {
218- if ( platform . platform !== "desktop" ) return
219- if ( interactive ( e . target ) ) return
220- if ( e . target instanceof Element && e . target . closest ( "[data-tauri-decorum-tb]" ) ) return
221-
222- const win = getWin ( )
223- if ( ! win ?. toggleMaximize ) return
224-
225- e . preventDefault ( )
226- void win . toggleMaximize ( ) . catch ( ( ) => undefined )
227- }
228-
229157 return (
230158 < header
231159 data-slot = { useV2Titlebar ( ) ? "titlebar-v2" : undefined }
@@ -238,16 +166,12 @@ export function Titlebar(props: { update?: TitlebarUpdate; debugTools?: { visibl
238166 style = { {
239167 "min-height" : minHeight ( ) ,
240168 // Keep native macOS traffic lights clear even when the desktop window is narrow.
241- "padding-left" : mac ( ) ? `${ 84 / zoom ( ) } px` : 0 ,
242- width : electronWindows ( ) ? `env(titlebar-area-width, calc(100vw - ${ windowsControlsWidth ( ) } ))` : undefined ,
243- "max-width" : electronWindows ( )
244- ? `env(titlebar-area-width, calc(100vw - ${ windowsControlsWidth ( ) } ))`
245- : undefined ,
246- "align-self" : electronWindows ( ) ? "flex-start" : undefined ,
169+ "padding-left" : macTrafficLights ( ) ? `${ macTrafficLightsBaseWidth / zoom ( ) } px` : 0 ,
170+ width : windows ( ) ? `env(titlebar-area-width, calc(100vw - ${ windowsControlsWidth ( ) } ))` : undefined ,
171+ "max-width" : windows ( ) ? `env(titlebar-area-width, calc(100vw - ${ windowsControlsWidth ( ) } ))` : undefined ,
172+ "align-self" : windows ( ) ? "flex-start" : undefined ,
247173 } }
248174 data-tauri-drag-region
249- onMouseDown = { drag }
250- onDblClick = { maximize }
251175 >
252176 < Switch >
253177 < Match when = { useV2Titlebar ( ) } >
@@ -459,8 +383,8 @@ export function Titlebar(props: { update?: TitlebarUpdate; debugTools?: { visibl
459383 classList = { {
460384 "pt-2" : ! bottom ( ) ,
461385 "pb-2" : bottom ( ) ,
462- "md:pl-2" : mac ( ) ,
463- "md:pl-4" : ! mac ( ) ,
386+ "md:pl-2" : macTrafficLights ( ) ,
387+ "md:pl-4" : ! macTrafficLights ( ) ,
464388 } }
465389 >
466390 < ChannelIndicator debugTools = { props . debugTools } />
@@ -528,9 +452,6 @@ export function Titlebar(props: { update?: TitlebarUpdate; debugTools?: { visibl
528452 </ Show >
529453 < div class = "flex-1" />
530454 < TitlebarV2Right state = { v2RightState ( ) } />
531- < Show when = { windows ( ) && ! electronWindows ( ) } >
532- < div data-tauri-decorum-tb class = "flex flex-row" />
533- </ Show >
534455 </ div >
535456 )
536457 } }
@@ -543,14 +464,13 @@ export function Titlebar(props: { update?: TitlebarUpdate; debugTools?: { visibl
543464 < div
544465 classList = { {
545466 "flex items-center min-w-0" : true ,
546- "pl-2" : ! mac ( ) ,
467+ "pl-2" : ! macTrafficLights ( ) ,
547468 } }
548469 >
549470 < Show when = { windows ( ) || linux ( ) } >
550471 < WindowsAppMenu command = { command } platform = { platform } />
551472 </ Show >
552473 < Show when = { mac ( ) } >
553- { /*<div class="h-full shrink-0" style={{ width: `${72 / zoom()}px` }} />*/ }
554474 < div class = "xl:hidden w-10 shrink-0 flex items-center justify-center" >
555475 < IconButton
556476 icon = "menu"
@@ -680,12 +600,10 @@ export function Titlebar(props: { update?: TitlebarUpdate; debugTools?: { visibl
680600 "pr-2" : ! windows ( ) ,
681601 } }
682602 data-tauri-drag-region
683- onMouseDown = { drag }
684603 >
685604 < div id = "opencode-titlebar-right" class = "flex items-center gap-1 shrink-0 justify-end" />
686605 < Show when = { windows ( ) } >
687- { ! tauriApi ( ) && < div class = "shrink-0" style = { { width : windowsControlsWidth ( ) } } /> }
688- < div data-tauri-decorum-tb class = "flex flex-row" />
606+ < div class = "shrink-0" style = { { width : windowsControlsWidth ( ) } } />
689607 </ Show >
690608 </ div >
691609 </ div >
0 commit comments