Skip to content

Improve layout and structure of assistant components#99

Merged
izadoesdev merged 2 commits into
databuddy-analytics:stagingfrom
sbansal1999:assistant-page-fixes
Aug 18, 2025
Merged

Improve layout and structure of assistant components#99
izadoesdev merged 2 commits into
databuddy-analytics:stagingfrom
sbansal1999:assistant-page-fixes

Conversation

@sbansal1999

@sbansal1999 sbansal1999 commented Aug 18, 2025

Copy link
Copy Markdown
Contributor
Desktop View Screenshot 2025-08-19 at 1 45 32 AM
Tablet/Mobile View image

Summary by CodeRabbit

  • New Features

    • Redesigned welcome section with cohesive “Welcome to Databunny” block and icon.
    • Quick examples now shown as a responsive, animated grid with clickable buttons.
  • Style

    • Added subtle gradient background and full-height layout adjustments.
    • Refined message spacing and overall visual framing.
  • Refactor

    • Replaced custom scroll area with native scrolling for messages.
    • Streamlined message rendering for improved performance.
    • Simplified page rendering with early returns for loading and data states.

@vercel

vercel Bot commented Aug 18, 2025

Copy link
Copy Markdown

@sbansal1999 is attempting to deploy a commit to the Databuddy Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Aug 18, 2025

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

Refactors ChatSection to use native scrolling, redesigns the welcome/quick-questions UI into a responsive grid, adjusts message rendering spacing, updates AIAssistantMain container classes for a gradient backdrop and full-height layout, simplifies AssistantPage rendering with early returns, and sets the websites/[id] layout container to h-full.

Changes

Cohort / File(s) Summary
Chat UI refactor
apps/dashboard/app/(main)/websites/[id]/assistant/components/chat-section.tsx
Replaced ScrollArea with native div scrolling; redesigned welcome block; converted quick examples to a responsive grid with animated buttons; streamlined message mapping and spacing; preserved input/submit behavior.
Assistant main layout styling
apps/dashboard/app/(main)/websites/[id]/assistant/components/ai-assistant-main.tsx
Removed explicit type on .find callback parameter; switched outer wrapper to gradient background; added h-full to inner flex container; maintained Chat vs. Visualization structure.
Assistant page render flow
apps/dashboard/app/(main)/websites/[id]/assistant/page.tsx
Replaced conditional JSX with early returns: immediately renders loading skeleton when loading or missing data; otherwise renders main; data-fetching effect unchanged.
Websites layout height tweak
apps/dashboard/app/(main)/websites/[id]/layout.tsx
Added h-full to outer container class for full-height layout; no logic changes.

Sequence Diagram(s)

sequenceDiagram
  participant U as User
  participant P as AssistantPage
  participant D as Data/State
  participant M as AIAssistantMain
  participant L as LoadingSkeleton

  U->>P: Navigate to /websites/[id]/assistant
  P->>D: Check isLoading & websiteData
  alt isLoading or missing data
    P-->>U: Render LoadingSkeleton
    P->>L: Show
  else ready
    P-->>U: Render AIAssistantMain
    P->>M: Show
  end
Loading
sequenceDiagram
  participant U as User
  participant C as ChatSection
  participant S as sendMessage()
  participant V as Viewport

  U->>C: Click quick question button
  C->>S: sendMessage(text)
  S-->>C: Message enqueued/rendered
  C->>V: scrollToBottom()
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Poem

A gradient dawn across the chat,
I twitch my ears—imagine that!
Buttons bloom in tidy rows,
Quick questions hop where curiosity goes.
Scrolls now glide on native breeze,
Messages nest with gentle ease.
Thump-thump—Databunny’s pleased. 🐇✨

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.
    • 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.
  • 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 the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

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

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

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

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • 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.

@sbansal1999

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 18, 2025

Copy link
Copy Markdown
Contributor
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🔭 Outside diff range comments (1)
apps/dashboard/app/(main)/websites/[id]/assistant/components/chat-section.tsx (1)

172-176: ModelSelector onModelChange is a no-op; users can’t switch models

onModelChange={() => {}} prevents the model from changing. Wire it to the model atom setter so the selection persists and impacts responses.

Apply this diff:

-	const [selectedModel] = useAtom(modelAtom);
+	const [selectedModel, setSelectedModel] = useAtom(modelAtom);
-					<ModelSelector
-						disabled={isLoading}
-						onModelChange={() => {}}
-						selectedModel={selectedModel}
-					/>
+					<ModelSelector
+						disabled={isLoading}
+						onModelChange={setSelectedModel}
+						selectedModel={selectedModel}
+					/>

Also applies to: 81-82

🧹 Nitpick comments (2)
apps/dashboard/app/(main)/websites/[id]/assistant/components/chat-section.tsx (1)

90-96: Avoid repeated O(n) filters on every render; memoize messageStats

messageStats runs three filters on each render. It’s minor now but grows with history size. Memoize based on messages to keep renders snappy.

