Skip to content

Commit ef39b49

Browse files
committed
fix(chat): scope table Add-to-chat to a column-header selection's columns
Cursor: a column-header selection set contextMenuColumnIds to undefined, so Add-to-chat sent every column (full-row dump). A column selection spans all rows of the chosen columns, so treat it like a cell range and carry those column ids.
1 parent 3130371 commit ef39b49

1 file changed

Lines changed: 7 additions & 14 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: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3690,10 +3690,11 @@ export function TableGrid({
36903690
: contextMenuRowIds.length || 1
36913691

36923692
/**
3693-
* Column ids for an "Add to chat" table selection. Only a spreadsheet-style
3694-
* cell range narrows the columns; whole-row (gutter) selections and single
3695-
* rows send every column (undefined). A range spanning all columns is
3696-
* equivalent to whole rows, so it also collapses to undefined.
3693+
* Column ids for an "Add to chat" table selection. A spreadsheet-style cell
3694+
* range AND a column-header selection (which spans every row of the chosen
3695+
* columns) narrow the columns; whole-row (gutter) selections and single rows
3696+
* send every column (undefined). A range spanning all columns is equivalent to
3697+
* whole rows, so it also collapses to undefined.
36973698
*/
36983699
const contextMenuColumnIds = useMemo<string[] | undefined>(() => {
36993700
if (!contextMenu.isOpen || !contextMenu.row) return undefined
@@ -3704,7 +3705,7 @@ export function TableGrid({
37043705
return undefined
37053706
}
37063707
const sel = normalizedSelection
3707-
if (!sel || isColumnSelection) return undefined
3708+
if (!sel) return undefined
37083709
const contextRowArrayIndex = rows.findIndex((r) => r.id === contextMenu.row!.id)
37093710
if (contextRowArrayIndex < sel.startRow || contextRowArrayIndex > sel.endRow) return undefined
37103711
const ids: string[] = []
@@ -3713,15 +3714,7 @@ export function TableGrid({
37133714
if (col) ids.push(getColumnId(col))
37143715
}
37153716
return ids.length > 0 && ids.length < displayColumns.length ? ids : undefined
3716-
}, [
3717-
contextMenu.isOpen,
3718-
contextMenu.row,
3719-
rowSelection,
3720-
normalizedSelection,
3721-
isColumnSelection,
3722-
rows,
3723-
displayColumns,
3724-
])
3717+
}, [contextMenu.isOpen, contextMenu.row, rowSelection, normalizedSelection, rows, displayColumns])
37253718

37263719
const addToChat = useAddToChat()
37273720
const handleAddSelectionToChat = useCallback(async () => {

0 commit comments

Comments
 (0)