Load Last checkbox in the chat header, remembered per placement

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.
This commit is contained in:
Gmer4Lfe
2026-08-17 15:43:50 -04:00
parent 99c94ffaec
commit d3d6f30f72
+23 -1
View File
@@ -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 {
<label class="vv-ai-cb" title="Show the model's reasoning as it is written, not after">
<input type="checkbox" id="<?= $p ?>-see-think"> <span>Reasoning</span>
</label>
<!-- Governs the NEXT open, not this one: by the time it can be clicked the thread it would
have resumed is already on screen. The title says so, because a checkbox that appears
to do nothing when ticked is worse than no checkbox. -->
<label class="vv-ai-cb" title="Reopen this card on your last conversation. Applies next time the page loads.">
<input type="checkbox" id="<?= $p ?>-resume" checked> <span>Load Last</span>
</label>
<label class="vv-ai-cb" title="Follow the newest line. Unticks when you scroll up, re-ticks at the bottom.">
<input type="checkbox" id="<?= $p ?>-follow" checked> <span>Auto Scroll</span>
</label>