Skip to content

fix(sidebar): keep session rename input visible while editing#781

Merged
blackmammoth merged 2 commits into
siteboon:mainfrom
navarrotech:fix/persist-session-rename-input
May 29, 2026
Merged

fix(sidebar): keep session rename input visible while editing#781
blackmammoth merged 2 commits into
siteboon:mainfrom
navarrotech:fix/persist-session-rename-input

Conversation

@navarrotech
Copy link
Copy Markdown

@navarrotech navarrotech commented May 24, 2026

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:

  • While editingSession === session.id, force the action panel to opacity-100 so it stays visible regardless of hover.
  • Add a mousedown listener (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.
  • Hide the relative-time badge while editing so it does not overlap the input.

Test plan

  • Hover a desktop sidebar session row, click the pencil. Input appears and stays focused after moving the cursor off the row.
  • Press Enter to save / Escape to cancel — works as before.
  • Click the green check / red X — works as before.
  • Click anywhere outside the editing panel (other session, chat area, sidebar background) — edit is cancelled, no save.
  • Start editing one session, click the pencil on a different session — first edit cancels, second becomes active.

Summary by CodeRabbit

  • New Features

    • Sidebar session items now support closing edit mode by clicking outside the edit panel.
  • Bug Fixes

    • Fixed visibility logic for session age and edit controls to properly reflect current editing state.

Review Change Stack

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.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 24, 2026

📝 Walkthrough

Walkthrough

SidebarSessionItem now detects outside clicks to cancel session editing. The component derives an isEditing flag from the current editing session, creates a ref to the edit container, and registers a mousedown listener to trigger cancellation when clicking outside. UI elements update visibility based on this editing state.

Changes

Session Editing Interaction

Layer / File(s) Summary
Outside-click detection and editing state
src/components/sidebar/view/subcomponents/SidebarSessionItem.tsx
React imports now include useEffect and useRef. Component derives isEditing from editingSession, creates editingContainerRef, and adds an effect that registers a document mousedown handler; when editing is active and the user clicks outside the container, onCancelEditingSession is triggered.
UI visibility control based on editing state
src/components/sidebar/view/subcomponents/SidebarSessionItem.tsx
Compact session age element hides when isEditing is true, preserving prior hover-based behavior when not editing. Edit-options container className becomes driven by isEditing opacity rules (visible while editing, hover-only otherwise) and receives the editingContainerRef attachment.

A rabbit bounced in to tame the edit flow,
With outside-click detection, canceling below.
The container now listens, the UI does dance,
Hiding and showing with elegant stance! 🐰✨

🚥 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
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main fix: keeping the session rename input visible during editing, which directly addresses the issue of the action panel disappearing on mouse movement.
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 unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

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

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
src/components/sidebar/view/subcomponents/SidebarSessionItem.tsx (1)

84-101: ⚡ Quick win

Outside-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 onCancelEditingSession callback 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 in useCallback would 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

📥 Commits

Reviewing files that changed from the base of the PR and between 10f721c and d941b08.

📒 Files selected for processing (1)
  • src/components/sidebar/view/subcomponents/SidebarSessionItem.tsx

@blackmammoth blackmammoth merged commit 951f587 into siteboon:main May 29, 2026
1 check passed
@navarrotech navarrotech deleted the fix/persist-session-rename-input branch May 29, 2026 15:43
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