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

* feat(copilot): add rename operation to user_table tool

* fix(copilot): use newName instead of name for table rename operation
This commit is contained in:
Waleed
2026-03-19 23:43:24 -07:00
committed by GitHub
parent e796dfee0d
commit 8d84c30556
2 changed files with 32 additions and 0 deletions

View File

@@ -18,6 +18,7 @@ import {
insertRow,
queryRows,
renameColumn,
renameTable,
updateColumnConstraints,
updateColumnType,
updateRow,
@@ -878,6 +879,36 @@ export const userTableServerTool: BaseServerTool<UserTableArgs, UserTableResult>
}
}
case 'rename': {
if (!args.tableId) {
return { success: false, message: 'Table ID is required' }
}
const newName = (args as Record<string, unknown>).newName as string | undefined
if (!newName) {
return { success: false, message: 'newName is required for renaming a table' }
}
if (!workspaceId) {
return { success: false, message: 'Workspace ID is required' }
}
const table = await getTableById(args.tableId)
if (!table) {
return { success: false, message: `Table not found: ${args.tableId}` }
}
if (table.workspaceId !== workspaceId) {
return { success: false, message: 'Table not found' }
}
const requestId = crypto.randomUUID().slice(0, 8)
const renamed = await renameTable(args.tableId, newName, requestId)
return {
success: true,
message: `Renamed table to "${renamed.name}"`,
data: { table: { id: renamed.id, name: renamed.name } },
}
}
default:
return { success: false, message: `Unknown operation: ${operation}` }
}

View File

@@ -127,6 +127,7 @@ export const UserTableArgsSchema = z.object({
'rename_column',
'delete_column',
'update_column',
'rename',
]),
args: z
.object({