fix: remove onClick handler causing wierd issue on windows that try to open microsoft store

This commit is contained in:
Kacper
2025-12-16 03:18:10 +01:00
parent 23cef5fd82
commit c8c05efb8d

View File

@@ -31,7 +31,8 @@ import {
} from "@/hooks/use-keyboard-shortcuts"; } from "@/hooks/use-keyboard-shortcuts";
export function AgentView() { export function AgentView() {
const { currentProject, setLastSelectedSession, getLastSelectedSession } = useAppStore(); const { currentProject, setLastSelectedSession, getLastSelectedSession } =
useAppStore();
const shortcuts = useKeyboardShortcutsConfig(); const shortcuts = useKeyboardShortcutsConfig();
const [input, setInput] = useState(""); const [input, setInput] = useState("");
const [selectedImages, setSelectedImages] = useState<ImageAttachment[]>([]); const [selectedImages, setSelectedImages] = useState<ImageAttachment[]>([]);
@@ -72,13 +73,16 @@ export function AgentView() {
}); });
// Handle session selection with persistence // Handle session selection with persistence
const handleSelectSession = useCallback((sessionId: string | null) => { const handleSelectSession = useCallback(
setCurrentSessionId(sessionId); (sessionId: string | null) => {
// Persist the selection for this project setCurrentSessionId(sessionId);
if (currentProject?.path) { // Persist the selection for this project
setLastSelectedSession(currentProject.path, sessionId); if (currentProject?.path) {
} setLastSelectedSession(currentProject.path, sessionId);
}, [currentProject?.path, setLastSelectedSession]); }
},
[currentProject?.path, setLastSelectedSession]
);
// Restore last selected session when switching to Agent view or when project changes // Restore last selected session when switching to Agent view or when project changes
useEffect(() => { useEffect(() => {
@@ -95,7 +99,10 @@ export function AgentView() {
const lastSessionId = getLastSelectedSession(currentProject.path); const lastSessionId = getLastSelectedSession(currentProject.path);
if (lastSessionId) { if (lastSessionId) {
console.log("[AgentView] Restoring last selected session:", lastSessionId); console.log(
"[AgentView] Restoring last selected session:",
lastSessionId
);
setCurrentSessionId(lastSessionId); setCurrentSessionId(lastSessionId);
} }
}, [currentProject?.path, getLastSelectedSession]); }, [currentProject?.path, getLastSelectedSession]);
@@ -418,7 +425,9 @@ export function AgentView() {
<div className="w-16 h-16 rounded-2xl bg-primary/10 flex items-center justify-center mx-auto mb-6"> <div className="w-16 h-16 rounded-2xl bg-primary/10 flex items-center justify-center mx-auto mb-6">
<Sparkles className="w-8 h-8 text-primary" /> <Sparkles className="w-8 h-8 text-primary" />
</div> </div>
<h2 className="text-xl font-semibold mb-3 text-foreground">No Project Selected</h2> <h2 className="text-xl font-semibold mb-3 text-foreground">
No Project Selected
</h2>
<p className="text-muted-foreground leading-relaxed"> <p className="text-muted-foreground leading-relaxed">
Open or create a project to start working with the AI agent. Open or create a project to start working with the AI agent.
</p> </p>
@@ -480,7 +489,9 @@ export function AgentView() {
<Bot className="w-5 h-5 text-primary" /> <Bot className="w-5 h-5 text-primary" />
</div> </div>
<div> <div>
<h1 className="text-lg font-semibold text-foreground">AI Agent</h1> <h1 className="text-lg font-semibold text-foreground">
AI Agent
</h1>
<p className="text-sm text-muted-foreground"> <p className="text-sm text-muted-foreground">
{currentProject.name} {currentProject.name}
{currentSessionId && !isConnected && " - Connecting..."} {currentSessionId && !isConnected && " - Connecting..."}
@@ -497,7 +508,9 @@ export function AgentView() {
</div> </div>
)} )}
{agentError && ( {agentError && (
<span className="text-xs text-destructive font-medium">{agentError}</span> <span className="text-xs text-destructive font-medium">
{agentError}
</span>
)} )}
{currentSessionId && messages.length > 0 && ( {currentSessionId && messages.length > 0 && (
<Button <Button
@@ -591,42 +604,47 @@ export function AgentView() {
)} )}
{/* Display attached images for user messages */} {/* Display attached images for user messages */}
{message.role === "user" && message.images && message.images.length > 0 && ( {message.role === "user" &&
<div className="mt-3 space-y-2"> message.images &&
<div className="flex items-center gap-1.5 text-xs text-primary-foreground/80"> message.images.length > 0 && (
<ImageIcon className="w-3 h-3" /> <div className="mt-3 space-y-2">
<span>{message.images.length} image{message.images.length > 1 ? 's' : ''} attached</span> <div className="flex items-center gap-1.5 text-xs text-primary-foreground/80">
</div> <ImageIcon className="w-3 h-3" />
<div className="flex flex-wrap gap-2"> <span>
{message.images.map((image, index) => { {message.images.length} image
// Construct proper data URL from base64 data and mime type {message.images.length > 1 ? "s" : ""} attached
const dataUrl = image.data.startsWith('data:') </span>
? image.data </div>
: `data:${image.mimeType || 'image/png'};base64,${image.data}`; <div className="flex flex-wrap gap-2">
return ( {message.images.map((image, index) => {
<div // Construct proper data URL from base64 data and mime type
key={image.id || `img-${index}`} const dataUrl = image.data.startsWith("data:")
className="relative group rounded-lg overflow-hidden border border-primary-foreground/20 bg-primary-foreground/10" ? image.data
> : `data:${image.mimeType || "image/png"};base64,${
<img image.data
src={dataUrl} }`;
alt={image.filename || `Attached image ${index + 1}`} return (
className="w-20 h-20 object-cover cursor-pointer hover:opacity-90 transition-opacity" <div
onClick={(e) => { key={image.id || `img-${index}`}
e.stopPropagation(); className="relative group rounded-lg overflow-hidden border border-primary-foreground/20 bg-primary-foreground/10"
// Open image in a larger view (could be enhanced with a modal) >
window.open(dataUrl, '_blank'); <img
}} src={dataUrl}
/> alt={
<div className="absolute bottom-0 left-0 right-0 bg-black/50 px-1.5 py-0.5 text-[9px] text-white truncate"> image.filename ||
{image.filename || `Image ${index + 1}`} `Attached image ${index + 1}`
}
className="w-20 h-20 object-cover hover:opacity-90 transition-opacity"
/>
<div className="absolute bottom-0 left-0 right-0 bg-black/50 px-1.5 py-0.5 text-[9px] text-white truncate">
{image.filename || `Image ${index + 1}`}
</div>
</div> </div>
</div> );
); })}
})} </div>
</div> </div>
</div> )}
)}
<p <p
className={cn( className={cn(
@@ -654,9 +672,18 @@ export function AgentView() {
<div className="bg-card border border-border rounded-2xl px-4 py-3 shadow-sm"> <div className="bg-card border border-border rounded-2xl px-4 py-3 shadow-sm">
<div className="flex items-center gap-3"> <div className="flex items-center gap-3">
<div className="flex items-center gap-1"> <div className="flex items-center gap-1">
<span className="w-2 h-2 rounded-full bg-primary animate-pulse" style={{ animationDelay: "0ms" }} /> <span
<span className="w-2 h-2 rounded-full bg-primary animate-pulse" style={{ animationDelay: "150ms" }} /> className="w-2 h-2 rounded-full bg-primary animate-pulse"
<span className="w-2 h-2 rounded-full bg-primary animate-pulse" style={{ animationDelay: "300ms" }} /> style={{ animationDelay: "0ms" }}
/>
<span
className="w-2 h-2 rounded-full bg-primary animate-pulse"
style={{ animationDelay: "150ms" }}
/>
<span
className="w-2 h-2 rounded-full bg-primary animate-pulse"
style={{ animationDelay: "300ms" }}
/>
</div> </div>
<span className="text-sm text-muted-foreground"> <span className="text-sm text-muted-foreground">
Thinking... Thinking...
@@ -773,7 +800,8 @@ export function AgentView() {
/> />
{selectedImages.length > 0 && !isDragOver && ( {selectedImages.length > 0 && !isDragOver && (
<div className="absolute right-3 top-1/2 -translate-y-1/2 text-xs bg-primary text-primary-foreground px-2 py-0.5 rounded-full font-medium"> <div className="absolute right-3 top-1/2 -translate-y-1/2 text-xs bg-primary text-primary-foreground px-2 py-0.5 rounded-full font-medium">
{selectedImages.length} image{selectedImages.length > 1 ? "s" : ""} {selectedImages.length} image
{selectedImages.length > 1 ? "s" : ""}
</div> </div>
)} )}
{isDragOver && ( {isDragOver && (
@@ -792,7 +820,8 @@ export function AgentView() {
disabled={isProcessing || !isConnected} disabled={isProcessing || !isConnected}
className={cn( className={cn(
"h-11 w-11 rounded-xl border-border", "h-11 w-11 rounded-xl border-border",
showImageDropZone && "bg-primary/10 text-primary border-primary/30", showImageDropZone &&
"bg-primary/10 text-primary border-primary/30",
selectedImages.length > 0 && "border-primary/30 text-primary" selectedImages.length > 0 && "border-primary/30 text-primary"
)} )}
title="Attach images" title="Attach images"
@@ -817,7 +846,11 @@ export function AgentView() {
{/* Keyboard hint */} {/* Keyboard hint */}
<p className="text-[11px] text-muted-foreground mt-2 text-center"> <p className="text-[11px] text-muted-foreground mt-2 text-center">
Press <kbd className="px-1.5 py-0.5 bg-muted rounded text-[10px] font-medium">Enter</kbd> to send Press{" "}
<kbd className="px-1.5 py-0.5 bg-muted rounded text-[10px] font-medium">
Enter
</kbd>{" "}
to send
</p> </p>
</div> </div>
)} )}