Skip to content

Conversation

@jsonify
Copy link
Owner

@jsonify jsonify commented Dec 11, 2025

No description provided.

- Add new context menu item in Noted submenu for summarizing selected text
- Works in any file (not just Notes folder)
- Uses VS Code LLM API (GitHub Copilot) for AI-powered summarization
- Generates concise 2-3 sentence summary
- Inserts summary below selection with "## Summary of Selection" header
- Shows error message if Copilot is unavailable
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @jsonify, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request implements a new 'Summarize Selection' feature, allowing users to quickly obtain AI-generated summaries of any text they highlight in the editor. The functionality is integrated into the editor's context menu and automatically inserts the summary below the selection, enhancing productivity by providing instant insights into chosen text segments.

Highlights

  • New Feature: Summarize Selection: Introduces a new command noted.summarizeSelection to generate AI-powered summaries of selected text within the editor.
  • Context Menu Integration: The 'Summarize Selection' command is now accessible via the editor's context menu, appearing when text is selected.
  • In-Editor Summary Insertion: The generated summary is automatically inserted into the active editor directly below the selected text, formatted with a clear '## Summary of Selection' header.
  • AI-Powered Summarization: Leverages an AI language model (e.g., GitHub Copilot) to create concise 2-3 sentence summaries of the selected content.
  • Robust Error Handling: Includes checks for an active editor, valid text selection, AI enablement, and language model availability, providing informative error messages to the user.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a useful 'Summarize Selection' feature. The implementation is mostly solid, with good use of progress notifications and error handling. I've identified a high-severity issue regarding cancellation token propagation which prevents the AI request from being cancelled by the user. I've also suggested a refactoring to simplify and improve the consistency of how the summary is inserted into the editor. Addressing these points will make the feature more robust and reliable.

Comment on lines 384 to 400
// Insert summary below the selection
const endPosition = selection.end;
const insertPosition = new vscode.Position(endPosition.line + 1, 0);

// Format the summary with header (extra blank line before header)
const summaryText = `\n\n## Summary of Selection\n\n${summary}\n`;

await editor.edit(editBuilder => {
// If we're at the end of a line, add a newline first
const lineText = editor.document.lineAt(endPosition.line).text;
if (endPosition.character === lineText.length) {
editBuilder.insert(new vscode.Position(endPosition.line, lineText.length), summaryText);
} else {
// Insert at the beginning of the next line
editBuilder.insert(insertPosition, summaryText);
}
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The current logic for inserting the summary is a bit complex and can lead to inconsistent vertical spacing depending on whether the selection ends at the end of a line or mid-line. This can be simplified to a single, consistent behavior by always inserting the summary at the end of the line where the selection terminates. This makes the code easier to read and ensures predictable output.

                    // Insert summary at the end of the line containing the selection's end point
                    // to ensure consistent spacing.
                    const endLine = editor.document.lineAt(selection.end.line);
                    const insertPosition = endLine.range.end;

                    // Format the summary with header (extra blank line before header)
                    const summaryText = `\n\n## Summary of Selection\n\n${summary}\n`;

                    await editor.edit(editBuilder => {
                        editBuilder.insert(insertPosition, summaryText);
                    });

jsonify and others added 2 commits December 11, 2025 09:08
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
…tion

- Add cancellation token parameter to summarizeSelection method
- Pass token from withProgress to enable proper cancellation
- Simplify insertion logic to always insert at end of selection line
@jsonify jsonify merged commit 5ca8fee into main Dec 11, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants