diff options
Diffstat (limited to 'modules/core/core-bundle.js')
| -rw-r--r-- | modules/core/core-bundle.js | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/modules/core/core-bundle.js b/modules/core/core-bundle.js index a689774..697b5ec 100644 --- a/modules/core/core-bundle.js +++ b/modules/core/core-bundle.js @@ -11094,19 +11094,29 @@ buildSystemPrompt() { }); } const st = ds._chatThread(); + // v4.6.76: a SEPARATE cursor from the terminal display. The UI poller + // runs every 30 s and advances the shared cursor, so a read that used it + // returned nothing — the answer was printed for the human and the model + // never saw it. Two readers, two cursors. First read is from 0. + let ac = 0; + try { ac = parseInt(localStorage.getItem('webx11_chat_agent_cursor') || '0', 10) || 0; } catch (e) { ac = 0; } const resp = await fetch( - '/spaces/newos4/api/chat/poll.php' + (st.cursor ? '?since=' + st.cursor : ''), + '/spaces/newos4/api/chat/poll.php' + (ac ? '?since=' + ac : ''), { headers: { 'X-Chat-Token': st.token } }); const j = await resp.json().catch(() => null); if (!resp.ok || !j || !j.success) { return JSON.stringify({ error: (j && j.error) || ('HTTP ' + resp.status) }); } - if (j.cursor) ds._chatSaveState({ token: st.token, cursor: j.cursor, thread: j.thread || '' }); + if (j.cursor) { try { localStorage.setItem('webx11_chat_agent_cursor', String(j.cursor)); } catch (e) {} } + const msgs = (j.messages || []).slice(-10).map(m => ({ + author: m.author, ts: m.ts, text: m.text + })); return JSON.stringify({ awaiting: j.awaiting, - messages: (j.messages || []).slice(-10).map(m => ({ - author: m.author, ts: m.ts, text: m.text - })) + messages: msgs, + note: msgs.length ? undefined + : (j.awaiting ? 'no reply yet — still awaiting Hermes' + : 'no new messages since your last read') }); } catch (e) { return JSON.stringify({ error: e.message }); |