Speakr is a personal, self-hosted web application designed for transcribing audio recordings
Python
Floating-chat v4 — (1) clamp the floating panel against #mainContentColumns rect (not main.main-content) so it can never enter the sidebar zone; .main-content has padding-left:320px which getBoundingClientRect would include in the box, so the old clamp let the panel slide behind the sidebar at left edges; (2) replace the three dock-target icons in the header with a compact split button — main half toggles dock-with-last-chosen-target / undock, caret opens a dropdown with all three options; lastDockChoice persisted to localStorage (key chat_last_dock, global) so the single button remembers across recordings + sessions; (3) outside-click handler closes the dock dropdown
Murtaza Nasira8168de6d1df
diff --git a/static/css/primitives.css b/static/css/primitives.cssindex dcf84d62..78babfc9 100644--- a/static/css/primitives.css+++ b/static/css/primitives.css@@ -1127,6 +1127,66 @@ textarea:focus-visible {background: var(--bg-tertiary);}+/* Split dock button (main + caret + dropdown) */+.floating-chat-dock-split {+ position: relative;+ display: inline-flex;+ align-items: stretch;+ border-radius: var(--radius-sm);+ overflow: visible;+}+.floating-chat-dock-main {+ border-top-right-radius: 0 !important;+ border-bottom-right-radius: 0 !important;+}+.floating-chat-dock-caret {+ width: 18px !important;+ min-width: 18px;+ border-top-left-radius: 0 !important;+ border-bottom-left-radius: 0 !important;+ border-left: 1px solid var(--border-primary);+ margin-left: -1px;+}+.floating-chat-dock-menu {+ position: absolute;+ top: calc(100% + 4px);+ right: 0;+ min-width: 220px;+ padding: var(--sp-1);+ z-index: 50;+ animation: chatPanelIn 140ms ease-out;+}+.floating-chat-dock-menu-item {+ appearance: none;+ background: transparent;+ border: none;+ color: var(--text-primary);+ font-size: var(--fs-meta);+ padding: var(--sp-2) var(--sp-3);+ border-radius: var(--radius-sm);+ width: 100%;+ text-align: left;+ display: inline-flex;+ align-items: center;+ gap: var(--sp-2);+ cursor: pointer;+ transition: background var(--t-fast) ease, color var(--t-fast) ease;+}+.floating-chat-dock-menu-item:hover {+ background: var(--bg-tertiary);+}+.floating-chat-dock-menu-item.is-active {+ color: var(--text-accent);+ background: var(--bg-tertiary);+}+.floating-chat-dock-menu-item i {+ width: 18px;+ color: var(--text-muted);+}+.floating-chat-dock-menu-item.is-active i {+ color: var(--text-accent);+}+/* SE-corner resize handle (only shown in floating state) */.floating-chat-resize-handle {position: absolute;diff --git a/static/js/app.modular.js b/static/js/app.modular.jsindex f5646180..b44404f9 100644--- a/static/js/app.modular.js+++ b/static/js/app.modular.js@@ -589,6 +589,17 @@ document.addEventListener('DOMContentLoaded', async () => {const chatLayoutTick = ref(0); // bumped on resize/sidebar-toggleconst chatDragActive = ref(false);const chatResizeActive = ref(false);+ // Last user-chosen dock target — remembered across sessions+ // so the single dock button can re-dock to wherever the+ // user prefers without re-picking from the dropdown.+ const chatLastDock = ref(+ (typeof localStorage !== 'undefined' && localStorage.getItem('chat_last_dock')) || 'right'+ );+ const chatDockMenuOpen = ref(false);+ const setChatLastDock = (target) => {+ chatLastDock.value = target;+ try { localStorage.setItem('chat_last_dock', target); } catch (e) { /* ignore */ }+ };let chatDragStartX = 0;let chatDragStartY = 0;let chatDragInitialX = 0;@@ -765,9 +776,6 @@ document.addEventListener('DOMContentLoaded', async () => {const dockChatPanel = (target) => {// target: 'left' | 'right' | 'full' | 'floating'if (target === 'floating' && chatPanelX.value == null) {- // First entry into floating from a dock — seat in- // the panel's current docked rect so it doesn't- // jump to (0,0).const panelEl = document.querySelector('.floating-chat-panel');if (panelEl) {const rect = panelEl.getBoundingClientRect();@@ -776,8 +784,23 @@ document.addEventListener('DOMContentLoaded', async () => {}}chatPanelState.value = target === 'floating' ? 'floating' : ('dock-' + target);+ // Remember non-floating dock choices for the split button.+ if (target !== 'floating') setChatLastDock(target);+ chatDockMenuOpen.value = false;saveChatPanelPosition();};+ const toggleChatDockToLast = () => {+ // Primary action of the split button: if currently+ // docked to chatLastDock, undock back to floating;+ // otherwise dock to the last-used target.+ const currentDock = chatPanelState.value.startsWith('dock-')+ ? chatPanelState.value.slice(5) : null;+ if (currentDock === chatLastDock.value) {+ dockChatPanel('floating');+ } else {+ dockChatPanel(chatLastDock.value);+ }+ };const toggleChatPanelMax = () => {// Backward-compatible alias used by old template; toggle full vs floatingif (chatPanelState.value === 'dock-full') {@@ -855,31 +878,37 @@ document.addEventListener('DOMContentLoaded', async () => {const w = chatPanelW.value;const h = chatPanelH.value;- if (mainRect) {+ // Use the actual #mainContentColumns rect for+ // clamping, NOT main.main-content. The <main>+ // element has padding-left: 320px when the sidebar+ // is open, but getBoundingClientRect includes the+ // padding region, so clamping to main.rect.left+ // would happily let the panel slip behind the+ // sidebar. #mainContentColumns is the column-split+ // area only — its left edge is the actual start of+ // content, its right is the viewport right edge,+ // its top/bottom are below the meta strip and+ // above the bottom audio bar.+ const cols = _rect('#mainContentColumns');+ if (cols) {const CORNER_SNAP = 80;- const distL = Math.abs(chatPanelX.value - mainRect.left);- const distR = Math.abs(chatPanelX.value + w - mainRect.right);- const distT = Math.abs(chatPanelY.value - mainRect.top);- const distB = Math.abs(chatPanelY.value + h - mainRect.bottom);-- // Hard-snap if within CORNER_SNAP px of any- // main-area edge.- if (distL < CORNER_SNAP) chatPanelX.value = mainRect.left + 12;- else if (distR < CORNER_SNAP) chatPanelX.value = mainRect.right - w - 12;- if (distT < CORNER_SNAP) chatPanelY.value = mainRect.top + 12;- else if (distB < CORNER_SNAP) {- // Leave room for the bottom audio bar (~64px)- chatPanelY.value = mainRect.bottom - h - 80;- }-- // Final clamp — never let the panel slip off-screen.+ const distL = Math.abs(chatPanelX.value - cols.left);+ const distR = Math.abs(chatPanelX.value + w - cols.right);+ const distT = Math.abs(chatPanelY.value - cols.top);+ const distB = Math.abs(chatPanelY.value + h - cols.bottom);+ if (distL < CORNER_SNAP) chatPanelX.value = cols.left + 12;+ else if (distR < CORNER_SNAP) chatPanelX.value = cols.right - w - 12;+ if (distT < CORNER_SNAP) chatPanelY.value = cols.top + 12;+ else if (distB < CORNER_SNAP) chatPanelY.value = cols.bottom - h - 12;++ // Final hard clamp inside the columns area.chatPanelX.value = Math.max(- mainRect.left + 8,- Math.min(chatPanelX.value, mainRect.right - w - 8)+ cols.left + 8,+ Math.min(chatPanelX.value, cols.right - w - 8));chatPanelY.value = Math.max(- mainRect.top + 8,- Math.min(chatPanelY.value, mainRect.bottom - h - 8)+ cols.top + 8,+ Math.min(chatPanelY.value, cols.bottom - h - 8));}saveChatPanelPosition();@@ -898,6 +927,13 @@ document.addEventListener('DOMContentLoaded', async () => {const _bumpChatLayout = () => { chatLayoutTick.value += 1; };if (typeof window !== 'undefined') {window.addEventListener('resize', _bumpChatLayout);+ // Close the floating-chat dock dropdown on any outside click.+ document.addEventListener('click', (e) => {+ if (!chatDockMenuOpen.value) return;+ if (!e.target.closest('.floating-chat-dock-split')) {+ chatDockMenuOpen.value = false;+ }+ });}// Restore chat panel position whenever the selected recording changes.@@ -1228,8 +1264,10 @@ document.addEventListener('DOMContentLoaded', async () => {showChat, isChatMaximized, chatMessages, chatInput, isChatLoading, chatMessagesRef, chatInputRef,chatPanelState, chatPanelX, chatPanelY, chatPanelW, chatPanelH,chatDragActive, chatResizeActive, floatingChatPanelStyle,+ chatLastDock, chatDockMenuOpen,openChatPanel, collapseChatPanel, toggleChatPanelMax,startChatPanelDrag, startChatPanelResize, dockChatPanel,+ toggleChatDockToLast,// Audio PlayerplayerVolume, audioIsPlaying, audioCurrentTime, audioDuration, audioIsMuted, audioIsLoading, asrEditorAudio,diff --git a/templates/components/detail/floating-chat.html b/templates/components/detail/floating-chat.htmlindex c4f61804..0ea1cf44 100644--- a/templates/components/detail/floating-chat.html+++ b/templates/components/detail/floating-chat.html@@ -56,24 +56,46 @@<i class="fas fa-eraser"></i></button><span class="floating-chat-dock-divider"></span>- <button @click="dockChatPanel('left')"- class="btn btn--icon btn--sm"- :class="{ 'is-active': chatPanelState === 'dock-left' }"- title="Dock to transcript column">- <i class="fas fa-square" style="font-size: 9px; transform: translateX(-3px);"></i><i class="fas fa-square-o" style="font-size: 9px; transform: translateX(-1px); opacity: 0.3;"></i>- </button>- <button @click="dockChatPanel('full')"- class="btn btn--icon btn--sm"- :class="{ 'is-active': chatPanelState === 'dock-full' }"- title="Dock full width">- <i class="fas fa-expand"></i>- </button>- <button @click="dockChatPanel('right')"- class="btn btn--icon btn--sm"- :class="{ 'is-active': chatPanelState === 'dock-right' }"- title="Dock to right rail">- <i class="fas fa-square-o" style="font-size: 9px; transform: translateX(-3px); opacity: 0.3;"></i><i class="fas fa-square" style="font-size: 9px; transform: translateX(-1px);"></i>- </button>+ <!-- Split dock button: main half toggles dock with+ last-chosen target; caret opens dropdown to+ pick a different target. -->+ <div class="floating-chat-dock-split">+ <button @click="toggleChatDockToLast"+ class="btn btn--icon btn--sm floating-chat-dock-main"+ :class="{ 'is-active': chatPanelState === ('dock-' + chatLastDock) }"+ :title="chatPanelState === ('dock-' + chatLastDock) ? 'Undock' : ('Dock to ' + chatLastDock)">+ <i v-if="chatLastDock === 'left'" class="fas fa-table-columns" style="transform: scaleX(1);"></i>+ <i v-else-if="chatLastDock === 'right'" class="fas fa-table-columns" style="transform: scaleX(-1);"></i>+ <i v-else class="fas fa-expand"></i>+ </button>+ <button @click="chatDockMenuOpen = !chatDockMenuOpen"+ class="btn btn--icon btn--sm floating-chat-dock-caret"+ title="Choose dock target">+ <i class="fas fa-caret-down" style="font-size: 10px;"></i>+ </button>+ <div v-if="chatDockMenuOpen"+ class="floating-chat-dock-menu surface-raised"+ @click.stop>+ <button @click="dockChatPanel('left')"+ class="floating-chat-dock-menu-item"+ :class="{ 'is-active': chatPanelState === 'dock-left' }">+ <i class="fas fa-table-columns" style="transform: scaleX(1);"></i>+ <span>Dock to transcript column</span>+ </button>+ <button @click="dockChatPanel('full')"+ class="floating-chat-dock-menu-item"+ :class="{ 'is-active': chatPanelState === 'dock-full' }">+ <i class="fas fa-expand"></i>+ <span>Dock full width</span>+ </button>+ <button @click="dockChatPanel('right')"+ class="floating-chat-dock-menu-item"+ :class="{ 'is-active': chatPanelState === 'dock-right' }">+ <i class="fas fa-table-columns" style="transform: scaleX(-1);"></i>+ <span>Dock to right rail</span>+ </button>+ </div>+ </div><span class="floating-chat-dock-divider"></span><button @click="collapseChatPanel"class="btn btn--icon btn--sm"