Add drag-resizable sidebar/chat separator to the web GUI

Desktop-only (>=900px) pointer-drag splitter between the session list and the chat; width clamped (200px..min(480, 50% viewport)) and persisted in localStorage; keyboard arrows + ARIA separator role; hover/focus highlight. README updated. Web assets only; suite unchanged (94 green + 2 ignored), clippy/fmt clean.
This commit is contained in:
adm committed 2026-11-24 20:57:59 +01:00
1 parent 1e13caa4ed
commit e29878bb3d
4 files changed
+67 -2

No files matched your search

+15
View File
@@ -74,6 +74,9 @@ html, body {
#scrim {
position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 20;
}
/* Resizable sidebar/chat separator: desktop only (mobile uses a drawer). */
#splitter { display: none; }
body.resizing { cursor: col-resize; user-select: none; }
.drawer-head {
display: flex; align-items: center; justify-content: space-between;
gap: 8px; padding: 12px;
@@ -171,4 +174,16 @@ details.thinking .reasoning {
#scrim { display: none !important; }
#menu { display: none; }
.msg.user .bubble { max-width: 70%; }
#splitter {
display: block; flex: 0 0 6px; width: 6px; cursor: col-resize;
position: relative; background: transparent; touch-action: none;
}
#splitter::after {
content: ""; position: absolute; top: 0; bottom: 0; left: 2px; width: 2px;
background: var(--border); transition: background 0.12s ease;
}
#splitter:hover::after, #splitter:focus-visible::after, body.resizing #splitter::after {
background: var(--accent);
}
#splitter:focus-visible { outline: none; }
}
+48
View File
@@ -236,7 +236,55 @@ function autoGrow(t) {
t.style.height = Math.min(t.scrollHeight, window.innerHeight * 0.4) + "px";
}
// ---- Resizable sidebar/chat separator (desktop only) ----------------------
function initSplitter() {
const splitter = $("#splitter");
const root = document.documentElement;
const width = () =>
parseInt(getComputedStyle(root).getPropertyValue("--sidebar-w")) || 280;
const apply = (w) => {
const max = Math.min(480, Math.floor(window.innerWidth * 0.5));
w = Math.max(200, Math.min(max, w));
root.style.setProperty("--sidebar-w", w + "px");
splitter.setAttribute("aria-valuenow", String(w));
return w;
};
const save = () => {
try { localStorage.setItem("sidebarW", String(width())); } catch { /* private mode */ }
};
let dragging = false, startX = 0, startW = 0;
splitter.addEventListener("pointerdown", (e) => {
dragging = true; startX = e.clientX; startW = width();
splitter.setPointerCapture(e.pointerId);
document.body.classList.add("resizing");
e.preventDefault();
});
splitter.addEventListener("pointermove", (e) => {
if (dragging) apply(startW + (e.clientX - startX));
});
const end = () => {
if (!dragging) return;
dragging = false;
document.body.classList.remove("resizing");
save();
};
splitter.addEventListener("pointerup", end);
splitter.addEventListener("pointercancel", end);
splitter.addEventListener("keydown", (e) => {
if (e.key === "ArrowLeft") apply(width() - 16);
else if (e.key === "ArrowRight") apply(width() + 16);
else return;
e.preventDefault(); save();
});
try {
const w = localStorage.getItem("sidebarW");
if (w) apply(parseInt(w));
} catch { /* private mode */ }
}
function wire() {
initSplitter();
$("#menu").addEventListener("click", openDrawer);
$("#scrim").addEventListener("click", closeDrawer);
$("#new-session").addEventListener("click", newSession);