From 852533534531b91c6e30e18cfcc99c9520bb5b56 Mon Sep 17 00:00:00 2001 From: James Ketrenos Date: Sat, 26 Apr 2025 16:36:51 -0700 Subject: [PATCH] Tweaked copy button placement --- frontend/src/App.tsx | 3 +-- frontend/src/AutoScroll.tsx | 24 +++++++++++----------- frontend/src/BackstoryTab.tsx | 28 ++++++++++++++++++++++++++ frontend/src/CopyBubble.tsx | 3 --- frontend/src/Message.tsx | 33 ++++++++++++++++++------------- frontend/src/VectorVisualizer.css | 19 ++++++++++++++++++ frontend/src/VectorVisualizer.tsx | 5 +++++ 7 files changed, 85 insertions(+), 30 deletions(-) create mode 100644 frontend/src/BackstoryTab.tsx create mode 100644 frontend/src/VectorVisualizer.css diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 954349d..9da6ed2 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -112,14 +112,12 @@ const App = () => { fetchAbout(); }, [about, setAbout]) - const handleSubmitChatQuery = (query: string) => { console.log(`handleSubmitChatQuery: ${query} -- `, chatRef.current ? ' sending' : 'no handler'); chatRef.current?.submitQuery(query); setActiveTab(0); }; - const tabs: TabProps[] = useMemo(() => { const backstoryPreamble: MessageList = [ { @@ -221,6 +219,7 @@ const App = () => { path: "about", children: ( , + autoscroll?: boolean, } -const Scrollable = ({ sx, children }: ScrollableProps) => { +const Scrollable = (props: ScrollableProps) => { + const { sx, children, autoscroll } = props; const scrollRef = useAutoScrollToBottom(); return { backgroundColor: "#F5F5F5", ...sx }} - ref={scrollRef} + ref={(autoscroll !== undefined && autoscroll !== false) ? scrollRef : undefined} >{children}; }; diff --git a/frontend/src/BackstoryTab.tsx b/frontend/src/BackstoryTab.tsx new file mode 100644 index 0000000..9afb29b --- /dev/null +++ b/frontend/src/BackstoryTab.tsx @@ -0,0 +1,28 @@ +import React from 'react'; +import Box from '@mui/material/Box'; +import { SxProps, Theme } from '@mui/material'; + +interface BackstoryTabProps { + children?: React.ReactNode; + sx?: SxProps, + className?: string, + active: boolean, +} + +function BackstoryTab(props: BackstoryTabProps) { + const { className, active, children, sx, ...other } = props; + + return ( + + {children} + + ); +} + +export { + BackstoryTab +} \ No newline at end of file diff --git a/frontend/src/CopyBubble.tsx b/frontend/src/CopyBubble.tsx index d08ef66..9c1f7bb 100644 --- a/frontend/src/CopyBubble.tsx +++ b/frontend/src/CopyBubble.tsx @@ -32,9 +32,6 @@ return ( { // overflowX: "auto" ...sx, }}> - - - + {message.role !== 'user' ? { } + + + {message.metadata && ( + + + + + + + )} + {message.metadata && <> - - - - - - diff --git a/frontend/src/VectorVisualizer.css b/frontend/src/VectorVisualizer.css new file mode 100644 index 0000000..21c2296 --- /dev/null +++ b/frontend/src/VectorVisualizer.css @@ -0,0 +1,19 @@ +.js-plotly-plot { + width: 100%; + height: 100%; +} + +.js-plotly-plot .plotly { + width: 100%; + height: 100%; +} + +.js-plotly-plot .plotly .main-svg { + width: 100%; + height: 100%; +} + +.plotly .svg-container { + width: 100% !important; + height: 100% !important; +} \ No newline at end of file diff --git a/frontend/src/VectorVisualizer.tsx b/frontend/src/VectorVisualizer.tsx index 63b4972..31f4f91 100644 --- a/frontend/src/VectorVisualizer.tsx +++ b/frontend/src/VectorVisualizer.tsx @@ -142,6 +142,11 @@ const VectorVisualizer: React.FC = (props: VectorVisualiz fetchCollection(); }, [result, setResult, connectionBase, setSnack, sessionId, view2D]) + /* Trigger a resize event to force Plotly to rescale */ + useEffect(() => { + window.dispatchEvent(new Event('resize')); + }, []) + useEffect(() => { if (!result || !result.embeddings) return; if (result.embeddings.length === 0) return;