feat(chat): highlight-to-chat — reference file/table selections in Chat - #6087
feat(chat): highlight-to-chat — reference file/table selections in Chat#6087mzxchandra wants to merge 3 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR SummaryMedium Risk Overview Producers: Monaco context menu, Tiptap bubble menu, and table context menu call Chat input: Server: Reviewed by Cursor Bugbot for commit 1551f96. Bugbot is set up for automated code reviews on this repo. Configure here. |
Greptile SummaryHighlight-to-chat adds scoped
Confidence Score: 5/5This PR appears safe to merge; the previously reported multi-row copy MIME drop is fixed for the loaded in-cap path. No blocking failure remains. Multi-row
|
| Filename | Overview |
|---|---|
| apps/sim/app/workspace/[workspaceId]/tables/[tableId]/components/table-grid/table-grid.tsx | Multi-row and column-header copy paths attach table_selection MIME synchronously when loaded and within caps; async paged path remains plain-text only for oversized/partial loads. |
| apps/sim/lib/copilot/chat/selection-clipboard.ts | Custom MIME attach/read with validation for file_selection and table_selection payloads. |
| apps/sim/lib/copilot/chat/process-contents.ts | Server resolves file_selection to fenced snippets and table_selection via workspace-scoped getRowsByIds. |
| apps/sim/hooks/use-add-to-chat.ts | Live mothership insert or pending-context storage plus hard navigate to chat home. |
| apps/sim/app/workspace/[workspaceId]/home/home.tsx | Drains pending selection contexts, maps selection kinds to resources, and avoids closing shared tabs while other chips still reference them. |
Reviews (10): Last reviewed commit: "fix(chat): carry the selection chip on a..." | Re-trigger Greptile
|
@cursor review |
|
@cursor review |
|
@cursor review |
|
@cursor review |
|
@cursor review |
|
@cursor review |
|
@cursor review |
|
@cursor review |
|
@cursor review |
Adds an IDE-style "add to chat" affordance so the Sim agent can reference an exact passage of a file or a specific set of table rows/cells instead of a whole resource. - Two new ChatContext kinds: file_selection (inline selected text + line range) and table_selection (authoritative row ids, optional column ids; the server re-fetches current rows by id). Chip registry, client serializer, boundary contract, and server resolver all extend along their existing switch(kind) seams. - Producers: Monaco context menu, Tiptap bubble menu, and the table grid context menu, all using the Sim Chat block icon. Adding a selection opens the split slideover (chat + resource) with the chip dropped straight into the input; from a standalone Files/Tables page the context is stashed and drained on chat mount. - Cmd+C / Cmd+V: a selection copied from a file/table rides a custom text/x-sim-selection clipboard MIME and pastes into chat as the same reference chip; the chat input round-trips a sole selection chip on copy/cut too. - Guards: selection payloads are length/row/column bounded and truncated within the schema bound; labels carry a deterministic key so distinct same-size selections don't collide; a shared resource tab closes only once no remaining chip references it; stale cell-range column ids drop the context rather than dumping the full table.
84081de to
5c4454b
Compare
|
@cursor review |
…ncate it Cursor: resolveFileSelectionResource wrapped the selected passage in a fixed ``` fence, so a selection that itself contained a fenced code block closed the outer fence early and the agent received a truncated snippet. The fence is now one backtick longer than the longest backtick run in the content (floored at three), matching CommonMark's close rule.
|
@cursor review |
|
@greptile review |
Cursor: a column-header Cmd+C always took the async paged clipboard path, which replaces the whole clipboard with text/plain only and can't carry a custom MIME - so pasting a column copy into Chat couldn't rebuild the table_selection chip that Add-to-chat produces for the same selection. When every row is loaded and within the chat-selection cap, the column copy now does a synchronous event write so the scoped table_selection rides alongside text/plain (mirroring the row-'some' and cell-range paths); oversized/partially-loaded columns keep the async plain-text path.
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
1 issue from previous review remains unresolved.
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 3dac5a8. Configure here.
|
@cursor review |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 1551f96. Configure here.

Summary
IDE-style highlight → "Add to chat" for Files and Tables: select a passage in a file (Monaco or the Tiptap markdown editor) or rows/cells in a table, and it becomes a scoped reference chip the Sim agent can read, instead of attaching the whole resource. Cmd+C / Cmd+V works too: copy a selection and paste it into the chat as the same reference.
Adding a selection from a standalone Files/Tables page opens the Chat in the split layout (chat left, resource right) with the chip already in the input; adding it while a resource is already open in Chat drops the chip into the current conversation.
Type of Change
How it works
ChatContextkindsfile_selection/table_selection. File selections carry the literal text + line range inline; table selections carry authoritative row/column ids and are re-fetched server-side by id (never trusting client cell values), scoped to the table + workspace.Blimpicon in the Monaco context menu, the Tiptap bubble menu, and the table context menu.text/x-sim-selectionclipboard type alongsidetext/plain(bubble-phase listener so it survives the editors' ownclearData()), read back by the chat paste handler.Testing
bunx tsc --noEmit: 0 errors. Biome clean.check:api-validationpasses (new context fields live only on the domain validator + theChatContextunion — no boundary violation).process-contents), label/bounds helpers (selection-context), and the clipboard codec round-trip/validation (selection-clipboard, new).Reviewers: focus on
lib/copilot/chat/process-contents.ts(server row re-fetch + bounds) and the merge with staging's nuqs?resource=refactor inhome.tsx.Checklist
🤖 Generated with Claude Code