Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions apps/sim/lib/copilot/tools/server/table/user-table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
insertRow,
queryRows,
renameColumn,
renameTable,
updateColumnConstraints,
updateColumnType,
updateRow,
Expand Down Expand Up @@ -878,6 +879,35 @@ export const userTableServerTool: BaseServerTool<UserTableArgs, UserTableResult>
}
}

case 'rename': {
if (!args.tableId) {
return { success: false, message: 'Table ID is required' }
}
if (!args.name) {
return { success: false, message: 'Name 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, args.name, requestId)
Comment thread
waleedlatif1 marked this conversation as resolved.
Outdated

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}` }
}
Expand Down
1 change: 1 addition & 0 deletions apps/sim/lib/copilot/tools/shared/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ export const UserTableArgsSchema = z.object({
'rename_column',
'delete_column',
'update_column',
'rename',
]),
args: z
.object({
Expand Down
Loading