Skip to content

Refactor AI tools and chat components for improved functionality#226

Merged
carhartlewis merged 1 commit intomainfrom
lewis/ai-chat
Mar 30, 2025
Merged

Refactor AI tools and chat components for improved functionality#226
carhartlewis merged 1 commit intomainfrom
lewis/ai-chat

Conversation

@carhartlewis
Copy link
Copy Markdown
Contributor

@carhartlewis carhartlewis commented Mar 30, 2025

  • Consolidated AI tools into a single tools export for better organization.
  • Removed deprecated tools and streamlined the chat API.
  • Introduced ChatAvatar and RiskDisplay components for enhanced user experience.
  • Updated Message and ReasoningMessagePart components to utilize new streaming capabilities.
  • Improved layout and responsiveness in AssistantSheet and Messages components.
  • Enhanced markdown rendering with MemoizedReactMarkdown for performance optimization.

Summary by CodeRabbit

  • New Features

    • Introduced a Chat Avatar to enhance the chat experience with personalized visuals.
    • Added a Risk Display component that presents risk details in a card grid layout.
    • Rolled out a responsive assistant interface that adapts between a sheet or drawer based on screen size.
    • Upgraded chat messaging components for improved visual feedback and clarity.
  • Enhancements

    • Streamlined Markdown rendering and refined spacing for a cleaner, more intuitive interface.
    • Optimized backend tool management for smoother overall performance.

- Consolidated AI tools into a single `tools` export for better organization.
- Removed deprecated tools and streamlined the chat API.
- Introduced `ChatAvatar` and `RiskDisplay` components for enhanced user experience.
- Updated `Message` and `ReasoningMessagePart` components to utilize new streaming capabilities.
- Improved layout and responsiveness in `AssistantSheet` and `Messages` components.
- Enhanced markdown rendering with `MemoizedReactMarkdown` for performance optimization.
@vercel
Copy link
Copy Markdown

vercel Bot commented Mar 30, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
app 🔄 Building (Inspect) Visit Preview 💬 Add feedback Mar 30, 2025 5:53pm
comp-portal 🔄 Building (Inspect) Visit Preview 💬 Add feedback Mar 30, 2025 5:53pm

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 30, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

This PR consolidates the tool access logic by replacing multiple individual tool imports with a single consolidated import from a new data directory. It removes the organization verification step from the chat API and updates the system prompt. Several UI components have been added or refactored, including new components for chat avatars and risk display, updates to message rendering and layout classes, and conditional rendering for different viewport sizes. Additionally, a hook for streamable text has been improved and minor CSS adjustments have been made to tighten the visual layout.

Changes

File(s) Change Summary
apps/app/src/app/api/chat/route.ts Consolidated tool imports; removed organization verification logic; revised system prompt tone and content.
apps/app/src/components/ai/chat-avatar.tsx
apps/app/src/components/ai/chat-text-area.tsx
apps/app/src/components/ai/markdown.tsx
apps/app/src/components/ai/message.tsx
apps/app/src/components/ai/messages.tsx
apps/app/src/components/ai/model-picker.tsx
apps/app/src/components/sheets/assistant-sheet.tsx
apps/app/src/components/ai/risk-display.tsx
Added new UI components (ChatAvatar, RiskDisplay) and refactored existing ones (ChatTextarea, Markdown, message components); updated layout classes and introduced responsive rendering (Sheet vs. Drawer in AssistantSheet).
apps/app/src/data/tools/index.ts
apps/app/src/data/tools/organization.ts
apps/app/src/data/tools/policies.ts
apps/app/src/data/tools/risks.ts
Introduced new tool files that consolidate functionalities for organization, policies, and risks, replacing the older hook-based tool exports.
apps/app/src/hooks/ai/tools.ts Removed the file containing individual tool exports and related logic.
apps/app/src/hooks/use-streamable-text.tsx Enhanced streamable text handling with direct string assignment, accumulated concatenation, and cleanup to avoid updates on unmounted components.
packages/ui/src/editor.css Adjusted margins for list elements and paragraphs to create a tighter layout in the editor.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant API_Route
    participant Tools

    Client->>API_Route: POST chat request
    API_Route->>Tools: Use consolidated tool set
    API_Route-->>Client: Return GRC-focused response
Loading
sequenceDiagram
    participant AssistantSheet
    participant SheetComponent
    participant DrawerComponent

    AssistantSheet->>AssistantSheet: Check viewport width (useMediaQuery)
    alt Desktop View
        AssistantSheet->>SheetComponent: Render Sheet with Chat
    else Mobile View
        AssistantSheet->>DrawerComponent: Render Drawer with Chat
    end
Loading

Possibly related PRs

Poem

I'm a rabbit with a joyful hop,
Coding changes made my heart go pop.
Tools consolidated, flows refined,
UI and API beautifully aligned.
With crisp new code, I cheer and prance –
In this fine code garden, I love to dance! 🐰🎉


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between bd459bf and 40d513e.

📒 Files selected for processing (16)
  • apps/app/src/app/api/chat/route.ts (2 hunks)
  • apps/app/src/components/ai/chat-avatar.tsx (1 hunks)
  • apps/app/src/components/ai/chat-text-area.tsx (0 hunks)
  • apps/app/src/components/ai/markdown.tsx (1 hunks)
  • apps/app/src/components/ai/message.tsx (5 hunks)
  • apps/app/src/components/ai/messages.tsx (2 hunks)
  • apps/app/src/components/ai/model-picker.tsx (1 hunks)
  • apps/app/src/components/ai/risk-display.tsx (1 hunks)
  • apps/app/src/components/sheets/assistant-sheet.tsx (1 hunks)
  • apps/app/src/data/tools/index.ts (1 hunks)
  • apps/app/src/data/tools/organization.ts (1 hunks)
  • apps/app/src/data/tools/policies.ts (1 hunks)
  • apps/app/src/data/tools/risks.ts (1 hunks)
  • apps/app/src/hooks/ai/tools.ts (0 hunks)
  • apps/app/src/hooks/use-streamable-text.tsx (1 hunks)
  • packages/ui/src/editor.css (2 hunks)
✨ 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:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @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.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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.

@carhartlewis carhartlewis merged commit 1a34e64 into main Mar 30, 2025
3 of 7 checks passed
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