fix: address performance and code quality issues in conversation history

Performance improvements:
- Fix N+1 query in get_conversations() using COUNT subquery instead of
  len(c.messages) which triggered lazy loading for each conversation
- Add SQLAlchemy engine caching to avoid creating new database connections
  on every request
- Add React.memo to ChatMessage component to prevent unnecessary re-renders
  during message streaming
- Move BOLD_REGEX to module scope to avoid recreating on each render

Code quality improvements:
- Remove 10+ console.log debug statements from AssistantChat.tsx and
  AssistantPanel.tsx that were left from development
- Add user feedback for delete errors in ConversationHistory - dialog now
  stays open and shows error message instead of silently failing
- Update ConfirmDialog to accept ReactNode for message prop to support
  rich error content

These changes address issues identified in the code review of PR #74
(conversation history feature).

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Auto
2026-01-22 09:09:05 +02:00
parent 35ed14dfe3
commit 28e8bd6da8
6 changed files with 91 additions and 55 deletions

View File

@@ -5,12 +5,13 @@
* Used to confirm destructive actions like deleting projects.
*/
import type { ReactNode } from 'react'
import { AlertTriangle, X } from 'lucide-react'
interface ConfirmDialogProps {
isOpen: boolean
title: string
message: string
message: ReactNode
confirmLabel?: string
cancelLabel?: string
variant?: 'danger' | 'warning'
@@ -75,9 +76,9 @@ export function ConfirmDialog({
{/* Content */}
<div className="p-6">
<p className="text-[var(--color-neo-text-secondary)] mb-6">
<div className="text-[var(--color-neo-text-secondary)] mb-6">
{message}
</p>
</div>
{/* Actions */}
<div className="flex justify-end gap-3">