Skip to content

Commit fafe018

Browse files
committed
fix(chat): bound the sync copy path by the text limit, not the chip cap
Cursor Bugbot: writeLoadedRowsWithChip bailed once loaded rows exceeded MAX_TABLE_SELECTION_ROWS, but buildTableSelectionContext already slices rowIds to that cap. So selecting more than 500 loaded rows fell through to the async path, which cannot carry a custom MIME, and silently lost the chip — while Add to Chat on the very same selection still produced a 500-row chip. The two limits govern different things: the chip's cap is how many rows a table_selection can reference, the text's is TABLE_LIMITS.MAX_COPY_ROWS. Gate on the latter. Past it the paged path still takes over, because it owns truncation and the accompanying notice.
1 parent 0ff8c7f commit fafe018

1 file changed

Lines changed: 9 additions & 3 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: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -381,9 +381,15 @@ function writeLoadedRowsWithChip(opts: {
381381
context: ChatContext | null
382382
}): boolean {
383383
const { rows, context } = opts
384-
if (!context || !opts.complete || rows.length === 0 || rows.length > MAX_TABLE_SELECTION_ROWS) {
385-
return false
386-
}
384+
// Bounded by the TEXT limit, not the chip's row cap: `context` already slices
385+
// itself to MAX_TABLE_SELECTION_ROWS, so a larger selection still copies in
386+
// full here and carries a chip for as many rows as a chip can reference —
387+
// matching what Add to Chat does with the same selection. Gating on the chip
388+
// cap instead would drop the chip entirely on the async fall-through, which
389+
// cannot carry a custom MIME. Past MAX_COPY_ROWS the paged path must take
390+
// over, since it owns truncation and the notice that goes with it.
391+
if (!context || !opts.complete || rows.length === 0) return false
392+
if (rows.length > TABLE_LIMITS.MAX_COPY_ROWS) return false
387393
opts.clipboardData?.setData(
388394
'text/plain',
389395
rows.map((row) => opts.buildCells(row).join('\t')).join('\n')

0 commit comments

Comments
 (0)