mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-21 02:24:09 -07:00
feat(core,cli): harden headless mode detection and align mocks
- Update isHeadlessMode in packages/core to check both stdin.isTTY and stdout.isTTY. - Synchronize isHeadlessMode mock in packages/cli tests and add global TTY stubs to ensure consistent test environments. - Add isMounted guard to useFolderTrust hook to prevent state updates on unmounted components in headless mode. - Expand unit tests in packages/core to cover new TTY check combinations and edge cases. - Stabilize flaky MCP initialization test in packages/core/src/config/config.test.ts by using a deterministic promise. - Address review findings regarding environment detection consistency and CI indicator checks.
This commit is contained in:
@@ -40,6 +40,7 @@ import {
|
||||
coreEvents,
|
||||
GEMINI_MODEL_ALIAS_AUTO,
|
||||
getAdminErrorMessage,
|
||||
isHeadlessMode,
|
||||
} from '@google/gemini-cli-core';
|
||||
import {
|
||||
type Settings,
|
||||
@@ -349,7 +350,7 @@ export async function parseArguments(
|
||||
|
||||
// -p/--prompt forces non-interactive mode; positional args default to interactive in TTY
|
||||
if (q && !result['prompt']) {
|
||||
if (process.stdin.isTTY) {
|
||||
if (!isHeadlessMode()) {
|
||||
startupMessages.push(
|
||||
'Positional arguments now default to interactive mode. To run in non-interactive mode, use the --prompt (-p) flag.',
|
||||
);
|
||||
@@ -589,7 +590,9 @@ export async function loadCliConfig(
|
||||
const interactive =
|
||||
!!argv.promptInteractive ||
|
||||
!!argv.experimentalAcp ||
|
||||
(process.stdin.isTTY && !argv.query && !argv.prompt && !argv.isCommand);
|
||||
(!isHeadlessMode({ prompt: argv.prompt }) &&
|
||||
!argv.query &&
|
||||
!argv.isCommand);
|
||||
|
||||
const allowedTools = argv.allowedTools || settings.tools?.allowed || [];
|
||||
const allowedToolsSet = new Set(allowedTools);
|
||||
|
||||
Reference in New Issue
Block a user