@@ -119,6 +119,7 @@ import {
119119 setupProjectScript ,
120120} from "~/projectScripts" ;
121121import { Toggle } from "./ui/toggle" ;
122+ import { SidebarTrigger } from "./ui/sidebar" ;
122123
123124function formatMessageMeta ( createdAt : string , duration : string | null ) : string {
124125 if ( ! duration ) return formatTimestamp ( createdAt ) ;
@@ -433,6 +434,12 @@ export default function ChatView({ threadId }: ChatViewProps) {
433434 ) ;
434435 const phase = derivePhase ( activeThread ?. session ?? null ) ;
435436 const isWorking = phase === "running" || isSending || isConnecting || isRevertingCheckpoint ;
437+ const canSend =
438+ Boolean ( api ) &&
439+ Boolean ( activeThread ) &&
440+ ! isSending &&
441+ ! isConnecting &&
442+ ( prompt . trim ( ) . length > 0 || composerImages . length > 0 ) ;
436443 const nowIso = new Date ( nowTick ) . toISOString ( ) ;
437444 const workLogEntries = useMemo (
438445 ( ) => deriveWorkLogEntries ( activeThread ?. events ?? [ ] , undefined ) ,
@@ -1583,7 +1590,12 @@ export default function ChatView({ threadId }: ChatViewProps) {
15831590 ) ;
15841591
15851592 const ensureSession = useCallback (
1586- async ( cwdOverride ?: string ) : Promise < EnsuredSessionInfo | null > => {
1593+ async (
1594+ cwdOverride ?: string ,
1595+ options ?: {
1596+ silent ?: boolean ;
1597+ } ,
1598+ ) : Promise < EnsuredSessionInfo | null > => {
15871599 if ( ! api || ! activeThread || ! activeProject ) return null ;
15881600 if ( activeThread . session && activeThread . session . status !== "closed" ) {
15891601 const sessionThreadId = activeThread . session . threadId ?? null ;
@@ -1606,7 +1618,10 @@ export default function ChatView({ threadId }: ChatViewProps) {
16061618 }
16071619
16081620 const priorCodexThreadId = activeThread . codexThreadId ;
1609- setIsConnecting ( true ) ;
1621+ const shouldShowConnectingState = ! options ?. silent ;
1622+ if ( shouldShowConnectingState ) {
1623+ setIsConnecting ( true ) ;
1624+ }
16101625 try {
16111626 const session = await api . providers . startSession ( {
16121627 provider : "codex" ,
@@ -1649,7 +1664,9 @@ export default function ChatView({ threadId }: ChatViewProps) {
16491664 } ) ;
16501665 return null ;
16511666 } finally {
1652- setIsConnecting ( false ) ;
1667+ if ( shouldShowConnectingState ) {
1668+ setIsConnecting ( false ) ;
1669+ }
16531670 }
16541671 } ,
16551672 [
@@ -1679,7 +1696,7 @@ export default function ChatView({ threadId }: ChatViewProps) {
16791696 }
16801697 checkpointHydrationSessionRequestRef . current . add ( requestKey ) ;
16811698 setThreadError ( activeThreadId , null ) ;
1682- void ensureSession ( ) . then (
1699+ void ensureSession ( undefined , { silent : true } ) . then (
16831700 ( ) => {
16841701 checkpointHydrationSessionRequestRef . current . delete ( requestKey ) ;
16851702 } ,
@@ -1904,6 +1921,24 @@ export default function ChatView({ threadId }: ChatViewProps) {
19041921 }
19051922 } ;
19061923
1924+ const triggerSend = ( ) => {
1925+ if ( ! canSend ) return ;
1926+ const form = textareaRef . current ?. form ;
1927+ if ( form ) {
1928+ if ( typeof form . requestSubmit === "function" ) {
1929+ form . requestSubmit ( ) ;
1930+ } else {
1931+ const submitEvent = new Event ( "submit" , { bubbles : true , cancelable : true } ) ;
1932+ const dispatched = form . dispatchEvent ( submitEvent ) ;
1933+ if ( ! dispatched ) {
1934+ return ;
1935+ }
1936+ }
1937+ return ;
1938+ }
1939+ void onSend ( { preventDefault : ( ) => undefined } as FormEvent ) ;
1940+ } ;
1941+
19071942 const onInterrupt = async ( ) => {
19081943 if ( ! api || ! activeThread ?. session ) return ;
19091944 await api . providers . interruptTurn ( {
@@ -2047,7 +2082,7 @@ export default function ChatView({ threadId }: ChatViewProps) {
20472082
20482083 if ( e . key === "Enter" && ! e . shiftKey ) {
20492084 e . preventDefault ( ) ;
2050- void onSend ( e as unknown as FormEvent ) ;
2085+ triggerSend ( ) ;
20512086 }
20522087 } ;
20532088 const onToggleWorkGroup = useCallback ( ( groupId : string ) => {
@@ -2117,7 +2152,7 @@ export default function ChatView({ threadId }: ChatViewProps) {
21172152 < div className = "flex min-h-0 min-w-0 flex-1 flex-col bg-background" >
21182153 { /* Top bar */ }
21192154 < header
2120- className = { `flex items-center justify-between border-b border-border px-5 ${ isElectron ? "drag-region h-[52px]" : "py-3" } ` }
2155+ className = { `flex items-center justify-between border-b border-border px-3 sm:px- 5 ${ isElectron ? "drag-region h-[52px]" : "py-3" } ` }
21212156 >
21222157 < ChatHeader
21232158 activeThreadId = { activeThread . id }
@@ -2151,7 +2186,7 @@ export default function ChatView({ threadId }: ChatViewProps) {
21512186 { /* Messages */ }
21522187 < div
21532188 ref = { messagesScrollRef }
2154- className = "min-h-0 flex-1 overflow-y-auto px-5 py-4"
2189+ className = "min-h-0 flex-1 overflow-y-auto px-3 py-3 sm:px-5 sm: py-4"
21552190 onScroll = { onMessagesScroll }
21562191 >
21572192 < MessagesTimeline
@@ -2176,7 +2211,12 @@ export default function ChatView({ threadId }: ChatViewProps) {
21762211 </ div >
21772212
21782213 { /* Input bar */ }
2179- < div className = { cn ( "px-5 pt-2" , isGitRepo ? "pb-1" : "pb-4" ) } >
2214+ < div
2215+ className = { cn (
2216+ "px-3 pt-2 sm:px-5 max-sm:pb-[calc(0.5rem+env(safe-area-inset-bottom))]" ,
2217+ isGitRepo ? "pb-1" : "pb-4" ,
2218+ ) }
2219+ >
21802220 < form onSubmit = { onSend } className = "mx-auto max-w-3xl" >
21812221 < div
21822222 className = { `group rounded-[20px] border bg-card transition-colors duration-200 focus-within:border-ring ${
@@ -2275,8 +2315,8 @@ export default function ChatView({ threadId }: ChatViewProps) {
22752315 </ div >
22762316
22772317 { /* Bottom toolbar */ }
2278- < div className = "flex items-center justify-between px-3 pb-3" >
2279- < div className = "flex items-center gap-1" >
2318+ < div className = "flex items-center justify-end px-3 pb-3 sm:justify-between " >
2319+ < div className = "hidden items-center gap-1 sm:flex " >
22802320 { /* Model picker */ }
22812321 < ModelPicker model = { selectedModel } onModelChange = { onModelSelect } />
22822322
@@ -2317,7 +2357,7 @@ export default function ChatView({ threadId }: ChatViewProps) {
23172357 { phase === "running" ? (
23182358 < button
23192359 type = "button"
2320- className = "flex h-8 w-8 items-center justify-center rounded-full bg-rose-500/90 text-white transition-all duration-150 hover:bg-rose-500 hover:scale-105"
2360+ className = "relative z-10 flex h-10 w-10 touch-manipulation items-center justify-center rounded-full bg-rose-500/90 text-white transition-all duration-150 hover:bg-rose-500 pointer-events-auto sm:h-8 sm:w-8 sm: hover:scale-105"
23212361 onClick = { ( ) => void onInterrupt ( ) }
23222362 aria-label = "Stop generation"
23232363 >
@@ -2333,11 +2373,10 @@ export default function ChatView({ threadId }: ChatViewProps) {
23332373 </ button >
23342374 ) : (
23352375 < button
2336- type = "submit"
2337- className = "flex h-8 w-8 items-center justify-center rounded-full bg-primary/90 text-primary-foreground transition-all duration-150 hover:bg-primary hover:scale-105 disabled:opacity-30 disabled:hover:scale-100"
2338- disabled = {
2339- isSending || isConnecting || ( ! prompt . trim ( ) && composerImages . length === 0 )
2340- }
2376+ type = "button"
2377+ className = "relative z-10 flex h-10 w-10 touch-manipulation items-center justify-center rounded-full bg-primary/90 text-primary-foreground transition-all duration-150 hover:bg-primary pointer-events-auto disabled:opacity-30 disabled:hover:scale-100 sm:h-8 sm:w-8 sm:hover:scale-105"
2378+ disabled = { ! canSend }
2379+ onClick = { triggerSend }
23412380 aria-label = {
23422381 isConnecting ? "Connecting" : isSending ? "Sending" : "Send message"
23432382 }
@@ -2387,13 +2426,15 @@ export default function ChatView({ threadId }: ChatViewProps) {
23872426 </ div >
23882427
23892428 { isGitRepo && (
2390- < BranchToolbar
2391- threadId = { activeThread . id }
2392- envMode = { envMode }
2393- onEnvModeChange = { onEnvModeChange }
2394- envLocked = { envLocked }
2395- onComposerFocusRequest = { scheduleComposerFocus }
2396- />
2429+ < div className = "hidden sm:block" >
2430+ < BranchToolbar
2431+ threadId = { activeThread . id }
2432+ envMode = { envMode }
2433+ onEnvModeChange = { onEnvModeChange }
2434+ envLocked = { envLocked }
2435+ onComposerFocusRequest = { scheduleComposerFocus }
2436+ />
2437+ </ div >
23972438 ) }
23982439
23992440 { activeThread . terminalOpen && api && activeProject && (
@@ -2497,28 +2538,43 @@ const ChatHeader = memo(function ChatHeader({
24972538} : ChatHeaderProps ) {
24982539 return (
24992540 < >
2500- < div className = "flex min-w-0 flex-1 items-center gap-3" >
2501- < h2 className = "truncate text-sm font-medium text-foreground" title = { activeThreadTitle } >
2541+ < div className = "flex min-w-0 flex-1 items-center gap-2 sm:gap-3" >
2542+ < SidebarTrigger className = "size-8 md:hidden" />
2543+ < Separator orientation = "vertical" className = "md:hidden data-[orientation=vertical]:h-4" />
2544+ < h2
2545+ className = "truncate text-xs font-medium text-foreground sm:text-sm"
2546+ title = { activeThreadTitle }
2547+ >
25022548 { activeThreadTitle }
25032549 </ h2 >
2504- { activeProjectName && < Badge variant = "outline" > { activeProjectName } </ Badge > }
2550+ { activeProjectName && (
2551+ < Badge variant = "outline" className = "hidden sm:inline-flex" >
2552+ { activeProjectName }
2553+ </ Badge >
2554+ ) }
25052555 </ div >
2506- < div className = "shrink-0 flex items-center gap-3" >
2556+ < div className = "shrink-0 flex items-center gap-1.5 sm:gap- 3" >
25072557 { activeProjectScripts && (
2508- < ProjectScriptsControl
2509- scripts = { activeProjectScripts }
2510- keybindings = { keybindings }
2511- preferredScriptId = { preferredScriptId }
2512- onRunScript = { onRunProjectScript }
2513- onAddScript = { onAddProjectScript }
2514- onUpdateScript = { onUpdateProjectScript }
2515- />
2558+ < div className = "hidden md:block" >
2559+ < ProjectScriptsControl
2560+ scripts = { activeProjectScripts }
2561+ keybindings = { keybindings }
2562+ preferredScriptId = { preferredScriptId }
2563+ onRunScript = { onRunProjectScript }
2564+ onAddScript = { onAddProjectScript }
2565+ onUpdateScript = { onUpdateProjectScript }
2566+ />
2567+ </ div >
25162568 ) }
25172569 { activeProjectName && (
2518- < OpenInPicker keybindings = { keybindings } activeThreadId = { activeThreadId } />
2570+ < div className = "hidden md:block" >
2571+ < OpenInPicker keybindings = { keybindings } activeThreadId = { activeThreadId } />
2572+ </ div >
25192573 ) }
25202574 { activeProjectName && (
2521- < GitActionsControl api = { api } gitCwd = { gitCwd } activeThreadId = { activeThreadId } />
2575+ < div className = "hidden md:block" >
2576+ < GitActionsControl api = { api } gitCwd = { gitCwd } activeThreadId = { activeThreadId } />
2577+ </ div >
25222578 ) }
25232579 < Toggle
25242580 pressed = { diffOpen }
0 commit comments