Skip to content

Commit 6a07cde

Browse files
committed
fix(chat): drain rows for a column-header Add-to-chat selection
Cursor: a column-header selection spans every row of the chosen columns, but Add-to-chat built rowIds from the loaded page only. Extend the drain (already used for gutter select-all) to column selections — load up to the cap and take all rows — so the chip references as many rows as it can carry.
1 parent ef39b49 commit 6a07cde

1 file changed

Lines changed: 13 additions & 8 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: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3718,17 +3718,22 @@ export function TableGrid({
37183718

37193719
const addToChat = useAddToChat()
37203720
const handleAddSelectionToChat = useCallback(async () => {
3721-
// A gutter select-all only has the loaded page in `contextMenuRowIds`; drain
3722-
// up to the cap so the chip references as many of the selected rows as it can
3723-
// carry (bounded by MAX_TABLE_SELECTION_ROWS) instead of a silent
3724-
// loaded-only subset — mirroring how the copy path loads before writing.
3721+
// A gutter select-all (filtered) or a column-header selection (every row of
3722+
// the chosen columns) covers rows beyond the loaded page that
3723+
// `contextMenuRowIds` reflects; drain up to the cap so the chip references as
3724+
// many rows as it can carry (bounded by MAX_TABLE_SELECTION_ROWS) instead of a
3725+
// silent loaded-only subset — mirroring how the copy path loads before writing.
37253726
let sourceRowIds = contextMenuRowIds
3726-
if (contextMenuIsSelectAll) {
3727+
if (contextMenuIsSelectAll || isColumnSelectionRef.current) {
37273728
try {
37283729
const { rows: loaded } = await ensureRowsLoadedUpToRef.current(MAX_TABLE_SELECTION_ROWS)
3729-
const drained = loaded
3730-
.filter((row) => rowSelectionIncludes(rowSelectionRef.current, row.id))
3731-
.map((row) => row.id)
3730+
// A column selection spans all rows; a gutter select-all filters by the
3731+
// (exclusion-aware) row selection.
3732+
const drained = (
3733+
contextMenuIsSelectAll
3734+
? loaded.filter((row) => rowSelectionIncludes(rowSelectionRef.current, row.id))
3735+
: loaded
3736+
).map((row) => row.id)
37323737
if (drained.length > 0) sourceRowIds = drained
37333738
} catch {
37343739
// Fall back to the already-loaded rows if the drain fails.

0 commit comments

Comments
 (0)