From d3d6f30f728721a8a0859026fec7d5397d5a9c93 Mon Sep 17 00:00:00 2001 From: Gmer4Lfe Date: Mon, 17 Aug 2026 15:43:50 -0400 Subject: [PATCH] Load Last checkbox in the chat header, remembered per placement MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Defaults on and is read before the resume fetch — an unchecked box has to prevent the load, not undo it once the thread is already on screen. --- Plugin/unraid/include/ai_chat.php | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/Plugin/unraid/include/ai_chat.php b/Plugin/unraid/include/ai_chat.php index 9ee3886..7b58647 100644 --- a/Plugin/unraid/include/ai_chat.php +++ b/Plugin/unraid/include/ai_chat.php @@ -899,6 +899,9 @@ vv_ai_profiles_script(); } const SEE_THINK_KEY = 'vvAiSeeThink:' + P; + // Per instance, like the reasoning key beside it: the Monitor card and a tab's assistant are + // opened for different reasons and should not share one answer to "pick up where I left off". + const RESUME_KEY = 'vvAiResume:' + P; const seeThink = () => { const c = $('see-think'); return !!c && c.checked; }; // Paths ride in data attributes rather than an onclick. They come out of the index, and a @@ -2056,7 +2059,20 @@ vv_ai_profiles_script(); // // Silent on failure. Nothing here is worth an error message: the fallback is the empty box // the operator would otherwise have got, and an empty box is a working chat. - if (store && o.resume !== false) { + // The checkbox decides, and it defaults ON — an unset key means a first visit, not a refusal. + // Read here rather than from the element, because construction runs before the header is + // wired and an unchecked box must prevent the fetch, not undo it afterwards. + let _resumeWanted = true; + try { _resumeWanted = localStorage.getItem(RESUME_KEY) !== '0'; } catch (_) {} + const resumeEl = $('resume'); + if (resumeEl) { + resumeEl.checked = _resumeWanted; + resumeEl.addEventListener('change', () => { + try { localStorage.setItem(RESUME_KEY, resumeEl.checked ? '1' : '0'); } catch (_) {} + }); + } + + if (store && o.resume !== false && _resumeWanted) { fetch(API + '?action=chats').then(r => r.json()).then(d => { if (!d.ok || !(d.chats || []).length) return; // Do not clobber a conversation the operator has already started. The list arrives after @@ -2307,6 +2323,12 @@ function vv_ai_chat_markup(string $prefix, array $o = []): void { + +