Description
When commit-echo suggest --commit runs with no staged changes, the user is offered to use unstaged changes. The auto-commit (--yes) path guards this with if (!diffResult.staged) and errors out, but the interactive path does not. The user then selects a suggestion and confirms the commit, and git commit -F runs against an empty index → confusing nothing to commit failure (or, if unrelated files got staged meanwhile, a commit whose content doesn't match the diff the LLM analyzed).
Location
src/commands/suggest.ts lines 334–341 (auto-commit guard) vs. lines 391–392 (interactive path, missing guard)
Code
// Guarded path (autoCommit):
if (!diffResult.staged) {
outro(pc.red('Auto-commit requires staged changes. Stage your changes with `git add` and try again.'));
process.exit(1);
}
await acceptAndCommit(first, config, diffResult.diff, true);
// Unguarded path (interactive):
if (shouldCommit) {
await acceptAndCommit(selected, config, diffResult.diff); // diffResult.staged === false here
}
Suggested fix
Add the same diffResult.staged check before acceptAndCommit in the interactive shouldCommit branch, and return without exiting (or exit cleanly) with a message telling the user to stage changes.
Impact
Users running suggest --commit interactively on unstaged work hit a git error mid-flow, or worse, commit the wrong content if the index changes between the diff snapshot and the commit.
Description
When
commit-echo suggest --commitruns with no staged changes, the user is offered to use unstaged changes. The auto-commit (--yes) path guards this withif (!diffResult.staged)and errors out, but the interactive path does not. The user then selects a suggestion and confirms the commit, andgit commit -Fruns against an empty index → confusingnothing to commitfailure (or, if unrelated files got staged meanwhile, a commit whose content doesn't match the diff the LLM analyzed).Location
src/commands/suggest.tslines 334–341 (auto-commit guard) vs. lines 391–392 (interactive path, missing guard)Code
Suggested fix
Add the same
diffResult.stagedcheck beforeacceptAndCommitin the interactiveshouldCommitbranch, and return without exiting (or exit cleanly) with a message telling the user to stage changes.Impact
Users running
suggest --commitinteractively on unstaged work hit a git error mid-flow, or worse, commit the wrong content if the index changes between the diff snapshot and the commit.