Skip to content

Commit 473cb7b

Browse files
committed
fix(cli): skip update check when disableUpdateNag is true
1 parent 105ad74 commit 473cb7b

File tree

2 files changed

+45
-10
lines changed

2 files changed

+45
-10
lines changed

packages/cli/src/gemini.test.tsx

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -639,4 +639,37 @@ describe('startInteractiveUI', () => {
639639
await new Promise((resolve) => setTimeout(resolve, 0));
640640
expect(checkForUpdates).toHaveBeenCalledTimes(1);
641641
});
642+
643+
it('should not check for updates when update nag is disabled', async () => {
644+
const { checkForUpdates } = await import('./ui/utils/updateCheck.js');
645+
646+
const mockInitializationResult = {
647+
authError: null,
648+
themeError: null,
649+
shouldOpenAuthDialog: false,
650+
geminiMdFileCount: 0,
651+
};
652+
653+
const settingsWithUpdateNagDisabled = {
654+
merged: {
655+
general: {
656+
disableUpdateNag: true,
657+
},
658+
ui: {
659+
hideWindowTitle: false,
660+
},
661+
},
662+
} as LoadedSettings;
663+
664+
await startInteractiveUI(
665+
mockConfig,
666+
settingsWithUpdateNagDisabled,
667+
mockStartupWarnings,
668+
mockWorkspaceRoot,
669+
mockInitializationResult,
670+
);
671+
672+
await new Promise((resolve) => setTimeout(resolve, 0));
673+
expect(checkForUpdates).not.toHaveBeenCalled();
674+
});
642675
});

packages/cli/src/gemini.tsx

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -183,16 +183,18 @@ export async function startInteractiveUI(
183183
},
184184
);
185185

186-
checkForUpdates()
187-
.then((info) => {
188-
handleAutoUpdate(info, settings, config.getProjectRoot());
189-
})
190-
.catch((err) => {
191-
// Silently ignore update check errors.
192-
if (config.getDebugMode()) {
193-
console.error('Update check failed:', err);
194-
}
195-
});
186+
if (!settings.merged.general?.disableUpdateNag) {
187+
checkForUpdates()
188+
.then((info) => {
189+
handleAutoUpdate(info, settings, config.getProjectRoot());
190+
})
191+
.catch((err) => {
192+
// Silently ignore update check errors.
193+
if (config.getDebugMode()) {
194+
console.error('Update check failed:', err);
195+
}
196+
});
197+
}
196198

197199
registerCleanup(() => instance.unmount());
198200
}

0 commit comments

Comments
 (0)