Skip to content

Comments

Chat minor fix#1215

Merged
duckduckhero merged 19 commits intomainfrom
chat-minor-fix
Jul 26, 2025
Merged

Chat minor fix#1215
duckduckhero merged 19 commits intomainfrom
chat-minor-fix

Conversation

@duckduckhero
Copy link
Contributor

No description provided.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 26, 2025

📝 Walkthrough

Walkthrough

This change set introduces a major refactor and feature enhancement to the chat functionality in the application. Chat logic, queries, and active entity management are modularized into custom React hooks, with new types and utility functions added. The UI is updated to support chat groups and improved autonomy selection. Backend and plugin layers are extended to support chat message deletion, with related permission and documentation updates. Localization files are updated to reflect UI text changes.

Changes

File(s) / Path(s) Change Summary
apps/desktop/src/components/left-sidebar/top-area/finder-button.tsx Replaces imported folder icon with a custom inline SVG icon.
apps/desktop/src/components/right-panel/components/chat/chat-input.tsx Changes import path for BadgeType.
apps/desktop/src/components/right-panel/components/chat/chat-message.tsx Refactors user/non-user message rendering, removes label, and unused imports.
apps/desktop/src/components/right-panel/components/chat/empty-chat-state.tsx Updates heading text.
apps/desktop/src/components/right-panel/components/chat/floating-action-buttons.tsx Replaces tooltip "View History" with dropdown for chat groups; extends props.
apps/desktop/src/components/right-panel/hooks/useActiveEntity.ts New hook: Manages active entity state based on route, resets chat UI state.
apps/desktop/src/components/right-panel/hooks/useChatLogic.ts New hook: Encapsulates chat submission, AI streaming, markdown, analytics, and keyboard handling.
apps/desktop/src/components/right-panel/hooks/useChatQueries.ts New hook: Handles chat group/message/session queries, manages chat group ID, provides group creation.
apps/desktop/src/components/right-panel/types/chat-types.ts New file: Defines chat-related types and re-exports session/message types.
apps/desktop/src/components/right-panel/utils/chat-utils.ts New file: Adds formatDate and focusInput utility functions.
apps/desktop/src/components/right-panel/views/chat-view.tsx Refactors to use new hooks for chat logic, queries, and active entity; simplifies component.
apps/desktop/src/components/settings/views/ai.tsx Integrates user context and analytics for AI autonomy selection; updates UI text.
apps/desktop/src/locales/en/messages.po
apps/desktop/src/locales/ko/messages.po
Updates translation catalogs: marks some strings obsolete, adds/updates others for autonomy and chat UI.
crates/db-user/src/chat_messages_ops.rs Adds delete_chat_messages async method to remove all messages for a group.
crates/db-user/src/sessions_ops.rs Modifies delete_session to cascade delete chat messages and groups before session deletion.
crates/template/assets/ai_chat_system.jinja Adds conditional rendering for meeting metadata in chat system prompt template.
plugins/db/build.rs Adds "delete_chat_messages" to command list.
plugins/db/js/bindings.gen.ts Adds deleteChatMessages async function to exported commands.
plugins/db/permissions/autogenerated/commands/delete_chat_messages.toml New file: Adds permission config for delete_chat_messages command.
plugins/db/permissions/autogenerated/reference.md Updates documentation to include delete chat messages permissions.
plugins/db/permissions/default.toml Adds "allow-delete-chat-messages" to default permissions.
plugins/db/permissions/schemas/schema.json Adds permission kinds for allowing/denying chat message deletion; updates default permission set doc.
plugins/db/src/commands/chats.rs Adds Tauri command delete_chat_messages for removing messages by group.
plugins/db/src/lib.rs Registers delete_chat_messages command in plugin builder.
apps/desktop/src/components/editor-area/floating-button.tsx Introduces shouldShowProgress to conditionally render progress only if < 100%.
apps/desktop/src/components/editor-area/index.tsx Reverses logic controlling showProgress to show only for "HyprLocal" LLM connection type.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant ChatView
    participant useActiveEntity
    participant useChatQueries
    participant useChatLogic
    participant DBPlugin

    User->>ChatView: Opens chat panel / navigates
    ChatView->>useActiveEntity: Detect active entity from route
    useActiveEntity->>ChatView: Update active entity, reset chat state

    ChatView->>useChatQueries: Fetch chat groups/messages/session data
    useChatQueries->>DBPlugin: Query chat groups/messages/session

    User->>ChatView: Types message / selects quick action
    ChatView->>useChatLogic: handleSubmit / handleQuickAction
    useChatLogic->>DBPlugin: Append user message
    useChatLogic->>DBPlugin: Stream AI response (assistant message)
    useChatLogic->>ChatView: Update messages state

    User->>ChatView: Selects chat group from dropdown
    ChatView->>useChatQueries: Set current chat group, fetch messages

    User->>ChatView: Triggers message deletion (future/implicit)
    ChatView->>DBPlugin: delete_chat_messages(group_id)
    DBPlugin->>DBPlugin: Remove messages from DB
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~40 minutes

