@@ -88,31 +88,21 @@ function handleComposerMenuKeyDown<T>(
8888 }
8989 return false ;
9090 }
91- const getIndex = ( ) => ( menu === "skill" ? state . skillMenuIndex : state . slashMenuIndex ) ;
92- const setIndex = ( index : number ) => {
93- if ( menu === "skill" ) {
94- state . skillMenuIndex = index ;
95- } else {
96- state . slashMenuIndex = index ;
97- }
98- } ;
91+ const indexKey = menu === "skill" ? "skillMenuIndex" : "slashMenuIndex" ;
9992 switch ( event . key ) {
10093 case "ArrowDown" :
94+ case "ArrowUp" : {
10195 event . preventDefault ( ) ;
102- setIndex ( ( getIndex ( ) + 1 ) % items . length ) ;
103- requestUpdate ( ) ;
104- scrollActive ( state , paneId ) ;
105- return true ;
106- case "ArrowUp" :
107- event . preventDefault ( ) ;
108- setIndex ( ( getIndex ( ) - 1 + items . length ) % items . length ) ;
96+ const offset = event . key === "ArrowDown" ? 1 : items . length - 1 ;
97+ state [ indexKey ] = ( state [ indexKey ] + offset ) % items . length ;
10998 requestUpdate ( ) ;
11099 scrollActive ( state , paneId ) ;
111100 return true ;
101+ }
112102 case "Tab" :
113103 case "Enter" : {
114104 event . preventDefault ( ) ;
115- const item = items [ getIndex ( ) ] ;
105+ const item = items [ state [ indexKey ] ] ;
116106 if ( item !== undefined ) {
117107 onSelect ( item , event . key === "Enter" ) ;
118108 }
@@ -133,9 +123,8 @@ export function renderChatComposer(props: ChatComposerProps) {
133123 const submittedProgress = props . queue . find ( ( item ) =>
134124 isCurrentSessionSubmittedProgress ( item , props . sessionKey , props . runStatus ) ,
135125 ) ;
136- const showSubmittedProgressUi = Boolean ( submittedProgress ) ;
137126 const composerRunStatus =
138- showAbortableUi || showSubmittedProgressUi
127+ showAbortableUi || Boolean ( submittedProgress )
139128 ? { phase : "in-progress" as const }
140129 : props . runStatus ;
141130 const compactBusy =
@@ -150,7 +139,6 @@ export function renderChatComposer(props: ChatComposerProps) {
150139 state . dictationDraftKey = draftKey ;
151140 const visibleDraft =
152141 state . composingDraft ?. key === draftKey ? state . composingDraft . value : props . draft ;
153- const actionDraft = visibleDraft ;
154142 state . textareaRef ??= ( element ?: Element ) => {
155143 const nextTextarea = element instanceof HTMLTextAreaElement ? element : null ;
156144 const prevTextarea = state . composerTextarea ;
@@ -618,7 +606,7 @@ export function renderChatComposer(props: ChatComposerProps) {
618606 // send-after-typing behavior until the host rerenders the primary actions.
619607 // Once a draft is rendered, the separate voice control starts Talk directly.
620608 onTap :
621- actionDraft . trim ( ) || props . attachments ?. length
609+ visibleDraft . trim ( ) || props . attachments ?. length
622610 ? ( ) => props . onToggleRealtimeTalk ?.( )
623611 : handleVoicePrimaryAction ,
624612 } ;
@@ -652,9 +640,9 @@ export function renderChatComposer(props: ChatComposerProps) {
652640 } ;
653641 const runControlsProps : ChatRunControlsProps = {
654642 canAbort : showAbortableUi ,
655- canSend : canSubmitDraft ( actionDraft ) ,
643+ canSend : canSubmitDraft ( visibleDraft ) ,
656644 connected : props . connected ,
657- draft : actionDraft ,
645+ draft : visibleDraft ,
658646 hasAttachments : ! props . suggestionComposer && Boolean ( props . attachments ?. length ) ,
659647 hasMessages : props . messages . length > 0 ,
660648 isBusy,
0 commit comments