fix(sidebar): keep session rename input visible while editing#781
Conversation
The rename input shares a parent div that uses `group-hover:opacity-100`, so moving the cursor off the row visually hid the input mid-edit. While editing, force the action panel to `opacity-100` and dismiss it via an outside-click listener instead of mouseleave. Also hide the relative-time badge so it does not overlap the input.
📝 WalkthroughWalkthroughSidebarSessionItem now detects outside clicks to cancel session editing. The component derives an ChangesSession Editing Interaction
🚥 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 unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/components/sidebar/view/subcomponents/SidebarSessionItem.tsx (1)
84-101: ⚡ Quick winOutside-click detection is well-implemented.
The mousedown listener correctly cancels editing when clicking outside the container. The early return when not editing keeps the logic clean, and the cleanup function properly prevents memory leaks.
Consider memoizing the callback in the parent
The
onCancelEditingSessioncallback is currently defined inline in the parent component (Sidebar.tsx), causing this effect to re-register the listener on every parent render when editing. While the impact is minimal (only one session can be edited at a time, and the early return guards against unnecessary work), wrapping the parent callback inuseCallbackwould prevent unnecessary effect re-runs.Parent component could apply:
const onCancelEditingSession = useCallback(() => { setEditingSession(null); setEditingSessionName(''); }, []);🤖 Prompt for 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. In `@src/components/sidebar/view/subcomponents/SidebarSessionItem.tsx` around lines 84 - 101, The parent-provided onCancelEditingSession is recreated each render causing the useEffect in SidebarSessionItem (the effect that installs the document 'mousedown' listener) to re-run unnecessarily; in the parent component that defines onCancelEditingSession (Sidebar.tsx) wrap that handler in useCallback (e.g., the function that calls setEditingSession and setEditingSessionName) so its identity is stable and pass the memoized onCancelEditingSession into SidebarSessionItem to avoid repeated effect tear-downs/re-registrations.
🤖 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.
Nitpick comments:
In `@src/components/sidebar/view/subcomponents/SidebarSessionItem.tsx`:
- Around line 84-101: The parent-provided onCancelEditingSession is recreated
each render causing the useEffect in SidebarSessionItem (the effect that
installs the document 'mousedown' listener) to re-run unnecessarily; in the
parent component that defines onCancelEditingSession (Sidebar.tsx) wrap that
handler in useCallback (e.g., the function that calls setEditingSession and
setEditingSessionName) so its identity is stable and pass the memoized
onCancelEditingSession into SidebarSessionItem to avoid repeated effect
tear-downs/re-registrations.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 3add1baf-c957-43c8-af87-bc37ee47b6c4
📒 Files selected for processing (1)
src/components/sidebar/view/subcomponents/SidebarSessionItem.tsx
Summary
When clicking the pencil ("Manually edit session name") button on a sidebar session row, the rename input only stayed visible while the cursor was over the row. Moving the mouse away hid the entire action panel (input + save + cancel), even mid-edit, because the panel is wrapped in a single div with
opacity-0 group-hover:opacity-100.Fix
In
src/components/sidebar/view/subcomponents/SidebarSessionItem.tsx:editingSession === session.id, force the action panel toopacity-100so it stays visible regardless of hover.mousedownlistener (mounted only while editing) so clicking anywhere outside the panel cancels the edit. This matches the existing Escape / cancel-button behavior and gives users an intuitive "click off to dismiss" interaction.Test plan
Summary by CodeRabbit
New Features
Bug Fixes