Description
Diff length truncation logic is scattered and inconsistent:
| Function |
Default Max Length |
Configurable |
getBranchDiff() (line 720) |
8000 chars |
Hardcoded parameter default |
getFilesDiff() (line 788) |
8000 chars |
Hardcoded parameter default |
Two specific problems:
-
8000 chars is too short for meaningful AI-generated commit messages / PR descriptions on any moderately sized change. Large diffs get truncated heavily, losing context. But without a hard cap, extreme cases (thousands of lines changed) would blow up token usage.
-
No user configuration — users cannot tune the limit based on their project size or AI token budget. The limit should be stored in .quick-pr-studio/settings.json under ProjectSettings.
Affected Code
src/gitService.ts:720-741 — getBranchDiff() hardcoded maxLength = 8000
src/gitService.ts:788-845 — getFilesDiff() hardcoded maxLength = 8000
src/projectConfig.ts — ProjectSettings interface (needs new field)
src/inputService.ts — callers pass filesDiff to AI without length awareness
Suggested Solution
- Add
maxDiffLength?: number (default 500000) to the ProjectSettings interface in src/projectConfig.ts
- Load the config value and pass it as
maxLength in all getBranchDiff / getFilesDiff calls
- Also enforce per-file diff limits roughly proportional to the total (e.g., each file gets at most
totalLimit / fileCount), so one massive file doesn't starve others
- Improve the truncation suffix from
...(diff truncated) to include total-available-info (e.g., ...(truncated: showing 500K of 2.1M total diff))
- Log a warning when truncation occurs so users are aware
No implementation required — design discussion only.
Description
Diff length truncation logic is scattered and inconsistent:
getBranchDiff()(line 720)getFilesDiff()(line 788)Two specific problems:
8000 chars is too short for meaningful AI-generated commit messages / PR descriptions on any moderately sized change. Large diffs get truncated heavily, losing context. But without a hard cap, extreme cases (thousands of lines changed) would blow up token usage.
No user configuration — users cannot tune the limit based on their project size or AI token budget. The limit should be stored in
.quick-pr-studio/settings.jsonunderProjectSettings.Affected Code
src/gitService.ts:720-741—getBranchDiff()hardcodedmaxLength = 8000src/gitService.ts:788-845—getFilesDiff()hardcodedmaxLength = 8000src/projectConfig.ts—ProjectSettingsinterface (needs new field)src/inputService.ts— callers passfilesDiffto AI without length awarenessSuggested Solution
maxDiffLength?: number(default500000) to theProjectSettingsinterface insrc/projectConfig.tsmaxLengthin allgetBranchDiff/getFilesDiffcallstotalLimit / fileCount), so one massive file doesn't starve others...(diff truncated)to include total-available-info (e.g.,...(truncated: showing 500K of 2.1M total diff))No implementation required — design discussion only.