summaryrefslogtreecommitdiff
path: root/packages/cli/src/ui/hooks
diff options
context:
space:
mode:
Diffstat (limited to 'packages/cli/src/ui/hooks')
-rw-r--r--packages/cli/src/ui/hooks/shellCommandProcessor.test.ts8
-rw-r--r--packages/cli/src/ui/hooks/shellCommandProcessor.ts11
-rw-r--r--packages/cli/src/ui/hooks/useReactToolScheduler.ts5
-rw-r--r--packages/cli/src/ui/hooks/useToolScheduler.test.ts15
4 files changed, 20 insertions, 19 deletions
diff --git a/packages/cli/src/ui/hooks/shellCommandProcessor.test.ts b/packages/cli/src/ui/hooks/shellCommandProcessor.test.ts
index 49dd9c2a..d5270aba 100644
--- a/packages/cli/src/ui/hooks/shellCommandProcessor.test.ts
+++ b/packages/cli/src/ui/hooks/shellCommandProcessor.test.ts
@@ -104,6 +104,8 @@ describe('useShellCommandProcessor', () => {
): ShellExecutionResult => ({
rawOutput: Buffer.from(overrides.output || ''),
output: 'Success',
+ stdout: 'Success',
+ stderr: '',
exitCode: 0,
signal: null,
error: null,
@@ -221,6 +223,7 @@ describe('useShellCommandProcessor', () => {
act(() => {
mockShellOutputCallback({
type: 'data',
+ stream: 'stdout',
chunk: 'hello',
});
});
@@ -231,9 +234,12 @@ describe('useShellCommandProcessor', () => {
// Advance time and send another event to trigger the throttled update
await act(async () => {
await vi.advanceTimersByTimeAsync(OUTPUT_UPDATE_INTERVAL_MS + 1);
+ });
+ act(() => {
mockShellOutputCallback({
type: 'data',
- chunk: 'hello world',
+ stream: 'stdout',
+ chunk: ' world',
});
});
diff --git a/packages/cli/src/ui/hooks/shellCommandProcessor.ts b/packages/cli/src/ui/hooks/shellCommandProcessor.ts
index 537b21ac..08df0a74 100644
--- a/packages/cli/src/ui/hooks/shellCommandProcessor.ts
+++ b/packages/cli/src/ui/hooks/shellCommandProcessor.ts
@@ -104,6 +104,7 @@ export const useShellCommandProcessor = (
const execPromise = new Promise<void>((resolve) => {
let lastUpdateTime = Date.now();
let cumulativeStdout = '';
+ let cumulativeStderr = '';
let isBinaryStream = false;
let binaryBytesReceived = 0;
@@ -141,7 +142,11 @@ export const useShellCommandProcessor = (
case 'data':
// Do not process text data if we've already switched to binary mode.
if (isBinaryStream) break;
- cumulativeStdout = event.chunk;
+ if (event.stream === 'stdout') {
+ cumulativeStdout += event.chunk;
+ } else {
+ cumulativeStderr += event.chunk;
+ }
break;
case 'binary_detected':
isBinaryStream = true;
@@ -167,7 +172,9 @@ export const useShellCommandProcessor = (
'[Binary output detected. Halting stream...]';
}
} else {
- currentDisplayOutput = cumulativeStdout;
+ currentDisplayOutput =
+ cumulativeStdout +
+ (cumulativeStderr ? `\n${cumulativeStderr}` : '');
}
// Throttle pending UI updates to avoid excessive re-renders.
diff --git a/packages/cli/src/ui/hooks/useReactToolScheduler.ts b/packages/cli/src/ui/hooks/useReactToolScheduler.ts
index ce9727b7..93e05387 100644
--- a/packages/cli/src/ui/hooks/useReactToolScheduler.ts
+++ b/packages/cli/src/ui/hooks/useReactToolScheduler.ts
@@ -62,8 +62,6 @@ export type TrackedToolCall =
| TrackedCompletedToolCall
| TrackedCancelledToolCall;
-import { useTerminalSize } from './useTerminalSize.js';
-
export function useReactToolScheduler(
onComplete: (tools: CompletedToolCall[]) => Promise<void>,
config: Config,
@@ -73,7 +71,6 @@ export function useReactToolScheduler(
getPreferredEditor: () => EditorType | undefined,
onEditorClose: () => void,
): [TrackedToolCall[], ScheduleFn, MarkToolsAsSubmittedFn] {
- const terminalSize = useTerminalSize();
const [toolCallsForDisplay, setToolCallsForDisplay] = useState<
TrackedToolCall[]
>([]);
@@ -143,7 +140,6 @@ export function useReactToolScheduler(
onToolCallsUpdate: toolCallsUpdateHandler,
getPreferredEditor,
config,
- getTerminalSize: () => terminalSize,
onEditorClose,
}),
[
@@ -152,7 +148,6 @@ export function useReactToolScheduler(
allToolCallsCompleteHandler,
toolCallsUpdateHandler,
getPreferredEditor,
- terminalSize,
onEditorClose,
],
);
diff --git a/packages/cli/src/ui/hooks/useToolScheduler.test.ts b/packages/cli/src/ui/hooks/useToolScheduler.test.ts
index c5d968fe..b2071931 100644
--- a/packages/cli/src/ui/hooks/useToolScheduler.test.ts
+++ b/packages/cli/src/ui/hooks/useToolScheduler.test.ts
@@ -36,13 +36,6 @@ import {
HistoryItemToolGroup,
} from '../types.js';
-vi.mock('./useTerminalSize', () => ({
- useTerminalSize: () => ({
- columns: 80,
- rows: 24,
- }),
-}));
-
// Mocks
vi.mock('@google/gemini-cli-core', async () => {
const actual = await vi.importActual('@google/gemini-cli-core');
@@ -231,8 +224,8 @@ describe('useReactToolScheduler in YOLO Mode', () => {
request.args,
expect.any(AbortSignal),
undefined,
- 80,
- 24,
+ undefined,
+ undefined,
);
// Check that onComplete was called with success
@@ -383,8 +376,8 @@ describe('useReactToolScheduler', () => {
request.args,
expect.any(AbortSignal),
undefined,
- 80,
- 24,
+ undefined,
+ undefined,
);
expect(onComplete).toHaveBeenCalledWith([
expect.objectContaining({