Possibly related PRs

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 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 b8f9077 and 77a7066.

📒 Files selected for processing (4)
  • apps/desktop/src/components/editor-area/floating-button.tsx (3 hunks)
  • apps/desktop/src/components/editor-area/index.tsx (1 hunks)
  • apps/desktop/src/locales/en/messages.po (17 hunks)
  • apps/desktop/src/locales/ko/messages.po (17 hunks)
✅ Files skipped from review due to trivial changes (1)
  • apps/desktop/src/locales/en/messages.po
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/desktop/src/locales/ko/messages.po
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{js,ts,tsx,rs}

⚙️ CodeRabbit Configuration File

**/*.{js,ts,tsx,rs}: 1. No error handling.
2. No unused imports, variables, or functions.
3. For comments, keep it minimal. It should be about "Why", not "What".

Files:

  • apps/desktop/src/components/editor-area/index.tsx
  • apps/desktop/src/components/editor-area/floating-button.tsx
⏰ 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 (macos, macos-latest)
  • GitHub Check: ci (windows, windows-latest)
  • GitHub Check: ci
🔇 Additional comments (5)
apps/desktop/src/components/editor-area/index.tsx (1)

248-248: LGTM! Progress display logic correctly reversed for HyprLocal connections.

The condition change from !== "HyprLocal" to === "HyprLocal" appears intentional and aligns with the related changes in floating-button.tsx where progress display is refined.

apps/desktop/src/components/editor-area/floating-button.tsx (4)

200-200: Good refinement to hide progress when complete.

The new shouldShowProgress constant properly combines the showProgress flag with a check that progress is less than 100%, improving the user experience by hiding progress UI when enhancement is complete.


231-235: LGTM! Correct usage of refined progress condition.

The replacement of showProgress with shouldShowProgress ensures the progress percentage text is only displayed when progress is active and less than 100%.


240-242: LGTM! Enhanced visual feedback with refined progress condition.

Using shouldShowProgress to determine the icon type (AnimatedEnhanceIcon vs EnhanceWIP) provides better visual feedback by showing the animated icon only when progress is actively being tracked.


243-247: LGTM! Consistent progress display logic.

The replacement maintains consistency with other progress display logic, ensuring progress percentage is only shown when actively tracking and less than 100%.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch chat-minor-fix

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 generate unit tests to generate unit tests for 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
Contributor

@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: 6

🔭 Outside diff range comments (1)
apps/desktop/src/components/left-sidebar/top-area/finder-button.tsx (1)

31-37: Make the button screen-reader friendly.

<Button> currently lacks an accessible name; the SVG is decorative. Add aria-label (or a visually-hidden <span>), so assistive tech can announce the purpose.

-        <Button
+        <Button
           variant="ghost"
           size="icon"
           onClick={handleClickFinder}
           className="hover:bg-neutral-200"
+          aria-label="Open finder view"
         >
🧹 Nitpick comments (11)
apps/desktop/src/components/settings/views/ai.tsx (1)

896-900: Consider error handling for analytics tracking.

The analytics event could fail silently if the analytics service is unavailable. While the coding guidelines specify no error handling, consider if failed analytics should affect the user experience.

                                        analyticsCommands.event({
                                          event: "autonomy_selected",
                                          distinct_id: userId,
                                          level: level,
-                                        });
+                                        }).catch(() => {
+                                          // Analytics failure shouldn't block user interaction
+                                        });
apps/desktop/src/components/right-panel/components/chat/floating-action-buttons.tsx (1)

35-66: LGTM! Solid dropdown implementation with room for minor improvement.

The dropdown logic is well-implemented with proper conditional rendering and state management. The text truncation at 25 characters provides good UX.

Consider extracting the text truncation logic to a utility function for reusability:

const truncateText = (text: string, maxLength: number = 25) => 
  text.length > maxLength ? text.substring(0, maxLength) + "..." : text;

// Usage in component:
{group.firstMessage
  ? truncateText(group.firstMessage)
  : `Chat Group ${index + 1}`}
apps/desktop/src/components/right-panel/views/chat-view.tsx (3)

33-33: Consider moving prevIsGenerating ref inside useChatQueries hook.

The prevIsGenerating ref is only used by the useChatQueries hook. For better encapsulation and separation of concerns, consider creating this ref inside the hook rather than at the component level.


81-90: Remove unnecessary async keyword.

The handleNewChat function is marked as async but doesn't use await or return a promise.

-const handleNewChat = async () => {
+const handleNewChat = () => {

92-94: Remove unnecessary async keyword.

The handleSelectChatGroup function doesn't perform any asynchronous operations.

-const handleSelectChatGroup = async (groupId: string) => {
+const handleSelectChatGroup = (groupId: string) => {
apps/desktop/src/components/right-panel/hooks/useChatQueries.ts (3)

81-81: Remove debug console.log statement.

Debug logging should be removed before merging to production.

-console.log("🔍 DEBUG: Loading messages for chat group =", currentChatGroupId);

60-71: Optimize useEffect dependencies.

The dependency array includes sessionId which isn't used in the effect body, and setCurrentChatGroupId which is a stable setter function that doesn't need to be included.

-}, [chatGroupsQuery.data, sessionId, setCurrentChatGroupId]);
+}, [chatGroupsQuery.data]);

94-104: Consider simplifying the generation state tracking logic.

The current implementation using a ref to track previous state works but is complex. Consider using a more straightforward approach in future iterations, such as a state machine or a dedicated hook for generation state management.

apps/desktop/src/components/right-panel/hooks/useChatLogic.ts (1)

107-107: Remove debug console.log statement.

Debug logging should be removed before merging.

-console.log("systemContent", systemContent);
apps/desktop/src/components/left-sidebar/top-area/finder-button.tsx (2)

7-7: Replace “what” comment with a concise “why”.

The inline comment explains what the code does, which is already obvious from the code itself. Per the project’s coding guidelines, comments should focus on why something is done. Either remove the comment or re-phrase it to convey the rationale (e.g., “// Use inline SVG to avoid pulling the full lucide-react bundle”).

-// Custom SVG icon component to replace the folder icon
+// Inline SVG avoids importing the entire lucide-react bundle

8-22: Expose ref & misc SVG props for better re-use.

Forwarding the ref and spreading remaining props makes the icon usable anywhere a regular SVG is expected (e.g., inside <Button asChild> wrappers or animated containers) without additional wrappers.

-function CustomFinderIcon({ size = 16 }: { size?: number }) {
-  return (
-    <svg
-      xmlns="http://www.w3.org/2000/svg"
-      viewBox="0 0 24 24"
-      fill="currentColor"
-      width={size}
-      height={size}
-    >
+import * as React from "react";
+
+type IconProps = React.SVGProps<SVGSVGElement> & { size?: number };
+
+const CustomFinderIcon = React.forwardRef<SVGSVGElement, IconProps>(
+  ({ size = 16, ...rest }, ref) => (
+    <svg
+      ref={ref}
+      xmlns="http://www.w3.org/2000/svg"
+      viewBox="0 0 24 24"
+      fill="currentColor"
+      width={size}
+      height={size}
+      aria-hidden="true"
+      {...rest}
+    >
       <path d="M21.001 3C21.5533 3 22.001 3.44772 22.001 4V20C22.001 20.5523 21.5533 21 21.001 21H3.00098C2.44869 21 2.00098 20.5523 2.00098 20V4C2.00098 3.44772 2.44869 3 3.00098 3H21.001ZM10.4817 4.99884L4.00098 5V19L12.747 18.9997C12.6851 18.6562 12.6308 18.3163 12.5844 17.98C12.2874 17.9933 12.0929 18 12.001 18C9.79308 18 7.60332 17.2701 5.44628 15.8321L6.55568 14.1679C8.39863 15.3966 10.2089 16 12.001 16C12.1337 16 12.2664 15.9967 12.3993 15.9901C12.3747 15.4926 12.3747 14.5797 12.4064 14H9.50098V13C9.50098 9.72527 9.82146 7.06094 10.4817 4.99884ZM12.601 4.99851C11.9358 6.58176 11.5567 9.41121 11.5119 12H14.6338L14.4933 13.124C14.3927 13.9288 14.3567 14.7687 14.3857 15.6439C15.3987 15.3449 16.4174 14.8539 17.4463 14.1679L18.5557 15.8321C17.2358 16.7119 15.9038 17.3267 14.5628 17.6714C14.62 18.1052 14.6937 18.5482 14.7819 18.999L20.001 19V5L12.601 4.99851ZM7.00098 7C7.55326 7 8.00098 7.44772 8.00098 8V9C8.00098 9.55228 7.55326 10 7.00098 10C6.44869 10 6.00098 9.55228 6.00098 9V8C6.00098 7.44772 6.44869 7 7.00098 7ZM17.001 7C17.5533 7 18.001 7.44772 18.001 8V9C18.001 9.55228 17.5533 10 17.001 10C16.4487 10 16.001 9.55228 16.001 9V8C16.001 7.44772 16.4487 7 17.001 7Z" />
     </svg>
-  );
-}
+  ),
+);
+
+CustomFinderIcon.displayName = "CustomFinderIcon";
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between a7688f6 and 0a9fdbe.

📒 Files selected for processing (24)
  • apps/desktop/src/components/left-sidebar/top-area/finder-button.tsx (2 hunks)
  • apps/desktop/src/components/right-panel/components/chat/chat-input.tsx (1 hunks)
  • apps/desktop/src/components/right-panel/components/chat/chat-message.tsx (1 hunks)
  • apps/desktop/src/components/right-panel/components/chat/empty-chat-state.tsx (1 hunks)
  • apps/desktop/src/components/right-panel/components/chat/floating-action-buttons.tsx (1 hunks)
  • apps/desktop/src/components/right-panel/hooks/useActiveEntity.ts (1 hunks)
  • apps/desktop/src/components/right-panel/hooks/useChatLogic.ts (1 hunks)
  • apps/desktop/src/components/right-panel/hooks/useChatQueries.ts (1 hunks)
  • apps/desktop/src/components/right-panel/types/chat-types.ts (1 hunks)
  • apps/desktop/src/components/right-panel/utils/chat-utils.ts (1 hunks)
  • apps/desktop/src/components/right-panel/views/chat-view.tsx (4 hunks)
  • apps/desktop/src/components/settings/views/ai.tsx (5 hunks)
  • apps/desktop/src/locales/en/messages.po (15 hunks)
  • apps/desktop/src/locales/ko/messages.po (15 hunks)
  • crates/db-user/src/chat_messages_ops.rs (1 hunks)
  • crates/template/assets/ai_chat_system.jinja (1 hunks)
  • plugins/db/build.rs (1 hunks)
  • plugins/db/js/bindings.gen.ts (1 hunks)
  • plugins/db/permissions/autogenerated/commands/delete_chat_messages.toml (1 hunks)
  • plugins/db/permissions/autogenerated/reference.md (2 hunks)
  • plugins/db/permissions/default.toml (1 hunks)
  • plugins/db/permissions/schemas/schema.json (2 hunks)
  • plugins/db/src/commands/chats.rs (1 hunks)
  • plugins/db/src/lib.rs (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{js,ts,tsx,rs}

⚙️ CodeRabbit Configuration File

**/*.{js,ts,tsx,rs}: 1. No error handling.
2. No unused imports, variables, or functions.
3. For comments, keep it minimal. It should be about "Why", not "What".

