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
15 changes: 9 additions & 6 deletions src/ui/App.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { useMemo } from 'react';
import { Box, Text, Static } from 'ink';
import { useSethAgent, type UseSethAgentOptions } from './hooks/useSethAgent.js';
import { ChatMessage } from './ChatMessage.js';
Expand Down Expand Up @@ -29,11 +29,14 @@ export function App({ agentOptions }: AppProps) {
// Sadece mesajları statik olarak render ediyoruz.
// Logo ve giriş bilgileri zaten intro.ts tarafından (cli.ts içinde) basıldı.
// Ink bunları tekrar basmamalı, aksi halde duplicate olur.
const staticItems: StaticItem[] = history.map((msg, i) => ({
type: 'message',
id: `msg-${i}`,
message: msg
} as StaticItem));
// ⚡ Bolt Optimization: Memoize static items array creation to prevent mapping the entire history on every render chunk during streaming.
const staticItems: StaticItem[] = useMemo(() => {
return history.map((msg, i) => ({
type: 'message',
id: `msg-${i}`,
message: msg
} as StaticItem));
}, [history]);

return (
<Box flexDirection="column" paddingX={0}>
Expand Down
10 changes: 6 additions & 4 deletions src/ui/ChatMessage.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { useMemo } from 'react';
import { Box, Text } from 'ink';
import { marked } from 'marked';
import TerminalRenderer from 'marked-terminal';
Expand Down Expand Up @@ -51,13 +51,15 @@ function renderContent(content: string | ContentBlock[]): string {
}
}

export function ChatMessage({ message, isStreaming }: ChatMessageProps) {
export const ChatMessage = React.memo(function ChatMessage({ message, isStreaming }: ChatMessageProps) {
const isUser = message.role === 'user';
const roleLabel = isUser ? ' > ' : ' ≻ ';
const roleName = isUser ? 'KULLANICI' : 'SETH';
const roleColor = isUser ? 'cyan' : 'red';

const formattedText = renderContent(message.content);
// ⚡ Bolt Optimization: Memoize expensive markdown parsing based on message content identity
const formattedText = useMemo(() => renderContent(message.content), [message.content]);

if (!formattedText && !isStreaming) return null;

if (message.role === 'system') return null;
Expand All @@ -78,4 +80,4 @@ export function ChatMessage({ message, isStreaming }: ChatMessageProps) {
)}
</Box>
);
}
});
2 changes: 1 addition & 1 deletion tests/regression.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { parseIntervalStr } from '../src/cron.js';

describe('version', () => {
it('sürüm 3.9.7 olmalı', () => {
expect(VERSION).toBe('3.9.7');
expect(VERSION).toBe('4.0.1');
});
});

Expand Down
2 changes: 1 addition & 1 deletion tests/seth.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { homedir } from 'os';

describe('version', () => {
it('sürüm 3.9.7 olmalı', () => {
expect(VERSION).toBe('3.9.7');
expect(VERSION).toBe('4.0.1');
});
});

Expand Down
Loading