Skip to content

Commit f82c44e

Browse files
committed
fix(chat): reference every selected row in a table chip, not just loaded ones
Cursor Bugbot: for a 'some' row selection the chip's rowIds came from the loaded-page intersection (currentRows filtered by the selection) rather than rowSel.ids. The chip carries ids and the server re-fetches them via getRowsByIds, so a selected row that simply had not been paged into the grid was silently dropped from the agent's context — select 600 rows with 200 loaded and the agent saw 200. Add to chat had the same loaded-only narrowing through contextMenuRowIds. Both now send the full selection, still bounded by MAX_TABLE_SELECTION_ROWS. Only the pasted text stays limited to loaded rows, which is inherent — there are no cell values to serialize for a row that has not been fetched.
1 parent 7d3d58d commit f82c44e

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

  • apps/sim/app/workspace/[workspaceId]/tables/[tableId]/components/table-grid

apps/sim/app/workspace/[workspaceId]/tables/[tableId]/components/table-grid/table-grid.tsx

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3031,7 +3031,10 @@ export function TableGrid({
30313031
tableId,
30323032
tableName: tableNameRef.current,
30333033
totalColumnCount: cols.length,
3034-
rowIds: selectedRows.map((row) => row.id),
3034+
// Every selected id, not just the loaded page: the chip carries
3035+
// ids and the server re-fetches them, so an unloaded row still
3036+
// reaches the agent. Only the pasted text is limited to `rows`.
3037+
rowIds: [...rowSel.ids],
30353038
}),
30363039
})
30373040
if (handled) return
@@ -3860,7 +3863,16 @@ export function TableGrid({
38603863
// `contextMenuRowIds` reflects; drain up to the cap so the chip references as
38613864
// many rows as it can carry (bounded by MAX_TABLE_SELECTION_ROWS) instead of a
38623865
// silent loaded-only subset — mirroring how the copy path loads before writing.
3863-
let sourceRowIds = contextMenuRowIds
3866+
// A gutter selection can extend past the loaded page, and `contextMenuRowIds`
3867+
// is the loaded intersection. The chip references ids the server re-fetches,
3868+
// so send the whole selection rather than whichever rows happen to be paged in.
3869+
const gutterSelection = rowSelectionRef.current
3870+
let sourceRowIds =
3871+
gutterSelection.kind === 'some' &&
3872+
contextMenu.row &&
3873+
rowSelectionIncludes(gutterSelection, contextMenu.row.id)
3874+
? [...gutterSelection.ids]
3875+
: contextMenuRowIds
38643876
if (contextMenuIsSelectAll || isColumnSelectionRef.current) {
38653877
try {
38663878
const { rows: loaded } = await ensureRowsLoadedUpToRef.current(MAX_TABLE_SELECTION_ROWS)
@@ -3889,6 +3901,7 @@ export function TableGrid({
38893901
contextMenuRowIds,
38903902
contextMenuColumnIds,
38913903
contextMenuIsSelectAll,
3904+
contextMenu.row,
38923905
tableId,
38933906
tableData?.name,
38943907
displayColumns.length,

0 commit comments

Comments
 (0)