Skip to content

Conversation

@duckduckhero
Copy link
Contributor

No description provided.

@coderabbitai
Copy link

coderabbitai bot commented Jul 21, 2025

📝 Walkthrough

Walkthrough

This change introduces a comprehensive AI-driven chat feature for meeting notes, including a streaming chat UI, markdown parsing and rendering, and integration with meeting context. It adds new components, types, and utilities for handling chat messages with markdown, enhances session data retrieval, and updates toolbar and localization logic. A new AI system prompt template is also added.

Changes

Files/Paths Change Summary
apps/desktop/src/components/editor-area/index.tsx Increased timeout durations for abort signals in generateTitleDirect (30s→60s) and useEnhanceMutation (60s→120s).
apps/desktop/src/components/right-panel/components/chat/chat-input.tsx Added isGenerating prop to disable textarea and submit button during AI generation.
apps/desktop/src/components/right-panel/components/chat/chat-message.tsx Extended ChatMessage props with sessionTitle, hasEnhancedNote, and onApplyMarkdown; now renders content via new MessageContent component.
apps/desktop/src/components/right-panel/components/chat/chat-messages-view.tsx Extended props with sessionTitle, hasEnhancedNote, and onApplyMarkdown; passes these to each ChatMessage.
apps/desktop/src/components/right-panel/components/chat/empty-chat-state.tsx Changed heading to "Chat with meeting notes" and added a "Beta" badge with a clickable "custom endpoints" link opening AI settings.
apps/desktop/src/components/right-panel/components/chat/index.ts Added named exports: MarkdownCard and MessageContent.
apps/desktop/src/components/right-panel/components/chat/markdown-card.tsx New file: Introduces MarkdownCard component for rendering markdown as HTML with copy/apply functionality and visual feedback.
apps/desktop/src/components/right-panel/components/chat/message-content.tsx New file: Introduces MessageContent component for conditional rendering of message parts (plain text or markdown blocks).
apps/desktop/src/components/right-panel/components/chat/types.ts Changed Message to interface, added parts?: MessagePart[]; introduced MessagePart interface for text/markdown blocks.
apps/desktop/src/components/right-panel/utils/markdown-parser.ts New file: Adds parseMarkdownBlocks utility to split text into MessagePart[] (text/markdown).
apps/desktop/src/components/right-panel/views/chat-view.tsx Major update: integrates AI chat generation with streaming, markdown parsing, session context, analytics tracking, and disables input during generation. Adds async handlers, new state, and helper functions.
apps/desktop/src/components/toolbar/bars/main-toolbar.tsx Removes feature flag check for chat panel; always shows ChatPanelButton.
apps/desktop/src/components/toolbar/buttons/transcript-panel-button.tsx Refines active state logic for transcript panel button using currentView.
apps/desktop/src/locales/en/messages.po, apps/desktop/src/locales/ko/messages.po Updates line references for translation entries; adds "Chat with meeting notes" and marks "How can I help you today?" as obsolete.
crates/template/assets/ai_chat_system.jinja New file: Adds an AI chat system prompt template for meeting context and markdown formatting.
crates/template/src/lib.rs Adds AiChatSystem to PredefinedTemplate, registers new template, and exposes it for use.
plugins/template/src/lib.rs Adds /think line to a test snapshot string in test_enhance_user.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant ChatInput
    participant ChatView
    participant AIModel
    participant MarkdownParser
    participant MessageContent/MarkdownCard
    participant SessionStore

    User->>ChatInput: Enter message & submit
    ChatInput->>ChatView: onSubmit (if !isGenerating)
    ChatView->>SessionStore: Fetch session context (title, notes, summary, transcript)
    ChatView->>AIModel: Send message history & context (streaming)
    AIModel-->>ChatView: Stream text chunks
    ChatView->>MarkdownParser: parseMarkdownBlocks(chunk)
    MarkdownParser-->>ChatView: MessagePart[]
    ChatView->>MessageContent/MarkdownCard: Update AI message parts in UI
    ChatView->>ChatInput: Set isGenerating = false
Loading

Estimated code review effort

4 (approximately one day)

Possibly related PRs

  • fastrepl/hyprnote#1050: Modifies useEnhanceMutation for template-based customization and grammar generation, directly related as both PRs change the same function and logic.
  • fastrepl/hyprnote#935: Introduced automatic title generation and enhanced mutation hooks; this PR extends the timeout logic in those same functions, making them directly related.

📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cc6acce and 5ad03cb.

📒 Files selected for processing (5)
  • apps/desktop/src/components/right-panel/components/chat/empty-chat-state.tsx (2 hunks)
  • apps/desktop/src/components/right-panel/views/chat-view.tsx (10 hunks)
  • apps/desktop/src/locales/en/messages.po (9 hunks)
  • apps/desktop/src/locales/ko/messages.po (9 hunks)
  • crates/template/assets/ai_chat_system.jinja (1 hunks)
✅ Files skipped from review due to trivial changes (2)
  • apps/desktop/src/locales/ko/messages.po
  • apps/desktop/src/locales/en/messages.po
🚧 Files skipped from review as they are similar to previous changes (2)
  • apps/desktop/src/components/right-panel/components/chat/empty-chat-state.tsx
  • crates/template/assets/ai_chat_system.jinja
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{js,ts,tsx,rs}

Instructions used from:

Sources:
⚙️ CodeRabbit Configuration File

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: ci
  • GitHub Check: ci (windows, windows-latest)
  • GitHub Check: ci (macos, macos-latest)
🔇 Additional comments (4)
apps/desktop/src/components/right-panel/views/chat-view.tsx (4)

1-21: Imports look good.

All imports are properly used throughout the component.


45-46: Good addition of generation state tracking.

The isGenerating state properly prevents concurrent AI operations.


448-455: Excellent integration of session data with chat components.

The new props passed to ChatMessagesView properly integrate session context (sessionTitle, hasEnhancedNote) and markdown handling (onApplyMarkdown).


466-466: Good UI state management with isGenerating prop.

Passing isGenerating to ChatInput ensures proper UI feedback during AI generation.

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

‼️ IMPORTANT
Auto-reply has been disabled for this repository in the CodeRabbit settings. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 8

🧹 Nitpick comments (4)
apps/desktop/src/components/right-panel/components/chat/markdown-card.tsx (2)

52-54: Improve error handling for markdown conversion failure.

Falling back to raw markdown content could confuse users who expect formatted HTML.

 } catch (error) {
   console.error("Failed to convert markdown:", error);
-  setHtmlContent(content);
+  setHtmlContent(`<p style="color: #666; font-style: italic;">Failed to format content. Showing raw text.</p><pre>${content}</pre>`);
 }

65-122: Extract inline styles for better maintainability.

Large inline style blocks make the component harder to maintain and increase bundle size.

Consider moving these styles to:

  1. A separate CSS module file (markdown-card.module.css)
  2. Or use a styled-components/emotion approach
  3. Or at least extract to a constant outside the component

This would improve maintainability and allow for better style reuse across the application.

apps/desktop/src/components/right-panel/views/chat-view.tsx (2)

54-76: Consider memoizing the session query configuration.

The query configuration object is recreated on every render, which could cause unnecessary re-fetches.

Consider using useMemo to memoize the query configuration:

+import { useMemo } from "react";

 const sessionData = useQuery({
   enabled: !!sessionId,
   queryKey: ["session", "chat-context", sessionId],
-  queryFn: async () => {
+  queryFn: useMemo(() => async () => {
     if (!sessionId) {
       return null;
     }
     // ... rest of the function
-  },
+  }, [sessionId]),
 });

193-194: Improve submit guard condition.

The comment mentions preventing submit if generating, but this should be more explicit in the code.

