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