The best way to control Claude Code, Codex and more from any computer or phone
| 1 | import { useGT, useMessages } from "gt-react-native"; |
| 2 | |
| 3 | import { AppBar } from "../../components/ui/AppBar"; |
| 4 | import type { AppBarAction, AppBarMenu } from "../../components/ui/AppBar.types"; |
| 5 | import { |
| 6 | useAdaptiveWorkspaceLayout, |
| 7 | useWorkspacePaneState, |
| 8 | } from "../layout/AdaptiveWorkspaceLayout"; |
| 9 | import type { ThreadInspectorMode } from "./thread-inspector-navigation"; |
| 10 | import { useWorkspaceBackNavigation } from "../layout/workspace/useAndroidWorkspaceNavigation"; |
| 11 | import { |
| 12 | threadTerminalMenu, |
| 13 | useThreadGitMenuDefinition, |
| 14 | type ThreadGitControlsProps, |
| 15 | } from "./ThreadGitControls"; |
| 16 | |
| 17 | export function ThreadHeader(props: { |
| 18 | readonly title: string; |
| 19 | readonly subtitle: string; |
| 20 | readonly gitControls: ThreadGitControlsProps; |
| 21 | readonly onReturnToThread?: () => void; |
| 22 | readonly draft?: boolean; |
| 23 | readonly hasThreadCwd: boolean; |
| 24 | readonly inspectorMode: ThreadInspectorMode | null; |
| 25 | readonly onOpenFilesInspector: () => void; |
| 26 | }) { |
| 27 | const gt = useGT(); |
| 28 | const m = useMessages(); |
| 29 | const goBack = useWorkspaceBackNavigation(); |
| 30 | const { toggleAuxiliaryPane, startNewTask } = useAdaptiveWorkspaceLayout(); |
| 31 | const { panes } = useWorkspacePaneState(); |
| 32 | const gitMenu = useThreadGitMenuDefinition(props.gitControls); |
| 33 | const terminalMenu = threadTerminalMenu(props.gitControls, m); |
| 34 | const filesVisible = props.inspectorMode === "files" && panes.auxiliaryPaneVisible; |
| 35 | const actions: AppBarAction[] = props.hasThreadCwd |
| 36 | ? [ |
| 37 | { |
| 38 | accessibilityLabel: filesVisible ? gt("Close files") : gt("Open files"), |
| 39 | icon: "folder", |
| 40 | selected: filesVisible, |
| 41 | disabled: !props.gitControls.canOpenFiles, |
| 42 | separateBackground: false, |
| 43 | onPress: filesVisible ? toggleAuxiliaryPane : props.onOpenFilesInspector, |
| 44 | }, |
| 45 | ] |
| 46 | : []; |
| 47 | const menus = [gitMenu, terminalMenu].filter((menu): menu is AppBarMenu => menu !== null); |
| 48 | |
| 49 | return ( |
| 50 | <AppBar |
| 51 | title={props.title} |
| 52 | subtitle={props.subtitle} |
| 53 | onBackToList={goBack} |
| 54 | onCompose={props.draft ? undefined : startNewTask} |
| 55 | backInSplitView={ |
| 56 | props.onReturnToThread |
| 57 | ? { |
| 58 | accessibilityLabel: gt("Return to chat"), |
| 59 | icon: "chevron.left", |
| 60 | onPress: props.onReturnToThread, |
| 61 | } |
| 62 | : undefined |
| 63 | } |
| 64 | actions={actions} |
| 65 | menus={menus} |
| 66 | hideBottomBorder |
| 67 | /> |
| 68 | ); |
| 69 | } |