Skip to content
Closed
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
32 changes: 22 additions & 10 deletions ui/desktop/src/components/ChatInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ export default function ChatInput({
const [displayValue, setDisplayValue] = useState(initialValue); // For immediate visual feedback
const [isFocused, setIsFocused] = useState(false);
const [pastedImages, setPastedImages] = useState<PastedImage[]>([]);
const [isFileDialogOpen, setIsFileDialogOpen] = useState(false);

// Derived state - chatState != Idle means we're in some form of loading state
const isLoading = chatState !== ChatState.Idle;
Expand Down Expand Up @@ -1014,13 +1015,21 @@ export default function ChatInput({
}
};

// Handle file selection with dialog state management
const handleFileSelect = async () => {
const path = await window.electron.selectFileOrDirectory();
if (path) {
const newValue = displayValue.trim() ? `${displayValue.trim()} ${path}` : path;
setDisplayValue(newValue);
setValue(newValue);
textAreaRef.current?.focus();
if (isFileDialogOpen) return; // Prevent multiple dialogs

setIsFileDialogOpen(true);
try {
const path = await window.electron.selectFileOrDirectory();
if (path) {
const newValue = displayValue.trim() ? `${displayValue.trim()} ${path}` : path;
setDisplayValue(newValue);
setValue(newValue);
textAreaRef.current?.focus();
}
} finally {
setIsFileDialogOpen(false);
}
};

Expand Down Expand Up @@ -1453,20 +1462,23 @@ export default function ChatInput({
{/* Directory path */}
<DirSwitcher className="mr-0" />
<div className="w-px h-4 bg-border-default mx-2" />

<Tooltip>
<TooltipTrigger asChild>
<Button
type="button"
onClick={handleFileSelect}
disabled={isFileDialogOpen}
variant="ghost"
size="sm"
className="flex items-center justify-center text-text-default/70 hover:text-text-default text-xs cursor-pointer transition-colors"
className="flex items-center justify-center text-text-default/70 hover:text-text-default text-xs cursor-pointer transition-colors disabled:opacity-50 disabled:cursor-not-allowed"
>
<Attach className="w-4 h-4" />
</Button>
</TooltipTrigger>
<TooltipContent>Attach file or directory</TooltipContent>
<TooltipContent>
{isFileDialogOpen ? 'Dialog open...' : 'Attach file or directory'}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This here isn’t working, when a button is disabled, radix UI tooltips don’t show on hover by default, so you might need to add an alternate fix for showing dialog is open or maybe just disable grey button is fine or you can show a disabled point there.

Also, when I’m in different tabs, I’m not able to open multiple dialogs, but that might be because we’re only fixing it for the chat input, so maybe we can ignore that for now

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I will look into it.

</TooltipContent>
</Tooltip>

<div className="w-px h-4 bg-border-default mx-2" />
Expand Down Expand Up @@ -1562,4 +1574,4 @@ export default function ChatInput({
</div>
</div>
);
}
}