diff --git a/packages/cli/src/ui/components/messages/GeminiMessage.tsx b/packages/cli/src/ui/components/messages/GeminiMessage.tsx index deed1eb0..0df9aaa3 100644 --- a/packages/cli/src/ui/components/messages/GeminiMessage.tsx +++ b/packages/cli/src/ui/components/messages/GeminiMessage.tsx @@ -4,9 +4,10 @@ * SPDX-License-Identifier: Apache-2.0 */ +import { appendFileSync } from 'fs'; import React, { useEffect } from 'react'; import { Text, Box } from 'ink'; -import { exec } from 'child_process'; +import { execFile } from 'child_process'; import { MarkdownDisplay } from '../../utils/MarkdownDisplay.js'; import { Colors } from '../../colors.js'; import { SCREEN_READER_MODEL_PREFIX } from '../../constants.js'; @@ -25,33 +26,23 @@ export const GeminiMessage: React.FC = ({ terminalWidth, }) => { // --- Start of Modification --- - // Use a useEffect hook to trigger a side effect when the component renders - // with new text. This is the correct way to handle non-UI logic in React. useEffect(() => { // Don't execute for pending or empty responses. if (isPending || !text) { return; } - // The command to run. - const commandToRun = 'gemini --output'; + // Use the absolute path to the gemini binary to avoid PATH issues. + const command = '/home/jcarr/go/bin/gemini'; + const args = ['--output', text]; - // IMPORTANT: Pass the AI's message via an environment variable - // to prevent shell injection vulnerabilities. - const options = { - env: { - ...process.env, - GEMINI_MESSAGE: text, - }, - }; - - exec(commandToRun, options, (error, stdout, stderr) => { + execFile(command, args, (error, stdout, stderr) => { if (error) { - // Display errors in the debug console for visibility. - console.error(`exec error: ${error.message}`); + // For debugging, you can log errors to a file. + // appendFileSync('/tmp/gemini-cli-debug.log', `execFile error: ${error.message}\n`); + console.error(`execFile error: ${error.message}`); return; } - // You could also display stdout or stderr if needed. }); }, [text, isPending]); // This hook re-runs only when `text` or `isPending` changes. // --- End of Modification --- @@ -80,3 +71,4 @@ export const GeminiMessage: React.FC = ({ ); }; +