kin: KIN-UI-007 Scroll to bottom при получении новых сообщений через polling

This commit is contained in:
Gros Frumos 2026-03-16 19:41:38 +02:00
parent 98d62266ba
commit bd9fbfbbcb
2 changed files with 21 additions and 2 deletions

View file

@ -12,6 +12,7 @@ const input = ref('')
const sending = ref(false)
const loading = ref(true)
const error = ref('')
const consecutiveErrors = ref(0)
const projectName = ref('')
const messagesEl = ref<HTMLElement | null>(null)
@ -37,8 +38,17 @@ function checkAndPoll() {
try {
const updated = await api.chatHistory(props.projectId)
messages.value = updated
consecutiveErrors.value = 0
error.value = ''
if (!hasRunningTasks(updated)) stopPoll()
} catch {}
} catch (e: any) {
consecutiveErrors.value++
console.warn(`[polling] ошибка #${consecutiveErrors.value}:`, e)
if (consecutiveErrors.value >= 3) {
error.value = 'Сервер недоступен. Проверьте подключение.'
stopPoll()
}
}
}, 3000)
}
@ -46,6 +56,7 @@ async function load() {
stopPoll()
loading.value = true
error.value = ''
consecutiveErrors.value = 0
try {
const [msgs, project] = await Promise.all([
api.chatHistory(props.projectId),