Sync upstream Gemini-CLI v0.8.2 (#838)

This commit is contained in:
tanzhenxin
2025-10-23 09:27:04 +08:00
committed by GitHub
parent 096fabb5d6
commit eb95c131be
644 changed files with 70389 additions and 23709 deletions

View File

@@ -146,9 +146,18 @@ export const PHRASE_CHANGE_INTERVAL_MS = 15000;
* @param isWaiting Whether to show a specific waiting phrase.
* @returns The current loading phrase.
*/
export const usePhraseCycler = (isActive: boolean, isWaiting: boolean) => {
export const usePhraseCycler = (
isActive: boolean,
isWaiting: boolean,
customPhrases?: string[],
) => {
const loadingPhrases =
customPhrases && customPhrases.length > 0
? customPhrases
: WITTY_LOADING_PHRASES;
const [currentLoadingPhrase, setCurrentLoadingPhrase] = useState(
WITTY_LOADING_PHRASES[0],
loadingPhrases[0],
);
const phraseIntervalRef = useRef<NodeJS.Timeout | null>(null);
@@ -165,16 +174,14 @@ export const usePhraseCycler = (isActive: boolean, isWaiting: boolean) => {
}
// Select an initial random phrase
const initialRandomIndex = Math.floor(
Math.random() * WITTY_LOADING_PHRASES.length,
Math.random() * loadingPhrases.length,
);
setCurrentLoadingPhrase(WITTY_LOADING_PHRASES[initialRandomIndex]);
setCurrentLoadingPhrase(loadingPhrases[initialRandomIndex]);
phraseIntervalRef.current = setInterval(() => {
// Select a new random phrase
const randomIndex = Math.floor(
Math.random() * WITTY_LOADING_PHRASES.length,
);
setCurrentLoadingPhrase(WITTY_LOADING_PHRASES[randomIndex]);
const randomIndex = Math.floor(Math.random() * loadingPhrases.length);
setCurrentLoadingPhrase(loadingPhrases[randomIndex]);
}, PHRASE_CHANGE_INTERVAL_MS);
} else {
// Idle or other states, clear the phrase interval
@@ -183,7 +190,7 @@ export const usePhraseCycler = (isActive: boolean, isWaiting: boolean) => {
clearInterval(phraseIntervalRef.current);
phraseIntervalRef.current = null;
}
setCurrentLoadingPhrase(WITTY_LOADING_PHRASES[0]);
setCurrentLoadingPhrase(loadingPhrases[0]);
}
return () => {
@@ -192,7 +199,7 @@ export const usePhraseCycler = (isActive: boolean, isWaiting: boolean) => {
phraseIntervalRef.current = null;
}
};
}, [isActive, isWaiting]);
}, [isActive, isWaiting, loadingPhrases]);
return currentLoadingPhrase;
};