Skip to content

Speakr is a personal, self-hosted web application designed for transcribing audio recordings

Python

Floating chat: FAB + open-from-collapsed position now both derive from #mainContentColumns — fixes the case where the player is docked at the top of the detail view but the FAB and the panel-on-open were assuming the player was at the bottom (FAB used a hardcoded CSS bottom:84px to clear the bottom audio bar; openChatPanel used main.main-content which extends past the visible content area when the player is at top); new floatingChatFabStyle computed mirrors the floating panel pattern — reads #mainContentColumns rect via getBoundingClientRect, computes fixed bottom/right offsets that put the FAB 24px inside the rect's bottom-right corner; the same ResizeObserver attached earlier auto-bumps chatLayoutTick on any layout change so the FAB re-positions when the user flips the player from bottom to top, when the sidebar collapses, when columns resize, etc.; openChatPanel now uses _rect('#mainContentColumns') so the FAB→panel transition lands inside the actual content area instead of below it

Murtaza Nasir36cbbd202b53
diff --git a/static/js/app.modular.js b/static/js/app.modular.js
index 2cd3bf8d..775de555 100644
--- a/static/js/app.modular.js
+++ b/static/js/app.modular.js
@@ -613,6 +613,28 @@ document.addEventListener('DOMContentLoaded', async () => {
};
// Compute the panel's inline style for the active state.
+ // Position of the collapsed FAB derives from the same
+ // #mainContentColumns rect as the floating/docked panel —
+ // single source of truth — so the FAB sits just inside the
+ // bottom-right corner of the content area regardless of
+ // whether the audio player is docked at the top or bottom.
+ // Falls back to viewport-bottom-right with a small inset
+ // when the rect isn't available yet (initial render).
+ const floatingChatFabStyle = computed(() => {
+ void chatLayoutTick.value;
+ const r = _rect('#mainContentColumns');
+ if (r && r.width > 0) {
+ return {
+ position: 'fixed',
+ top: 'auto',
+ bottom: (window.innerHeight - r.bottom + 24) + 'px',
+ left: 'auto',
+ right: (window.innerWidth - r.right + 24) + 'px',
+ };
+ }
+ return {}; // falls back to CSS bottom: 84px right: 24px
+ });
+
// Reactive on chatLayoutTick so resize / sidebar toggle
// trigger recompute.
const floatingChatPanelStyle = computed(() => {
@@ -724,11 +746,16 @@ document.addEventListener('DOMContentLoaded', async () => {
const openChatPanel = () => {
if (chatPanelState.value === 'collapsed') {
- const main = document.querySelector('main.main-content');
- const r = main ? main.getBoundingClientRect() : null;
+ // Use #mainContentColumns as the single bounds
+ // reference — same as the docked/floating panel
+ // clamp logic — so the FAB→panel transition lands
+ // inside the actual content area regardless of
+ // whether the audio player is docked at the top
+ // or bottom of the layout.
+ const r = _rect('#mainContentColumns');
chatPanelState.value = 'floating';
chatPanelX.value = r ? (r.right - chatPanelW.value - 24) : (window.innerWidth - chatPanelW.value - 24);
- chatPanelY.value = r ? (r.bottom - chatPanelH.value - 80) : (window.innerHeight - chatPanelH.value - 80);
+ chatPanelY.value = r ? (r.bottom - chatPanelH.value - 24) : (window.innerHeight - chatPanelH.value - 80);
}
saveChatPanelPosition();
};
@@ -1294,7 +1321,7 @@ document.addEventListener('DOMContentLoaded', async () => {
// Chat
showChat, isChatMaximized, chatMessages, chatInput, isChatLoading, chatMessagesRef, chatInputRef,
chatPanelState, chatPanelX, chatPanelY, chatPanelW, chatPanelH,
- chatDragActive, chatResizeActive, floatingChatPanelStyle,
+ chatDragActive, chatResizeActive, floatingChatPanelStyle, floatingChatFabStyle,
chatLastDock, chatDockMenuOpen,
openChatPanel, collapseChatPanel, toggleChatPanelMax,
startChatPanelDrag, startChatPanelResize, dockChatPanel,
diff --git a/templates/components/detail/floating-chat.html b/templates/components/detail/floating-chat.html
index b44d978a..026bcb04 100644
--- a/templates/components/detail/floating-chat.html
+++ b/templates/components/detail/floating-chat.html
@@ -12,10 +12,17 @@
-->
<Teleport to="body">
<div v-if="currentView === 'detail' && selectedRecording" class="floating-chat-root">
- <!-- FAB (collapsed) -->
+ <!-- FAB (collapsed). Position is derived from the same
+ #mainContentColumns rect that the floating/docked panel
+ uses, so the FAB sits just inside the bottom-right of the
+ content area regardless of where the audio player is
+ docked (top vs bottom). chatLayoutTick is touched to make
+ this style reactive to layout changes the ResizeObserver
+ catches. -->
<button v-if="chatPanelState === 'collapsed'"
@click="openChatPanel"
class="floating-chat-fab"
+ :style="floatingChatFabStyle"
:title="t('chat.chatWithTranscription')">
<i class="fas fa-comments"></i>
<span v-if="chatMessages && chatMessages.length > 0" class="floating-chat-fab-badge">