From 9e52f110e2121908465d97c4b77a122009bf0d92 Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Mon, 29 Jun 2026 23:05:17 -0700 Subject: [PATCH] Use native glass header for terminal route --- .../terminal/ThreadTerminalRouteScreen.tsx | 118 ++++++++++++------ .../src/lib/native-scroll-edge-effect.test.ts | 6 +- 2 files changed, 85 insertions(+), 39 deletions(-) diff --git a/apps/mobile/src/features/terminal/ThreadTerminalRouteScreen.tsx b/apps/mobile/src/features/terminal/ThreadTerminalRouteScreen.tsx index 8e9a47a58b..387c2afe3e 100644 --- a/apps/mobile/src/features/terminal/ThreadTerminalRouteScreen.tsx +++ b/apps/mobile/src/features/terminal/ThreadTerminalRouteScreen.tsx @@ -3,7 +3,7 @@ import { type KnownTerminalSession } from "@t3tools/client-runtime/state/termina import { SymbolView } from "expo-symbols"; import { Stack, useLocalSearchParams, useRouter } from "expo-router"; import { useCallback, useEffect, useMemo, useRef, useState } from "react"; -import { Pressable, Text as RNText, View, useColorScheme } from "react-native"; +import { Platform, Pressable, Text as RNText, View, useColorScheme } from "react-native"; import { KeyboardController, KeyboardEvents, @@ -25,6 +25,7 @@ import { terminalEnvironment } from "../../state/terminal"; import { useAtomCommand } from "../../state/use-atom-command"; import { useWorkspaceState } from "../../state/workspace"; import { buildThreadTerminalNavigation } from "../../lib/routes"; +import { nativeTopScrollEdgeEffect } from "../../lib/native-scroll-edge-effect"; import { MOBILE_TYPOGRAPHY } from "../../lib/typography"; import { useAttachedTerminalSession, @@ -72,6 +73,7 @@ import { const DEFAULT_TERMINAL_COLS = 80; const DEFAULT_TERMINAL_ROWS = 24; const TERMINAL_ACCESSORY_HEIGHT = 52; +const TOP_SCROLL_EDGE_EFFECT = nativeTopScrollEdgeEffect(Platform.OS, Platform.Version); type PendingModifier = "ctrl" | "meta"; type HostPlatform = "mac" | "linux" | "windows" | "unknown"; @@ -86,6 +88,47 @@ type TerminalToolbarAction = readonly modifier: PendingModifier; }; +function TerminalHeaderTitle(props: { + readonly topLine: string; + readonly bottomLine: string; + readonly foreground: string; + readonly mutedForeground: string; +}) { + return ( + + + {props.topLine} + + + {props.bottomLine} + + + ); +} + function firstRouteParam(value: string | string[] | undefined): string | null { if (Array.isArray(value)) { return value[0] ?? null; @@ -404,6 +447,7 @@ export function ThreadTerminalRouteScreen() { ); const terminalTheme = getPierreTerminalTheme(appearanceScheme); + const usesNativeHeaderGlass = Platform.OS === "ios"; const pendingModifier = pendingModifierState.terminalId === terminalId ? pendingModifierState.value : null; const headerTitle = useMemo(() => { @@ -422,6 +466,22 @@ export function ThreadTerminalRouteScreen() { selectedThreadProject?.title, selectedThreadProject?.workspaceRoot, ]); + const renderTerminalHeaderTitle = useCallback( + () => ( + + ), + [ + headerTitle.bottomLine, + headerTitle.topLine, + terminalTheme.foreground, + terminalTheme.mutedForeground, + ], + ); const terminalToolbarActions = useMemo>(() => { const modifierActions: ReadonlyArray = hostPlatform === "mac" @@ -903,44 +963,30 @@ export function ThreadTerminalRouteScreen() { headerShown: true, headerBackButtonDisplayMode: "minimal", headerBackTitle: "", + headerTransparent: usesNativeHeaderGlass, headerShadowVisible: false, - headerStyle: { backgroundColor: terminalTheme.background }, + headerStyle: { + backgroundColor: usesNativeHeaderGlass ? "transparent" : terminalTheme.background, + }, headerTintColor: terminalTheme.foreground, headerTitleAlign: "center", - title: "", - headerTitle: () => ( - - - {headerTitle.topLine} - - - {headerTitle.bottomLine} - - - ), + headerTitle: usesNativeHeaderGlass ? headerTitle.topLine : renderTerminalHeaderTitle, + headerTitleStyle: usesNativeHeaderGlass + ? { + fontSize: 17, + fontWeight: "800", + } + : undefined, + scrollEdgeEffects: usesNativeHeaderGlass + ? { + top: TOP_SCROLL_EDGE_EFFECT, + bottom: "hidden", + left: "hidden", + right: "hidden", + } + : undefined, + title: headerTitle.topLine, + unstable_navigationItemStyle: usesNativeHeaderGlass ? "editor" : undefined, }} /> diff --git a/apps/mobile/src/lib/native-scroll-edge-effect.test.ts b/apps/mobile/src/lib/native-scroll-edge-effect.test.ts index 953ea5213d..e2872a67c5 100644 --- a/apps/mobile/src/lib/native-scroll-edge-effect.test.ts +++ b/apps/mobile/src/lib/native-scroll-edge-effect.test.ts @@ -7,9 +7,9 @@ describe("nativeTopScrollEdgeEffect", () => { expect(nativeTopScrollEdgeEffect("ios", "26.5")).toBe("automatic"); }); - it("uses the native hard treatment on iOS 27 and later", () => { - expect(nativeTopScrollEdgeEffect("ios", "27.0")).toBe("hard"); - expect(nativeTopScrollEdgeEffect("ios", 28)).toBe("hard"); + it("uses the softer native treatment on iOS 27 and later", () => { + expect(nativeTopScrollEdgeEffect("ios", "27.0")).toBe("soft"); + expect(nativeTopScrollEdgeEffect("ios", 28)).toBe("soft"); }); it("does not apply the iOS workaround to other platforms", () => {