Files:

  • apps/desktop/src/components/right-panel/components/chat/chat-input.tsx
  • apps/desktop/src/components/right-panel/components/chat/empty-chat-state.tsx
  • apps/desktop/src/components/right-panel/components/chat/chat-message.tsx
  • plugins/db/build.rs
  • crates/db-user/src/chat_messages_ops.rs
  • plugins/db/js/bindings.gen.ts
  • apps/desktop/src/components/left-sidebar/top-area/finder-button.tsx
  • plugins/db/src/lib.rs
  • plugins/db/src/commands/chats.rs
  • apps/desktop/src/components/right-panel/utils/chat-utils.ts
  • apps/desktop/src/components/right-panel/types/chat-types.ts
  • apps/desktop/src/components/right-panel/components/chat/floating-action-buttons.tsx
  • apps/desktop/src/components/settings/views/ai.tsx
  • apps/desktop/src/components/right-panel/hooks/useChatQueries.ts
  • apps/desktop/src/components/right-panel/hooks/useActiveEntity.ts
  • apps/desktop/src/components/right-panel/views/chat-view.tsx
  • apps/desktop/src/components/right-panel/hooks/useChatLogic.ts
⏰ 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 (macos, macos-latest)
  • GitHub Check: ci (windows, windows-latest)
