Skip to content

fix(tasks): conversation rename#2107

Merged
jschwxrz merged 1 commit into
mainfrom
jona/eng-1324-renaming-a-conversation-in-right-sidebar-fails
May 19, 2026
Merged

fix(tasks): conversation rename#2107
jschwxrz merged 1 commit into
mainfrom
jona/eng-1324-renaming-a-conversation-in-right-sidebar-fails

Conversation

@jschwxrz
Copy link
Copy Markdown
Collaborator

  • fixes conversation rename failing from the right sidebar
  • delays entering inline rename mode until the context menu has fully closed
  • selects the rename input via callback ref when it mounts

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 19, 2026

Greptile Summary

This PR fixes conversation rename from the right sidebar by introducing a two-phase approach: clicking "Rename" sets a pending flag, and the inline edit input only mounts after the context menu's close animation fully completes via onOpenChangeComplete. The autoFocus attribute is also replaced by a callback ref to guarantee focus and selection on mount.

  • Introduces pendingRenameRef + handleContextMenuOpenChangeComplete to defer setIsEditing(true) until onOpenChangeComplete fires on the ContextMenu root, preventing the rename input from appearing while the context menu is still animating out.
  • Replaces autoFocus with a stable useCallback ref that explicitly calls focus() and select() when the input element mounts, which is more reliable in animated/virtualized containers.

Confidence Score: 4/5

Safe to merge — the deferred rename approach is logically correct and onOpenChangeComplete is a supported base-ui prop.

The core fix is sound: pendingRenameRef correctly tracks intent across the close animation, and onOpenChangeComplete on @base-ui/react ContextMenu Root is a documented, typed callback that fires after close animations finish. The only observation is that handleRename and handleContextMenuOpenChangeComplete are not wrapped in useCallback while handleRenameInputRef is, creating a minor inconsistency in an observer component. No functional bugs were found.

No files require special attention — the single changed file is straightforward and well-scoped.

Important Files Changed

Filename Overview
src/renderer/features/tasks/conversations/sidebar-conversations-list.tsx Introduces pendingRenameRef and onOpenChangeComplete to defer rename mode until the context menu animation completes; replaces autoFocus with a callback ref. Logic is correct; minor inconsistency in that handleRename/handleContextMenuOpenChangeComplete are not memoized while handleRenameInputRef is.

Sequence Diagram

sequenceDiagram
    participant User
    participant ContextMenu
    participant ConversationRow
    participant RenameInput

    User->>ContextMenu: Right-click (open menu)
    User->>ContextMenu: Click "Rename"
    ContextMenu->>ConversationRow: handleRename()
    Note over ConversationRow: pendingRenameRef.current = true
    ContextMenu->>ContextMenu: Begin close animation
    ContextMenu->>ConversationRow: onOpenChangeComplete(false)
    Note over ConversationRow: pendingRenameRef.current = false, setIsEditing(true)
    ConversationRow->>RenameInput: Mount input element
    RenameInput->>RenameInput: handleRenameInputRef(input) focus() + select()
    User->>RenameInput: Type new name / press Enter
    RenameInput->>ConversationRow: handleRenameSubmit(newTitle)
    ConversationRow->>ConversationRow: setIsEditing(false)
Loading
Prompt To Fix All With AI
Fix the following 1 code review issue. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 1
src/renderer/features/tasks/conversations/sidebar-conversations-list.tsx:62-71
`handleRename` and `handleContextMenuOpenChangeComplete` are recreated on every render, while `handleRenameInputRef` is memoized. Because `ConversationRow` is a MobX `observer`, any observed state change triggers a re-render and produces new function references. `handleContextMenuOpenChangeComplete` is forwarded directly to `ContextMenu` as `onOpenChangeComplete`, so wrapping both in `useCallback` keeps the pattern consistent and avoids unnecessary prop churn on the base-ui primitive.

```suggestion
  const handleRename = useCallback(() => {
    pendingRenameRef.current = true;
  }, []);

  const handleContextMenuOpenChangeComplete = useCallback((open: boolean) => {
    if (!open && pendingRenameRef.current) {
      pendingRenameRef.current = false;
      setIsEditing(true);
    }
  }, []);
```

Reviews (1): Last reviewed commit: "fix(tasks): delay conversation rename ed..." | Re-trigger Greptile

Comment thread src/renderer/features/tasks/conversations/sidebar-conversations-list.tsx Outdated
@jschwxrz jschwxrz force-pushed the jona/eng-1324-renaming-a-conversation-in-right-sidebar-fails branch from 15581f7 to 2d50741 Compare May 19, 2026 01:19
@jschwxrz jschwxrz merged commit 0f154ae into main May 19, 2026
1 check passed
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