From 9c0b5616fecec64f4bb5db8038e8ac6a254c1f1e Mon Sep 17 00:00:00 2001 From: Mohamed Boudra Date: Tue, 14 Apr 2026 11:34:50 +0700 Subject: [PATCH] Refine compact workspace header layout --- .../app/src/components/branch-switcher.tsx | 8 ++- .../screens/workspace/workspace-screen.tsx | 68 +++++++++++++++---- 2 files changed, 62 insertions(+), 14 deletions(-) diff --git a/packages/app/src/components/branch-switcher.tsx b/packages/app/src/components/branch-switcher.tsx index 432849389..f9ce26bf9 100644 --- a/packages/app/src/components/branch-switcher.tsx +++ b/packages/app/src/components/branch-switcher.tsx @@ -4,6 +4,7 @@ import { useQueryClient } from "@tanstack/react-query"; import { ChevronDown, GitBranch } from "lucide-react-native"; import { StyleSheet, useUnistyles } from "react-native-unistyles"; import { Combobox, ComboboxItem, type ComboboxOption } from "@/components/ui/combobox"; +import { useIsCompactFormFactor } from "@/constants/layout"; import { useHostRuntimeClient, useHostRuntimeIsConnected } from "@/runtime/host-runtime"; import { useToast } from "@/contexts/toast-context"; import { useBranchSwitcher } from "@/hooks/use-branch-switcher"; @@ -24,6 +25,7 @@ export function BranchSwitcher({ isGitCheckout, }: BranchSwitcherProps) { const { theme } = useUnistyles(); + const isCompact = useIsCompactFormFactor(); const anchorRef = useRef(null); const client = useHostRuntimeClient(serverId); const isConnected = useHostRuntimeIsConnected(serverId); @@ -65,7 +67,7 @@ export function BranchSwitcher({ {title} - + {!isCompact ? : null} ({ flexDirection: "row", alignItems: "center", gap: theme.spacing[1], + marginLeft: { + xs: -theme.spacing[2], + md: 0, + }, paddingVertical: theme.spacing[1], paddingHorizontal: theme.spacing[2], borderRadius: theme.borderRadius.md, diff --git a/packages/app/src/screens/workspace/workspace-screen.tsx b/packages/app/src/screens/workspace/workspace-screen.tsx index c16090e9f..cb8745ecb 100644 --- a/packages/app/src/screens/workspace/workspace-screen.tsx +++ b/packages/app/src/screens/workspace/workspace-screen.tsx @@ -141,6 +141,18 @@ function decodeSegment(value: string): string { } } +function areHeaderLabelsEquivalent( + a: string | null | undefined, + b: string | null | undefined, +): boolean { + const normalizedA = trimNonEmpty(a)?.toLocaleLowerCase(); + const normalizedB = trimNonEmpty(b)?.toLocaleLowerCase(); + if (!normalizedA || !normalizedB) { + return false; + } + return normalizedA === normalizedB; +} + function getFallbackTabOptionLabel(tab: WorkspaceTabDescriptor): string { if (tab.target.kind === "draft") { return "New Agent"; @@ -747,6 +759,12 @@ function WorkspaceScreenContent({ serverId, workspaceId }: WorkspaceScreenProps) ? resolveWorkspaceHeader({ workspace: workspaceDescriptor }) : null; const isWorkspaceHeaderLoading = workspaceHeader === null; + const workspaceHeaderTitle = workspaceHeader?.title ?? ""; + const workspaceHeaderSubtitle = workspaceHeader?.subtitle ?? ""; + const shouldShowWorkspaceHeaderSubtitle = !areHeaderLabelsEquivalent( + workspaceHeaderTitle, + workspaceHeaderSubtitle, + ); const isGitCheckout = checkoutQuery.data?.isGit ?? false; const currentBranchName = @@ -1949,27 +1967,29 @@ function WorkspaceScreenContent({ serverId, workspaceId }: WorkspaceScreenProps) {isWorkspaceHeaderLoading ? ( - <> + - + ) : ( - <> + - - {workspaceHeader.subtitle} - - + {shouldShowWorkspaceHeaderSubtitle ? ( + + {workspaceHeaderSubtitle} + + ) : null} + )} ({ flexShrink: 1, }, headerTitleContainer: { + flex: 1, flexShrink: 1, minWidth: 0, flexDirection: "row", alignItems: "center", gap: theme.spacing[2], }, + headerTitleTextGroup: { + minWidth: 0, + flexShrink: 1, + flexGrow: 1, + flexDirection: { + xs: "column", + md: "row", + }, + alignItems: { + xs: "flex-start", + md: "center", + }, + justifyContent: "center", + gap: { + xs: 0, + md: theme.spacing[2], + }, + }, headerProjectTitle: { color: theme.colors.foregroundMuted, - fontSize: theme.fontSize.base, + fontSize: { + xs: theme.fontSize.sm, + md: theme.fontSize.base, + }, flexShrink: 1, }, headerTitleSkeleton: {