From 6090c3a1dc8826dce6ad9eb9fc4d1454e3502960 Mon Sep 17 00:00:00 2001 From: taehwanis <82363795+taehwanis@users.noreply.github.com> Date: Tue, 4 Aug 2026 16:56:33 +0900 Subject: [PATCH] fix: keep an existing refreshInterval when the version probe fails installStatusLine captures the existing statusLine.refreshInterval before replacing the statusLine object, but only re-applies it when supportsRefreshInterval is true. getClaudeCodeVersion() returns null - and isClaudeCodeVersionAtLeast() therefore false - whenever `claude --version` cannot be run at all: not on PATH, the 5s timeout elapses, the output does not match the version regex, or the process exits non-zero. In those cases a re-install silently drops a refreshInterval the user had set, even when the installed Claude Code does support the setting. Keep the captured value in that branch and only apply the default of 10 on supported versions, matching the behaviour documented in #297 ("preserve existing value on re-install"). Add the missing case to the install matrix: existing value + unsupported. The three existing tests cover supported/unsupported on a fresh install and supported on re-install, so this regression had no test to catch it. --- src/utils/__tests__/claude-settings.test.ts | 13 +++++++++++++ src/utils/claude-settings.ts | 10 +++++++--- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/utils/__tests__/claude-settings.test.ts b/src/utils/__tests__/claude-settings.test.ts index 0630ba2a..1b858af5 100644 --- a/src/utils/__tests__/claude-settings.test.ts +++ b/src/utils/__tests__/claude-settings.test.ts @@ -351,6 +351,19 @@ describe('installStatusLine refreshInterval', () => { await installStatusLine({ commandMode: 'auto-npx', supportsRefreshInterval: true }); expect(readInstalledRefreshInterval()).toBe(5); }); + + it('should preserve existing refreshInterval when version is unsupported', async () => { + writeRawClaudeSettings(JSON.stringify({ + statusLine: { + type: 'command', + command: CCSTATUSLINE_COMMANDS.NPM, + padding: 0, + refreshInterval: 5 + } + })); + await installStatusLine({ commandMode: 'auto-npx', supportsRefreshInterval: false }); + expect(readInstalledRefreshInterval()).toBe(5); + }); }); describe('refreshInterval', () => { diff --git a/src/utils/claude-settings.ts b/src/utils/claude-settings.ts index 8aaecfce..5ab6f7c0 100644 --- a/src/utils/claude-settings.ts +++ b/src/utils/claude-settings.ts @@ -421,9 +421,13 @@ export async function installStatusLine({ padding: 0 }; - // Only set refreshInterval if Claude Code version supports it (>=2.1.97) - if (supportsRefreshInterval) { - settings.statusLine.refreshInterval = existingRefreshInterval ?? 10; + // Default refreshInterval only on supported versions (>=2.1.97), but always keep an + // existing value - the version probe also returns false when `claude --version` fails. + const refreshInterval = supportsRefreshInterval + ? (existingRefreshInterval ?? 10) + : existingRefreshInterval; + if (refreshInterval !== undefined) { + settings.statusLine.refreshInterval = refreshInterval; } await saveClaudeSettings(settings);