Skip to content

Commit d41fb30

Browse files
authored
fix(plan): make question type required in AskUser tool (#18959)
1 parent 89f1d16 commit d41fb30

5 files changed

Lines changed: 77 additions & 29 deletions

File tree

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

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ describe('AskUserDialog', () => {
3737
{
3838
question: 'Which authentication method should we use?',
3939
header: 'Auth',
40+
type: QuestionType.CHOICE,
4041
options: [
4142
{ label: 'OAuth 2.0', description: 'Industry standard, supports SSO' },
4243
{ label: 'JWT tokens', description: 'Stateless, good for APIs' },
@@ -74,6 +75,7 @@ describe('AskUserDialog', () => {
7475
{
7576
question: 'Which features?',
7677
header: 'Features',
78+
type: QuestionType.CHOICE,
7779
options: [
7880
{ label: 'TypeScript', description: '' },
7981
{ label: 'ESLint', description: '' },
@@ -171,6 +173,7 @@ describe('AskUserDialog', () => {
171173
{
172174
question: 'Which authentication method?',
173175
header: 'Auth',
176+
type: QuestionType.CHOICE,
174177
options: [{ label: 'OAuth 2.0', description: '' }],
175178
multiSelect: false,
176179
},
@@ -228,6 +231,7 @@ describe('AskUserDialog', () => {
228231
{
229232
question: 'Choose an option',
230233
header: 'Scroll Test',
234+
type: QuestionType.CHOICE,
231235
options: Array.from({ length: 15 }, (_, i) => ({
232236
label: `Option ${i + 1}`,
233237
description: `Description ${i + 1}`,
@@ -296,6 +300,7 @@ describe('AskUserDialog', () => {
296300
{
297301
question: 'Which database should we use?',
298302
header: 'Database',
303+
type: QuestionType.CHOICE,
299304
options: [
300305
{ label: 'PostgreSQL', description: 'Relational database' },
301306
{ label: 'MongoDB', description: 'Document database' },
@@ -305,6 +310,7 @@ describe('AskUserDialog', () => {
305310
{
306311
question: 'Which ORM do you prefer?',
307312
header: 'ORM',
313+
type: QuestionType.CHOICE,
308314
options: [
309315
{ label: 'Prisma', description: 'Type-safe ORM' },
310316
{ label: 'Drizzle', description: 'Lightweight ORM' },
@@ -359,12 +365,14 @@ describe('AskUserDialog', () => {
359365
{
360366
question: 'Which testing framework?',
361367
header: 'Testing',
368+
type: QuestionType.CHOICE,
362369
options: [{ label: 'Vitest', description: 'Fast unit testing' }],
363370
multiSelect: false,
364371
},
365372
{
366373
question: 'Which CI provider?',
367374
header: 'CI',
375+
type: QuestionType.CHOICE,
368376
options: [
369377
{ label: 'GitHub Actions', description: 'Built into GitHub' },
370378
],
@@ -402,12 +410,14 @@ describe('AskUserDialog', () => {
402410
{
403411
question: 'Which package manager?',
404412
header: 'Package',
413+
type: QuestionType.CHOICE,
405414
options: [{ label: 'pnpm', description: 'Fast, disk efficient' }],
406415
multiSelect: false,
407416
},
408417
{
409418
question: 'Which bundler?',
410419
header: 'Bundler',
420+
type: QuestionType.CHOICE,
411421
options: [{ label: 'Vite', description: 'Next generation bundler' }],
412422
multiSelect: false,
413423
},
@@ -465,6 +475,7 @@ describe('AskUserDialog', () => {
465475
{
466476
question: 'Which framework?',
467477
header: 'Framework',
478+
type: QuestionType.CHOICE,
468479
options: [
469480
{ label: 'React', description: 'Component library' },
470481
{ label: 'Vue', description: 'Progressive framework' },
@@ -474,6 +485,7 @@ describe('AskUserDialog', () => {
474485
{
475486
question: 'Which styling?',
476487
header: 'Styling',
488+
type: QuestionType.CHOICE,
477489
options: [
478490
{ label: 'Tailwind', description: 'Utility-first CSS' },
479491
{ label: 'CSS Modules', description: 'Scoped styles' },
@@ -500,12 +512,14 @@ describe('AskUserDialog', () => {
500512
{
501513
question: 'Create tests?',
502514
header: 'Tests',
515+
type: QuestionType.CHOICE,
503516
options: [{ label: 'Yes', description: 'Generate test files' }],
504517
multiSelect: false,
505518
},
506519
{
507520
question: 'Add documentation?',
508521
header: 'Docs',
522+
type: QuestionType.CHOICE,
509523
options: [{ label: 'Yes', description: 'Generate JSDoc comments' }],
510524
multiSelect: false,
511525
},
@@ -545,12 +559,14 @@ describe('AskUserDialog', () => {
545559
{
546560
question: 'Which license?',
547561
header: 'License',
562+
type: QuestionType.CHOICE,
548563
options: [{ label: 'MIT', description: 'Permissive license' }],
549564
multiSelect: false,
550565
},
551566
{
552567
question: 'Include README?',
553568
header: 'README',
569+
type: QuestionType.CHOICE,
554570
options: [{ label: 'Yes', description: 'Generate README.md' }],
555571
multiSelect: false,
556572
},
@@ -580,12 +596,14 @@ describe('AskUserDialog', () => {
580596
{
581597
question: 'Target Node version?',
582598
header: 'Node',
599+
type: QuestionType.CHOICE,
583600
options: [{ label: 'Node 20', description: 'LTS version' }],
584601
multiSelect: false,
585602
},
586603
{
587604
question: 'Enable strict mode?',
588605
header: 'Strict',
606+
type: QuestionType.CHOICE,
589607
options: [{ label: 'Yes', description: 'Strict TypeScript' }],
590608
multiSelect: false,
591609
},
@@ -727,6 +745,7 @@ describe('AskUserDialog', () => {
727745
{
728746
question: 'Should it be async?',
729747
header: 'Async',
748+
type: QuestionType.CHOICE,
730749
options: [
731750
{ label: 'Yes', description: 'Use async/await' },
732751
{ label: 'No', description: 'Synchronous hook' },
@@ -773,6 +792,7 @@ describe('AskUserDialog', () => {
773792
{
774793
question: 'Which styling approach?',
775794
header: 'Style',
795+
type: QuestionType.CHOICE,
776796
options: [
777797
{ label: 'CSS Modules', description: 'Scoped CSS' },
778798
{ label: 'Tailwind', description: 'Utility classes' },
@@ -895,6 +915,7 @@ describe('AskUserDialog', () => {
895915
{
896916
question: 'Choice Q?',
897917
header: 'Choice',
918+
type: QuestionType.CHOICE,
898919
options: [{ label: 'Option 1', description: '' }],
899920
multiSelect: false,
900921
},
@@ -952,12 +973,14 @@ describe('AskUserDialog', () => {
952973
{
953974
question: 'Question 1?',
954975
header: 'Q1',
976+
type: QuestionType.CHOICE,
955977
options: [{ label: 'A1', description: '' }],
956978
multiSelect: false,
957979
},
958980
{
959981
question: 'Question 2?',
960982
header: 'Q2',
983+
type: QuestionType.CHOICE,
961984
options: [{ label: 'A2', description: '' }],
962985
multiSelect: false,
963986
},
@@ -1008,6 +1031,7 @@ describe('AskUserDialog', () => {
10081031
{
10091032
question: 'Which option do you prefer?',
10101033
header: 'Test',
1034+
type: QuestionType.CHOICE,
10111035
options: [{ label: 'Yes', description: '' }],
10121036
multiSelect: false,
10131037
},
@@ -1036,6 +1060,7 @@ describe('AskUserDialog', () => {
10361060
{
10371061
question: 'Is **this** working?',
10381062
header: 'Test',
1063+
type: QuestionType.CHOICE,
10391064
options: [{ label: 'Yes', description: '' }],
10401065
multiSelect: false,
10411066
},
@@ -1067,6 +1092,7 @@ describe('AskUserDialog', () => {
10671092
{
10681093
question: 'Is **this** working?',
10691094
header: 'Test',
1095+
type: QuestionType.CHOICE,
10701096
options: [{ label: 'Yes', description: '' }],
10711097
multiSelect: false,
10721098
},
@@ -1096,6 +1122,7 @@ describe('AskUserDialog', () => {
10961122
{
10971123
question: 'Run `npm start`?',
10981124
header: 'Test',
1125+
type: QuestionType.CHOICE,
10991126
options: [{ label: 'Yes', description: '' }],
11001127
multiSelect: false,
11011128
},
@@ -1126,6 +1153,7 @@ describe('AskUserDialog', () => {
11261153
{
11271154
question: 'Choose an option',
11281155
header: 'Context Test',
1156+
type: QuestionType.CHOICE,
11291157
options: Array.from({ length: 10 }, (_, i) => ({
11301158
label: `Option ${i + 1}`,
11311159
description: `Description ${i + 1}`,
@@ -1162,6 +1190,7 @@ describe('AskUserDialog', () => {
11621190
{
11631191
question: longQuestion,
11641192
header: 'Alternate Buffer Test',
1193+
type: QuestionType.CHOICE,
11651194
options: [{ label: 'Option 1', description: 'Desc 1' }],
11661195
multiSelect: false,
11671196
},
@@ -1195,6 +1224,7 @@ describe('AskUserDialog', () => {
11951224
{
11961225
question: 'Select your preferred language:',
11971226
header: 'Language',
1227+
type: QuestionType.CHOICE,
11981228
options: [
11991229
{ label: 'TypeScript', description: '' },
12001230
{ label: 'JavaScript', description: '' },
@@ -1228,6 +1258,7 @@ describe('AskUserDialog', () => {
12281258
{
12291259
question: 'Select your preferred language:',
12301260
header: 'Language',
1261+
type: QuestionType.CHOICE,
12311262
options: [
12321263
{ label: 'TypeScript', description: '' },
12331264
{ label: 'JavaScript', description: '' },

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { act } from 'react';
99
import { renderWithProviders } from '../../test-utils/render.js';
1010
import { waitFor } from '../../test-utils/async.js';
1111
import { AskUserDialog } from './AskUserDialog.js';
12-
import type { Question } from '@google/gemini-cli-core';
12+
import { QuestionType, type Question } from '@google/gemini-cli-core';
1313

1414
describe('Key Bubbling Regression', () => {
1515
afterEach(() => {
@@ -20,6 +20,7 @@ describe('Key Bubbling Regression', () => {
2020
{
2121
question: 'Choice Q?',
2222
header: 'Choice',
23+
type: QuestionType.CHOICE,
2324
options: [
2425
{ label: 'Option 1', description: '' },
2526
{ label: 'Option 2', description: '' },

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,9 @@ export enum QuestionType {
147147
export interface Question {
148148
question: string;
149149
header: string;
150-
/** Question type: 'choice' renders selectable options, 'text' renders free-form input, 'yesno' renders a binary Yes/No choice. Defaults to 'choice'. */
151-
type?: QuestionType;
152-
/** Selectable choices. REQUIRED when type='choice' or omitted. IGNORED for 'text' and 'yesno'. */
150+
/** Question type: 'choice' renders selectable options, 'text' renders free-form input, 'yesno' renders a binary Yes/No choice. */
151+
type: QuestionType;
152+
/** Selectable choices. REQUIRED when type='choice'. IGNORED for 'text' and 'yesno'. */
153153
options?: QuestionOption[];
154154
/** Allow multiple selections. Only applies when type='choice'. */
155155
multiSelect?: boolean;

0 commit comments

Comments
 (0)