Skip to content
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

Status #158

Merged
merged 14 commits into from
Jun 16, 2024
Merged

Status #158

merged 14 commits into from
Jun 16, 2024

Conversation

Mubelotix
Copy link
Owner

@Mubelotix Mubelotix commented Jun 1, 2024

Summary by CodeRabbit

  • New Features

    • Added a new endpoint to retrieve the indexing status of documents in real-time.
    • Introduced a new UI component that displays the indexing status with progress bars and messages.
  • Styling Enhancements

    • Updated various CSS files to improve layout and background colors, especially for better alignment and responsiveness.
    • Introduced a new CSS file for the indexing status component.
  • UI Components

    • Implemented a new IndexingStatusComp component to dynamically fetch and display indexing status.
  • Bug Fixes

    • Removed outdated scripts and adjusted HTML structures for improved performance and compatibility.
    • Tweaked height and background color properties for better visual consistency.

@Mubelotix Mubelotix marked this pull request as ready for review June 16, 2024 18:26
@Mubelotix
Copy link
Owner Author

@coderabbitai review

Copy link

coderabbitai bot commented Jun 16, 2024

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.

Copy link

coderabbitai bot commented Jun 16, 2024

Important

Review skipped

Auto incremental reviews are disabled on this repository.

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

The update introduces a new feature for tracking and displaying the status of document indexing in a web UI. It includes back-end changes to manage and query indexing status, front-end components to display this information, and adjustments to existing code to integrate this feature seamlessly. Additionally, there are various minor stylistic and functional changes across different project files.

Changes

Files/Directories Change Summaries
daemon/src/api/indexing_status.rs Added indexing_status function to retrieve and return indexing status in JSON.
daemon/src/api/mod.rs Added indexing_status module and endpoint to the API routes.
daemon/src/dns_pins.rs Added TODO comment and adjusted DNS pins management logic.
daemon/src/index/index.rs Introduced methods for managing and retrieving document indexing status.
daemon/src/index/inner_im.rs Added sweep function with visibility restriction.
daemon/src/index/mod.rs Added a new status module and exported its entities.
daemon/src/index/status.rs Introduced IndexingStatus struct to track indexing metrics.
webui/index.html Added CSS link for indexing_status and removed unnecessary script.
webui/src/api.rs Modified ApiError enum and made get function public.
webui/src/components/indexing_status/api.rs Added function for fetching indexing status asynchronously.
webui/src/components/indexing_status/indexing_status.css Added CSS styling for indexing status component.
webui/src/components/indexing_status/indexing_status.html Introduced UI component for displaying indexing status.
webui/src/components/indexing_status/indexing_status.rs Introduced IndexingStatusComp component and related logic.
webui/src/components/indexing_status/ty.rs Imported types for indexing_status component without altering exports.
webui/src/main.rs Added attribute to suppress lint warning.
webui/src/pages/results/results.css Adjusted height and background color properties.
webui/src/pages/search/search.css Modified height and padding properties.
webui/src/pages/search/search.html Introduced IndexingStatusComp component in search page.
webui/src/pages/search/search.rs Added rpc_addr variable initialization.
webui/src/pages/settings/settings.css Updated styling properties for settings page and button.
webui/src/prelude.rs Exported indexing_status entities and removed wildcard import.
webui/src/util.rs Replaced get and apply calls with Reflect equivalents.
webui/testing.html Removed script setting CSS variable based on viewport height.

Poem

By the code's dance, we see it grow,
With indexing status now in tow.
From back-end depths to front-end show,
The progress bar will brightly glow.
As queries fly and data flows,
Our system gleams with fresh new glows.
Kudos to devs, their craft in flow,
In bits and bytes, new features sow! 🌟🐇


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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration 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: 11

Outside diff range comments (1)
daemon/src/index/index.rs (1)

Line range hint 53-77: The refresh logic in DocumentIndex is complex and could benefit from further modularization. Consider breaking down the function into smaller, more manageable parts.

