feat(dashboard): Implement Widget Configuration and Display Components
- Added WidgetConfigModal for creating and editing widgets with fields for title, sources, prompt, provider, model, and refresh frequency.
- Integrated MarkdownRenderer for displaying widget content previews.
- Created WidgetDisplay component to show widget details, including loading states, error handling, and source information.
- Developed a reusable Card component structure for consistent UI presentation.
- Introduced useDashboard hook for managing widget state, including adding, updating, deleting, and refreshing widgets.
- Implemented local storage management for dashboard state and settings.
- Added types for widgets, dashboard configuration, and API requests/responses to improve type safety and clarity.
2025-07-19 08:23:06 -06:00
|
|
|
/* eslint-disable @next/next/no-img-element */
|
|
|
|
|
'use client';
|
|
|
|
|
|
|
|
|
|
import { cn } from '@/lib/utils';
|
2025-08-04 00:41:31 -06:00
|
|
|
import {
|
|
|
|
|
CheckCheck,
|
|
|
|
|
Copy as CopyIcon,
|
|
|
|
|
Search,
|
|
|
|
|
FileText,
|
|
|
|
|
Globe,
|
|
|
|
|
Settings,
|
|
|
|
|
} from 'lucide-react';
|
feat(dashboard): Implement Widget Configuration and Display Components
- Added WidgetConfigModal for creating and editing widgets with fields for title, sources, prompt, provider, model, and refresh frequency.
- Integrated MarkdownRenderer for displaying widget content previews.
- Created WidgetDisplay component to show widget details, including loading states, error handling, and source information.
- Developed a reusable Card component structure for consistent UI presentation.
- Introduced useDashboard hook for managing widget state, including adding, updating, deleting, and refreshing widgets.
- Implemented local storage management for dashboard state and settings.
- Added types for widgets, dashboard configuration, and API requests/responses to improve type safety and clarity.
2025-07-19 08:23:06 -06:00
|
|
|
import Markdown, { MarkdownToJSX } from 'markdown-to-jsx';
|
|
|
|
|
import { useState } from 'react';
|
|
|
|
|
import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter';
|
2025-07-21 23:49:09 -06:00
|
|
|
import {
|
|
|
|
|
oneDark,
|
|
|
|
|
oneLight,
|
|
|
|
|
} from 'react-syntax-highlighter/dist/cjs/styles/prism';
|
2025-07-19 17:25:52 -06:00
|
|
|
import { useTheme } from 'next-themes';
|
feat(dashboard): Implement Widget Configuration and Display Components
- Added WidgetConfigModal for creating and editing widgets with fields for title, sources, prompt, provider, model, and refresh frequency.
- Integrated MarkdownRenderer for displaying widget content previews.
- Created WidgetDisplay component to show widget details, including loading states, error handling, and source information.
- Developed a reusable Card component structure for consistent UI presentation.
- Introduced useDashboard hook for managing widget state, including adding, updating, deleting, and refreshing widgets.
- Implemented local storage management for dashboard state and settings.
- Added types for widgets, dashboard configuration, and API requests/responses to improve type safety and clarity.
2025-07-19 08:23:06 -06:00
|
|
|
import ThinkBox from './ThinkBox';
|
2025-08-04 00:41:31 -06:00
|
|
|
import { Document } from '@langchain/core/documents';
|
|
|
|
|
import CitationLink from './CitationLink';
|
feat(dashboard): Implement Widget Configuration and Display Components
- Added WidgetConfigModal for creating and editing widgets with fields for title, sources, prompt, provider, model, and refresh frequency.
- Integrated MarkdownRenderer for displaying widget content previews.
- Created WidgetDisplay component to show widget details, including loading states, error handling, and source information.
- Developed a reusable Card component structure for consistent UI presentation.
- Introduced useDashboard hook for managing widget state, including adding, updating, deleting, and refreshing widgets.
- Implemented local storage management for dashboard state and settings.
- Added types for widgets, dashboard configuration, and API requests/responses to improve type safety and clarity.
2025-07-19 08:23:06 -06:00
|
|
|
|
|
|
|
|
// Helper functions for think overlay
|
|
|
|
|
const extractThinkContent = (content: string): string | null => {
|
2025-08-03 15:48:34 -06:00
|
|
|
const thinkRegex = /<think[^>]*>([\s\S]*?)<\/think>/g;
|
feat(dashboard): Implement Widget Configuration and Display Components
- Added WidgetConfigModal for creating and editing widgets with fields for title, sources, prompt, provider, model, and refresh frequency.
- Integrated MarkdownRenderer for displaying widget content previews.
- Created WidgetDisplay component to show widget details, including loading states, error handling, and source information.
- Developed a reusable Card component structure for consistent UI presentation.
- Introduced useDashboard hook for managing widget state, including adding, updating, deleting, and refreshing widgets.
- Implemented local storage management for dashboard state and settings.
- Added types for widgets, dashboard configuration, and API requests/responses to improve type safety and clarity.
2025-07-19 08:23:06 -06:00
|
|
|
const matches = content.match(thinkRegex);
|
|
|
|
|
if (!matches) return null;
|
2025-07-19 11:34:56 -06:00
|
|
|
|
feat(dashboard): Implement Widget Configuration and Display Components
- Added WidgetConfigModal for creating and editing widgets with fields for title, sources, prompt, provider, model, and refresh frequency.
- Integrated MarkdownRenderer for displaying widget content previews.
- Created WidgetDisplay component to show widget details, including loading states, error handling, and source information.
- Developed a reusable Card component structure for consistent UI presentation.
- Introduced useDashboard hook for managing widget state, including adding, updating, deleting, and refreshing widgets.
- Implemented local storage management for dashboard state and settings.
- Added types for widgets, dashboard configuration, and API requests/responses to improve type safety and clarity.
2025-07-19 08:23:06 -06:00
|
|
|
// Extract content between think tags and join if multiple
|
|
|
|
|
const extractedContent = matches
|
2025-08-03 15:48:34 -06:00
|
|
|
.map((match) => match.replace(/<\/?think[^>]*>/g, ''))
|
feat(dashboard): Implement Widget Configuration and Display Components
- Added WidgetConfigModal for creating and editing widgets with fields for title, sources, prompt, provider, model, and refresh frequency.
- Integrated MarkdownRenderer for displaying widget content previews.
- Created WidgetDisplay component to show widget details, including loading states, error handling, and source information.
- Developed a reusable Card component structure for consistent UI presentation.
- Introduced useDashboard hook for managing widget state, including adding, updating, deleting, and refreshing widgets.
- Implemented local storage management for dashboard state and settings.
- Added types for widgets, dashboard configuration, and API requests/responses to improve type safety and clarity.
2025-07-19 08:23:06 -06:00
|
|
|
.join('\n\n');
|
2025-07-19 11:34:56 -06:00
|
|
|
|
feat(dashboard): Implement Widget Configuration and Display Components
- Added WidgetConfigModal for creating and editing widgets with fields for title, sources, prompt, provider, model, and refresh frequency.
- Integrated MarkdownRenderer for displaying widget content previews.
- Created WidgetDisplay component to show widget details, including loading states, error handling, and source information.
- Developed a reusable Card component structure for consistent UI presentation.
- Introduced useDashboard hook for managing widget state, including adding, updating, deleting, and refreshing widgets.
- Implemented local storage management for dashboard state and settings.
- Added types for widgets, dashboard configuration, and API requests/responses to improve type safety and clarity.
2025-07-19 08:23:06 -06:00
|
|
|
// Return null if content is empty or only whitespace
|
|
|
|
|
return extractedContent.trim().length === 0 ? null : extractedContent;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const removeThinkTags = (content: string): string => {
|
2025-08-03 15:48:34 -06:00
|
|
|
return content.replace(/<think[^>]*>[\s\S]*?<\/think>/g, '').trim();
|
feat(dashboard): Implement Widget Configuration and Display Components
- Added WidgetConfigModal for creating and editing widgets with fields for title, sources, prompt, provider, model, and refresh frequency.
- Integrated MarkdownRenderer for displaying widget content previews.
- Created WidgetDisplay component to show widget details, including loading states, error handling, and source information.
- Developed a reusable Card component structure for consistent UI presentation.
- Introduced useDashboard hook for managing widget state, including adding, updating, deleting, and refreshing widgets.
- Implemented local storage management for dashboard state and settings.
- Added types for widgets, dashboard configuration, and API requests/responses to improve type safety and clarity.
2025-07-19 08:23:06 -06:00
|
|
|
};
|
|
|
|
|
|
2025-08-03 15:48:34 -06:00
|
|
|
// Add stable IDs to think tags if they don't already have them
|
|
|
|
|
const addThinkBoxIds = (content: string): string => {
|
|
|
|
|
let thinkCounter = 0;
|
|
|
|
|
return content.replace(/<think(?![^>]*\sid=)/g, () => {
|
|
|
|
|
return `<think id="think-${thinkCounter++}"`;
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
interface MarkdownRendererProps {
|
|
|
|
|
content: string;
|
|
|
|
|
className?: string;
|
|
|
|
|
showThinking?: boolean;
|
|
|
|
|
messageId?: string;
|
|
|
|
|
expandedThinkBoxes?: Set<string>;
|
|
|
|
|
onThinkBoxToggle?: (
|
|
|
|
|
messageId: string,
|
|
|
|
|
thinkBoxId: string,
|
|
|
|
|
expanded: boolean,
|
|
|
|
|
) => void;
|
2025-08-04 00:41:31 -06:00
|
|
|
sources?: Document[];
|
2025-08-03 15:48:34 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Custom ToolCall component for markdown
|
|
|
|
|
const ToolCall = ({
|
|
|
|
|
type,
|
|
|
|
|
query,
|
|
|
|
|
urls,
|
|
|
|
|
count,
|
2025-07-19 11:34:56 -06:00
|
|
|
children,
|
|
|
|
|
}: {
|
2025-08-03 15:48:34 -06:00
|
|
|
type?: string;
|
|
|
|
|
query?: string;
|
|
|
|
|
urls?: string;
|
|
|
|
|
count?: string;
|
|
|
|
|
children?: React.ReactNode;
|
feat(dashboard): Implement Widget Configuration and Display Components
- Added WidgetConfigModal for creating and editing widgets with fields for title, sources, prompt, provider, model, and refresh frequency.
- Integrated MarkdownRenderer for displaying widget content previews.
- Created WidgetDisplay component to show widget details, including loading states, error handling, and source information.
- Developed a reusable Card component structure for consistent UI presentation.
- Introduced useDashboard hook for managing widget state, including adding, updating, deleting, and refreshing widgets.
- Implemented local storage management for dashboard state and settings.
- Added types for widgets, dashboard configuration, and API requests/responses to improve type safety and clarity.
2025-07-19 08:23:06 -06:00
|
|
|
}) => {
|
2025-08-03 15:48:34 -06:00
|
|
|
const getIcon = (toolType: string) => {
|
|
|
|
|
switch (toolType) {
|
|
|
|
|
case 'search':
|
|
|
|
|
case 'web_search':
|
|
|
|
|
return (
|
|
|
|
|
<Search size={16} className="text-blue-600 dark:text-blue-400" />
|
|
|
|
|
);
|
|
|
|
|
case 'file':
|
|
|
|
|
case 'file_search':
|
|
|
|
|
return (
|
|
|
|
|
<FileText size={16} className="text-green-600 dark:text-green-400" />
|
|
|
|
|
);
|
|
|
|
|
case 'url':
|
|
|
|
|
case 'url_summarization':
|
|
|
|
|
return (
|
|
|
|
|
<Globe size={16} className="text-purple-600 dark:text-purple-400" />
|
|
|
|
|
);
|
|
|
|
|
default:
|
|
|
|
|
return (
|
|
|
|
|
<Settings size={16} className="text-gray-600 dark:text-gray-400" />
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const formatToolMessage = () => {
|
|
|
|
|
if (type === 'search' || type === 'web_search') {
|
|
|
|
|
return (
|
|
|
|
|
<>
|
|
|
|
|
<span className="mr-2">{getIcon(type)}</span>
|
|
|
|
|
<span className="text-black/60 dark:text-white/60">Web search:</span>
|
|
|
|
|
<span className="ml-2 px-2 py-0.5 bg-black/5 dark:bg-white/5 rounded font-mono text-sm">
|
|
|
|
|
{query || children}
|
|
|
|
|
</span>
|
|
|
|
|
</>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (type === 'file' || type === 'file_search') {
|
|
|
|
|
return (
|
|
|
|
|
<>
|
|
|
|
|
<span className="mr-2">{getIcon(type)}</span>
|
|
|
|
|
<span className="text-black/60 dark:text-white/60">File search:</span>
|
|
|
|
|
<span className="ml-2 px-2 py-0.5 bg-black/5 dark:bg-white/5 rounded font-mono text-sm">
|
|
|
|
|
{query || children}
|
|
|
|
|
</span>
|
|
|
|
|
</>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (type === 'url' || type === 'url_summarization') {
|
|
|
|
|
const urlCount = count ? parseInt(count) : 1;
|
|
|
|
|
return (
|
|
|
|
|
<>
|
|
|
|
|
<span className="mr-2">{getIcon(type)}</span>
|
|
|
|
|
<span className="text-black/60 dark:text-white/60">
|
|
|
|
|
Analyzing {urlCount} web page{urlCount === 1 ? '' : 's'} for
|
|
|
|
|
additional details
|
|
|
|
|
</span>
|
|
|
|
|
</>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Fallback for unknown tool types
|
|
|
|
|
return (
|
|
|
|
|
<>
|
|
|
|
|
<span className="mr-2">{getIcon(type || 'default')}</span>
|
|
|
|
|
<span className="text-black/60 dark:text-white/60">Using tool:</span>
|
|
|
|
|
<span className="ml-2 px-2 py-0.5 bg-black/5 dark:bg-white/5 rounded font-mono text-sm border">
|
|
|
|
|
{type || 'unknown'}
|
|
|
|
|
</span>
|
|
|
|
|
</>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div className="my-3 px-4 py-3 bg-gradient-to-r from-blue-50/50 to-purple-50/50 dark:from-blue-900/20 dark:to-purple-900/20 border border-blue-200/30 dark:border-blue-700/30 rounded-lg">
|
|
|
|
|
<div className="flex items-center text-sm font-medium">
|
|
|
|
|
{formatToolMessage()}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
feat(dashboard): Implement Widget Configuration and Display Components
- Added WidgetConfigModal for creating and editing widgets with fields for title, sources, prompt, provider, model, and refresh frequency.
- Integrated MarkdownRenderer for displaying widget content previews.
- Created WidgetDisplay component to show widget details, including loading states, error handling, and source information.
- Developed a reusable Card component structure for consistent UI presentation.
- Introduced useDashboard hook for managing widget state, including adding, updating, deleting, and refreshing widgets.
- Implemented local storage management for dashboard state and settings.
- Added types for widgets, dashboard configuration, and API requests/responses to improve type safety and clarity.
2025-07-19 08:23:06 -06:00
|
|
|
};
|
|
|
|
|
|
2025-08-03 15:48:34 -06:00
|
|
|
const ThinkTagProcessor = ({
|
|
|
|
|
children,
|
|
|
|
|
id,
|
|
|
|
|
isExpanded,
|
|
|
|
|
onToggle,
|
|
|
|
|
}: {
|
|
|
|
|
children: React.ReactNode;
|
|
|
|
|
id?: string;
|
|
|
|
|
isExpanded?: boolean;
|
|
|
|
|
onToggle?: (thinkBoxId: string, expanded: boolean) => void;
|
|
|
|
|
}) => {
|
|
|
|
|
return (
|
2025-08-04 00:41:31 -06:00
|
|
|
<ThinkBox
|
|
|
|
|
content={children}
|
2025-08-03 15:48:34 -06:00
|
|
|
expanded={isExpanded}
|
|
|
|
|
onToggle={() => {
|
|
|
|
|
if (id && onToggle) {
|
|
|
|
|
onToggle(id, !isExpanded);
|
|
|
|
|
}
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
);
|
2025-08-04 00:41:31 -06:00
|
|
|
};
|
|
|
|
|
const CodeBlock = ({
|
feat(dashboard): Implement Widget Configuration and Display Components
- Added WidgetConfigModal for creating and editing widgets with fields for title, sources, prompt, provider, model, and refresh frequency.
- Integrated MarkdownRenderer for displaying widget content previews.
- Created WidgetDisplay component to show widget details, including loading states, error handling, and source information.
- Developed a reusable Card component structure for consistent UI presentation.
- Introduced useDashboard hook for managing widget state, including adding, updating, deleting, and refreshing widgets.
- Implemented local storage management for dashboard state and settings.
- Added types for widgets, dashboard configuration, and API requests/responses to improve type safety and clarity.
2025-07-19 08:23:06 -06:00
|
|
|
className,
|
|
|
|
|
children,
|
|
|
|
|
}: {
|
|
|
|
|
className?: string;
|
|
|
|
|
children: React.ReactNode;
|
|
|
|
|
}) => {
|
2025-07-19 17:25:52 -06:00
|
|
|
const { theme } = useTheme();
|
2025-07-21 23:49:09 -06:00
|
|
|
|
feat(dashboard): Implement Widget Configuration and Display Components
- Added WidgetConfigModal for creating and editing widgets with fields for title, sources, prompt, provider, model, and refresh frequency.
- Integrated MarkdownRenderer for displaying widget content previews.
- Created WidgetDisplay component to show widget details, including loading states, error handling, and source information.
- Developed a reusable Card component structure for consistent UI presentation.
- Introduced useDashboard hook for managing widget state, including adding, updating, deleting, and refreshing widgets.
- Implemented local storage management for dashboard state and settings.
- Added types for widgets, dashboard configuration, and API requests/responses to improve type safety and clarity.
2025-07-19 08:23:06 -06:00
|
|
|
// Extract language from className (format could be "language-javascript" or "lang-javascript")
|
|
|
|
|
let language = '';
|
|
|
|
|
if (className) {
|
|
|
|
|
if (className.startsWith('language-')) {
|
|
|
|
|
language = className.replace('language-', '');
|
|
|
|
|
} else if (className.startsWith('lang-')) {
|
|
|
|
|
language = className.replace('lang-', '');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const content = children as string;
|
|
|
|
|
const [isCopied, setIsCopied] = useState(false);
|
|
|
|
|
|
|
|
|
|
const handleCopyCode = () => {
|
|
|
|
|
navigator.clipboard.writeText(content);
|
|
|
|
|
setIsCopied(true);
|
|
|
|
|
setTimeout(() => setIsCopied(false), 2000);
|
|
|
|
|
};
|
|
|
|
|
|
2025-07-19 17:25:52 -06:00
|
|
|
// Choose syntax highlighting style based on theme
|
|
|
|
|
const syntaxStyle = theme === 'light' ? oneLight : oneDark;
|
|
|
|
|
const backgroundStyle = theme === 'light' ? '#fafafa' : '#1c1c1c';
|
|
|
|
|
|
feat(dashboard): Implement Widget Configuration and Display Components
- Added WidgetConfigModal for creating and editing widgets with fields for title, sources, prompt, provider, model, and refresh frequency.
- Integrated MarkdownRenderer for displaying widget content previews.
- Created WidgetDisplay component to show widget details, including loading states, error handling, and source information.
- Developed a reusable Card component structure for consistent UI presentation.
- Introduced useDashboard hook for managing widget state, including adding, updating, deleting, and refreshing widgets.
- Implemented local storage management for dashboard state and settings.
- Added types for widgets, dashboard configuration, and API requests/responses to improve type safety and clarity.
2025-07-19 08:23:06 -06:00
|
|
|
return (
|
2025-07-19 17:25:52 -06:00
|
|
|
<div className="rounded-md overflow-hidden my-4 relative group border border-light-200 dark:border-dark-secondary">
|
|
|
|
|
<div className="flex justify-between items-center px-4 py-2 bg-light-100 dark:bg-dark-200 border-b border-light-200 dark:border-dark-secondary text-xs text-black/70 dark:text-white/70 font-mono">
|
feat(dashboard): Implement Widget Configuration and Display Components
- Added WidgetConfigModal for creating and editing widgets with fields for title, sources, prompt, provider, model, and refresh frequency.
- Integrated MarkdownRenderer for displaying widget content previews.
- Created WidgetDisplay component to show widget details, including loading states, error handling, and source information.
- Developed a reusable Card component structure for consistent UI presentation.
- Introduced useDashboard hook for managing widget state, including adding, updating, deleting, and refreshing widgets.
- Implemented local storage management for dashboard state and settings.
- Added types for widgets, dashboard configuration, and API requests/responses to improve type safety and clarity.
2025-07-19 08:23:06 -06:00
|
|
|
<span>{language}</span>
|
|
|
|
|
<button
|
|
|
|
|
onClick={handleCopyCode}
|
2025-07-19 17:25:52 -06:00
|
|
|
className="p-1 rounded-md hover:bg-light-200 dark:hover:bg-dark-secondary transition duration-200"
|
feat(dashboard): Implement Widget Configuration and Display Components
- Added WidgetConfigModal for creating and editing widgets with fields for title, sources, prompt, provider, model, and refresh frequency.
- Integrated MarkdownRenderer for displaying widget content previews.
- Created WidgetDisplay component to show widget details, including loading states, error handling, and source information.
- Developed a reusable Card component structure for consistent UI presentation.
- Introduced useDashboard hook for managing widget state, including adding, updating, deleting, and refreshing widgets.
- Implemented local storage management for dashboard state and settings.
- Added types for widgets, dashboard configuration, and API requests/responses to improve type safety and clarity.
2025-07-19 08:23:06 -06:00
|
|
|
aria-label="Copy code to clipboard"
|
|
|
|
|
>
|
|
|
|
|
{isCopied ? (
|
|
|
|
|
<CheckCheck size={14} className="text-green-500" />
|
|
|
|
|
) : (
|
2025-07-19 17:25:52 -06:00
|
|
|
<CopyIcon size={14} className="text-black/70 dark:text-white/70" />
|
feat(dashboard): Implement Widget Configuration and Display Components
- Added WidgetConfigModal for creating and editing widgets with fields for title, sources, prompt, provider, model, and refresh frequency.
- Integrated MarkdownRenderer for displaying widget content previews.
- Created WidgetDisplay component to show widget details, including loading states, error handling, and source information.
- Developed a reusable Card component structure for consistent UI presentation.
- Introduced useDashboard hook for managing widget state, including adding, updating, deleting, and refreshing widgets.
- Implemented local storage management for dashboard state and settings.
- Added types for widgets, dashboard configuration, and API requests/responses to improve type safety and clarity.
2025-07-19 08:23:06 -06:00
|
|
|
)}
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
<SyntaxHighlighter
|
|
|
|
|
language={language || 'text'}
|
2025-07-19 17:25:52 -06:00
|
|
|
style={syntaxStyle}
|
feat(dashboard): Implement Widget Configuration and Display Components
- Added WidgetConfigModal for creating and editing widgets with fields for title, sources, prompt, provider, model, and refresh frequency.
- Integrated MarkdownRenderer for displaying widget content previews.
- Created WidgetDisplay component to show widget details, including loading states, error handling, and source information.
- Developed a reusable Card component structure for consistent UI presentation.
- Introduced useDashboard hook for managing widget state, including adding, updating, deleting, and refreshing widgets.
- Implemented local storage management for dashboard state and settings.
- Added types for widgets, dashboard configuration, and API requests/responses to improve type safety and clarity.
2025-07-19 08:23:06 -06:00
|
|
|
customStyle={{
|
|
|
|
|
margin: 0,
|
|
|
|
|
padding: '1rem',
|
|
|
|
|
borderRadius: 0,
|
2025-07-19 17:25:52 -06:00
|
|
|
backgroundColor: backgroundStyle,
|
feat(dashboard): Implement Widget Configuration and Display Components
- Added WidgetConfigModal for creating and editing widgets with fields for title, sources, prompt, provider, model, and refresh frequency.
- Integrated MarkdownRenderer for displaying widget content previews.
- Created WidgetDisplay component to show widget details, including loading states, error handling, and source information.
- Developed a reusable Card component structure for consistent UI presentation.
- Introduced useDashboard hook for managing widget state, including adding, updating, deleting, and refreshing widgets.
- Implemented local storage management for dashboard state and settings.
- Added types for widgets, dashboard configuration, and API requests/responses to improve type safety and clarity.
2025-07-19 08:23:06 -06:00
|
|
|
}}
|
|
|
|
|
wrapLines={true}
|
|
|
|
|
wrapLongLines={true}
|
|
|
|
|
showLineNumbers={language !== '' && content.split('\n').length > 1}
|
|
|
|
|
useInlineStyles={true}
|
|
|
|
|
PreTag="div"
|
|
|
|
|
>
|
|
|
|
|
{content}
|
|
|
|
|
</SyntaxHighlighter>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
2025-07-19 11:34:56 -06:00
|
|
|
const MarkdownRenderer = ({
|
|
|
|
|
content,
|
|
|
|
|
className,
|
2025-08-03 15:48:34 -06:00
|
|
|
showThinking = true,
|
|
|
|
|
messageId,
|
|
|
|
|
expandedThinkBoxes,
|
|
|
|
|
onThinkBoxToggle,
|
2025-08-04 00:41:31 -06:00
|
|
|
sources,
|
2025-07-19 11:34:56 -06:00
|
|
|
}: MarkdownRendererProps) => {
|
2025-08-03 15:48:34 -06:00
|
|
|
// Preprocess content to add stable IDs to think tags
|
|
|
|
|
const processedContent = addThinkBoxIds(content);
|
|
|
|
|
|
|
|
|
|
// Check if a think box is expanded
|
|
|
|
|
const isThinkBoxExpanded = (thinkBoxId: string) => {
|
|
|
|
|
return expandedThinkBoxes?.has(thinkBoxId) || false;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Handle think box toggle
|
|
|
|
|
const handleThinkBoxToggle = (thinkBoxId: string, expanded: boolean) => {
|
|
|
|
|
if (messageId && onThinkBoxToggle) {
|
|
|
|
|
onThinkBoxToggle(messageId, thinkBoxId, expanded);
|
|
|
|
|
}
|
|
|
|
|
};
|
2025-07-19 11:34:56 -06:00
|
|
|
|
2025-08-03 15:48:34 -06:00
|
|
|
// Determine what content to render based on showThinking parameter
|
2025-08-04 00:41:31 -06:00
|
|
|
const contentToRender = showThinking
|
2025-08-03 15:48:34 -06:00
|
|
|
? processedContent
|
|
|
|
|
: removeThinkTags(processedContent);
|
feat(dashboard): Implement Widget Configuration and Display Components
- Added WidgetConfigModal for creating and editing widgets with fields for title, sources, prompt, provider, model, and refresh frequency.
- Integrated MarkdownRenderer for displaying widget content previews.
- Created WidgetDisplay component to show widget details, including loading states, error handling, and source information.
- Developed a reusable Card component structure for consistent UI presentation.
- Introduced useDashboard hook for managing widget state, including adding, updating, deleting, and refreshing widgets.
- Implemented local storage management for dashboard state and settings.
- Added types for widgets, dashboard configuration, and API requests/responses to improve type safety and clarity.
2025-07-19 08:23:06 -06:00
|
|
|
// Markdown formatting options
|
|
|
|
|
const markdownOverrides: MarkdownToJSX.Options = {
|
|
|
|
|
overrides: {
|
2025-08-03 15:48:34 -06:00
|
|
|
ToolCall: {
|
|
|
|
|
component: ToolCall,
|
|
|
|
|
},
|
feat(dashboard): Implement Widget Configuration and Display Components
- Added WidgetConfigModal for creating and editing widgets with fields for title, sources, prompt, provider, model, and refresh frequency.
- Integrated MarkdownRenderer for displaying widget content previews.
- Created WidgetDisplay component to show widget details, including loading states, error handling, and source information.
- Developed a reusable Card component structure for consistent UI presentation.
- Introduced useDashboard hook for managing widget state, including adding, updating, deleting, and refreshing widgets.
- Implemented local storage management for dashboard state and settings.
- Added types for widgets, dashboard configuration, and API requests/responses to improve type safety and clarity.
2025-07-19 08:23:06 -06:00
|
|
|
think: {
|
2025-08-03 15:48:34 -06:00
|
|
|
component: ({ children, id, ...props }) => {
|
|
|
|
|
// Use the id from the HTML attribute
|
|
|
|
|
const thinkBoxId = id || 'think-unknown';
|
|
|
|
|
const isExpanded = isThinkBoxExpanded(thinkBoxId);
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<ThinkTagProcessor
|
|
|
|
|
id={thinkBoxId}
|
|
|
|
|
isExpanded={isExpanded}
|
|
|
|
|
onToggle={handleThinkBoxToggle}
|
|
|
|
|
>
|
|
|
|
|
{children}
|
|
|
|
|
</ThinkTagProcessor>
|
|
|
|
|
);
|
|
|
|
|
},
|
feat(dashboard): Implement Widget Configuration and Display Components
- Added WidgetConfigModal for creating and editing widgets with fields for title, sources, prompt, provider, model, and refresh frequency.
- Integrated MarkdownRenderer for displaying widget content previews.
- Created WidgetDisplay component to show widget details, including loading states, error handling, and source information.
- Developed a reusable Card component structure for consistent UI presentation.
- Introduced useDashboard hook for managing widget state, including adding, updating, deleting, and refreshing widgets.
- Implemented local storage management for dashboard state and settings.
- Added types for widgets, dashboard configuration, and API requests/responses to improve type safety and clarity.
2025-07-19 08:23:06 -06:00
|
|
|
},
|
|
|
|
|
code: {
|
|
|
|
|
component: ({ className, children }) => {
|
|
|
|
|
// Check if it's an inline code block or a fenced code block
|
|
|
|
|
if (className) {
|
|
|
|
|
// This is a fenced code block (```code```)
|
|
|
|
|
return <CodeBlock className={className}>{children}</CodeBlock>;
|
|
|
|
|
}
|
|
|
|
|
// This is an inline code block (`code`)
|
|
|
|
|
return (
|
2025-07-19 17:25:52 -06:00
|
|
|
<code className="px-1.5 py-0.5 rounded bg-light-200 dark:bg-dark-secondary text-black dark:text-white font-mono text-sm">
|
feat(dashboard): Implement Widget Configuration and Display Components
- Added WidgetConfigModal for creating and editing widgets with fields for title, sources, prompt, provider, model, and refresh frequency.
- Integrated MarkdownRenderer for displaying widget content previews.
- Created WidgetDisplay component to show widget details, including loading states, error handling, and source information.
- Developed a reusable Card component structure for consistent UI presentation.
- Introduced useDashboard hook for managing widget state, including adding, updating, deleting, and refreshing widgets.
- Implemented local storage management for dashboard state and settings.
- Added types for widgets, dashboard configuration, and API requests/responses to improve type safety and clarity.
2025-07-19 08:23:06 -06:00
|
|
|
{children}
|
|
|
|
|
</code>
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
},
|
2025-07-19 17:25:52 -06:00
|
|
|
strong: {
|
|
|
|
|
component: ({ children }) => (
|
|
|
|
|
<strong className="font-bold text-black dark:text-white">
|
|
|
|
|
{children}
|
|
|
|
|
</strong>
|
|
|
|
|
),
|
|
|
|
|
},
|
feat(dashboard): Implement Widget Configuration and Display Components
- Added WidgetConfigModal for creating and editing widgets with fields for title, sources, prompt, provider, model, and refresh frequency.
- Integrated MarkdownRenderer for displaying widget content previews.
- Created WidgetDisplay component to show widget details, including loading states, error handling, and source information.
- Developed a reusable Card component structure for consistent UI presentation.
- Introduced useDashboard hook for managing widget state, including adding, updating, deleting, and refreshing widgets.
- Implemented local storage management for dashboard state and settings.
- Added types for widgets, dashboard configuration, and API requests/responses to improve type safety and clarity.
2025-07-19 08:23:06 -06:00
|
|
|
pre: {
|
|
|
|
|
component: ({ children }) => children,
|
|
|
|
|
},
|
2025-07-19 12:29:15 -06:00
|
|
|
a: {
|
2025-08-04 00:41:31 -06:00
|
|
|
component: (props) => {
|
|
|
|
|
// Check if this is a citation link with data-citation attribute
|
|
|
|
|
const citationNumber = props['data-citation'];
|
|
|
|
|
|
|
|
|
|
if (sources && citationNumber) {
|
|
|
|
|
const number = parseInt(citationNumber);
|
|
|
|
|
const source = sources[number - 1];
|
|
|
|
|
|
|
|
|
|
if (source) {
|
|
|
|
|
return (
|
|
|
|
|
<CitationLink
|
|
|
|
|
number={number.toString()}
|
|
|
|
|
source={source}
|
|
|
|
|
url={props.href}
|
|
|
|
|
/>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Default link behavior
|
|
|
|
|
return <a {...props} target="_blank" rel="noopener noreferrer" />;
|
|
|
|
|
},
|
2025-07-19 12:29:15 -06:00
|
|
|
},
|
2025-07-19 12:00:08 -06:00
|
|
|
// Prevent rendering of certain HTML elements for security
|
|
|
|
|
iframe: () => null, // Don't render iframes
|
|
|
|
|
script: () => null, // Don't render scripts
|
|
|
|
|
object: () => null, // Don't render objects
|
|
|
|
|
style: () => null, // Don't render styles
|
feat(dashboard): Implement Widget Configuration and Display Components
- Added WidgetConfigModal for creating and editing widgets with fields for title, sources, prompt, provider, model, and refresh frequency.
- Integrated MarkdownRenderer for displaying widget content previews.
- Created WidgetDisplay component to show widget details, including loading states, error handling, and source information.
- Developed a reusable Card component structure for consistent UI presentation.
- Introduced useDashboard hook for managing widget state, including adding, updating, deleting, and refreshing widgets.
- Implemented local storage management for dashboard state and settings.
- Added types for widgets, dashboard configuration, and API requests/responses to improve type safety and clarity.
2025-07-19 08:23:06 -06:00
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div className="relative">
|
|
|
|
|
<Markdown
|
|
|
|
|
className={cn(
|
2025-07-19 17:25:52 -06:00
|
|
|
'prose prose-h1:mb-3 prose-h2:mb-2 prose-h2:mt-6 prose-h2:font-[800] prose-h3:mt-4 prose-h3:mb-1.5 prose-h3:font-[600] dark:prose-invert prose-p:leading-relaxed prose-pre:p-0 font-[400]',
|
feat(dashboard): Implement Widget Configuration and Display Components
- Added WidgetConfigModal for creating and editing widgets with fields for title, sources, prompt, provider, model, and refresh frequency.
- Integrated MarkdownRenderer for displaying widget content previews.
- Created WidgetDisplay component to show widget details, including loading states, error handling, and source information.
- Developed a reusable Card component structure for consistent UI presentation.
- Introduced useDashboard hook for managing widget state, including adding, updating, deleting, and refreshing widgets.
- Implemented local storage management for dashboard state and settings.
- Added types for widgets, dashboard configuration, and API requests/responses to improve type safety and clarity.
2025-07-19 08:23:06 -06:00
|
|
|
'prose-code:bg-transparent prose-code:p-0 prose-code:text-inherit prose-code:font-normal prose-code:before:content-none prose-code:after:content-none',
|
|
|
|
|
'prose-pre:bg-transparent prose-pre:border-0 prose-pre:m-0 prose-pre:p-0',
|
2025-07-19 17:25:52 -06:00
|
|
|
'prose-strong:text-black dark:prose-strong:text-white prose-strong:font-bold',
|
2025-07-19 12:00:08 -06:00
|
|
|
'break-words text-black dark:text-white max-w-full',
|
2025-07-19 11:34:56 -06:00
|
|
|
className,
|
feat(dashboard): Implement Widget Configuration and Display Components
- Added WidgetConfigModal for creating and editing widgets with fields for title, sources, prompt, provider, model, and refresh frequency.
- Integrated MarkdownRenderer for displaying widget content previews.
- Created WidgetDisplay component to show widget details, including loading states, error handling, and source information.
- Developed a reusable Card component structure for consistent UI presentation.
- Introduced useDashboard hook for managing widget state, including adding, updating, deleting, and refreshing widgets.
- Implemented local storage management for dashboard state and settings.
- Added types for widgets, dashboard configuration, and API requests/responses to improve type safety and clarity.
2025-07-19 08:23:06 -06:00
|
|
|
)}
|
|
|
|
|
options={markdownOverrides}
|
|
|
|
|
>
|
2025-08-03 15:48:34 -06:00
|
|
|
{contentToRender}
|
feat(dashboard): Implement Widget Configuration and Display Components
- Added WidgetConfigModal for creating and editing widgets with fields for title, sources, prompt, provider, model, and refresh frequency.
- Integrated MarkdownRenderer for displaying widget content previews.
- Created WidgetDisplay component to show widget details, including loading states, error handling, and source information.
- Developed a reusable Card component structure for consistent UI presentation.
- Introduced useDashboard hook for managing widget state, including adding, updating, deleting, and refreshing widgets.
- Implemented local storage management for dashboard state and settings.
- Added types for widgets, dashboard configuration, and API requests/responses to improve type safety and clarity.
2025-07-19 08:23:06 -06:00
|
|
|
</Markdown>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default MarkdownRenderer;
|