mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-20 08:47:44 +00:00
Sync upstream Gemini-CLI v0.8.2 (#838)
This commit is contained in:
@@ -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;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user