-
Notifications
You must be signed in to change notification settings - Fork 418
Feature chat (Beta version) #1184
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
📝 WalkthroughWalkthroughThis 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
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
Estimated code review effort4 (approximately one day) Possibly related PRs
📜 Recent review detailsConfiguration used: .coderabbit.yaml 📒 Files selected for processing (5)
✅ Files skipped from review due to trivial changes (2)
🚧 Files skipped from review as they are similar to previous changes (2)
🧰 Additional context used📓 Path-based instructions (1)**/*.{js,ts,tsx,rs}Instructions used from: Sources: ⏰ 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)
🔇 Additional comments (4)
✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed 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)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this 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:
- A separate CSS module file (
markdown-card.module.css)- Or use a styled-components/emotion approach
- 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
useMemoto 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
📒 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
MarkdownCardandMessageContentexports 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
currentViewto the destructured properties enables more precise UI state management.
17-17: LGTM: Improved visual feedback with precise active state.The new
isActivelogic 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
MessageContentimport 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
ChatMessagePropsinterface.
24-29: Component delegation follows React best practices.The refactoring to use
MessageContentcomponent 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
partsarray 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
isGeneratingprop 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
isGeneratingimproves 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
MessageContentPropsinterface properly defines all required and optional properties with clear types. The optional callback pattern foronApplyMarkdownis 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
MarkdownCardincludes 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
AiChatSystemvariant 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 newAiChatSystemvariant, maintaining consistency with the pattern used for other templates.
79-79: Template constant properly defined.The
AI_CHAT_SYSTEM_TPLconstant 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
ChatMessageinstance, 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 confirmedThe
timelinefilter 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 timelineandtest_timeline)No further changes needed.
apps/desktop/src/components/right-panel/components/chat/markdown-card.tsx (1)
21-25: Add error handling foronApplyMarkdowncallback.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.rendercall 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.
apps/desktop/src/components/right-panel/components/chat/markdown-card.tsx
Show resolved
Hide resolved
…nto feature-chat
There was a problem hiding this 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.jinjaapps/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
striptagsfilter instead:-{{ enhancedContent | replace('<[^>]*>', '') | replace(' ', ' ') | replace('&', '&') | replace('<', '<') | replace('>', '>') }} +{{ enhancedContent | striptags | replace(' ', ' ') | replace('&', '&') | replace('<', '<') | replace('>', '>') }}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
prepareMessageHistoryfunction 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
📒 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
isGeneratingstate 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
parseMarkdownBlocksis clean.
| 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 || [], | ||
| }; | ||
| }, | ||
| }); |
There was a problem hiding this comment.
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.tsxLength 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.
| 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.
| console.error("AI error:", error); | ||
|
|
There was a problem hiding this comment.
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.
|
@duckduckhero fix prompt and merge it |
No description provided.