Switch from useInput to useKeypress. (#6056)

This commit is contained in:
Jacob Richman
2025-08-12 14:05:49 -07:00
committed by GitHub
parent 74fd0841d0
commit d219f90132
19 changed files with 350 additions and 259 deletions

View File

@@ -5,7 +5,6 @@
*/
import { useState, useRef, useCallback, useEffect, useMemo } from 'react';
import { useInput } from 'ink';
import {
Config,
GeminiClient,
@@ -55,6 +54,7 @@ import {
TrackedCancelledToolCall,
} from './useReactToolScheduler.js';
import { useSessionStats } from '../contexts/SessionContext.js';
import { useKeypress } from './useKeypress.js';
export function mergePartListUnions(list: PartListUnion[]): PartListUnion {
const resultParts: PartListUnion = [];
@@ -213,11 +213,14 @@ export const useGeminiStream = (
pendingHistoryItemRef,
]);
useInput((_input, key) => {
if (key.escape) {
cancelOngoingRequest();
}
});
useKeypress(
(key) => {
if (key.name === 'escape') {
cancelOngoingRequest();
}
},
{ isActive: streamingState === StreamingState.Responding },
);
const prepareQueryForGemini = useCallback(
async (