Skip to content

Conversation

@matiasdaloia
Copy link
Collaborator

@matiasdaloia matiasdaloia commented Feb 28, 2025

What

  • Added a new welcome screen when the selected scan root is the $HOME path
  • Usually this will only happen when opening the app from the applications folder
image

Summary by CodeRabbit

  • New Features

    • Introduced a welcome screen that guides users in selecting a folder for initiating scans with options to choose a new or a recently used directory.
    • Enhanced tracking of recent scan locations, making it easier to revisit previous scans.
    • Rolled out a set of modular UI cards for a consistent and clearer presentation of information.
    • Added functionality to retrieve recent scan roots for improved user experience.
    • Implemented a utility for validating default paths based on the operating system.
  • Style

    • Applied global styling updates that ensure uniform borders, outlines, and improved background and text colors for a cleaner look.
  • Bug Fixes

    • Improved error handling for directory selection and notifications for better user feedback.
  • Chores

    • Updated the build environment in GitHub Actions to use a newer version of Ubuntu for enhanced compatibility.
    • Specified a fixed version of Python for integration tests to ensure consistency.

@matiasdaloia matiasdaloia self-assigned this Feb 28, 2025
@matiasdaloia matiasdaloia requested a review from eeisegn February 28, 2025 09:35
@matiasdaloia matiasdaloia added the enhancement New feature or request label Feb 28, 2025
@coderabbitai
Copy link

coderabbitai bot commented Feb 28, 2025

Walkthrough

The changes add functionality for managing recent scan roots across the system. A new method is introduced in the backend (App.GetRecentScanRoots) with corresponding updates to the configuration in Go. In the frontend, a new React component (WelcomeScreen) and a set of card UI components provide interfaces for selecting directories and accessing recent folders. Additionally, the hook for results has been updated to explicitly return only necessary properties, the store now tracks recent scan roots, and a new CSS base layer is defined. Minor modifications to event handling in the root route enhance control flow.

Changes

File(s) Change Summary
app.go Added GetRecentScanRoots method to the App struct that retrieves recent scan roots from the configuration.
internal/config/config.go Added recentScanRoots field to Config and ConfigDTO; introduced methods GetRecentScanRoots, AddRecentScanRoot, and SetRecentScanRoots to manage recent scan roots; updated JSON marshaling and scan root setting logic.
frontend/src/components/WelcomeScreen.tsx Introduced a new React component for directory scanning; added functionalities for selecting a new folder and a recent folder with error handling and modal management.
frontend/src/components/ui/card.tsx Introduced new card UI components (Card, CardHeader, CardTitle, CardDescription, CardContent, CardFooter) with ref forwarding and customizable styling.
frontend/src/hooks/useResults.tsx
frontend/src/stores/useConfigStore.ts
Modified the useResults hook to explicitly return data and isLoading; added recentScanRoots state in the configuration store and updated its initialization.
frontend/src/routes/root.tsx Added a new state variable scanRoot and updated event listener management; introduced conditional rendering of WelcomeScreen based on the scanRoot state.
frontend/src/style.css Added a new CSS base layer with universal (*) styling for borders and outlines, and body styling for background and foreground colors using @apply directives.
frontend/wailsjs/go/main/App.d.ts
frontend/wailsjs/go/main/App.js
Added function declarations and implementations for GetRecentScanRoots in the Wailsjs bridge to align with backend changes.

Sequence Diagram(s)

sequenceDiagram
    participant U as User
    participant WS as WelcomeScreen
    participant CS as ConfigStore
    participant AP as App (Go)
    participant CFG as Config
    U->>WS: Click "Select Recent Folder"
    WS->>CS: Request recent scan roots
    CS->>AP: Call GetRecentScanRoots()
    AP->>CFG: Retrieve recent scan roots
    CFG-->>AP: Return list of scan roots
    AP-->>CS: Return scan roots list
    CS-->>WS: Update UI with scan roots
Loading

Suggested reviewers

  • eeisegn

Poem

In the code garden where ideas sprout,
I, a happy rabbit, happily shout.
With recent scan roots, our paths align,
New components and methods, looking so fine.
Hopping through changes with a joyful leap,
I celebrate our improvements in bounds and in heap! 🐇


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ 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 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.

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: 3

