mirror of
https://github.com/AmruthPillai/Reactive-Resume.git
synced 2026-07-27 10:24:48 +10:00
chore: polish ai chat interactions
Co-authored-by: amruthpillai <1134738+amruthpillai@users.noreply.github.com>
This commit is contained in:
@@ -29,6 +29,8 @@ type AIChatResponse = {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const FAB_TIMEOUT_MS = 60_000;
|
||||||
|
|
||||||
export function AIChatPanel() {
|
export function AIChatPanel() {
|
||||||
const aiEnabled = useAIStore((state) => state.enabled);
|
const aiEnabled = useAIStore((state) => state.enabled);
|
||||||
const aiConfig = useAIStore((state) => ({
|
const aiConfig = useAIStore((state) => ({
|
||||||
@@ -41,7 +43,7 @@ export function AIChatPanel() {
|
|||||||
const { resumeId } = useParams({ from: "/builder/$resumeId" });
|
const { resumeId } = useParams({ from: "/builder/$resumeId" });
|
||||||
const updateResumeData = useResumeStore((state) => state.updateResumeData);
|
const updateResumeData = useResumeStore((state) => state.updateResumeData);
|
||||||
|
|
||||||
const { isOpen, fabVisible, lastInteraction, messages, toggle, open, close, hideFab, addMessage, touch } =
|
const { isOpen, fabVisible, lastInteraction, messages, toggle, close, hideFab, addMessage, touch } =
|
||||||
useAIChatStore();
|
useAIChatStore();
|
||||||
|
|
||||||
const [input, setInput] = useState("");
|
const [input, setInput] = useState("");
|
||||||
@@ -76,7 +78,7 @@ export function AIChatPanel() {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!fabVisible || isOpen) return;
|
if (!fabVisible || isOpen) return;
|
||||||
const last = lastInteraction ?? Date.now();
|
const last = lastInteraction ?? Date.now();
|
||||||
const remaining = Math.max(0, 60_000 - (Date.now() - last));
|
const remaining = Math.max(0, FAB_TIMEOUT_MS - (Date.now() - last));
|
||||||
const timer = setTimeout(() => {
|
const timer = setTimeout(() => {
|
||||||
if (!useAIChatStore.getState().isOpen) hideFab();
|
if (!useAIChatStore.getState().isOpen) hideFab();
|
||||||
}, remaining);
|
}, remaining);
|
||||||
@@ -173,7 +175,7 @@ export function AIChatPanel() {
|
|||||||
>
|
>
|
||||||
<Button
|
<Button
|
||||||
size="icon"
|
size="icon"
|
||||||
variant="default"
|
variant="default"
|
||||||
className="pointer-events-auto shadow-lg"
|
className="pointer-events-auto shadow-lg"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
toggle();
|
toggle();
|
||||||
@@ -184,20 +186,6 @@ export function AIChatPanel() {
|
|||||||
</Button>
|
</Button>
|
||||||
</motion.div>
|
</motion.div>
|
||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
{!fabVisible && (
|
|
||||||
<Button
|
|
||||||
className="hidden"
|
|
||||||
variant="ghost"
|
|
||||||
size="icon"
|
|
||||||
onClick={() => {
|
|
||||||
open();
|
|
||||||
touch();
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<SparkleIcon />
|
|
||||||
</Button>
|
|
||||||
)}
|
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,10 @@ type AIChatActions = {
|
|||||||
|
|
||||||
type AIChatStore = AIChatState & AIChatActions;
|
type AIChatStore = AIChatState & AIChatActions;
|
||||||
|
|
||||||
const createId = () => (crypto.randomUUID ? crypto.randomUUID() : Math.random().toString(36).slice(2));
|
const createId = () =>
|
||||||
|
typeof crypto !== "undefined" && crypto.randomUUID
|
||||||
|
? crypto.randomUUID()
|
||||||
|
: `${Date.now()}-${Math.random().toString(36).slice(2)}`;
|
||||||
|
|
||||||
const initialMessages: AIChatMessage[] = [
|
const initialMessages: AIChatMessage[] = [
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user