🔇 Additional comments (32)
apps/desktop/src/components/settings/views/ai.tsx (4)

10-11: LGTM: Clean analytics integration.

The imports are appropriate for the new analytics functionality being added.


173-173: LGTM: UI text improvements for autonomy levels.

The updated descriptions better emphasize "AI autonomy" levels and provide clearer guidance to users about what each level means.

Also applies to: 178-178, 182-184, 186-188


879-879: LGTM: Consistent UI labeling for autonomy.

The form labels now consistently use "autonomy" terminology, aligning with the updated descriptions.

Also applies to: 882-882


201-201: No need to null-check userId from useHypr

useHypr() throws if it isn’t wrapped in a HyprProvider, and the HyprContext type defines userId: string. Once you call useHypr(), you’re guaranteed a non-null context and a defined userId, so no additional guard is needed before analytics calls.

Likely an incorrect or invalid review comment.

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

24-28: LGTM: Simple and effective focus utility.

The focusInput function provides a clean abstraction for focusing textarea elements with proper null checking.

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

9-9: LGTM: Improved import organization.

Moving BadgeType import to a dedicated types module improves code organization and separation of concerns.

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

34-34: LGTM: Improved user-facing text.

The heading change from "Chat with meeting notes" to "Chat with this meeting" provides clearer, more direct context for users.

