Skip to content

Conversation

@ammar-agent
Copy link
Collaborator

Fixes console log spam from background git status polling operations.

Problem

GitStatusStore and GitStatusIndicator poll git status every 3 seconds. When output exceeds the 16KB limit, the bash tool writes full output to temp files, causing console spam:

[gitStatus] Script failed: [OUTPUT OVERFLOW - ...]
Full output saved to /var/folders/.../bash-ffe12c1a.txt

Background operations don't need full output - they just fail silently.

Solution

Added overflow_policy: 'truncate' | 'tmpfile' configuration option:

  • 'truncate' - Returns first 50 lines inline, no temp file (for background ops)
  • 'tmpfile' - Writes full output to temp file (default, for AI operations)

The option is NOT exposed to AI - it's only available through internal configuration.

Changes

  • Added overflow_policy? to ToolConfiguration interface
  • Updated bash.ts to branch on policy when handling overflow
  • Plumbed through IPC types and handlers
  • Applied overflow_policy: 'truncate' to GitStatusStore and GitStatusIndicator

Testing

  • Added 2 new tests verifying both policies
  • All 504 tests pass
  • Verified AI tool schema doesn't expose the parameter

Generated with cmux

Add `overflow_policy: 'truncate' | 'tmpfile'` option to bash execution
that prevents temp file spam from background git status polling.

## Problem

GitStatusStore and GitStatusIndicator poll git status every 3 seconds.
When output exceeds 16KB limit, bash tool writes full output to temp
files, causing console spam:

```
[gitStatus] Script failed: [OUTPUT OVERFLOW - ...]
Full output saved to /var/folders/.../bash-ffe12c1a.txt
```

Background operations don't need full output - they just fail silently.

## Solution

Add `overflow_policy` config option (not exposed to AI):
- `'truncate'` - Return first 50 lines inline, no temp file
- `'tmpfile'` - Current behavior (default for AI operations)

## Changes

1. **Core implementation** (bash.ts):
   - Check `config.overflow_policy ?? 'tmpfile'` in truncation handler
   - Truncate: return first 50 lines with error message
   - Tmpfile: write full output to temp file (default behavior)

2. **Type plumbing**:
   - Add `overflow_policy?` to ToolConfiguration interface
   - Pass through IPC types and ipcMain handler
   - NOT exposed in AI tool schema (verified)

3. **Usage**:
   - GitStatusStore: use `overflow_policy: 'truncate'` for status checks
   - GitStatusStore: use `overflow_policy: 'truncate'` for git fetch
   - GitStatusIndicator: use `overflow_policy: 'truncate'` for popover

## Testing

Added 2 new tests:
- Verify truncate policy returns first 50 lines, no temp file
- Verify default (no policy) uses tmpfile behavior

All 504 tests pass. Typecheck passes.

_Generated with `cmux`_
All executeBash IPC calls are from UI (background operations).
AI uses bash tool directly (not through IPC), so always gets tmpfile.

Simplifications:
- Remove overflow_policy from IPC types
- Hardcode overflow_policy: 'truncate' in ipcMain handler
- Remove overflow_policy from all call sites (GitStatusStore, GitStatusIndicator)

Result: Same behavior, less configuration surface area.

_Generated with `cmux`_
@ammario ammario enabled auto-merge October 15, 2025 00:38
@ammario ammario added this pull request to the merge queue Oct 15, 2025
Merged via the queue into main with commit b84f658 Oct 15, 2025
7 checks passed
@ammario ammario deleted the git-status branch October 15, 2025 00:48
github-merge-queue bot pushed a commit that referenced this pull request Oct 15, 2025
Reduces console noise from background git status polling by increasing
the bash truncate limit.

## Changes

### Increase bash truncate limit to 80 lines

Changed from 50 → 80 lines for the `truncate` overflow policy. This
provides better debugging context for git status output while still
preventing excessive spam.

**Before (50 lines):**
- Too restrictive for useful debugging
- Git status output often cut off mid-info

**After (80 lines):**
- Provides better context for git operations
- Still prevents console flooding
- Only affects IPC bash calls (background operations)

## Note on SHOW_BRANCH truncation

Initially considered truncating `git show-branch` output before parsing,
but this would break ahead/behind counting in
`parseGitShowBranchForStatus` which iterates all commit lines. The
80-line truncate limit is sufficient for most cases, and the `truncate`
overflow policy ensures we don't spam temp files.

## Dependencies

Built on top of #256 which adds the `overflow_policy` feature.

_Generated with `cmux`_
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.

2 participants