This is a shared transcript of a chat session with the greptileai/greptile-vscode repo.

Sign in another way

Hi! I am an expert on the greptileai/greptile-vscode repository.

Ask me anything! Need help prompting? Check out our prompt guide!

How would I add keyboard shortcuts to quickly add or remove repos from context?

To add keyboard shortcuts for quickly adding or removing repositories from the context in the greptileai/greptile-vscode codebase, you can follow these steps based on the structure and functionality provided in the chat-new-chat.tsx and related components within the /webview-ui/src/components/repo directory:

Adding Repositories with Keyboard Shortcuts

  1. Capture Keyboard Events Globally: You need to listen for keyboard events at a global level or within a specific component where it makes sense. For adding repositories, you might extend the handleKeyDown function in chat-new-chat.tsx or implement a similar function at a higher level in your application.

  2. Define Shortcut Keys: Decide on the specific keys or combination of keys that will trigger the add or remove actions. For example, you might use Ctrl + N to add a new repository.

  3. Implement the Shortcut Logic: Modify the handleKeyDown function or create a new function to handle the shortcut logic. You can use the event.key (for single keys) or a combination of checks like event.ctrlKey and event.key (for key combinations) to determine when to trigger the add or remove actions.

jsx
1const handleGlobalKeyDown = (event) => { 2 if (event.ctrlKey && event.key === 'n') { 3 // Trigger add repo logic 4 handleClone(); 5 } 6 // Add more conditions for other shortcuts 7};
  1. Attach the Event Listener: Attach the handleGlobalKeyDown function to a global event listener or to a specific component, depending on where you want the shortcut to be active.
jsx
1useEffect(() => { 2 window.addEventListener('keydown', handleGlobalKeyDown); 3 return () => { 4 window.removeEventListener('keydown', handleGlobalKeyDown); 5 }; 6}, [/* dependencies */]);

Removing Repositories with Keyboard Shortcuts

For removing repositories, you would follow a similar approach but with a few adjustments:

  1. Identify the Repository to Remove: Determine how you will identify which repository should be removed when the shortcut is triggered. This could be based on the currently selected repository or another criterion.

  2. Implement the Remove Logic: Use the deleteRepo function provided in the RepoChipActions component as a reference. You might need to access or modify the session state to remove the repository from the context.

  3. Shortcut for Removing: Define a shortcut, such as Ctrl + D, and implement the logic in your global or component-specific keydown handler.

jsx
1if (event.ctrlKey && event.key === 'd') { 2 // Logic to determine which repo to remove 3 // Trigger remove repo logic 4}

Remember to ensure that your keyboard shortcuts do not conflict with existing shortcuts in the user's environment and are intuitive to use.

Will the end user have to do anything to get the new keybindings?

For the end user to receive new keybindings for adding or removing repositories from context in the greptileai/greptile-vscode extension, the extension itself must be updated to include these keybindings in its implementation. This process typically involves:

  1. Defining Keybindings in the Extension: The extension's codebase must be updated to define the new keybindings. This could involve updating the package.json to include the keybindings under the contributes.keybindings section. However, based on the provided files, specific implementation details on adding keybindings directly within the extension's code (e.g., in vscode-utils.ts or another relevant file) were not provided.

  2. Updating the Extension: Once the keybindings are added to the extension's codebase and the extension is updated (compiled and published), end users will need to update the extension on their VS Code setup to receive these new keybindings.

  3. No Manual Setup Required by End Users: If the keybindings are predefined in the extension's update, end users will not have to perform any manual setup to use the new keybindings. They will automatically be available once the extension is updated and active.

  4. Documentation and Communication: It's important to document these new keybindings and communicate the changes to your users. This could be done through the extension's README file, changelog, or other communication channels used by your project.

If the keybindings are meant to be customizable by the end user or require some form of manual activation, instructions for doing so should be clearly provided in the extension's documentation.

Given the current context, it seems the direct implementation details for adding these keybindings within the extension's codebase (e.g., through vscode-utils.ts or another mechanism) were not explicitly provided. If the extension leverages the VS Code API for keybindings, it would typically handle this through its package.json and possibly additional TypeScript or JavaScript code for more complex logic.

Pick up where this conversation left off.

Sign in another way