🧹 Nitpick comments (3)
frontend/src/hooks/useResults.tsx (1)

29-30: Improved API clarity

Good change to make the hook's interface more explicit by returning specific properties instead of spreading all queryResult properties. This improves API stability and prevents unintentional exposure of internal details.

Consider adding JSDoc comments to document the return value of this hook, especially since you've made the interface more explicit:

/**
 * Hook to fetch and manage scan results
 * @returns {Object} Object containing results data, loading state, and reset function
 * @returns {ResultsData} data - The fetched results data
 * @returns {boolean} isLoading - Whether the results are currently loading
 * @returns {() => void} reset - Function to reset the query and refetch results
 */
frontend/src/style.css (1)

97-104: Good addition of global base styles.

The new @layer base block properly establishes consistent styling for the entire application with border, outline, background, and text color defaults. These styles will help maintain visual consistency for the new WelcomeScreen component.

Consider consolidating the body styles from lines 5-12 with the new body styles in this layer for better maintainability in the future.

internal/config/config.go (1)

189-194: Use the slices.Index function for more concise code.

The Go slices package provides a cleaner way to find an element's index.

-  for i, p := range c.recentScanRoots {
-    if p == path {
-      c.recentScanRoots = slices.Delete(c.recentScanRoots, i, i+1)
-      break
-    }
-  }
+  if idx := slices.Index(c.recentScanRoots, path); idx != -1 {
+    c.recentScanRoots = slices.Delete(c.recentScanRoots, idx, idx+1)
+  }
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between b68cfa1 and 1995815.