- let pinned = match list_pinned(&self.config.ipfs_rpc).await {
+ self.handle_pinned_elements().await;
- let new_links = match ls(ipfs_rpc, cid.clone()).await {
+ self.handle_new_links(ipfs_rpc, cid).await;
Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

Commits

Files that changed from the base of the PR and between f80e8e3 and 9ad647e.

Files selected for processing (23)
  • daemon/src/api/indexing_status.rs (1 hunks)
  • daemon/src/api/mod.rs (4 hunks)
  • daemon/src/dns_pins.rs (1 hunks)
  • daemon/src/index/index.rs (6 hunks)
  • daemon/src/index/inner_im.rs (1 hunks)
  • daemon/src/index/mod.rs (1 hunks)
  • daemon/src/index/status.rs (1 hunks)
  • webui/index.html (2 hunks)
  • webui/src/api.rs (5 hunks)
  • webui/src/components/indexing_status/api.rs (1 hunks)
  • webui/src/components/indexing_status/indexing_status.css (1 hunks)
  • webui/src/components/indexing_status/indexing_status.html (1 hunks)
  • webui/src/components/indexing_status/indexing_status.rs (1 hunks)
  • webui/src/components/indexing_status/ty.rs (1 hunks)
  • webui/src/main.rs (1 hunks)
  • webui/src/pages/results/results.css (1 hunks)
  • webui/src/pages/search/search.css (2 hunks)
  • webui/src/pages/search/search.html (1 hunks)
  • webui/src/pages/search/search.rs (1 hunks)
  • webui/src/pages/settings/settings.css (1 hunks)
  • webui/src/prelude.rs (1 hunks)
  • webui/src/util.rs (2 hunks)
  • webui/testing.html (1 hunks)
Additional comments not posted (23)
webui/src/components/indexing_status/api.rs (1)

3-5: The function get_indexing_status correctly forms the URL and fetches the indexing status. Ensure that the get function from the prelude handles errors appropriately.

Verification successful

The get function is implemented in webui/src/api.rs and uses api_custom_method to handle the HTTP GET request. The function is designed to handle errors by returning a Result<T, ApiError> type, indicating that errors are properly managed.

  • webui/src/api.rs: pub async fn get<T: DeserializeOwned>(url: impl AsRef<str>) -> Result<T, ApiError>
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the error handling in the `get` function.

# Test: Search for the `get` function implementation. Expect: Proper error handling.
rg --type rust $'pub async fn get'

Length of output: 1879



Script:

#!/bin/bash
# Description: Retrieve the implementation of the `get` function from `webui/src/api.rs`.

# Extract the `get` function implementation.
rg --type rust --pcre2 --context 10 'pub async fn get<T: DeserializeOwned>(url: impl AsRef<str>) -> Result<T, ApiError>' webui/src/api.rs

Length of output: 139



Script:

#!/bin/bash
# Description: Retrieve the implementation of the `get` function from `webui/src/api.rs`.

# Use ast-grep to find the `get` function implementation.
ast-grep --lang rust --pattern $'pub async fn get<T: DeserializeOwned>(url: impl AsRef<str>) -> Result<T, ApiError>' webui/src/api.rs

Length of output: 134



Script:

#!/bin/bash
# Description: Retrieve the implementation of the `get` function from the entire repository.

# Use rg to find the `get` function implementation.
rg --type rust --context 20 'pub async fn get<T: DeserializeOwned>(url: impl AsRef<str>) -> Result<T, ApiError>'

Length of output: 114



Script:

#!/bin/bash
# Description: Retrieve the implementation of any `get` function from the entire repository.

# Use rg to find any `get` function implementation.
rg --type rust --context 20 'pub async fn get'

Length of output: 39010

webui/src/components/indexing_status/ty.rs (1)

1-1: The file path at the top is unusual. If it's meant to indicate the source of the struct, consider removing it or replacing it with a more standard comment format.

-../../../../daemon/src/index/status.rs
+// Source: daemon/src/index/status.rs

Likely invalid or redundant comment.

daemon/src/index/status.rs (1)

3-11: The IndexingStatus struct is well-defined and appropriately uses the Serialize and Deserialize traits for data transfer. Good use of Rust's type system and traits.

webui/src/components/indexing_status/indexing_status.css (1)

1-28: CSS styles are well-structured and responsive.

webui/src/main.rs (1)

22-23: Module addition follows existing patterns and is correctly implemented.

Verification successful

The file path for indexing_status.rs in the module declaration is correct and matches the expected location in the webui directory.

  • webui/src/components/indexing_status/indexing_status.rs
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the file path for `indexing_status.rs` is correct.

# Test: Search for the file. Expect: File should exist.
fd "indexing_status.rs"

Length of output: 113

webui/src/prelude.rs (1)

3-3: Export addition is appropriate and aligns with project structure.

webui/src/components/indexing_status/indexing_status.html (1)

1-22: The HTML structure for the indexing status component is well-organized and semantically correct.

webui/src/pages/search/search.rs (1)

33-33: Ensure that the admarus_addr method securely handles the retrieval of the address, considering it's used directly in a UI component.

Verification successful

The admarus_addr method in ConnectionStatus returns a static string based on the health status of the admarus_daemon and admarus_gateway. It directly maps specific statuses to URLs and does not involve any dynamic or sensitive data handling.

  • Location of admarus_addr implementation:
    • webui/src/components/connection_status/connection_status.rs
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Search for the implementation of `admarus_addr` to ensure it handles data securely.
ast-grep --lang rust --pattern $'impl ConnectionStatus {
  $$$
  admarus_addr($_) {
    $$$
  }
  $$$  
}'

Length of output: 602



Script:

#!/bin/bash
# Description: Search for the implementation of `admarus_addr` to ensure it handles data securely.
ast-grep --lang rust --pattern 'impl ConnectionStatus {
    fn admarus_addr(&self) -> $_ {
        $$$
    }
}'

