Skip to content

feat: add react-rough-notation dependency and update chat components …#235

Merged
MODSetter merged 1 commit intomainfrom
dev
Jul 26, 2025
Merged

feat: add react-rough-notation dependency and update chat components …#235
MODSetter merged 1 commit intomainfrom
dev

Conversation

@MODSetter
Copy link
Owner

@MODSetter MODSetter commented Jul 26, 2025

…for improved UI

Screenshots

API Changes

  • This PR includes API changes

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Performance improvement (non-breaking change which enhances performance)
  • Documentation update
  • Breaking change (fix or feature that would cause existing functionality to change)

Testing

  • I have tested these changes locally
  • I have added/updated unit tests
  • I have added/updated integration tests

Checklist:

  • My code follows the code style of this project
  • My change requires documentation updates
  • I have updated the documentation accordingly
  • My change requires dependency updates
  • I have updated the dependencies accordingly
  • My code builds clean without any errors or warnings
  • All new and existing tests passed

Summary by CodeRabbit

  • New Features
    • Introduced an animated empty state in the chat interface, enhancing the user experience with engaging visual highlights when there are no messages.
  • Style
    • Updated the appearance of the "Further Suggested Questions" accordion for improved visual consistency.
  • Chores
    • Added "react-rough-notation" as a new dependency.
  • Other
    • Changed the initial chat search mode to "CHUNKS" for new sessions.

@vercel
Copy link

vercel bot commented Jul 26, 2025

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

Name Status Preview Comments Updated (UTC)
surf-sense-frontend ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 26, 2025 2:06pm

@coderabbitai
Copy link

coderabbitai bot commented Jul 26, 2025

Walkthrough

A new AnimatedEmptyState React component was introduced to provide an animated empty state UI in the chat interface, utilizing the react-rough-notation library. The chat messages component was updated to use this new animated empty state. Minor presentational updates were made to the "Further Questions" UI, and the chat state hook's default search mode was changed. The new dependency was added to package.json.

Changes

File(s) Change Summary
surfsense_web/components/chat/AnimatedEmptyState.tsx Added new AnimatedEmptyState React component with animated text highlights and layout stability logic.
surfsense_web/components/chat/ChatMessages.tsx Replaced static empty state with AnimatedEmptyState; no logic changes elsewhere; formatting updates.
surfsense_web/components/chat/ChatFurtherQuestions.tsx Updated accordion and trigger styling; changed trigger text; no logic changes.
surfsense_web/hooks/useChat.ts Changed initial searchMode from "DOCUMENTS" to "CHUNKS"; formatting and style improvements.
surfsense_web/package.json Added react-rough-notation dependency.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant ChatMessagesUI
    participant AnimatedEmptyState

    User->>ChatMessagesUI: Open chat with no messages
    ChatMessagesUI->>AnimatedEmptyState: Render empty state
    AnimatedEmptyState->>AnimatedEmptyState: Track sidebar/layout state
    AnimatedEmptyState->>AnimatedEmptyState: Wait for layout stability & in-view
    AnimatedEmptyState->>User: Show animated highlights in empty state UI
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐇✨
In the chat where silence lay,
Animated highlights now sway.
SurfSense glows with colors bright,
Inviting users to delight.
Sidebar shifts, the layout waits—
Then green and blue illuminate!
Hooray for code that animates!

Note

⚡️ Unit Test Generation is now available in beta!

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

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

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.
    • Explain this complex logic.
    • 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 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.

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.

@recurseml
Copy link

recurseml bot commented Jul 26, 2025

✨ No issues found! Your code is sparkling clean! ✨

Need help? Join our Discord for support!
https://discord.gg/qEjHQk64Z9

@MODSetter MODSetter merged commit 0bd46c1 into main Jul 26, 2025
7 of 10 checks passed
Copy link

@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 (3)
surfsense_web/components/chat/AnimatedEmptyState.tsx (3)

32-43: Consider accessibility for reduced motion preferences.

The animation logic is well-implemented, but consider respecting user preferences for reduced motion.

+ import { useReducedMotion } from "framer-motion";

