Skip to content

refactor: reuse SheetNavigationButtons component and useSheetNavigation hook#3804

Merged
akshaydeo merged 1 commit into
devfrom
05-27-refactor_use_sheetnavigation_hook_in_mcp_detail_sheet
May 27, 2026
Merged

refactor: reuse SheetNavigationButtons component and useSheetNavigation hook#3804
akshaydeo merged 1 commit into
devfrom
05-27-refactor_use_sheetnavigation_hook_in_mcp_detail_sheet

Conversation

@impoiler

Copy link
Copy Markdown
Contributor

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
  • Refactor
  • Documentation
  • Chore/CI

Affected areas

  • Core (Go)
  • Transports (HTTP)
  • Providers/Integrations
  • Plugins
  • UI (React)
  • Docs

How to test

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

  • 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

@coderabbitai

coderabbitai Bot commented May 27, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d29c25b1-e2ce-4caf-8bcb-ab69a21caef7

📥 Commits

Reviewing files that changed from the base of the PR and between 0fc25a8 and 05a4995.

📒 Files selected for processing (2)
  • ui/app/workspace/mcp-logs/views/mcpLogDetailsSheet.tsx
  • ui/app/workspace/mcp-registry/views/mcpClientSheet.tsx
🚧 Files skipped from review as they are similar to previous changes (2)
  • ui/app/workspace/mcp-logs/views/mcpLogDetailsSheet.tsx
  • ui/app/workspace/mcp-registry/views/mcpClientSheet.tsx

📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Added confirmation prompts when navigating away from MCP client configuration sheets with unsaved changes, preventing accidental data loss.
  • Improvements

    • Refined navigation handling in MCP logs and client views for better consistency and user experience.

Walkthrough

Two 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.

Changes

Sheet Navigation UI Updates

Layer / File(s) Summary
MCP Log Details Sheet Navigation Refactoring
ui/app/workspace/mcp-logs/views/mcpLogDetailsSheet.tsx
Replaces hotkey-based up/down handlers and chevron buttons with useSheetNavigation and SheetNavigationButtons; imports updated and prev/next key bindings plus onNavigate are wired into the sheet header.
MCP Client Sheet Unsaved Changes Protection
ui/app/workspace/mcp-registry/views/mcpClientSheet.tsx
Adds useCallback and derives isDirty from form and local state; navigation is memoized to store a pendingNavDirection when dirty, useSheetNavigation is disabled while pending, the component return is wrapped to render an AlertDialog alongside the sheet, and the dialog clears pending direction then invokes stored navigation.

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Possibly related PRs

    • maximhq/bifrost#3745: Refactors other sheets to use useSheetNavigation and SheetNavigationButtons (similar navigation unification).
    • maximhq/bifrost#3739: Introduced the shared useSheetNavigation/SheetNavigationButtons changes referenced by the log details update.
  • Suggested reviewers

    • akshaydeo

"I hopped through the code with a twitchy nose,
Tabs and arrows now in neat little rows.
One sheet skips keys, one guards what you've penned,
A rabbit's small cheer for a safer end. 🐇✨"

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main refactoring work: extracting shared navigation components and hooks into reusable pieces.
Description check ✅ Passed The description covers all key sections with summary, changes, type, affected areas, testing steps, and related metadata appropriately filled in.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 05-27-refactor_use_sheetnavigation_hook_in_mcp_detail_sheet

Comment @coderabbitai help to get the list of available commands and usage tips.

@greptile-apps

greptile-apps Bot commented May 27, 2026

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5

Safe 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

Filename Overview
ui/app/workspace/mcp-logs/views/mcpLogDetailsSheet.tsx Replaces inline prev/next buttons and direct useHotkeys calls with the shared SheetNavigationButtons component and useSheetNavigation hook. Keyboard shortcuts now also include vim-style k/j bindings (added by the shared hook). No functional regressions.
ui/app/workspace/mcp-registry/views/mcpClientSheet.tsx Wraps Sheet + AlertDialog in a Fragment (moving the dialog outside the sheet for cleaner portal stacking), inlines confirmNavigation/cancelNavigation helpers, wraps handleNavigate in useCallback, and changes the navigation enabled condition from !!onNavigate to !pendingNavDirection. The new condition is actually an improvement: it prevents hotkeys from firing while the unsaved-changes confirm dialog is open, fixing a subtle race where pressing a key during the dialog would silently overwrite the pending direction.

Reviews (5): Last reviewed commit: "refactor: use sheetNavigation hook in mc..." | Re-trigger Greptile

Comment thread ui/app/workspace/mcp-logs/views/mcpLogDetailsSheet.tsx
@impoiler impoiler force-pushed the 05-27-fix_fetch_only_active_tabs_data_in_dashboard branch from 11e3a09 to 18253b0 Compare May 27, 2026 12:19
@impoiler impoiler force-pushed the 05-27-refactor_use_sheetnavigation_hook_in_mcp_detail_sheet branch from f7660f7 to 0fc25a8 Compare May 27, 2026 12:19
@coderabbitai coderabbitai Bot requested review from akshaydeo and danpiths May 27, 2026 12:21

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

📥 Commits

Reviewing files that changed from the base of the PR and between 18253b0 and 0fc25a8.

📒 Files selected for processing (2)
  • ui/app/workspace/mcp-logs/views/mcpLogDetailsSheet.tsx
  • ui/app/workspace/mcp-registry/views/mcpClientSheet.tsx

Comment thread ui/app/workspace/mcp-logs/views/mcpLogDetailsSheet.tsx
Comment thread ui/app/workspace/mcp-registry/views/mcpClientSheet.tsx
Comment thread ui/app/workspace/mcp-registry/views/mcpClientSheet.tsx
@impoiler impoiler force-pushed the 05-27-fix_fetch_only_active_tabs_data_in_dashboard branch from 18253b0 to be859cc Compare May 27, 2026 12:30
@impoiler impoiler force-pushed the 05-27-refactor_use_sheetnavigation_hook_in_mcp_detail_sheet branch from 0fc25a8 to 236bdfa Compare May 27, 2026 12:30
coderabbitai[bot]
coderabbitai Bot previously approved these changes May 27, 2026
@impoiler impoiler force-pushed the 05-27-fix_fetch_only_active_tabs_data_in_dashboard branch from a957ea9 to c6a89b9 Compare May 27, 2026 13:16
@impoiler impoiler force-pushed the 05-27-refactor_use_sheetnavigation_hook_in_mcp_detail_sheet branch from fa7e8a2 to c620789 Compare May 27, 2026 13:16

akshaydeo commented May 27, 2026

Copy link
Copy Markdown
Contributor

Merge activity

  • May 27, 1:44 PM UTC: A user started a stack merge that includes this pull request via Graphite.
  • May 27, 2:01 PM UTC: Graphite rebased this pull request as part of a merge.
  • May 27, 2:02 PM UTC: @akshaydeo merged this pull request with Graphite.

@akshaydeo akshaydeo changed the base branch from 05-27-fix_fetch_only_active_tabs_data_in_dashboard to graphite-base/3804 May 27, 2026 13:57
@akshaydeo akshaydeo changed the base branch from graphite-base/3804 to dev May 27, 2026 14:00
@akshaydeo akshaydeo dismissed coderabbitai[bot]’s stale review May 27, 2026 14:00

The base branch was changed.

@akshaydeo akshaydeo force-pushed the 05-27-refactor_use_sheetnavigation_hook_in_mcp_detail_sheet branch from c620789 to 05a4995 Compare May 27, 2026 14:00
@akshaydeo akshaydeo merged commit d9c77fd into dev May 27, 2026
15 checks passed
@akshaydeo akshaydeo deleted the 05-27-refactor_use_sheetnavigation_hook_in_mcp_detail_sheet branch May 27, 2026 14:02
akshaydeo pushed a commit that referenced this pull request May 29, 2026
…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
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.

2 participants