Length of output: 113



Script:

#!/bin/bash
# Description: Search for the implementation of `admarus_addr` to ensure it handles data securely.
rg 'fn admarus_addr' --context 5

Length of output: 1121

webui/src/pages/search/search.html (1)

22-22: The integration of the IndexingStatusComp component is correctly implemented and enhances the page's functionality by providing real-time indexing status.

webui/src/pages/search/search.css (1)

72-72: Adding padding to the buttons improves the visual spacing and usability of the interface.

daemon/src/index/mod.rs (2)

11-11: The addition of the status module is aligned with the new functionality for indexing status management. Ensure all dependencies and interactions are correctly integrated.


14-14: Exporting the status module at a higher level indicates its significance in the project. This change should be well-documented to aid in future maintenance and development.

webui/src/pages/results/results.css (1)

5-5: The updated background color (#f5f5f5) should be checked against the UI design guidelines to ensure consistency across the application.

webui/testing.html (1)

48-48: The structure of the main content seems intact. Ensure that the testing environment accurately reflects the production environment to avoid discrepancies in behavior.

webui/index.html (1)

15-15: The addition of the CSS link for the indexing status component is correctly implemented.

daemon/src/api/mod.rs (4)

7-7: Integration of indexing_status module is correctly done.


14-15: Modules are properly imported and used in the API.


137-137: Proper chaining of API routes with CORS settings applied. Ensure that all necessary HTTP methods are allowed for each endpoint.

Verification successful

The recent search results provide more context about the server configuration and CORS settings. The daemon/src/api/mod.rs file includes the CORS middleware configuration and allows the HTTP methods GET, POST, and DELETE.

  • The server runs with the configuration specified in config.api_addr.
  • The CORS settings are established using warp::cors() and allow methods GET, POST, and DELETE.

These findings confirm that the necessary HTTP methods are allowed and CORS settings are applied.

  • daemon/src/api/mod.rs:
    • warp::serve(routes).run(config.api_addr.parse::<SocketAddr>().expect("Invalid api_addr")).await;
    • let mut cors = warp::cors()
    • .allow_methods(vec!["GET", "POST", "DELETE"])
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that all necessary HTTP methods are allowed for each endpoint.
# Test: Check the CORS settings for each route.
# Expect: GET, POST, DELETE methods should be allowed where applicable.

# Checking CORS settings
curl -X OPTIONS http://localhost:8000/ -i
curl -X OPTIONS http://localhost:8000/indexing-status -i
curl -X OPTIONS http://localhost:8000/search -i

Length of output: 1373



Script:

#!/bin/bash
# Step 1: Find the port configuration in the codebase.
echo "Searching for port configuration..."
rg 'port\s*=\s*' --glob '*.rs'

# Step 2: Find CORS settings and allowed HTTP methods in the codebase.
echo "Searching for CORS settings and allowed HTTP methods..."
rg 'CORS' --glob '*.rs'
rg 'allowed_methods' --glob '*.rs'
rg 'route' --glob '*.rs'

Length of output: 3782



Script:

#!/bin/bash
# Step 1: Find the server configuration to identify the correct port.
echo "Searching for server configuration..."
rg 'run\(' --glob '*.rs'
rg 'serve\(' --glob '*.rs'

# Step 2: Search for the CORS middleware or configuration.
echo "Searching for CORS middleware or configuration..."
rg 'cors' --glob '*.rs'
rg 'warp::cors' --glob '*.rs'

# Step 3: Identify the HTTP methods allowed for each endpoint.
echo "Searching for HTTP methods allowed for each endpoint..."
rg 'method(' --glob '*.rs'
rg 'GET' --glob '*.rs'
rg 'POST' --glob '*.rs'
rg 'DELETE' --glob '*.rs'

Length of output: 2453


82-87: The indexing_status endpoint is added correctly to the API routes. Ensure that the index2 object's state is properly managed across requests, given its use in a closure.

webui/src/api.rs (2)

79-89: The implementation of the Display trait for ApiError is correct. Ensure that all error messages are user-friendly and provide enough information to diagnose issues.


99-99: The get function is implemented correctly for asynchronous fetching of data. Ensure proper error handling is in place for network requests.

Verification successful

The api_custom_method function in webui/src/api.rs uses various error handling mechanisms to manage network errors and response parsing issues. The function returns appropriate error messages for different types of network failures such as Fetch, NotText, BadRequest, Server, and Unknown.

  • The function uses map_err to convert errors into ApiError variants.
  • Specific error types are handled and returned based on the HTTP response status code.

This confirms that proper error handling is in place.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify proper error handling for network requests in the `get` function.
# Test: Simulate network failures and check error responses.
# Expect: Appropriate error messages for different types of network failures.

# Simulating network failure
curl -s http://localhost:8000/nonexistent -o /dev/null

Length of output: 56



Script:

#!/bin/bash
# Locate and extract the implementation of the `get` function in `webui/src/api.rs`
ast-grep --lang rust --pattern 'pub async fn get<T: DeserializeOwned>(url: impl AsRef<str>) -> Result<T, ApiError> {
  $$$
}' > get_function_impl.txt