-  if (!inputValue.trim() || isGenerating) { // Prevent submit if generating
+  // Prevent submit if input is empty or AI is currently generating
+  if (!inputValue.trim() || isGenerating) {
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 735b2a1 and 38ac741.

📒 Files selected for processing (18)
  • apps/desktop/src/components/editor-area/index.tsx (2 hunks)
  • apps/desktop/src/components/right-panel/components/chat/chat-input.tsx (3 hunks)
  • apps/desktop/src/components/right-panel/components/chat/chat-message.tsx (2 hunks)
  • apps/desktop/src/components/right-panel/components/chat/chat-messages-view.tsx (2 hunks)
  • apps/desktop/src/components/right-panel/components/chat/empty-chat-state.tsx (2 hunks)
  • apps/desktop/src/components/right-panel/components/chat/index.ts (1 hunks)
  • apps/desktop/src/components/right-panel/components/chat/markdown-card.tsx (1 hunks)
  • apps/desktop/src/components/right-panel/components/chat/message-content.tsx (1 hunks)
  • apps/desktop/src/components/right-panel/components/chat/types.ts (1 hunks)
  • apps/desktop/src/components/right-panel/utils/markdown-parser.ts (1 hunks)
  • apps/desktop/src/components/right-panel/views/chat-view.tsx (10 hunks)
  • apps/desktop/src/components/toolbar/bars/main-toolbar.tsx (1 hunks)
  • apps/desktop/src/components/toolbar/buttons/transcript-panel-button.tsx (2 hunks)
  • apps/desktop/src/locales/en/messages.po (9 hunks)
  • apps/desktop/src/locales/ko/messages.po (9 hunks)
  • crates/template/assets/ai_chat_system.jinja (1 hunks)
  • crates/template/src/lib.rs (4 hunks)
  • plugins/template/src/.lib.rs.pending-snap (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{js,ts,tsx,rs}

Instructions used from:

Sources:
⚙️ CodeRabbit Configuration File

🧬 Code Graph Analysis (5)
apps/desktop/src/components/toolbar/buttons/transcript-panel-button.tsx (1)
apps/desktop/src/contexts/right-panel.tsx (1)
  • useRightPanel (172-178)
apps/desktop/src/components/right-panel/utils/markdown-parser.ts (1)
apps/desktop/src/components/right-panel/components/chat/types.ts (1)
  • MessagePart (1-5)
apps/desktop/src/components/right-panel/components/chat/markdown-card.tsx (3)
apps/desktop/src/components/right-panel/components/chat/index.ts (1)
  • MarkdownCard (8-8)
plugins/local-llm/src/server.rs (1)
  • content (195-201)
packages/ui/src/components/ui/button.tsx (1)
  • Button (37-89)
apps/desktop/src/components/right-panel/components/chat/chat-messages-view.tsx (1)
apps/desktop/src/components/right-panel/components/chat/chat-message.tsx (1)
  • ChatMessage (13-32)
apps/desktop/src/components/right-panel/components/chat/message-content.tsx (3)
apps/desktop/src/components/right-panel/components/chat/types.ts (1)
  • Message (7-13)
apps/desktop/src/components/right-panel/components/chat/index.ts (2)
  • MessageContent (9-9)
  • MarkdownCard (8-8)
apps/desktop/src/components/right-panel/components/chat/markdown-card.tsx (1)
  • MarkdownCard (15-165)
🔇 Additional comments (38)
apps/desktop/src/components/editor-area/index.tsx (2)

49-49: LGTM: Appropriate timeout increase for AI title generation.

The timeout increase from 30 to 60 seconds is reasonable for AI-powered title generation, especially considering the enhanced chat features that may involve more complex processing.


368-368: LGTM: Well-justified timeout increase for enhanced AI operations.

The timeout increase from 60 to 120 seconds aligns with the broader AI chat enhancements and streaming capabilities. This provides adequate time for complex AI text generation and enhancement operations without premature cancellation.

apps/desktop/src/components/right-panel/components/chat/empty-chat-state.tsx (2)

1-1: LGTM: Badge import is properly used.

The Badge component import is correctly utilized for the beta indicator.


24-31: LGTM: Improved UX with clearer messaging and beta indicator.

The changes enhance the user experience by:

  • Making the purpose more specific ("Chat with your meeting notes" vs generic help)
  • Adding a clear beta indicator with appropriate styling
  • Using a proper flex layout to accommodate both elements

The blue-themed badge styling effectively communicates the beta status.

apps/desktop/src/components/right-panel/components/chat/index.ts (1)

8-9: LGTM: New exports support enhanced chat functionality.

The addition of MarkdownCard and MessageContent exports properly exposes the new markdown rendering components for the enhanced chat feature. The explicit named export syntax is appropriate and consistent.

apps/desktop/src/components/toolbar/buttons/transcript-panel-button.tsx (2)

11-11: LGTM: Proper extraction of currentView for enhanced state logic.

Adding currentView to the destructured properties enables more precise UI state management.


17-17: LGTM: Improved visual feedback with precise active state.

The new isActive logic provides better UX by highlighting the button only when the transcript panel is both expanded AND currently active. This gives users clearer visual feedback about which panel view is currently selected.

Also applies to: 28-28

apps/desktop/src/components/toolbar/bars/main-toolbar.tsx (1)

61-61: LGTM: Simplified chat panel access.

Making the chat panel button always available removes feature flag complexity and aligns with the enhanced chat functionality being promoted to a core feature. This improves user experience by providing consistent access to the chat panel.

apps/desktop/src/components/right-panel/components/chat/chat-message.tsx (4)

3-3: Import addition looks good.

The new MessageContent import is necessary for the component-based message rendering approach.


8-10: Props extension is well-structured.

The optional props follow TypeScript conventions and provide clear interfaces for enhanced chat functionality.


13-13: Function signature properly matches the interface.

The destructuring correctly includes all new props from the ChatMessageProps interface.


24-29: Component delegation follows React best practices.

The refactoring to use MessageContent component promotes separation of concerns and properly passes all props through.

apps/desktop/src/components/right-panel/components/chat/types.ts (2)

1-5: MessagePart interface is well-designed.

The interface properly supports structured message content with clear type distinctions and optional completion state for streaming scenarios.


7-13: Message interface conversion enhances extensibility.

Converting from type alias to interface and adding optional parts array maintains backward compatibility while enabling structured message content.

plugins/template/src/.lib.rs.pending-snap (1)

1-2: Test snapshot file is standard.

This auto-generated snapshot captures expected template rendering behavior for the AI chat system. No issues with test artifacts.

apps/desktop/src/locales/ko/messages.po (1)

371-371: Localization updates are properly maintained.

The file correctly updates source references, adds new translatable strings, and marks obsolete entries following standard i18n practices.

Also applies to: 425-428, 508-508, 635-635, 713-715, 750-750, 1120-1120, 1190-1190, 1242-1242

apps/desktop/src/components/right-panel/components/chat/chat-input.tsx (3)

20-20: Interface extension is appropriate.

The optional isGenerating prop follows TypeScript conventions and clearly indicates its purpose for managing input state during AI generation.


24-34: Parameter destructuring is well-formatted.

The multi-line destructuring with default value for isGenerating improves readability and maintains backward compatibility.


120-120: Disabled state management is properly implemented.

Both textarea and submit button are correctly disabled during AI generation, preventing concurrent input and submissions while maintaining existing input validation.

Also applies to: 137-137

apps/desktop/src/locales/en/messages.po (2)

371-371: LGTM: Localization updates align with chat feature changes.

The localization file updates properly reflect the UI text changes for the new chat functionality. The source reference updates for existing translations and the addition of new chat-related messages are correctly formatted.

Also applies to: 425-427, 508-508, 635-635, 750-750, 1120-1120, 1242-1242


713-714: Confirm obsolete translation removal.

The obsolete translation "How can I help you today?" is marked for removal, which aligns with the new "Chat with your meeting notes" heading. Ensure this obsolete entry is properly cleaned up in the final build.

apps/desktop/src/components/right-panel/components/chat/message-content.tsx (4)

1-2: LGTM: Clean imports and type definitions.

The imports are properly structured and the component uses appropriate TypeScript interfaces.


4-9: Well-defined interface with appropriate optional properties.

The MessageContentProps interface properly defines all required and optional properties with clear types. The optional callback pattern for onApplyMarkdown is appropriate for this use case.


11-19: Solid fallback rendering for messages without parts.

The fallback rendering for messages without parsed parts is correctly implemented, maintaining consistent styling with the rest of the chat interface.


21-44: Well-structured conditional rendering with proper key handling.

The component correctly maps over message parts with proper key assignment and handles both text and markdown content types appropriately. The prop passing to MarkdownCard includes all necessary context.

apps/desktop/src/components/right-panel/utils/markdown-parser.ts (3)

1-2: Clean import structure.

The import statement properly references the MessagePart type from the chat types module.


3-8: Well-initialized parser state variables.

The function properly initializes all necessary state variables for tracking the parsing process.


41-62: Proper handling of remaining content and incomplete blocks.

The logic for handling remaining content after the main loop is well-implemented. It correctly distinguishes between incomplete markdown blocks and remaining text content, which is essential for streaming scenarios.

crates/template/src/lib.rs (4)

45-46: Consistent enum variant addition.

The new AiChatSystem variant follows the established naming convention and serialization pattern used by other template variants.


68-68: Proper From trait implementation.

The From<PredefinedTemplate> implementation correctly includes the new AiChatSystem variant, maintaining consistency with the pattern used for other templates.


79-79: Template constant properly defined.

The AI_CHAT_SYSTEM_TPL constant follows the naming convention and correctly includes the template content from the assets directory.


111-115: Template registration correctly implemented.

The template is properly registered in the Minijinja environment using the correct reference and template content. The error handling with unwrap() is consistent with other template registrations in the same function.

apps/desktop/src/components/right-panel/components/chat/chat-messages-view.tsx (3)

7-9: Well-typed interface extensions.

The new optional props are properly typed and align with the enhanced chat functionality requirements. The optional nature prevents breaking changes to existing usage.


12-12: Proper prop destructuring.

The component parameter destructuring correctly includes all new props while maintaining the existing parameter structure.


21-29: Clean prop forwarding to ChatMessage components.

The props are correctly passed down to each ChatMessage instance, enabling the enhanced functionality while maintaining the existing map structure and key assignment.

crates/template/assets/ai_chat_system.jinja (1)

30-30: Timeline filter registration confirmed

The timeline filter is already registered and implemented, so the template usage is valid:

  • Registration: crates/template/src/lib.rs
    env.add_filter("timeline", filters::timeline);
  • Implementation & tests: crates/template/src/filters.rs (includes pub fn timeline and test_timeline)

No further changes needed.

apps/desktop/src/components/right-panel/components/chat/markdown-card.tsx (1)

21-25: Add error handling for onApplyMarkdown callback.

The callback could throw an error but there's no error handling.

 const handleApplyClick = () => {
-  if (onApplyMarkdown) {
-    onApplyMarkdown(content);
-  }
+  if (onApplyMarkdown) {
+    try {
+      onApplyMarkdown(content);
+    } catch (error) {
+      console.error("Failed to apply markdown:", error);
+      // Consider showing user feedback
+    }
+  }
 };

Likely an incorrect or invalid review comment.

apps/desktop/src/components/right-panel/views/chat-view.tsx (1)

151-163: Add error handling for template rendering.

The templateCommands.render call could fail but isn't wrapped in try-catch.

 const prepareMessageHistory = async (messages: Message[], currentUserMessage?: string) => {
   const refetchResult = await sessionData.refetch();
   let freshSessionData = refetchResult.data;

-  const systemContent = await templateCommands.render("ai_chat.system", {
-    session: freshSessionData,
-    // Pass raw words for timeline filter to handle
-    words: JSON.stringify(freshSessionData?.words || []),
-    title: freshSessionData?.title,
-    enhancedContent: freshSessionData?.enhancedContent,
-    rawContent: freshSessionData?.rawContent,
-    preMeetingContent: freshSessionData?.preMeetingContent,
-  });
+  let systemContent;
+  try {
+    systemContent = await templateCommands.render("ai_chat.system", {
+      session: freshSessionData,
+      // Pass raw words for timeline filter to handle
+      words: JSON.stringify(freshSessionData?.words || []),
+      title: freshSessionData?.title,
+      enhancedContent: freshSessionData?.enhancedContent,
+      rawContent: freshSessionData?.rawContent,
+      preMeetingContent: freshSessionData?.preMeetingContent,
+    });
+  } catch (error) {
+    console.error("Failed to render system template:", error);
+    // Provide a fallback system prompt
+    systemContent = "You are a helpful AI assistant.";
+  }

Likely an incorrect or invalid review comment.

@duckduckhero duckduckhero deleted the feature-chat branch July 21, 2025 07:13
@duckduckhero duckduckhero restored the feature-chat branch July 21, 2025 07:13
@duckduckhero duckduckhero reopened this Jul 21, 2025
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🔭 Outside diff range comments (2)
crates/template/assets/ai_chat_system.jinja (1)

100-104: Address formatting issues causing pipeline failure.

The dprint formatting check is failing on lines 100-102. The template needs proper formatting to pass CI checks.

Run the formatting tool to fix these issues:

dprint fmt crates/template/assets/ai_chat_system.jinja
apps/desktop/src/components/right-panel/views/chat-view.tsx (1)

74-160: Address formatting issues causing pipeline failure.

The dprint formatting check is failing on lines 74-160. The code needs proper formatting to pass CI checks.

Run the formatting tool to fix these issues:

dprint fmt apps/desktop/src/components/right-panel/views/chat-view.tsx
♻️ Duplicate comments (4)
crates/template/assets/ai_chat_system.jinja (3)

103-103: Missing line annotation for new content.

Line 103 is missing the ~ annotation that indicates it's a new line, as noted in previous reviews.


20-20: Fix HTML tag stripping pattern remains unresolved.

The regex pattern '<[^>]*>' in the replace filter is still being treated as a literal string, not a regex pattern. This issue was flagged in previous reviews but hasn't been addressed.

Consider using the striptags filter instead:

-{{ enhancedContent | replace('<[^>]*>', '') | replace('&nbsp;', ' ') | replace('&amp;', '&') | replace('&lt;', '<') | replace('&gt;', '>') }}
+{{ enhancedContent | striptags | replace('&nbsp;', ' ') | replace('&amp;', '&') | replace('&lt;', '<') | replace('&gt;', '>') }}

Also applies to: 24-24


101-103: Inconsistent markdown delimiter instructions remain unfixed.

The instruction on line 101 mentions ``` blocks but uses inconsistent language. This was flagged in previous reviews but hasn't been corrected.

Apply this fix for consistency:

-IT IS PARAMOUNT THAT WHEN YOU GENERATE RESPONSES LIKE THIS, YOU KEEP THE MARKDOWN NOTE INSIDE THE ``` BLOCKS.
-Please PUT all markdown blocks inside the ``` blocks.
+IT IS PARAMOUNT THAT WHEN YOU GENERATE RESPONSES LIKE THIS, YOU KEEP THE NOTE INSIDE THE ``` BLOCKS.
+Please PUT all markdown blocks inside the ``` blocks.
apps/desktop/src/components/right-panel/views/chat-view.tsx (1)

124-125: Debug console.log statements remain in production code.

Multiple console.log statements are still present despite being flagged in previous reviews. These should be removed from production code.

Remove these debug statements:

-      console.error("No session ID available");
-      console.error("Session not found in store");
-      console.log("Applied markdown content to enhanced note");

Also applies to: 131-131, 141-141

🧹 Nitpick comments (1)
apps/desktop/src/components/right-panel/views/chat-view.tsx (1)

147-184: Message history preparation could be optimized.

The prepareMessageHistory function refetches session data on every call, which may be unnecessary if the data hasn't changed.

Consider memoizing or checking if refetch is needed:

+  const prepareMessageHistory = useCallback(async (messages: Message[], currentUserMessage?: string) => {
+    // Only refetch if session data is stale
+    let freshSessionData = sessionData.data;
+    if (sessionData.isStale) {
+      const refetchResult = await sessionData.refetch();
+      freshSessionData = refetchResult.data;
+    }
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0f707ca and cc6acce.

📒 Files selected for processing (3)
  • apps/desktop/src/components/right-panel/components/chat/empty-chat-state.tsx (2 hunks)
  • apps/desktop/src/components/right-panel/views/chat-view.tsx (10 hunks)
  • crates/template/assets/ai_chat_system.jinja (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/desktop/src/components/right-panel/components/chat/empty-chat-state.tsx
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{js,ts,tsx,rs}

Instructions used from:

Sources:
⚙️ CodeRabbit Configuration File

🪛 GitHub Actions: .github/workflows/fmt.yaml
crates/template/assets/ai_chat_system.jinja

[error] 100-102: dprint formatting check failed. File contains formatting issues that need to be fixed.

apps/desktop/src/components/right-panel/views/chat-view.tsx

[error] 74-160: dprint formatting check failed. File contains formatting issues that need to be fixed.

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: i18n
  • GitHub Check: ci
  • GitHub Check: ci (windows, windows-latest)
  • GitHub Check: ci
  • GitHub Check: ci (macos, macos-latest)
  • GitHub Check: ci (windows, windows-latest)
🔇 Additional comments (2)
apps/desktop/src/components/right-panel/views/chat-view.tsx (2)

46-46: Generation state tracking implementation is solid.

The addition of isGenerating state provides proper concurrency control to prevent multiple simultaneous AI requests.


186-270: Async message handling logic is well-structured.

The handleSubmit function properly manages the generation state, streaming, and error handling. The markdown parsing integration with parseMarkdownBlocks is clean.

Comment on lines +54 to +75
const sessionData = useQuery({
enabled: !!sessionId,
queryKey: ["session", "chat-context", sessionId],
queryFn: async () => {
if (!sessionId) {
return null;
}

const session = await dbCommands.getSession({ id: sessionId });
if (!session) {
return null;
}

return {
title: session.title || "",
rawContent: session.raw_memo_html || "",
enhancedContent: session.enhanced_memo_html,
preMeetingContent: session.pre_meeting_memo_html,
words: session.words || [],
};
},
});
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

Verify session data fetching performance.

The useQuery implementation looks correct, but consider the performance impact of refetching session data for every message preparation.

Check if session data is being over-fetched:


🏁 Script executed:

#!/bin/bash
# Check for potential session data refetch patterns
rg -A 5 -B 5 "refetch" apps/desktop/src/components/right-panel/views/chat-view.tsx

Length of output: 579


Optimize session data refetch in prepareMessageHistory

We’ve confirmed that every call to prepareMessageHistory invokes await sessionData.refetch(), causing a network request on each message render. This can degrade performance, especially in long-running chats. Please:

• In apps/desktop/src/components/right-panel/views/chat-view.tsx
– Remove the explicit sessionData.refetch() inside prepareMessageHistory.
– Use the already-cached sessionData.data instead of forcing a refetch.
• On your useQuery call (lines ~54–75), set a sensible staleTime (e.g. staleTime: 5 * 60_000) so data stays fresh for the duration of the chat session without repeated requests.

Example diff:

   const sessionData = useQuery({
     enabled: !!sessionId,
+    staleTime: 5 * 60_000,
     queryKey: ["session", "chat-context", sessionId],
     queryFn: async () => { … },
   });

   const prepareMessageHistory = async (messages, currentUserMessage) => {
-    const refetchResult = await sessionData.refetch();
-    let freshSessionData = refetchResult.data;
+    const freshSessionData = sessionData.data;
     …
   };
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const sessionData = useQuery({
enabled: !!sessionId,
queryKey: ["session", "chat-context", sessionId],
queryFn: async () => {
if (!sessionId) {
return null;
}
const session = await dbCommands.getSession({ id: sessionId });
if (!session) {
return null;
}
return {
title: session.title || "",
rawContent: session.raw_memo_html || "",
enhancedContent: session.enhanced_memo_html,
preMeetingContent: session.pre_meeting_memo_html,
words: session.words || [],
};
},
});
const sessionData = useQuery({
enabled: !!sessionId,
staleTime: 5 * 60_000,
queryKey: ["session", "chat-context", sessionId],
queryFn: async () => {
if (!sessionId) {
return null;
}
const session = await dbCommands.getSession({ id: sessionId });
if (!session) {
return null;
}
return {
title: session.title || "",
rawContent: session.raw_memo_html || "",
enhancedContent: session.enhanced_memo_html,
preMeetingContent: session.pre_meeting_memo_html,
words: session.words || [],
};
},
});
const prepareMessageHistory = async (messages, currentUserMessage) => {
const freshSessionData = sessionData.data;
};
🤖 Prompt for AI Agents
In apps/desktop/src/components/right-panel/views/chat-view.tsx around lines 54
to 75, the useQuery call for sessionData should be updated to include a
staleTime option set to 5 minutes (300000 ms) to prevent frequent refetches.
Additionally, remove any explicit calls to sessionData.refetch() inside
prepareMessageHistory and instead rely on the cached sessionData.data to improve
performance during message rendering.

Comment on lines +257 to +258
console.error("AI error:", error);

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Inconsistent error handling logging.

Error logging uses console.error which contradicts the coding guidelines that specify "no error handling" and the general removal of console statements.

Consider removing error logging or using a proper logging service:

-      console.error("AI error:", error);
-      console.error("AI error:", error);

Also applies to: 349-349

🤖 Prompt for AI Agents
In apps/desktop/src/components/right-panel/views/chat-view.tsx at lines 257-258
and 349, replace the console.error calls with either no error logging or use the
project's designated logging service according to coding guidelines. Remove
console.error statements entirely or refactor them to use the proper logging
utility to maintain consistency and adhere to the "no error handling" directive.

@yujonglee
Copy link
Contributor

@duckduckhero fix prompt and merge it

@yujonglee yujonglee merged commit d693937 into main Jul 21, 2025
8 checks passed
@yujonglee yujonglee deleted the feature-chat branch July 21, 2025 16:32
@coderabbitai coderabbitai bot mentioned this pull request Jul 26, 2025
@coderabbitai coderabbitai bot mentioned this pull request Aug 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants