fix: improve foreground process detection for macOS compatibility

Expand default foreground command list beyond node/claude to include
npx, tsx, bun, deno. Log actual detected process name for debugging.
Add configurable foregroundCommands in ~/.claude-auto-retry.json.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
CheapestInference
2026-03-29 03:52:16 +02:00
parent 35f908d3dc
commit 0652a23274
4 changed files with 26 additions and 4 deletions
+15
View File
@@ -55,6 +55,21 @@ describe('processOneTick', () => {
s.waitUntil = Date.now() - 1000; s.status = 'waiting';
assert.equal(await processOneTick(s, t, '%0', DEFAULT_CONFIG, () => true), 'skipped-not-claude');
assert.equal(t._sent.length, 0);
assert.equal(s._lastForeground, 'vim');
});
it('accepts custom foregroundCommands from config', async () => {
const t = mockTmux('5-hour limit reached - resets 3pm (UTC)', 'my-claude-wrapper');
const s = createMonitorState();
s.waitUntil = Date.now() - 1000; s.status = 'waiting';
const config = { ...DEFAULT_CONFIG, foregroundCommands: ['my-claude-wrapper'] };
assert.equal(await processOneTick(s, t, '%0', config, () => true), 'retried');
assert.equal(t._sent.length, 1);
});
it('matches npx as default foreground command', async () => {
const t = mockTmux('5-hour limit reached - resets 3pm (UTC)', 'npx');
const s = createMonitorState();
s.waitUntil = Date.now() - 1000; s.status = 'waiting';
assert.equal(await processOneTick(s, t, '%0', DEFAULT_CONFIG, () => true), 'retried');
});
it('resets counter when rate limit disappears', async () => {
const t = mockTmux('Claude is working normally');