80 lines
2.7 KiB
TypeScript
80 lines
2.7 KiB
TypeScript
import { Platform } from "react-native";
|
|
import { useUnistyles } from "react-native-unistyles";
|
|
import { isElectronRuntime, isElectronRuntimeMac } from "@/desktop/host";
|
|
|
|
export const FOOTER_HEIGHT = 75;
|
|
|
|
// Shared header inner height (excluding safe area insets and border)
|
|
// Used by both agent header (ScreenHeader) and explorer sidebar header
|
|
// This ensures both headers have the same visual height
|
|
export const HEADER_INNER_HEIGHT = 48;
|
|
export const HEADER_INNER_HEIGHT_MOBILE = 56;
|
|
export const WORKSPACE_SECONDARY_HEADER_HEIGHT = 36;
|
|
export const HEADER_TOP_PADDING_MOBILE = 8;
|
|
|
|
// Max width for chat content (stream view, input area, new agent form)
|
|
export const MAX_CONTENT_WIDTH = 820;
|
|
|
|
// Desktop app constants for macOS traffic light buttons
|
|
// These buttons (close/minimize/maximize) overlay the top-left corner
|
|
export const DESKTOP_TRAFFIC_LIGHT_WIDTH = 78;
|
|
export const DESKTOP_TRAFFIC_LIGHT_HEIGHT = 45;
|
|
|
|
// Windows/Linux window controls (minimize/maximize/close) — top-right
|
|
export const DESKTOP_WINDOW_CONTROLS_WIDTH = 140;
|
|
export const DESKTOP_WINDOW_CONTROLS_HEIGHT = 48;
|
|
|
|
// Check if running in the Electron desktop runtime (any OS)
|
|
function isElectronDesktopRuntime(): boolean {
|
|
if (Platform.OS !== "web") return false;
|
|
return isElectronRuntime();
|
|
}
|
|
|
|
// Check if running in the Electron desktop runtime on macOS
|
|
function isElectronDesktopRuntimeMac(): boolean {
|
|
if (Platform.OS !== "web") return false;
|
|
return isElectronRuntimeMac();
|
|
}
|
|
|
|
// Cached result - only cache true, keep checking if false (in case desktop globals load later)
|
|
let _isElectronRuntimeMacCached: boolean | null = null;
|
|
let _isElectronRuntimeCached: boolean | null = null;
|
|
|
|
export function getIsElectronRuntimeMac(): boolean {
|
|
if (_isElectronRuntimeMacCached === true) {
|
|
return true;
|
|
}
|
|
const result = isElectronDesktopRuntimeMac();
|
|
if (result) {
|
|
_isElectronRuntimeMacCached = true;
|
|
}
|
|
return result;
|
|
}
|
|
|
|
export function getIsElectronRuntime(): boolean {
|
|
if (_isElectronRuntimeCached === true) {
|
|
return true;
|
|
}
|
|
const result = isElectronDesktopRuntime();
|
|
if (result) {
|
|
_isElectronRuntimeCached = true;
|
|
}
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Reactive hook — re-renders the component when the breakpoint changes.
|
|
* Always use this instead of reading UnistylesRuntime.breakpoint directly.
|
|
*/
|
|
export function useIsCompactFormFactor(): boolean {
|
|
const { rt } = useUnistyles();
|
|
return rt.breakpoint === "xs" || rt.breakpoint === "sm";
|
|
}
|
|
|
|
// SplitContainer relies on dnd-kit and DOM-backed accessibility helpers.
|
|
// Keep that capability distinct from desktop-width layout so touch tablets
|
|
// can use the desktop shell without entering web-only code paths.
|
|
export function supportsDesktopPaneSplits(): boolean {
|
|
return Platform.OS === "web";
|
|
}
|