fix(cli): allow ask question dialog to take full window height (#23693)

This commit is contained in:
Jacob Richman
2026-03-25 16:26:34 -07:00
committed by GitHub
parent b91758bf6b
commit a86935b6de
12 changed files with 494 additions and 53 deletions
+21 -10
View File
@@ -14,7 +14,7 @@ import {
} from 'react';
import {
type DOMElement,
measureElement,
ResizeObserver,
useApp,
useStdout,
useStdin,
@@ -397,7 +397,6 @@ export const AppContainer = (props: AppContainerProps) => {
const branchName = useGitBranchName(config.getTargetDir());
// Layout measurements
const mainControlsRef = useRef<DOMElement>(null);
// For performance profiling only
const rootUiRef = useRef<DOMElement>(null);
const lastTitleRef = useRef<string | null>(null);
@@ -1396,6 +1395,7 @@ Logging in with Google... Restarting Gemini CLI to continue.
!proQuotaRequest &&
!copyModeEnabled;
const observerRef = useRef<ResizeObserver | null>(null);
const [controlsHeight, setControlsHeight] = useState(0);
const [lastNonCopyControlsHeight, setLastNonCopyControlsHeight] = useState(0);
@@ -1410,15 +1410,26 @@ Logging in with Google... Restarting Gemini CLI to continue.
? lastNonCopyControlsHeight
: controlsHeight;
useLayoutEffect(() => {
if (mainControlsRef.current) {
const fullFooterMeasurement = measureElement(mainControlsRef.current);
const roundedHeight = Math.round(fullFooterMeasurement.height);
if (roundedHeight > 0 && roundedHeight !== controlsHeight) {
setControlsHeight(roundedHeight);
}
const mainControlsRef = useCallback((node: DOMElement | null) => {
if (observerRef.current) {
observerRef.current.disconnect();
observerRef.current = null;
}
}, [buffer, terminalWidth, terminalHeight, controlsHeight, isInputActive]);
if (node) {
const observer = new ResizeObserver((entries) => {
const entry = entries[0];
if (entry) {
const roundedHeight = Math.round(entry.contentRect.height);
setControlsHeight((prev) =>
roundedHeight !== prev ? roundedHeight : prev,
);
}
});
observer.observe(node);
observerRef.current = observer;
}
}, []);
// Compute available terminal height based on stable controls measurement
const availableTerminalHeight = Math.max(