@@ -6,13 +6,16 @@ import {
66} from "@t3tools/contracts" ;
77import { memo } from "react" ;
88import GitActionsControl from "../GitActionsControl" ;
9- import { DiffIcon , TerminalSquareIcon } from "lucide-react" ;
9+ import { DiffIcon , EllipsisIcon , TerminalSquareIcon } from "lucide-react" ;
1010import { Badge } from "../ui/badge" ;
1111import { Tooltip , TooltipPopup , TooltipTrigger } from "../ui/tooltip" ;
1212import ProjectScriptsControl , { type NewProjectScriptInput } from "../ProjectScriptsControl" ;
1313import { Toggle } from "../ui/toggle" ;
1414import { SidebarTrigger } from "../ui/sidebar" ;
1515import { OpenInPicker } from "./OpenInPicker" ;
16+ import { useIsMobile } from "~/hooks/useMediaQuery" ;
17+ import { Button } from "../ui/button" ;
18+ import { Popover , PopoverPopup , PopoverTrigger } from "../ui/popover" ;
1619
1720interface ChatHeaderProps {
1821 activeThreadId : ThreadId ;
@@ -61,6 +64,8 @@ export const ChatHeader = memo(function ChatHeader({
6164 onToggleTerminal,
6265 onToggleDiff,
6366} : ChatHeaderProps ) {
67+ const isMobile = useIsMobile ( ) ;
68+
6469 return (
6570 < div className = "@container/header-actions flex min-w-0 flex-1 items-center gap-2" >
6671 < div className = "flex min-w-0 flex-1 items-center gap-2 overflow-hidden sm:gap-3" >
@@ -82,75 +87,149 @@ export const ChatHeader = memo(function ChatHeader({
8287 </ Badge >
8388 ) }
8489 </ div >
85- < div className = "flex shrink-0 items-center justify-end gap-2 @3xl/header-actions:gap-3" >
86- { activeProjectScripts && (
87- < ProjectScriptsControl
88- scripts = { activeProjectScripts }
89- keybindings = { keybindings }
90- preferredScriptId = { preferredScriptId }
91- onRunScript = { onRunProjectScript }
92- onAddScript = { onAddProjectScript }
93- onUpdateScript = { onUpdateProjectScript }
94- onDeleteScript = { onDeleteProjectScript }
95- />
96- ) }
97- { activeProjectName && (
98- < OpenInPicker
99- keybindings = { keybindings }
100- availableEditors = { availableEditors }
101- openInCwd = { openInCwd }
102- />
103- ) }
104- { activeProjectName && < GitActionsControl gitCwd = { gitCwd } activeThreadId = { activeThreadId } /> }
105- < Tooltip >
106- < TooltipTrigger
107- render = {
108- < Toggle
109- className = "shrink-0"
110- pressed = { terminalOpen }
111- onPressedChange = { onToggleTerminal }
112- aria-label = "Toggle terminal drawer"
113- variant = "outline"
114- size = "xs"
115- disabled = { ! terminalAvailable }
116- >
117- < TerminalSquareIcon className = "size-3" />
118- </ Toggle >
119- }
120- />
121- < TooltipPopup side = "bottom" >
122- { ! terminalAvailable
123- ? "Terminal is unavailable until this thread has an active project."
124- : terminalToggleShortcutLabel
125- ? `Toggle terminal drawer (${ terminalToggleShortcutLabel } )`
126- : "Toggle terminal drawer" }
127- </ TooltipPopup >
128- </ Tooltip >
129- < Tooltip >
130- < TooltipTrigger
131- render = {
132- < Toggle
133- className = "shrink-0"
134- pressed = { diffOpen }
135- onPressedChange = { onToggleDiff }
136- aria-label = "Toggle diff panel"
137- variant = "outline"
138- size = "xs"
139- disabled = { ! isGitRepo }
140- >
141- < DiffIcon className = "size-3" />
142- </ Toggle >
143- }
144- />
145- < TooltipPopup side = "bottom" >
146- { ! isGitRepo
147- ? "Diff panel is unavailable because this project is not a git repository."
148- : diffToggleShortcutLabel
149- ? `Toggle diff panel (${ diffToggleShortcutLabel } )`
150- : "Toggle diff panel" }
151- </ TooltipPopup >
152- </ Tooltip >
153- </ div >
90+ { isMobile ? (
91+ < Popover >
92+ < PopoverTrigger
93+ render = { < Button size = "icon-xs" variant = "outline" aria-label = "More actions" /> }
94+ >
95+ < EllipsisIcon aria-hidden = "true" className = "size-4" />
96+ </ PopoverTrigger >
97+ < PopoverPopup side = "bottom" align = "end" sideOffset = { 4 } className = "w-auto" >
98+ < div className = "flex flex-col gap-3" >
99+ < div className = "flex items-center justify-between gap-4" >
100+ < span className = "text-sm text-foreground" > Terminal</ span >
101+ < Toggle
102+ className = "shrink-0"
103+ pressed = { terminalOpen }
104+ onPressedChange = { onToggleTerminal }
105+ aria-label = "Toggle terminal drawer"
106+ variant = "outline"
107+ size = "xs"
108+ disabled = { ! terminalAvailable }
109+ >
110+ < TerminalSquareIcon className = "size-3" />
111+ </ Toggle >
112+ </ div >
113+ < div className = "flex items-center justify-between gap-4" >
114+ < span className = "text-sm text-foreground" > Diff</ span >
115+ < Toggle
116+ className = "shrink-0"
117+ pressed = { diffOpen }
118+ onPressedChange = { onToggleDiff }
119+ aria-label = "Toggle diff panel"
120+ variant = "outline"
121+ size = "xs"
122+ disabled = { ! isGitRepo }
123+ >
124+ < DiffIcon className = "size-3" />
125+ </ Toggle >
126+ </ div >
127+ { activeProjectName && (
128+ < >
129+ < div className = "h-px bg-border" />
130+ < div className = "flex items-center gap-2" >
131+ < OpenInPicker
132+ keybindings = { keybindings }
133+ availableEditors = { availableEditors }
134+ openInCwd = { openInCwd }
135+ />
136+ </ div >
137+ </ >
138+ ) }
139+ { activeProjectName && (
140+ < div className = "flex items-center gap-2" >
141+ < GitActionsControl gitCwd = { gitCwd } activeThreadId = { activeThreadId } />
142+ </ div >
143+ ) }
144+ { activeProjectScripts && (
145+ < div className = "flex items-center gap-2" >
146+ < ProjectScriptsControl
147+ scripts = { activeProjectScripts }
148+ keybindings = { keybindings }
149+ preferredScriptId = { preferredScriptId }
150+ onRunScript = { onRunProjectScript }
151+ onAddScript = { onAddProjectScript }
152+ onUpdateScript = { onUpdateProjectScript }
153+ onDeleteScript = { onDeleteProjectScript }
154+ />
155+ </ div >
156+ ) }
157+ </ div >
158+ </ PopoverPopup >
159+ </ Popover >
160+ ) : (
161+ < div className = "flex shrink-0 items-center justify-end gap-2 @3xl/header-actions:gap-3" >
162+ { activeProjectScripts && (
163+ < ProjectScriptsControl
164+ scripts = { activeProjectScripts }
165+ keybindings = { keybindings }
166+ preferredScriptId = { preferredScriptId }
167+ onRunScript = { onRunProjectScript }
168+ onAddScript = { onAddProjectScript }
169+ onUpdateScript = { onUpdateProjectScript }
170+ onDeleteScript = { onDeleteProjectScript }
171+ />
172+ ) }
173+ { activeProjectName && (
174+ < OpenInPicker
175+ keybindings = { keybindings }
176+ availableEditors = { availableEditors }
177+ openInCwd = { openInCwd }
178+ />
179+ ) }
180+ { activeProjectName && (
181+ < GitActionsControl gitCwd = { gitCwd } activeThreadId = { activeThreadId } />
182+ ) }
183+ < Tooltip >
184+ < TooltipTrigger
185+ render = {
186+ < Toggle
187+ className = "shrink-0"
188+ pressed = { terminalOpen }
189+ onPressedChange = { onToggleTerminal }
190+ aria-label = "Toggle terminal drawer"
191+ variant = "outline"
192+ size = "xs"
193+ disabled = { ! terminalAvailable }
194+ >
195+ < TerminalSquareIcon className = "size-3" />
196+ </ Toggle >
197+ }
198+ />
199+ < TooltipPopup side = "bottom" >
200+ { ! terminalAvailable
201+ ? "Terminal is unavailable until this thread has an active project."
202+ : terminalToggleShortcutLabel
203+ ? `Toggle terminal drawer (${ terminalToggleShortcutLabel } )`
204+ : "Toggle terminal drawer" }
205+ </ TooltipPopup >
206+ </ Tooltip >
207+ < Tooltip >
208+ < TooltipTrigger
209+ render = {
210+ < Toggle
211+ className = "shrink-0"
212+ pressed = { diffOpen }
213+ onPressedChange = { onToggleDiff }
214+ aria-label = "Toggle diff panel"
215+ variant = "outline"
216+ size = "xs"
217+ disabled = { ! isGitRepo }
218+ >
219+ < DiffIcon className = "size-3" />
220+ </ Toggle >
221+ }
222+ />
223+ < TooltipPopup side = "bottom" >
224+ { ! isGitRepo
225+ ? "Diff panel is unavailable because this project is not a git repository."
226+ : diffToggleShortcutLabel
227+ ? `Toggle diff panel (${ diffToggleShortcutLabel } )`
228+ : "Toggle diff panel" }
229+ </ TooltipPopup >
230+ </ Tooltip >
231+ </ div >
232+ ) }
154233 </ div >
155234 ) ;
156235} ) ;
0 commit comments