Skip to content

Commit 0e47d6e

Browse files
improvement(mothership): drop get_job operation — poll background jobs via query_rows
Per review, get_job is unnecessary: the model observes background import/delete progress with query_rows (rows appearing as an import lands; the delete mask already makes query_rows reflect the post-delete view). Removes the operation and repoints the dispatch messages at query_rows. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent c1c4160 commit 0e47d6e

2 files changed

Lines changed: 3 additions & 86 deletions

File tree

apps/sim/lib/copilot/tools/server/table/user-table.test.ts

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -833,49 +833,3 @@ describe('userTableServerTool.delete_rows_by_filter', () => {
833833
expect(mockDeleteRowsByFilter).toHaveBeenCalledTimes(1)
834834
})
835835
})
836-
837-
describe('userTableServerTool.get_job', () => {
838-
beforeEach(() => {
839-
vi.clearAllMocks()
840-
})
841-
842-
it('returns the active job derived on the table', async () => {
843-
mockGetTableById.mockResolvedValue(
844-
buildTable({
845-
rowCount: 1234,
846-
jobId: 'job-1',
847-
jobType: 'import',
848-
jobStatus: 'running',
849-
jobError: null,
850-
jobRowsProcessed: 500,
851-
})
852-
)
853-
854-
const result = await userTableServerTool.execute(
855-
{ operation: 'get_job', args: { tableId: 'tbl_1' } },
856-
{ userId: 'user-1', workspaceId: 'workspace-1' }
857-
)
858-
859-
expect(result.success).toBe(true)
860-
expect(result.data?.job).toEqual({
861-
id: 'job-1',
862-
type: 'import',
863-
status: 'running',
864-
error: null,
865-
rowsProcessed: 500,
866-
})
867-
expect(result.data?.rowCount).toBe(1234)
868-
})
869-
870-
it('returns job: null when the table has no job', async () => {
871-
mockGetTableById.mockResolvedValue(buildTable())
872-
873-
const result = await userTableServerTool.execute(
874-
{ operation: 'get_job', args: { tableId: 'tbl_1' } },
875-
{ userId: 'user-1', workspaceId: 'workspace-1' }
876-
)
877-
878-
expect(result.success).toBe(true)
879-
expect(result.data?.job).toBeNull()
880-
})
881-
})

apps/sim/lib/copilot/tools/server/table/user-table.ts

Lines changed: 3 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -374,43 +374,6 @@ export const userTableServerTool: BaseServerTool<UserTableArgs, UserTableResult>
374374
}
375375
}
376376

377-
case 'get_job': {
378-
if (!args.tableId) {
379-
return { success: false, message: 'Table ID is required' }
380-
}
381-
if (!workspaceId) {
382-
return { success: false, message: 'Workspace ID is required' }
383-
}
384-
385-
const table = await getTableById(args.tableId)
386-
if (!table || table.workspaceId !== workspaceId) {
387-
return { success: false, message: `Table not found: ${args.tableId}` }
388-
}
389-
390-
if (!table.jobId) {
391-
return {
392-
success: true,
393-
message: `No active or recent job for table "${table.name}"`,
394-
data: { job: null, rowCount: table.rowCount },
395-
}
396-
}
397-
398-
return {
399-
success: true,
400-
message: `Job ${table.jobId} (${table.jobType}) is ${table.jobStatus}`,
401-
data: {
402-
job: {
403-
id: table.jobId,
404-
type: table.jobType,
405-
status: table.jobStatus,
406-
error: table.jobError ?? null,
407-
rowsProcessed: table.jobRowsProcessed ?? 0,
408-
},
409-
rowCount: table.rowCount,
410-
},
411-
}
412-
}
413-
414377
case 'delete': {
415378
const tableIds: string[] = args.tableIds ?? (args.tableId ? [args.tableId] : [])
416379
if (tableIds.length === 0) {
@@ -812,7 +775,7 @@ export const userTableServerTool: BaseServerTool<UserTableArgs, UserTableResult>
812775
})
813776
return {
814777
success: true,
815-
message: `Started background delete of ${doomedCount} matching rows (job ${jobId}). The rows are hidden from reads immediately; call get_job to track progress.`,
778+
message: `Started background delete of ${doomedCount} matching rows (job ${jobId}). The rows are hidden from reads immediately — query_rows already reflects the post-delete view.`,
816779
data: { jobId, doomedCount },
817780
}
818781
}
@@ -1005,7 +968,7 @@ export const userTableServerTool: BaseServerTool<UserTableArgs, UserTableResult>
1005968
}
1006969
return {
1007970
success: true,
1008-
message: `Created table "${table.name}" (${table.id}); importing rows from "${record.name}" in the background (job ${importId}). Columns and rows appear as the import progresses — call get_job with this tableId to track it.`,
971+
message: `Created table "${table.name}" (${table.id}); importing rows from "${record.name}" in the background (job ${importId}). Columns and rows appear as the import progresses — query_rows to check what has landed.`,
1009972
data: {
1010973
tableId: table.id,
1011974
tableName: table.name,
@@ -1170,7 +1133,7 @@ export const userTableServerTool: BaseServerTool<UserTableArgs, UserTableResult>
11701133
})
11711134
return {
11721135
success: true,
1173-
message: `Started background ${mode} import of "${record.name}" into "${table.name}" (job ${importId}). Rows appear as the import progresses — call get_job to track it.`,
1136+
message: `Started background ${mode} import of "${record.name}" into "${table.name}" (job ${importId}). Rows appear as the import progresses — query_rows to check what has landed.`,
11741137
data: { tableId: table.id, jobId: importId, mode },
11751138
}
11761139
}

0 commit comments

Comments
 (0)