export function AnimatedEmptyState() {
  const ref = useRef(null);
  const isInView = useInView(ref);
  const { state } = useSidebar();
+ const shouldReduceMotion = useReducedMotion();
  const [shouldShowHighlight, setShouldShowHighlight] = useState(false);
  const [layoutStable, setLayoutStable] = useState(true);

  // Re-enable highlights after layout stabilizes and component is in view
  useEffect(() => {
    if (layoutStable && isInView) {
      const showTimer = setTimeout(() => {
-       setShouldShowHighlight(true);
+       setShouldShowHighlight(!shouldReduceMotion);
      }, 100);

      return () => clearTimeout(showTimer);
    } else {
      setShouldShowHighlight(false);
    }
- }, [layoutStable, isInView]);
+ }, [layoutStable, isInView, shouldReduceMotion]);

58-67: Consider reducing animation iterations for better UX.

The animation repeats 3 times over 2 seconds, which might be excessive and potentially distracting for users.

<RoughNotation
  type="highlight"
  animationDuration={2000}
- iterations={3}
+ iterations={1}
  color="#3b82f680"
  multiline
>

70-79: Apply consistent animation parameters.

For consistency with the heading animation, consider reducing iterations here as well.

<RoughNotation
  type="underline"
  animationDuration={2000}
- iterations={3}
+ iterations={1}
  color="#10b981"
>
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 237e11f and 1e05c5e.

