Skip to content

Diff length truncation is hardcoded and not user-configurable #12

@SunYanbox

Description

@SunYanbox

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:

  1. 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.

  2. 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-741getBranchDiff() hardcoded maxLength = 8000
  • src/gitService.ts:788-845getFilesDiff() hardcoded maxLength = 8000
  • src/projectConfig.tsProjectSettings interface (needs new field)
  • src/inputService.ts — callers pass filesDiff to AI without length awareness

Suggested Solution

  1. Add maxDiffLength?: number (default 500000) to the ProjectSettings interface in src/projectConfig.ts
  2. Load the config value and pass it as maxLength in all getBranchDiff / getFilesDiff calls
  3. 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
  4. Improve the truncation suffix from ...(diff truncated) to include total-available-info (e.g., ...(truncated: showing 500K of 2.1M total diff))
  5. Log a warning when truncation occurs so users are aware

No implementation required — design discussion only.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions