@@ -7,6 +7,7 @@ import { getFileSubject } from "@/app/store/wps";
77import { RpcApi } from "@/app/store/wshclientapi" ;
88import { TabRpcClient } from "@/app/store/wshrpcutil" ;
99import {
10+ atoms ,
1011 fetchWaveFile ,
1112 getApi ,
1213 getOverrideConfigAtom ,
@@ -16,6 +17,7 @@ import {
1617 openLink ,
1718 WOS ,
1819} from "@/store/global" ;
20+ import { getLayoutModelForStaticTab } from "@/layout/index" ;
1921import * as services from "@/store/services" ;
2022import { PLATFORM , PlatformMacOS } from "@/util/platformutil" ;
2123import { base64ToArray , fireAndForget } from "@/util/util" ;
@@ -99,8 +101,10 @@ export class TermWrap {
99101 lastUpdated : number ;
100102 promptMarkers : TermTypes . IMarker [ ] = [ ] ;
101103 shellIntegrationStatusAtom : jotai . PrimitiveAtom < ShellIntegrationStatus | null > ;
104+ currentCwdAtom : jotai . PrimitiveAtom < string | null > ;
102105 lastCommandAtom : jotai . PrimitiveAtom < string | null > ;
103106 claudeCodeActiveAtom : jotai . PrimitiveAtom < boolean > ;
107+ contentHeightRows : number ;
104108 nodeModel : BlockNodeModel ; // this can be null
105109 hoveredLinkUri : string | null = null ;
106110 onLinkHover ?: ( uri : string | null , mouseX : number , mouseY : number ) => void ;
@@ -120,6 +124,7 @@ export class TermWrap {
120124 lastMode2026ResetTs : number = 0 ;
121125 inSyncTransaction : boolean = false ;
122126 inRepaintTransaction : boolean = false ;
127+ syncQuickTerminalHeight_debounced : ( ) => void ;
123128
124129 constructor (
125130 tabId : string ,
@@ -139,8 +144,10 @@ export class TermWrap {
139144 this . lastUpdated = Date . now ( ) ;
140145 this . promptMarkers = [ ] ;
141146 this . shellIntegrationStatusAtom = jotai . atom ( null ) as jotai . PrimitiveAtom < ShellIntegrationStatus | null > ;
147+ this . currentCwdAtom = jotai . atom ( null ) as jotai . PrimitiveAtom < string | null > ;
142148 this . lastCommandAtom = jotai . atom ( null ) as jotai . PrimitiveAtom < string | null > ;
143149 this . claudeCodeActiveAtom = jotai . atom ( false ) ;
150+ this . contentHeightRows = 0 ;
144151 this . webglEnabledAtom = jotai . atom ( false ) as jotai . PrimitiveAtom < boolean > ;
145152 this . terminal = new Terminal ( options ) ;
146153 this . fitAddon = new FitAddon ( ) ;
@@ -182,7 +189,7 @@ export class TermWrap {
182189 // Register OSC handlers
183190 this . terminal . parser . registerOscHandler ( 7 , ( data : string ) => {
184191 try {
185- return handleOsc7Command ( data , this . blockId , this . loaded ) ;
192+ return handleOsc7Command ( data , this . blockId , this . loaded , this ) ;
186193 } catch ( e ) {
187194 console . error ( "[termwrap] osc 7 handler error" , this . blockId , e ) ;
188195 return false ;
@@ -280,6 +287,7 @@ export class TermWrap {
280287 this . mainFileSubject = null ;
281288 this . heldData = [ ] ;
282289 this . handleResize_debounced = debounce ( 50 , this . handleResize . bind ( this ) ) ;
290+ this . syncQuickTerminalHeight_debounced = debounce ( 16 , this . syncQuickTerminalHeight . bind ( this ) ) ;
283291 this . terminal . open ( this . connectElem ) ;
284292
285293 const dragoverHandler = ( e : DragEvent ) => {
@@ -475,6 +483,7 @@ export class TermWrap {
475483 if ( msg . fileop == "truncate" ) {
476484 this . terminal . clear ( ) ;
477485 this . heldData = [ ] ;
486+ this . syncQuickTerminalHeight_debounced ( ) ;
478487 } else if ( msg . fileop == "append" ) {
479488 const decodedData = base64ToArray ( msg . data64 ) ;
480489 if ( this . loaded ) {
@@ -508,6 +517,7 @@ export class TermWrap {
508517 this . dataBytesProcessed += data . length ;
509518 }
510519 this . lastUpdated = Date . now ( ) ;
520+ this . syncQuickTerminalHeight_debounced ( ) ;
511521 resolve ( ) ;
512522 } ) ;
513523 return prtn ;
@@ -575,13 +585,31 @@ export class TermWrap {
575585 ) ;
576586 RpcApi . ControllerInputCommand ( TabRpcClient , { blockid : this . blockId , termsize : termSize } ) ;
577587 }
588+ this . syncQuickTerminalHeight_debounced ( ) ;
578589 dlog ( "resize" , `${ this . terminal . rows } x${ this . terminal . cols } ` , `${ oldRows } x${ oldCols } ` , this . hasResized ) ;
579590 if ( ! this . hasResized ) {
580591 this . hasResized = true ;
581592 this . resyncController ( "initial resize" ) ;
582593 }
583594 }
584595
596+ private getContentHeightRows ( ) : number {
597+ return Math . max ( 1 , this . terminal . buffer . active . baseY + this . terminal . buffer . active . cursorY + 1 ) ;
598+ }
599+
600+ private syncQuickTerminalHeight ( ) {
601+ const nextRows = this . getContentHeightRows ( ) ;
602+ this . contentHeightRows = nextRows ;
603+
604+ const quickTermState = globalStore . get ( atoms . quickTerminalAtom ) ;
605+ if ( quickTermState . blockId !== this . blockId ) {
606+ return ;
607+ }
608+
609+ const layoutModel = getLayoutModelForStaticTab ( ) ;
610+ layoutModel ?. updateTree ( false ) ;
611+ }
612+
585613 processAndCacheData ( ) {
586614 if ( this . dataBytesProcessed < MinDataProcessedForCache ) {
587615 return ;
0 commit comments