Skip to content

fix: prevent UI freeze on large repos with timeout protection and adaptive polling#20

Draft
Claude wants to merge 2 commits intomasterfrom
claude/fix-large-repo-issue
Draft

fix: prevent UI freeze on large repos with timeout protection and adaptive polling#20
Claude wants to merge 2 commits intomasterfrom
claude/fix-large-repo-issue

Conversation

@Claude
Copy link
Contributor

@Claude Claude AI commented Mar 11, 2026

Summary

  • Add 30s timeout to all git operations to prevent hung processes from freezing the UI
  • Increase buffer limits from 5MB/10MB to 50MB to handle repos with hundreds of thousands of files
  • Implement adaptive polling: 15s interval for slow repos (>5s refresh), 3s for normal repos
  • Detect and warn when .git directories exceed 10GB with actionable user guidance

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ⚡ Performance improvement

Related Issues

Addresses issue where opening large repositories (3GB code, 16GB .git) caused system freeze.

How to Test

  1. Open a large repository (multi-GB .git directory)
  2. Verify console shows warning for .git >10GB
  3. Monitor git operations complete within 30s (check DevTools Network/Console)
  4. Confirm polling switches to 15s interval after first slow refresh (>5s)
  5. Verify UI remains responsive during git operations

Screenshots / Screen Recording

N/A - performance/timeout fix with console warnings

Technical Details

Timeout Protection (electron/src/lib/git-exec.ts):

// Before: no timeout, 5MB buffer
execFile("git", args, { cwd, maxBuffer: 5 * 1024 * 1024 }, ...);

// After: 30s timeout, 50MB buffer
const timeout = options?.timeout ?? 30000;
const maxBuffer = options?.maxBuffer ?? 50 * 1024 * 1024;
execFile("git", args, { cwd, maxBuffer, timeout }, ...);

Adaptive Polling (src/hooks/useGitStatus.ts):

  • Track refresh duration per repo: duration = performance.now() - startTime
  • Mark repos taking >5s as isLargeRepo: true
  • Adjust interval: pollInterval = hasLargeRepo ? 15000 : 3000

Size Detection (electron/src/ipc/git.ts):

  • New getGitDirSize() IPC handler using du -sk .git with 5s timeout
  • Console warning when .git exceeds 10GB with worktree/shallow clone suggestions

Checklist

  • I've tested this on macOS (required for Electron/native features)
  • TypeScript compiles with no errors (pnpm build)
  • No any types introduced
  • Logical margins used (ms-*/me-* instead of ml-*/mr-*)
  • User-generated content containers have wrap-break-word
  • New shared types go in shared/types/, not src/types/
  • Large components/hooks are decomposed into sub-components/sub-hooks if needed
Original prompt

This section details on the original issue you should resolve

<issue_title>[Bug]: Unable to use on a large repo</issue_title>
<issue_description>### Description

I tried opening a large repo (3GB of code, 16GB of .git) and it basically took down my computer. I couldn't even take a look at processes, my Acitivity Monitor stalled. 🙃

Steps to Reproduce

Open a large repo as a project.

Expected Behavior

It works

Actual Behavior

It doesn't work

AI Engine

Not engine-specific

Operating System

macOS (Apple Silicon)

Harnss Version

0.17.4

Area

No response

Logs / Error Output


Additional Context

No response</issue_description>

<agent_instructions>Deeply analyze what may be causing such behavior.</agent_instructions>

Comments on the Issue (you are @claude[agent] in this section)

@OpenSource03 Did you make sure to check latest https://github.com/OpenSource03/harnss/releases/tag/v0.18.1?

I have a new release coming soon heavily focusing on performance too.</comment_new>

- Add 30s default timeout to all git commands to prevent hung processes
- Increase git command buffer sizes from 5MB/10MB to 50MB for large repos
- Make git status polling adaptive: 15s interval for slow repos (>5s refresh), 3s for normal repos
- Add getGitDirSize IPC handler to detect very large .git directories
- Track refresh duration per repo and mark repos as "large" if refresh takes >5s
- Warn in console when detecting .git directories >10GB
- Update RepoState interface to track isLargeRepo and lastRefreshDuration

Co-authored-by: OpenSource03 <29690431+OpenSource03@users.noreply.github.com>
@Claude Claude AI changed the title [WIP] Fix bug preventing usage of large repos fix: prevent UI freeze on large repos with timeout protection and adaptive polling Mar 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Unable to use on a large repo

2 participants