Apply this diff:

-import { useEffect, useRef, useState } from 'react';
+import { useEffect, useMemo, useRef, useState } from 'react';
-	// Calculate message statistics
-	const messageStats = {
-		total: messages.length - 1, // Excluding welcome message
-		charts: messages.filter((m) => m.responseType === 'chart').length,
-		metrics: messages.filter((m) => m.responseType === 'metric').length,
-		text: messages.filter((m) => m.responseType === 'text').length,
-	};
+	// Calculate message statistics
+	const messageStats = useMemo(() => {
+		const stats = { total: Math.max(0, messages.length - 1), charts: 0, metrics: 0, text: 0 };
+		for (const m of messages) {
+			if (m.responseType === 'chart') stats.charts++;
+			else if (m.responseType === 'metric') stats.metrics++;
+			else if (m.responseType === 'text') stats.text++;
+		}
+		return stats;
+	}, [messages]);

Also applies to: 15-15

apps/dashboard/app/(main)/websites/[id]/assistant/components/ai-assistant-main.tsx (1)

58-60: Gradient wrapper height chain confirmed
All ancestor layouts provide explicit height, so your outer <div className="h-full bg-gradient-to-br…"> will stretch as expected:

• apps/dashboard/app/layout.tsx
<body className="flex h-full min-h-screen…">
• apps/dashboard/app/(main)/layout.tsx
– outer <div className="h-screen overflow-hidden…">
– nested <div className="h-screen…"> wrapping {children}
• apps/dashboard/app/(main)/websites/[id]/layout.tsx (line 53)
<div className="mx-auto h-full…">

If you’re happy with two stacked gradients (outer and ChatSection’s inner backdrop), no change is needed. Otherwise, consider removing one gradient layer for a cleaner, single backdrop.

📜 Review details

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

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 5ca89d1 and 28adc1f.

📒 Files selected for processing (4)
  • apps/dashboard/app/(main)/websites/[id]/assistant/components/ai-assistant-main.tsx (2 hunks)
  • apps/dashboard/app/(main)/websites/[id]/assistant/components/chat-section.tsx (1 hunks)
  • apps/dashboard/app/(main)/websites/[id]/assistant/page.tsx (1 hunks)
  • apps/dashboard/app/(main)/websites/[id]/layout.tsx (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
apps/dashboard/app/(main)/websites/[id]/assistant/page.tsx (1)
apps/dashboard/app/(main)/websites/[id]/assistant/components/ai-assistant-main.tsx (1)
  • AIAssistantMain (16-80)
apps/dashboard/app/(main)/websites/[id]/assistant/components/chat-section.tsx (3)
apps/dashboard/lib/utils.ts (1)
  • cn (4-6)
apps/dashboard/lib/discord-webhook.ts (1)
  • sendMessage (89-99)
apps/dashboard/app/(main)/websites/[id]/assistant/components/message-bubble.tsx (1)
  • MessageBubble (259-268)
🔇 Additional comments (5)
apps/dashboard/app/(main)/websites/[id]/layout.tsx (1)

53-53: Height propagation verified; no changes needed
I confirmed that your added h-full will work as intended:

  • The root <html> has h-full and the <body> uses flex h-full min-h-screen.
  • All top-level layout wrappers employ h-screen on their container <div>s.
    With that full-height context upstream, the inner h-full will correctly fill its parent without causing double scroll.
apps/dashboard/app/(main)/websites/[id]/assistant/components/chat-section.tsx (2)

209-267: Welcome/quick-examples redesign looks great

Clean, cohesive welcome block and the responsive grid of examples improve UX and scannability. The subtle animations and iconography feel polished.


271-274: Direct MessageBubble rendering with reduced spacing is simpler and efficient

Dropping extra wrappers and using space-y-3 keeps the DOM lighter and layout tighter without sacrificing readability.

apps/dashboard/app/(main)/websites/[id]/assistant/page.tsx (1)

80-85: Early-return rendering path simplifies control flow

Clear separation of loading vs. loaded states. This pairs nicely with the AIAssistantMain wrapper now handling its own background/height.

apps/dashboard/app/(main)/websites/[id]/assistant/components/ai-assistant-main.tsx (1)

24-29: Type inference on .find callback is fine here

Dropping the explicit Message type on the predicate parameter keeps things concise without losing safety. No action needed.

Comment thread apps/dashboard/app/(main)/websites/[id]/assistant/components/chat-section.tsx Outdated
@sbansal1999
sbansal1999 force-pushed the assistant-page-fixes branch from 28adc1f to a12e7d2 Compare August 18, 2025 21:00
@sbansal1999

Copy link
Copy Markdown
Contributor Author

Pushed the scrollRef change.

@izadoesdev
izadoesdev merged commit 99e1fc2 into databuddy-analytics:staging Aug 18, 2025
0 of 3 checks passed
This was referenced Aug 24, 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.

2 participants