fixed injection watcher
This commit is contained in:
@@ -41,7 +41,10 @@
|
||||
.app-main {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
overflow: hidden;
|
||||
overflow-x: hidden;
|
||||
overflow-y: auto;
|
||||
-webkit-overflow-scrolling: touch;
|
||||
overscroll-behavior: contain;
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
|
||||
@@ -179,6 +179,14 @@
|
||||
font-size: 0.92rem;
|
||||
}
|
||||
|
||||
.message-error {
|
||||
align-self: center;
|
||||
max-width: 92%;
|
||||
background: #2a1a1a;
|
||||
border: 1px solid #5a2a2a;
|
||||
color: #f0b0b0;
|
||||
}
|
||||
|
||||
.message-role {
|
||||
font-size: 0.75rem;
|
||||
color: #8b95a5;
|
||||
|
||||
@@ -42,6 +42,7 @@ export default function Chat() {
|
||||
"thinking",
|
||||
);
|
||||
const [liveNotices, setLiveNotices] = useState<string[]>([]);
|
||||
const [chatError, setChatError] = useState<string | null>(null);
|
||||
const messagesRef = useRef<HTMLDivElement>(null);
|
||||
const inputRef = useRef<HTMLTextAreaElement>(null);
|
||||
const scrollRafRef = useRef<number | null>(null);
|
||||
@@ -93,7 +94,7 @@ export default function Chat() {
|
||||
cancelAnimationFrame(scrollRafRef.current);
|
||||
}
|
||||
};
|
||||
}, [messages, streaming, liveNotices, loading, scrollToBottom]);
|
||||
}, [messages, streaming, liveNotices, loading, chatError, scrollToBottom]);
|
||||
|
||||
const dismissKeyboard = useCallback(() => {
|
||||
inputRef.current?.blur();
|
||||
@@ -151,6 +152,7 @@ export default function Chat() {
|
||||
setStreaming("");
|
||||
setPendingPhase("thinking");
|
||||
setLiveNotices([]);
|
||||
setChatError(null);
|
||||
|
||||
const tempUser: ChatMessage = {
|
||||
id: Date.now(),
|
||||
@@ -187,6 +189,7 @@ export default function Chat() {
|
||||
if (chunk.event === "done") {
|
||||
setStreaming("");
|
||||
setLiveNotices([]);
|
||||
setChatError(null);
|
||||
setLoading(false);
|
||||
if (assistantText.trim()) {
|
||||
setMessages((prev) => [
|
||||
@@ -208,8 +211,9 @@ export default function Chat() {
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
const message = err instanceof Error ? err.message : "Ошибка чата";
|
||||
setChatError(message);
|
||||
setStreaming("");
|
||||
setLiveNotices([]);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
@@ -310,6 +314,13 @@ export default function Chat() {
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{chatError && (
|
||||
<div className="message message-error" role="alert">
|
||||
<div className="message-role">ошибка</div>
|
||||
<div className="message-content">{chatError}</div>
|
||||
</div>
|
||||
)}
|
||||
<div className="messages-bottom-anchor" aria-hidden="true" />
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user