@@ -85,7 +85,7 @@ function optimizeInputTextActions(
8585 const mergedActions : SessionAction [ ] = [ ] ;
8686 const mergedLines : number [ ] = [ ] ;
8787 for ( let index = 0 ; index < actions . length ; index += 1 ) {
88- const action = actions [ index ] ;
88+ const action = actions [ index ] ! ;
8989 const optimized = optimizeTypedAfterTap ( actions , actionLines , index ) ;
9090 if ( optimized ) {
9191 mergedActions . push ( ...optimized . actions ) ;
@@ -104,16 +104,17 @@ function optimizeTypedAfterTap(
104104 actionLines : number [ ] ,
105105 index : number ,
106106) : { actions : SessionAction [ ] ; actionLines : number [ ] ; consumed : number } | null {
107- const action = actions [ index ] ;
107+ const action = actions [ index ] ! ;
108108 const nextAction = actions [ index + 1 ] ;
109109 const typedAfterTap = readPlainTypeText ( nextAction ) ;
110110 const tapSelector = readPlainMaestroTapSelector ( action ) ;
111- if ( typedAfterTap === null || tapSelector === null ) return null ;
111+ if ( ! nextAction || typedAfterTap === null || tapSelector === null ) return null ;
112112 const line = actionLines [ index ] ?? 1 ;
113113 if ( ! isLikelyTextEntrySelector ( tapSelector ) ) {
114114 return { actions : [ clearMaestroNonHittableTap ( action ) ] , actionLines : [ line ] , consumed : 1 } ;
115115 }
116- if ( actions [ index + 2 ] ?. command !== MAESTRO_RUNTIME_COMMAND . pressEnter ) {
116+ const pressEnterAction = actions [ index + 2 ] ;
117+ if ( pressEnterAction ?. command !== MAESTRO_RUNTIME_COMMAND . pressEnter ) {
117118 return { actions : [ clearMaestroNonHittableTap ( action ) ] , actionLines : [ line ] , consumed : 1 } ;
118119 }
119120 return {
@@ -129,7 +130,7 @@ function optimizeTypedAfterTap(
129130 positionals : [ tapSelector , typedAfterTap ] ,
130131 flags : action . flags ,
131132 } ,
132- actions [ index + 2 ] as SessionAction ,
133+ pressEnterAction ,
133134 ] ,
134135 actionLines : [ line , line , actionLines [ index + 2 ] ?? line ] ,
135136 consumed : 3 ,
0 commit comments