continue
continue copied to clipboard
`sdk.ide.Diff()` returns nothing even when `git diff --cached` does
Before submitting your bug report
- [X] I believe this is a bug. I'll try to join the Continue Discord for questions
- [X] I'm not able to find an open issue that reports the same bug
- [X] I've seen the troubleshooting guide on the Continue Docs
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
- Implement https://docs.continue.dev/customization/slash-commands#custom-slash-commands-1 in your config.ts
- 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
Discord ref: https://discord.com/channels/1108621136150929458/1108621136830398496/1240360160766066779
looks like it's only showing unstaged changes. looking into this now
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
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
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.