-
Notifications
You must be signed in to change notification settings - Fork 2.8k
feat: add collapsed code snippet display in chat input #10124
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
base: main
Are you sure you want to change the base?
Conversation
Re-reviewed the changes since commit 5e9ea62. All previously flagged issues have been resolved. No new issues found.
Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues. |
packages/types/src/code-snippet.ts
Outdated
| * Creates a unique ID for a code snippet | ||
| */ | ||
| export function createCodeSnippetId(): string { | ||
| return `snippet-${Date.now()}-${Math.random().toString(36).substr(2, 9)}` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
String.prototype.substr() is deprecated. Use substring(2, 11) instead since substr(start, length) is equivalent to substring(start, start + length).
| return `snippet-${Date.now()}-${Math.random().toString(36).substr(2, 9)}` | |
| return `snippet-${Date.now()}-${Math.random().toString(36).substring(2, 11)}` |
Fix it with Roo Code or mention @roomote and request a fix.
Re-reviewed the PR. The 2 previously flagged issues remain unresolved:
Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues. |
Re-reviewed the PR. No new issues found. The 2 previously flagged issues remain unresolved:
Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues. |
Implements a feature to show code context as compact chips in the chat input box rather than displaying full code text. When selecting code and adding to context, it now appears as a collapsed chip showing the file path and line range. Features: - CodeSnippet type for structured code references - CodeSnippetChip component for compact display of code references - Multiple code snippets can be added and displayed as chips - Full code content is expanded when sending to AI - Remove button on each chip to remove snippets Relates to #10085
Based on user feedback in Issue #10085, the code reference chip now displays only line numbers (e.g., "lines 10-25") instead of file path and line numbers (e.g., "file.ts:10-25") since the code is always from the current page. Also adds test coverage for code-snippet module.
…bstr, use Number() for type conversion
5e9ea62 to
b760452
Compare
This PR attempts to address Issue #10085.
Summary
Implements a feature to show code context as compact chips in the chat input box rather than displaying full code text. When selecting code and adding to context via the "Add to Roo Code" code action, it now appears as a collapsed chip showing the file path and line range (e.g.,
file.ts:1-10).Changes
New Files
packages/types/src/code-snippet.ts- CodeSnippet type and helper functions for:webview-ui/src/components/chat/CodeSnippetChip.tsx- Compact chip component for collapsed displayModified Files
packages/types/src/index.ts- Export code-snippet modulesrc/shared/ExtensionMessage.ts- AddaddCodeSnippetinvoke type and codeSnippet fieldsrc/core/webview/ClineProvider.ts- Send structured CodeSnippet instead of formatted textwebview-ui/src/components/chat/ChatView.tsx- Handle code snippet state and expand on sendwebview-ui/src/components/chat/ChatTextArea.tsx- Display code snippet chipsFeatures
fileName:startLine-endLineHow It Works
CodeSnippetobject with file path, line range, and contentFeedback and guidance are welcome!
Important
Adds feature to display code snippets as compact chips in chat input, enhancing UI by preventing clutter from large code blocks.
fileName:startLine-endLine.CodeSnippetChipandCodeSnippetChipsinCodeSnippetChip.tsxfor displaying and managing snippet chips.ChatTextArea.tsxandChatView.tsxupdated to handle code snippet state and display.CodeSnippettype and helper functions incode-snippet.tsfor ID creation, label formatting, and snippet expansion.code-snippet.tsincode-snippet.test.ts.ClineProvider.tsmodified to send structuredCodeSnippetobjects.ExtensionMessage.tsupdated to includeaddCodeSnippetinvoke type andcodeSnippetfield.This description was created by
for b760452. You can customize this summary. It will automatically update as commits are pushed.