Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion packages/cli/src/gemini.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ describe('gemini.tsx main function', () => {
'isRaw',
);
Object.defineProperty(process.stdin, 'isTTY', {
value: true,
value: false, // 在 stream-json 樑式下应为 false
configurable: true,
});
Object.defineProperty(process.stdin, 'isRaw', {
Expand Down Expand Up @@ -344,6 +344,9 @@ describe('gemini.tsx main function', () => {
getInputFormat: () => 'stream-json',
getContentGeneratorConfig: () => ({ authType: 'test-auth' }),
getWarnings: () => [],
getUsageStatisticsEnabled: () => true,
getSessionId: () => 'test-session-id',
getOutputFormat: () => OutputFormat.TEXT,
} as unknown as Config;

vi.mocked(loadCliConfig).mockResolvedValue(configStub);
Expand Down Expand Up @@ -442,6 +445,7 @@ describe('gemini.tsx main function kitty protocol', () => {
getScreenReader: () => false,
getGeminiMdFileCount: () => 0,
getWarnings: () => [],
getUsageStatisticsEnabled: () => true,
} as unknown as Config);
vi.mocked(loadSettings).mockReturnValue({
errors: [],
Expand Down
11 changes: 5 additions & 6 deletions packages/cli/src/gemini.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -385,17 +385,16 @@ export async function main() {
setMaxSizedBoxDebugging(isDebugMode);

// Check input format early to determine initialization flow
const inputFormat =
typeof config.getInputFormat === 'function'
// In TTY mode, ignore stream-json input format to prevent process from hanging
const inputFormat = process.stdin.isTTY
? InputFormat.TEXT
: typeof config.getInputFormat === 'function'
? config.getInputFormat()
: InputFormat.TEXT;

// For stream-json mode, defer config.initialize() until after the initialize control request
// For other modes, initialize normally
let initializationResult: InitializationResult | undefined;
if (inputFormat !== InputFormat.STREAM_JSON) {
initializationResult = await initializeApp(config, settings);
}
const initializationResult = await initializeApp(config, settings);

if (config.getExperimentalZedIntegration()) {
return runAcpAgent(config, settings, argv);
Expand Down