At full size the dock's own button becomes its collapse, and closing hands the panel back

This commit is contained in:
Gmer4Lfe
2026-08-06 22:49:38 -04:00
parent b803fefebd
commit 141e2ca37c
+31 -11
View File
@@ -2387,28 +2387,43 @@ function vvAiDockAppend(html) {
function vvAiDockExpand() {
document.getElementById('vv-ai-dock-body').style.display = '';
document.getElementById('vv-ai-dock-hide').style.display = '';
vvAiDockApplyGrow();
requestAnimationFrame(vvFitRight);
}
// Trades panel space between the conversation and whatever is above it. Separate from collapse,
// which is all-or-nothing: this is for reading a long answer without losing sight of the log.
// One control, two jobs, decided by what is on screen: grow the conversation, or — once it is
// already holding the panel — close it. A dedicated shrink-back would be a third state nobody
// asked for; at full size the only thing left to want is the view above.
//
// Closing from expanded also gives the size back. Without that, 82% is a one-way door: the next
// question reopens at 82%, the button is a collapse again, and nothing ever restores the 40%.
function vvAiDockGrow() {
vvAiDockBig = !vvAiDockBig;
const open = vvAiDockBodyOpen();
vvAiDockBig = !(vvAiDockBig && open);
localStorage.setItem('vv-ai-dock-big', vvAiDockBig ? '1' : '0');
vvAiDockApplyGrow();
// Growing a hidden conversation would look like the button did nothing, so opening it is part
// of growing. Shrinking deliberately does not collapse — that is what the ▾ button is for.
if (vvAiDockBig) vvAiDockExpand();
else requestAnimationFrame(vvFitRight);
else vvAiDockCollapse();
}
function vvAiDockBodyOpen() {
const b = document.getElementById('vv-ai-dock-body');
return !!b && b.style.display !== 'none';
}
// Called by expand and collapse as well as on load, so the button always describes the action it
// will actually perform. A stored "expanded" preference with the conversation shut still reads as
// grow — collapsing something already closed is not an action worth offering.
function vvAiDockApplyGrow() {
const b = document.getElementById('vv-ai-dock-grow');
if (!b) return;
b.textContent = vvAiDockBig ? '⤡' : '⤢';
b.title = vvAiDockBig ? 'Give the panel back to the view above'
: 'Give the conversation more of the panel';
b.classList.toggle('vv-ai-dock-grow-on', vvAiDockBig);
const collapses = vvAiDockBig && vvAiDockBodyOpen();
b.textContent = collapses ? '▾' : '⤢';
b.title = collapses ? 'Collapse — the conversation is kept'
: 'Give the conversation more of the panel';
b.classList.toggle('vv-ai-dock-grow-on', collapses);
// Two collapse buttons side by side is one too many. While this one collapses, the other hides.
const hide = document.getElementById('vv-ai-dock-hide');
if (hide && collapses) hide.style.display = 'none';
}
// Collapse is not clear. Re-expanding shows the same conversation, so you can shrink it to read
@@ -2416,6 +2431,11 @@ function vvAiDockApplyGrow() {
function vvAiDockCollapse() {
document.getElementById('vv-ai-dock-body').style.display = 'none';
document.getElementById('vv-ai-dock-hide').style.display = 'none';
// Closing hands the panel back, whichever button did it, so the next question opens at the
// ordinary size instead of inheriting a decision made about a different answer.
vvAiDockBig = false;
localStorage.setItem('vv-ai-dock-big', '0');
vvAiDockApplyGrow();
requestAnimationFrame(vvFitRight);
}