Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 27 additions & 3 deletions src/web-ui/src/flow_chat/components/FileMentionPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,14 @@ export const FileMentionPicker: React.FC<FileMentionPickerProps> = ({
onClose();
}, [onSelect, onClose]);

const handleItemClick = useCallback((item: FileItem) => {
if (item.isDirectory && !isSearchMode) {
enterDirectory(item);
} else {
handleSelect(item);
}
}, [enterDirectory, handleSelect, isSearchMode]);

const handleKeyDown = useCallback((e: KeyboardEvent) => {
if (!isOpen) return;

Expand All @@ -344,11 +352,25 @@ export const FileMentionPicker: React.FC<FileMentionPickerProps> = ({
setSelectedIndex(prev => (prev < displayItems.length - 1 ? prev + 1 : 0));
}
break;
case 'ArrowRight':
e.preventDefault();
e.stopPropagation();
if (!isSearchMode && displayItems.length > 0 && displayItems[selectedIndex]?.isDirectory) {
enterDirectory(displayItems[selectedIndex]);
}
break;
case 'ArrowLeft':
e.preventDefault();
e.stopPropagation();
if (!isSearchMode && pathHistory.length > 0) {
goBack();
}
break;
case 'Enter':
e.preventDefault();
e.stopPropagation();
if (displayItems.length > 0 && displayItems[selectedIndex]) {
handleSelect(displayItems[selectedIndex]);
handleItemClick(displayItems[selectedIndex]);
}
break;
case 'Escape':
Expand All @@ -364,7 +386,7 @@ export const FileMentionPicker: React.FC<FileMentionPickerProps> = ({
}
break;
}
}, [displayItems, handleSelect, isOpen, onClose, selectedIndex]);
}, [displayItems, handleSelect, handleItemClick, enterDirectory, goBack, isSearchMode, isOpen, onClose, selectedIndex, pathHistory.length]);

useEffect(() => {
if (isOpen) {
Expand Down Expand Up @@ -478,7 +500,7 @@ export const FileMentionPicker: React.FC<FileMentionPickerProps> = ({
key={item.path}
data-index={index}
className={`file-mention-picker__item ${index === selectedIndex ? 'file-mention-picker__item--selected' : ''}`}
onClick={() => handleSelect(item)}
onClick={() => handleItemClick(item)}
onContextMenu={(e) => handleContextMenu(e, item)}
onMouseEnter={() => setSelectedIndex(index)}
>
Expand All @@ -495,6 +517,8 @@ export const FileMentionPicker: React.FC<FileMentionPickerProps> = ({

<div className="file-mention-picker__footer">
<span><kbd>↑</kbd><kbd>↓</kbd> {t('fileMention.navHint')}</span>
<span><kbd>→</kbd> {t('fileMention.enterHint')}</span>
<span><kbd>←</kbd> {t('fileMention.backHint')}</span>
<span><kbd>Enter</kbd> {t('fileMention.selectHint')}</span>
</div>
</div>
Expand Down
3 changes: 1 addition & 2 deletions src/web-ui/src/flow_chat/services/FlowChatManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,7 @@ export class FlowChatManager {
return existingRequest;
}

let request: Promise<boolean>;
request = this.initializeWorkspace(
const request = this.initializeWorkspace(
requestKey,
workspacePath,
preferredMode,
Expand Down
Loading