Files
Jyotisha/frontend/src/hooks/use-queued-message.ts
T
Jesse_ChenandCursor 055b7adca9 fix(web): keep composer enabled while generating and treat stop as neutral (BUG-551, BUG-552)
Enter now queues one follow-up instead of dropping it, and a rectification stop leaves the streamed reply with a grey notice instead of an error alert.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-06 13:08:43 +08:00

29 lines
719 B
TypeScript

"use client";
import { useCallback, useRef, useState } from "react";
import { appendQueuedText } from "@/lib/queued-draft";
export function useQueuedMessage() {
const [text, setText] = useState("");
const textRef = useRef("");
const enqueue = useCallback((incoming: string) => {
const nextIncoming = incoming.trim();
if (!nextIncoming) return false;
const next = appendQueuedText(textRef.current, nextIncoming);
textRef.current = next;
setText(next);
return true;
}, []);
const take = useCallback(() => {
const current = textRef.current;
if (!current) return "";
textRef.current = "";
setText("");
return current;
}, []);
return { text, enqueue, take };
}