plugins/db/permissions/default.toml (1)

49-49: LGTM: Appropriate permission addition.

The new "allow-delete-chat-messages" permission follows established naming conventions and is correctly placed in the chat section.

plugins/db/build.rs (1)

47-47: LGTM!

The new command is properly added to the chat section and follows the established naming convention.

plugins/db/permissions/autogenerated/commands/delete_chat_messages.toml (1)

1-14: LGTM!

The permission configuration follows the standard pattern with both allow and deny permissions defined without pre-configured scope, which is appropriate for a parameterized command.

plugins/db/js/bindings.gen.ts (1)

118-120: LGTM!

The generated function follows the established pattern and correctly maps to the backend command with appropriate parameter and return types.

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

20-33: LGTM!

The conditional template sections are well-structured and follow consistent patterns. The placement before the main content and proper spacing enhance readability.

plugins/db/src/lib.rs (1)

61-61: LGTM!

The command registration is properly placed within the chats section and follows the established pattern for command collection.

crates/db-user/src/chat_messages_ops.rs (1)

58-69: LGTM - Well-implemented deletion method

The delete_chat_messages function follows the established patterns in this file with proper async handling, parameterized queries for SQL injection prevention, and consistent error propagation. The use of impl Into<String> for the parameter type is consistent with other methods.