# Print the extracted function implementation for review
cat get_function_impl.txt

Length of output: 354



Script:

#!/bin/bash
# Locate and extract the implementation of the `api_custom_method` function in the codebase
ast-grep --lang rust --pattern 'async fn api_custom_method($_, $_, $_) -> $_ {
  $$$
}' > api_custom_method_impl.txt

# Print the extracted function implementation for review
cat api_custom_method_impl.txt

Length of output: 122



Script:

#!/bin/bash
# Search for the definition of `api_custom_method` in the codebase using ripgrep
rg 'fn api_custom_method' > api_custom_method_search.txt

# Print the search results for review
cat api_custom_method_search.txt

Length of output: 224



Script:

#!/bin/bash
# Extract the full implementation of the `api_custom_method` function in `webui/src/api.rs`
ast-grep --lang rust --pattern 'async fn api_custom_method<I: Serialize, O: DeserializeOwned>(endpoint: impl AsRef<str>, method: &'static str, body: I) -> Result<O, ApiError> {
  $$$
}' > api_custom_method_impl_full.txt

# Print the extracted function implementation for review
cat api_custom_method_impl_full.txt

Length of output: 313



Script:

#!/bin/bash
# Correct the pattern to extract the full implementation of the `api_custom_method` function in `webui/src/api.rs`
ast-grep --lang rust --pattern $'async fn api_custom_method<I: Serialize, O: DeserializeOwned>(endpoint: impl AsRef<str>, method: &\'static str, body: I) -> Result<O, ApiError> {
  $$$
}' > api_custom_method_impl_full.txt

# Print the extracted function implementation for review
cat api_custom_method_impl_full.txt

Length of output: 2631

daemon/src/index/index.rs (2)

