Skip to content

Commit e5615f4

Browse files
Adib234jacob314
andauthored
fix(plan): prevent plan truncation in approval dialog by supporting unconstrained heights (#21037)
Co-authored-by: jacob314 <jacob314@gmail.com>
1 parent bc75a61 commit e5615f4

5 files changed

Lines changed: 18 additions & 11 deletions

File tree

packages/cli/src/ui/AppContainer.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1389,11 +1389,7 @@ Logging in with Google... Restarting Gemini CLI to continue.
13891389
// Compute available terminal height based on controls measurement
13901390
const availableTerminalHeight = Math.max(
13911391
0,
1392-
terminalHeight -
1393-
controlsHeight -
1394-
staticExtraHeight -
1395-
2 -
1396-
backgroundShellHeight,
1392+
terminalHeight - controlsHeight - backgroundShellHeight - 1,
13971393
);
13981394

13991395
config.setShellExecutionConfig({

packages/cli/src/ui/components/AskUserDialog.tsx

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -807,24 +807,29 @@ const ChoiceQuestionView: React.FC<ChoiceQuestionViewProps> = ({
807807
const TITLE_MARGIN = 1;
808808
const FOOTER_HEIGHT = 2; // DialogFooter + margin
809809
const overhead = HEADER_HEIGHT + TITLE_MARGIN + FOOTER_HEIGHT;
810+
810811
const listHeight = availableHeight
811812
? Math.max(1, availableHeight - overhead)
812813
: undefined;
813-
const questionHeight =
814+
815+
const questionHeightLimit =
814816
listHeight && !isAlternateBuffer
815-
? Math.min(15, Math.max(1, listHeight - DIALOG_PADDING))
817+
? question.unconstrainedHeight
818+
? Math.max(1, listHeight - selectionItems.length * 2)
819+
: Math.min(15, Math.max(1, listHeight - DIALOG_PADDING))
816820
: undefined;
821+
817822
const maxItemsToShow =
818-
listHeight && questionHeight
819-
? Math.max(1, Math.floor((listHeight - questionHeight) / 2))
823+
listHeight && questionHeightLimit
824+
? Math.max(1, Math.floor((listHeight - questionHeightLimit) / 2))
820825
: selectionItems.length;
821826

822827
return (
823828
<Box flexDirection="column">
824829
{progressHeader}
825830
<Box marginBottom={TITLE_MARGIN}>
826831
<MaxSizedBox
827-
maxHeight={questionHeight}
832+
maxHeight={questionHeightLimit}
828833
maxWidth={availableWidth}
829834
overflowDirection="bottom"
830835
>

packages/cli/src/ui/components/ExitPlanModeDialog.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@ export const ExitPlanModeDialog: React.FC<ExitPlanModeDialogProps> = ({
249249
],
250250
placeholder: 'Type your feedback...',
251251
multiSelect: false,
252+
unconstrainedHeight: false,
252253
},
253254
]}
254255
onSubmit={(answers) => {

packages/cli/src/ui/components/ToolConfirmationQueue.test.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,10 @@ describe('ToolConfirmationQueue', () => {
282282
// hideToolIdentity is true for ask_user -> subtracts 4 instead of 6
283283
// availableContentHeight = 19 - 4 = 15
284284
// ToolConfirmationMessage handlesOwnUI=true -> returns full 15
285-
// AskUserDialog uses 15 lines to render its multi-line question and options.
285+
// AskUserDialog allocates questionHeight = availableHeight - overhead - DIALOG_PADDING.
286+
// listHeight = 15 - overhead (Header:0, Margin:1, Footer:2) = 12.
287+
// maxQuestionHeight = listHeight - 4 = 8.
288+
// 8 lines is enough for the 6-line question.
286289
await waitFor(() => {
287290
expect(lastFrame()).toContain('Line 6');
288291
expect(lastFrame()).not.toContain('lines hidden');

packages/core/src/confirmation-bus/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,8 @@ export interface Question {
167167
multiSelect?: boolean;
168168
/** Placeholder hint text. For type='text', shown in the input field. For type='choice', shown in the "Other" custom input. */
169169
placeholder?: string;
170+
/** Allow the question to consume more vertical space instead of being strictly capped. */
171+
unconstrainedHeight?: boolean;
170172
}
171173

172174
export interface AskUserRequest {

0 commit comments

Comments
 (0)