plugins/db/permissions/autogenerated/reference.md (2)

45-45: Documentation correctly updated for new permission

The addition of allow-delete-chat-messages to the default permissions list is properly placed and consistent with the permission structure.


117-138: Permission table entries properly formatted

The new permission table entries for both allow and deny variants of delete-chat-messages follow the established documentation format and provide clear descriptions.

plugins/db/src/commands/chats.rs (1)

79-97: Excellent implementation following established patterns

The delete_chat_messages command function perfectly follows the established patterns in this file with proper Tauri annotations, consistent error handling, and appropriate state management. The implementation is secure and well-structured.

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

12-36: Good UI improvement for user message differentiation

The conditional rendering for user messages creates a more standard chat interface with proper right-alignment, styling, and timestamp display. The implementation follows React best practices and uses appropriate Tailwind CSS classes.


38-47: Clean simplified rendering for non-user messages

The simplified rendering for non-user messages removes unnecessary complexity while maintaining functionality. The component structure is clean and maintainable.

plugins/db/permissions/schemas/schema.json (2)

321-332: Permission schema entries correctly defined

The new permission kinds for allow-delete-chat-messages and deny-delete-chat-messages are properly structured with appropriate descriptions and follow the established JSON schema pattern.


838-841: Default permission description properly updated

The default permission set description correctly includes the new allow-delete-chat-messages permission in the comprehensive list, maintaining consistency with the actual permission grants.

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

357-390: LGTM! Source reference updates look correct.

The line number updates for API-related messages properly reflect the refactored AI settings component structure.


380-382: LGTM! Chat message updates align with UI improvements.

The removal of "Assistant:" and "User:" labels and updating "Chat with meeting notes" to "Chat with this meeting" improves the chat interface clarity.

Also applies to: 441-446, 1285-1287

apps/desktop/src/components/right-panel/components/chat/floating-action-buttons.tsx (2)

1-17: LGTM! Well-designed interface extension.

The optional props for chat groups maintain backward compatibility while enabling the new dropdown functionality. Import additions are appropriate for the new UI components.


19-34: LGTM! Clean component structure and button repositioning.

The local state management for dropdown control is appropriate, and repositioning the New Chat button to the left provides better UX flow.

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

1-9: LGTM! Clean and well-structured type definitions.

The ActiveEntityInfo interface and BadgeType union type are appropriately designed for the chat entity tracking functionality.


10-21: LGTM! Comprehensive ChatState interface design.

The interface covers all necessary chat state properties including messages, UI flags, and current group tracking. The re-exports provide clean type organization.

apps/desktop/src/components/right-panel/hooks/useActiveEntity.ts (3)

1-28: LGTM! Well-structured hook interface and setup.

The hook props interface clearly defines state setters, and the route matching setup appropriately covers all entity types. The sessionId derivation logic is sound.


29-62: LGTM! Robust entity change detection and state management.

The effect properly detects entity changes and comprehensively resets chat state to prevent data leakage between different entities. The comparison logic is thorough.


63-81: LGTM! Complete dependency management and clean API.

The dependency array properly includes all referenced values, and the return object provides a clean interface for consuming components.

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

20-180: Excellent refactoring to improve separation of concerns.

The extraction of chat logic, queries, and active entity management into dedicated hooks significantly improves the component's maintainability and testability. The component now focuses purely on UI concerns while delegating business logic to specialized hooks.

