refactor: reuse SheetNavigationButtons component and useSheetNavigation hook#3804
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughSummary by CodeRabbit
WalkthroughTwo MCP workspace sheet components: the log details sheet is refactored to use a shared navigation hook and buttons, and the client sheet defers navigation when unsaved changes exist and shows a confirmation dialog to confirm discard before navigating. ChangesSheet Navigation UI Updates
🎯 3 (Moderate) | ⏱️ ~20 minutes
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
SheetNavigationButtons component and useSheetNavigation hookSheetNavigationButtons component and useSheetNavigation hook
Confidence Score: 5/5Safe to merge — this is a clean refactor with no functional regressions and one incidental improvement to navigation guard logic. Both changed files correctly delegate to the shared components without altering any business logic. The enabled change in mcpClientSheet.tsx is an improvement over the original, and the AlertDialog restructuring is architecturally sound. No files require special attention. Important Files Changed
Reviews (5): Last reviewed commit: "refactor: use sheetNavigation hook in mc..." | Re-trigger Greptile |
11e3a09 to
18253b0
Compare
f7660f7 to
0fc25a8
Compare
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@ui/app/workspace/mcp-logs/views/mcpLogDetailsSheet.tsx`:
- Around line 127-134: The SheetNavigationButtons usage in
mcpLogDetailsSheet.tsx lacks E2E selectors; update the SheetNavigationButtons
call to pass stable test id props (e.g., prevButtonTestId and nextButtonTestId
or a sheetTestId prefix) and then modify the SheetNavigationButtons component to
accept those props and apply them to the actual button elements (e.g., <Button
data-testid={prevButtonTestId}> and <Button data-testid={nextButtonTestId}>).
Ensure the prop names match between the call site and the component (referencing
SheetNavigationButtons, prevKeys, nextKeys, and onNavigate) so E2E tests can
target the prev/next controls reliably.
In `@ui/app/workspace/mcp-registry/views/mcpClientSheet.tsx`:
- Around line 1311-1327: Add stable E2E selectors to the new unsaved-navigation
dialog by adding data-testid attributes to the interactive controls: add
data-testid="unsaved-nav-cancel" to the AlertDialogCancel and
data-testid="unsaved-nav-discard" to the AlertDialogAction within the
AlertDialog that uses pendingNavDirection, setPendingNavDirection and
onNavigate; keep existing onClick handlers intact so Cancel still calls
setPendingNavDirection(null) and Discard still captures dir then calls
onNavigate?.(dir).
- Around line 215-226: The dirty-check used by handleNavigate (isDirty) omits
in-progress edits in allowedExtraHeadersRaw, so typing there and navigating
skips the confirmation; update the isDirty calculation to also consider
differences between allowedExtraHeadersRaw and the form's synced value (e.g.,
compare allowedExtraHeadersRaw !== form.getValues('allowed_extra_headers') or
!== allowedExtraHeaders if that variable exists), so handleNavigate will call
setPendingNavDirection when the raw textarea differs from the saved RHF value
before calling onNavigate.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 6ec09de0-107a-4026-a9a4-e8b17bebb96e
📒 Files selected for processing (2)
ui/app/workspace/mcp-logs/views/mcpLogDetailsSheet.tsxui/app/workspace/mcp-registry/views/mcpClientSheet.tsx
18253b0 to
be859cc
Compare
0fc25a8 to
236bdfa
Compare
a957ea9 to
c6a89b9
Compare
fa7e8a2 to
c620789
Compare
Merge activity
|
The base branch was changed.
c620789 to
05a4995
Compare
…ation` hook (#3804) ## Summary Extracts the navigation button UI and keyboard shortcut logic from `MCPLogDetailSheet` into shared `SheetNavigationButtons` component and `useSheetNavigation` hook, reducing duplication and making sheet navigation reusable across other sheet views. ## Changes - Replaced the inline prev/next `Button` elements in `MCPLogDetailSheet` with the shared `SheetNavigationButtons` component - Replaced direct `useHotkeys` calls with the `useSheetNavigation` hook, which returns the key bindings passed into `SheetNavigationButtons` for tooltip display - Removed `ChevronDown`, `ChevronUp` icon imports and `useHotkeys` import from this file since they are now handled internally by the shared components ## Type of change - [ ] Bug fix - [ ] Feature - [x] Refactor - [ ] Documentation - [ ] Chore/CI ## Affected areas - [ ] Core (Go) - [ ] Transports (HTTP) - [ ] Providers/Integrations - [ ] Plugins - [x] UI (React) - [ ] Docs ## How to test ```sh cd ui pnpm i || npm i pnpm test || npm test pnpm build || npm run build ``` 1. Open the MCP Logs view and click on a log entry to open the detail sheet. 2. Verify the previous/next navigation buttons appear and are enabled/disabled correctly based on position in the list. 3. Press the up/down arrow keys and confirm navigation between log entries works as expected. 4. Confirm keyboard shortcut hints are visible in the navigation button tooltips. ## Screenshots/Recordings N/A ## Breaking changes - [x] No ## Related issues N/A ## Security considerations None. ## Checklist - [ ] I read `docs/contributing/README.md` and followed the guidelines - [ ] I added/updated tests where appropriate - [ ] I updated documentation where needed - [ ] I verified builds succeed (Go and UI) - [ ] I verified the CI pipeline passes locally if applicable

Summary
Extracts the navigation button UI and keyboard shortcut logic from
MCPLogDetailSheetinto sharedSheetNavigationButtonscomponent anduseSheetNavigationhook, reducing duplication and making sheet navigation reusable across other sheet views.Changes
Buttonelements inMCPLogDetailSheetwith the sharedSheetNavigationButtonscomponentuseHotkeyscalls with theuseSheetNavigationhook, which returns the key bindings passed intoSheetNavigationButtonsfor tooltip displayChevronDown,ChevronUpicon imports anduseHotkeysimport from this file since they are now handled internally by the shared componentsType of change
Affected areas
How to test
Screenshots/Recordings
N/A
Breaking changes
Related issues
N/A
Security considerations
None.
Checklist
docs/contributing/README.mdand followed the guidelines