6-6: The addition of status to DocumentIndex is correctly implemented. Ensure that the IndexingStatus has proper default values set for all fields to avoid potential null issues.

Also applies to: 15-15


104-123: Ensure that the set_status_updating_filter method is called with correct values to prevent incorrect filter updates.

Verification successful

The rg search revealed the implementation of the set_status_updating_filter method in daemon/src/index/index.rs:

daemon/src/index/index.rs:async fn set_status_updating_filter(&self, updating_filter: bool) {

Given this, we can now focus on verifying how this method is called and ensuring it is invoked with the correct values.

To proceed, let's:

  1. Verify the calls to set_status_updating_filter in the codebase.
  2. Ensure the values passed to these calls are appropriate.

We'll use rg to find all instances where set_status_updating_filter is called.


The rg search results show that set_status_updating_filter is called twice in the codebase, both in daemon/src/index/index.rs:

  1. self.set_status_updating_filter(true).await;
  2. self.set_status_updating_filter(false).await;

These calls align with the provided snippet, where the method is called before and after the update_filter method. This indicates that the method is indeed being called with the values true and false to indicate the start and end of the filter update process, respectively.

Thus, the review comment's concern about ensuring the set_status_updating_filter method is called with correct values appears to be addressed correctly in the code.

  • self.set_status_updating_filter(true).await; is called before self.update_filter().await; to indicate the filter is updating.
  • self.set_status_updating_filter(false).await; is called after self.update_filter().await; to indicate the filter update is complete.
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the `set_status_updating_filter` method is called with correct values.
# Test: Check the filter status before and after updates to ensure correctness.
# Expect: Filter status should match the expected values after updates.

# Checking filter status
echo "Filter status before update: $(curl http://localhost:8000/filter-status)"
# Simulate updates
curl -X POST http://localhost:8000/update-filter -d '{"updating": true}'
echo "Filter status after update: $(curl http://localhost:8000/filter-status)"

Length of output: 1519



Script:

#!/bin/bash
# Search for the `set_status_updating_filter` method implementation in the codebase
ast-grep --lang rust --pattern 'fn set_status_updating_filter($_) { $$$ }'

Length of output: 76



Script:

#!/bin/bash
# Broaden the search pattern to find the `set_status_updating_filter` method implementation in the codebase
ast-grep --lang rust --pattern 'fn set_status_updating_filter($$$) { $$$ }'

Length of output: 77



Script:

#!/bin/bash
# Search for all method definitions in the codebase to find `set_status_updating_filter`
rg 'fn ' --glob '*.rs'

Length of output: 52062



Script:

#!/bin/bash
# Search for all calls to `set_status_updating_filter` in the codebase
rg 'set_status_updating_filter' --glob '*.rs'

Length of output: 310

webui/src/pages/results/results.css Show resolved Hide resolved
daemon/src/api/indexing_status.rs Show resolved Hide resolved
webui/src/pages/search/search.css Show resolved Hide resolved
daemon/src/api/mod.rs Outdated Show resolved Hide resolved
daemon/src/dns_pins.rs Show resolved Hide resolved
webui/src/util.rs Show resolved Hide resolved
webui/src/pages/settings/settings.css Show resolved Hide resolved
webui/src/api.rs Show resolved Hide resolved
daemon/src/index/index.rs Show resolved Hide resolved
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

Outside diff range comments (1)
daemon/src/main.rs (1)

Line range hint 17-17: Consider enhancing the visibility of the warning regarding unsupported API addresses, possibly by halting execution or providing more detailed user feedback.

Also applies to: 22-22

Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

Commits

Files that changed from the base of the PR and between 9ad647e and ce923ec.

Files selected for processing (2)
  • daemon/src/api/mod.rs (3 hunks)
  • daemon/src/main.rs (1 hunks)
Additional comments not posted (2)
daemon/src/main.rs (1)

2-2: The explanation for disabling clippy::map_clone is clear and justified given the use of Arc clones.

daemon/src/api/mod.rs (1)

7-7: Correct inclusion of the indexing_status module aligns with the PR's objectives for enhanced indexing status management.

daemon/src/api/mod.rs Show resolved Hide resolved
@Mubelotix Mubelotix merged commit 906d841 into master Jun 16, 2024
1 check 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