hide vim mode

This commit is contained in:
dal 2025-09-30 13:51:48 -06:00
parent fe79f4e979
commit de2f13e311
No known key found for this signature in database
GPG Key ID: 16F4B0E1E9F61122
2 changed files with 18 additions and 3 deletions

View File

@ -24,6 +24,7 @@ export function Main() {
const [vimEnabled] = useState(() => getSetting('vimMode')); const [vimEnabled] = useState(() => getSetting('vimMode'));
const [currentVimMode, setCurrentVimMode] = useState<VimMode>('insert'); const [currentVimMode, setCurrentVimMode] = useState<VimMode>('insert');
const [showSettings, setShowSettings] = useState(false); const [showSettings, setShowSettings] = useState(false);
const [isAutocompleteOpen, setIsAutocompleteOpen] = useState(false);
useInput((value, key) => { useInput((value, key) => {
if (key.ctrl && value === 'c') { if (key.ctrl && value === 'c') {
@ -98,8 +99,13 @@ export function Main() {
placeholder='Try "Review the changes in my current branch"' placeholder='Try "Review the changes in my current branch"'
onVimModeChange={setCurrentVimMode} onVimModeChange={setCurrentVimMode}
onCommandExecute={handleCommandExecute} onCommandExecute={handleCommandExecute}
onAutocompleteStateChange={setIsAutocompleteOpen}
/>
<VimStatus
vimMode={currentVimMode}
vimEnabled={vimEnabled}
hideWhenAutocomplete={isAutocompleteOpen}
/> />
<VimStatus vimMode={currentVimMode} vimEnabled={vimEnabled} />
</Box> </Box>
<ChatFooter /> <ChatFooter />
</Box> </Box>

View File

@ -66,10 +66,11 @@ export function ChatStatusBar() {
interface VimStatusProps { interface VimStatusProps {
vimMode?: 'normal' | 'insert' | 'visual'; vimMode?: 'normal' | 'insert' | 'visual';
vimEnabled?: boolean; vimEnabled?: boolean;
hideWhenAutocomplete?: boolean;
} }
export function VimStatus({ vimMode, vimEnabled }: VimStatusProps) { export function VimStatus({ vimMode, vimEnabled, hideWhenAutocomplete }: VimStatusProps) {
if (!vimEnabled || !vimMode) { if (!vimEnabled || !vimMode || hideWhenAutocomplete) {
return null; return null;
} }
@ -105,6 +106,7 @@ interface ChatInputProps {
onSubmit: () => void; onSubmit: () => void;
onVimModeChange?: (mode: 'normal' | 'insert' | 'visual') => void; onVimModeChange?: (mode: 'normal' | 'insert' | 'visual') => void;
onCommandExecute?: (command: SlashCommand) => void; onCommandExecute?: (command: SlashCommand) => void;
onAutocompleteStateChange?: (isOpen: boolean) => void;
} }
export function ChatInput({ export function ChatInput({
@ -114,6 +116,7 @@ export function ChatInput({
onSubmit, onSubmit,
onVimModeChange, onVimModeChange,
onCommandExecute, onCommandExecute,
onAutocompleteStateChange,
}: ChatInputProps) { }: ChatInputProps) {
const [mentionQuery, setMentionQuery] = useState<string | null>(null); const [mentionQuery, setMentionQuery] = useState<string | null>(null);
const [mentionStart, setMentionStart] = useState<number>(-1); const [mentionStart, setMentionStart] = useState<number>(-1);
@ -188,6 +191,12 @@ export function ChatInput({
} }
}, [slashQuery]); }, [slashQuery]);
// Notify parent when autocomplete state changes
useEffect(() => {
const isOpen = showAutocomplete || showCommandAutocomplete;
onAutocompleteStateChange?.(isOpen);
}, [showAutocomplete, showCommandAutocomplete, onAutocompleteStateChange]);
// Handle autocomplete navigation // Handle autocomplete navigation
const handleAutocompleteNavigate = (direction: 'up' | 'down' | 'select' | 'close') => { const handleAutocompleteNavigate = (direction: 'up' | 'down' | 'select' | 'close') => {
// Handle command autocomplete // Handle command autocomplete