Handle buffer overflows gracefully and truncate diffs fairly (#5083)
- Gracefully fall back to file-name summaries when staged diffs exceed node/ssh execution maxBuffer limits, preventing generation failures. - Split oversized diffs by file and allocate budget via water-filling, ensuring single huge files do not starve smaller human changes. - Clip truncated diff sections on line boundaries to avoid half-lines.
This commit is contained in:
@@ -33,6 +33,20 @@ describe('buildCommitMessagePrompt', () => {
|
||||
expect(prompt).toContain('Branch: (detached)')
|
||||
expect(prompt).toContain('Additional user prompt:\nUse Conventional Commits.')
|
||||
})
|
||||
|
||||
it('notes when the diff was omitted so the agent relies on the file list', () => {
|
||||
const prompt = buildCommitMessagePrompt(
|
||||
{
|
||||
branch: 'feature/big-diff',
|
||||
stagedSummary: 'A\thuge.jsonl',
|
||||
stagedPatch: ''
|
||||
},
|
||||
''
|
||||
)
|
||||
|
||||
expect(prompt).toContain('Staged files:\nA\thuge.jsonl')
|
||||
expect(prompt).toContain('diff omitted — too large to read')
|
||||
})
|
||||
})
|
||||
|
||||
describe('splitGeneratedCommitMessage', () => {
|
||||
|
||||
Reference in New Issue
Block a user