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:
1 parent
1e13caa4ed
commit
e29878bb3d
4 files changed
+67
-2
No files matched your search
@@ -92,8 +92,9 @@ under `/assets/...`, embedded via `rust-embed` — no Node, no build step, works
|
|||||||
offline, same-origin so no CORS). It is a thin client over a **session-aware API**:
|
offline, same-origin so no CORS). It is a thin client over a **session-aware API**:
|
||||||
|
|
||||||
- `GET /` — the chat shell (responsive: an off-canvas session drawer on phones, a
|
- `GET /` — the chat shell (responsive: an off-canvas session drawer on phones, a
|
||||||
persistent sidebar on wide screens; streaming answers with a collapsible
|
persistent sidebar on wide screens with a **drag-resizable separator** between the
|
||||||
"thinking" panel; touch-friendly targets and safe-area insets).
|
session list and the chat — width clamped and persisted; streaming answers with a
|
||||||
|
collapsible "thinking" panel; touch-friendly targets and safe-area insets).
|
||||||
- `POST /api/sessions`, `GET /api/sessions`, `GET/PATCH/DELETE /api/sessions/{id}`,
|
- `POST /api/sessions`, `GET /api/sessions`, `GET/PATCH/DELETE /api/sessions/{id}`,
|
||||||
`GET /api/sessions/{id}/messages` — session CRUD and history.
|
`GET /api/sessions/{id}/messages` — session CRUD and history.
|
||||||
- `POST /api/sessions/{id}/chat` — append a turn; the server loads the stored
|
- `POST /api/sessions/{id}/chat` — append a turn; the server loads the stored
|
||||||
|
|||||||
@@ -74,6 +74,9 @@ html, body {
|
|||||||
#scrim {
|
#scrim {
|
||||||
position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 20;
|
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 {
|
.drawer-head {
|
||||||
display: flex; align-items: center; justify-content: space-between;
|
display: flex; align-items: center; justify-content: space-between;
|
||||||
gap: 8px; padding: 12px;
|
gap: 8px; padding: 12px;
|
||||||
@@ -171,4 +174,16 @@ details.thinking .reasoning {
|
|||||||
#scrim { display: none !important; }
|
#scrim { display: none !important; }
|
||||||
#menu { display: none; }
|
#menu { display: none; }
|
||||||
.msg.user .bubble { max-width: 70%; }
|
.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; }
|
||||||
}
|
}
|
||||||
@@ -236,7 +236,55 @@ function autoGrow(t) {
|
|||||||
t.style.height = Math.min(t.scrollHeight, window.innerHeight * 0.4) + "px";
|
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() {
|
function wire() {
|
||||||
|
initSplitter();
|
||||||
$("#menu").addEventListener("click", openDrawer);
|
$("#menu").addEventListener("click", openDrawer);
|
||||||
$("#scrim").addEventListener("click", closeDrawer);
|
$("#scrim").addEventListener("click", closeDrawer);
|
||||||
$("#new-session").addEventListener("click", newSession);
|
$("#new-session").addEventListener("click", newSession);
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
<button id="show-stats" class="btn ghost">Statistiche</button>
|
<button id="show-stats" class="btn ghost">Statistiche</button>
|
||||||
</div>
|
</div>
|
||||||
</aside>
|
</aside>
|
||||||
|
<div id="splitter" role="separator" aria-orientation="vertical" aria-label="Ridimensiona l'elenco delle discussioni" aria-valuemin="200" aria-valuemax="480" aria-valuenow="280" tabindex="0"></div>
|
||||||
<div id="scrim" hidden></div>
|
<div id="scrim" hidden></div>
|
||||||
|
|
||||||
<!-- Main column -->
|
<!-- Main column -->
|
||||||
|
|||||||
Reference in new issue
Block a user