mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-03 08:24:10 -07:00
feat(cli): add macOS run-event notifications (interactive only) (#19056)
Co-authored-by: Tommaso Sciortino <sciortino@gmail.com>
This commit is contained in:
@@ -16,10 +16,14 @@ export const DISABLE_FOCUS_REPORTING = '\x1b[?1004l';
|
||||
export const FOCUS_IN = '\x1b[I';
|
||||
export const FOCUS_OUT = '\x1b[O';
|
||||
|
||||
export const useFocus = () => {
|
||||
export const useFocus = (): {
|
||||
isFocused: boolean;
|
||||
hasReceivedFocusEvent: boolean;
|
||||
} => {
|
||||
const { stdin } = useStdin();
|
||||
const { stdout } = useStdout();
|
||||
const [isFocused, setIsFocused] = useState(true);
|
||||
const [hasReceivedFocusEvent, setHasReceivedFocusEvent] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
const handleData = (data: Buffer) => {
|
||||
@@ -28,8 +32,10 @@ export const useFocus = () => {
|
||||
const lastFocusOut = sequence.lastIndexOf(FOCUS_OUT);
|
||||
|
||||
if (lastFocusIn > lastFocusOut) {
|
||||
setHasReceivedFocusEvent(true);
|
||||
setIsFocused(true);
|
||||
} else if (lastFocusOut > lastFocusIn) {
|
||||
setHasReceivedFocusEvent(true);
|
||||
setIsFocused(false);
|
||||
}
|
||||
};
|
||||
@@ -58,5 +64,8 @@ export const useFocus = () => {
|
||||
{ isActive: true },
|
||||
);
|
||||
|
||||
return isFocused;
|
||||
return {
|
||||
isFocused,
|
||||
hasReceivedFocusEvent,
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user