apps/desktop/src/components/right-panel/hooks/useChatLogic.ts (1)

1-370: Well-structured hook with clear separation of concerns.

The hook effectively encapsulates chat interaction logic and provides a clean interface. Once the code duplication is addressed, this will be an excellent example of extracting complex logic into a reusable hook.

Copy link
Contributor

@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: 0

♻️ Duplicate comments (2)
apps/desktop/src/components/right-panel/hooks/useChatLogic.ts (2)

58-66: Remove error handling to comply with coding guidelines.

The try-catch block violates the coding guidelines that specify "No error handling" for TypeScript files.

Apply this diff to remove the error handling:

-    try {
-      const html = await miscCommands.opinionatedMdToHtml(markdownContent);
-
-      sessionStore.getState().updateEnhancedNote(html);
-
-      console.log("Applied markdown content to enhanced note");
-    } catch (error) {
-      console.error("Failed to apply markdown content:", error);
-    }
+    const html = await miscCommands.opinionatedMdToHtml(markdownContent);
+
+    sessionStore.getState().updateEnhancedNote(html);
+
+    console.log("Applied markdown content to enhanced note");

171-239: Remove error handling to comply with coding guidelines.

The try-catch block violates the coding guidelines that specify "No error handling" for TypeScript files.

Apply this diff to remove the error handling:

-    try {
       const provider = await modelProvider();
       const model = provider.languageModel("defaultModel");

       const aiMessageId = (Date.now() + 1).toString();
       const aiMessage: Message = {
         id: aiMessageId,
         content: "Generating...",
         isUser: false,
         timestamp: new Date(),
       };
       setMessages((prev) => [...prev, aiMessage]);

       const { textStream } = streamText({
         model,
         messages: await prepareMessageHistory(messages, content),
       });

       let aiResponse = "";

       for await (const chunk of textStream) {
         aiResponse += chunk;

         const parts = parseMarkdownBlocks(aiResponse);

         setMessages((prev) =>
           prev.map(msg =>
             msg.id === aiMessageId
               ? {
                 ...msg,
                 content: aiResponse,
                 parts: parts,
               }
               : msg
           )
         );
       }

       await dbCommands.upsertChatMessage({
         id: aiMessageId,
         group_id: groupId,
         created_at: new Date().toISOString(),
         role: "Assistant",
         content: aiResponse.trim(),
       });

       setIsGenerating(false);
-    } catch (error) {
-      console.error("AI error:", error);
-
-      setIsGenerating(false);
-
-      const errorMessageId = (Date.now() + 1).toString();
-      const aiMessage: Message = {
-        id: errorMessageId,
-        content: "Sorry, I encountered an error. Please try again.",
-        isUser: false,
-        timestamp: new Date(),
-      };
-      setMessages((prev) => [...prev, aiMessage]);
-
-      await dbCommands.upsertChatMessage({
-        id: errorMessageId,
-        group_id: groupId,
-        created_at: new Date().toISOString(),
-        role: "Assistant",
-        content: "Sorry, I encountered an error. Please try again.",
-      });
-    }
🧹 Nitpick comments (2)
apps/desktop/src/components/right-panel/hooks/useChatLogic.ts (2)

107-107: Remove debug console.log statement.

Debug console statements should be removed from production code.

-    console.log("systemContent", systemContent);

63-63: Remove debug console.log statement.

Debug console statements should be removed from production code.

-      console.log("Applied markdown content to enhanced note");
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 0a9fdbe and 7652d16.

📒 Files selected for processing (4)
  • apps/desktop/src/components/right-panel/hooks/useChatLogic.ts (1 hunks)
  • apps/desktop/src/components/settings/views/ai.tsx (5 hunks)
  • apps/desktop/src/locales/en/messages.po (15 hunks)
  • apps/desktop/src/locales/ko/messages.po (15 hunks)
✅ Files skipped from review due to trivial changes (1)
  • apps/desktop/src/locales/en/messages.po
