Skip to content

feat(sidebar-controls): added ability to expand on hover#343

Merged
emir-karabeg merged 1 commit into
mainfrom
feat/sidebar-controls
May 10, 2025
Merged

feat(sidebar-controls): added ability to expand on hover#343
emir-karabeg merged 1 commit into
mainfrom
feat/sidebar-controls

Conversation

@emir-karabeg

Copy link
Copy Markdown
Collaborator

Description

Extended sidebar capability to expand on hover in addition to expand/collapse.

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Security enhancement
  • Performance improvement
  • Code refactoring (no functional changes)

How Has This Been Tested?

Open/close toolbar, workflow, and logs. Set different sidebar controls and test out each page.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added tests that prove my fix is effective or that my feature works
  • All tests pass locally and in CI (npm test)
  • My changes generate no new warnings
  • Any dependent changes have been merged and published in downstream modules
  • I have updated version numbers as needed (if needed)
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

Security Considerations:

  • My changes do not introduce any new security vulnerabilities
  • I have considered the security implications of my changes

@vercel

vercel Bot commented May 10, 2025

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
sim ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 10, 2025 5:48am
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
docs ⬜️ Skipped (Inspect) May 10, 2025 5:48am

@greptile-apps greptile-apps 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.

PR Summary

Added hover mode functionality to the sidebar, allowing dynamic expansion on hover alongside existing expanded/collapsed states, with new controls for mode selection and improved workspace header interactions.

  • Added sidebar-control.tsx with a Popover menu for selecting between expanded, collapsed, and hover modes
  • Updated store.ts to replace simple collapsed state with mode-based system (expanded, collapsed, hover)
  • Added z-index management in globals.css for proper sidebar overlay layering (z-index: 40)
  • Modified workflow.tsx to handle sidebar state transitions with isSidebarCollapsed = mode === 'expanded' ? !isExpanded : mode === 'collapsed' || mode === 'hover'
  • Added event propagation controls in workspace-header.tsx to prevent unintended sidebar collapse in hover mode

💡 (1/5) You can manually trigger the bot by mentioning @greptileai in a comment!

8 file(s) reviewed, 11 comment(s)
Edit PR Review Bot Settings | Greptile

Comment on lines +19 to +20
const isSidebarCollapsed =
mode === 'expanded' ? !isExpanded : mode === 'collapsed' || mode === 'hover'

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.

logic: Potential edge case: isSidebarCollapsed will be true in hover mode even when hovering (expanded). This may cause toolbar position jumps during hover.

onClick={() => setIsCollapsed(false)}
className={`fixed transition-left duration-200 ${isSidebarCollapsed ? 'left-20' : 'left-64'} bottom-[18px] z-10 flex h-9 w-9 items-center justify-center rounded-lg bg-background text-muted-foreground hover:text-foreground hover:bg-accent border`}
onClick={() => setIsToolbarOpen(true)}
className={`fixed transition-all duration-200 ${isSidebarCollapsed ? 'left-20' : 'left-64'} bottom-[18px] z-10 flex h-9 w-9 items-center justify-center rounded-lg bg-background text-muted-foreground hover:text-foreground hover:bg-accent border`}

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.

style: transition-all may cause unnecessary transitions on unrelated properties. Consider using specific transition properties like 'transition-[left]'

Comment thread sim/app/globals.css Outdated
Comment on lines +324 to +326
.main-content-overlay:hover {
box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

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.

style: box-shadow values should use CSS custom properties for consistency with the design system and dark mode support

Comment on lines +15 to +24
const handleModeChange = (value: SidebarMode) => {
// When selecting expanded mode, ensure it's expanded
if (value === 'expanded' && !isExpanded) {
toggleExpanded()
}

// Set the new mode
setMode(value)
setOpen(false)
}

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.

style: Consider adding a check to prevent unnecessary state updates when selecting the current mode

sideOffset={5}
>
<div className="border-b py-[10px] px-4">
<h4 className="text-xs font-[480] text-muted-foreground">Sidebar control</h4>

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.

style: font-[480] is an unusual font weight value. Consider using standard weights like 400 or 500

Comment on lines +77 to +81
useEffect(() => {
if (isAnyModalOpen) {
setExplicitMouseEnter(false)
}
}, [isAnyModalOpen])

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.

logic: Resetting explicitMouseEnter when modal opens could cause sidebar to unexpectedly collapse while user is still hovering

Comment on lines +7 to +8
mode: SidebarMode
isExpanded: boolean

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.

style: Having both mode and isExpanded could lead to inconsistent states. Consider using only mode and deriving expanded state from it.

Comment on lines +30 to +31
setMode: (mode) => set({ mode }),
toggleExpanded: () => set((state) => ({ isExpanded: !state.isExpanded })),

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.

logic: setMode should also update isExpanded to maintain state consistency (e.g. when mode is 'collapsed', isExpanded should be false)

Comment on lines +238 to +239
// Keep local isOpen state in sync with the store (for internal component use)
const [isOpen, setIsOpen] = useState(workspaceDropdownOpen)

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.

logic: local isOpen state initialized from workspaceDropdownOpen but no sync effect to keep them in sync

Suggested change
// Keep local isOpen state in sync with the store (for internal component use)
const [isOpen, setIsOpen] = useState(workspaceDropdownOpen)
// Keep local isOpen state in sync with the store (for internal component use)
const [isOpen, setIsOpen] = useState(workspaceDropdownOpen)
useEffect(() => {
setIsOpen(workspaceDropdownOpen)
}, [workspaceDropdownOpen])

Comment on lines +441 to +450
// Special handling for click interactions in hover mode
const handleTriggerClick = (e: React.MouseEvent) => {
// When in hover mode, explicitly prevent bubbling for the trigger
if (mode === 'hover') {
e.stopPropagation()
e.preventDefault()
// Toggle dropdown state
handleDropdownOpenChange(!isOpen)
}
}

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.

logic: handleTriggerClick only toggles dropdown in hover mode but should also handle click mode

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.

1 participant