Skip to content

Conversation

@avi-007
Copy link
Collaborator

@avi-007 avi-007 commented Jun 24, 2025

Q/A checklist

  • I have tested my UI changes on mobile and they look acceptable

  • I have tested changes to the workflows in both the API and the UI

  • I have done a code review of my changes and looked at each line of the diff + the references of each function I have changed

  • My changes have not increased the import time of the server

How to check import time?

time python -c 'import server'

You can visualize this using tuna:

python3 -X importtime -c 'import server' 2> out.log && tuna out.log

To measure import time for a specific library:

$ time python -c 'import pandas'

________________________________________________________
Executed in    1.15 secs    fish           external
   usr time    2.22 secs   86.00 micros    2.22 secs
   sys time    0.72 secs  613.00 micros    0.72 secs

To reduce import times, import libraries that take a long time inside the functions that use them instead of at the top of the file:

def my_function():
    import pandas as pd
    ...

Legal Boilerplate

Look, I get it. The entity doing business as “Gooey.AI” and/or “Dara.network” was incorporated in the State of Delaware in 2020 as Dara Network Inc. and is gonna need some rights from me in order to utilize my contributions in this PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Dara Network Inc can use, modify, copy, and redistribute my contributions, under its choice of terms.

@avi-007 avi-007 requested a review from devxpy June 24, 2025 23:57
@coderabbitai
Copy link

coderabbitai bot commented Jun 24, 2025

Walkthrough

The changes introduce several UI and logic adjustments across three modules. In widgets/explore.py, commented-out code related to fetching and passing total_runs is removed, and a type annotation is added to the _render_non_featured function. In widgets/saved_workflow.py, a new boolean parameter is_member is added to render_saved_workflow_preview and render_footer_breadcrumbs to control display logic, with updates to CSS classes, layout, and conditions for showing run counts and author information. In widgets/workflow_search.py, the render_search_results function is updated by nesting _render_run inside it and adding conditional logic based on workspace filters and membership status, passing these flags to the updated preview rendering function.

Possibly related PRs

  • Explore page improvements #709: Modifies the run count display threshold in widgets/explore.py, affecting related functionality to the current changes in run count display logic.

Suggested reviewers

  • devxpy

📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 0f3263d and 92f03b6.

📒 Files selected for processing (1)
  • widgets/workflow_search.py (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • widgets/workflow_search.py
⏰ 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: test (3.10.12, 1.8.3)
✨ Finishing Touches
  • 📝 Generate Docstrings

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

🧹 Nitpick comments (3)
widgets/saved_workflow.py (1)

198-207: Consider improving the version notes structure.

The version notes section has been moved and wrapped in a styled div. The implementation looks good, but there's a minor improvement opportunity.

-            with gui.div(
-                className="text-truncate text-muted",
-                style=dict(maxWidth="200px"),
-            ):
+            with gui.div(
+                className="text-truncate text-muted",
+                style={"maxWidth": "200px"},
+            ):

This follows the static analysis suggestion to use dictionary literal instead of dict() call.

widgets/workflow_search.py (1)

185-224: Consider refactoring the complex conditional logic for better readability.

The _render_run function has grown quite complex with multiple conditional branches. While the logic appears correct, it would benefit from some refactoring to improve maintainability.

Consider extracting helper functions:

def _render_run(pr: PublishedRun):
    workflow = Workflow(pr.workflow)
    
    # Extract UI display flags
    display_flags = _determine_display_flags(pr, user, search_filters)
    
    render_saved_workflow_preview(
        workflow.page_cls,
        pr,
        workflow_pill=f"{workflow.get_or_create_metadata().emoji} {workflow.short_title}",
        hide_visibility_pill=True,
        **display_flags
    )

def _determine_display_flags(pr: PublishedRun, user: AppUser | None, search_filters: SearchFilters) -> dict:
    """Determine which UI elements should be shown/hidden based on user context."""
    show_workspace_author = not bool(search_filters and search_filters.workspace)
    is_member = bool(getattr(pr, "is_member", False))
    hide_last_editor = bool(pr.workspace_id and not is_member)
    hide_updated_at = hide_last_editor
    
    show_all_run_counts = _should_show_all_run_counts(
        is_member, user, search_filters
    )
    
    return {
        "show_workspace_author": show_workspace_author,
        "hide_last_editor": hide_last_editor,
        "hide_updated_at": hide_updated_at,
        "show_all_run_counts": show_all_run_counts,
    }

def _should_show_all_run_counts(is_member: bool, user: AppUser | None, search_filters: SearchFilters) -> bool:
    """Check if all run counts should be shown (for workspace owners)."""
    if not (is_member and search_filters and search_filters.workspace and user and not user.is_anonymous):
        return False
    
    user_workspace_ids = {w.id for w in user.cached_workspaces}
    user_workspace_handles = {w.handle.name for w in user.cached_workspaces if w.handle}
    
    try:
        workspace_id = int(search_filters.workspace)
        return workspace_id in user_workspace_ids
    except ValueError:
        return search_filters.workspace in user_workspace_handles
widgets/explore.py (1)

139-155: Consider extracting the workspace ownership logic to a shared utility.

The workspace ownership check logic is duplicated between this file and widgets/workflow_search.py. Consider extracting this to a shared utility function to maintain DRY principles.

Create a utility function in a shared module:

# In a shared utility module, e.g., utils/workspace.py
def is_user_workspace_owner(user: AppUser | None, workspace_filter: str | None) -> bool:
    """Check if the current user owns the filtered workspace."""
    if not (user and workspace_filter and not user.is_anonymous):
        return False
    
    user_workspace_ids = {w.id for w in user.cached_workspaces}
    user_workspace_handles = {w.handle.name for w in user.cached_workspaces if w.handle}
    
    try:
        workspace_id = int(workspace_filter)
        return workspace_id in user_workspace_ids
    except ValueError:
        return workspace_filter in user_workspace_handles

Then use it in both files:

show_all_counts = is_user_workspace_owner(user, search_filters.workspace)
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 261bbfc and 7a2c92d.

📒 Files selected for processing (4)
  • widgets/author.py (8 hunks)
  • widgets/explore.py (3 hunks)
  • widgets/saved_workflow.py (4 hunks)
  • widgets/workflow_search.py (1 hunks)
🧰 Additional context used
🪛 Pylint (3.3.7)
widgets/saved_workflow.py

[refactor] 204-204: Consider using '{"maxWidth": '200px'}' instead of a call to 'dict'.

(R1735)

🔇 Additional comments (13)
widgets/saved_workflow.py (5)

32-34: LGTM: Clean parameter additions for UI control.

The new parameters provide clear control over UI element visibility with sensible defaults.


87-89: LGTM: Consistent parameter passing.

The parameters are correctly passed through to the footer rendering function.


173-175: LGTM: Function signature updated correctly.

The new parameters are properly added with appropriate defaults.


210-219: LGTM: Proper conditional rendering for updated timestamp.

The logic correctly checks for the hide_updated_at flag and applies consistent styling.


221-221: LGTM: Enhanced run count display logic.

The condition properly respects both the existing threshold (50+ runs) and the new show_all_run_counts flag for more granular control.

widgets/workflow_search.py (1)

204-212: LGTM: Robust workspace ownership check.

The implementation correctly handles both numeric workspace IDs and string handles, with appropriate error handling for the type conversion.

widgets/explore.py (3)

18-18: LGTM: Minor text improvements.

Good catch fixing the typographic apostrophes to standard quotes for consistency.

Also applies to: 21-21


47-52: LGTM: Proper parameter threading through grid layout.

The lambda functions correctly pass the user and search_filters parameters to the rendering functions.

Also applies to: 54-59


100-104: LGTM: Clean function signature updates.

The parameters are consistently added across all rendering functions with appropriate defaults.

Also applies to: 112-116, 127-131

widgets/author.py (4)

26-26: LGTM: Appropriate special case for breadcrumbs.

Correctly preserves underlines for breadcrumb navigation by explicitly setting remove_underline=False.


45-49: LGTM: Clean conditional link styling.

The link creation logic properly applies the text decoration class based on the parameter, with appropriate fallback to dummy element.


60-60: LGTM: Consistent parameter threading.

The remove_underline parameter is properly added to all functions with sensible defaults and correctly passed through the call hierarchy.

Also applies to: 79-79, 89-89, 105-105, 116-116


126-131: LGTM: Improved link creation logic.

The explicit if-else structure is more readable than the previous conditional expression and properly handles the class name application.

@devxpy devxpy self-assigned this Jun 25, 2025
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: 2

🧹 Nitpick comments (2)
utils/workspace.py (2)

4-18: Consider performance optimization for frequently called function.

The function recreates sets from user.cached_workspaces on every call. Since this utility is used across multiple UI components (as mentioned in the AI summary), consider caching these sets to improve performance.

def is_user_workspace_owner(user: AppUser | None, workspace_filter: str | None) -> bool:
    """Check if the current user owns the filtered workspace."""
    if not (user and workspace_filter and not user.is_anonymous):
        return False

-   user_workspace_ids = {w.id for w in user.cached_workspaces}
-   user_workspace_handles = {w.handle.name for w in user.cached_workspaces if w.handle}
+   # Cache workspace sets to avoid recreating on every call
+   if not hasattr(user, '_workspace_ids_cache'):
+       user._workspace_ids_cache = {w.id for w in user.cached_workspaces}
+       user._workspace_handles_cache = {w.handle.name for w in user.cached_workspaces if w.handle}
+   
+   user_workspace_ids = user._workspace_ids_cache
+   user_workspace_handles = user._workspace_handles_cache

    try:
        # Check if workspace filter is numeric (workspace ID)
        workspace_id = int(workspace_filter)
        return workspace_id in user_workspace_ids
    except ValueError:
        # Workspace filter is a handle name
        return workspace_filter in user_workspace_handles

4-5: Enhance function documentation.

The docstring could be more detailed about the supported workspace filter formats and the function's behavior.

-   """Check if the current user owns the filtered workspace."""
+   """
+   Check if the current user owns the filtered workspace.
+   
+   Args:
+       user: The user to check ownership for. Returns False if None or anonymous.
+       workspace_filter: Either a workspace ID (numeric string) or handle name (string).
+                        Returns False if None or empty.
+   
+   Returns:
+       True if the user owns the workspace identified by the filter, False otherwise.
+   """
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 7a2c92d and c187ffc.

📒 Files selected for processing (5)
  • utils/__init__.py (1 hunks)
  • utils/workspace.py (1 hunks)
  • widgets/explore.py (3 hunks)
  • widgets/saved_workflow.py (5 hunks)
  • widgets/workflow_search.py (2 hunks)
✅ Files skipped from review due to trivial changes (1)
  • utils/init.py
🚧 Files skipped from review as they are similar to previous changes (3)
  • widgets/saved_workflow.py
  • widgets/workflow_search.py
  • widgets/explore.py
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: test (3.10.12, 1.8.3)

Comment on lines 12 to 18
try:
# Check if workspace filter is numeric (workspace ID)
workspace_id = int(workspace_filter)
return workspace_id in user_workspace_ids
except ValueError:
# Workspace filter is a handle name
return workspace_filter in user_workspace_handles
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Enhance error handling and add input validation.

The current implementation only handles ValueError for int conversion. Consider adding more comprehensive error handling and input validation.

    try:
        # Check if workspace filter is numeric (workspace ID)
        workspace_id = int(workspace_filter)
+       if workspace_id <= 0:
+           return False
        return workspace_id in user_workspace_ids
-   except ValueError:
+   except (ValueError, TypeError):
        # Workspace filter is a handle name
+       if not isinstance(workspace_filter, str) or not workspace_filter.strip():
+           return False
        return workspace_filter in user_workspace_handles
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
try:
# Check if workspace filter is numeric (workspace ID)
workspace_id = int(workspace_filter)
return workspace_id in user_workspace_ids
except ValueError:
# Workspace filter is a handle name
return workspace_filter in user_workspace_handles
try:
# Check if workspace filter is numeric (workspace ID)
workspace_id = int(workspace_filter)
if workspace_id <= 0:
return False
return workspace_id in user_workspace_ids
except (ValueError, TypeError):
# Workspace filter is a handle name
if not isinstance(workspace_filter, str) or not workspace_filter.strip():
return False
return workspace_filter in user_workspace_handles
🤖 Prompt for AI Agents
In utils/workspace.py around lines 12 to 18, improve the error handling by
adding input validation before attempting to convert workspace_filter to int,
and catch additional potential exceptions beyond ValueError. Validate that
workspace_filter is a string or appropriate type, and handle cases where it
might be None or an unexpected type, returning False or raising a clear error as
needed. Expand the except block to handle other exceptions that could arise
during conversion or membership checks to make the function more robust.

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)
utils/workspace.py (1)

39-87: Consider refactoring to reduce return statements, but current implementation is acceptable.

The static analysis tool flags 9 return statements exceeding the recommended limit of 6. While this could be refactored to use fewer returns, the current defensive programming approach with early returns actually improves readability and follows good practices for input validation and error handling.

If you prefer to address the static analysis warning, consider consolidating some return statements:

-    if not (user and workspace_filter and not user.is_anonymous):
-        return False
-
-    # Additional input validation
-    if not isinstance(workspace_filter, str):
-        return False
-
-    workspace_filter = workspace_filter.strip()
-    if not workspace_filter:
-        return False
+    if not (user and workspace_filter and not user.is_anonymous and 
+            isinstance(workspace_filter, str) and workspace_filter.strip()):
+        return False
+    
+    workspace_filter = workspace_filter.strip()

However, the current implementation is perfectly acceptable and prioritizes clarity over strict adherence to the return statement limit.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between c187ffc and 639c9ac.

📒 Files selected for processing (1)
  • utils/workspace.py (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
utils/workspace.py (1)
app_users/models.py (2)
  • AppUser (90-262)
  • cached_workspaces (242-249)
🪛 Pylint (3.3.7)
utils/workspace.py

[refactor] 4-4: Too many return statements (9/6)

(R0911)

⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: test (3.10.12, 1.8.3)
  • GitHub Check: test (3.10.12, 1.8.3)
🔇 Additional comments (2)
utils/workspace.py (2)

54-58: Past review comments have been properly addressed.

The previous concerns about safety checks for workspace handle attribute access have been resolved with the comprehensive validation on line 57: if w.handle and hasattr(w.handle, "name") and w.handle.name.


4-88: Excellent implementation with comprehensive error handling and performance optimization.

This utility function is well-designed with:

  • Thorough input validation and documentation
  • Smart caching mechanism for performance optimization
  • Comprehensive exception handling covering edge cases
  • Support for both workspace ID and handle name formats

The function effectively centralizes workspace ownership logic and will enable consistent UI behavior across the widgets that use it.

@avi-007 avi-007 force-pushed the explore-page-fix branch 2 times, most recently from 1381890 to e0edc9a Compare June 26, 2025 01:37
@devxpy
Copy link
Member

devxpy commented Jul 1, 2025

image image image image image

mobile layout has weird spacing

@devxpy devxpy assigned avi-007 and unassigned devxpy Jul 1, 2025
… display in explore and saved workflow widgets
@avi-007 avi-007 assigned devxpy and avi-007 and unassigned avi-007 and devxpy Jul 7, 2025
feat: default column mapping if the field name matches the column name
fix: show variables in bulk run columns
@avi-007 avi-007 merged commit c5d8138 into master Jul 14, 2025
8 checks passed
@coderabbitai coderabbitai bot mentioned this pull request Jul 23, 2025
4 tasks
@avi-007 avi-007 deleted the explore-page-fix branch August 6, 2025 14:17
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.

3 participants