Skip to content

feat(copilot): add rename operation to user_table tool#3691

Merged
waleedlatif1 merged 2 commits intostagingfrom
feat/rename-table
Mar 20, 2026
Merged

feat(copilot): add rename operation to user_table tool#3691
waleedlatif1 merged 2 commits intostagingfrom
feat/rename-table

Conversation

@waleedlatif1
Copy link
Collaborator

Summary

  • Adds `rename` to the `UserTableArgsSchema` operation enum in shared schemas
  • Adds server-side `case 'rename':` handler in the copilot user_table executor — validates ownership, calls `renameTable` from the table service, returns structured result

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 20, 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 20, 2026 6:37am

Request Review

@cursor
Copy link

cursor bot commented Mar 20, 2026

PR Summary

Medium Risk
Adds a new mutating operation that changes table metadata and relies on workspace ownership checks; risk is moderate due to potential authorization/validation edge cases and downstream assumptions about table names.

Overview
Adds support for a new user_table tool operation, rename, enabling Copilot workflows to rename an existing user table.

The server tool now validates tableId, newName, and workspaceId, checks the table belongs to the current workspace, calls renameTable, and returns a structured {id, name} result. The shared UserTableArgsSchema operation enum is updated to allow the new rename operation.

Written by Cursor Bugbot for commit 6695013. Configure here.

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Mar 20, 2026

Greptile Summary

This PR adds a rename operation to the copilot user_table tool, enabling LLM agents to rename a table by tableId and newName. The two-file change follows the existing patterns cleanly — the schema addition is minimal (one enum value in UserTableArgsSchema), and the server handler is a faithful copy of the delete case with an ownership check before delegating to the renameTable service function.

Key observations:

  • The handler correctly uses newName (consistent with rename_column and the workspace_file rename handler) to identify the target name — the previously raised inconsistency has been resolved.
  • Ownership is verified via getTableById + workspaceId comparison before calling renameTable, matching the delete case pattern exactly.
  • renameTable performs secondary name validation via validateTableName, so invalid names are caught even if the guard is bypassed.
  • No automated tests were added (acknowledged in the checklist); manual testing was performed.

Confidence Score: 5/5

  • This PR is safe to merge — the new handler is well-guarded and consistent with existing patterns.
  • The implementation directly mirrors the established delete case: validates inputs, verifies workspace ownership, and delegates to a service function that has its own secondary validation. No regressions are introduced; the schema addition is additive and backward-compatible. The only gap is the absence of automated tests, but the change is sufficiently simple and the logic is covered by the service-level validation.
  • No files require special attention.

Important Files Changed

Filename Overview
apps/sim/lib/copilot/tools/shared/schemas.ts Adds 'rename' to the UserTableArgsSchema operation enum; the existing newName field in the args sub-object already covers the rename parameter with no further schema changes required.
apps/sim/lib/copilot/tools/server/table/user-table.ts Adds the case 'rename': handler — mirrors the delete case pattern exactly: validates tableId, newName, workspaceId, performs ownership check via getTableById, then delegates to renameTable. Implementation is clean and consistent with existing operations.

Sequence Diagram

sequenceDiagram
    participant Client as Copilot Client
    participant Tool as userTableServerTool
    participant DB1 as getTableById
    participant Svc as renameTable
    participant DB2 as DB (UPDATE)

    Client->>Tool: execute({ operation: 'rename', args: { tableId, newName } })
    Tool->>Tool: validate tableId present
    Tool->>Tool: validate newName present
    Tool->>Tool: validate workspaceId present
    Tool->>DB1: getTableById(tableId)
    DB1-->>Tool: TableDefinition | null
    alt table not found
        Tool-->>Client: { success: false, message: 'Table not found: ...' }
    else workspaceId mismatch
        Tool-->>Client: { success: false, message: 'Table not found' }
    else ownership confirmed
        Tool->>Svc: renameTable(tableId, newName, requestId)
        Svc->>Svc: validateTableName(newName)
        alt invalid name
            Svc-->>Tool: throws Error
            Tool-->>Client: { success: false, message: 'Operation failed: ...' }
        else valid name
            Svc->>DB2: UPDATE userTableDefinitions SET name=newName WHERE id=tableId
            DB2-->>Svc: { id }
            Svc-->>Tool: { id, name }
            Tool-->>Client: { success: true, message: 'Renamed table to "..."', data: { table } }
        end
    end
Loading

Last reviewed commit: "fix(copilot): use ne..."

@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 merged commit 8d84c30 into staging Mar 20, 2026
12 checks passed
@waleedlatif1 waleedlatif1 deleted the feat/rename-table branch March 20, 2026 06: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.

1 participant