📒 Files selected for processing (10)
  • app.go (1 hunks)
  • frontend/src/components/WelcomeScreen.tsx (1 hunks)
  • frontend/src/components/ui/card.tsx (1 hunks)
  • frontend/src/hooks/useResults.tsx (1 hunks)
  • frontend/src/routes/root.tsx (2 hunks)
  • frontend/src/stores/useConfigStore.ts (4 hunks)
  • frontend/src/style.css (1 hunks)
  • frontend/wailsjs/go/main/App.d.ts (1 hunks)
  • frontend/wailsjs/go/main/App.js (1 hunks)
  • internal/config/config.go (8 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build
🔇 Additional comments (16)
frontend/wailsjs/go/main/App.js (1)

9-11: Addition looks good!

Properly implemented function to call the Go backend's GetRecentScanRoots method to retrieve recent scan root directories.

frontend/wailsjs/go/main/App.d.ts (1)

8-9: Type declaration matches implementation

The TypeScript type declaration correctly specifies that the function returns a Promise resolving to an array of strings, matching its implementation in App.js.

app.go (1)

197-199: Implementation follows existing patterns

This method follows the same pattern as other getter methods in the file, properly delegating to the configuration object and handling error returns consistently.

frontend/src/stores/useConfigStore.ts (4)

27-35: The import looks good.

The addition of GetRecentScanRoots import is correctly included with the other App imports.


37-42: Good addition of recentScanRoots property.

The recentScanRoots property is correctly added to the ResultsState interface as a string array.


58-60: Proper initialization of the new state property.

The recentScanRoots property is correctly initialized as an empty array, consistent with the rest of the state properties.


74-80: Properly updated config retrieval.

The getInitialConfig method is correctly updated to fetch and set the recent scan roots along with the other configuration properties.

frontend/src/routes/root.tsx (3)

24-34: Imports are properly updated.

The imports have been correctly updated to include the new WelcomeScreen component and useConfigStore, while removing the unused useEffect import.


39-40: Good extraction of scanRoot from store.

The scanRoot is correctly extracted from the config store using the selector pattern.


57-59: Good conditional rendering of WelcomeScreen.

The conditional rendering is correctly implemented to show the WelcomeScreen when scanRoot is '/'.

frontend/src/components/ui/card.tsx (3)

5-19: Well-implemented Card component.

The Card component follows best practices:

  • Uses forwardRef for proper ref forwarding
  • Applies the cn utility for class name merging
  • Sets a displayName for better debugging
  • Properly typed with TypeScript

20-75: Card subcomponents follow consistent patterns.

All card subcomponents (CardHeader, CardTitle, CardDescription, CardContent, CardFooter) follow the same well-structured pattern with proper typing, className handling, and displayName settings. This ensures consistency and maintainability.


76-76: Exports are properly defined.

All card components are correctly exported as named exports.

frontend/src/components/WelcomeScreen.tsx (1)

38-132: Component structure looks good!

The WelcomeScreen component is well-structured with clear separation of concerns, proper error handling, and a clean UI layout using Card components. The implementation provides a good user experience by offering both new scan options and access to recent folders.

internal/config/config.go (2)

239-241: Good error handling on AddRecentScanRoot.

The code properly logs errors when adding a recent scan root fails, which is important for debugging. This ensures that even if the configuration update fails, it won't block the main workflow.


35-36: Import addition is appropriate.

The addition of the slices package is correct for the new functionality that manages the recent scan roots array.

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

🧹 Nitpick comments (1)
frontend/src/lib/utils.ts (1)

52-61: Well-implemented platform-specific path detection!

The implementation of isDefaultPath is clear and handles the default paths correctly for different platforms. It's a good approach to use a switch statement for platform-specific checks.

For Windows, consider if there are other drive letters you might want to check for (D:, E:, etc.) or if you need to handle UNC paths in the future, but this implementation is sufficient for the current use case of detecting default paths.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 1995815 and 7b14836.

📒 Files selected for processing (3)
  • frontend/src/components/WelcomeScreen.tsx (1 hunks)
  • frontend/src/lib/utils.ts (1 hunks)
  • frontend/src/routes/root.tsx (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • frontend/src/components/WelcomeScreen.tsx
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build
🔇 Additional comments (3)
frontend/src/routes/root.tsx (3)

53-65: Excellent fix for event handlers with proper cleanup!

The event handlers are now correctly implemented with cleanup functions, which addresses the issue mentioned in the previous review. This prevents memory leaks and ensures event handlers won't be duplicated when the component re-renders.


67-69: Good implementation of the welcome screen conditional rendering

This conditional rendering logic implements the PR objective of showing a welcome screen when the scan root is set to a default path. The integration with the isDefaultPath utility function and environment platform detection provides a clean, cross-platform solution.


41-42: Appropriate use of hooks for environment and configuration

These state hooks provide the necessary data for the welcome screen feature implementation, keeping the component clean and following React best practices.

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

🧹 Nitpick comments (1)
.github/workflows/test.yml (1)

93-104: Establish and Verify Python Virtual Environment for Scanoss

The new step creates and activates a Python virtual environment, upgrades pip, installs the scanoss package, and verifies its installation through multiple checks. This adds reliability to the integration test environment.

  • Consider adding error handling (for example, using set -e at the start of the script) to ensure that any command failure aborts the step immediately.
  • Additionally, wrapping $VIRTUAL_ENV in quotes (e.g., "$VIRTUAL_ENV/bin") when appending to GITHUB_PATH can safeguard against potential issues with spaces in directory paths.
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between f1681cf and 28a85ca.

📒 Files selected for processing (1)
  • .github/workflows/test.yml (2 hunks)
🔇 Additional comments (3)
.github/workflows/test.yml (3)

19-19: Update Build Job Environment

The update from ubuntu-20.04 to ubuntu-22.04 is a beneficial modernization that takes advantage of newer OS packages and security improvements. Please verify that all dependencies and build steps remain compatible with this newer image.


91-91: Specify Python Version for Integration Tests

Changing the Python version from a floating "3.x" to a fixed "3.8" ensures consistency across environments. Confirm that all tests and scripts are compatible with Python 3.8.


109-111: Activate Virtual Environment in Integration Test Run

The integration tests now correctly activate the Python virtual environment before executing go test with the integration tag. Ensure that this activation is necessary for your tests and that all required environment variables are available during the test execution.

@matiasdaloia matiasdaloia force-pushed the feature/mdaloia/ES-162-SCANOSS-Code-Compare-Add-UI-for-selecting-the-scan-root-if-the-path-is- branch from 28a85ca to 7b14836 Compare March 5, 2025 10:09
@matiasdaloia matiasdaloia merged commit a7a83eb into main Mar 10, 2025
8 of 10 checks passed
@matiasdaloia matiasdaloia deleted the feature/mdaloia/ES-162-SCANOSS-Code-Compare-Add-UI-for-selecting-the-scan-root-if-the-path-is- branch March 10, 2025 09:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants