Skip to content

refactor: enhance RunsTable component layout #497

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

Merged
merged 3 commits into from
Mar 27, 2025

Conversation

theanuragg
Copy link
Contributor

@theanuragg theanuragg commented Mar 23, 2025

This PR fixes #481

I’ve made changes to the codebase, but my Docker setup is taking so much, so I haven’t been able to capture a screenshot of the changes yet will added asap

Summary by CodeRabbit

  • Refactor

    • Enhanced the table component structure and state management to improve readability, maintainability, and responsiveness. These updates deliver a smoother, more intuitive experience across various screen sizes.
  • Style

    • Applied consistent formatting updates across the user interface, contributing to a cleaner, modern, and cohesive appearance that enhances overall visual appeal. This refined design offers an improved viewing experience on all devices.

Copy link

coderabbitai bot commented Mar 23, 2025

Walkthrough

The changes update the RunsTable component to improve code readability and consistency. Import statements now uniformly use double quotes. Column definitions have been extended with maxWidth and flexGrow properties, alongside adjusted minWidth values. Type definitions for column IDs and sort directions were updated. State management, including search functionality and notification messages, has been reformatted with standardized arrow functions. Additionally, media queries have been introduced to enhance the table layout for responsiveness.

Changes

File(s) Change Summary
src/components/.../RunsTable.tsx • Updated import statements to use double quotes
• Enhanced column definitions with maxWidth, flexGrow, and adjusted minWidth
• Revised type definitions for columns and sort direction
• Refactored state management and search functionality
• Reformatted notification messages and rendering logic
• Adjusted table layout with media queries for responsiveness

Sequence Diagram(s)

sequenceDiagram
    actor User as User
    participant RT as RunsTable Component
    participant SM as State Management

    User->>RT: Enter search term
    RT->>SM: Call handleSearchChange
    SM-->>RT: Update state and re-render table
    User->>RT: Click column header to sort
    RT->>SM: Update sort parameters
    SM-->>RT: Re-render table with sorted rows
Loading

Assessment against linked issues

