Skip to content
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

Command: new experimental command for generating commit messages #4130

Merged
merged 28 commits into from May 14, 2024

Conversation

abeatrix
Copy link
Contributor

@abeatrix abeatrix commented May 10, 2024

The commit introduces a new experimental Cody command for generating commit messages:

image
  • cody.command.generate-commit: Generates a commit message based on the staged changes.
  • cody.command.abort-commit: Aborts the commit message generation process.

The commands are available in the Source Control view and the Command Palette when a Git repository is open.

(This commit was generated by the new Cody command 😍 )

TBD

  • Should we keep generating commit without including the ignored items? Current behavior is to display the error in the input box to let user know that there is an ignored file included.
  • If there is no staged files, should we still generate commit for unstaged files?

Test plan

New feature covered by a new e2e test.

Manual Tests

From the Cody Commands sidebar

cody_commit

  1. Start Cody in dev mode from this branch
  2. Make some changes in your editor, and leave them unstaged
  3. Click on the Generate Commit in the Cody Commands sidebar
  4. You should be redirected to the Source Control sidebar
  5. The Source Control panel will be focused, and Cody's response will start streaming into the input box directly
  6. Verify Cody's response

From the Source Control sidebar

commit_pr

  1. Start Cody in dev mode from this branch
  2. Make some changes in your editor, and leave them unstaged
  3. Open the Source Control sidebar, and make sure the commit input is empty
  4. Hover over the commit input box to see Cody icon shows up in the title bar
  5. Click on the Cody icon in the title bar
  6. Cody's response will start streaming into the input box directly
  7. Verify Cody's response

When an ignored file is detected

codycommit

  1. Start Cody in dev mode from this branch
  2. Make changes in a Cody ignored file
  3. Click on the Generate Commit in the Cody Commands sidebaror Cody icon in the Source Control panel.
  4. You should be redirected to the Source Control sidebar
  5. The Source Control panel will be focused
  6. An error message will show up about the ignored file

The commit introduces a new experimental Cody command for generating commit messages:

- `cody.command.generate-commit`: Generates a commit message based on the staged changes.
- `cody.command.abort-commit`: Aborts the commit message generation process.

The commands are available in the Source Control view and the Command Palette when a Git repository is open.
@abeatrix abeatrix requested review from umpox, RXminuS and a team May 10, 2024 01:33
Copy link
Contributor

@umpox umpox left a comment

Choose a reason for hiding this comment

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

Nice, left some comments of things I think we should do. I won't get further than this today (need to look into Edit issues on JetBrains), but will take a look next week hopefully.

Also cc @toolmantim for a design review here

vscode/package.json Show resolved Hide resolved
vscode/package.json Show resolved Hide resolved
vscode/package.json Outdated Show resolved Hide resolved
vscode/src/commands/context/git-api.ts Outdated Show resolved Hide resolved
vscode/package.json Outdated Show resolved Hide resolved
vscode/src/commands/scm/source-control.ts Show resolved Hide resolved
vscode/src/commands/scm/source-control.ts Show resolved Hide resolved
* @param abortController - An optional `AbortController` instance to use for aborting the current commit generation.
*/
private statusUpdate(abortController?: AbortController): void {
const isGenerating = abortController !== undefined
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we possibly use something more specific? Like this.inProgress instead of checking for the presence of an abortController

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@RXminuS and i chatted about this earlier and we think this is easier because we will still need to reset the abortController if we switch to use this.inProgress, but we can still change it if you don't agree :)

vscode/src/commands/scm/source-control.ts Outdated Show resolved Hide resolved
vscode/src/commands/scm/source-control.ts Show resolved Hide resolved
@umpox
Copy link
Contributor

umpox commented May 10, 2024

Also, idea: We should use the typewriter lib/shared/src/chat/typewriter.ts to make the streaming of the text into the input box more fluid

RXminuS and others added 7 commits May 10, 2024 15:44
Show a placeholder text in the source control input box while generating the commit message using AI. This improves the user experience by providing feedback that the operation is in progress.

Additionally, this commit handles a case where the source control input box does not have a placeholder property, and falls back to updating the value instead.
…t message generation

The Typewriter is used in the streaming function, where it replaces the direct updates to the input box. This approach improves the user experience by providing a more natural typing effect and feedback that the operation is in progress.
Co-authored-by: Tom Ross <tom@umpox.com>
@abeatrix abeatrix marked this pull request as ready for review May 11, 2024 06:24
@abeatrix abeatrix requested a review from umpox May 11, 2024 06:24
Copy link
Contributor

@umpox umpox left a comment

Choose a reason for hiding this comment

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

Awesome, great team effort! @abeatrix and @RXminuS

I think it's looking really good, the only thing I'm a little unsure about is the prompt right now. Still feels quite long, WDYT @RXminuS?

Happy to merge and iterate on this though :)

@RXminuS
Copy link
Contributor

RXminuS commented May 13, 2024

I think let's merge the function and then iterate on the response quality. We can then also add a few different prompts and some metrics on which one's gets comitted as suggested (or hamming distance?).

@umpox
Copy link
Contributor

umpox commented May 13, 2024

@RXminuS Sounds good, anything you want to add, or happy to merge this?

@RXminuS
Copy link
Contributor

RXminuS commented May 13, 2024

I still need to merge my e2e test fix I think because they don't pass yet right?

@umpox
Copy link
Contributor

umpox commented May 13, 2024

@RXminuS 👍 yep (only just noticed lol :D)

vscode/src/commands/scm/prompts.ts Outdated Show resolved Hide resolved
vscode/test/e2e/command-commit.test.ts Outdated Show resolved Hide resolved
vscode/test/e2e/command-commit.test.ts Show resolved Hide resolved
RXminuS and others added 6 commits May 14, 2024 11:40
Improve the logic for verifying file existence in the git diff context by checking the reverse path. This addresses issues with nested workspaces that may add unknown prefixes to the file paths.

Also, add a check to ensure the git diff output is not empty before processing the results.
@RXminuS RXminuS merged commit d67bb32 into main May 14, 2024
19 checks passed
@RXminuS RXminuS deleted the bee/commit-command branch May 14, 2024 15:40
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.

None yet

3 participants