@@ -123,6 +123,8 @@ const VS_SELECTION_MAX_PROMPT_CHARS = 4000;
123123const BUILD_FIX_POLL_INTERVAL_MS = 2000 ;
124124const BUILD_FIX_MAX_CHARS = 12000 ;
125125const OPENAI_KEY_STATUS_CACHE_MS = 15000 ;
126+ const PROMPT_INPUT_MAX_HEIGHT_DESKTOP_PX = 360 ;
127+ const PROMPT_INPUT_MAX_HEIGHT_MOBILE_PX = 192 ;
126128const UI_AUDIT_OUTGOING_TYPES = new Set ( [
127129 "session_create" ,
128130 "session_attach" ,
@@ -1382,6 +1384,33 @@ function rememberPromptDraftForState(state) {
13821384 persistPromptDraftState ( ) ;
13831385}
13841386
1387+ function getPromptInputMaxHeightPx ( ) {
1388+ return isMobileViewport ( ) ? PROMPT_INPUT_MAX_HEIGHT_MOBILE_PX : PROMPT_INPUT_MAX_HEIGHT_DESKTOP_PX ;
1389+ }
1390+
1391+ function refreshPromptInputHeight ( options = { } ) {
1392+ if ( ! promptInput ) {
1393+ return ;
1394+ }
1395+
1396+ const reset = options . reset === true ;
1397+ const maxHeightPx = getPromptInputMaxHeightPx ( ) ;
1398+ promptInput . style . maxHeight = `${ maxHeightPx } px` ;
1399+
1400+ if ( reset ) {
1401+ promptInput . style . height = "" ;
1402+ promptInput . style . overflowY = "hidden" ;
1403+ return ;
1404+ }
1405+
1406+ promptInput . style . height = "auto" ;
1407+ const scrollHeight = Math . max ( 0 , promptInput . scrollHeight || 0 ) ;
1408+ if ( scrollHeight > 0 ) {
1409+ promptInput . style . height = `${ Math . min ( scrollHeight , maxHeightPx ) } px` ;
1410+ }
1411+ promptInput . style . overflowY = scrollHeight > maxHeightPx ? "auto" : "hidden" ;
1412+ }
1413+
13851414function clearCurrentPromptDraft ( ) {
13861415 const key = getCurrentPromptDraftKey ( ) ;
13871416 rememberPromptDraftForKey ( key , "" ) ;
@@ -1408,6 +1437,7 @@ function restorePromptDraftForActiveSession(options = {}) {
14081437 if ( promptInput . value !== normalized ) {
14091438 promptInput . value = normalized ;
14101439 }
1440+ refreshPromptInputHeight ( { reset : normalized . length === 0 } ) ;
14111441
14121442 let nextImages = promptDraftImagesByKey . get ( key ) ;
14131443 if ( ( ! Array . isArray ( nextImages ) || nextImages . length === 0 )
@@ -5077,6 +5107,7 @@ function removeQueuedPrompt(sessionId, queueItemId) {
50775107
50785108function restoreQueuedPromptForEditing ( text , images = [ ] ) {
50795109 promptInput . value = String ( text || "" ) ;
5110+ refreshPromptInputHeight ( { reset : promptInput . value . length === 0 } ) ;
50805111
50815112 pendingComposerImages = normalizePromptDraftImages ( images , { assignIds : true } ) ;
50825113 renderComposerImages ( ) ;
@@ -8193,6 +8224,7 @@ promptInput.addEventListener("paste", async (event) => {
81938224} ) ;
81948225
81958226promptInput . addEventListener ( "input" , ( ) => {
8227+ refreshPromptInputHeight ( { reset : promptInput . value . length === 0 } ) ;
81968228 rememberPromptDraftForState ( getActiveSessionState ( ) ) ;
81978229 refreshVsSelectionSnapshot ( ) . catch ( ( ) => { } ) ;
81988230} ) ;
@@ -8386,6 +8418,7 @@ async function queueCurrentComposerPrompt() {
83868418 }
83878419
83888420 promptInput . value = "" ;
8421+ refreshPromptInputHeight ( { reset : true } ) ;
83898422 clearCurrentPromptDraft ( ) ;
83908423 clearComposerImages ( ) ;
83918424 resetPlanModeNextTurn ( ) ;
@@ -8423,6 +8456,7 @@ promptForm.addEventListener("submit", async (event) => {
84238456 if ( prompt . localeCompare ( "cancel" , undefined , { sensitivity : "accent" } ) === 0 ) {
84248457 cancelPendingToolUserInput ( ) ;
84258458 promptInput . value = "" ;
8459+ refreshPromptInputHeight ( { reset : true } ) ;
84268460 clearCurrentPromptDraft ( ) ;
84278461 clearComposerImages ( ) ;
84288462 return ;
@@ -8438,6 +8472,7 @@ promptForm.addEventListener("submit", async (event) => {
84388472
84398473 if ( ! pendingBuildFixClip && images . length === 0 && await tryHandleSlashCommand ( prompt ) ) {
84408474 promptInput . value = "" ;
8475+ refreshPromptInputHeight ( { reset : true } ) ;
84418476 clearCurrentPromptDraft ( ) ;
84428477 return ;
84438478 }
@@ -8522,6 +8557,7 @@ promptForm.addEventListener("submit", async (event) => {
85228557 }
85238558
85248559 promptInput . value = "" ;
8560+ refreshPromptInputHeight ( { reset : true } ) ;
85258561 clearCurrentPromptDraft ( ) ;
85268562 clearComposerImages ( ) ;
85278563 resetPlanModeNextTurn ( ) ;
@@ -8560,6 +8596,7 @@ promptInput.addEventListener("keydown", (event) => {
85608596
85618597 event . preventDefault ( ) ;
85628598 promptInput . value = lastSent ;
8599+ refreshPromptInputHeight ( { reset : false } ) ;
85638600 promptInput . selectionStart = promptInput . selectionEnd = promptInput . value . length ;
85648601 rememberPromptDraftForState ( getActiveSessionState ( ) ) ;
85658602 return ;
@@ -8707,6 +8744,7 @@ window.addEventListener("resize", () => {
87078744 if ( ! isMobileViewport ( ) ) {
87088745 setMobileProjectsOpen ( false ) ;
87098746 }
8747+ refreshPromptInputHeight ( { reset : promptInput . value . length === 0 } ) ;
87108748 updateMobileProjectsButton ( ) ;
87118749 updateConversationMetaVisibility ( ) ;
87128750 updateScrollToBottomButton ( ) ;
@@ -8757,6 +8795,7 @@ document.addEventListener("visibilitychange", () => {
87578795} ) ;
87588796
87598797applySavedUiSettings ( ) ;
8798+ refreshPromptInputHeight ( { reset : promptInput . value . length === 0 } ) ;
87608799renderComposerImages ( ) ;
87618800renderVsSelectionIndicator ( ) ;
87628801startVsSelectionPolling ( ) ;
0 commit comments