Objective Addressed Explanation
Enhancement: Output data table sizing (#481)

Possibly related PRs

Suggested labels

Type: Enhancement, Scope: UI/UX

Suggested reviewers

  • amhsirak

Poem

Oh, what a hop this code did take,
With double quotes in every break,
The table now can flex and grow,
Through state and sort it steals the show,
A rabbit’s joy in every line,
Celebrating changes, purely divine!
🐰✨


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between a7ffe5a and adb6f57.

📒 Files selected for processing (1)
  • src/components/run/RunsTable.tsx (11 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/components/run/RunsTable.tsx

Note

🎁 Summarized by CodeRabbit Free

Your organization has reached its limit of developer seats under the Pro Plan. For new users, CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please add seats to your subscription by visiting https://app.coderabbit.ai/login.If you believe this is a mistake and have available seats, please assign one to the pull request author through the subscription management page using the link above.

🪧 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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @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: 2

🧹 Nitpick comments (1)
src/components/run/RunsTable.tsx (1)

271-278: Improve performance by avoiding spread on accumulators

Using spread syntax on accumulators in a reduce function has O(n²) time complexity, which may cause performance issues with large datasets.

Consider using a more efficient approach:

- const reset = Object.keys(prev).reduce(
-   (acc, robotId) => ({
-     ...acc,
-     [robotId]: { ...prev[robotId], page: 0 },
-   }),
-   {}
- );
+ const reset = {};
+ Object.keys(prev).forEach(robotId => {
+   reset[robotId] = { ...prev[robotId], page: 0 };
+ });
🧰 Tools
🪛 Biome (1.9.4)

[error] 273-273: Avoid the use of spread (...) syntax on accumulators.

Spread syntax should be avoided on accumulators (like those in .reduce) because it causes a time complexity of O(n^2).
Consider methods such as .splice or .push instead.

(lint/performance/noAccumulatingSpread)

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 7843cda and d5ac10d.

📒 Files selected for processing (1)
  • src/components/run/RunsTable.tsx (11 hunks)
🧰 Additional context used
🪛 Biome (1.9.4)
src/components/run/RunsTable.tsx

[error] 273-273: Avoid the use of spread (...) syntax on accumulators.

Spread syntax should be avoided on accumulators (like those in .reduce) because it causes a time complexity of O(n^2).
Consider methods such as .splice or .push instead.

(lint/performance/noAccumulatingSpread)

🔇 Additional comments (4)
src/components/run/RunsTable.tsx (4)

485-494: Good improvement to table responsiveness

The addition of media queries for responsive layout is a good enhancement that will improve the user experience on mobile devices.


64-64: Type definition is consistent with code style changes

Changing string literals from single quotes to double quotes in type definitions maintains consistency with the updated code style throughout the file.


31-62: Good improvement to column layout control

The addition of maxWidth and flexGrow properties to column definitions improves layout control and responsiveness of the table.


338-339:

❓ Verification inconclusive

Validate date format conversion logic

The date parsing logic appears to be swapping month and day positions in the date string, which might cause issues with date interpretation in different locales.

Please verify that this regex replacement works correctly for all your date formats:


🏁 Script executed:

#!/bin/bash
# Test the date parsing logic with different formats
echo "Testing date conversion logic:"
echo "Input: 12/25/2023, Expected output: 25/12/2023"
echo "12/25/2023" | sed -E 's/(\d+)\/(\d+)\//\2\/\1\//'

Length of output: 240


Clarify and Verify Date Conversion Testing
The JavaScript regex in
return new Date(dateStr.replace(/(\d+)\/(\d+)\//, "$2/$1/"));
appears to swap the month and day as intended. However, the verification using a sed command isn’t applicable here—sed’s regex engine does not recognize \d, so your test returns the original string unchanged. Please verify this logic within a JavaScript context (e.g., unit tests or NodeJS REPL) to ensure it correctly handles all your intended date formats.

  • File: src/components/run/RunsTable.tsx
  • Lines: 338-339

Comment on lines 419 to 428
[
paginationStates,
runId,
runningRecordingName,
currentInterpretationLog,
abortRunHandler,
handleDelete,
accordionSortConfigs,
]
);
Copy link

@coderabbitai coderabbitai bot Mar 23, 2025

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Ensure dependency array includes getPaginationState

The renderTableRows function uses getPaginationState but doesn't include it in the dependency array for useCallback, which may cause stale closure issues.

Add getPaginationState to the dependency array:

  [
    paginationStates,
    runId,
    runningRecordingName,
    currentInterpretationLog,
    abortRunHandler,
    handleDelete,
    accordionSortConfigs,
+   getPaginationState,
  ]
📝 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
[
paginationStates,
runId,
runningRecordingName,
currentInterpretationLog,
abortRunHandler,
handleDelete,
accordionSortConfigs,
]
);
[
paginationStates,
runId,
runningRecordingName,
currentInterpretationLog,
abortRunHandler,
handleDelete,
accordionSortConfigs,
getPaginationState,
]
);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

great catch by bot

Copy link

Choose a reason for hiding this comment

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

Your organization has reached its limit of developer seats under the Pro Plan. In order to use the Chat feature, you need to buy additional seats

Comment on lines 526 to 527
(column.flexGrow / totalFlexGrow) * 100
}%`,
Copy link

@coderabbitai coderabbitai bot Mar 23, 2025

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix reference to undefined variable totalFlexGrow

The code references a variable totalFlexGrow that isn't defined anywhere in the file. This will cause a runtime error when rendering the table cells.

You need to either define this variable or replace it with the actual calculation of the total flex grow. A simple solution would be:

- (column.flexGrow / totalFlexGrow) * 100
+ (column.flexGrow / columns.reduce((sum, col) => sum + (col.flexGrow || 0), 0)) * 100
📝 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
(column.flexGrow / totalFlexGrow) * 100
}%`,
(column.flexGrow / columns.reduce((sum, col) => sum + (col.flexGrow || 0), 0)) * 100
}%`,

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hey @amhsirak , my approach is Move totalFlexGrow into useMemo. what you think

Copy link

Choose a reason for hiding this comment

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

Your organization has reached its limit of developer seats under the Pro Plan. In order to use the Chat feature, you need to buy additional seats

@amhsirak amhsirak added Type: Enhancement Improvements to existing features Scope: UI/UX Issues/PRs related to UI/UX labels Mar 24, 2025
Copy link
Member

@amhsirak amhsirak left a comment

Choose a reason for hiding this comment

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

@theanuragg thank you - lgtm. Will merge to develop this week 👍

@amhsirak amhsirak merged commit 81c0484 into getmaxun:develop Mar 27, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Scope: UI/UX Issues/PRs related to UI/UX Type: Enhancement Improvements to existing features
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enhancement: Output data table sizing
2 participants