-
Notifications
You must be signed in to change notification settings - Fork 3.7k
feat(chat): highlight-to-chat — reference file/table selections in Chat #6087
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
mzxchandra
wants to merge
12
commits into
staging
Choose a base branch
from
feat/highlight-to-chat
base: staging
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
5c4454b
feat(chat): highlight-to-chat for file and table selections
mzxchandra 3dac5a8
fix(chat): widen selection code fence so embedded backticks can't tru…
mzxchandra 1551f96
fix(chat): carry the selection chip on a column-header copy
mzxchandra 27dbd17
Merge remote-tracking branch 'origin/staging' into worktree-add-to-ch…
waleedlatif1 6421994
refactor(chat): clean up highlight-to-chat selections
waleedlatif1 a80f2e2
refactor(chat): tighten table copy fallback and helper placement
waleedlatif1 8455da9
fix(chat): apply chip handoffs as one batch; widen table copy chip path
waleedlatif1 598791e
fix(chat): distinguish a line-less file-selection label from the whol…
waleedlatif1 7d3d58d
fix(chat): don't revive an aged-out chip handoff when accumulating
waleedlatif1 f82c44e
fix(chat): reference every selected row in a table chip, not just loa…
waleedlatif1 9a1da09
docs(chat): scope the table copy 'complete' comment to the text path
waleedlatif1 231e0a0
fix(chat): compare selection ids as sets, not sequences
waleedlatif1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 3 additions & 2 deletions
5
.../[workspaceId]/files/components/file-viewer/rich-markdown-editor/menus/toolbar-button.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
...sim/app/workspace/[workspaceId]/files/components/file-viewer/use-selection-copy-bridge.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| 'use client' | ||
|
|
||
| import { type RefObject, useEffect } from 'react' | ||
| import { attachSelectionContextToClipboard } from '@/lib/copilot/chat/selection-clipboard' | ||
| import type { ChatContext } from '@/stores/panel' | ||
|
|
||
| /** | ||
| * Rides a selection {@link ChatContext} onto the editor's native copy so a | ||
| * highlighted passage copied with Cmd+C pastes into Chat as a reference chip. | ||
| * | ||
| * Attached in the BUBBLE phase so it runs after the inner editor's own copy | ||
| * handler — Monaco and ProseMirror both `clearData()` before writing | ||
| * `text/plain`, so the custom type must be added last to survive. | ||
| * | ||
| * @param buildContext - Returns null when there is no non-empty selection. | ||
| * @param enabled - Re-runs the effect for a container that mounts late (behind a | ||
| * loading gate); a ref isn't reactive, so the effect would otherwise bail on the | ||
| * first render and never re-attach. | ||
| */ | ||
| export function useSelectionCopyBridge( | ||
| containerRef: RefObject<HTMLElement | null>, | ||
| buildContext: () => ChatContext | null, | ||
| enabled = true | ||
| ): void { | ||
| useEffect(() => { | ||
| const dom = containerRef.current | ||
| if (!dom || !enabled) return | ||
| const onCopy = (e: ClipboardEvent) => { | ||
| const context = buildContext() | ||
| if (context) attachSelectionContextToClipboard(e.clipboardData, context) | ||
| } | ||
| dom.addEventListener('copy', onCopy) | ||
| return () => dom.removeEventListener('copy', onCopy) | ||
| }, [containerRef, buildContext, enabled]) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.