Tweaked copy button placement

This commit is contained in:
James Ketr 2025-04-26 16:36:51 -07:00
parent 5f184b4a1d
commit 8525335345
7 changed files with 85 additions and 30 deletions

View File

@ -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: (
<Scrollable
autoscroll={false}
sx={{
maxWidth: "1024px",
height: "calc(100vh - 72px)",

View File

@ -53,15 +53,15 @@ const useAutoScrollToBottom = (
behavior: smooth ? 'smooth' : 'auto'
});
} else {
console.log('Not scrolling', {
isNearBottom,
isUserScrollingUp,
scrollHeight: container.scrollHeight,
scrollTop: container.scrollTop,
clientHeight: container.clientHeight,
threshold,
delta: container.scrollHeight - container.scrollTop - container.clientHeight
});
// console.log('Not scrolling', {
// isNearBottom,
// isUserScrollingUp,
// scrollHeight: container.scrollHeight,
// scrollTop: container.scrollTop,
// clientHeight: container.clientHeight,
// threshold,
// delta: container.scrollHeight - container.scrollTop - container.clientHeight
// });
}
};
@ -130,9 +130,11 @@ const useAutoScrollToBottom = (
interface ScrollableProps {
children?: React.ReactNode;
sx?: SxProps<Theme>,
autoscroll?: boolean,
}
const Scrollable = ({ sx, children }: ScrollableProps) => {
const Scrollable = (props: ScrollableProps) => {
const { sx, children, autoscroll } = props;
const scrollRef = useAutoScrollToBottom();
return <Box
sx={{
@ -143,7 +145,7 @@ const Scrollable = ({ sx, children }: ScrollableProps) => {
backgroundColor: "#F5F5F5",
...sx
}}
ref={scrollRef}
ref={(autoscroll !== undefined && autoscroll !== false) ? scrollRef : undefined}
>{children}</Box>;
};

View File

@ -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<Theme>,
className?: string,
active: boolean,
}
function BackstoryTab(props: BackstoryTabProps) {
const { className, active, children, sx, ...other } = props;
return (
<Box
className={ className || "BackstoryTab"}
sx={{ "display": active ? "flex": "none", ...sx }}
{...other}
>
{children}
</Box>
);
}
export {
BackstoryTab
}

View File

@ -32,9 +32,6 @@ return (
<IconButton
onClick={handleCopy}
sx={{
position: 'absolute',
top: 0,
right: 0,
width: 24,
height: 24,
opacity: 0.75,

View File

@ -255,9 +255,7 @@ const Message = (props: MessageProps) => {
// overflowX: "auto"
...sx,
}}>
<CardContent ref={textFieldRef} sx={{ position: "relative", display: "flex", flexDirection: "column", overflowX: "auto", m: 0, p: 0 }}>
<CopyBubble content={message?.content} />
<CardContent ref={textFieldRef} sx={{ position: "relative", display: "flex", flexDirection: "column", overflowX: "auto", m: 0, p: 0, paddingBottom: '0px !important' }}>
{message.role !== 'user' ?
<StyledMarkdown
className="MessageContent"
@ -273,9 +271,13 @@ const Message = (props: MessageProps) => {
</Typography>
}
</CardContent>
{message.metadata && <>
<CardActions disableSpacing sx={{ justifySelf: "flex-end", alignSelf: "flex-end" }}>
<Button variant="text" onClick={handleExpandClick} sx={{ color: "darkgrey", p: 1, flexGrow: 0, justifySelf: "flex-end" }}>LLM information for this query</Button>
<CardActions disableSpacing sx={{ display: "flex", flexDirection: "row", justifyContent: "space-between", alignItems: "center", width: "100%" }}>
<CopyBubble content={message?.content} />
{message.metadata && (
<Box sx={{ display: "flex", alignItems: "center", gap: 1 }}>
<Button variant="text" onClick={handleExpandClick} sx={{ color: "darkgrey", p: 1 }}>
LLM information for this query
</Button>
<ExpandMore
expand={expanded}
onClick={handleExpandClick}
@ -284,7 +286,10 @@ const Message = (props: MessageProps) => {
>
<ExpandMoreIcon />
</ExpandMore>
</Box>
)}
</CardActions>
{message.metadata && <>
<Collapse in={expanded} timeout="auto" unmountOnExit>
<CardContent>
<MessageMeta {...{ ...message.metadata, sessionId, connectionBase, setSnack }} />

View File

@ -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;
}

View File

@ -142,6 +142,11 @@ const VectorVisualizer: React.FC<VectorVisualizerProps> = (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;