-
-
Notifications
You must be signed in to change notification settings - Fork 254
Add AI chat panel to Platform website (#11346) #11347
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
Add AI chat panel to Platform website (#11346) #11347
Conversation
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the WalkthroughAdds an AI chat panel feature to the Platform client: new component (UI, logic, styles), DI wiring, shared DTOs, and inclusion in MainLayout. Updates theme variables and media-query mixins. Adds Bit.BlazorUI.Extras dependency and assets and minor build target tweak. Changes
Sequence Diagram(s)sequenceDiagram
participant U as User
participant P as AppAiChatPanel (Razor)
participant C as Channel<string>
participant UI as UI State
U->>P: Open panel, type message, click Send
activate P
P->>C: StartChannel() / Write(userInput)
P->>UI: Add user message + placeholder assistant<br/>isLoading = true
UI-->>U: Render updated chat
Note over P,C: Streaming placeholder (future hub/service)
C-->>P: Read chunks / completion
P->>UI: Update last assistant message<br/>isLoading = false
UI-->>U: Render assistant response
deactivate P
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Assessment against linked issues
Assessment against linked issues: Out-of-scope changesNone found. Poem
✨ Finishing Touches🧪 Generate unit tests
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. Comment |
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: 13
🧹 Nitpick comments (18)
src/Websites/Platform/src/Bit.Websites.Platform.Server/Components/App.razor (1)
35-35: Consider deferring Extras script for faster first paintIf supported by the Script tag helper, add defer to avoid blocking parsing.
- <Script Src="_content/Bit.BlazorUI.Extras/scripts/bit.blazorui.extras.js"></Script> + <Script Src="_content/Bit.BlazorUI.Extras/scripts/bit.blazorui.extras.js" defer></Script>src/Websites/Platform/src/Bit.Websites.Platform.Client/Bit.Websites.Platform.Client.csproj (1)
39-39: Package addition is consistent with the Bit stackVersion aligns with other Bit packages. Optionally move Bit.* versions to central package management (Directory.Packages.props) or a $(BitPackagesVersion) property to keep them in sync.
src/Websites/Platform/src/Bit.Websites.Platform.Shared/Dtos/AiChat/AiChatMessageRole.cs (1)
3-7: Stabilize enum wire format with explicit valuesAdd explicit numeric values to prevent unintended reordering/renumbering in future.
public enum AiChatMessageRole { - User, - Assistant + User = 0, + Assistant = 1 }src/Websites/Platform/src/Bit.Websites.Platform.Client/Styles/app.scss (1)
7-10: Add light‐theme fallback for --bit-clr-bg-ter
Prevent undefined var in light mode by defining a base value in:root:+:root { + --bit-clr-bg-ter: var(--bit-clr-bg-pri, #ffffff); +}src/Websites/Platform/src/Bit.Websites.Platform.Client/Styles/abstracts/_media-queries.scss (1)
76-98: Clarify inclusivity and add a brief doc block for gt- and new gt-xs.*To avoid ambiguity over inclusive edges, add a short comment noting that lt-* uses max-width (inclusive) and gt-* uses min-width (inclusive). This helps future contributors reason about off-by-one expectations across all mixins.
// media gt queries +// Note: All lt-* use inclusive max-width; all gt-* use inclusive min-width. +// Example: lt-md => <= $screen-sm-max, gt-md => >= $screen-lg-min. @mixin gt-lg {src/Websites/Platform/src/Bit.Websites.Platform.Client/Shared/AppComponentBase.cs (1)
35-36: Avoid throwing from a getter; let consumers decide when to observe cancellation.Calling
ThrowIfCancellationRequestedin the property getter can cause unexpected exceptions at read time. Prefer returning the token and letting the awaited operation surfaceOperationCanceledException.- cts.Token.ThrowIfCancellationRequested(); return cts.Token;src/Websites/Platform/src/Bit.Websites.Platform.Client/Shared/MainLayout.razor (1)
21-22: Stacking and overlay order: ensure MessageBox remains on top.If both use fixed positioning, DOM order may affect stacking when z-index ties. Either swap render order or assign explicit z-indexes.
-<MessageBox /> -<AppAiChatPanel /> +<AppAiChatPanel /> +<MessageBox />Optionally set z-indexes in the panel’s SCSS (see AppAiChatPanel.razor.scss note) so MessageBox is always above.
src/Websites/Platform/src/Bit.Websites.Platform.Client/Shared/AppAiChatPanel.razor.scss (3)
13-33: Make the FAB reliably overlay content.Add an explicit z-index to the open-panel button to avoid being obscured by page content or other overlays.
.open-panel-button { padding: 0; left: unset; right: unset; inset-inline-end: 2rem; + z-index: var(--z-index-ai-chat-fab, 1100);
23-26: Prefer logical property for vertical offset.Use
inset-block-endfor RTL awareness and writing-mode friendliness.- bottom: 4rem; + inset-block-end: 4rem;
44-47: Less aggressive wrapping for code text.
word-break: break-allcan hurt readability. Consideroverflow-wrap:anywhereplusword-break:break-word.- white-space: pre-wrap; - word-break: break-all; + white-space: pre-wrap; + overflow-wrap: anywhere; + word-break: break-word;src/Websites/Platform/src/Bit.Websites.Platform.Shared/Dtos/AiChat/StartChatbotRequest.cs (1)
3-12: DTO immutability and intent signaling.Prefer a record with init-only and a read-only collection to avoid mid-flight mutation of history during streaming.
-public class StartChatbotRequest +public sealed record StartChatbotRequest { - public int CultureId { get; set; } + public int CultureId { get; init; } - public string? DeviceInfo { get; set; } + public string? DeviceInfo { get; init; } - public List<AiChatMessage> ChatMessagesHistory { get; set; } = []; + public IReadOnlyList<AiChatMessage> ChatMessagesHistory { get; init; } = Array.Empty<AiChatMessage>(); - public Uri? ServerApiAddress { get; set; } + public Uri? ServerApiAddress { get; init; } // See SSRF note above. }src/Websites/Platform/src/Bit.Websites.Platform.Client/Shared/AppAiChatPanel.razor (5)
7-15: Missing accessible label on the floating trigger button.Add a Title/AriaLabel so screen readers can announce the action.
<BitButton Float Draggable FloatOffset="1rem" Class="open-panel-button" Variant="BitVariant.Outline" OnClick="() => isOpen = true" Color="BitColor.PrimaryBackground" IconUrl="/images/ai-chat-icon-64.webp" + Title="Open AI chat" + AriaLabel="Open AI chat" FloatPosition="BitPosition.BottomRight" />
17-21: Simplify responsive props (avoidis true/falsepatterns).Use direct boolean expressions for clarity.
- <BitProPanel ShowCloseButton - @bind-IsOpen="isOpen" - ModeFull="isSmallScreen is true" - Modeless="isSmallScreen is false" + <BitProPanel ShowCloseButton + @bind-IsOpen="isOpen" + ModeFull="@isSmallScreen" + Modeless="@(!isSmallScreen)" OnDismiss="WrapHandled(HandleOnDismissPanel)">
24-25: String casing / localization.Consider title-casing and localizing the header text.
- <BitText Typography="BitTypography.H5">AI chat panel</BitText> + <BitText Typography="BitTypography.H5">AI Chat Panel</BitText>
74-74: Minor formatting nit.Remove leading space in the attribute value.
- <BitStack Alignment=" BitAlignment.Center" FitHeight FillContent Class="default-prompt-container"> + <BitStack Alignment="BitAlignment.Center" FitHeight FillContent Class="default-prompt-container">
114-123: Send button accessibility.Since the button is icon-only, ensure
Title/AriaLabelare present for AT users.<BitButton Float AutoLoading FloatAbsolute - Title="Send" + Title="Send" + AriaLabel="Send message" IconName="Up" FloatOffset="0.5rem" Class="send-message-button"src/Websites/Platform/src/Bit.Websites.Platform.Client/Shared/AppAiChatPanel.razor.cs (2)
150-156: Async without awaits.
StopChanneldoesn’t await anything. Make it synchronous to reduce noise.- private async Task StopChannel() + private Task StopChannel() { if (channel is null) return; channel.Writer.Complete(); channel = null; + return Task.CompletedTask; }(Alternatively, keep async and add awaits once hub wiring is in.)
85-93: Localization for the initial assistant message.Hard-coded English string; consider using your localization pipeline.
- Content = "I'm here to make your app experience awesome! Got a question or need a hand?", + Content = AppStrings.AiChatPanel_WelcomeMessage, // example resource
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Knowledge Base: Disabled due to Reviews > Disable Knowledge Base setting
⛔ Files ignored due to path filters (2)
src/Websites/Platform/src/Bit.Websites.Platform.Client/wwwroot/images/github-icon-dark.svgis excluded by!**/*.svgsrc/Websites/Platform/src/Bit.Websites.Platform.Client/wwwroot/images/github-icon-light.svgis excluded by!**/*.svg
📒 Files selected for processing (13)
src/Websites/Platform/src/Bit.Websites.Platform.Client/Bit.Websites.Platform.Client.csproj(2 hunks)src/Websites/Platform/src/Bit.Websites.Platform.Client/Extensions/IServiceCollectionExtensions.cs(1 hunks)src/Websites/Platform/src/Bit.Websites.Platform.Client/Shared/AppAiChatPanel.razor(1 hunks)src/Websites/Platform/src/Bit.Websites.Platform.Client/Shared/AppAiChatPanel.razor.cs(1 hunks)src/Websites/Platform/src/Bit.Websites.Platform.Client/Shared/AppAiChatPanel.razor.scss(1 hunks)src/Websites/Platform/src/Bit.Websites.Platform.Client/Shared/AppComponentBase.cs(3 hunks)src/Websites/Platform/src/Bit.Websites.Platform.Client/Shared/MainLayout.razor(1 hunks)src/Websites/Platform/src/Bit.Websites.Platform.Client/Styles/abstracts/_media-queries.scss(1 hunks)src/Websites/Platform/src/Bit.Websites.Platform.Client/Styles/app.scss(1 hunks)src/Websites/Platform/src/Bit.Websites.Platform.Server/Components/App.razor(2 hunks)src/Websites/Platform/src/Bit.Websites.Platform.Shared/Dtos/AiChat/AiChatMessage.cs(1 hunks)src/Websites/Platform/src/Bit.Websites.Platform.Shared/Dtos/AiChat/AiChatMessageRole.cs(1 hunks)src/Websites/Platform/src/Bit.Websites.Platform.Shared/Dtos/AiChat/StartChatbotRequest.cs(1 hunks)
⏰ 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). (1)
- GitHub Check: build and test
🔇 Additional comments (6)
src/Websites/Platform/src/Bit.Websites.Platform.Server/Components/App.razor (1)
13-13: Extras CSS inclusion looks correctLoaded after core Bit.BlazorUI CSS; ordering is fine.
src/Websites/Platform/src/Bit.Websites.Platform.Client/Bit.Websites.Platform.Client.csproj (1)
103-105: XML escape fix for Outputs is correctUsing ->Replace in MSBuild attributes is required; this resolves parsing issues.
src/Websites/Platform/src/Bit.Websites.Platform.Client/Extensions/IServiceCollectionExtensions.cs (1)
27-28: Registering Bit.BlazorUI.Extras services is appropriatePlaced after core Bit UI services; good ordering.
src/Websites/Platform/src/Bit.Websites.Platform.Client/Styles/abstracts/_media-queries.scss (1)
50-74: Breakpoints remap for lt- looks correct.*Using the next-lower max as the upper bound preserves continuity (no gaps/overlaps) and matches the defined min/max pairs.
src/Websites/Platform/src/Bit.Websites.Platform.Shared/Dtos/AiChat/AiChatMessage.cs (1)
9-10: Ensure JsonIgnore resolves without relying on global usings.If there’s no
using System.Text.Json.Serialization;in scope, this won’t compile. Fully qualify to be safe.-[JsonIgnore] +[System.Text.Json.Serialization.JsonIgnore] public bool Successful { get; set; } = true;Alternatively, add
using System.Text.Json.Serialization;at the top of the file.src/Websites/Platform/src/Bit.Websites.Platform.Shared/Dtos/AiChat/StartChatbotRequest.cs (1)
9-9: Ignore C# version warning. The Bit.Websites.Platform.Shared project targets net9.0 (default C# 13), so the C# 12 collection expression (= []) is fully supported—no change needed.Likely an incorrect or invalid review comment.
closes #11346
Summary by CodeRabbit