⛔ Files ignored due to path filters (1)
  • surfsense_web/pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (5)
  • surfsense_web/components/chat/AnimatedEmptyState.tsx (1 hunks)
  • surfsense_web/components/chat/ChatFurtherQuestions.tsx (1 hunks)
  • surfsense_web/components/chat/ChatMessages.tsx (1 hunks)
  • surfsense_web/hooks/useChat.ts (1 hunks)
  • surfsense_web/package.json (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (3)
surfsense_web/components/chat/AnimatedEmptyState.tsx (1)
surfsense_web/components/ui/sidebar.tsx (1)
  • useSidebar (722-722)
surfsense_web/components/chat/ChatMessages.tsx (5)
surfsense_web/components/chat/AnimatedEmptyState.tsx (1)
  • AnimatedEmptyState (11-84)
surfsense_web/components/chat/ChatTerminal.tsx (1)
  • TerminalDisplay (6-115)
surfsense_web/components/chat/ChatSources.tsx (1)
  • ChatSourcesDisplay (104-224)
surfsense_web/components/chat/ChatCitation.tsx (1)
  • CitationDisplay (11-62)
surfsense_web/components/chat/ChatFurtherQuestions.tsx (1)
  • ChatFurtherQuestions (12-45)
surfsense_web/hooks/useChat.ts (1)
surfsense_web/hooks/use-documents.ts (1)
  • Document (5-13)
🔇 Additional comments (6)
surfsense_web/package.json (1)

64-64: Approve react-rough-notation dependency

Verified that react-rough-notation@^1.0.5 is the latest stable release on npm (version 1.0.5) and no known security vulnerabilities are reported.

surfsense_web/components/chat/ChatFurtherQuestions.tsx (1)

25-44: LGTM! Clean UI improvements.

The styling updates improve the visual presentation of the suggested questions accordion. The changes maintain existing functionality while enhancing the user interface with better spacing, colors, and typography.

surfsense_web/hooks/useChat.ts (1)

19-21: Verify Default Search Mode Change

The default searchMode in useChat.ts has been switched from "DOCUMENTS" to "CHUNKS", which means users will now see “Chunks” selected by default instead of “Documents.” This impacts:

  • surfsense_web/hooks/useChat.ts (initial state of searchMode)
  • surfsense_web/components/chat/ChatInputGroup.tsx
    • line 262: variant={searchMode === "DOCUMENTS" ? "default" : "ghost"}
    • line 271: variant={searchMode === "CHUNKS" ? "default" : "ghost"}

Please confirm that changing the default search mode aligns with the PR’s goals. If intentional, update the PR description or docs to note this behavioral change; if not, consider reverting or adjusting it.

surfsense_web/components/chat/ChatMessages.tsx (2)

14-14: Good integration of the new animated empty state.

Clean import of the AnimatedEmptyState component.


21-23: Excellent replacement of static empty state with animated version.

The integration of AnimatedEmptyState within LlamaIndexChatMessages.Empty is well-implemented and maintains the existing chat framework structure while enhancing the user experience.

surfsense_web/components/chat/AnimatedEmptyState.tsx (1)

11-16: Good component structure with proper state management.

The component correctly uses refs and state to manage animation timing and visibility. The state variables are well-named and serve clear purposes.

Comment on lines +18 to +30
// Track sidebar state changes and manage highlight visibility
useEffect(() => {
// Set layout as unstable when sidebar state changes
setLayoutStable(false);
setShouldShowHighlight(false);

// Wait for layout to stabilize after sidebar transition
const stabilizeTimer = setTimeout(() => {
setLayoutStable(true);
}, 300); // Wait for sidebar transition (200ms) + buffer

return () => clearTimeout(stabilizeTimer);
}, [state]);
Copy link

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 sidebar transition timing assumption.

The component assumes a 200ms sidebar transition duration (with 300ms total delay). This hardcoded timing could become problematic if the sidebar transition duration changes.


🏁 Script executed:

#!/bin/bash
# Search for sidebar transition duration configurations
echo "Searching for sidebar transition/animation durations:"
rg -A 2 -B 2 "transition.*duration|animation.*duration|200ms|300ms" --type css --type tsx --type ts

echo -e "\nLooking for sidebar component configuration:"
fd sidebar.tsx -x cat {} \; | head -50

Length of output: 1790


🏁 Script executed:

#!/bin/bash
# Locate and inspect the desktop Sidebar component
SIDEBAR_FILE=$(fd --type f --hidden -g "sidebar.tsx" | head -n1)
echo "→ Sidebar component path: $SIDEBAR_FILE"
grep -R --color=always "transition" -n "$SIDEBAR_FILE"
grep -R --color=always "duration-" -n "$SIDEBAR_FILE"

# Locate and inspect the UI Sheet component (mobile sidebar)
SHEET_FILE=$(fd --type f --hidden -g "sheet.tsx" | head -n1)
echo -e "\n→ Sheet component path: $SHEET_FILE"
grep -R --color=always "transition" -n "$SHEET_FILE"
grep -R --color=always "duration" -n "$SHEET_FILE"

Length of output: 4821


Sidebar transition timing may not cover mobile animations

The 300 ms timeout in AnimatedEmptyState.tsx matches the desktop sidebar’s 200 ms Tailwind transition (duration-200), but on mobile the Sheet uses a 500 ms open animation (data-[state=open]:duration-500). As a result, the highlight reset may fire too early on mobile.

Files to review:

  • surfsense_web/components/ui/sidebar.tsx – uses transition-[width] duration-200
  • surfsense_web/components/ui/sheet.tsx – uses data-[state=open]:duration-500 / data-[state=closed]:duration-300

Recommendations:

  • Centralize or export the sidebar/sheet durations instead of hard-coding 300 ms
  • Branch on isMobile to apply a longer timeout (≥ 500 ms + buffer)
  • Better yet, use transitionend/animationend events (or a hook) to detect when the animation completes
🤖 Prompt for AI Agents
In surfsense_web/components/chat/AnimatedEmptyState.tsx around lines 18 to 30,
the fixed 300 ms timeout for sidebar transition does not accommodate the longer
500 ms mobile sheet animation, causing premature highlight reset on mobile. To
fix this, replace the hard-coded timeout with a dynamic duration by either
importing centralized duration constants from sidebar.tsx and sheet.tsx or
detecting if the device is mobile and applying a longer timeout accordingly. For
a more robust solution, implement event listeners for transitionend or
animationend events to trigger layout stabilization precisely when the animation
finishes.

aptdnfapt pushed a commit to aptdnfapt/SurfSense that referenced this pull request Oct 19, 2025
feat: add react-rough-notation dependency and update chat components …
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