Skip to content

Commit ca8979b

Browse files
committed
update reservation for traffic lights width on macos tahoe
1 parent 9b28cf7 commit ca8979b

8 files changed

Lines changed: 76 additions & 25 deletions

File tree

frontend/app/store/wshclientapi.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -618,6 +618,12 @@ export class RpcApiType {
618618
return client.wshRpcCall("listalleditableapps", null, opts);
619619
}
620620

621+
// command "macosversion" [call]
622+
MacOSVersionCommand(client: WshClient, opts?: RpcOpts): Promise<string> {
623+
if (this.mockClient) return this.mockClient.mockWshRpcCall(client, "macosversion", null, opts);
624+
return client.wshRpcCall("macosversion", null, opts);
625+
}
626+
621627
// command "makedraftfromlocal" [call]
622628
MakeDraftFromLocalCommand(client: WshClient, data: CommandMakeDraftFromLocalData, opts?: RpcOpts): Promise<CommandMakeDraftFromLocalRtnData> {
623629
if (this.mockClient) return this.mockClient.mockWshRpcCall(client, "makedraftfromlocal", data, opts);

frontend/app/tab/tabbar.tsx

Lines changed: 34 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { TabRpcClient } from "@/app/store/wshrpcutil";
77
import { useWaveEnv } from "@/app/waveenv/waveenv";
88
import { WorkspaceLayoutModel } from "@/app/workspace/workspace-layout-model";
99
import { deleteLayoutModelForTab } from "@/layout/index";
10+
import { isMacOSTahoeOrLater } from "@/util/platformutil";
1011
import { fireAndForget } from "@/util/util";
1112
import { useAtomValue } from "jotai";
1213
import { OverlayScrollbars } from "overlayscrollbars";
@@ -20,6 +21,9 @@ import { WorkspaceSwitcher } from "./workspaceswitcher";
2021

2122
const TabDefaultWidth = 130;
2223
const TabMinWidth = 100;
24+
const MacOSTrafficLightsWidth = 74;
25+
const MacOSTahoeTrafficLightsWidth = 80;
26+
2327
const OSOptions = {
2428
overflow: {
2529
x: "scroll",
@@ -636,10 +640,13 @@ const TabBar = memo(({ workspace, noTabs }: TabBarProps) => {
636640
// Calculate window drag left width based on platform and state
637641
let windowDragLeftWidth = 10;
638642
if (env.isMacOS() && !isFullScreen) {
643+
const trafficLightsWidth = isMacOSTahoeOrLater()
644+
? MacOSTahoeTrafficLightsWidth
645+
: MacOSTrafficLightsWidth;
639646
if (zoomFactor > 0) {
640-
windowDragLeftWidth = 74 / zoomFactor;
647+
windowDragLeftWidth = trafficLightsWidth / zoomFactor;
641648
} else {
642-
windowDragLeftWidth = 74;
649+
windowDragLeftWidth = trafficLightsWidth;
643650
}
644651
}
645652

@@ -684,28 +691,32 @@ const TabBar = memo(({ workspace, noTabs }: TabBarProps) => {
684691
<div
685692
className="tabs-wrapper"
686693
ref={tabsWrapperRef}
687-
style={{ width: `${tabsWrapperWidth}px`, ...(noTabs ? ({ WebkitAppRegion: "drag" } as React.CSSProperties) : {}) }}
694+
style={{
695+
width: `${tabsWrapperWidth}px`,
696+
...(noTabs ? ({ WebkitAppRegion: "drag" } as React.CSSProperties) : {}),
697+
}}
688698
>
689-
{!noTabs && tabIds.map((tabId, index) => {
690-
const isActive = activeTabId === tabId;
691-
const showDivider = index !== 0 && !isActive && index !== activeTabIndex + 1;
692-
return (
693-
<Tab
694-
key={tabId}
695-
ref={tabRefs.current[index]}
696-
id={tabId}
697-
showDivider={showDivider}
698-
onSelect={() => handleSelectTab(tabId)}
699-
active={isActive}
700-
onDragStart={(event) => handleDragStart(event, tabId, tabRefs.current[index])}
701-
onClose={(event) => handleCloseTab(event, tabId)}
702-
onLoaded={() => handleTabLoaded(tabId)}
703-
isDragging={draggingTab === tabId}
704-
tabWidth={tabWidthRef.current}
705-
isNew={tabId === newTabId}
706-
/>
707-
);
708-
})}
699+
{!noTabs &&
700+
tabIds.map((tabId, index) => {
701+
const isActive = activeTabId === tabId;
702+
const showDivider = index !== 0 && !isActive && index !== activeTabIndex + 1;
703+
return (
704+
<Tab
705+
key={tabId}
706+
ref={tabRefs.current[index]}
707+
id={tabId}
708+
showDivider={showDivider}
709+
onSelect={() => handleSelectTab(tabId)}
710+
active={isActive}
711+
onDragStart={(event) => handleDragStart(event, tabId, tabRefs.current[index])}
712+
onClose={(event) => handleCloseTab(event, tabId)}
713+
onLoaded={() => handleTabLoaded(tabId)}
714+
isDragging={draggingTab === tabId}
715+
tabWidth={tabWidthRef.current}
716+
isNew={tabId === newTabId}
717+
/>
718+
);
719+
})}
709720
</div>
710721
</div>
711722
<button

frontend/app/tab/tabbarenv.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ export type TabBarEnv = WaveEnvSubset<{
1212
installAppUpdate: WaveEnv["electron"]["installAppUpdate"];
1313
};
1414
rpc: {
15+
ActivityCommand: WaveEnv["rpc"]["ActivityCommand"];
16+
SetConfigCommand: WaveEnv["rpc"]["SetConfigCommand"];
17+
SetMetaCommand: WaveEnv["rpc"]["SetMetaCommand"];
18+
UpdateTabNameCommand: WaveEnv["rpc"]["UpdateTabNameCommand"];
1519
UpdateWorkspaceTabIdsCommand: WaveEnv["rpc"]["UpdateWorkspaceTabIdsCommand"];
1620
};
1721
atoms: {
@@ -24,7 +28,8 @@ export type TabBarEnv = WaveEnvSubset<{
2428
updaterStatusAtom: WaveEnv["atoms"]["updaterStatusAtom"];
2529
};
2630
wos: WaveEnv["wos"];
27-
getSettingsKeyAtom: SettingsKeyAtomFnType<"app:hideaibutton" | "tab:confirmclose" | "window:showmenubar">;
31+
getSettingsKeyAtom: SettingsKeyAtomFnType<"app:hideaibutton" | "app:tabbar" | "tab:confirmclose" | "window:showmenubar">;
32+
showContextMenu: WaveEnv["showContextMenu"];
2833
mockSetWaveObj: WaveEnv["mockSetWaveObj"];
2934
isWindows: WaveEnv["isWindows"];
3035
isMacOS: WaveEnv["isMacOS"];

frontend/util/platformutil.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,28 @@
1-
// Copyright 2025, Command Line Inc.
1+
// Copyright 2026, Command Line Inc.
22
// SPDX-License-Identifier: Apache-2.0
33

44
export const PlatformMacOS = "darwin";
55
export const PlatformWindows = "win32";
66
export const PlatformLinux = "linux";
77
export let PLATFORM: NodeJS.Platform = PlatformMacOS;
8+
export let MacOSVersion: string = null;
89

910
export function setPlatform(platform: NodeJS.Platform) {
1011
PLATFORM = platform;
1112
}
1213

14+
export function setMacOSVersion(version: string) {
15+
MacOSVersion = version;
16+
}
17+
18+
export function isMacOSTahoeOrLater(): boolean {
19+
if (!isMacOS() || MacOSVersion == null) {
20+
return false;
21+
}
22+
const major = parseInt(MacOSVersion.split(".")[0], 10);
23+
return major >= 16;
24+
}
25+
1326
export function isMacOS(): boolean {
1427
return PLATFORM == PlatformMacOS;
1528
}

frontend/wave.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import { activeTabIdAtom } from "@/store/tab-model";
3232
import * as WOS from "@/store/wos";
3333
import { loadFonts } from "@/util/fontutil";
3434
import { setKeyUtilPlatform } from "@/util/keyutil";
35+
import { isMacOS, setMacOSVersion } from "@/util/platformutil";
3536
import { createElement } from "react";
3637
import { createRoot } from "react-dom/client";
3738

@@ -163,6 +164,10 @@ async function initWave(initOpts: WaveInitOpts) {
163164
await loadBadges();
164165
initGlobalWaveEventSubs(initOpts);
165166
subscribeToConnEvents();
167+
if (isMacOS()) {
168+
const macOSVersion = await RpcApi.MacOSVersionCommand(TabRpcClient);
169+
setMacOSVersion(macOSVersion);
170+
}
166171

167172
// ensures client/window/workspace are loaded into the cache before rendering
168173
try {

pkg/wshrpc/wshclient/wshclient.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -615,6 +615,12 @@ func ListAllEditableAppsCommand(w *wshutil.WshRpc, opts *wshrpc.RpcOpts) ([]wshr
615615
return resp, err
616616
}
617617

618+
// command "macosversion", wshserver.MacOSVersionCommand
619+
func MacOSVersionCommand(w *wshutil.WshRpc, opts *wshrpc.RpcOpts) (string, error) {
620+
resp, err := sendRpcRequestCallHelper[string](w, "macosversion", nil, opts)
621+
return resp, err
622+
}
623+
618624
// command "makedraftfromlocal", wshserver.MakeDraftFromLocalCommand
619625
func MakeDraftFromLocalCommand(w *wshutil.WshRpc, data wshrpc.CommandMakeDraftFromLocalData, opts *wshrpc.RpcOpts) (*wshrpc.CommandMakeDraftFromLocalRtnData, error) {
620626
resp, err := sendRpcRequestCallHelper[*wshrpc.CommandMakeDraftFromLocalRtnData](w, "makedraftfromlocal", data, opts)

pkg/wshrpc/wshrpctypes.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ type WshRpcInterface interface {
8383
DebugTermCommand(ctx context.Context, data CommandDebugTermData) (*CommandDebugTermRtnData, error)
8484
BlocksListCommand(ctx context.Context, data BlocksListRequest) ([]BlocksListEntry, error)
8585
WaveInfoCommand(ctx context.Context) (*WaveInfoData, error)
86+
MacOSVersionCommand(ctx context.Context) (string, error)
8687
WshActivityCommand(ct context.Context, data map[string]int) error
8788
ActivityCommand(ctx context.Context, data ActivityUpdate) error
8889
RecordTEventCommand(ctx context.Context, data telemetrydata.TEvent) error

pkg/wshrpc/wshserver/wshserver.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -878,6 +878,10 @@ func (ws *WshServer) WaveInfoCommand(ctx context.Context) (*wshrpc.WaveInfoData,
878878
}, nil
879879
}
880880

881+
func (ws *WshServer) MacOSVersionCommand(ctx context.Context) (string, error) {
882+
return wavebase.ClientMacOSVersion(), nil
883+
}
884+
881885
// BlocksListCommand returns every block visible in the requested
882886
// scope (current workspace by default).
883887
func (ws *WshServer) BlocksListCommand(

0 commit comments

Comments
 (0)