🚧 Files skipped from review as they are similar to previous changes (2)
  • apps/desktop/src/components/settings/views/ai.tsx
  • apps/desktop/src/locales/ko/messages.po
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{js,ts,tsx,rs}

⚙️ CodeRabbit Configuration File

**/*.{js,ts,tsx,rs}: 1. No error handling.
2. No unused imports, variables, or functions.
3. For comments, keep it minimal. It should be about "Why", not "What".

Files:

  • apps/desktop/src/components/right-panel/hooks/useChatLogic.ts
🧠 Learnings (1)
apps/desktop/src/components/right-panel/hooks/useChatLogic.ts (1)

Learnt from: plyght
PR: #921
File: plugins/location-connectivity/src/error.rs:1-41
Timestamp: 2025-06-06T16:31:46.457Z
Learning: In the location-connectivity plugin (plugins/location-connectivity/), comprehensive error handling via LocationConnectivityError is necessary despite the "no error handling" guideline, as the plugin performs system-level operations (WiFi detection, persistent storage) that require proper error propagation to the frontend.

⏰ 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 (windows, windows-latest)
  • GitHub Check: ci (macos, macos-latest)
  • GitHub Check: ci
🔇 Additional comments (2)
apps/desktop/src/components/right-panel/hooks/useChatLogic.ts (2)

1-12: All imports are properly used.

The imports are correctly utilized throughout the hook implementation.


242-252: Clean refactoring eliminates previous code duplication.

The functions now properly delegate to the shared processUserMessage function, eliminating the code duplication that was flagged in previous reviews.

Copy link
Contributor

@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: 1

🧹 Nitpick comments (1)
crates/db-user/src/sessions_ops.rs (1)

113-127: Consider using a single DELETE statement with subquery for better performance.

The current implementation fetches all group IDs first, then deletes messages for each group individually. This could be optimized using a single DELETE statement with a subquery to reduce database round trips.

-    let mut rows = conn
-        .query(
-            "SELECT id FROM chat_groups WHERE session_id = ?",
-            vec![session_id.clone()],
-        )
-        .await?;
-
-    while let Some(row) = rows.next().await? {
-        let group_id: String = row.get(0)?;
-        conn.execute(
-            "DELETE FROM chat_messages WHERE group_id = ?",
-            vec![group_id],
-        )
-        .await?;
-    }
+    conn.execute(
+        "DELETE FROM chat_messages WHERE group_id IN (SELECT id FROM chat_groups WHERE session_id = ?)",
+        vec![session_id.clone()],
+    )
+    .await?;
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 7652d16 and b8f9077.

📒 Files selected for processing (7)
  • crates/db-user/src/sessions_ops.rs (1 hunks)
  • plugins/db/build.rs (1 hunks)
  • plugins/db/js/bindings.gen.ts (1 hunks)
  • plugins/db/permissions/autogenerated/reference.md (2 hunks)
  • plugins/db/permissions/default.toml (1 hunks)
  • plugins/db/permissions/schemas/schema.json (2 hunks)
  • plugins/db/src/lib.rs (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • plugins/db/permissions/autogenerated/reference.md
🚧 Files skipped from review as they are similar to previous changes (5)
  • plugins/db/permissions/default.toml
  • plugins/db/build.rs
  • plugins/db/src/lib.rs
  • plugins/db/permissions/schemas/schema.json
  • plugins/db/js/bindings.gen.ts
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{js,ts,tsx,rs}

⚙️ CodeRabbit Configuration File

**/*.{js,ts,tsx,rs}: 1. No error handling.
2. No unused imports, variables, or functions.
3. For comments, keep it minimal. It should be about "Why", not "What".

Files:

  • crates/db-user/src/sessions_ops.rs
⏰ 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)

@duckduckhero duckduckhero merged commit 4c9a618 into main Jul 26, 2025
8 checks passed
@ComputelessComputer ComputelessComputer deleted the chat-minor-fix branch December 14, 2025 15:21
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.

1 participant