Spaces:
Sleeping
Sleeping
Commit Β·
c38084a
1
Parent(s): 3e085e1
fixes
Browse filesFiles changed (3)
- frontend/index.html+15-2
- frontend/script.js+83-8
- frontend/style.css+102
10 unmodified lines11121314151617142 unmodified lines16016116216316416520 unmodified lines18618718818919019110 unmodified linesif (t) document.documentElement.dataset.theme = t;})();</script><link rel="stylesheet" href="/static/style.css?v=12" /><script src="https://cdn.jsdelivr.net/npm/@supabase/supabase-js@2"></script><script src="https://cdn.jsdelivr.net/npm/pdfjs-dist@3.11.174/build/pdf.min.js"></script><script src="https://cdn.jsdelivr.net/npm/marked@12/marked.min.js"></script>142 unmodified lines</div><!-- ββ PDF reference preview modal ββ --><div class="pdf-modal hidden" id="pdfModal"><div class="pdf-modal-backdrop" id="pdfModalBackdrop"></div>20 unmodified lines</div></div><script src="/static/script.js?v=15"></script></body></html>10 unmodified lines11121314151617142 unmodified lines16016116216316416516616716816917017117217317417517617717820 unmodified lines19920020120220320410 unmodified linesif (t) document.documentElement.dataset.theme = t;})();</script><link rel="stylesheet" href="/static/style.css?v=14" /><script src="https://cdn.jsdelivr.net/npm/@supabase/supabase-js@2"></script><script src="https://cdn.jsdelivr.net/npm/pdfjs-dist@3.11.174/build/pdf.min.js"></script><script src="https://cdn.jsdelivr.net/npm/marked@12/marked.min.js"></script>142 unmodified lines</div><!-- ββ Confirmation modal ββ --><div class="confirm-modal hidden" id="confirmModal"><div class="confirm-backdrop" id="confirmBackdrop"></div><div class="confirm-card"><p class="confirm-text" id="confirmText">Are you sure?</p><div class="confirm-actions"><button type="button" class="confirm-btn cancel" id="confirmCancel">Cancel</button><button type="button" class="confirm-btn danger" id="confirmOk">Delete</button></div><p class="confirm-hint">Enter to confirm · Esc to cancel</p></div></div><!-- ββ PDF reference preview modal ββ --><div class="pdf-modal hidden" id="pdfModal"><div class="pdf-modal-backdrop" id="pdfModalBackdrop"></div>20 unmodified lines</div></div><script src="/static/script.js?v=17"></script></body></html>
520 unmodified lines52152252352452552652753 unmodified lines581582583584585586587588589590591592593594595596597598599600360 unmodified lines961962963964965966967520 unmodified linesren.className = 'session-ren';ren.innerHTML = '✎';ren.title = 'Rename conversation';ren.addEventListener('click', (e) => { e.stopPropagation(); startRename(li, s); });const del = document.createElement('button');del.className = 'session-del';53 unmodified linesquestionInput.focus();}async function deleteSession(sessionId) {if (!confirm('Delete this conversation? This cannot be undone.')) return;try {await authedFetch(`/sessions/${sessionId}`, { method: 'DELETE' });if (sessionId === currentSessionId) startNewChat();await loadSessions();} catch { /* ignore */ }}/* Inline rename: swap the title for an input; Enter/blur saves, Esc cancels */function startRename(li, s) {const titleSpan = li.querySelector('.session-title');if (!titleSpan) return;const input = document.createElement('input');input.type = 'text';input.className = 'session-rename-input';360 unmodified lines}async function deleteDocument(name, li) {if (!confirm(`Remove "${name}" and all of its content from the knowledge base?`)) return;li.style.opacity = '.4';try {const res = await authedFetch(`/documents/${encodeURIComponent(name)}`, { method: 'DELETE' });520 unmodified lines52152252352452552652752852953053153253 unmodified lines586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675360 unmodified lines1036103710381039104010411042520 unmodified linesren.className = 'session-ren';ren.innerHTML = '✎';ren.title = 'Rename conversation';ren.addEventListener('click', (e) => {e.stopPropagation();const editing = li.querySelector('.session-rename-input');if (editing) editing.blur(); // acting as the save (tick) buttonelse startRename(li, s);});const del = document.createElement('button');del.className = 'session-del';53 unmodified linesquestionInput.focus();}/* ββ Confirmation modal (Enter = confirm, Esc = cancel) ββ */const confirmModal = document.getElementById('confirmModal');const confirmBackdrop = document.getElementById('confirmBackdrop');const confirmText = document.getElementById('confirmText');const confirmOk = document.getElementById('confirmOk');const confirmCancel = document.getElementById('confirmCancel');function confirmDialog(text, okLabel = 'Delete') {return new Promise(resolve => {confirmText.textContent = text;confirmOk.textContent = okLabel;confirmModal.classList.remove('hidden');const done = (value) => {confirmModal.classList.add('hidden');document.removeEventListener('keydown', onKey, true);confirmOk.removeEventListener('click', ok);confirmCancel.removeEventListener('click', cancel);confirmBackdrop.removeEventListener('click', cancel);resolve(value);};const ok = () => done(true);const cancel = () => done(false);const onKey = (e) => {if (e.key === 'Enter') { e.preventDefault(); e.stopPropagation(); ok(); }else if (e.key === 'Escape') { e.preventDefault(); e.stopPropagation(); cancel(); }};confirmOk.addEventListener('click', ok);confirmCancel.addEventListener('click', cancel);confirmBackdrop.addEventListener('click', cancel);document.addEventListener('keydown', onKey, true);confirmOk.focus();});}/* Small transient notice (bottom center) */function showToast(text) {let t = document.getElementById('toast');if (!t) {t = document.createElement('div');t.id = 'toast';t.className = 'toast';document.body.appendChild(t);}t.textContent = text;t.classList.add('show');clearTimeout(showToast._timer);showToast._timer = setTimeout(() => t.classList.remove('show'), 3500);}async function deleteSession(sessionId) {if (!await confirmDialog('Delete this conversation? This cannot be undone.')) return;// Optimistic: remove from the sidebar immediately, roll back if the API failsconst li = sessionList.querySelector(`.session-item[data-id="${sessionId}"]`);if (li) li.remove();if (!sessionList.querySelector('.session-item')) {sessionList.innerHTML = '<li class="session-empty">No conversations yet</li>';}if (sessionId === currentSessionId) startNewChat();try {const res = await authedFetch(`/sessions/${sessionId}`, { method: 'DELETE' });if (!res.ok) throw new Error();} catch {await loadSessions(); // bring the conversation backshowToast('Could not delete the conversation β it has been restored.');}}/* Inline rename: swap the title for an input; Enter/blur/tick saves, Esc cancels */function startRename(li, s) {const titleSpan = li.querySelector('.session-title');if (!titleSpan) return;// The pencil becomes a tick (save) while editingconst ren = li.querySelector('.session-ren');if (ren) {ren.innerHTML = '✓';ren.title = 'Save name';ren.classList.add('confirming');}const input = document.createElement('input');input.type = 'text';input.className = 'session-rename-input';360 unmodified lines}async function deleteDocument(name, li) {if (!await confirmDialog(`Remove "${name}" and all of its content from the knowledge base?`, 'Remove')) return;li.style.opacity = '.4';try {const res = await authedFetch(`/documents/${encodeURIComponent(name)}`, { method: 'DELETE' });
864 unmodified lines865866867868869870196 unmodified lines106710681069107010711072864 unmodified lines}.auth-link:hover { color: var(--accent); }/* ββ Utility ββ */.hidden { display: none !important; }196 unmodified lines.session-del:hover { color: #ff9c9c; }.session-ren:hover { color: var(--accent); }.session-rename-input {flex: 1;min-width: 0;864 unmodified lines865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965196 unmodified lines1162116311641165116611671168116911701171117211731174864 unmodified lines}.auth-link:hover { color: var(--accent); }/* ββ Confirmation modal ββ */.confirm-modal {position: fixed;inset: 0;z-index: 80;display: flex;align-items: center;justify-content: center;padding: 20px;}.confirm-backdrop {position: absolute;inset: 0;background: rgba(0, 0, 0, .55);}.confirm-card {position: relative;width: 100%;max-width: 360px;background: var(--surface);border: 1px solid var(--border);border-radius: 16px;padding: 24px 22px 16px;box-shadow: 0 24px 60px rgba(0, 0, 0, .45);animation: msg-in .18s ease;}.confirm-text {font-size: .92rem;line-height: 1.55;word-break: break-word;}.confirm-actions {display: flex;justify-content: flex-end;gap: 10px;margin-top: 18px;}.confirm-btn {padding: 9px 18px;border-radius: 10px;font-size: .86rem;font-weight: 600;font-family: var(--font);cursor: pointer;transition: background .15s, border-color .15s;}.confirm-btn.cancel {background: var(--surface2);border: 1px solid var(--border);color: var(--text);}.confirm-btn.cancel:hover { border-color: var(--accent); }.confirm-btn.danger {background: #c0392b;border: 1px solid #c0392b;color: #fff;}.confirm-btn.danger:hover { background: #a93226; }.confirm-btn.danger:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }.confirm-hint {margin-top: 12px;text-align: center;font-size: .7rem;color: var(--text-muted);}/* ββ Toast (transient notice) ββ */.toast {position: fixed;bottom: 24px;left: 50%;transform: translate(-50%, 10px);background: var(--surface);color: var(--text);border: 1px solid var(--border);border-radius: 12px;padding: 11px 18px;font-size: .84rem;box-shadow: 0 10px 30px rgba(0, 0, 0, .35);opacity: 0;pointer-events: none;transition: opacity .25s, transform .25s;z-index: 90;max-width: 92vw;}.toast.show { opacity: 1; transform: translate(-50%, 0); }/* ββ Utility ββ */.hidden { display: none !important; }196 unmodified lines.session-del:hover { color: #ff9c9c; }.session-ren:hover { color: var(--accent); }/* While renaming, the pencil is a tick (save) β keep it visible */.session-ren.confirming {opacity: 1;color: var(--accent);font-weight: 700;}.session-rename-input {flex: 1;min-width: 0;
frontend/index.html+15-2
frontend/script.js+83-8
frontend/style.css+102