-
Notifications
You must be signed in to change notification settings - Fork 898
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
Conversation
WalkthroughThe changes update the Changes
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
Assessment against linked issues
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Note 🎁 Summarized by CodeRabbit FreeYour 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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this 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 accumulatorsUsing 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 ofO(n^2)
.
Consider methods such as .splice or .push instead.(lint/performance/noAccumulatingSpread)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 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 responsivenessThe 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 changesChanging 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 controlThe 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
src/components/run/RunsTable.tsx
Outdated
[ | ||
paginationStates, | ||
runId, | ||
runningRecordingName, | ||
currentInterpretationLog, | ||
abortRunHandler, | ||
handleDelete, | ||
accordionSortConfigs, | ||
] | ||
); |
There was a problem hiding this comment.
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.
[ | |
paginationStates, | |
runId, | |
runningRecordingName, | |
currentInterpretationLog, | |
abortRunHandler, | |
handleDelete, | |
accordionSortConfigs, | |
] | |
); | |
[ | |
paginationStates, | |
runId, | |
runningRecordingName, | |
currentInterpretationLog, | |
abortRunHandler, | |
handleDelete, | |
accordionSortConfigs, | |
getPaginationState, | |
] | |
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great catch by bot
There was a problem hiding this comment.
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
src/components/run/RunsTable.tsx
Outdated
(column.flexGrow / totalFlexGrow) * 100 | ||
}%`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
(column.flexGrow / totalFlexGrow) * 100 | |
}%`, | |
(column.flexGrow / columns.reduce((sum, col) => sum + (col.flexGrow || 0), 0)) * 100 | |
}%`, |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this 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 👍
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
Style