Skip to content

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

Python

Ship the floating dockable chat panel: new components/detail/floating-chat.html (Teleported to body) with FAB at bottom-right when collapsed, opens into a 380x520 panel docked-se by default; header drag-to-snap supports 4-corner snap (within 100px) plus free-floating; maximize toggles to fill the viewport-less-header; per-recording position persisted in localStorage; .floating-chat-* CSS primitives in primitives.css handle all 4 states + responsive (mobile hides the floating chat — mobile uses the bottom-nav Chat tab instead); old desktop-chat-section.html no longer included from desktop-right-panel.html since the right rail tab content fills the column

Murtaza Nasir601005631e31
diff --git a/floating-chat-fab.png b/floating-chat-fab.png
new file mode 100644
index 00000000..488abe76
Binary files /dev/null and b/floating-chat-fab.png differ
diff --git a/floating-chat-open.png b/floating-chat-open.png
new file mode 100644
index 00000000..2d7aa65a
Binary files /dev/null and b/floating-chat-open.png differ
diff --git a/static/css/primitives.css b/static/css/primitives.css
index b82688c3..de57d9f2 100644
--- a/static/css/primitives.css
+++ b/static/css/primitives.css
@@ -955,3 +955,158 @@ textarea:focus-visible {
outline: none;
box-shadow: 0 0 0 3px var(--ring-focus);
}
+
+
+/* ---- Floating Chat Panel ------------------------------------------------
+ *
+ * Floating, dockable chat surface for the recording-detail screen.
+ * Lives at z-index 40 (above content but below modals at 50).
+ *
+ * States — keyed by the chat-panel--{state} class:
+ * .is-floating free-positioned, drag to move
+ * .is-docked-ne/nw/se/sw snapped to a viewport corner
+ * .is-maximized fills the viewport less the global header
+ * --------------------------------------------------------------------- */
+
+.floating-chat-root {
+ position: fixed;
+ inset: 0;
+ pointer-events: none;
+ z-index: 40;
+}
+
+/* FAB (collapsed) */
+.floating-chat-fab {
+ position: fixed;
+ bottom: 84px; /* above the persistent bottom audio player */
+ right: 24px;
+ width: 56px;
+ height: 56px;
+ border-radius: 999px;
+ background: var(--bg-button);
+ color: var(--text-button);
+ border: none;
+ cursor: pointer;
+ display: inline-flex;
+ align-items: center;
+ justify-content: center;
+ box-shadow: var(--shadow-lg);
+ font-size: 22px;
+ transition: transform var(--t-fast) ease, box-shadow var(--t-fast) ease;
+ pointer-events: auto;
+}
+.floating-chat-fab:hover {
+ transform: scale(1.06);
+ box-shadow: 0 16px 40px rgba(0, 0, 0, 0.18);
+}
+.floating-chat-fab-badge {
+ position: absolute;
+ top: -4px;
+ right: -4px;
+ min-width: 20px;
+ height: 20px;
+ padding: 0 6px;
+ border-radius: 999px;
+ background: var(--bg-danger);
+ color: #fff;
+ font-size: 11px;
+ font-weight: 700;
+ display: inline-flex;
+ align-items: center;
+ justify-content: center;
+}
+
+/* Panel (floating / docked / maximized) */
+.floating-chat-panel {
+ position: fixed;
+ width: 380px;
+ height: 520px;
+ max-width: calc(100vw - 32px);
+ max-height: calc(100vh - 80px);
+ background: var(--bg-secondary);
+ color: var(--text-primary);
+ border: var(--border-hairline) solid var(--border-primary);
+ border-radius: var(--radius-lg);
+ box-shadow: var(--shadow-lg);
+ display: flex;
+ flex-direction: column;
+ overflow: hidden;
+ pointer-events: auto;
+ backdrop-filter: blur(6px);
+ animation: chatPanelIn 180ms cubic-bezier(0.16, 1, 0.3, 1);
+}
+
+@keyframes chatPanelIn {
+ from { opacity: 0; transform: translateY(8px) scale(0.97); }
+ to { opacity: 1; transform: translateY(0) scale(1); }
+}
+
+/* Docked corners */
+.floating-chat-panel.is-docked-se { bottom: 84px; right: 24px; top: auto; left: auto; }
+.floating-chat-panel.is-docked-sw { bottom: 84px; left: 24px; top: auto; right: auto; }
+.floating-chat-panel.is-docked-ne { top: 80px; right: 24px; bottom: auto; left: auto; }
+.floating-chat-panel.is-docked-nw { top: 80px; left: 24px; bottom: auto; right: auto; }
+
+/* Maximized */
+.floating-chat-panel.is-maximized {
+ width: calc(100vw - 48px);
+ height: calc(100vh - 120px);
+ top: 80px;
+ left: 24px;
+ right: 24px;
+ bottom: auto;
+ max-width: none;
+ max-height: none;
+}
+
+/* Header (drag handle) */
+.floating-chat-header {
+ flex: 0 0 auto;
+ display: flex;
+ align-items: center;
+ gap: var(--sp-2);
+ padding: var(--sp-2) var(--sp-3);
+ border-bottom: var(--border-hairline) solid var(--border-primary);
+ cursor: grab;
+ user-select: none;
+ background: var(--bg-tertiary);
+}
+.floating-chat-header:active { cursor: grabbing; }
+
+.floating-chat-header-title {
+ flex: 1;
+ display: inline-flex;
+ align-items: center;
+ gap: var(--sp-2);
+ font-size: var(--fs-meta);
+ font-weight: 600;
+ color: var(--text-primary);
+}
+.floating-chat-header-title i { color: var(--text-muted); font-size: 12px; }
+
+.floating-chat-header-actions {
+ display: inline-flex;
+ align-items: center;
+ gap: 2px;
+}
+
+.floating-chat-messages {
+ flex: 1 1 auto;
+ overflow-y: auto;
+ padding: var(--sp-3);
+}
+.floating-chat-messages > .message {
+ margin-bottom: var(--sp-3);
+}
+
+.floating-chat-input {
+ flex: 0 0 auto;
+ border-top: var(--border-hairline) solid var(--border-primary);
+ padding: var(--sp-2) var(--sp-3);
+ background: var(--bg-secondary);
+}
+
+@media (max-width: 768px) {
+ .floating-chat-fab { display: none; }
+ .floating-chat-panel { display: none; }
+}
diff --git a/static/js/app.modular.js b/static/js/app.modular.js
index 737d06dc..2bc4d4af 100644
--- a/static/js/app.modular.js
+++ b/static/js/app.modular.js
@@ -574,6 +574,161 @@ document.addEventListener('DOMContentLoaded', async () => {
const chatMessagesRef = ref(null);
const chatInputRef = ref(null);
+ // --- Floating Chat Panel State ---
+ // 'collapsed' (FAB only) | 'floating' (free-positioned) |
+ // 'docked-{ne,nw,se,sw}' (snapped to viewport corner) |
+ // 'maximized' (fills viewport less header)
+ const chatPanelState = ref('collapsed');
+ const chatPanelX = ref(null);
+ const chatPanelY = ref(null);
+ // Drag state — not persisted, just runtime
+ const chatDragActive = ref(false);
+ let chatDragStartX = 0;
+ let chatDragStartY = 0;
+ let chatDragInitialX = 0;
+ let chatDragInitialY = 0;
+
+ const floatingChatPanelStyle = computed(() => {
+ if (chatPanelState.value === 'floating' && chatPanelX.value != null) {
+ return {
+ top: chatPanelY.value + 'px',
+ left: chatPanelX.value + 'px',
+ right: 'auto',
+ bottom: 'auto'
+ };
+ }
+ return {};
+ });
+
+ // Persistence per recording (best-effort; ignores errors).
+ const _chatPanelStorageKey = () => {
+ const rec = selectedRecording.value;
+ return rec ? `chat_panel_pos_${rec.id}` : null;
+ };
+ const saveChatPanelPosition = () => {
+ const key = _chatPanelStorageKey();
+ if (!key) return;
+ try {
+ localStorage.setItem(key, JSON.stringify({
+ state: chatPanelState.value,
+ x: chatPanelX.value,
+ y: chatPanelY.value,
+ }));
+ } catch (e) { /* quota exceeded etc — ignore */ }
+ };
+ const restoreChatPanelPosition = () => {
+ const key = _chatPanelStorageKey();
+ if (!key) return;
+ try {
+ const raw = localStorage.getItem(key);
+ if (!raw) {
+ chatPanelState.value = 'collapsed';
+ return;
+ }
+ const data = JSON.parse(raw);
+ chatPanelState.value = data.state || 'collapsed';
+ chatPanelX.value = data.x;
+ chatPanelY.value = data.y;
+ } catch (e) {
+ chatPanelState.value = 'collapsed';
+ }
+ };
+
+ const openChatPanel = () => {
+ chatPanelState.value = 'docked-se';
+ saveChatPanelPosition();
+ };
+ const collapseChatPanel = () => {
+ chatPanelState.value = 'collapsed';
+ saveChatPanelPosition();
+ };
+ const toggleChatPanelMax = () => {
+ if (chatPanelState.value === 'maximized') {
+ chatPanelState.value = 'docked-se';
+ } else {
+ chatPanelState.value = 'maximized';
+ }
+ saveChatPanelPosition();
+ };
+
+ // Drag-to-snap: header pointer-down → track mouse → on
+ // release, if released within 100px of a corner, snap to
+ // that corner; otherwise stay free-floating.
+ const startChatPanelDrag = (event) => {
+ if (chatPanelState.value === 'maximized') return;
+ const isTouch = event.touches != null;
+ const point = isTouch ? event.touches[0] : event;
+ chatDragActive.value = true;
+
+ // If the panel was docked, switch to floating with the
+ // current rendered position before the user starts
+ // moving it (otherwise dragging from a docked corner
+ // would snap weirdly).
+ const panelEl = event.currentTarget.closest('.floating-chat-panel');
+ if (panelEl) {
+ const rect = panelEl.getBoundingClientRect();
+ chatPanelX.value = rect.left;
+ chatPanelY.value = rect.top;
+ chatPanelState.value = 'floating';
+ }
+ chatDragStartX = point.clientX;
+ chatDragStartY = point.clientY;
+ chatDragInitialX = chatPanelX.value || 0;
+ chatDragInitialY = chatPanelY.value || 0;
+
+ const moveHandler = (e) => {
+ const p = e.touches ? e.touches[0] : e;
+ chatPanelX.value = chatDragInitialX + (p.clientX - chatDragStartX);
+ chatPanelY.value = chatDragInitialY + (p.clientY - chatDragStartY);
+ };
+ const endHandler = () => {
+ chatDragActive.value = false;
+ document.removeEventListener('mousemove', moveHandler);
+ document.removeEventListener('mouseup', endHandler);
+ document.removeEventListener('touchmove', moveHandler);
+ document.removeEventListener('touchend', endHandler);
+
+ // Snap to corner if released within snap radius.
+ const SNAP = 100;
+ const vw = window.innerWidth;
+ const vh = window.innerHeight;
+ const panelW = 380;
+ const panelH = 520;
+ const x = chatPanelX.value;
+ const y = chatPanelY.value;
+ // Use the panel's centroid for snap detection.
+ const cx = x + panelW / 2;
+ const cy = y + panelH / 2;
+ const nearLeft = cx < SNAP + panelW / 2;
+ const nearRight = cx > vw - SNAP - panelW / 2;
+ const nearTop = cy < SNAP + panelH / 2;
+ const nearBottom = cy > vh - SNAP - panelH / 2;
+ if (nearLeft && nearTop) chatPanelState.value = 'docked-nw';
+ else if (nearRight && nearTop) chatPanelState.value = 'docked-ne';
+ else if (nearLeft && nearBottom) chatPanelState.value = 'docked-sw';
+ else if (nearRight && nearBottom) chatPanelState.value = 'docked-se';
+ // Else stay 'floating' with the x/y we have.
+ // Clamp into viewport so it can't be dragged off-screen.
+ if (chatPanelState.value === 'floating') {
+ chatPanelX.value = Math.max(0, Math.min(chatPanelX.value, vw - panelW));
+ chatPanelY.value = Math.max(0, Math.min(chatPanelY.value, vh - panelH));
+ }
+ saveChatPanelPosition();
+ };
+ document.addEventListener('mousemove', moveHandler);
+ document.addEventListener('mouseup', endHandler);
+ document.addEventListener('touchmove', moveHandler, { passive: true });
+ document.addEventListener('touchend', endHandler);
+ event.preventDefault();
+ };
+
+ // Restore chat panel position whenever the selected recording changes.
+ watch(selectedRecording, (newRec) => {
+ if (newRec) {
+ restoreChatPanelPosition();
+ }
+ }, { immediate: false });
+
// --- Audio Player State (Main Player) ---
const playerVolume = ref(1.0);
const audioIsPlaying = ref(false);
@@ -882,6 +1037,8 @@ document.addEventListener('DOMContentLoaded', async () => {
// Chat
showChat, isChatMaximized, chatMessages, chatInput, isChatLoading, chatMessagesRef, chatInputRef,
+ chatPanelState, chatPanelX, chatPanelY, chatDragActive, floatingChatPanelStyle,
+ openChatPanel, collapseChatPanel, toggleChatPanelMax, startChatPanelDrag,
// Audio Player
playerVolume, audioIsPlaying, audioCurrentTime, audioDuration, audioIsMuted, audioIsLoading, asrEditorAudio,
diff --git a/templates/components/detail-view.html b/templates/components/detail-view.html
index 1eae1596..23fbedc0 100644
--- a/templates/components/detail-view.html
+++ b/templates/components/detail-view.html
@@ -116,6 +116,9 @@
screen so the player is always within reach. -->
{% include 'components/detail/desktop-bottom-player.html' %}
</div>
+
+ <!-- Floating dockable chat (teleported to body; desktop-only). -->
+ {% include 'components/detail/floating-chat.html' %}
</div>
{% include 'components/detail/empty-state.html' %}
diff --git a/templates/components/detail/desktop-right-panel.html b/templates/components/detail/desktop-right-panel.html
index f319e463..f6057cf3 100644
--- a/templates/components/detail/desktop-right-panel.html
+++ b/templates/components/detail/desktop-right-panel.html
@@ -64,13 +64,14 @@
</div>
<!-- Tab Content -->
- <div v-if="!isChatMaximized" class="flex-1 overflow-hidden">
+ <div class="flex-1 overflow-hidden">
{% include 'components/detail/desktop-summary-tab.html' %}
{% include 'components/detail/desktop-notes-tab.html' %}
{% include 'components/detail/desktop-events-tab.html' %}
</div>
</div>
- <!-- Chat Section -->
- {% include 'components/detail/desktop-chat-section.html' %}
+ <!-- Chat is no longer inline — it lives in the floating dockable
+ panel (components/detail/floating-chat.html) which is mounted
+ at the detail-view level and teleported to <body>. -->
</div>
diff --git a/templates/components/detail/floating-chat.html b/templates/components/detail/floating-chat.html
new file mode 100644
index 00000000..067e8cce
--- /dev/null
+++ b/templates/components/detail/floating-chat.html
@@ -0,0 +1,133 @@
+<!-- Floating Dockable Chat Panel (design system v1).
+ States:
+ - 'collapsed': FAB only, bottom-right
+ - 'floating' : 380×500 panel at user-saved position
+ - 'docked-{ne,nw,se,sw}': snapped to a corner
+ - 'maximized': fills available space
+ Drag the header to move. Drop within 100px of a viewport corner →
+ snaps to that corner. Position persisted in localStorage per
+ recording id. Teleported to <body> so it floats above all content. -->
+<Teleport to="body">
+ <div v-if="currentView === 'detail' && selectedRecording" class="floating-chat-root">
+ <!-- FAB (collapsed) -->
+ <button v-if="chatPanelState === 'collapsed'"
+ @click="openChatPanel"
+ class="floating-chat-fab"
+ :title="t('chat.chatWithTranscription')">
+ <i class="fas fa-comments"></i>
+ <span v-if="chatMessages && chatMessages.length > 0" class="floating-chat-fab-badge">
+ ${chatMessages.length}
+ </span>
+ </button>
+
+ <!-- Panel (floating/docked/maximized) -->
+ <div v-else
+ class="floating-chat-panel"
+ :class="['is-' + chatPanelState]"
+ :style="floatingChatPanelStyle">
+ <!-- Header (drag handle) -->
+ <div class="floating-chat-header"
+ @mousedown="startChatPanelDrag"
+ @touchstart.passive="startChatPanelDrag">
+ <div class="floating-chat-header-title">
+ <i class="fas fa-comments"></i>
+ <span>${ t('chat.chatWithTranscription') }</span>
+ <span v-if="chatMessages && chatMessages.length > 0" class="tab__count">${chatMessages.length}</span>
+ </div>
+ <div class="floating-chat-header-actions">
+ <button v-if="chatMessages.length > 0"
+ @click.stop="downloadChat"
+ class="btn btn--icon btn--sm"
+ :title="t('buttons.downloadChat')">
+ <i class="fas fa-download"></i>
+ </button>
+ <button v-if="chatMessages.length > 0"
+ @click.stop="clearChat"
+ class="btn btn--icon btn--sm"
+ style="color: var(--text-muted);"
+ title="Clear chat">
+ <i class="fas fa-eraser"></i>
+ </button>
+ <button @click.stop="toggleChatPanelMax"
+ class="btn btn--icon btn--sm"
+ :title="chatPanelState === 'maximized' ? t('tooltips.restoreChat') : t('tooltips.maximizeChat')">
+ <i :class="['fas', chatPanelState === 'maximized' ? 'fa-compress' : 'fa-expand']"></i>
+ </button>
+ <button @click.stop="collapseChatPanel"
+ class="btn btn--icon btn--sm"
+ :title="t('buttons.close')">
+ <i class="fas fa-times"></i>
+ </button>
+ </div>
+ </div>
+
+ <!-- Messages -->
+ <div ref="chatMessagesRef" class="floating-chat-messages">
+ <div v-if="chatMessages.length === 0" class="empty">
+ <div class="empty__icon"><i class="fas fa-robot"></i></div>
+ <div class="empty__title" v-text="t('help.askAboutTranscription')"></div>
+ <div class="empty__body">Type a question below. Markdown supported.</div>
+ </div>
+
+ <div v-for="(message, index) in chatMessages" :key="index"
+ :class="['message relative group',
+ message.role === 'user' ? 'user-message ml-auto' : 'ai-message',
+ message.role === 'assistant' ? 'pr-10' : '']">
+ <button v-if="message.role === 'assistant'"
+ @click="copyMessage(message.content, $event)"
+ class="btn btn--icon btn--sm absolute"
+ style="top: var(--sp-2); right: var(--sp-2);"
+ :title="t('buttons.copyMessage')">
+ <i class="fas fa-copy"></i>
+ </button>
+ <div v-if="message.thinking && message.role === 'assistant'" class="mb-2">
+ <button @click="message.thinkingExpanded = !message.thinkingExpanded"
+ class="text-xs text-[var(--text-muted)] hover:text-[var(--text-secondary)] flex items-center gap-1">
+ <i :class="['fas', message.thinkingExpanded ? 'fa-chevron-down' : 'fa-chevron-right']"></i>
+ <span v-text="t('help.modelReasoning')"></span>
+ <span class="text-[var(--text-muted)]">(${message.thinking.split('\n').length} lines)</span>
+ </button>
+ <div v-if="message.thinkingExpanded"
+ class="mt-2 p-3 bg-[var(--bg-tertiary)] border border-[var(--border-primary)] rounded-md text-xs text-[var(--text-muted)] max-h-64 overflow-y-auto">
+ <pre class="whitespace-pre-wrap font-mono">${message.thinking}</pre>
+ </div>
+ </div>
+ <div v-if="message.html" v-html="message.html"></div>
+ <div v-else class="whitespace-pre-wrap">${message.content}</div>
+ </div>
+
+ <div v-if="isChatLoading" class="ai-message flex items-center gap-2">
+ <div class="spinner"></div>
+ <span v-text="t('chat.thinking')"></span>
+ </div>
+ </div>
+
+ <!-- Input -->
+ <div class="floating-chat-input">
+ <div class="flex gap-2 items-end">
+ <textarea v-model="chatInput"
+ ref="chatInputRef"
+ @keydown="handleChatKeydown"
+ :disabled="selectedRecording.status !== 'COMPLETED' || processedTranscription.isError"
+ :placeholder="t('chat.placeholderWithHint')"
+ class="field"
+ style="resize: none;"
+ rows="2"></textarea>
+ <button @click="sendChatMessage"
+ :disabled="!chatInput.trim() || isChatLoading || selectedRecording.status !== 'COMPLETED' || processedTranscription.isError"
+ class="btn btn--primary btn--icon btn--lg"
+ :title="t('buttons.send') || 'Send'">
+ <i class="fas fa-paper-plane"></i>
+ </button>
+ </div>
+ <div v-if="processedTranscription.isError" class="t-meta mt-2 flex items-center gap-1.5" style="color: var(--text-danger);">
+ <i class="fas fa-exclamation-triangle"></i>
+ <span v-text="t('chat.cannotChatTranscriptionFailed')"></span>
+ </div>
+ <div v-else-if="selectedRecording.status !== 'COMPLETED'" class="t-meta mt-2">
+ <span v-text="t('chat.availableAfterTranscription')"></span>
+ </div>
+ </div>
+ </div>
+ </div>
+</Teleport>