TypeScript
fix(mobile): add close controls to tablet files and terminal (#11115)
Julius Marminge47dbb06c3b17
diff --git a/apps/mobile/src/features/files/thread-file-navigator-pane.tsx b/apps/mobile/src/features/files/thread-file-navigator-pane.tsxindex 33b99dd8e8c..50c92ed1f59 100644--- a/apps/mobile/src/features/files/thread-file-navigator-pane.tsx+++ b/apps/mobile/src/features/files/thread-file-navigator-pane.tsx@@ -18,6 +18,7 @@ import { useEnvironmentQuery } from "../../state/query";import { useAppearancePreferences } from "../settings/appearance/AppearancePreferencesProvider";import { FileTreeBrowser } from "./FileTreeBrowser";import { preloadWorkspaceFileContents } from "./preload-workspace-file";+import { useAdaptiveWorkspaceLayout } from "../layout/AdaptiveWorkspaceLayout";export function ThreadFileNavigatorPane(props: {readonly cwd: string;@@ -28,6 +29,7 @@ export function ThreadFileNavigatorPane(props: {readonly onSelectFile: (path: string) => void;}) {const [searchQuery, setSearchQuery] = useState("");+ const { toggleAuxiliaryPane } = useAdaptiveWorkspaceLayout();const { themeAppearance: highlightTheme } = useAppearancePreferences();const theme = useUniwindTheme();const foregroundColor = theme["--color-foreground"];@@ -64,8 +66,18 @@ export function ThreadFileNavigatorPane(props: {type: "button" as const,width: 44,},+ {+ accessibilityLabel: "Close files",+ icon: { name: "xmark", type: "sfSymbol" as const },+ identifier: "thread-file-navigator-close",+ onPress: toggleAuxiliaryPane,+ sharesBackground: false,+ tintColor: foregroundColor,+ type: "button" as const,+ width: 44,+ },] as ComponentProps<typeof ScreenStackHeaderConfig>["headerRightBarButtonItems"],- [entriesQuery.refresh, foregroundColor],+ [entriesQuery.refresh, foregroundColor, toggleAuxiliaryPane],);const fileTree = (@@ -159,6 +171,15 @@ export function ThreadFileNavigatorPane(props: {type="monochrome"/></Pressable>+ <Pressable+ accessibilityRole="button"+ accessibilityLabel="Close files"+ hitSlop={8}+ className="h-8 w-8 items-center justify-center rounded-full active:bg-subtle"+ onPress={toggleAuxiliaryPane}+ >+ <SymbolView name="xmark" size={14} tintColorClassName="accent-icon-muted" />+ </Pressable></View><View className="flex-row items-center gap-2 border-t border-border px-3 py-2"><SymbolViewdiff --git a/apps/mobile/src/features/terminal/ThreadTerminalRouteScreen.tsx b/apps/mobile/src/features/terminal/ThreadTerminalRouteScreen.tsxindex bc2e6fc3c64..6829a88cef7 100644--- a/apps/mobile/src/features/terminal/ThreadTerminalRouteScreen.tsx+++ b/apps/mobile/src/features/terminal/ThreadTerminalRouteScreen.tsx@@ -850,6 +850,19 @@ export function ThreadTerminalRouteScreen(props: ThreadTerminalRouteScreenProps)[navigation, selectedThread, terminalId],);+ const handleCloseTerminal = useCallback(() => {+ if (navigation.canGoBack()) {+ navigation.goBack();+ return;+ }+ navigation.dispatch(+ StackActions.replace("Thread", {+ environmentId: params.environmentId,+ threadId: params.threadId,+ }),+ );+ }, [navigation, params.environmentId, params.threadId]);+const navigateAwayAfterExit = useCallback(() => {// With other shells still live, fall through to the previous one instead// of dropping the user back on the thread.@@ -1143,7 +1156,7 @@ export function ThreadTerminalRouteScreen(props: ThreadTerminalRouteScreenProps)<AndroidScreenHeadertitle="Terminal"subtitle={headerSubtitle}- onBack={navigation.canGoBack() ? () => navigation.goBack() : undefined}+ onBack={handleCloseTerminal}trailing={<>{layout.usesSplitView ? (@@ -1179,6 +1192,12 @@ export function ThreadTerminalRouteScreen(props: ThreadTerminalRouteScreenProps){layout.usesSplitView ? (<NativeHeaderToolbar placement="left">+ <NativeHeaderToolbar.Button+ accessibilityLabel="Close terminal"+ icon="xmark"+ onPress={handleCloseTerminal}+ separateBackground+ /><NativeHeaderToolbar.ButtonaccessibilityLabel={panes.primarySidebarVisible ? "Maximize terminal" : "Show threads"}icon={