Skip to content
Merged
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
32 changes: 15 additions & 17 deletions client/src/components/ChatToggleButton.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useState, useRef, useEffect } from 'react';
import { useState, useRef } from 'react';

interface ChatToggleButtonProps {
isOpen: boolean;
Expand All @@ -9,7 +9,20 @@ const STORAGE_KEY = 'neura-chat-btn-pos';

function ChatToggleButton({ isOpen, onToggle }: ChatToggleButtonProps) {
const [position, setPosition] = useState<{ x: number; y: number } | null>(
null,
() => {
try {
const saved = localStorage.getItem(STORAGE_KEY);
if (saved) {
const parsed = JSON.parse(saved);
if (typeof parsed.x === 'number' && typeof parsed.y === 'number') {
return parsed;
}
}
} catch {
// ignore parse errors
}
return null;
},
);

// Drag state stored in refs to avoid re-renders during drag
Expand All @@ -21,21 +34,6 @@ function ChatToggleButton({ isOpen, onToggle }: ChatToggleButtonProps) {
currentY: number;
}>({ startX: 0, startY: 0, isDragging: false, currentX: 0, currentY: 0 });

// Restore position from localStorage on mount
useEffect(() => {
try {
const saved = localStorage.getItem(STORAGE_KEY);
if (saved) {
const parsed = JSON.parse(saved);
if (typeof parsed.x === 'number' && typeof parsed.y === 'number') {
setPosition(parsed);
}
}
} catch {
// ignore parse errors
}
}, []);

const handlePointerDown = (e: React.PointerEvent<HTMLButtonElement>) => {
e.currentTarget.setPointerCapture(e.pointerId);
dragRef.current = {
Expand Down
2 changes: 2 additions & 0 deletions client/src/components/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ const Login = () => {
type="email"
className="bg-neutral-800 border border-gray-700 rounded-lg px-4 py-3 text-white focus:ring-2 focus:ring-blue-500 outline-none transition"
required
autoComplete="email"
autoFocus
/>
</div>
Expand All @@ -75,6 +76,7 @@ const Login = () => {
type="password"
className="bg-neutral-800 border border-gray-700 rounded-lg px-4 py-3 text-white focus:ring-2 focus:ring-blue-500 outline-none transition"
required
autoComplete="current-password"
/>
</div>

Expand Down
Loading
Loading