@@ -89,31 +89,21 @@ function handleComposerMenuKeyDown<T>(
8989 }
9090 return false ;
9191 }
92- const getIndex = ( ) => ( menu === "skill" ? state . skillMenuIndex : state . slashMenuIndex ) ;
93- const setIndex = ( index : number ) => {
94- if ( menu === "skill" ) {
95- state . skillMenuIndex = index ;
96- } else {
97- state . slashMenuIndex = index ;
98- }
99- } ;
92+ const indexKey = menu === "skill" ? "skillMenuIndex" : "slashMenuIndex" ;
10093 switch ( event . key ) {
10194 case "ArrowDown" :
95+ case "ArrowUp" : {
10296 event . preventDefault ( ) ;
103- setIndex ( ( getIndex ( ) + 1 ) % items . length ) ;
104- requestUpdate ( ) ;
105- scrollActive ( state , paneId ) ;
106- return true ;
107- case "ArrowUp" :
108- event . preventDefault ( ) ;
109- setIndex ( ( getIndex ( ) - 1 + items . length ) % items . length ) ;
97+ const offset = event . key === "ArrowDown" ? 1 : items . length - 1 ;
98+ state [ indexKey ] = ( state [ indexKey ] + offset ) % items . length ;
11099 requestUpdate ( ) ;
111100 scrollActive ( state , paneId ) ;
112101 return true ;
102+ }
113103 case "Tab" :
114104 case "Enter" : {
115105 event . preventDefault ( ) ;
116- const item = items [ getIndex ( ) ] ;
106+ const item = items [ state [ indexKey ] ] ;
117107 if ( item !== undefined ) {
118108 onSelect ( item , event . key === "Enter" ) ;
119109 }
@@ -134,9 +124,8 @@ export function renderChatComposer(props: ChatComposerProps) {
134124 const submittedProgress = props . queue . find ( ( item ) =>
135125 isCurrentSessionSubmittedProgress ( item , props . sessionKey , props . runStatus ) ,
136126 ) ;
137- const showSubmittedProgressUi = Boolean ( submittedProgress ) ;
138127 const composerRunStatus =
139- showAbortableUi || showSubmittedProgressUi
128+ showAbortableUi || Boolean ( submittedProgress )
140129 ? { phase : "in-progress" as const }
141130 : props . runStatus ;
142131 const compactBusy =
@@ -151,7 +140,6 @@ export function renderChatComposer(props: ChatComposerProps) {
151140 state . dictationDraftKey = draftKey ;
152141 const visibleDraft =
153142 state . composingDraft ?. key === draftKey ? state . composingDraft . value : props . draft ;
154- const actionDraft = visibleDraft ;
155143 state . textareaRef ??= ( element ?: Element ) => {
156144 const nextTextarea = element instanceof HTMLTextAreaElement ? element : null ;
157145 const prevTextarea = state . composerTextarea ;
@@ -619,7 +607,7 @@ export function renderChatComposer(props: ChatComposerProps) {
619607 // send-after-typing behavior until the host rerenders the primary actions.
620608 // Once a draft is rendered, the separate voice control starts Talk directly.
621609 onTap :
622- actionDraft . trim ( ) || props . attachments ?. length
610+ visibleDraft . trim ( ) || props . attachments ?. length
623611 ? ( ) => props . onToggleRealtimeTalk ?.( )
624612 : handleVoicePrimaryAction ,
625613 } ;
@@ -641,9 +629,9 @@ export function renderChatComposer(props: ChatComposerProps) {
641629 } ;
642630 const runControlsProps : ChatRunControlsProps = {
643631 canAbort : showAbortableUi ,
644- canSend : canSubmitDraft ( actionDraft ) ,
632+ canSend : canSubmitDraft ( visibleDraft ) ,
645633 connected : props . connected ,
646- draft : actionDraft ,
634+ draft : visibleDraft ,
647635 hasAttachments : ! props . suggestionComposer && Boolean ( props . attachments ?. length ) ,
648636 hasMessages : props . messages . length > 0 ,
649637 isBusy,
0 commit comments