Skip to content

feat(tasks): add rename to task context menu#3442

Merged
waleedlatif1 merged 1 commit intofeat/mothership-copilotfrom
waleedlatif1/task-rename-context-menu
Mar 6, 2026
Merged

feat(tasks): add rename to task context menu#3442
waleedlatif1 merged 1 commit intofeat/mothership-copilotfrom
waleedlatif1/task-rename-context-menu

Conversation

@waleedlatif1
Copy link
Collaborator

Summary

  • Add "Rename" option to the right-click context menu for tasks in the sidebar
  • New PATCH endpoint at /api/copilot/chat/rename for updating chat titles
  • useRenameTask TanStack Query mutation with optimistic updates
  • Inline rename input with Enter/Escape/blur handling

Type of Change

  • New feature

Testing

Tested manually

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel
Copy link

vercel bot commented Mar 6, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Mar 6, 2026 8:48pm

Request Review

@cursor
Copy link

cursor bot commented Mar 6, 2026

PR Summary

Medium Risk
Adds a new authenticated API endpoint that updates chat titles in the database and wires it into the sidebar with optimistic UI updates; main risk is around incorrect task selection/rollback behavior and server-side validation/authorization edge cases.

Overview
Adds task renaming from the sidebar: the task context menu now conditionally shows Rename, which swaps the item into an inline input with Enter/Escape/blur handling and triggers a rename mutation.

Introduces PATCH /api/copilot/chat/rename, validating { chatId, title }, scoping the update to the current user, and returning 404 when the chat isn’t found. Adds useRenameTask with an optimistic update + rollback and list invalidation to keep the task list in sync.

Written by Cursor Bugbot for commit ff60881. Configure here.

@waleedlatif1 waleedlatif1 changed the base branch from staging to feat/mothership-copilot March 6, 2026 20:21
@waleedlatif1 waleedlatif1 force-pushed the waleedlatif1/task-rename-context-menu branch from 391c6ac to 4cc1402 Compare March 6, 2026 20:30
@waleedlatif1
Copy link
Collaborator Author

@greptile

@waleedlatif1
Copy link
Collaborator Author

@cursor review

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Mar 6, 2026

Greptile Summary

This PR adds a "Rename" option to the task right-click context menu, wiring together a new PATCH API route, a useRenameTask TanStack Query mutation with optimistic updates, and an inline rename input. The backend and mutation hook are well-implemented — the endpoint correctly scopes updates to the authenticated user, uses .returning() to distinguish a real update from a no-op, and the hook follows the existing optimistic-update pattern faithfully.

Two issues remain in sidebar.tsx:

  1. Rename on the 'new' placeholder task — When there are no real tasks, the task list renders a placeholder with id: 'new'. Right-clicking it exposes the "Rename" menu item; confirming a rename fires a mutation with chatId: 'new', which the server rejects with a 404, causing the optimistic name to flash and silently roll back. The guard should explicitly exclude activeTaskId === 'new' before allowing the rename action.

  2. truncate on the rename <input> — The overflow: hidden from Tailwind's truncate utility prevents horizontal scrolling inside the input, making it impossible to review or edit task names that exceed the visible field width.

The backend and mutation hook are solid. The two remaining issues are confined to sidebar.tsx: one is a logic bug (rename invocable on a non-persisted placeholder that will always 404) and one is a CSS usability regression on the rename input. Neither is a security issue, but the placeholder rename causes a guaranteed error path with a confusing silent rollback.

Confidence Score: 3/5

  • Safe to merge after fixing the placeholder-task rename guard and removing truncate from the input; neither issue is a security risk, but the placeholder rename is a logic bug with confusing UX.
  • The backend and mutation hook are solid. The two remaining issues are confined to sidebar.tsx: one is a logic bug (rename invocable on a non-persisted placeholder that will always 404, causing a silent flicker) and one is a CSS usability regression (truncate blocks scrolling for long names). Neither is a security issue, but the placeholder rename bug creates a guaranteed error path that confuses the user.
  • apps/sim/app/workspace/[workspaceId]/w/components/sidebar/sidebar.tsx — placeholder guard and input truncate class.

Sequence Diagram

sequenceDiagram
    participant User
    participant Sidebar
    participant NavItemContextMenu
    participant useRenameTask
    participant RenameAPI as /api/copilot/chat/rename
    participant DB

    User->>Sidebar: Right-click task
    Sidebar->>Sidebar: handleTaskContextMenu
    Sidebar->>NavItemContextMenu: open (onRename=handleStartTaskRename)
    User->>NavItemContextMenu: Click Rename
    NavItemContextMenu->>Sidebar: onRename()
    Sidebar->>Sidebar: setRenamingTaskId, setRenameValue
    NavItemContextMenu->>Sidebar: onClose()
    Sidebar->>User: Render inline input

    alt User presses Enter or blurs
        User->>Sidebar: Enter / blur
        Sidebar->>Sidebar: handleSaveTaskRename
        Sidebar->>useRenameTask: mutate({ chatId, title })
        useRenameTask->>useRenameTask: onMutate - optimistic update
        useRenameTask->>RenameAPI: PATCH { chatId, title }
        RenameAPI->>DB: UPDATE WHERE id=chatId AND userId=user.id
        DB-->>RenameAPI: updated row or none
        alt Row found
            RenameAPI-->>useRenameTask: 200 success
            useRenameTask->>useRenameTask: invalidate task list
        else Not found
            RenameAPI-->>useRenameTask: 404 not found
            useRenameTask->>useRenameTask: rollback and invalidate
        end
    else User presses Escape
        User->>Sidebar: Escape
        Sidebar->>Sidebar: handleCancelTaskRename
        Sidebar->>Sidebar: DOM removal fires blur exit early
    end
Loading

Last reviewed commit: ff60881

@waleedlatif1 waleedlatif1 force-pushed the waleedlatif1/task-rename-context-menu branch from 4cc1402 to ff60881 Compare March 6, 2026 20:41
@waleedlatif1
Copy link
Collaborator Author

@greptile

@waleedlatif1
Copy link
Collaborator Author

@cursor review

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

@waleedlatif1 waleedlatif1 force-pushed the waleedlatif1/task-rename-context-menu branch from ff60881 to 364bd0a Compare March 6, 2026 20:48
@waleedlatif1 waleedlatif1 merged commit 82ba3d7 into feat/mothership-copilot Mar 6, 2026
3 checks passed
@waleedlatif1 waleedlatif1 deleted the waleedlatif1/task-rename-context-menu branch March 6, 2026 20:49
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