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
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@ import React from 'react';
import { motion } from 'framer-motion';
import { MarkdownRenderer } from '@tarko/ui';
import { wrapMarkdown } from '@/common/utils/markdown';

type DisplayMode = 'source' | 'rendered';
import { FileDisplayMode } from '../../types';

interface MessageContentProps {
message: string;
isMarkdown?: boolean;
displayMode?: DisplayMode;
displayMode?: FileDisplayMode;
isShortMessage?: boolean;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import { MonacoCodeEditor } from '@tarko/ui';
import { FileDisplayMode } from '../types';
import { StandardPanelContent } from '../types/panelContent';
import { MessageContent } from '../components/shared';

type DisplayMode = 'source' | 'rendered';
import { useStableCodeContent } from '@/common/hooks/useStableValue';
import { ThrottledHtmlRenderer } from '../components/ThrottledHtmlRenderer';
import { formatBytes } from '../utils/codeUtils';
Expand Down Expand Up @@ -89,7 +87,7 @@ export const FileResultRenderer: React.FC<FileResultRendererProps> = ({
<MessageContent
message={stableContent}
isMarkdown={true}
displayMode={displayMode as DisplayMode}
displayMode={displayMode}
isShortMessage={false}
/>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
* Utility functions for file type detection and handling
*/

import { FileDisplayMode } from '../types';

export interface FileTypeInfo {
isHtml: boolean;
isMarkdown: boolean;
Expand All @@ -16,7 +18,7 @@ export interface FileTypeInfo {
export function getFileTypeInfo(filePath: string): FileTypeInfo {
const fileName = filePath.split('/').pop() || filePath;
const extension = fileName.toLowerCase().split('.').pop() || '';

const isHtml = extension === 'html' || extension === 'htm';
const isMarkdown = extension === 'md' || extension === 'markdown';
const isRenderableFile = isHtml || isMarkdown;
Expand Down Expand Up @@ -54,13 +56,13 @@ export function isMarkdownFile(filePath: string): boolean {
/**
* Get the appropriate default display mode for a file during streaming
*/
export function getDefaultDisplayMode(filePath: string, isStreaming: boolean): 'source' | 'rendered' {
export function getDefaultDisplayMode(filePath: string, isStreaming: boolean): FileDisplayMode {
const { isHtml } = getFileTypeInfo(filePath);

// For HTML files during streaming, default to source mode
if (isHtml && isStreaming) {
return 'source';
}

return 'rendered';
}
Loading