Skip to content

Conversation

@ammar-agent
Copy link
Collaborator

Add optional niceness parameter to the executeBash IPC call for controlling process priority. This parameter is only available at the IPC level and is not exposed to agents in tool descriptions.

Changes

  • Add niceness parameter to IPC interface: Added optional niceness parameter to executeBash options (accepts -20 to 19, where lower = higher priority)
  • Wire through stack: Parameter flows from IPC → ipcMain handler → bash tool → process spawn
  • Bash tool implementation: When niceness is specified, commands are wrapped with nice -n <value>
  • Frontend git operations: Set all git-related executeBash calls to use niceness 19 (lowest priority) to prevent background operations from interfering with user interactions
  • Auto-dependency installation: Added ensure-deps Makefile target that automatically runs bun install if node_modules doesn't exist

Technical Details

When niceness is provided, the bash tool wraps commands like:

nice -n 19 bash -c "original command"

All git operations in GitStatusContext and GitStatusIndicator now run at lowest priority:

  • Git fetch (30s timeout)
  • Git status checks (5s timeout)
  • Git diff operations (5s timeout)

Generated with cmux

- Add optional niceness parameter to executeBash IPC interface
- Wire through ipcMain handler to bash tool configuration
- Bash tool wraps commands with nice when niceness is specified
- Parameter only available at IPC level, not exposed to agents
- Add ensure-deps Makefile target to auto-install dependencies
Set niceness to 19 (lowest priority) for all git-related executeBash
calls in the frontend to prevent background git operations from
interfering with user interactions.
@ammario ammario added this pull request to the merge queue Oct 10, 2025
Merged via the queue into main with commit af6ad38 Oct 10, 2025
7 checks passed
@ammario ammario deleted the bash-nice branch October 10, 2025 18:14
sreya pushed a commit that referenced this pull request Nov 15, 2025
Fixes the regression introduced in PR #162 where complex multi-line bash
scripts with conditionals would fail with exit code 2.

## Problem

The original implementation wrapped commands using `JSON.stringify`,
which converted newlines to literal `\n` strings:
```bash
nice -n 19 bash -c "if [ \0 -ne 0 ]; then\n  echo \"test\"\nfi"
```

This broke bash syntax, causing scripts with conditionals and multi-line
logic to fail.

## Solution

Spawn `nice` directly with proper arguments array instead of string
wrapping:
```typescript
spawn("nice", ["-n", "19", "bash", "-c", script], ...)
```

This avoids all escaping issues while maintaining the same niceness
functionality.

## Testing

Added comprehensive test coverage:
- ✅ Complex multi-line scripts with conditionals (reproduces the git
status regression)
- ✅ Exit code handling with niceness
- ✅ Simple commands with niceness

All 36 tests pass including the new niceness test suite.

_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