Voice-to-text dictation app with local (Nvidia Parakeet/Whisper) and cloud models (BYOK). Privacy-first and available cross-platform.
JavaScript aianthropiccross-platformgeminigroqlinuxmacosnvidiaopen-sourceopenaiparakeetspeech-to-texttranscribewhisperwindows
fix(notes): keep note content visible above the floating chat panel (#1769)
Idris Gadifa11ddc9040c
diff --git a/src/components/notes/EmbeddedChat.tsx b/src/components/notes/EmbeddedChat.tsxindex 639cc87cc..227541a17 100644--- a/src/components/notes/EmbeddedChat.tsx+++ b/src/components/notes/EmbeddedChat.tsx@@ -8,6 +8,7 @@ import type { Message, AgentState } from "../chat/types";import { setActiveNoteId, setActiveFolderId } from "../../stores/noteStore";import type { ContainerConversationItem } from "../../hooks/useContainerChat";import { ConversationPicker } from "./ConversationPicker";+import { FLOATING_CHAT_MAX_HEIGHT_CSS } from "./floatingChatLayout";export type EmbeddedChatMode = "hidden" | "floating" | "sidebar";@@ -22,6 +23,8 @@ interface EmbeddedChatProps {activeConversationId?: number | null;onSwitchConversation?: (id: number) => void;onNewChat?: () => void;+ /** Floating panel ref; NoteEditor reserves scroll space with it. */+ floatingPanelRef?: React.Ref<HTMLDivElement>;}function EmptyState() {@@ -46,6 +49,7 @@ export default function EmbeddedChat({activeConversationId,onSwitchConversation,onNewChat,+ floatingPanelRef,}: EmbeddedChatProps) {const { t } = useTranslation();@@ -143,9 +147,11 @@ export default function EmbeddedChat({if (mode === "floating") {return (<div+ ref={floatingPanelRef}+ style={{ maxHeight: FLOATING_CHAT_MAX_HEIGHT_CSS }}className={cn("absolute bottom-4 left-5 right-5 z-20 mx-auto max-w-[600px]",- "max-h-[calc(100%-2rem)] min-h-50",+ "min-h-50","flex flex-col","bg-background/95 dark:bg-surface-2/95","border border-black/15 dark:border-white/18",diff --git a/src/components/notes/MeetingTranscriptChat.tsx b/src/components/notes/MeetingTranscriptChat.tsxindex f7282a873..5b726c910 100644--- a/src/components/notes/MeetingTranscriptChat.tsx+++ b/src/components/notes/MeetingTranscriptChat.tsx@@ -774,7 +774,7 @@ export function MeetingTranscriptChat({)}<divref={scrollRef}- className="flex-1 min-h-0 overflow-y-auto px-4 pt-2 pb-24 flex flex-col gap-1.5 agent-chat-scroll"+ className="flex-1 min-h-0 overflow-y-auto px-4 pt-2 flex flex-col gap-1.5 agent-chat-scroll pb-[var(--floating-inset,96px)]">{segments.map((segment, i) => {const selfSide = isSelfSide(segment);diff --git a/src/components/notes/NoteEditor.tsx b/src/components/notes/NoteEditor.tsxindex 2b440d5f7..875801836 100644--- a/src/components/notes/NoteEditor.tsx+++ b/src/components/notes/NoteEditor.tsx@@ -69,6 +69,7 @@ import {} from "../../utils/transcriptSpeakerState";import NoteParticipants from "./NoteParticipants";import type { CalendarAttendee } from "../../types/calendar";+import { observeFloatingChatLayout } from "./floatingChatLayout";const CHIP_BUTTON_CLASS ="inline-flex items-center gap-1.5 text-[11px] px-1.5 py-0.5 rounded-md border border-border/70 dark:border-white/25 text-foreground/50 dark:text-foreground/35 hover:text-foreground/60 hover:border-border/60 hover:bg-foreground/3 dark:hover:text-foreground/40 dark:hover:border-white/10 dark:hover:bg-white/3 transition-all duration-150 cursor-pointer outline-none focus-visible:ring-1 focus-visible:ring-ring/30";@@ -716,6 +717,34 @@ export default function NoteEditor({prevRecordingRef.current = isRecording;}, [isRecording, scheduleUiUpdate]);+ const contentScrollRef = useRef<HTMLDivElement>(null);++ const getActiveScroller = useCallback((root: HTMLDivElement): HTMLElement | null => {+ const candidates = [root, ...Array.from(root.querySelectorAll<HTMLElement>("*"))].filter(+ (el) => el.scrollHeight - el.clientHeight > 2+ );+ if (!candidates.length) return null;+ return candidates.reduce((a, b) =>+ b.scrollHeight - b.clientHeight > a.scrollHeight - a.clientHeight ? b : a+ );+ }, []);++ const floatingChatPanelRef = useCallback(+ (panel: HTMLDivElement | null): (() => void) | undefined => {+ const container = panel?.parentElement;+ const contentRoot = contentScrollRef.current;+ if (!panel || !container || !contentRoot) return undefined;++ return observeFloatingChatLayout({+ panel,+ container,+ contentRoot,+ getActiveScroller: (): HTMLElement | null => getActiveScroller(contentRoot),+ });+ },+ [getActiveScroller]+ );+const handleContentChange = useCallback((newValue: string) => {onContentChange(note.id, newValue);@@ -1150,7 +1179,7 @@ export default function NoteEditor({)}<div className="flex-1 relative min-h-0">- <div className="h-full overflow-y-auto">+ <div ref={contentScrollRef} className="h-full overflow-y-auto">{viewMode === "transcript" && (hasChatSegments || isRecording) ? (isRecording ? (<LiveMeetingTranscriptChat@@ -1245,6 +1274,7 @@ export default function NoteEditor({{chatMode === "floating" && (<EmbeddedChatmode="floating"+ floatingPanelRef={floatingChatPanelRef}onModeChange={setChatMode}messages={embeddedChat.messages}agentState={embeddedChat.agentState}diff --git a/src/components/notes/floatingChatLayout.ts b/src/components/notes/floatingChatLayout.tsnew file mode 100644index 000000000..c9190b97f--- /dev/null+++ b/src/components/notes/floatingChatLayout.ts@@ -0,0 +1,94 @@+export const FLOATING_CHAT_INSET_EXTRA_PX = 32;+export const FLOATING_CHAT_MIN_VISIBLE_CONTENT_PX = 80;+export const FLOATING_CHAT_MAX_HEIGHT_CSS = "calc(100% - 7rem)";++const SCROLL_BOTTOM_THRESHOLD_PX = 80;++export interface ScrollMetrics {+ scrollHeight: number;+ scrollTop: number;+ clientHeight: number;+}++interface ResizeObserverHandle {+ observe: (element: Element) => void;+ disconnect: () => void;+}++interface FloatingChatLayoutOptions {+ panel: HTMLElement;+ container: HTMLElement;+ contentRoot: HTMLElement;+ getActiveScroller: () => HTMLElement | null;+}++interface FloatingChatLayoutDependencies {+ createResizeObserver?: (callback: () => void) => ResizeObserverHandle;+ requestFrame?: (callback: () => void) => number;+ cancelFrame?: (frameId: number) => void;+}++export function isNearScrollBottom(metrics: ScrollMetrics): boolean {+ const distanceToBottom = metrics.scrollHeight - metrics.scrollTop - metrics.clientHeight;+ return distanceToBottom <= SCROLL_BOTTOM_THRESHOLD_PX;+}++export function observeFloatingChatLayout(+ { panel, container, contentRoot, getActiveScroller }: FloatingChatLayoutOptions,+ dependencies: FloatingChatLayoutDependencies = {}+): () => void {+ const createResizeObserver =+ dependencies.createResizeObserver ?? ((callback): ResizeObserverHandle => new ResizeObserver(callback));+ const requestFrame =+ dependencies.requestFrame ?? ((callback): number => requestAnimationFrame(callback));+ const cancelFrame = dependencies.cancelFrame ?? ((frameId): void => cancelAnimationFrame(frameId));+ let followsBottom = true;+ let frameId: number | null = null;+ let forcePinPending = false;++ const pinActiveScroller = (): void => {+ const scroller = getActiveScroller();+ if (!scroller) return;+ scroller.scrollTop = scroller.scrollHeight - scroller.clientHeight;+ followsBottom = true;+ };++ const schedulePin = (force: boolean): void => {+ forcePinPending ||= force;+ if (!forcePinPending && !followsBottom) return;+ if (frameId !== null) cancelFrame(frameId);+ frameId = requestFrame((): void => {+ frameId = null;+ const shouldForce = forcePinPending;+ forcePinPending = false;+ if (shouldForce || followsBottom) pinActiveScroller();+ });+ };++ const applyInset = (force = false): void => {+ container.style.setProperty(+ "--floating-inset",+ `${panel.offsetHeight + FLOATING_CHAT_INSET_EXTRA_PX}px`+ );+ schedulePin(force);+ };++ const updateFollowState = (): void => {+ const scroller = getActiveScroller();+ followsBottom = scroller !== null && isNearScrollBottom(scroller);+ };++ contentRoot.addEventListener("scroll", updateFollowState, true);+ applyInset(true);++ const observer = createResizeObserver((): void => applyInset());+ observer.observe(panel);+ observer.observe(contentRoot);++ return (): void => {+ observer.disconnect();+ contentRoot.removeEventListener("scroll", updateFollowState, true);+ if (frameId !== null) cancelFrame(frameId);+ container.style.removeProperty("--floating-inset");+ };+}diff --git a/src/components/ui/RichTextEditor.tsx b/src/components/ui/RichTextEditor.tsxindex c0c4d9f72..e9dfd90d9 100644--- a/src/components/ui/RichTextEditor.tsx+++ b/src/components/ui/RichTextEditor.tsx@@ -120,7 +120,12 @@ export function RichTextEditor({<div className={cn("relative w-full h-full", className)} onClick={handleClick}><EditorContenteditor={editor}- className={cn("h-full overflow-y-auto", disabled && "pointer-events-none opacity-70")}+ className={cn(+ "h-full overflow-y-auto",+ disabled && "pointer-events-none opacity-70",+ // Reserved by an ancestor via --floating-inset; 0 elsewhere.+ "pb-[var(--floating-inset,0px)]"+ )}/></div>);diff --git a/src/hooks/useStickToBottom.ts b/src/hooks/useStickToBottom.tsindex 6d38e15b1..836916926 100644--- a/src/hooks/useStickToBottom.ts+++ b/src/hooks/useStickToBottom.ts@@ -33,6 +33,15 @@ export function useStickToBottom<T extends HTMLElement>(const bottom = node.scrollHeight - node.clientHeight;if (bottom > 0 && Math.abs(node.scrollTop - bottom) > 1) node.scrollTop = bottom;}+ // Re-pin when content height settles late; re-attached per dep since the+ // content element can swap (empty state → list).+ const content = node.firstElementChild;+ if (!content) return;+ const ro = new ResizeObserver(() => {+ if (pinnedRef.current) node.scrollTop = node.scrollHeight - node.clientHeight;+ });+ ro.observe(content);+ return () => ro.disconnect();}, [dep, resetToTop]);const handleScroll = useCallback(() => {diff --git a/test/components/floatingChatLayout.test.js b/test/components/floatingChatLayout.test.jsnew file mode 100644index 000000000..c518e2644--- /dev/null+++ b/test/components/floatingChatLayout.test.js@@ -0,0 +1,140 @@+const test = require("node:test");+const assert = require("node:assert/strict");++const load = () => import("../../src/components/notes/floatingChatLayout.ts");++function createElement(overrides = {}) {+ const listeners = new Map();+ const styleValues = new Map();++ return {+ scrollHeight: 0,+ scrollTop: 0,+ clientHeight: 0,+ offsetHeight: 0,+ style: {+ setProperty(name, value) {+ styleValues.set(name, value);+ },+ removeProperty(name) {+ styleValues.delete(name);+ },+ getPropertyValue(name) {+ return styleValues.get(name) ?? "";+ },+ },+ addEventListener(name, listener) {+ listeners.set(name, listener);+ },+ removeEventListener(name, listener) {+ if (listeners.get(name) === listener) listeners.delete(name);+ },+ dispatch(name) {+ listeners.get(name)?.();+ },+ hasListener(name) {+ return listeners.has(name);+ },+ ...overrides,+ };+}++test("near-bottom detection uses the real scroll range", async () => {+ const { isNearScrollBottom } = await load();++ assert.equal(+ isNearScrollBottom({ scrollHeight: 1232, scrollTop: 700, clientHeight: 300 }),+ false,+ "232px of remaining padded scroll range is not near the bottom"+ );+ assert.equal(+ isNearScrollBottom({ scrollHeight: 1232, scrollTop: 852, clientHeight: 300 }),+ true,+ "80px from the scroll bottom remains pinned"+ );+});++test("viewport resizes preserve pinned content without yanking a reader", async () => {+ const { observeFloatingChatLayout } = await load();+ const panel = createElement({ offsetHeight: 200 });+ const container = createElement();+ const contentRoot = createElement();+ const scroller = createElement({ scrollHeight: 1000, scrollTop: 700, clientHeight: 300 });+ const observedElements = [];+ const scheduledFrames = new Map();+ let resizeCallback;+ let nextFrameId = 0;+ let observerDisconnected = false;++ const cleanup = observeFloatingChatLayout(+ {+ panel,+ container,+ contentRoot,+ getActiveScroller: () => scroller,+ },+ {+ createResizeObserver(callback) {+ resizeCallback = callback;+ return {+ observe(element) {+ observedElements.push(element);+ },+ disconnect() {+ observerDisconnected = true;+ },+ };+ },+ requestFrame(callback) {+ const frameId = ++nextFrameId;+ scheduledFrames.set(frameId, () => {+ scheduledFrames.delete(frameId);+ callback();+ });+ return frameId;+ },+ cancelFrame(frameId) {+ scheduledFrames.delete(frameId);+ },+ }+ );++ assert.deepEqual(observedElements, [panel, contentRoot]);+ assert.equal(container.style.getPropertyValue("--floating-inset"), "232px");++ scheduledFrames.get(nextFrameId)();+ scroller.clientHeight = 150;+ resizeCallback();+ scheduledFrames.get(nextFrameId)();+ assert.equal(scroller.scrollTop, 850, "a pinned scroller follows a viewport shrink");++ scroller.scrollTop = 600;+ contentRoot.dispatch("scroll");+ panel.offsetHeight = 240;+ resizeCallback();+ assert.equal(scheduledFrames.size, 0, "a reader away from the bottom is not scheduled to move");+ assert.equal(scroller.scrollTop, 600);++ scroller.scrollTop = 850;+ contentRoot.dispatch("scroll");+ resizeCallback();+ assert.equal(scheduledFrames.size, 1);++ cleanup();+ assert.equal(observerDisconnected, true);+ assert.equal(contentRoot.hasListener("scroll"), false);+ assert.equal(scheduledFrames.size, 0);+ assert.equal(container.style.getPropertyValue("--floating-inset"), "");+});++test("the panel cap leaves the promised note content visible", async () => {+ const {+ FLOATING_CHAT_INSET_EXTRA_PX,+ FLOATING_CHAT_MAX_HEIGHT_CSS,+ FLOATING_CHAT_MIN_VISIBLE_CONTENT_PX,+ } = await load();++ assert.equal(FLOATING_CHAT_INSET_EXTRA_PX, 32);+ assert.equal(FLOATING_CHAT_MIN_VISIBLE_CONTENT_PX, 80);+ assert.equal(FLOATING_CHAT_MAX_HEIGHT_CSS, "calc(100% - 7rem)");+});