Put the Scheduler dock on the same conversation store as everything else

This commit is contained in:
Gmer4Lfe
2026-08-09 00:16:09 -04:00
parent f4fd17be4d
commit 073352b21e
4 changed files with 105 additions and 9 deletions
+25 -1
View File
@@ -65,6 +65,9 @@
require_once dirname(__DIR__) . '/include/scheduler.php';
require_once dirname(__DIR__) . '/include/docs.php';
require_once dirname(__DIR__) . '/include/ai_profiles.php';
// For vv_ai_chat_store_script() only — this page renders no chat widget. The store is shared;
// the presentation deliberately is not.
require_once dirname(__DIR__) . '/include/ai_chat.php';
// Live values for the `$VAR` markers in pages/readme/*.md. Conf variables, plus the derived
// path constants — those are not conf keys, but they are exactly what a reader needs resolved
@@ -1060,7 +1063,13 @@ Still the same two servers, two households, the same media stack running itself.
At rest it is one input row. Answers expand it upward and the views above shrink to
suit, which is why vvFitRight() subtracts its height. It pushes rather than overlays
so the thing you are asking about stays on screen. Collapsing keeps the conversation. -->
<?php vv_ai_profiles_script(); ?>
<?php
// The registry and the conversation store — not the chat widget. This dock draws its own
// bar and must keep looking like itself; what it must not have is its own answer to where
// a conversation lives.
vv_ai_profiles_script();
vv_ai_chat_store_script();
?>
<div id="vv-ai-dock">
<div id="vv-ai-dock-body" style="display:none"></div>
<div id="vv-ai-dock-bar">
@@ -2350,6 +2359,7 @@ function vvClickCog(el) {
let vvAiProfile = 'varaverk';
let vvAiScope = 'Scheduler';
let vvAiHist = []; // what the model is told; reset when the scope changes
let vvAiChatId = ""; // the stored conversation this thread is appending to
let vvAiBusy = false;
let vvAiPoll = null;
@@ -2381,6 +2391,10 @@ function vvAiDockScope(profile, label, target) {
// question about a conf key, but hiding that the earlier exchange happened is worse.
if (had) {
vvAiHist = [];
// A new stored conversation too, not a continuation of the last one. The scope is part of
// the record, so appending turns about a different thing to the same row would produce a
// conversation whose stored scope describes only its first half.
vvAiChatId = '';
vvAiDockAppend('<div class="vv-ai-dock-sep">now looking at ' + vvEscHtml(label) + '</div>');
}
// The scope moved under text already typed. Not blocked — just never silent.
@@ -2564,6 +2578,16 @@ function vvAiDockPoll(token, started) {
if (j.status === 'done') {
vvAiHist.push({ role: 'assistant', content: j.answer || '' });
vvAiDockDone(j.answer || '(empty answer)', false, j.sources || []);
// Same store as the AI tab and the Monitor row, through the same writer. This dock
// kept its conversation in a JavaScript array and nothing else, so a thread died on
// reload — including the troubleshooting ones, which are the most expensive to have
// had and the most annoying to lose. The scope goes with it so reopening the thread
// restores what it was reasoned about rather than continuing it against whatever
// happens to be on screen.
if (window.VvAiChatSave) {
window.VvAiChatSave(vvAiHist, vvAiProfile, vvAiScope, vvAiChatId)
.then(id => { if (id) vvAiChatId = id; });
}
fetch('/plugins/varaverk/api/ai.php', { method: 'POST',
headers: { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8' },
body: new URLSearchParams({ action: 'clear', token }) }).catch(() => {});