continue icon indicating copy to clipboard operation
continue copied to clipboard

`sdk.ide.Diff()` returns nothing even when `git diff --cached` does

Open cristoslc opened this issue 1 year ago • 3 comments

Before submitting your bug report

Relevant environment info

- OS:macOS 14.5
- Continue: v0.8.27
- IDE: VSCode 1.89.1

Description

tried implementing the example from https://docs.continue.dev/customization/slash-commands#custom-slash-commands-1 and it keeps returning a null diff, even when I have staged changes. I put together https://gist.github.com/cristoslc/0d9a555f3aab9d27ca6f2e3e60294d64 which tries git diff --cached, and that's returning what I expect when I have staged files.

To reproduce

  1. Implement https://docs.continue.dev/customization/slash-commands#custom-slash-commands-1 in your config.ts
  2. run custom slash command EXPECTED: Commit message summarizing diff ACTUAL: Response indicating LLM did not receive any diff

WORKAROUND: https://gist.github.com/cristoslc/0d9a555f3aab9d27ca6f2e3e60294d64 Workaround uses git diff --cached in the project folder and works as expected.

Log output

[Extension Host]% {text: 'const { exec } = require("child_process");\nconst {…rn config;\n}\n\nmodule.exports = { modifyConfig };\n'}
console.ts:137 [Extension Host]% {text: 'export function modifyConfig(config: Config): Conf…ssage;\n      }\n    },\n  });\n  return config;\n}\n\n\n'}
console.ts:137

cristoslc avatar May 15 '24 16:05 cristoslc

Discord ref: https://discord.com/channels/1108621136150929458/1108621136830398496/1240360160766066779

looks like it's only showing unstaged changes. looking into this now

cristoslc avatar May 15 '24 21:05 cristoslc

Relevant line of code is here:

https://github.com/continuedev/continue/blob/preview/extensions/vscode/src/util/ideUtils.ts#L593-L594

It looks like the one arg to this function is whether or not to use caching

sestinj avatar May 15 '24 21:05 sestinj

So it seems like this cache parameter actually is a "staged or not staged" parameter after having tested it a bunch. I'm weary of this, probably there's some reason something staged would be cached, but haven't found the behavior to be otherwise yet. So this commit is my solution for now, but I'm going to keep my eye on it. The thing to look for at this point would be duplication

https://github.com/continuedev/continue/commit/b5052a3176af984dc82aa6a8994aefce6b3de0fc

sestinj avatar May 15 '24 22:05 sestinj

I noticed this problem myself, just trying to use @Git Diff summarize this commit for me in the chat panel. I assume it's the same problem, because all of the files in the commit were new, and staged to be committed. Because they're all new (untracked) files, even running git diff from the terminal shows no diff. If I stage them (adding them to the index), then git diff also shows no changes, because they're already staged. I think what would be nice is for @Git Diff to use git diff --cached to just look at the staged changes (that way I can control exactly what I want it to summarize for me).

If I should open a separate ticket for this, let me know. It looks like your proposed solution is to include staged and unstaged changes in the context, which would also be fine I suppose. It still doesn't include untracked files, and doesn't allow as much control (in terms of what changes are being included), but it would work well for 90% of cases.

mltsy avatar Jun 03 '24 15:06 mltsy