The scheduler AI dock read the poll envelope as the job, so every answer hung on thinking

This commit is contained in:
Gmer4Lfe
2026-08-06 18:28:13 -04:00
parent 269ef9b2de
commit e467cdaf23
2 changed files with 16 additions and 8 deletions
+7 -3
View File
@@ -2429,11 +2429,15 @@ function vvAiDockSend() {
}).catch(e => vvAiDockDone('Request failed: ' + e, true));
}
function vvAiDockPoll(token) {
function vvAiDockPoll(token, started) {
started = started || Date.now();
clearTimeout(vvAiPoll);
if (Date.now() - started > 300000) return vvAiDockDone('Timed out waiting for a response.', true);
vvAiPoll = setTimeout(() => {
fetch('/plugins/varaverk/api/ai.php?action=poll&token=' + encodeURIComponent(token))
.then(r => r.json()).then(j => {
.then(r => r.json()).then(d => {
if (!d.ok) return vvAiDockDone(d.error || 'Poll failed', true);
const j = d.job || {};
if (j.status === 'done') {
vvAiHist.push({ role: 'assistant', content: j.answer || '' });
vvAiDockDone(j.answer || '(empty answer)', false, j.sources || []);
@@ -2443,7 +2447,7 @@ function vvAiDockPoll(token) {
return;
}
if (j.status === 'error') return vvAiDockDone(j.error || 'Unknown error', true);
vvAiDockPoll(token);
vvAiDockPoll(token, started);
}).catch(e => vvAiDockDone('Poll failed: ' + e, true));
}, 1000);
}