Skip to content

Commit 5abaaa5

Browse files
feat: display current git branch in MoreDrawer header
1 parent afd2c18 commit 5abaaa5

1 file changed

Lines changed: 33 additions & 13 deletions

File tree

frontend/src/components/navigation/MoreDrawer.tsx

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
import { useNavigate, useLocation } from 'react-router-dom'
1+
import { useNavigate, useLocation, useParams } from 'react-router-dom'
22
import { useState } from 'react'
3-
import { ChevronDown, ChevronRight, Command as CommandIcon, FileText, X } from 'lucide-react'
3+
import { ChevronDown, ChevronRight, Command as CommandIcon, FileText, X, GitBranch } from 'lucide-react'
44
import { useAuth } from '@/hooks/useAuth'
55
import { useServerHealth } from '@/hooks/useServerHealth'
66
import { useMemoryPluginStatus } from '@/hooks/useMemoryPluginStatus'
77
import { useCommands } from '@/hooks/useCommands'
88
import { useUIState } from '@/stores/uiStateStore'
9+
import { useQuery } from '@tanstack/react-query'
10+
import { getRepo } from '@/api/repos'
911
import { OPENCODE_API_ENDPOINT } from '@/config'
1012
import { SideDrawer, SideDrawerContent } from '@/components/ui/side-drawer'
1113
import { FileBrowserSheet } from '@/components/file-browser/FileBrowserSheet'
@@ -22,6 +24,8 @@ interface MoreDrawerProps {
2224
export function MoreDrawer({ isOpen, onClose }: MoreDrawerProps) {
2325
const navigate = useNavigate()
2426
const location = useLocation()
27+
const { id } = useParams<{ id: string }>()
28+
const repoId = id ? Number(id) : null
2529
const [commandsOpen, setCommandsOpen] = useState(false)
2630
const [mentionFileBrowserOpen, setMentionFileBrowserOpen] = useState(false)
2731
const { logout } = useAuth()
@@ -33,6 +37,14 @@ export function MoreDrawer({ isOpen, onClose }: MoreDrawerProps) {
3337
const selectPromptCommand = useUIState((state) => state.selectPromptCommand)
3438
const selectPromptFile = useUIState((state) => state.selectPromptFile)
3539

40+
const { data: repo } = useQuery({
41+
queryKey: ['repo', repoId],
42+
queryFn: () => repoId ? getRepo(repoId) : null,
43+
enabled: !!repoId,
44+
})
45+
46+
const currentBranch = repo?.currentBranch || repo?.branch
47+
3648
const handleSettingsClick = () => {
3749
const newParams = new URLSearchParams(location.search)
3850
newParams.delete('mobileTab')
@@ -95,18 +107,26 @@ export function MoreDrawer({ isOpen, onClose }: MoreDrawerProps) {
95107

96108
return (
97109
<SideDrawer isOpen={isOpen} onClose={onClose} side="right" ariaLabel="More" widthClass="w-screen sm:w-[min(90vw,420px)]">
98-
<div className="flex flex-shrink-0 items-center justify-between gap-3 border-b border-border bg-background px-4 py-1.5">
99-
{versionLabel && (
100-
<span className="truncate text-xs leading-tight text-muted-foreground">{versionLabel}</span>
110+
<div className="flex flex-col flex-shrink-0 border-b border-border bg-background px-4 py-1.5">
111+
<div className="flex items-center justify-between gap-3 mb-2">
112+
{versionLabel && (
113+
<span className="truncate text-xs leading-tight text-muted-foreground">{versionLabel}</span>
114+
)}
115+
<button
116+
type="button"
117+
onClick={onClose}
118+
className="shrink-0 rounded-sm p-2 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
119+
aria-label="Close"
120+
>
121+
<X className="h-5 w-5" />
122+
</button>
123+
</div>
124+
{currentBranch && (
125+
<div className="flex items-center gap-2 text-xs text-muted-foreground">
126+
<GitBranch className="h-3.5 w-3.5" />
127+
<span>{currentBranch}</span>
128+
</div>
101129
)}
102-
<button
103-
type="button"
104-
onClick={onClose}
105-
className="shrink-0 rounded-sm p-2 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
106-
aria-label="Close"
107-
>
108-
<X className="h-5 w-5" />
109-
</button>
110130
</div>
111131
<SideDrawerContent className="flex flex-col gap-1">
112132
{isSessionDetail && (

0 commit comments

Comments
 (0)