Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions ui/desktop/src/components/MarkdownContent.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState, useEffect } from 'react';
import React, { useState, useEffect, useRef } from 'react';
import ReactMarkdown from 'react-markdown';
import remarkGfm from 'remark-gfm';
import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter';
Expand All @@ -17,16 +17,31 @@ interface MarkdownContentProps {

const CodeBlock = ({ language, children }: { language: string; children: string }) => {
const [copied, setCopied] = useState(false);
const timeoutRef = useRef<number | null>(null);

const handleCopy = async () => {
try {
await navigator.clipboard.writeText(children);
setCopied(true);
setTimeout(() => setCopied(false), 2000); // Reset after 2 seconds

if (timeoutRef.current) {
window.clearTimeout(timeoutRef.current);
}

timeoutRef.current = window.setTimeout(() => setCopied(false), 2000);
} catch (err) {
console.error('Failed to copy text: ', err);
}
};

useEffect(() => {
return () => {
if (timeoutRef.current) {
window.clearTimeout(timeoutRef.current);
}
};
}, []);

return (
<div className="relative group w-full">
<button
Expand Down
13 changes: 9 additions & 4 deletions ui/desktop/src/components/ProgressiveMessageList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,16 @@ export default function ProgressiveMessageList({

// Force complete rendering when search is active
useEffect(() => {
// Only add listener if we're actually loading
if (!isLoading) {
return;
}

const handleKeyDown = (e: KeyboardEvent) => {
const isMac = window.electron.platform === 'darwin';
const isSearchShortcut = (isMac ? e.metaKey : e.ctrlKey) && e.key === 'f';

if (isSearchShortcut && isLoading) {
if (isSearchShortcut) {
// Immediately render all messages when search is triggered
setRenderedCount(messages.length);
setIsLoading(false);
Expand Down Expand Up @@ -248,14 +253,14 @@ export default function ProgressiveMessageList({
renderedCount,
renderMessage,
isUserMessage,
hasContextHandlerContent,
getContextHandlerType,
chat,
append,
appendMessage,
toolCallNotifications,
onScrollToBottom,
isStreamingMessage,
hasContextHandlerContent,
getContextHandlerType,
onScrollToBottom,
]);

return (
Expand Down
Loading