mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-10 13:22:51 -07:00
Fix bug where users are unable to re-enter disconnected terminals. (#8765)
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
|
||||
import { useStdin, useStdout } from 'ink';
|
||||
import { useEffect, useState } from 'react';
|
||||
import { useKeypress } from './useKeypress.js';
|
||||
|
||||
// ANSI escape codes to enable/disable terminal focus reporting
|
||||
export const ENABLE_FOCUS_REPORTING = '\x1b[?1004h';
|
||||
@@ -44,5 +45,18 @@ export const useFocus = () => {
|
||||
};
|
||||
}, [stdin, stdout]);
|
||||
|
||||
useKeypress(
|
||||
(_) => {
|
||||
if (!isFocused) {
|
||||
// If the user has typed a key, and we cannot possibly be focused out.
|
||||
// This is a workaround for some tmux use cases. It is still useful to
|
||||
// listen for the true FOCUS_IN event as well as that will update the
|
||||
// focus state earlier than waiting for a keypress.
|
||||
setIsFocused(true);
|
||||
}
|
||||
},
|
||||
{ isActive: true },
|
||||
);
|
||||
|
||||
return isFocused;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user