(mode)
| 4833 | if (token !== state.chatLoadToken) return; |
| 4834 | if (!data.session) throw new Error(ui().chat.missingSession); |
| 4835 | state.chatSessionId = data.session.session_id || normalizedSessionId; |
| 4836 | renderChatMessages(data.messages || []); |
| 4837 | renderChatHistory({ sessions: state.chatHistory, groups: state.chatHistoryGroups }); |
| 4838 | } |
| 4839 | |
| 4840 | async function clearChatHistory() { |
| 4841 | const count = state.chatHistory.length; |
| 4842 | if (!count) { |
| 4843 | showFeedbackToast("warning", ui().chat.noHistoryTitle, ui().chat.noHistoryDetail); |
| 4844 | return; |
| 4845 | } |
| 4846 | const confirmed = window.confirm(ui().chat.clearConfirm(count)); |
| 4847 | if (!confirmed) return; |
| 4848 | const data = await api("/api/chat/sessions/clear", { |
| 4849 | method: "POST", |
| 4850 | body: JSON.stringify({ user_id: currentUser() }) |
| 4851 | }); |
| 4852 | state.chatSessionId = ""; |
no test coverage detected