@@ -121,15 +121,19 @@ export function useTerminal(options: UseTerminalOptions): UseTerminalReturn {
121121 if ( isDisposed ) return ;
122122
123123 // Initialize xterm with macOS Terminal-like appearance
124+ const isMobile = 'ontouchstart' in window || navigator . maxTouchPoints > 0 ;
125+
124126 xterm = new Terminal ( {
125127 cursorBlink : true ,
126128 cursorStyle : 'block' ,
127- fontSize : 11 ,
129+ fontSize : isMobile ? 13 : 11 ,
128130 fontFamily : '"Fira Code", "SF Mono", "Menlo", "Monaco", "Cascadia Code", "Consolas", monospace' ,
129131 fontWeight : '500' ,
130132 fontWeightBold : '600' ,
131133 lineHeight : 1.2 ,
132134 letterSpacing : 0 ,
135+ scrollback : 5000 ,
136+ smoothScrollDuration : isMobile ? 100 : 0 ,
133137 allowTransparency : false ,
134138 theme : {
135139 background : '#1e1e1e' ,
@@ -244,9 +248,38 @@ export function useTerminal(options: UseTerminalOptions): UseTerminalReturn {
244248
245249 container . addEventListener ( 'paste' , handlePaste ) ;
246250 container . addEventListener ( 'contextmenu' , handleContextMenu ) ;
251+
252+ // Improve mobile touch scrolling: boost scroll speed and momentum
253+ let touchStartY = 0 ;
254+ let touchScrollCleanup : ( ( ) => void ) | null = null ;
255+ if ( isMobile ) {
256+ const handleTouchStart = ( e : TouchEvent ) => {
257+ touchStartY = e . touches [ 0 ] . clientY ;
258+ } ;
259+ const handleTouchMove = ( e : TouchEvent ) => {
260+ if ( ! xterm ) return ;
261+ const deltaY = touchStartY - e . touches [ 0 ] . clientY ;
262+ touchStartY = e . touches [ 0 ] . clientY ;
263+ // Scroll by lines based on touch delta (amplify for momentum feel)
264+ const lines = Math . round ( deltaY / 10 ) ;
265+ if ( lines !== 0 ) {
266+ xterm . scrollLines ( lines ) ;
267+ }
268+ // Prevent page scroll while scrolling terminal
269+ e . preventDefault ( ) ;
270+ } ;
271+ container . addEventListener ( 'touchstart' , handleTouchStart , { passive : true } ) ;
272+ container . addEventListener ( 'touchmove' , handleTouchMove , { passive : false } ) ;
273+ touchScrollCleanup = ( ) => {
274+ container . removeEventListener ( 'touchstart' , handleTouchStart ) ;
275+ container . removeEventListener ( 'touchmove' , handleTouchMove ) ;
276+ } ;
277+ }
278+
247279 pasteCleanup = ( ) => {
248280 container . removeEventListener ( 'paste' , handlePaste ) ;
249281 container . removeEventListener ( 'contextmenu' , handleContextMenu ) ;
282+ touchScrollCleanup ?.( ) ;
250283 } ;
251284
252285 xtermRef . current = xterm ;
0 commit comments