At full size the dock's own button becomes its collapse, and closing hands the panel back
This commit is contained in:
@@ -2387,28 +2387,43 @@ function vvAiDockAppend(html) {
|
|||||||
function vvAiDockExpand() {
|
function vvAiDockExpand() {
|
||||||
document.getElementById('vv-ai-dock-body').style.display = '';
|
document.getElementById('vv-ai-dock-body').style.display = '';
|
||||||
document.getElementById('vv-ai-dock-hide').style.display = '';
|
document.getElementById('vv-ai-dock-hide').style.display = '';
|
||||||
|
vvAiDockApplyGrow();
|
||||||
requestAnimationFrame(vvFitRight);
|
requestAnimationFrame(vvFitRight);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Trades panel space between the conversation and whatever is above it. Separate from collapse,
|
// One control, two jobs, decided by what is on screen: grow the conversation, or — once it is
|
||||||
// which is all-or-nothing: this is for reading a long answer without losing sight of the log.
|
// 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() {
|
function vvAiDockGrow() {
|
||||||
vvAiDockBig = !vvAiDockBig;
|
const open = vvAiDockBodyOpen();
|
||||||
|
vvAiDockBig = !(vvAiDockBig && open);
|
||||||
localStorage.setItem('vv-ai-dock-big', vvAiDockBig ? '1' : '0');
|
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();
|
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() {
|
function vvAiDockApplyGrow() {
|
||||||
const b = document.getElementById('vv-ai-dock-grow');
|
const b = document.getElementById('vv-ai-dock-grow');
|
||||||
if (!b) return;
|
if (!b) return;
|
||||||
b.textContent = vvAiDockBig ? '⤡' : '⤢';
|
const collapses = vvAiDockBig && vvAiDockBodyOpen();
|
||||||
b.title = vvAiDockBig ? 'Give the panel back to the view above'
|
b.textContent = collapses ? '▾' : '⤢';
|
||||||
|
b.title = collapses ? 'Collapse — the conversation is kept'
|
||||||
: 'Give the conversation more of the panel';
|
: 'Give the conversation more of the panel';
|
||||||
b.classList.toggle('vv-ai-dock-grow-on', vvAiDockBig);
|
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
|
// 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() {
|
function vvAiDockCollapse() {
|
||||||
document.getElementById('vv-ai-dock-body').style.display = 'none';
|
document.getElementById('vv-ai-dock-body').style.display = 'none';
|
||||||
document.getElementById('vv-ai-dock-hide').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);
|
requestAnimationFrame(vvFitRight);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user