feat: add drag-and-drop sorting for API provider cards#844
Conversation
🦋 Changeset detectedLatest commit: 857f241 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
PR Review: Add drag-and-drop sorting for API provider cards【Taste Score】🟡 Acceptable Overall the implementation works, but there are a few issues to address. 【Key Issues】1. Type mismatch in
|
There was a problem hiding this comment.
2 issues found across 5 files
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name=".changeset/lemon-icons-burn.md">
<violation number="1" location=".changeset/lemon-icons-burn.md:2">
P2: This changeset declares a `patch` version bump for a new feature. Per semantic versioning, new features should use `minor` (backwards-compatible additions), while `patch` is for bug fixes. Consider changing to `minor` since drag-and-drop sorting is new functionality.</violation>
</file>
<file name="src/entrypoints/options/pages/api-providers/providers-config.tsx">
<violation number="1" location="src/entrypoints/options/pages/api-providers/providers-config.tsx:140">
P0: Critical data loss: `setList={setProvidersConfig}` will replace the entire providers config with only API providers after reorder, deleting any non-API providers. Create a handler that preserves non-API providers when updating the list.</violation>
</file>
Reply to cubic to teach it or ask questions. Tag @cubic-dev-ai to re-run a review.
src/entrypoints/options/pages/api-providers/providers-config.tsx
Outdated
Show resolved
Hide resolved
|
dnd 包是不是好点 https://dndkit.com/ |
可以,不过昨天我试了下,dndkit的代码量会偏多点 |
或许我们可以比较一下?把两个东西的优劣点拿出来看看 |
PR Review: feat: add drag-and-drop sorting for API provider cardsOverall Assessment🟢 Good taste - This is a well-implemented feature using the established @dnd-kit library. The component is reusable and follows the project's React patterns. 👍 What's Done Well
|
src/entrypoints/options/pages/api-providers/providers-config.tsx
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
2 issues found across 4 files (changes from recent commits).
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="src/components/sortable-list.tsx">
<violation number="1" location="src/components/sortable-list.tsx:69">
P2: The PR description claims "Auto-scroll when dragging to list edges" but `autoScroll` is explicitly set to `false`, which disables this functionality. Either update the code to enable auto-scroll or correct the PR description to reflect the actual behavior.</violation>
<violation number="2" location="src/components/sortable-list.tsx:92">
P2: Missing `transition` property from `useSortable` hook. Without including `transition` in the style object, drag animations will be jerky/instant instead of smooth. Add `transition` to the destructured values and include it in the style.</violation>
</file>
Reply to cubic to teach it or ask questions. Tag @cubic-dev-ai to re-run a review.
PR Review: feat: add drag-and-drop sorting for API provider cards【Taste Score】🟢 Good taste Overall this is a well-implemented feature that follows the project's patterns. The component abstraction is clean and reusable. ✅ What's Done Well
|
Code Review for PR #844: feat: add drag-and-drop sorting for API provider cards【Taste Score】🟢 Good taste Overall, this is a well-implemented feature with good UX considerations. ✅ Strengths
🔍 Issues & Suggestions1. Potential bug:
|
PR Review: feat: add drag-and-drop sorting for API provider cards【Taste Score】🟢 Good taste - Clean implementation using a well-established library (@dnd-kit) with appropriate abstraction. 【Key Insights】Data structure: ✅ Correctly preserves non-API providers during reorder by filtering and re-concatenating. Complexity: ✅ Reasonable - the Risk points: Low - changes are well-contained to the options page. Code Quality & Best PracticesStrengths:
Suggestions:
Potential Bugs
Performance Considerations✅ Good choices:
Security Concerns✅ No security concerns identified. The changes are purely UI-focused and don't involve:
Test Coverage
Recommend adding at minimum:
SummaryOverall: Good implementation. The PR introduces a clean, reusable drag-and-drop component using industry-standard libraries. The code follows project patterns and is appropriately scoped. Recommended actions before merge:
🟢 Verdict: Approve with minor suggestions |
PR Review: feat: add drag-and-drop sorting for API provider cardsOverall, this is a well-structured implementation that adds a useful feature. The code follows the project's conventions and uses appropriate libraries. Here's my detailed feedback: ✅ What's Good
🟡 Suggestions1.
|
| Aspect | Rating |
|---|---|
| Code Quality | 🟢 Good |
| Best Practices | 🟢 Good |
| Performance | 🟡 Minor optimization possible |
| Security | 🟢 No concerns |
| Test Coverage | 🔴 Missing tests |
| Accessibility | 🟡 Could be improved |
Recommendation: Approve with minor suggestions. The implementation is solid and the feature works well. Consider adding tests in a follow-up.
PR Review: feat: add drag-and-drop sorting for API provider cards【Taste Score】🟢 Good taste This is a well-implemented feature that adds user-requested functionality. The architecture follows existing patterns, and the concurrent write handling is thoughtfully designed. 【Key Insights】Data structure: Correctly separates API providers from non-API providers during reorder, preserving stable ordering for the full config. Complexity: The write queue + version counter pattern in Risk points: Module-level mutable state ( 🟢 Strengths
🟡 Minor Suggestions
🔒 SecurityNo concerns. The changes don't introduce any user input handling, external data fetching, or privilege escalation paths. ⚡ PerformanceGood. The optimistic update pattern ensures UI remains responsive. The write queue prevents storage thrashing. SummaryThis is a clean, well-architected PR that adds a frequently-requested feature. The concurrent write handling is sophisticated and correctly implemented. The minor suggestions above are polish items rather than blockers. Recommendation: ✅ Approve after addressing the unused effect (item 1) and verifying the gradient class names (item 2). |
Type of Changes
Description
Add drag-and-drop functionality to reorder API provider cards in the settings page.
How Has This Been Tested?
Checklist
Summary by cubic
Added drag-and-drop sorting to API provider cards in Settings using dnd-kit. Users can reorder providers with clear drag visuals, stable scroll, and the selected card stays selected.
New Features
Bug Fixes
Written for commit 857f241. Summary will update on new commits.